content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Tips on upgrading to python 3.0?
So with the final releases of Python 3.0 (and now 3.1), a lot of people are facing the worry of how to upgrade without losing half their codebase due to backwards incompatibility.
What are people's best tips for avoiding the many pitfalls that will almost-inevitably result from swi... | Tips on upgrading to python 3.0? | So with the final releases of Python 3.0 (and now 3.1), a lot of people are facing the worry of how to upgrade without losing half their codebase due to backwards incompatibility.
What are people's best tips for avoiding the many pitfalls that will almost-inevitably result from switching to the next-generation of pytho... | [
"First, this question is very similar to How are you planning on handling the migration to Python 3?. Check the answers there.\nThere is also a section in the Python Wiki about porting applications to Python 3.x\nThe Release Notes for python 3.0 contains a section about porting. I'm quoting the tips there:\n\n\n(P... | [
3,
3,
2
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0001072028_python_python_3.x.txt |
Q:
see if two files have the same content in python
Possible Duplicates:
Finding duplicate files and removing them.
In Python, is there a concise way of comparing whether the contents of two text files are the same?
What is the easiest way to see if two files are the same content-wise in Python.
One thing I can do ... | see if two files have the same content in python |
Possible Duplicates:
Finding duplicate files and removing them.
In Python, is there a concise way of comparing whether the contents of two text files are the same?
What is the easiest way to see if two files are the same content-wise in Python.
One thing I can do is md5 each file and compare. Is there a better way?... | [
"Yes, I think hashing the file would be the best way if you have to compare several files and store hashes for later comparison. As hash can clash, a byte-by-byte comparison may be done depending on the use case.\nGenerally byte-by-byte comparison would be sufficient and efficient, which filecmp module already does... | [
168,
6
] | [] | [] | [
"file",
"python"
] | stackoverflow_0001072569_file_python.txt |
Q:
Playing MMS streams within Python
I'm writing a XM desktop application (I plan on releasing the source on github when I'm finished if anyone is interested) Anyway, the one part I know very little about is how to play media within Python (I'm using PyQt for the frontend). Basically, I have a mms:// url that I need ... | Playing MMS streams within Python | I'm writing a XM desktop application (I plan on releasing the source on github when I'm finished if anyone is interested) Anyway, the one part I know very little about is how to play media within Python (I'm using PyQt for the frontend). Basically, I have a mms:// url that I need to play. I was wondering if there is a ... | [
"You can have a look at \n\nPyMedia\nPyGame\nwxPython\n\nHere is a code snippet of doing a similar thing with wxPython.\nAll of these can play media files.\n"
] | [
2
] | [] | [] | [
"audio_streaming",
"mms",
"pyqt",
"python",
"streaming"
] | stackoverflow_0001072652_audio_streaming_mms_pyqt_python_streaming.txt |
Q:
Printing python modulus operator as it is over command line
I want to print modulus operator as it is over the command line:
E.g this is how the output should look like:
1%2
2%4
or
30%
40%
I am using the print statement like this:
print 'computing %s % %s' % (num1,
num2)
Its throwing the default error:
TypeEr... | Printing python modulus operator as it is over command line | I want to print modulus operator as it is over the command line:
E.g this is how the output should look like:
1%2
2%4
or
30%
40%
I am using the print statement like this:
print 'computing %s % %s' % (num1,
num2)
Its throwing the default error:
TypeError: not all arguments
converted during string formatting
For ... | [
"Escape the % sign with another % sign, like this:\nprint 'computing %s %% %s' % (num1, num2)\n\n",
"print 'computing %s %% %s' % (num1, num2)\n\n"
] | [
9,
1
] | [] | [] | [
"modulo",
"operators",
"python"
] | stackoverflow_0001072951_modulo_operators_python.txt |
Q:
date is added in background while adding time in datastore GAE
3.Why does "jan 1st 1970" gets added in the startime field in datastore when I am doing the below statements?
(hour,min) = self.request.get('starttime').split(":")
#if either of them is null or empty string then int will throw exception
if ... | date is added in background while adding time in datastore GAE | 3.Why does "jan 1st 1970" gets added in the startime field in datastore when I am doing the below statements?
(hour,min) = self.request.get('starttime').split(":")
#if either of them is null or empty string then int will throw exception
if hour and min :
datastoremodel.starttime = datetime.time(int(... | [
"google app engine doc says\nclass TimeProperty(verbose_name=None, auto_now=False, auto_now_add=False, ...)\nA time property, without a date. Takes a Python standard library datetime.time value. See DateTimeProperty for more information.\nValue type: datetime.time. This is converted to a datetime.datetime internall... | [
2
] | [] | [] | [
"datetime",
"google_app_engine",
"python"
] | stackoverflow_0001072877_datetime_google_app_engine_python.txt |
Q:
Calculate score in a pyramid score system
I am trying to calculate gamescores for a bunch over users and I haven't really got it yet. It is a pyramid game where you can invite people, and the people you invite is placed beneth you in the relations tree.
So if i invite X and X invites Y i get kickback from both of ... | Calculate score in a pyramid score system | I am trying to calculate gamescores for a bunch over users and I haven't really got it yet. It is a pyramid game where you can invite people, and the people you invite is placed beneth you in the relations tree.
So if i invite X and X invites Y i get kickback from both of them. Let's say 10%^steps...
So from X i get 10... | [
"I doubt these two lines\nscore += child.points*math.pow(.1, get_ancestors(child))\nscore += get_score(child)\n\nthis is a simple recursive structure so i think something like below will suffice\nscore += get_score(child)*.1\n\nand recursive beauty will take care of itself\nyou also do not need 'if children:' chec... | [
2,
0
] | [] | [] | [
"python",
"recursion"
] | stackoverflow_0001072977_python_recursion.txt |
Q:
Updating one aspect of a Pygame surface
I have an application written in python that's basically an etch-a-sketch, you move pixels around with WASD and arrow keys and it leaves a trail. However, I want to add a counter for the amount of pixels on the screen. How do I have the counter update without updating the en... | Updating one aspect of a Pygame surface | I have an application written in python that's basically an etch-a-sketch, you move pixels around with WASD and arrow keys and it leaves a trail. However, I want to add a counter for the amount of pixels on the screen. How do I have the counter update without updating the entire surface and pwning the pixel drawings?
| [
"Use Surface.blit(source, dest, area=None, special_flags = 0): return Rect\ndest can be a pair of coordinates representing the upper left corner of the source.\nYou probably want to erase the your old counter value, before you blit the new one. For this you can capture the background before you blit your counter va... | [
1
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0001072639_pygame_python.txt |
Q:
Form Initialization with ToscaWidgets
Question:
How do I prefill a CheckBoxTable from ToscaWidgets with values.
Background:
I've looked everywhere and I can't seem to figure out how to initialize a particular form field with ToscaWidgets. Most form fields seem to respond just fine to initialization, like if I cre... | Form Initialization with ToscaWidgets | Question:
How do I prefill a CheckBoxTable from ToscaWidgets with values.
Background:
I've looked everywhere and I can't seem to figure out how to initialize a particular form field with ToscaWidgets. Most form fields seem to respond just fine to initialization, like if I create a form with a single TextField in it wh... | [
"set them via the value param. \nimport tw.forms\nf = tw.forms.TableForm(fields=[tw.forms.CheckBoxTable(\"name\",options=((\"foo\"),(\"bar\")))]) \nf(value={\"name\":{\"foo\":True,\"bar\":False}})\n>>> u'<form xmlns=\"http://www.w3.org/1999/xhtml\" action=\"\" method=\"post\" class=\"tableform\">\\n <table borde... | [
1
] | [] | [] | [
"forms",
"mako",
"python",
"toscawidgets",
"turbogears"
] | stackoverflow_0001071277_forms_mako_python_toscawidgets_turbogears.txt |
Q:
How to reduce color palette with PIL
I'm not sure how I would go about reducing the color palette of a PIL Image. I would like to reduce an image's palette to the 5 prominent colors found in that image. My overall goal is to do some basic color sampling.
A:
That's easy, just use the undocumented colors argument:... | How to reduce color palette with PIL | I'm not sure how I would go about reducing the color palette of a PIL Image. I would like to reduce an image's palette to the 5 prominent colors found in that image. My overall goal is to do some basic color sampling.
| [
"That's easy, just use the undocumented colors argument:\nresult = image.convert('P', palette=Image.ADAPTIVE, colors=5)\n\nI'm using Image.ADAPTIVE to avoid dithering\n",
"I assume you want to do something more sophisticated than posterize. \"Sampling\" as you say, will take some finesse, as the 5 most common co... | [
39,
5,
3
] | [] | [] | [
"colors",
"image",
"palette",
"python",
"python_imaging_library"
] | stackoverflow_0001065945_colors_image_palette_python_python_imaging_library.txt |
Q:
Pyinstaller traceback
Traceback (most recent call last):
File "<string>", line 137, in <module>
File C:\Python26\buildSVG_Resizer\out1.pyz/encodings", line 100, in search_function
TypeError: importHook() got an unexpected keyword argument 'level'
The imports in my .py file are:
import xml.etree.ElementTree as ET... | Pyinstaller traceback | Traceback (most recent call last):
File "<string>", line 137, in <module>
File C:\Python26\buildSVG_Resizer\out1.pyz/encodings", line 100, in search_function
TypeError: importHook() got an unexpected keyword argument 'level'
The imports in my .py file are:
import xml.etree.ElementTree as ET
import os, stat
import tkF... | [
"importHook in iu.py (top level of pyinstaller) does accept a level= named argument, so the message is quite perplexing and suggests a bad installation.\nWhat output do you get from cd'ing to pyinstaller's top directory and doing:\nsvn log -r HEAD\n\n? Should currently be \nr685 | giovannibajo | 2009-06-30 05:19:5... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0001074144_python.txt |
Q:
Learning Python for a .NET developer
I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.
I've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard pl... | Learning Python for a .NET developer | I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.
I've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard platform we use.
There are some legacy Pytho... | [
"Foord and Muirhead's IronPython in Action is an amazingly good book, perfectly suitable for teaching Python to .NET folks as well as teaching .NET to Python folks. I may be biased, as I was a tech reviewer and Foord is a friend, but I've had other cases in the past where a friend wrote a book and I tech reviewed i... | [
22,
8,
4,
3,
3,
2,
2,
2
] | [] | [] | [
".net",
"c#",
"dynamic_languages",
"python"
] | stackoverflow_0001072530_.net_c#_dynamic_languages_python.txt |
Q:
Does anyone know of source code for a web based study group?
I'm looking for source code for a web based study group. I'd prefer something in Python or C#. I have searched google but I'm finding mostly existing study groups on particular topics and not software to host an online study group.
Can anyone help out?
... | Does anyone know of source code for a web based study group? | I'm looking for source code for a web based study group. I'd prefer something in Python or C#. I have searched google but I'm finding mostly existing study groups on particular topics and not software to host an online study group.
Can anyone help out?
Edit: Ah, I was unfamiliar with the buzzwords "Learning Managemen... | [
"I am not quite sure what you mean by \"host an online study group\".\nIf it is about people collaborate to learn something, I think moodle is what you are looking for.\nHere is the wikipedia lemma for moodle:\n\nMoodle is a free and open source\n e-learning software platform, also\n known as a Course Management ... | [
4,
0
] | [] | [] | [
"c#",
"python"
] | stackoverflow_0001071433_c#_python.txt |
Q:
How do I find the memory address of a Python / Django model object?
An ordinary object, I can use
o.__repr__()
to see something like
'<__main__.A object at 0x9d78fec>'
But, say, a Django User just returns
<User:bob>
How can I see the actual address of one of these, or compare whether two such model-objects ... | How do I find the memory address of a Python / Django model object? | An ordinary object, I can use
o.__repr__()
to see something like
'<__main__.A object at 0x9d78fec>'
But, say, a Django User just returns
<User:bob>
How can I see the actual address of one of these, or compare whether two such model-objects are actually the same object or not?
| [
"id() will return the identity of the object (generally implemented as the address), which is guaranteed unique for two objects which exist at the same point in time. However the obvious way to check whether two objects are identical is to use the operator explicitely designed for this: is\nie.\n if obj1 is obj2: ... | [
7,
2,
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001075106_django_django_models_python.txt |
Q:
Generating an image thumbnail that is <10KB and did not lose proportions
Notice how for every image that google indexes it has a small thumbnail.
These thumbnails are:
Less than 10KB in size.
The proportions of the width / height are the same as the ones in the original image.
I would like to write a function (i... | Generating an image thumbnail that is <10KB and did not lose proportions | Notice how for every image that google indexes it has a small thumbnail.
These thumbnails are:
Less than 10KB in size.
The proportions of the width / height are the same as the ones in the original image.
I would like to write a function (in python) that would take an image and create a thumbnail with these to proper... | [
"In this short post, Mike Fletcher and the effbot show (and discuss detailed variation) an excellent approach for the task you want to do.\nEdit: as for the 10K requirement, it's hard (to say the least;-) to predict how well an image will compress, depending on the image's format, since today's compression algorith... | [
3,
1,
1
] | [] | [] | [
"image_processing",
"python",
"python_imaging_library"
] | stackoverflow_0001075037_image_processing_python_python_imaging_library.txt |
Q:
Splitting a large XML file in Python
I'm looking to split a huge XML file into smaller bits. I'd like to scan through the file looking for a specific tag, then grab all info between and , then save that into a file, then continue on through the rest of the file.
My issue is trying to find a clean way to note the ... | Splitting a large XML file in Python | I'm looking to split a huge XML file into smaller bits. I'd like to scan through the file looking for a specific tag, then grab all info between and , then save that into a file, then continue on through the rest of the file.
My issue is trying to find a clean way to note the start and end of the tags, so that I can g... | [
"There are two common ways to handle XML data.\nOne is called DOM, which stands for Document Object Model. This style of XML parsing is probably what you have seen when looking at documentation, because it reads the entire XML into memory to create the object model.\nThe second is called SAX, which is a streaming ... | [
9,
6,
6,
2,
0
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0000476949_python_xml.txt |
Q:
Does python have hooks into EXT3
We have several cron jobs that ftp proxy logs to a centralized server. These files can be rather large and take some time to transfer. Part of the requirement of this project is to provide a logging mechanism in which we log the success or failure of these transfers. This is simple... | Does python have hooks into EXT3 | We have several cron jobs that ftp proxy logs to a centralized server. These files can be rather large and take some time to transfer. Part of the requirement of this project is to provide a logging mechanism in which we log the success or failure of these transfers. This is simple enough.
My question is, is there a wa... | [
"no need for ext3-specific hooks; just check lsof, or more exactly, /proc/<pid>/fd/* and /proc/<pid>/fdinfo/* (that's where lsof gets it's info, AFAICT). There you can check if the file is open, if it's writeable, and the 'cursor' position.\nThat's not the whole picture; but any more is done in processpace by stdl... | [
7,
1
] | [] | [] | [
"ext3",
"linux",
"python"
] | stackoverflow_0001075391_ext3_linux_python.txt |
Q:
Simplifying Data with a for loop (Python)
I was trying to simplify the code:
header = []
header.append(header1)
header.append(header2)
header.append(header3)
header.append(header4)
header.append(header5)
header.appe... | Simplifying Data with a for loop (Python) | I was trying to simplify the code:
header = []
header.append(header1)
header.append(header2)
header.append(header3)
header.append(header4)
header.append(header5)
header.append(header6)
where:
header1 = str(i... | [
"You should really structure your data as a list or a dictionary, like this:\ninput.headerOut[1]\ninput.headerOut[2]\n# etc.\n\nwhich would make this a lot easier, and more Pythonic. But you can do what you want using getattr:\nheaderList = []\nfor i in range(1, 7):\n header = str(getattr(input, 'headerOut%d' %... | [
9,
5,
2,
2
] | [] | [] | [
"for_loop",
"loops",
"python",
"simplify",
"string"
] | stackoverflow_0001075631_for_loop_loops_python_simplify_string.txt |
Q:
Using the AND and NOT Operator in Python
Here is my custom class that I have that represents a triangle. I'm trying to write code that checks to see if self.a, self.b, and self.c are greater than 0, which would mean that I have Angle, Angle, Angle.
Below you will see the code that checks for A and B, however wh... | Using the AND and NOT Operator in Python | Here is my custom class that I have that represents a triangle. I'm trying to write code that checks to see if self.a, self.b, and self.c are greater than 0, which would mean that I have Angle, Angle, Angle.
Below you will see the code that checks for A and B, however when I use just self.a != 0 then it works fine. ... | [
"You should write :\nif (self.a != 0) and (self.b != 0) :\n\n\"&\" is the bit wise operator and does not suit for boolean operations. The equivalent of \"&&\" is \"and\" in Python.\nA shorter way to check what you want is to use the \"in\" operator :\nif 0 not in (self.a, self.b) :\n\nYou can check if anything is ... | [
130,
23,
13
] | [] | [] | [
"operators",
"python"
] | stackoverflow_0001075652_operators_python.txt |
Q:
Writing a website in Python
I'm pretty proficient in PHP, but want to try something new.
I'm also know a bit of Python, enough to do the basics of the basics, but haven't used in a web design type situation.
I've just written this, which works:
#!/usr/bin/python
def main():
print "Content-type: text/html"
... | Writing a website in Python | I'm pretty proficient in PHP, but want to try something new.
I'm also know a bit of Python, enough to do the basics of the basics, but haven't used in a web design type situation.
I've just written this, which works:
#!/usr/bin/python
def main():
print "Content-type: text/html"
print
print "<html><head>"
... | [
"Your question was about basic CGI scripting, looking at your example, but it seems like everyone has chosen to answer it with \"use my favorite framework\". Let's try a different approach.\nIf you're looking for a direct replacement for what you wrote above (ie. CGI scripting), then you're probably looking for the... | [
27,
12,
8,
2,
2,
0,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0001070999_python.txt |
Q:
How should I learn to use the Windows API with Python?
I have very little experience building software for Windows, and zero experience using the Windows API, but I'm reasonably familiar with Python. How should I go about learning to use the Windows API with Python?
A:
Honestly, no. The Windows API is an 800 po... | How should I learn to use the Windows API with Python? | I have very little experience building software for Windows, and zero experience using the Windows API, but I'm reasonably familiar with Python. How should I go about learning to use the Windows API with Python?
| [
"Honestly, no. The Windows API is an 800 pound monster covered with hair. Charlie Petzold's 15 pound book was the canonical reference once upon a time.\nThat said, the Python for Windows folks have some good material. Microsoft has the whole API online, including some sample code and such. And the Wikipedia art... | [
42,
25,
7,
7,
3,
2,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"python",
"winapi"
] | stackoverflow_0000342729_python_winapi.txt |
Q:
I want to parse a PAC file to get some Proxy information... just not in Explorer
Follow on from this question:
I am working on a Python 2.4 app which will run on Windows XP. It needs to be able to download various resources from HTTP and it's got to work in all of our office locations which use "PAC" files to auto... | I want to parse a PAC file to get some Proxy information... just not in Explorer | Follow on from this question:
I am working on a Python 2.4 app which will run on Windows XP. It needs to be able to download various resources from HTTP and it's got to work in all of our office locations which use "PAC" files to automatically select http proxies.
Thanks to somebody who responded to my previous questio... | [
"Are you able to download the PAC file from the remote host? I am asking because usually urllib in python uses static information for the proxy, retrieved from the registry.\nHowever, if you are able to get that file, then I think you could be able to get also another file - and then your idea of using FF version c... | [
1
] | [] | [] | [
"internet_explorer",
"javascript",
"python",
"windows"
] | stackoverflow_0001075899_internet_explorer_javascript_python_windows.txt |
Q:
IPv6 decoder for pcapy/impacket
I use the pcapy/impacket library to decode network packets in Python. It has an IP decoder which knows about the syntax of IPv4 packets but apparently no IPv6 decoder.
Does anyone get one?
In a private correspondance, the Impacket maintainers say it may be better to start with Scap... | IPv6 decoder for pcapy/impacket | I use the pcapy/impacket library to decode network packets in Python. It has an IP decoder which knows about the syntax of IPv4 packets but apparently no IPv6 decoder.
Does anyone get one?
In a private correspondance, the Impacket maintainers say it may be better to start with Scapy
| [
"Scapy, recommended by the Impacket maintainers, has no IPv6 decoding at this time. But there is an unofficial extension to do so.\nWith this extension, it works:\nfor packet in traffic:\n if packet.type == ETH_P_IPV6 or packet.type == ETH_P_IP:\n ip = packet.payload\n if (ip.version == 4 and ip.proto == UDP... | [
2,
1
] | [
"I have never used pcapy before, but I do have used libpcap in C projects. As the pcapy page states it is not statically linked to libcap, so you can upgrade to a newer one with IPv6 support.\nAccording to libpcap changelog, version 1.0 released on October 27, 2008, has default IPv6 support (it is supposed to have ... | [
-1,
-1
] | [
"impacket",
"ipv6",
"packet_capture",
"pcapy",
"python"
] | stackoverflow_0000369764_impacket_ipv6_packet_capture_pcapy_python.txt |
Q:
One liner to replicate lines coming from a file (Python)
I have a regular list comprehension to load all lines of a file in a list
f = open('file')
try:
self._raw = [L.rstrip('\n') for L in f]
finally:
f.close()
Now I'd like to insert in the list each line 'n' times on the fly. How to do it inside the li... | One liner to replicate lines coming from a file (Python) | I have a regular list comprehension to load all lines of a file in a list
f = open('file')
try:
self._raw = [L.rstrip('\n') for L in f]
finally:
f.close()
Now I'd like to insert in the list each line 'n' times on the fly. How to do it inside the list comprehension ?
Tnx
| [
"self._raw = [L.rstrip('\\n') for L in f for _ in xrange(n)]\n\n"
] | [
6
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0001076872_list_comprehension_python.txt |
Q:
How do I detect whether sys.stdout is attached to terminal or not?
Is there a way to detect whether sys.stdout is attached to a console terminal or not? For example, I want to be able to detect if foo.py is run via:
$ python foo.py # user types this on console
OR
$ python foo.py > output.txt # redirection
$ pyth... | How do I detect whether sys.stdout is attached to terminal or not? | Is there a way to detect whether sys.stdout is attached to a console terminal or not? For example, I want to be able to detect if foo.py is run via:
$ python foo.py # user types this on console
OR
$ python foo.py > output.txt # redirection
$ python foo.py | grep .... # pipe
The reason I ask this question is that I ... | [
"This can be detected using isatty:\nif sys.stdout.isatty():\n # You're running in a real terminal\nelse:\n # You're being piped or redirected\n\nTo demonstrate this in a shell:\n\npython -c \"import sys; print(sys.stdout.isatty())\" should write True\npython -c \"import sys; print(sys.stdout.isatty())\" | ca... | [
262
] | [] | [] | [
"console",
"python",
"terminal"
] | stackoverflow_0001077113_console_python_terminal.txt |
Q:
Python Unix time doesn't work in Javascript
In Python, using calendar.timegm(), I get a 10 digit result for a unix timestamp. When I put this into Javscript's setTime() function, it comes up with a date in 1970. It evidently needs a unix timestamp that is 13 digits long. How can this happen? Are they both counting... | Python Unix time doesn't work in Javascript | In Python, using calendar.timegm(), I get a 10 digit result for a unix timestamp. When I put this into Javscript's setTime() function, it comes up with a date in 1970. It evidently needs a unix timestamp that is 13 digits long. How can this happen? Are they both counting from the same date?
How can I use the same unix... | [
"timegm is based on Unix's gmtime() method, which return seconds since Jan 1, 1970.\nJavascripts setTime() method is milliseconds since that date. You'll need to multiply your seconds times 1000 to convert to the format expected by Javascript.\n",
"Here are a couple of python methods I use to convert to and from... | [
11,
9,
2,
1
] | [] | [] | [
"datetime",
"javascript",
"python",
"unix_timestamp",
"utc"
] | stackoverflow_0001077393_datetime_javascript_python_unix_timestamp_utc.txt |
Q:
Making a variable non-inheritable in python
Is there a way to make a variable non-inheritable in python? Like in the following example: B is a subclass of A, but I want it to have its own SIZE value.
Could I get an Error to be raised (on __init__ or on getsize()) if B doesn't override SIZE?
class A:
SIZE = 5
... | Making a variable non-inheritable in python | Is there a way to make a variable non-inheritable in python? Like in the following example: B is a subclass of A, but I want it to have its own SIZE value.
Could I get an Error to be raised (on __init__ or on getsize()) if B doesn't override SIZE?
class A:
SIZE = 5
def getsize(self): return self.SIZE
class B(A):... | [
"Use a double-underscore prefix:\n(Double-underscore solution deleted after Emma's clarification)\nOK, you can do it like this:\nclass A:\n SIZE = 5\n def __init__(self):\n if self.__class__ != A:\n del self.SIZE\n\n def getsize(self):\n return self.SIZE\n\nclass B(A):\n pass\n\... | [
8,
5,
2,
1,
0,
0,
0,
0
] | [] | [] | [
"inheritance",
"python"
] | stackoverflow_0001076718_inheritance_python.txt |
Q:
Share objects with file handle attribute between processes
I have a question about shared resource with file handle between processes.
Here is my test code:
from multiprocessing import Process,Lock,freeze_support,Queue
import tempfile
#from cStringIO import StringIO
class File():
def __init__(self):
s... | Share objects with file handle attribute between processes | I have a question about shared resource with file handle between processes.
Here is my test code:
from multiprocessing import Process,Lock,freeze_support,Queue
import tempfile
#from cStringIO import StringIO
class File():
def __init__(self):
self.temp = tempfile.TemporaryFile()
#print self.temp
... | [
"I have to object (at length, won't just fit in a commentl;-) to @Mark's repeated assertion that file handles just can't be \"passed around between running processes\" -- this is simply not true in real, modern operating systems, such as, oh, say, Unix (free BSD variants, MacOSX, and Linux, included -- hmmm, I wond... | [
7
] | [] | [] | [
"multiprocessing",
"python"
] | stackoverflow_0001075443_multiprocessing_python.txt |
Q:
Python Unicode UnicodeEncodeError
I am having issues with trying to convert an UTF-8 string to unicode. I get the error.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 73-75: ordinal not in range(128)
I tried wrapping this in a try/except block but then google was giving me a system adminis... | Python Unicode UnicodeEncodeError | I am having issues with trying to convert an UTF-8 string to unicode. I get the error.
UnicodeEncodeError: 'ascii' codec can't encode characters in position 73-75: ordinal not in range(128)
I tried wrapping this in a try/except block but then google was giving me a system administrator error which was one line.
Can so... | [
"The correct solution is to do the following:\nself.response.headers['Location'] = urllib.quote(absolute_url.encode(\"utf-8\"))\n\n",
"The location header you are trying to set needs to be an Url, and an Url needs to be in Ascii. Since your Url is not an Ascii string you get the error. Just catching the error won... | [
8,
4,
1
] | [
"Try this:\nself.response.headers['Location'] = absolute_url.decode(\"utf-8\")\nor\nself.response.headers['Location'] = unicode(absolute_url, \"utf-8\")\n\n"
] | [
-1
] | [
"google_app_engine",
"python",
"unicode",
"utf_8"
] | stackoverflow_0001077564_google_app_engine_python_unicode_utf_8.txt |
Q:
Windows Application Programming & wxPython
Developing a project of mine I realize I have a need for some level of persistence across sessions, for example when a user executes the application, changes some preferences and then closes the app. The next time the user executes the app, be it after a reboot or 15 min... | Windows Application Programming & wxPython | Developing a project of mine I realize I have a need for some level of persistence across sessions, for example when a user executes the application, changes some preferences and then closes the app. The next time the user executes the app, be it after a reboot or 15 minutes, I would like to be able to retain the pref... | [
"I would advice to do it in two steps.\n\nFirst step is to save your prefs. as\nstring, for that you can\na)\nUse any xml lib or output xml by\nhand to output string and read\nsimilarly from string\nb) Just use pickle module to dump your prefs object as a string\nc) Somehow generate a string from prefs which ... | [
3,
1
] | [] | [] | [
"python",
"windows",
"wxpython"
] | stackoverflow_0001077649_python_windows_wxpython.txt |
Q:
Tkinter button bind and parent deatroy
This is my code :
print '1'
from Tkinter import *
print '2'
class myApp:
print '3'
def __init__(self,parent):
print '4'
## self.myparent = parent line1
print '11'
self.myContainer1 = Frame(parent)
print '12'
sel... | Tkinter button bind and parent deatroy | This is my code :
print '1'
from Tkinter import *
print '2'
class myApp:
print '3'
def __init__(self,parent):
print '4'
## self.myparent = parent line1
print '11'
self.myContainer1 = Frame(parent)
print '12'
self.myContainer1.pack()
print '13'
... | [
"Why ever did you comment out those two lines mentioning self.myparent and create a new one mentioning a mysterious, never-initialized self.parent?! That's the start of your problem, of course -- looks like absurd, deliberate sabotage of code.\n",
"Assign the incoming parameter parent to self.parent?\ndef __init... | [
2,
0,
0,
0
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0001077932_python_tkinter.txt |
Q:
How can I deal with No module named edit.editor?
I am trying to follow the WingIDE tutorial on creating scripts in the IDE.
This following example scripts always throws an error:
import wingapi
def test_script(test_str):
app = wingapi.gApplication
v = "Product info is: " + str(app.GetProductInfo())
v += "\n... | How can I deal with No module named edit.editor? | I am trying to follow the WingIDE tutorial on creating scripts in the IDE.
This following example scripts always throws an error:
import wingapi
def test_script(test_str):
app = wingapi.gApplication
v = "Product info is: " + str(app.GetProductInfo())
v += "\nAnd you typed: %s" % test_str
wingapi.gApplication.S... | [
"Answer is based on email from Stephan Deibel from the Wingware company that develops Wind IDE.\n\nScripts are not launched in Wing's debugger. If you're editing them within Wing, they get reloaded as soon as you save and you should be able to use Command By Name in the edit menu to type test-script, which will ex... | [
1
] | [] | [] | [
"python",
"wing_ide"
] | stackoverflow_0001072736_python_wing_ide.txt |
Q:
Restarting a Django application running on Apache + mod_python
I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I don't really want to do that since it's a production server running... | Restarting a Django application running on Apache + mod_python | I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I don't really want to do that since it's a production server running other stuff too. Is there some other way to force that?
Just to mak... | [
"If possible, you should switch to mod_wsgi. This is now the recommended way to serve Django anyway, and is much more efficient in terms of memory and server resources.\nIn mod_wsgi, each site has a .wsgi file associated with it. To restart a site, just touch the relevant file, and only that code will be reloaded.\... | [
15,
4,
1
] | [
"Use a test server included in Django. (like ./manage.py runserver 0.0.0.0:8080) It will do most things you would need during development. The only drawback is that it cannot handle simultaneous requests with multi-threading.\nI've heard that there is a trick that setting Apache's max instances to 1 so that every c... | [
-1
] | [
"django",
"mod_python",
"python"
] | stackoverflow_0001078166_django_mod_python_python.txt |
Q:
I'd like to call the Windows C++ function WinHttpGetProxyForUrl from Python - can this be done?
Microsoft provides a method as part of WinHTTP which allows a user to determine which Proxy ought to be used for any given URL. It's called WinHttpGetProxyForUrl.
Unfortunately I'm programming in python so I cannot dire... | I'd like to call the Windows C++ function WinHttpGetProxyForUrl from Python - can this be done? | Microsoft provides a method as part of WinHTTP which allows a user to determine which Proxy ought to be used for any given URL. It's called WinHttpGetProxyForUrl.
Unfortunately I'm programming in python so I cannot directly access this function - I can use Win32COM to call any Microsoft service with a COM interface.
So... | [
"You can use ctypes to call function in WinHttp.dll, it is the DLL which contains 'WinHttpGetProxyForUrl. '\nThough to call it you will need a HINTERNET session variable, so here I am showing you the first step, it shows how you can use ctypes to call into DLL,it produces a HINTERNET which you have to pass to WinHt... | [
1,
1
] | [] | [] | [
"c++",
"com",
"python",
"windows"
] | stackoverflow_0001078939_c++_com_python_windows.txt |
Q:
CherryPy interferes with Twisted shutting down on Windows
I've got an application that runs Twisted by starting the reactor with reactor.run() in my main thread after starting some other threads, including the CherryPy web server. Here's a program that shuts down cleanly when Ctrl+C is pressed on Linux but not on... | CherryPy interferes with Twisted shutting down on Windows | I've got an application that runs Twisted by starting the reactor with reactor.run() in my main thread after starting some other threads, including the CherryPy web server. Here's a program that shuts down cleanly when Ctrl+C is pressed on Linux but not on Windows:
from threading import Thread
from signal import signa... | [
"CherryPy handles signals by default when you call quickstart. In your case, you should probably just unroll quickstart, which is only a few lines, and pick and choose. Here's basically what quickstart does in trunk:\nif config:\n cherrypy.config.update(config)\n\ntree.mount(root, script_name, config)\n\nif hasa... | [
14
] | [] | [] | [
"cherrypy",
"linux",
"python",
"twisted",
"windows"
] | stackoverflow_0001075351_cherrypy_linux_python_twisted_windows.txt |
Q:
Handling authentication and proxy servers with httplib2
I'm attempting to test interactions with a Nexus server that requires authentication for the operations I intend to use, but I also need to handle an internal proxy server.
Based on my (limited) understanding I can add multiple handlers to the opener. However... | Handling authentication and proxy servers with httplib2 | I'm attempting to test interactions with a Nexus server that requires authentication for the operations I intend to use, but I also need to handle an internal proxy server.
Based on my (limited) understanding I can add multiple handlers to the opener. However I'm still getting a 401 response. I've checked the username ... | [
"Can you show the full headers of the 401 response you're getting? Maybe it's not a basic auth request, maybe it's the proxy wanting its own authentication -- it's hard to guess without seeing said headers!\nEdit: thanks for showing the headers (I reformatted them as \"code\" else they were unreadable).\nAs I suspe... | [
3
] | [] | [] | [
"httplib2",
"nexus",
"python"
] | stackoverflow_0001080179_httplib2_nexus_python.txt |
Q:
How to emulate language complement operator in .hgignore?
I have a Python regular expression that matches a set of filenames. How to change it so that I can use it in Mercurial's .hgignore file to ignore files that do not match the expression?
Full story:
I have a big source tree with *.ml files scattered everywhe... | How to emulate language complement operator in .hgignore? | I have a Python regular expression that matches a set of filenames. How to change it so that I can use it in Mercurial's .hgignore file to ignore files that do not match the expression?
Full story:
I have a big source tree with *.ml files scattered everywhere. I want to put them into a new repository. There are other, ... | [
"The regexs are applied to each subdirectory component in turn as well as the file name, not the entire relative path at once. So if I have a/b/c/d in my repo, each regex will be applied to a, a/b, a/b/c as well as a/b/c/d. If any component matches, the file will be ignored. (You can tell that this is the behaviour... | [
1,
0,
0
] | [] | [] | [
"mercurial",
"python",
"regex"
] | stackoverflow_0001079342_mercurial_python_regex.txt |
Q:
Cleaning an image to only black
I have an image.
I would like to go over that image, pixel by pixel, and any pixel that is not black should be turned to white. How do I do this?
(Python).
Thanks!
A:
The most efficient way is to use the point function
def only_black(band):
if band > 0:
return 255
... | Cleaning an image to only black | I have an image.
I would like to go over that image, pixel by pixel, and any pixel that is not black should be turned to white. How do I do this?
(Python).
Thanks!
| [
"The most efficient way is to use the point function\ndef only_black(band):\n if band > 0:\n return 255\n return 0\nresult = im.convert('L').point(only_black)\n\nThis is what the PIL documentation has to say about this:\n\nWhen converting to a bilevel image\n (mode \"1\"), the source image is first\n ... | [
6,
3,
1
] | [] | [] | [
"image_processing",
"python",
"python_imaging_library"
] | stackoverflow_0001080219_image_processing_python_python_imaging_library.txt |
Q:
Random list with rules
I'm trying to create a list of tasks that I've read from some text files and put them into lists. I want to create a master list of what I'm going to do through the day however I've got a few rules for this.
One list has separate daily tasks that don't depend on the order they are complet... | Random list with rules | I'm trying to create a list of tasks that I've read from some text files and put them into lists. I want to create a master list of what I'm going to do through the day however I've got a few rules for this.
One list has separate daily tasks that don't depend on the order they are completed. I call this list 'daily... | [
"First, copy and shuffle daily to initialize master:\nmaster = list(daily)\nrandom.shuffle(master)\n\nthen (the interesting part!-) the alteration of master (to insert projects randomly but without order changes), and finally random.shuffle(endofday); master.extend(endofday).\nAs I said the alteration part is the i... | [
4,
1,
1,
1,
1
] | [] | [] | [
"python",
"random"
] | stackoverflow_0001080393_python_random.txt |
Q:
Preventing invoking C types from Python
What's the correct way to prevent invoking (creating an instance of) a C type from Python?
I've considered providing a tp_init that raises an exception, but as I understand it that would still allow __new__ to be called directly on the type.
A C function returns instances of... | Preventing invoking C types from Python | What's the correct way to prevent invoking (creating an instance of) a C type from Python?
I've considered providing a tp_init that raises an exception, but as I understand it that would still allow __new__ to be called directly on the type.
A C function returns instances of this type -- that's the only way instances o... | [
"Simple: leave the tp_new slot of the type empty.\n>>> Foo()\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nTypeError: cannot create 'foo.Foo' instances\n>>> Foo.__new__(Foo)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nTypeError: object.__new__(foo.Fo... | [
3,
1,
0,
0
] | [] | [] | [
"cpython",
"python"
] | stackoverflow_0001079690_cpython_python.txt |
Q:
How to reload a Python module that was imported in another file?
I am trying to learn how Python reloads modules, but have hit a roadblock.
Let's say I have:
dir1\file1.py:
from dir2.file2 import ClassOne
myObject = ClassOne()
dir1\dir2\file2.py:
class ClassOne():
def reload_module():
reload(file2)
The... | How to reload a Python module that was imported in another file? | I am trying to learn how Python reloads modules, but have hit a roadblock.
Let's say I have:
dir1\file1.py:
from dir2.file2 import ClassOne
myObject = ClassOne()
dir1\dir2\file2.py:
class ClassOne():
def reload_module():
reload(file2)
The reload call fails to find module "file2".
My question is, how do I do... | [
" def reload_module():\n import file2\n reload(file2)\n\nHowever, this will not per se change the type of objects you've instantiated from classes held in the previous version of file2. The Python Cookbook 2nd edition has a recipe on how to accomplish such feats, and it's far too long and complex in b... | [
3
] | [] | [] | [
"import",
"module",
"python",
"reload"
] | stackoverflow_0001080521_import_module_python_reload.txt |
Q:
handler not working in gae python
I have two handlers in webapp.WSGIApplication for two forms in a django template, one of the handler works on dopost but the other one goes to blank page. Why is this so?
A:
Some error or typo somewhere in your code or configuration, it's impossible to say much more without seei... | handler not working in gae python | I have two handlers in webapp.WSGIApplication for two forms in a django template, one of the handler works on dopost but the other one goes to blank page. Why is this so?
| [
"Some error or typo somewhere in your code or configuration, it's impossible to say much more without seeing those files of course.\n"
] | [
1
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0001080618_django_google_app_engine_python.txt |
Q:
Accessing Python Objects in a Core Dump
Is there anyway to discover the python value of a PyObject* from a corefile in gdb
A:
It's lots of work, but of course it can be done, especially if you have all the symbols. Look at the header files for the specific version of Python (and compilation options in use to bui... | Accessing Python Objects in a Core Dump | Is there anyway to discover the python value of a PyObject* from a corefile in gdb
| [
"It's lots of work, but of course it can be done, especially if you have all the symbols. Look at the header files for the specific version of Python (and compilation options in use to build it): they define PyObject as a struct which includes, first and foremost, a pointer to a type. Lots of macros are used, so yo... | [
4
] | [] | [] | [
"postmortem_debugging",
"python",
"python_c_api"
] | stackoverflow_0001080832_postmortem_debugging_python_python_c_api.txt |
Q:
How to direct tkinter to look elsewhere for Tcl/Tk library (to dodge broken library without reinstalling)
I've written a Python script that uses Tkinter. I want to deploy that script on a handful of computers that are on Mac OS 10.4.11. But that build of MAC OS X seems to have a broken TCL/TK install. Even loading... | How to direct tkinter to look elsewhere for Tcl/Tk library (to dodge broken library without reinstalling) | I've written a Python script that uses Tkinter. I want to deploy that script on a handful of computers that are on Mac OS 10.4.11. But that build of MAC OS X seems to have a broken TCL/TK install. Even loading the package gives me:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: dlopen(/Sys... | [
"You can change where your system looks for dynamic/shared libraries by altering DYLD_LIBRARY_PATH in your environment before launching Python. You can do this in Terminal like so:\n$ DYLD_LIBRARY_PATH=<insert path here>:$DYLD_LIBRARY_PATH python\n\n... or create a wrapper:\n#!/bin/sh\nexport DYLD_LIBRARY_PATH=<ins... | [
1
] | [] | [] | [
"macos",
"python",
"tkinter"
] | stackoverflow_0001060745_macos_python_tkinter.txt |
Q:
How Do I Remove Text From Generated Django Form?
So earlier I asked a question about removing the label that Django forms have by default. That worked out great, and I removed the label. However, the text that is generated by the form is still there! I would very much like to remove the text. Here is what I mean:
... | How Do I Remove Text From Generated Django Form? | So earlier I asked a question about removing the label that Django forms have by default. That worked out great, and I removed the label. However, the text that is generated by the form is still there! I would very much like to remove the text. Here is what I mean:
<p>Text: <textarea rows="10" cols="40" name="text"></t... | [
"The answer:\nclass CommentForm(forms.Form):\n comment = forms.CharField(widget=forms.Textarea(), label='')\n\nAlso, no auto_id in the constructor when creating the object, it should be left as:\ncomment = new CommentForm()\n\n",
"Have you tried:\nclass CommentForm(forms.Form):\n comment = forms.CharField(w... | [
4,
1,
0
] | [] | [] | [
"django",
"forms",
"python",
"textarea"
] | stackoverflow_0001080828_django_forms_python_textarea.txt |
Q:
Decompile .swf file to get images in python
I would like to decompile a .swf file and get all the images from it, in python.
Are there any libraries that do this?
A:
The SWFTools distribution has a command line program, SWFExtract, that can do this. You could call that from python to do what you want:
http://ww... | Decompile .swf file to get images in python | I would like to decompile a .swf file and get all the images from it, in python.
Are there any libraries that do this?
| [
"The SWFTools distribution has a command line program, SWFExtract, that can do this. You could call that from python to do what you want:\nhttp://www.swftools.org/\nhttp://www.swftools.org/swfextract.html\n",
"I don't think there are any libraries available for python, but maybe you can have an offline process t... | [
6,
2,
2
] | [] | [] | [
"flash",
"python"
] | stackoverflow_0001081183_flash_python.txt |
Q:
Changes to Python since Dive into Python
I've been teaching myself Python by working through Dive Into Python by Mark Pilgrim. I thoroughly recommend it, as do other Stack Overflow users.
However, the last update to Dive Into Python was five years ago. I look forward to reading the new Dive into Python 3 When I ma... | Changes to Python since Dive into Python | I've been teaching myself Python by working through Dive Into Python by Mark Pilgrim. I thoroughly recommend it, as do other Stack Overflow users.
However, the last update to Dive Into Python was five years ago. I look forward to reading the new Dive into Python 3 When I make the switch to 3.x, but for now, using djang... | [
"Check out What's New in Python. It has all the versions in the 2.x series. Per Alex's comments, you'll want to look at all Python 2.x for x > 2.\nHighlights for day-to-day coding:\nEnumeration: Instead of doing:\nfor i in xrange(len(sequence)):\n val = sequence[i]\n pass\n\nYou can now more succinctly write:... | [
9,
6,
3,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0001080734_python.txt |
Q:
How can I report the API of a class programmatically?
My goal is to parse a class and return a data-structure (object, dictionary, etc) that is descriptive of the methods and the related parameters contained within the class. Bonus points for types and returns...
Requirements: Must be Python
For example, the belo... | How can I report the API of a class programmatically? | My goal is to parse a class and return a data-structure (object, dictionary, etc) that is descriptive of the methods and the related parameters contained within the class. Bonus points for types and returns...
Requirements: Must be Python
For example, the below class:
class Foo:
def bar(hello=None):
retur... | [
"You probably want to check out Python's inspect module. It will get you most of the way there:\n>>> class Foo:\n... def bar(hello=None):\n... return hello\n... def baz(world=None):\n... return baz\n...\n>>> import inspect\n>>> members = inspect.getmembers(Foo)\n>>> print members\n[('__doc... | [
8
] | [] | [] | [
"api",
"python"
] | stackoverflow_0001081392_api_python.txt |
Q:
Yahoo Chat in Python
I'm wondering how the best way to build a way to interface with Yahoo Chat is. I haven't found anything that looks incredibly easy to do yet. One thought it to build it all from scratch, the other thought would be to grab the code from open source software. I could use something like zinc, ... | Yahoo Chat in Python | I'm wondering how the best way to build a way to interface with Yahoo Chat is. I haven't found anything that looks incredibly easy to do yet. One thought it to build it all from scratch, the other thought would be to grab the code from open source software. I could use something like zinc, however, this maybe more c... | [
"Python-purple is a python API for accessing libpurple, the Pidgin backend. It will give you access to all the IM networks which Pidgin supports, including Y!Messenger, MSN Messenger, Jabber/GTalk/XMPP, and more...\n"
] | [
4
] | [] | [] | [
"networking",
"python"
] | stackoverflow_0001082078_networking_python.txt |
Q:
2D vector projection in Python
The code below projects the blue vector, AC, onto the red vector, AB, the resulting projected vector, AD, is drawn as purple. This is intended as my own implementation of this Wolfram demonstration.
Something is wrong however and I can really figure out what. Should be either that th... | 2D vector projection in Python | The code below projects the blue vector, AC, onto the red vector, AB, the resulting projected vector, AD, is drawn as purple. This is intended as my own implementation of this Wolfram demonstration.
Something is wrong however and I can really figure out what. Should be either that the projection formula itself is wrong... | [
"Shouldn't this\nD = project(AC,AB)\nAD = vsub(D,A)\n\nbe\nAD = project(AC,AB)\nD = vadd(A,AD)\n\nUnfortunately, I can't test it, but that's the only thing that looks wrong to me.\n"
] | [
6
] | [] | [] | [
"2d",
"math",
"projection",
"python"
] | stackoverflow_0001082187_2d_math_projection_python.txt |
Q:
Automatically pressing a "submit" button using python
The bus company I use runs an awful website (Hebrew,English) which making a simple "From A to B timetable today" query a nightmare. I suspect they are trying to encourage the usage of the costly SMS query system.
I'm trying to harvest the entire timetable from ... | Automatically pressing a "submit" button using python | The bus company I use runs an awful website (Hebrew,English) which making a simple "From A to B timetable today" query a nightmare. I suspect they are trying to encourage the usage of the costly SMS query system.
I'm trying to harvest the entire timetable from the site, by submitting the query for every possible point ... | [
"Twill is a simple scripting language for Web browsing. It happens to sport a python api.\n\ntwill is essentially a thin shell around the mechanize package. All twill commands are implemented in the commands.py file, and pyparsing does the work of parsing the input and converting it into Python commands (see parse.... | [
11,
10,
7
] | [] | [] | [
"data_harvest",
"form_submit",
"python",
"scripting"
] | stackoverflow_0001082361_data_harvest_form_submit_python_scripting.txt |
Q:
Sort a list of strings based on regular expression match
I have a text file that looks a bit like:
random text random text, can be anything blabla %A blabla
random text random text, can be anything blabla %D blabla
random text random text, can be anything blabla blabla %F
random text random text, can be anything b... | Sort a list of strings based on regular expression match | I have a text file that looks a bit like:
random text random text, can be anything blabla %A blabla
random text random text, can be anything blabla %D blabla
random text random text, can be anything blabla blabla %F
random text random text, can be anything blabla blabla
random text random text, %C can be anything blabl... | [
"In [1]: def grp(pat, txt): \n ...: r = re.search(pat, txt)\n ...: return r.group(0) if r else '&'\n\nIn [2]: y\nOut[2]: \n['random text random text, can be anything blabla %A blabla',\n 'random text random text, can be anything blabla %D blabla',\n 'random text random text, can be anything blabla blabl... | [
9,
4,
1,
1
] | [] | [] | [
"python",
"sorting"
] | stackoverflow_0001082413_python_sorting.txt |
Q:
USB - sync vs async vs semi-async
Updates:
I wrote an asynchronous C version and it works as it should.
Turns out the speed issue was due to Python's GIL. There's a method to fine tune its behavior.
sys.setcheckinterval(interval)
Setting interval to zero (default is 100) fixes the slow speed issue. Now all that's... | USB - sync vs async vs semi-async | Updates:
I wrote an asynchronous C version and it works as it should.
Turns out the speed issue was due to Python's GIL. There's a method to fine tune its behavior.
sys.setcheckinterval(interval)
Setting interval to zero (default is 100) fixes the slow speed issue. Now all that's left is to figure out is what's causin... | [
"Ok I don't know if I get you right. You have some device with LCD, you have some firmware on it to handle USB requests. On PC side you are using PyUSB wich wraps libUsb. \nCouple of suggestions if you are experiancing speed problems, try to limit data you are transfering. Do not transfer whole raw data, mayby only... | [
1
] | [] | [] | [
"ctypes",
"libusb",
"python",
"usb"
] | stackoverflow_0001060305_ctypes_libusb_python_usb.txt |
Q:
How do you do something after you render the view? (Django)
I want to do something after I have rendered the view using
return render_to_response()
Are signals the only way to do this? Do I need to write a custom signal or does request_finished give me enough information? Basically I need to know what page was r... | How do you do something after you render the view? (Django) | I want to do something after I have rendered the view using
return render_to_response()
Are signals the only way to do this? Do I need to write a custom signal or does request_finished give me enough information? Basically I need to know what page was rendered, and then do an action in response to that.
Thanks.
UPDAT... | [
"You spawn a separate thread and have it do the action.\nt = threading.Thread(target=do_my_action, args=[my_argument])\n# We want the program to wait on this thread before shutting down.\nt.setDaemon(False)\nt.start()\n\nThis will cause 'do_my_action(my_argument)' to be executed in a second thread which will keep w... | [
12,
5,
5,
5,
2
] | [
"In render to response, you pass the html page that you want displayed. That other page needs to send a post (via Javascript or something) that triggers the correct function in your views, then that view calls the correct next page to be shown.\n",
"Perhaps I do not understand your question. But why not something... | [
-1,
-2
] | [
"django",
"python"
] | stackoverflow_0001081340_django_python.txt |
Q:
What is the Pythonic way to write this loop?
for jr in json_reports:
jr['time_created'] = str(jr['time_created'])
A:
Looks to me that you're already there
A:
That would be the pythonic way to write the loop if you need to assign it to the same list.
If you just want to pull out strings of all time_created in... | What is the Pythonic way to write this loop? | for jr in json_reports:
jr['time_created'] = str(jr['time_created'])
| [
"Looks to me that you're already there\n",
"That would be the pythonic way to write the loop if you need to assign it to the same list.\nIf you just want to pull out strings of all time_created indices in each element of json_reports, you can use a list comprehension:\nstrings = [str(i['time_created']) for i in j... | [
10,
5
] | [] | [] | [
"python"
] | stackoverflow_0001083115_python.txt |
Q:
Send an xmpp message using a python library
How can I send an XMPP message using one of the following Python libraries: wokkel, xmpppy, or jabber.py ?
I think I am aware of the pseudo-code, but so far have not been able to get one running correctly. This is what I have tried so far:
Call some API and pass the se... | Send an xmpp message using a python library | How can I send an XMPP message using one of the following Python libraries: wokkel, xmpppy, or jabber.py ?
I think I am aware of the pseudo-code, but so far have not been able to get one running correctly. This is what I have tried so far:
Call some API and pass the servername and port number to connect to that serve... | [
"This is the simplest possible xmpp client. It will send a 'hello :)' message. I'm using xmpppy in the example. And connecting to gtalk server. I think the example is self-explanatory:\nimport xmpp\n\nusername = 'username'\npasswd = 'password'\nto='name@example.com'\nmsg='hello :)'\n\n\nclient = xmpp.Client('gmail.... | [
39,
1
] | [] | [] | [
"python",
"xmpp"
] | stackoverflow_0000910737_python_xmpp.txt |
Q:
Get brief human-readable info about XRI OpenID with Python?
I'd like to be able to tell to the site visitor that comes with his/her OpenID: you are using your XYZ id for the first time on mysite - please create your sceen name, where XYZ is a nice token that makes sense. For example - XYZ could be the provider nam... | Get brief human-readable info about XRI OpenID with Python? | I'd like to be able to tell to the site visitor that comes with his/her OpenID: you are using your XYZ id for the first time on mysite - please create your sceen name, where XYZ is a nice token that makes sense. For example - XYZ could be the provider name.
I'd like to find a solution that works for OpenID as defined i... | [
"Since OpenIDs are URLs, this might be the cleanest way in the absence of built-in support in Janrain:\nfrom urlparse import urlparse\nopenid_str = \"http://myprovider/myname\" # str(openid_obj)\nparts = urlparse(openid_str)\nprovider_name = parts[1]\nprint (provider_name) # Prints myprovider\n\n"
] | [
3
] | [] | [] | [
"janrain",
"openid",
"python",
"xri"
] | stackoverflow_0001083435_janrain_openid_python_xri.txt |
Q:
Missing datetime.timedelta.to_seconds() -> float in Python?
I understand that seconds and microseconds are probably represented separately in datetime.timedelta for efficiency reasons, but I just wrote this simple function:
def to_seconds_float(timedelta):
"""Calculate floating point representation of combined... | Missing datetime.timedelta.to_seconds() -> float in Python? | I understand that seconds and microseconds are probably represented separately in datetime.timedelta for efficiency reasons, but I just wrote this simple function:
def to_seconds_float(timedelta):
"""Calculate floating point representation of combined
seconds/microseconds attributes in :param:`timedelta`.
... | [
"A Python float has about 15 significant digits, so with seconds being up to 86400 (5 digits to the left of the decimal point) and microseconds needing 6 digits, you could well include the days (up to several years' worth) without loss of precision.\nA good mantra is \"pi seconds is a nanocentury\" -- about 3.14E9 ... | [
12,
3
] | [] | [] | [
"datetime",
"python",
"timedelta"
] | stackoverflow_0001083402_datetime_python_timedelta.txt |
Q:
python csv question
i'm just testing out the csv component in python, and i am having some trouble with it.
I have a fairly standard csv string, and the default options all seems to fit with my test, but the result shouldn't group 1, 2, 3, 4 in a row and 5, 6, 7, 8 in a row?
Thanks a lot for any enlightenment pro... | python csv question | i'm just testing out the csv component in python, and i am having some trouble with it.
I have a fairly standard csv string, and the default options all seems to fit with my test, but the result shouldn't group 1, 2, 3, 4 in a row and 5, 6, 7, 8 in a row?
Thanks a lot for any enlightenment provided!
Python 2.6.2 (r26... | [
"csv.reader expects an iterable. You gave it \"1, 2, 3, 4\\n 5, 6, 7, 8\\n\"; iteration produces characters. Try giving it [\"1, 2, 3, 4\\n\", \"5, 6, 7, 8\\n\"] -- iteration will produce lines.\n",
"csv.reader takes an iterable or iterator returning lines, see the docs. You're passing it a string, which is an it... | [
8,
3,
2,
2
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0001083364_csv_python.txt |
Q:
Best way to programmatically create image
I'm looking for a way to create a graphics file (I don't really mind the file type, as they are easily converted).
The input would be the desired resolution, and a list of pixels and colors (x, y, RGB color).
Is there a convenient python library for that? What are the pros... | Best way to programmatically create image | I'm looking for a way to create a graphics file (I don't really mind the file type, as they are easily converted).
The input would be the desired resolution, and a list of pixels and colors (x, y, RGB color).
Is there a convenient python library for that? What are the pros\cons\pitfalls?
| [
"PIL is the canonical Python Imaging Library.\nPros: Everybody wanting to do what you're doing uses PIL. 8-)\nCons: None springs to mind.\n",
"Alternatively, you can try ImageMagick.\nLast time I checked, PIL didn't work on Python 3, which is potentially a con. (I don't know about ImageMagick's API.) I believe a... | [
7,
0
] | [] | [] | [
"graphics",
"python",
"python_imaging_library"
] | stackoverflow_0001083943_graphics_python_python_imaging_library.txt |
Q:
Implementing a custom Python authentication handler
The answer to a previous question showed that Nexus implement a custom authentication helper called "NxBASIC".
How do I begin to implement a handler in python?
Update:
Implementing the handler per Alex's suggestion looks to be the right approach, but fails tryin... | Implementing a custom Python authentication handler | The answer to a previous question showed that Nexus implement a custom authentication helper called "NxBASIC".
How do I begin to implement a handler in python?
Update:
Implementing the handler per Alex's suggestion looks to be the right approach, but fails trying to extract the scheme and realm from the authreq.
The r... | [
"If, as described, name and description are the only differences between this \"NxBasic\" and good old \"Basic\", then you could essentially copy-paste-edit some code from urllib2.py (which unfortunately doesn't expose the scheme name as easily overridable in itself), as follows (see urllib2.py's online sources):\n... | [
1
] | [] | [] | [
"httplib2",
"nexus",
"python",
"restlet"
] | stackoverflow_0001080920_httplib2_nexus_python_restlet.txt |
Q:
Django Database Caching
I'm working on a small project, and I wanted to provide multiple caching options to the end user. I figured with Django it's pretty simplistic to swap memcached for database or file based caching. My memcached implementation works like a champ without any issues. I placed time stamps on my ... | Django Database Caching | I'm working on a small project, and I wanted to provide multiple caching options to the end user. I figured with Django it's pretty simplistic to swap memcached for database or file based caching. My memcached implementation works like a champ without any issues. I placed time stamps on my pages, and curl consistently ... | [
"According to the documentation you're supposed to create the table not by using syncdb but with the following:\npython manage.py createcachetable cache_table\n\nIf you haven't done that, try and see if it doesn't work.\n"
] | [
8
] | [] | [] | [
"django",
"django_cache",
"python"
] | stackoverflow_0001084569_django_django_cache_python.txt |
Q:
Getting a dict out of a method?
I'm trying to get a dict out of a method, so far I'm able to get the method name, and its arguments (using the inspect module), the problem I'm facing is that I'd like to have the default arguments too (or the argument type).
This is basically my unit test:
class Test:
def metho... | Getting a dict out of a method? | I'm trying to get a dict out of a method, so far I'm able to get the method name, and its arguments (using the inspect module), the problem I'm facing is that I'd like to have the default arguments too (or the argument type).
This is basically my unit test:
class Test:
def method1(anon_type, array=[], string="strin... | [
"what exactly is the problem? all arguments are ordered, keyword arguments should be the last in definition. do you know how to slice a list?\n",
"Here is what I usually do:\nimport inspect, itertools\nargs, varargs, keywords, defaults = inspect.getargspec(method1)\nprint dict(itertools.izip_longest(args[::-1], d... | [
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0001084566_python.txt |
Q:
C++ or Python as a starting point into GUI programming?
I have neglected my programming skills since i left school and now i want to start a few things that are running around in my head. Qt would be the toolkit for me to use but i am undecided if i should use Python (looks to me like the easier to learn with a fe... | C++ or Python as a starting point into GUI programming? | I have neglected my programming skills since i left school and now i want to start a few things that are running around in my head. Qt would be the toolkit for me to use but i am undecided if i should use Python (looks to me like the easier to learn with a few general ideas about programming) or C++ (the thing to use w... | [
"Being an expert in both C++ and Python, my mantra has long been \"Python where I can, C++ where I must\": Python is faster (in term of programmer productivity and development cycle) and easier, C++ can give that extra bit of power when I have to get close to the hardware or be extremely careful about every byte or... | [
25,
5,
4
] | [
"How about Ruby? You can write Qt apps in Ruby allegedly (http://rubyforge.org/projects/korundum), and it gives you a good excuse to look at the very excellent \"Why's Poignant Guide...\" (http://poignantguide.net) which is how Monty Python would have introduced programming....\n(Actually thinking about learning py... | [
-1
] | [
"c++",
"python",
"qt"
] | stackoverflow_0001084935_c++_python_qt.txt |
Q:
Transition from Python2.4 to Python2.6 on CentOS, module migration problem
I have a problem of upgrading python from 2.4 to 2.6:
I have CentOS 5 (Full). It has python 2.4 living in /usr/lib/python2.4/ . Additional modules are living in /usr/lib/python2.4/site-packages/ . I've built python 2.6 from sources at /usr/... | Transition from Python2.4 to Python2.6 on CentOS, module migration problem | I have a problem of upgrading python from 2.4 to 2.6:
I have CentOS 5 (Full). It has python 2.4 living in /usr/lib/python2.4/ . Additional modules are living in /usr/lib/python2.4/site-packages/ . I've built python 2.6 from sources at /usr/local/lib/python2.6/ . I've set default python to python2.6 . Now old modules f... | [
"They are not broken, they are simply not installed. The solution to that is to install them under 2.6. But first we should see if you really should do that...\nYes, Python will when installed replace the python command to the version installed (unless you run it with --alt-install). You don't exactly state what yo... | [
3,
0,
0,
0
] | [] | [] | [
"centos",
"linux",
"python",
"python_2.6",
"upgrade"
] | stackoverflow_0001081698_centos_linux_python_python_2.6_upgrade.txt |
Q:
Downloading a Large Number of Files from S3
What's the Fastest way to get a large number of files (relatively small 10-50kB) from Amazon S3 from Python? (In the order of 200,000 - million files).
At the moment I am using boto to generate Signed URLs, and using PyCURL to get the files one by one.
Would some type ... | Downloading a Large Number of Files from S3 | What's the Fastest way to get a large number of files (relatively small 10-50kB) from Amazon S3 from Python? (In the order of 200,000 - million files).
At the moment I am using boto to generate Signed URLs, and using PyCURL to get the files one by one.
Would some type of concurrency help? PyCurl.CurlMulti object?
I ... | [
"I don't know anything about python, but in general you would want to break the task down into smaller chunks so that they can be run concurrently. You could break it down by file type, or alphabetical or something, and then run a separate script for each portion of the break down.\n",
"In the case of python, as... | [
2,
1,
1,
0,
0,
0
] | [] | [] | [
"amazon_s3",
"amazon_web_services",
"boto",
"curl",
"python"
] | stackoverflow_0001051275_amazon_s3_amazon_web_services_boto_curl_python.txt |
Q:
Problem with printing contents of a list
I'm having a somewhat odd problem with Python(2.6.2) that I've come to the conclusion is a bug in the Vista port (I cant replicate it in XP or Linux).
I have a list of users, encrypted passwords, and their host that I am storing in a larger list (it's acting as a sort of da... | Problem with printing contents of a list | I'm having a somewhat odd problem with Python(2.6.2) that I've come to the conclusion is a bug in the Vista port (I cant replicate it in XP or Linux).
I have a list of users, encrypted passwords, and their host that I am storing in a larger list (it's acting as a sort of database).
This all works fine and dandy, except... | [
"Your file users.txt is in UTF-16, but you're opening it as ASCII.\nEither change it to ASCII, or open it like this:\nimport codecs\nusers = codecs.open( \"users-16.txt\", \"r\", \"utf-16\" )\n\n",
"Try replacing\ncreate_user( user )\n\nwith\ncreate_user( user.decode(\"utf16\") )\n\n"
] | [
6,
1
] | [] | [] | [
"python"
] | stackoverflow_0001085051_python.txt |
Q:
Does creating separate functions instead of one big one slow processing time?
I'm working in the Google App Engine environment and programming in Python. I am creating a function that essentially generates a random number/letter string and then stores to the memcache.
def generate_random_string():
# return a ra... | Does creating separate functions instead of one big one slow processing time? | I'm working in the Google App Engine environment and programming in Python. I am creating a function that essentially generates a random number/letter string and then stores to the memcache.
def generate_random_string():
# return a random 6-digit long string
def check_and_store_to_memcache():
randomstring = gen... | [
"Focus on being able to read and easily understand your code.\nOnce you've done this, if you have a performance problem, then look into what might be causing it.\nMost languages, python included, tend to have fairly low overhead for making method calls. Putting this code into a single function is not going to (dra... | [
38,
24,
4,
2
] | [] | [] | [
"function",
"google_app_engine",
"performance",
"python"
] | stackoverflow_0001083105_function_google_app_engine_performance_python.txt |
Q:
How to recommend the next achievement
Short version:
I have a similar setup to StackOverflow. Users get Achievements. I have many more achievements than SO, lets say on the order of 10k, and each user has in the 100s of achievements. Now, how would you recommend (to recommend) the next achievement for a user to t... | How to recommend the next achievement | Short version:
I have a similar setup to StackOverflow. Users get Achievements. I have many more achievements than SO, lets say on the order of 10k, and each user has in the 100s of achievements. Now, how would you recommend (to recommend) the next achievement for a user to try for?
Long version:
The objects are model... | [
"One method you can recommend which achievements to go for is to see how many of your users already have those achievements and recommend those popular ones. When they have achieved those you go down the list and recommend slightly less popular ones. However, this has a naive assumption that everyone wants to go fo... | [
3,
2
] | [] | [] | [
"achievements",
"django",
"optimization",
"python"
] | stackoverflow_0001081789_achievements_django_optimization_python.txt |
Q:
How to check available Python libraries on Google App Engine & add more
How to check available Python libraries on Google App Engine & add more?
Is SQLite available or we must use GQL with their database system only?
Thank you in advance.
A:
SQLite is there (but since you cannot write to files, you must use it i... | How to check available Python libraries on Google App Engine & add more | How to check available Python libraries on Google App Engine & add more?
Is SQLite available or we must use GQL with their database system only?
Thank you in advance.
| [
"SQLite is there (but since you cannot write to files, you must use it in a read-only way, or on a :memory: database).\nApp engine docs do a good job at documenting what's there. You can add any other pure-python library, typically as a zipfile of .py (NOT .pyc) files to upload in the main directory of your app (yo... | [
4,
1
] | [] | [] | [
"google_app_engine",
"python",
"sqlite"
] | stackoverflow_0001085538_google_app_engine_python_sqlite.txt |
Q:
How do I install with distutils to a specific Python installation?
I have a Windows machine with Python 2.3, 2.6 and 3.0 installed and 2.5 installed with Cygwin. I've downloaded the pexpect package but when I run "python setup.py install" it installs to the 2.6 installation.
How could I have it install to the Cygw... | How do I install with distutils to a specific Python installation? | I have a Windows machine with Python 2.3, 2.6 and 3.0 installed and 2.5 installed with Cygwin. I've downloaded the pexpect package but when I run "python setup.py install" it installs to the 2.6 installation.
How could I have it install to the Cygwin Python installation, or any other installation?
| [
"call the specific python version that you want to install for. For example:\n$ python2.3 setup.py install\n\nshould install the package for python 2.3\n",
"using \"python2.3\" can be wrong if another (default) installation patched PATH to itself only.\nTask can be solved by:\n\nfinding full path to desired pytho... | [
5,
0
] | [] | [] | [
"distutils",
"installation",
"python"
] | stackoverflow_0001059594_distutils_installation_python.txt |
Q:
What's the simplest way to put a python script into the system tray (Windows)
What's the simplest way to put a python script into the system tray?
My target platform is Windows. I don't want to see the 'cmd.exe' window.
A:
Those are two questions, actually:
Adding a tray icon can be done with Win32 API. Example... | What's the simplest way to put a python script into the system tray (Windows) | What's the simplest way to put a python script into the system tray?
My target platform is Windows. I don't want to see the 'cmd.exe' window.
| [
"Those are two questions, actually:\n\nAdding a tray icon can be done with Win32 API. Example: SysTrayIcon.py\nHiding the cmd.exe window is as easy as using pythonw.exe instead of python.exe to run your scripts.\n\n"
] | [
54
] | [] | [] | [
"python",
"system_tray"
] | stackoverflow_0001085694_python_system_tray.txt |
Q:
How do I use TLS with asyncore?
An asyncore-based XMPP client opens a normal TCP connection to an XMPP server. The server indicates it requires an encrypted connection. The client is now expected to start a TLS handshake so that subsequent requests can be encrypted.
tlslite integrates with asyncore, but the sample... | How do I use TLS with asyncore? | An asyncore-based XMPP client opens a normal TCP connection to an XMPP server. The server indicates it requires an encrypted connection. The client is now expected to start a TLS handshake so that subsequent requests can be encrypted.
tlslite integrates with asyncore, but the sample code is for a server (?) and I don't... | [
"Definitely check out twisted and wokkel. I've been building tons of xmpp bots and components with it and it's a dream.\n",
"I've followed what I believe are all the steps tlslite documents to make an asyncore client work -- I can't actually get it to work since the only asyncore client I have at hand to tweak f... | [
4,
2
] | [] | [] | [
"python",
"ssl"
] | stackoverflow_0001085050_python_ssl.txt |
Q:
where to start OpenID implementation in python,which API is better suits
im using python API in our research project.i read lot of ppt and material, and finally understand this concept now i have task to execute simple function which is chek user credential thorough openid provider and return successful after the ... | where to start OpenID implementation in python,which API is better suits | im using python API in our research project.i read lot of ppt and material, and finally understand this concept now i have task to execute simple function which is chek user credential thorough openid provider and return successful after the valid user check.....
| [
"To add to the recommendation of the Python OpenID library: their docs pages for the server and consumer modules both have useful Overview sections which you should read as a good starting point. The examples directory is also useful; I've written things starting from server.py and consumer.py from there.\n",
"Wh... | [
3,
2
] | [] | [] | [
"python"
] | stackoverflow_0001086127_python.txt |
Q:
Is is possible to return an object or value from a Python script to the hosting application?
For example in Lua you can place the following line at the end of a script:
return <some-value/object>
The value/object that is returned can then be retrieved by the hosting application.
I use this pattern so that scripts... | Is is possible to return an object or value from a Python script to the hosting application? | For example in Lua you can place the following line at the end of a script:
return <some-value/object>
The value/object that is returned can then be retrieved by the hosting application.
I use this pattern so that scripts can represent factories for event handlers. The script-based event handlers are then used to ext... | [
"It's totally possible and a common technique when embedding Python. This article shows the basics, as does this page. The core function is PyObject_CallObject() which calls code written in Python, from C.\n",
"This can be done in Python just the same way. You can require the plugin to provide a getHandler() func... | [
2,
2,
2,
0
] | [] | [] | [
"c#",
"ironpython",
"python"
] | stackoverflow_0001086188_c#_ironpython_python.txt |
Q:
Parsing HTML rows into CSV
First off the html row looks like this:
<tr class="evenColor"> blahblah TheTextIneed blahblah and ends with </tr>
I would show the real html but I am sorry to say don't know how to block it. feels shame
Using BeautifulSoup (Python) or any other recommended Screen Scraping/Parsing metho... | Parsing HTML rows into CSV | First off the html row looks like this:
<tr class="evenColor"> blahblah TheTextIneed blahblah and ends with </tr>
I would show the real html but I am sorry to say don't know how to block it. feels shame
Using BeautifulSoup (Python) or any other recommended Screen Scraping/Parsing method I would like to output about 1... | [
"You don't really explain why you are stuck - what's not working exactly?\nThe following line may well be your problem:\nsoup = BeautifulSoup(open(filename[\"r\"]))\n\nIt looks to me like this should be:\nsoup = BeautifulSoup(open(filename, \"r\"))\n\nThe following line:\nfor row in soup.findAll(\"tr\", attrs={ \"c... | [
4,
4,
2
] | [] | [] | [
"beautifulsoup",
"csv",
"html",
"python",
"screen_scraping"
] | stackoverflow_0001086266_beautifulsoup_csv_html_python_screen_scraping.txt |
Q:
Django: information captured from URLs available in template files?
Given:
urlpatterns = \
patterns('blog.views',
(r'^blog/(?P<year>\d{4})/$', 'year_archive', {'foo': 'bar'}),
)
in a urls.py file. (Should it be 'archive_year' instead
of 'year_archive' ?... | Django: information captured from URLs available in template files? | Given:
urlpatterns = \
patterns('blog.views',
(r'^blog/(?P<year>\d{4})/$', 'year_archive', {'foo': 'bar'}),
)
in a urls.py file. (Should it be 'archive_year' instead
of 'year_archive' ? - see below for ref.)
Is it possible to capture information from the URL... | [
"No, that's not possible within the URLConf -- the dispatcher has a fixed set of things it does. (It takes the group dictionary from your regex match and passes it as keyword arguments to your view function.) Within your (custom) view function, you should be able to manipulate how those values are passed into the t... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001086531_django_python.txt |
Q:
What is the best way to do Bit Field manipulation in Python?
I'm reading some MPEG Transport Stream protocol over UDP and it has some funky bitfields in it (length 13 for example). I'm using the "struct" library to do the broad unpacking, but is there a simple way to say "Grab the next 13 bits" rather than have to... | What is the best way to do Bit Field manipulation in Python? | I'm reading some MPEG Transport Stream protocol over UDP and it has some funky bitfields in it (length 13 for example). I'm using the "struct" library to do the broad unpacking, but is there a simple way to say "Grab the next 13 bits" rather than have to hand-tweak the bit manipulation? I'd like something like the way ... | [
"The bitstring module is designed to address just this problem. It will let you read, modify and construct data using bits as the basic building blocks. The latest versions are for Python 2.6 or later (including Python 3) but version 1.0 supported Python 2.4 and 2.5 as well.\nA relevant example for you might be thi... | [
26,
8
] | [] | [] | [
"bit",
"bit_fields",
"python",
"udp"
] | stackoverflow_0000039663_bit_bit_fields_python_udp.txt |
Q:
Python: How can I import all variables?
I'm new to Python and programming in general (a couple of weeks at most).
Concerning Python and using modules, I realise that functions can imported using from a import *.
So instead of typing
a.sayHi()
a.sayBye()
I can say
sayHi()
sayBye()
which I find simplifies things a... | Python: How can I import all variables? | I'm new to Python and programming in general (a couple of weeks at most).
Concerning Python and using modules, I realise that functions can imported using from a import *.
So instead of typing
a.sayHi()
a.sayBye()
I can say
sayHi()
sayBye()
which I find simplifies things a great deal. Now, say I have a bunch of varia... | [
"You gave the solution yourself: from a import * will work just fine. Python does not differentiate between functions and variables in this respect.\n>>> from a import *\n>>> if name == \"Michael\" and age == 15:\n... print('Simple!')\n...\nSimple!\n\n",
"Just for some context, most linters will flag from mod... | [
79,
38,
14,
8
] | [] | [] | [
"import",
"module",
"python",
"variables"
] | stackoverflow_0001084977_import_module_python_variables.txt |
Q:
how to make table partitions?
I am not very familiar with databases, and so I do not know how to partition a table using SQLAlchemy.
Your help would be greatly appreciated.
A:
There are two kinds of partitioning: Vertical Partitioning and Horizontal Partitioning.
From the docs:
Vertical Partitioning
Vertical pa... | how to make table partitions? | I am not very familiar with databases, and so I do not know how to partition a table using SQLAlchemy.
Your help would be greatly appreciated.
| [
"There are two kinds of partitioning: Vertical Partitioning and Horizontal Partitioning.\nFrom the docs:\n\nVertical Partitioning\nVertical partitioning places different\n kinds of objects, or different tables,\n across multiple databases:\nengine1 = create_engine('postgres://db1')\nengine2 = create_engine('postg... | [
4,
3,
3
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0001085304_python_sqlalchemy.txt |
Q:
Boolean value of objects in Python
As we know, Python has boolean values for objects: If a class has a __len__ method, every instance of it for which __len__() happens to return 0 will be evaluated as a boolean False (for example, the empty list).
In fact, every iterable, empty custom object is evaluated as False ... | Boolean value of objects in Python | As we know, Python has boolean values for objects: If a class has a __len__ method, every instance of it for which __len__() happens to return 0 will be evaluated as a boolean False (for example, the empty list).
In fact, every iterable, empty custom object is evaluated as False if it appears in boolean expression.
Now... | [
"In Python < 3.0 :\nYou have to use __nonzero__ to achieve what you want. It's a method that is called automatically by Python when evaluating an object in a boolean context. It must return a boolean that will be used as the value to evaluate.\nE.G :\nclass Foo(object):\n\n def __init__(self, bar) :\n sel... | [
56,
39
] | [] | [] | [
"boolean",
"python"
] | stackoverflow_0001087135_boolean_python.txt |
Q:
Can I be warned when I used a generator function by accident
I was working with generator functions and private functions of a class. I am wondering
Why when yielding (which in my one case was by accident) in __someFunc that this function just appears not to be called from within __someGenerator. Also what is the... | Can I be warned when I used a generator function by accident | I was working with generator functions and private functions of a class. I am wondering
Why when yielding (which in my one case was by accident) in __someFunc that this function just appears not to be called from within __someGenerator. Also what is the terminology I want to use when referring to these aspects of the ... | [
"A \"generator\" isn't so much a language feature, as a name for functions that \"yield.\" Yielding is pretty much always legal. There's not really any way for Python to know that you didn't \"mean\" to yield from some function.\nThis PEP http://www.python.org/dev/peps/pep-0255/ talks about generators, and may he... | [
6,
2,
2,
1,
0
] | [] | [] | [
"function",
"generator",
"language_features",
"python"
] | stackoverflow_0001087019_function_generator_language_features_python.txt |
Q:
Can bin() be overloaded like oct() and hex() in Python 2.6?
In Python 2.6 (and earlier) the hex() and oct() built-in functions can be overloaded in a class by defining __hex__ and __oct__ special functions. However there is not a __bin__ special function for overloading the behaviour of Python 2.6's new bin() buil... | Can bin() be overloaded like oct() and hex() in Python 2.6? | In Python 2.6 (and earlier) the hex() and oct() built-in functions can be overloaded in a class by defining __hex__ and __oct__ special functions. However there is not a __bin__ special function for overloading the behaviour of Python 2.6's new bin() built-in function.
I want to know if there is any way of flexibly ove... | [
"As you've already discovered, you can't override bin(), but it doesn't sound like you need to do that. You just want a 0-padded binary value. Unfortunately in python 2.5 and previous, you couldn't use \"%b\" to indicate binary, so you can't use the \"%\" string formatting operator to achieve the result you want.... | [
12,
7,
1,
0
] | [] | [] | [
"binary",
"overloading",
"python",
"python_2.6"
] | stackoverflow_0001002116_binary_overloading_python_python_2.6.txt |
Q:
file I/O in Spidermonkey
Thanks to python-spidermonkey, using JavaScript code from Python is really easy.
However, instead of using Python to read JS code from a file and passing the string to Spidermonkey, is there a way to read the file from within Spidermonkey (or pass the filepath as an argument, as in Rhino)?... | file I/O in Spidermonkey | Thanks to python-spidermonkey, using JavaScript code from Python is really easy.
However, instead of using Python to read JS code from a file and passing the string to Spidermonkey, is there a way to read the file from within Spidermonkey (or pass the filepath as an argument, as in Rhino)?
| [
"The SpiderMonkey as a library allows that by calling the JS_EvaluateScript with a non-NULL filename argument.\nHowever, the interfacing code of python-spidermonkey calls JS_EvaluateScript only inside the eval_script method, which as coded supplies source only as a string.\nYou should address your issue to the pyth... | [
2,
2
] | [] | [] | [
"javascript",
"python",
"spidermonkey"
] | stackoverflow_0001055850_javascript_python_spidermonkey.txt |
Q:
Reportlab page x of y NumberedCanvas and Images
I had been using the reportlab NumberedCanvas given at http://code.activestate.com/recipes/546511/ . However, when i try to build a PDF that contains Image flowables, the images do not show, although enough vertical space is left for the image to fit. Is there any so... | Reportlab page x of y NumberedCanvas and Images | I had been using the reportlab NumberedCanvas given at http://code.activestate.com/recipes/546511/ . However, when i try to build a PDF that contains Image flowables, the images do not show, although enough vertical space is left for the image to fit. Is there any solution for this?
| [
"See my new, improved recipe for this, which includes a simple test with images. Here's an excerpt from the recipe (which omits the test code):\nfrom reportlab.pdfgen import canvas\nfrom reportlab.lib.units import mm\n\nclass NumberedCanvas(canvas.Canvas):\n def __init__(self, *args, **kwargs):\n canvas.C... | [
13
] | [] | [] | [
"python",
"reportlab"
] | stackoverflow_0001087495_python_reportlab.txt |
Q:
testing python applications that use mysql
I want to write some unittests for an application that uses MySQL. However, I do not want to connect to a real mysql database, but rather to a temporary one that doesn't require any SQL server at all.
Any library (I could not find anything on google)? Any design pattern? ... | testing python applications that use mysql | I want to write some unittests for an application that uses MySQL. However, I do not want to connect to a real mysql database, but rather to a temporary one that doesn't require any SQL server at all.
Any library (I could not find anything on google)? Any design pattern? Note that DIP doesn't work since I will still ha... | [
"There isn't a good way to do that. You want to run your queries against a real MySQL server, otherwise you don't know if they will work or not.\nHowever, that doesn't mean you have to run them against a production server. We have scripts that create a Unit Test database, and then tear it down once the unit tests ... | [
12,
4
] | [] | [] | [
"mysql",
"python",
"unit_testing"
] | stackoverflow_0001088077_mysql_python_unit_testing.txt |
Q:
Sorting a Python list by key... while checking for string OR float?
Ok, I've got a list like this (just a sample of data):
data = {"NAME": "James", "RANK": "3.0", "NUM": "27.5" ... }
Now, if I run something like this:
sortby = "NAME" //this gets passed to the function, hence why I am using a variable sortby inste... | Sorting a Python list by key... while checking for string OR float? | Ok, I've got a list like this (just a sample of data):
data = {"NAME": "James", "RANK": "3.0", "NUM": "27.5" ... }
Now, if I run something like this:
sortby = "NAME" //this gets passed to the function, hence why I am using a variable sortby instead
data.sort(key=itemgetter(sortby))
I get all the strings sorted proper... | [
"If you want a general function which you can pass as a parameter to sort(key=XXX), then here's a candidate complete with test:\nDATA = [\n { 'name' : 'A', 'value' : '10.0' },\n { 'name' : 'B', 'value' : '2.0' },\n]\n\ndef get_attr(name):\n def inner_func(o):\n try:\n rv = float(o[name])\... | [
7,
4,
0
] | [] | [] | [
"list",
"python",
"sorting"
] | stackoverflow_0001088392_list_python_sorting.txt |
Q:
Python Libraries for FTP Upload/Download?
Okay so a bit of forward:
We have a service/daemon written in python that monitors remote ftp sites. These sites are not under our command, some of them we do NOT have del/rename/write access, some also are running extremely old ftp software. Such that certain commands do ... | Python Libraries for FTP Upload/Download? | Okay so a bit of forward:
We have a service/daemon written in python that monitors remote ftp sites. These sites are not under our command, some of them we do NOT have del/rename/write access, some also are running extremely old ftp software. Such that certain commands do not work. There is no standardization among any... | [
"You don't mention which alternatives you've looked at already. Is ftputil one of them?\nhttp://ftputil.sschwarzer.net/trac/wiki/Documentation\nIf you're trying to code around edge cases from various server implementations, you might be better off looking at the code used by Mozilla/Firefox. I imagine this is one ... | [
2,
1
] | [] | [] | [
"ftp",
"ftplib",
"python"
] | stackoverflow_0001088518_ftp_ftplib_python.txt |
Q:
How to print output using python?
When this .exe file runs it prints a screen full of information and I want to print a particular line out to the screen, here on line "6":
cmd = ' -a ' + str(a) + ' -b ' + str(b) + str(Output)
process = Popen(cmd, shell=True, stderr=STDOUT, stdout=PIPE)
outputstring =... | How to print output using python? | When this .exe file runs it prints a screen full of information and I want to print a particular line out to the screen, here on line "6":
cmd = ' -a ' + str(a) + ' -b ' + str(b) + str(Output)
process = Popen(cmd, shell=True, stderr=STDOUT, stdout=PIPE)
outputstring = process.communicate()[0]
outputlis... | [
"You're trying to append the result of a call into the call itself. You have to run the command once without the + str(Output) part to get the output in the first place.\nThink about it this way. Let's say I was adding some numbers together.\n z = 5 + b\n b = z + 2\n\nI have to define either z or b before the state... | [
5,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0001088764_python.txt |
Q:
Decorator to mark a method to be executed no more than once even if called several times
I will go straight to the example:
class Foo:
@execonce
def initialize(self):
print 'Called'
>>> f1 = Foo()
>>> f1.initialize()
Called
>>> f1.initialize()
>>> f2 = Foo()
>>> f2.initialize()
Called
>>> f2.initialize()
... | Decorator to mark a method to be executed no more than once even if called several times | I will go straight to the example:
class Foo:
@execonce
def initialize(self):
print 'Called'
>>> f1 = Foo()
>>> f1.initialize()
Called
>>> f1.initialize()
>>> f2 = Foo()
>>> f2.initialize()
Called
>>> f2.initialize()
>>>
I tried to define execonce but could not write one that works with methods.
PS: I cannot... | [
"import functools\n\ndef execonce(f):\n\n @functools.wraps(f)\n def donothing(*a, **k):\n pass\n\n @functools.wraps(f)\n def doit(self, *a, **k):\n try:\n return f(self, *a, **k)\n finally:\n setattr(self, f.__name__, donothing)\n\n return doit\n\n",
"You ... | [
6,
0,
0
] | [] | [] | [
"class",
"decorator",
"methods",
"python"
] | stackoverflow_0001089023_class_decorator_methods_python.txt |
Q:
Pythonic way to log specific things to a file?
I understand that Python loggers cannot be instantiated directly, as the documentation suggests:
Note that Loggers are never
instantiated directly, but always
through the module-level function
logging.getLogger(name)
.. which is reasonable, as you are expected... | Pythonic way to log specific things to a file? | I understand that Python loggers cannot be instantiated directly, as the documentation suggests:
Note that Loggers are never
instantiated directly, but always
through the module-level function
logging.getLogger(name)
.. which is reasonable, as you are expected not to create logger objects for every class/module... | [
"Instead of many loggers, you could use one logger and many handlers. For example:\nlog = logging.getLogger(name)\nwhile some_condition:\n try:\n handler = make_handler(filename)\n log.addHandler(handler)\n # do something and log\n\n finally:\n log.removeHandler(handler)\n ... | [
4,
1,
0
] | [] | [] | [
"logging",
"python"
] | stackoverflow_0001089269_logging_python.txt |
Q:
App Engine db.model reference question
How can I get at the Labels data from within my Task model?
class Task(db.Model):
title = db.StringProperty()
class Label(db.Model):
name = db.StringProperty()
class Tasklabel(db.Model):
task = db.ReferenceProperty(Task)
label = db.ReferenceProperty(Label)
creating... | App Engine db.model reference question | How can I get at the Labels data from within my Task model?
class Task(db.Model):
title = db.StringProperty()
class Label(db.Model):
name = db.StringProperty()
class Tasklabel(db.Model):
task = db.ReferenceProperty(Task)
label = db.ReferenceProperty(Label)
creating the association is no problem, but how can ... | [
"This worked for me with your current datamodel:\ntaskObject = db.Query(Task).get()\nfor item in taskObject.tasklabel_set:\n item.label.name\n\nOr you could remove the Label class and just do a one-to-many relationship between Task and TaskLabel:\nclass Task(db.Model):\n title = db.StringProperty()\n\... | [
2,
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0001088678_google_app_engine_python.txt |
Q:
Django: Dynamic LOGIN_URL variable
Currently, in my settings module I have this:
LOGIN_URL = '/login'
If I ever decide to change the login URL in urls.py, I'll have to change it here as well. Is there any more dynamic way of doing this?
A:
Settings IS where you are setting your dynamic login url. Make sure to i... | Django: Dynamic LOGIN_URL variable | Currently, in my settings module I have this:
LOGIN_URL = '/login'
If I ever decide to change the login URL in urls.py, I'll have to change it here as well. Is there any more dynamic way of doing this?
| [
"Settings IS where you are setting your dynamic login url. Make sure to import LOGIN_URL from settings.py in your urls.py and use that instead.\nfrom projectname.settings import LOGIN_URL\n\n",
"This works for me ... with LOGIN_URL = '/accounts/login'\nIf the problem is that settings.py has ...\nLOGIN_URL = '/log... | [
7,
4
] | [] | [] | [
"django",
"django_urls",
"python"
] | stackoverflow_0001088913_django_django_urls_python.txt |
Q:
How to make custom PhotoEffects in Django Photologue?
I'm creating an image gallery in Django using the Photologue application. There are a number of PhotoEffects that come with it. I'd like to extend these and make my own so that I can do more complicated effects such as adding drop shadows, glossy overlays, et... | How to make custom PhotoEffects in Django Photologue? | I'm creating an image gallery in Django using the Photologue application. There are a number of PhotoEffects that come with it. I'd like to extend these and make my own so that I can do more complicated effects such as adding drop shadows, glossy overlays, etc.
Is is possible to create custom effects that Photologue ... | [
"I'm the developer of Photologue. I would suggest you look at the 3.x branch of Photologue and more specifically, django-imagekit, the new Library it's based on: http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home. One of the goals of ImageKit was to make it easier to extend Photologue. All effects and manipul... | [
2,
1
] | [] | [] | [
"django",
"photologue",
"python",
"python_imaging_library"
] | stackoverflow_0001089304_django_photologue_python_python_imaging_library.txt |
Q:
How does Python store lists internally?
How are lists in python stored internally? Is it an array? A linked list? Something else?
Or does the interpreter guess at the right structure for each instance based on length, etc.
If the question is implementation dependent, what about the classic CPython?
A:
from Core ... | How does Python store lists internally? | How are lists in python stored internally? Is it an array? A linked list? Something else?
Or does the interpreter guess at the right structure for each instance based on length, etc.
If the question is implementation dependent, what about the classic CPython?
| [
"from Core Python Containers: Under the Hood\nList Implementation:\nFixed-length array of pointers\n* When the array grows or shrinks, calls realloc() and, if necessary, copies all of the items to the new space\nsource code: Include/listobject.h and Objects/listobject.c\nbtw: here is the video\n"
] | [
31
] | [] | [] | [
"data_structures",
"python"
] | stackoverflow_0001090104_data_structures_python.txt |
Q:
Python: Inflate and Deflate implementations
I am interfacing with a server that requires that data sent to it is compressed with Deflate algorithm (Huffman encoding + LZ77) and also sends data that I need to Inflate.
I know that Python includes Zlib, and that the C libraries in Zlib support calls to Inflate and ... | Python: Inflate and Deflate implementations | I am interfacing with a server that requires that data sent to it is compressed with Deflate algorithm (Huffman encoding + LZ77) and also sends data that I need to Inflate.
I know that Python includes Zlib, and that the C libraries in Zlib support calls to Inflate and Deflate, but these apparently are not provided by... | [
"You can still use the zlib module to inflate/deflate data. The gzip module uses it internally, but adds a file-header to make it into a gzip-file. Looking at the gzip.py file, something like this could work:\nimport zlib\n\ndef deflate(data, compresslevel=9):\n compress = zlib.compressobj(\n compress... | [
29,
25
] | [] | [] | [
"c#",
"compression",
"python",
"zlib"
] | stackoverflow_0001089662_c#_compression_python_zlib.txt |
Q:
Python remove all lines which have common value in fields
I have lines of data comprising of 4 fields
aaaa bbb1 cccc dddd
aaaa bbb2 cccc dddd
aaaa bbb3 cccc eeee
aaaa bbb4 cccc ffff
aaaa bbb5 cccc gggg
aaaa bbb6 cccc dddd
Please bear with me.
The first and third field is always the same - but I do... | Python remove all lines which have common value in fields | I have lines of data comprising of 4 fields
aaaa bbb1 cccc dddd
aaaa bbb2 cccc dddd
aaaa bbb3 cccc eeee
aaaa bbb4 cccc ffff
aaaa bbb5 cccc gggg
aaaa bbb6 cccc dddd
Please bear with me.
The first and third field is always the same - but I don't need them, the 4th field can be the same or different. The ... | [
"Here you go:\nfrom collections import defaultdict\n\nLINES = \"\"\"\\\naaaa bbb1 cccc dddd\naaaa bbb2 cccc dddd\naaaa bbb3 cccc eeee\naaaa bbb4 cccc ffff\naaaa bbb5 cccc gggg\naaaa bbb6 cccc dddd\"\"\".split('\\n')\n\n# Count how many lines each unique value of the fourth field appears in.\nd_counts = defaultdict(... | [
6,
0
] | [] | [] | [
"duplicate_removal",
"python"
] | stackoverflow_0001089550_duplicate_removal_python.txt |
Q:
Special (magic) methods in Python
What are all the special (magic) methods in Python? The __xxx__ methods, that is.
I'm often looking for a way to override something which I know is possible to do through one of these methods, but I'm having a hard time to find how since as far as I can tell there is no definitive... | Special (magic) methods in Python | What are all the special (magic) methods in Python? The __xxx__ methods, that is.
I'm often looking for a way to override something which I know is possible to do through one of these methods, but I'm having a hard time to find how since as far as I can tell there is no definitive list of these methods, PLUS their name... | [
"At the python level, most of them are documented in the language reference. At the C level, you can find it under the object protocol section (strictly speaking, you only have a subset here, though).\n"
] | [
52
] | [] | [] | [
"python"
] | stackoverflow_0001090620_python.txt |
Q:
Python operators
I am learning Python for the past few days and I have written this piece of code to evaluate a postfix expression.
postfix_expression = "34*34*+"
stack = []
for char in postfix_expression :
try :
char = int(char);
stack.append(char);
except ValueError:
if char == ... | Python operators | I am learning Python for the past few days and I have written this piece of code to evaluate a postfix expression.
postfix_expression = "34*34*+"
stack = []
for char in postfix_expression :
try :
char = int(char);
stack.append(char);
except ValueError:
if char == '+' :
stac... | [
"The operator module has functions that implement the standard arithmetic operators. With that, you can set up a mapping like:\nOperatorFunctions = {\n '+': operator.add,\n '-': operator.sub,\n '*': operator.mul,\n '/': operator.div,\n # etc\n}\n\nThen your main loop can look something like this:\nfo... | [
17
] | [
"Just use eval along with string generation:\npostfix_expression = \"34*34*+\"\nstack = []\nfor char in postfix_expression:\n if char in '+-*/':\n expression = '%d%s%d' % (stack.pop(), char, stack.pop())\n stack.append(eval(expression))\n else:\n stack.append(int(char))\nprint stack.pop()... | [
-1,
-1
] | [
"operators",
"python"
] | stackoverflow_0001090863_operators_python.txt |
Q:
Drawbacks of storing an integer as a string in a database
I have id values for products that I need store. Right now they are all integers, but I'm not sure if the data provider in the future will introduce letters or symbols into that mix, so I'm debating whether to store it now as integer or string.
Are there pe... | Drawbacks of storing an integer as a string in a database | I have id values for products that I need store. Right now they are all integers, but I'm not sure if the data provider in the future will introduce letters or symbols into that mix, so I'm debating whether to store it now as integer or string.
Are there performance or other disadvantages to saving the values as string... | [
"Unless you really need the features of an integer (that is, the ability to do arithmetic), then it is probably better for you to store the product IDs as strings. You will never need to do anything like add two product IDs together, or compute the average of a group of product IDs, so there is no need for an actua... | [
37,
18,
3,
3,
1,
1,
1,
0,
0,
0
] | [] | [] | [
"database",
"database_design",
"mysql",
"python"
] | stackoverflow_0001090022_database_database_design_mysql_python.txt |
Q:
How to communicate between Python and C# using XML-RPC?
Assume I have a simple XML-RPC service that is implemented with Python:
from SimpleXMLRPCServer import SimpleXMLRPCServer # Python 2
def getTest():
return 'test message'
if __name__ == '__main__' :
server = SimpleXMLRPCServer(('localhost', 8888))
... | How to communicate between Python and C# using XML-RPC? | Assume I have a simple XML-RPC service that is implemented with Python:
from SimpleXMLRPCServer import SimpleXMLRPCServer # Python 2
def getTest():
return 'test message'
if __name__ == '__main__' :
server = SimpleXMLRPCServer(('localhost', 8888))
server.register_function(getTest)
server.serve_forever... | [
"Not to toot my own horn, but: http://liboxide.svn.sourceforge.net/viewvc/liboxide/trunk/Oxide.Net/Rpc/\nclass XmlRpcTest : XmlRpcClient\n{\n private static Uri remoteHost = new Uri(\"http://localhost:8888/\");\n\n [RpcCall]\n public string GetTest()\n {\n return (string)DoRequest(remoteHost, \n ... | [
3,
3,
2
] | [] | [] | [
"c#",
"python",
"xml_rpc"
] | stackoverflow_0001090792_c#_python_xml_rpc.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.