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:
py2exe - generated executable freezes when connecting to socket
Pardon my ignorance as I'm still a beginner in coding.
I'm trying to convert a python script I wrote to a Windows executable program using py2exe. However, though I am able to successfully convert the script, the executable doesn't seem to be fully fu... | py2exe - generated executable freezes when connecting to socket | Pardon my ignorance as I'm still a beginner in coding.
I'm trying to convert a python script I wrote to a Windows executable program using py2exe. However, though I am able to successfully convert the script, the executable doesn't seem to be fully functional.
After much debugging, I have isolated the cause and the fol... | [
"Are you able to input the IP address? Reading that thread it seems that py2exe requires a special windows argument to launch a console. Otherwise, raw_input tries to read from the standard input, and hangs/crashes because it does not find anything.\nGiven the age of the thread, I checked py2exe doc: you might want... | [
1
] | [] | [] | [
"py2exe",
"python"
] | stackoverflow_0000931851_py2exe_python.txt |
Q:
AppEngine: Maintaining DataStore Consistency When Creating Records
I've hit a small dilemma! I have a handler called vote; when it is invoked it sets a user's vote to whatever they have picked. To remember what options they previously picked, I store a VoteRecord options which details what their current vote is se... | AppEngine: Maintaining DataStore Consistency When Creating Records | I've hit a small dilemma! I have a handler called vote; when it is invoked it sets a user's vote to whatever they have picked. To remember what options they previously picked, I store a VoteRecord options which details what their current vote is set to.
Of course, the first time they vote, I have to create the object a... | [
"The easiest way to do this is to use key names for your vote objects, and use Model.get_or_insert. First, come up with a naming scheme for your key names - naming it after the poll is a good idea - and then do a get_or_insert to fetch or create the relevant entity:\nvote = VoteRecord.get_or_insert(pollname, parent... | [
3,
1
] | [] | [] | [
"consistency",
"google_app_engine",
"google_cloud_datastore",
"python",
"transactions"
] | stackoverflow_0000522586_consistency_google_app_engine_google_cloud_datastore_python_transactions.txt |
Q:
Search functionality for Django
I'm developing a web app using Django, and I'll need to add search functionality soon. Search will be implemented for two models, one being an extension of the auth user class and another one with the fields name, tags, and description. So I guess nothing too scary here in context o... | Search functionality for Django | I'm developing a web app using Django, and I'll need to add search functionality soon. Search will be implemented for two models, one being an extension of the auth user class and another one with the fields name, tags, and description. So I guess nothing too scary here in context of searching text.
For development I a... | [
"If that field tags means what I think it means, i.e. you plan to store a string which concatenates multiple tags for an item, then you might need full-text search on it... but it's a bad design; rather, you should have a many-many relationship between items and a tags table (in another table, ItemTag or something,... | [
5,
1,
0,
0
] | [] | [] | [
"database",
"django",
"full_text_search",
"python",
"search"
] | stackoverflow_0000932255_database_django_full_text_search_python_search.txt |
Q:
How to parse angular values using regular expressions
I have very little experience using regular expressions and I need to parse an angle value expressed as bearings, using regular expressions, example:
"N45°20'15.3"E"
Which represents:
45 degrees, 20 minutes with 15.3 seconds, located at the NE quadrant.
The re... | How to parse angular values using regular expressions | I have very little experience using regular expressions and I need to parse an angle value expressed as bearings, using regular expressions, example:
"N45°20'15.3"E"
Which represents:
45 degrees, 20 minutes with 15.3 seconds, located at the NE quadrant.
The restrictions are:
The first character can be "N" or "S"
The ... | [
"Try this regular expression:\n^([NS])([0-5]?\\d)°([0-5]?\\d)'(?:([0-5]?\\d)(?:\\.\\d)?\")?([EW])$\n\nIt matches any string that …\n\n^([NS]) begins with N or S\n([0-5]?\\d)° followed by a degree value, either a single digit between 0 and 9 (\\d) or two digits with the first bewteen 0 and 5 ([0-5]) and the seco... | [
8,
4
] | [] | [] | [
"angle",
"python",
"regex"
] | stackoverflow_0000932796_angle_python_regex.txt |
Q:
Expression up to comment or end of line
Although this question is similar to this thread
I think I might be doing something wrong at the time of constructing the code with the Regular Expression.
I want to match anything in a line up to a comment ("#") or the end of the line (if it doesn't have a comment).
The reg... | Expression up to comment or end of line | Although this question is similar to this thread
I think I might be doing something wrong at the time of constructing the code with the Regular Expression.
I want to match anything in a line up to a comment ("#") or the end of the line (if it doesn't have a comment).
The regex I am using is: (.*)(#|$)
(.*) = Everything... | [
"The * is greedy (consumes as much of the string as it can) and is thus consuming the entire line (past the # and to the end-of-line). Change \".*\" to \".*?\" and it will work.\nSee the Regular Expression HOWTO for more information.\n",
"Here's the correct regex to do something like this:\n([^#]*)(#.*)?\n\nAlso... | [
7,
3,
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000932783_python_regex.txt |
Q:
skip over HTML tags in Regular Expression patterns
I'm trying to write a regular expression pattern (in python) for reformatting these template engine files.
Basically the scheme looks like this:
[$$price$$]
{
<h3 class="price">
$12.99
</h3>
}
I'm trying to make it remove any extra tabs\spaces\new lin... | skip over HTML tags in Regular Expression patterns | I'm trying to write a regular expression pattern (in python) for reformatting these template engine files.
Basically the scheme looks like this:
[$$price$$]
{
<h3 class="price">
$12.99
</h3>
}
I'm trying to make it remove any extra tabs\spaces\new lines so it should look like this:
[$$price$$]{<h3 class="p... | [
"Using regular expressions to deal with HTML is extremely error-prone; they're simply not the right tool.\nInstead, use a HTML/XML-aware library (such as lxml) to build a DOM-style object tree; modify the text segments within the tree in-place, and generate your output again using said library.\n",
"Try this:\n\\... | [
5,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000732465_python_regex.txt |
Q:
Python Regex combined with string substitution?
I'm wondering if its possible to use string substitution along with the python re module?
For example I'm using optparse and have a variable named options.hostname which will change each time the user executes the script.
I have the following regex matching 3 string... | Python Regex combined with string substitution? | I'm wondering if its possible to use string substitution along with the python re module?
For example I'm using optparse and have a variable named options.hostname which will change each time the user executes the script.
I have the following regex matching 3 strings in each line of the log file.
match = re.search (r... | [
" match = re.search (r'^\\[(\\d+)\\] (SERVICE NOTIFICATION:).*(\\bCRITICAL).*(%s)'\n % options.hostname, line)\n\n"
] | [
2
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000933046_python_regex.txt |
Q:
Python module globals versus __init__ globals
Apologies, somewhat confused Python newbie question. Let's say I have a module called animals.py.......
globvar = 1
class dog:
def bark(self):
print globvar
class cat:
def miaow(self):
print globvar
What is the difference between this and
class do... | Python module globals versus __init__ globals | Apologies, somewhat confused Python newbie question. Let's say I have a module called animals.py.......
globvar = 1
class dog:
def bark(self):
print globvar
class cat:
def miaow(self):
print globvar
What is the difference between this and
class dog:
def __init__(self):
global globvar
... | [
"global doesn't create a new variable, it just states that this name should refer to a global variable instead of a local one. Usually assignments to variables in a function/class/... refer to local variables. For example take a function like this:\ndef increment(n)\n # this creates a new local m\n m = n+1\n ret... | [
9,
4
] | [] | [] | [
"global",
"python"
] | stackoverflow_0000933042_global_python.txt |
Q:
XML characters in python xml.dom
I am working on producing an xml document from python. We are using the xml.dom package to create the xml document. We are having a problem where we want to produce the character φ which is a φ. However, when we put that string in a text node and call toxml() on it we ge... | XML characters in python xml.dom | I am working on producing an xml document from python. We are using the xml.dom package to create the xml document. We are having a problem where we want to produce the character φ which is a φ. However, when we put that string in a text node and call toxml() on it we get &#x03c6;. Our current solution ... | [
"I think you need to use a Unicode string with \\u03c6 in it, because the .data field of a text node is supposed (as far as I understand) to be \"parsed\" data, not including XML entities (whence the & when made back into XML). If you want to ensure that, on output, non-ascii characters are expressed as entiti... | [
1
] | [] | [] | [
"dom",
"python",
"xml"
] | stackoverflow_0000933004_dom_python_xml.txt |
Q:
Scope, using functions in current module
I know this must be a trivial question, but I've tried many different ways, and searched quie a bit for a solution, but how do I create and reference subfunctions in the current module?
For example, I am writing a program to parse through a text file, and for each of the 30... | Scope, using functions in current module | I know this must be a trivial question, but I've tried many different ways, and searched quie a bit for a solution, but how do I create and reference subfunctions in the current module?
For example, I am writing a program to parse through a text file, and for each of the 300 different names in it, I want to assign to a... | [
"A function needs to be defined before it can be called. If you want to have the code that needs to be executed at the top of the file, just define a main function and call it from the bottom:\nimport sys\n\ndef main(args):\n pass\n\n# All your other function definitions here\n\nif __name__ == '__main__':\n e... | [
5,
1,
0,
0
] | [] | [] | [
"function",
"module",
"python",
"scope",
"structure"
] | stackoverflow_0000925075_function_module_python_scope_structure.txt |
Q:
Control an embedded into website flash player with Python?
I am trying to write few simple python scripts, which will allow me to control one of the Internet radio (which I listen) with an keybinded python scripts.
I am now able to connect and log into the website, I am able to get out the song data ( that is - al... | Control an embedded into website flash player with Python? | I am trying to write few simple python scripts, which will allow me to control one of the Internet radio (which I listen) with an keybinded python scripts.
I am now able to connect and log into the website, I am able to get out the song data ( that is - all the data which are passed to the player).
I noticed, that the ... | [
"No you can't control the player with Python, flash and javascript can talk to each other because of how the Flash player works when embedded in a web page. Sounds like you're circumventing the flash player anyhow, so why do you need to control a player you're not using?\n"
] | [
1
] | [] | [] | [
"controls",
"embedded_resource",
"flash",
"javascript",
"python"
] | stackoverflow_0000933441_controls_embedded_resource_flash_javascript_python.txt |
Q:
Is there a way to invoke a Python function with the wrong number of arguments without invoking a TypeError?
When you invoke a function with the wrong number of arguments, or with a keyword argument that isn't in its definition, you get a TypeError. I'd like a piece of code to take a callback and invoke it with var... | Is there a way to invoke a Python function with the wrong number of arguments without invoking a TypeError? | When you invoke a function with the wrong number of arguments, or with a keyword argument that isn't in its definition, you get a TypeError. I'd like a piece of code to take a callback and invoke it with variable arguments, based on what the callback supports. One way of doing it would be to, for a callback cb, use cb.... | [
"Rather than digging down into the details yourself, you can inspect the function's signature -- you probably want inspect.getargspec(cb).\nExactly how you want to use that info, and the args you have, to call the function \"properly\", is not completely clear to me. Assuming for simplicity that you only care about... | [
7,
3
] | [] | [] | [
"apply",
"invocation",
"python"
] | stackoverflow_0000933484_apply_invocation_python.txt |
Q:
What is the best way to fetch/render one-to-many relationships?
I have 2 models which look like that:
class Entry(models.Model):
user = models.ForeignKey(User)
dataname = models.TextField()
datadesc = models.TextField()
timestamp = models.DateTimeField(auto_now=True)
class EntryFile(models.Model):
entry = mod... | What is the best way to fetch/render one-to-many relationships? | I have 2 models which look like that:
class Entry(models.Model):
user = models.ForeignKey(User)
dataname = models.TextField()
datadesc = models.TextField()
timestamp = models.DateTimeField(auto_now=True)
class EntryFile(models.Model):
entry = models.ForeignKey(Entry)
datafile = models.FileField(upload_to="uplo... | [
"Just cut your view code to this line:\nentries = Entry.objects.filter(user=request.user).order_by(\"-timestamp\")\n\nAnd do this in the template:\n{% for entry in entries %}\n <td>{{ entry.datadesc }}</td>\n <td><table>\n {% for file in entry.entryfile_set.all %}\n <td>{{ file.datafile.name|split:\... | [
5
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000933612_django_python.txt |
Q:
Python Regex Search And Replace
I'm not new to Python but a complete newbie with regular expressions (on my to do list)
I am trying to use python re to convert a string such as
[Hollywood Holt](http://www.hollywoodholt.com)
to
<a href="http://www.hollywoodholt.com">Hollywood Holt</a>
and a string like
*Hello wor... | Python Regex Search And Replace | I'm not new to Python but a complete newbie with regular expressions (on my to do list)
I am trying to use python re to convert a string such as
[Hollywood Holt](http://www.hollywoodholt.com)
to
<a href="http://www.hollywoodholt.com">Hollywood Holt</a>
and a string like
*Hello world*
to
<strong>Hello world</strong>
... | [
"Why are you bothering to use a regex? Your content is Markdown, why not simply take the string and run it through the markdown module?\nFirst, make sure Markdown is installed. It has a dependancy on ElementTree so easy_install the two of them as follows. If you're running Windows, you can use the Windows instal... | [
12
] | [] | [] | [
"markdown",
"python",
"regex",
"string"
] | stackoverflow_0000933824_markdown_python_regex_string.txt |
Q:
Django-like abstract database API for non-Django projects
I love the abstract database API that comes with Django, I was wondering if I could use this (or something similar) to model, access, and manage my (postgres) database for my non-Django Python projects.
A:
What you're looking for is an object-relational m... | Django-like abstract database API for non-Django projects | I love the abstract database API that comes with Django, I was wondering if I could use this (or something similar) to model, access, and manage my (postgres) database for my non-Django Python projects.
| [
"What you're looking for is an object-relational mapper (ORM). Django has its own, built-in.\nTo use Django's ORM by itself:\n\nUsing the Django ORM as a standalone component\nUse Django ORM as standalone\nUsing settings without setting DJANGO_SETTINGS_MODULE\n\nIf you want to use something else:\n\nWhat are some g... | [
17,
6,
2
] | [] | [] | [
"database",
"django",
"django_models",
"orm",
"python"
] | stackoverflow_0000933232_database_django_django_models_orm_python.txt |
Q:
Getting response from bluetooth device
I'm trying to write a simple module that will enable sending SMS. I using bluetooth to connect to the mobile using the below example:
file: bt-sendsms.py
import bluetooth
target = '00:32:AC:32:36:E8' # Mobile address
print "Trying to send SMS on %s" % target
BTSocket = ... | Getting response from bluetooth device | I'm trying to write a simple module that will enable sending SMS. I using bluetooth to connect to the mobile using the below example:
file: bt-sendsms.py
import bluetooth
target = '00:32:AC:32:36:E8' # Mobile address
print "Trying to send SMS on %s" % target
BTSocket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
... | [
"From the Python you look like you are opening any old RFCOMM channel and hoping it will magically take the AT commands and do the messaging.\nI think (and I could be wrong) that you need to connect to a specific profile/sevice channel and I think for SMS it is the the Messaging Access Profile (MAP), which is not y... | [
3
] | [] | [] | [
"bluetooth",
"mobile_phones",
"python",
"sms"
] | stackoverflow_0000934460_bluetooth_mobile_phones_python_sms.txt |
Q:
Packaging script source files in IronPython and IronRuby
Does anyone know how to add python and ruby libs as a resource in a dll for deployment? I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files. Is there a simple w... | Packaging script source files in IronPython and IronRuby | Does anyone know how to add python and ruby libs as a resource in a dll for deployment? I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files. Is there a simple way to do this so that a require or import statement will find ... | [
"You could add custom import hook that looks for embedded resources when an import is executed. This is slightly complex and probably not worth the trouble.\nA better technique would be to fetch all of the embedded modules at startup time, execute them with the ScriptEngine and put the modules you have created into... | [
1,
0,
0
] | [] | [] | [
"c#",
"ironpython",
"ironruby",
"python",
"ruby"
] | stackoverflow_0000933822_c#_ironpython_ironruby_python_ruby.txt |
Q:
Python3.0 - tokenize and untokenize
I am using something similar to the following simplified script to parse snippets of python from a larger file:
import io
import tokenize
src = 'foo="bar"'
src = bytes(src.encode())
src = io.BytesIO(src)
src = list(tokenize.tokenize(src.readline))
for tok in src:
print(tok)... | Python3.0 - tokenize and untokenize | I am using something similar to the following simplified script to parse snippets of python from a larger file:
import io
import tokenize
src = 'foo="bar"'
src = bytes(src.encode())
src = io.BytesIO(src)
src = list(tokenize.tokenize(src.readline))
for tok in src:
print(tok)
src = tokenize.untokenize(src)
Althoug... | [
"src = 'foo=\"bar\"\\n'You forgot newline.\n",
"If you limit the input to untokenize to the first 2 items of the tokens, it seems to work.\nimport io\nimport tokenize\n\nsrc = 'foo=\"bar\"'\nsrc = bytes(src.encode())\nsrc = io.BytesIO(src)\n\nsrc = list(tokenize.tokenize(src.readline))\n\nfor tok in src:\n print... | [
3,
0
] | [] | [] | [
"lexical_analysis",
"python",
"python_3.x",
"tokenize"
] | stackoverflow_0000934661_lexical_analysis_python_python_3.x_tokenize.txt |
Q:
python db connection
I am having a script which makes a db connection and pereform some select operation.accroding to the fetch data i am calling different functions which also perform db operations.How can i pass db connection to the functions which are being called as i donot want to make new connection
A:
Why... | python db connection | I am having a script which makes a db connection and pereform some select operation.accroding to the fetch data i am calling different functions which also perform db operations.How can i pass db connection to the functions which are being called as i donot want to make new connection
| [
"Why to pass connection itself? Maybe build a class that handles all the DB-operation and just pass this class' instance around, calling it's methods to perform selects, inserts and all that DB-specific code? \n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0000934221_python.txt |
Q:
Clipping FFT Matrix
Audio processing is pretty new for me. And currently using Python Numpy for processing wave files. After calculating FFT matrix I am getting noisy power values for non-existent frequencies. I am interested in visualizing the data and accuracy is not a high priority. Is there a safe way to calcu... | Clipping FFT Matrix | Audio processing is pretty new for me. And currently using Python Numpy for processing wave files. After calculating FFT matrix I am getting noisy power values for non-existent frequencies. I am interested in visualizing the data and accuracy is not a high priority. Is there a safe way to calculate the clipping value t... | [
"Simulated waveforms shouldn't show FFTs like your figure, so something is very wrong, and probably not with the FFT, but with the input waveform. The main problem in your plot is not the ripples, but the harmonics around 1000 Hz, and the subharmonic at 500 Hz. A simulated waveform shouldn't show any of this (for... | [
3,
2,
1,
1
] | [] | [] | [
"audio",
"fft",
"python",
"signal_processing"
] | stackoverflow_0000933088_audio_fft_python_signal_processing.txt |
Q:
WxPython differences between Windows and Linux
The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details.
For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutor... | WxPython differences between Windows and Linux | The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details.
For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutorials don't work in my computer.
So, do you know what... | [
"I've noticed odd peculiarities in a small GUI I wrote a while back, but it's been a long time since I tried to the specifics are a rather distant memory. Do you have some specific examples which fail? Maybe we can improve them and fix the bugs?\nHave you tried the official wxPython tutorials? ...or were you after ... | [
2,
0,
0
] | [] | [] | [
"linux",
"python",
"user_interface",
"windows",
"wxpython"
] | stackoverflow_0000916987_linux_python_user_interface_windows_wxpython.txt |
Q:
Insert/Delete performance
DB Table:
id int(6)
message char(5)
I have to add a record (message) to the DB table. In case of duplicate message(this message already exists with different id) I want to delete (or inactivate somehow) the both of the messages and get their ID's in reply.
Is it possible to perfo... | Insert/Delete performance | DB Table:
id int(6)
message char(5)
I have to add a record (message) to the DB table. In case of duplicate message(this message already exists with different id) I want to delete (or inactivate somehow) the both of the messages and get their ID's in reply.
Is it possible to perform with only one query? Any per... | [
"If you really want to worry about locking do this.\n\nUPDATE table SET status='INACTIVE' WHERE id = 'key';\nIf this succeeds, there was a duplicate.\n\nINSERT the additional inactive record. Do whatever else you want with your duplicates.\n\nIf this fails, there was no duplicate.\n\nINSERT the new active record. ... | [
2,
1,
0
] | [] | [] | [
"database",
"database_design",
"performance",
"python"
] | stackoverflow_0000934602_database_database_design_performance_python.txt |
Q:
Difference between "__method__" and "method"
What is the difference between __method__, method and _method__?
Is there any or for some random reason people thought that __doc__ should be right like that instead of doc. What makes a method more special than the other?
A:
__method: private method.
__method__: spec... | Difference between "__method__" and "method" | What is the difference between __method__, method and _method__?
Is there any or for some random reason people thought that __doc__ should be right like that instead of doc. What makes a method more special than the other?
| [
"\n__method: private method.\n__method__: special Python method. They are named like this to prevent name collisions. Check this page for a list of these special methods.\n_method: This is the recommended naming convention for protected methods in the Python style guide.\n\nFrom the style guide:\n\n\n_single_leadin... | [
74,
23,
4,
1,
0,
0,
0
] | [] | [] | [
"methods",
"python"
] | stackoverflow_0000935378_methods_python.txt |
Q:
Implementing NSText delegate methods in PyObjc and Cocoa
In the project that I'm building, I'd like to have a method called when I paste some text into a specific text field. I can't seem to get this to work, but here's what I've tried
I implimented a custom class (based on NSObject) to be a delegate for my textfi... | Implementing NSText delegate methods in PyObjc and Cocoa | In the project that I'm building, I'd like to have a method called when I paste some text into a specific text field. I can't seem to get this to work, but here's what I've tried
I implimented a custom class (based on NSObject) to be a delegate for my textfield, then gave it the method: textDidChange:
class textFieldDe... | [
"The reason this isn't working for you is that textDidChange_ isn't a delegate method. It's a method on the NSTextField that posts the notification of the change. If you have peek at the docs for textDidChange, you'll see that it mentions the actual name of the delegate method:\n\nThis method causes the receiver’s ... | [
3
] | [] | [] | [
"cocoa",
"pyobjc",
"python"
] | stackoverflow_0000934628_cocoa_pyobjc_python.txt |
Q:
Java equivalent of function mapping in Python
In python, if I have a few functions that I would like to call based on an input, i can do this:
lookup = {'function1':function1, 'function2':function2, 'function3':function3}
lookup[input]()
That is I have a dictionary of function name mapped to the function, and cal... | Java equivalent of function mapping in Python | In python, if I have a few functions that I would like to call based on an input, i can do this:
lookup = {'function1':function1, 'function2':function2, 'function3':function3}
lookup[input]()
That is I have a dictionary of function name mapped to the function, and call the function by a dictionary lookup.
How to do th... | [
"Java doesn't have first-class methods, so the command pattern is your friend...\ndisclamer: code not tested!\npublic interface Command \n{\n void invoke();\n}\n\nMap<String, Command> commands = new HashMap<String, Command>();\ncommands.put(\"function1\", new Command() \n{\n public void invoke() { System.out.... | [
15,
4,
2,
1,
1,
0,
0
] | [] | [] | [
"function",
"java",
"python"
] | stackoverflow_0000934509_function_java_python.txt |
Q:
Cast a class instance to a subclass
I'm using boto to manage some EC2 instances. It provides an Instance class. I'd like to subclass it to meet my particular needs. Since boto provides a query interface to get your instances, I need something to convert between classes. This solution seems to work, but changing th... | Cast a class instance to a subclass | I'm using boto to manage some EC2 instances. It provides an Instance class. I'd like to subclass it to meet my particular needs. Since boto provides a query interface to get your instances, I need something to convert between classes. This solution seems to work, but changing the class attribute seems dodgy. Is there a... | [
"I wouldn't subclass and cast. I don't think casting is ever a good policy. \nInstead, consider a Wrapper or Façade.\nclass MyThing( object ):\n def __init__( self, theInstance ):\n self.ec2_instance = theInstance \n\nNow, you can subclass MyThing as much as you want and you shouldn't need to be casting... | [
7
] | [] | [] | [
"boto",
"class",
"python",
"subclass"
] | stackoverflow_0000935448_boto_class_python_subclass.txt |
Q:
Scientific Plotting in Python
I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python?
Thanks in advance for the help,
-... | Scientific Plotting in Python | I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python?
Thanks in advance for the help,
--Leo
| [
"get matplotlib\n",
"The easiest option is matplotlib. Two particular solutions that might work for you are:\n1) You can generate a series of plots, each a snapshot at a given time. These can either be displayed as a dynamic plot in matplotlib, where the axes stay the same and the data moves around; or you can ... | [
16,
8,
4,
3,
2,
0,
0
] | [] | [] | [
"plot",
"python",
"scientific_computing",
"visualization"
] | stackoverflow_0000816086_plot_python_scientific_computing_visualization.txt |
Q:
How do I pass an exception between threads in python
I need to pass exceptions across a thread boundary.
I'm using python embedded in a non thread safe app which has one thread safe call, post_event(callable), which calls callable from its main thread.
I am running a pygtk gui in a seperate thread, so when a butto... | How do I pass an exception between threads in python | I need to pass exceptions across a thread boundary.
I'm using python embedded in a non thread safe app which has one thread safe call, post_event(callable), which calls callable from its main thread.
I am running a pygtk gui in a seperate thread, so when a button is clicked I post an event with post_event, and wait for... | [
"\n#what do I do here? How do I store the exception?\n\nUse sys.exc_info()[:2], see this wiki\nBest way to communicate among threads is Queue. Have the main thread instantiate a Queue.Queue instance and pass it to subthreads; when a subthread has something to communicate back to the master it uses .put on that queu... | [
13
] | [] | [] | [
"exception",
"multithreading",
"python"
] | stackoverflow_0000936556_exception_multithreading_python.txt |
Q:
Python and subprocess
This is for a script I'm working on. It's supposed to run an .exe file for the loop below. (By the way not sure if it's visible but for el in ('90','52.6223',...) is outside the loop and makes a nested loop with the rest) I'm not sure if the ordering is correct or what not. Also when the .exe... | Python and subprocess | This is for a script I'm working on. It's supposed to run an .exe file for the loop below. (By the way not sure if it's visible but for el in ('90','52.6223',...) is outside the loop and makes a nested loop with the rest) I'm not sure if the ordering is correct or what not. Also when the .exe file is ran, it spits some... | [
"Using shell=True is wrong because that needlessy invokes the shell.\nInstead, do this:\nfor el in ('90.','52.62263.','26.5651.','10.8123.'):\n if el == '90.':\n z = ('0.')\n elif el == '52.62263.':\n z = ('0.', '72.', '144.', '216.', '288.')\n elif el == '26.5651':\n z = ('324.', '36.... | [
1
] | [] | [] | [
"loops",
"popen",
"python",
"subprocess"
] | stackoverflow_0000936505_loops_popen_python_subprocess.txt |
Q:
Comparison of data in SQL through Python
I have to parse a very complex dump (whatever it is). I have done the parsing through Python. Since the parsed data is very huge in amount, I have to feed it in the database (SQL). I have also done this. Now the thing is I have to compare the data now present in the SQL.
Ac... | Comparison of data in SQL through Python | I have to parse a very complex dump (whatever it is). I have done the parsing through Python. Since the parsed data is very huge in amount, I have to feed it in the database (SQL). I have also done this. Now the thing is I have to compare the data now present in the SQL.
Actually I have to compare the data of 1st dump ... | [
"If you don't have MINUS or EXCEPT, there is also this, which will show all non-matching rows using a UNION/GROUP BY trick\nSELECT MAX(table), data1, data2\nFROM (\n SELECT 'foo1' AS table, foo1.data1, foo1.data2 FROM foo1\n UNION ALL\n SELECT 'foo2' AS table, foo2.data1, foo2.data2 FROM foo2\n) AS X\nGROU... | [
1,
0
] | [] | [] | [
"python",
"sql"
] | stackoverflow_0000934117_python_sql.txt |
Q:
Why does "**" bind more tightly than negation?
I was just bitten by the following scenario:
>>> -1 ** 2
-1
Now, digging through the Python docs, it's clear that this is intended behavior, but why? I don't work with any other languages with power as a builtin operator, but not having unary negation bind as tightl... | Why does "**" bind more tightly than negation? | I was just bitten by the following scenario:
>>> -1 ** 2
-1
Now, digging through the Python docs, it's clear that this is intended behavior, but why? I don't work with any other languages with power as a builtin operator, but not having unary negation bind as tightly as possible seems dangerously counter-intuitive to... | [
"That behaviour is the same as in math formulas, so I am not sure what the problem is, or why it is counter-intuitive. Can you explain where have you seen something different? \"**\" always bind more than \"-\": -x^2 is not the same as (-x)^2\nJust use (-1) ** 2, exactly as you'd do in math.\n",
"Short answer: it... | [
23,
5,
3,
1
] | [
"Ocaml doesn't do the same\n# -12.0**2.0\n ;;\n- : float = 144.\n\nThat's kind of weird...\n# -12.0**0.5;;\n- : float = nan\n\nLook at that link though...\norder of operations\n"
] | [
-1
] | [
"operator_precedence",
"python"
] | stackoverflow_0000936904_operator_precedence_python.txt |
Q:
Python Mod_WSGI Output Buffer
This is a bit of a tricky question;
I'm working with mod_wsgi in python and want to make an output buffer that yields HTML on an ongoing basis (until the page is done loading).
Right now I have my script set up so that the Application() function creates a separate 'Page' thread for ... | Python Mod_WSGI Output Buffer | This is a bit of a tricky question;
I'm working with mod_wsgi in python and want to make an output buffer that yields HTML on an ongoing basis (until the page is done loading).
Right now I have my script set up so that the Application() function creates a separate 'Page' thread for the page code, then immediately aft... | [
"mod_wsgi should have built in support for Generators. So if your using a Framework like CherryPy you just need to do:\ndef index():\n yield \"Some output\"\n #Do Somemore work\n yield \"Some more output\"\n\nWhere each yield will return to the user a chunk of the page. \nHere is some basics from CherrPy o... | [
2,
2
] | [] | [] | [
"buffer",
"mod_wsgi",
"output_buffering",
"python"
] | stackoverflow_0000935978_buffer_mod_wsgi_output_buffering_python.txt |
Q:
Keep code from running during syncdb
I have some code that throws causes syncdb to throw an error (because it tries to access the model before the tables are created).
Is there a way to keep the code from running on syncdb? something like:
if not syncdb:
run_some_code()
Thanks :)
edit: PS - I thought about us... | Keep code from running during syncdb | I have some code that throws causes syncdb to throw an error (because it tries to access the model before the tables are created).
Is there a way to keep the code from running on syncdb? something like:
if not syncdb:
run_some_code()
Thanks :)
edit: PS - I thought about using the post_init signal... for the code t... | [
"\"edit: PS - I thought about using the post_init signal... for the code that accesses the db, is that a good idea?\"\nNever.\nIf you have code that's accessing the model before the tables are created, you have big, big problems. You're probably doing something seriously wrong.\nNormally, you run syncdb approximat... | [
4,
2
] | [] | [] | [
"django",
"django_models",
"django_syncdb",
"python",
"syncdb"
] | stackoverflow_0000937316_django_django_models_django_syncdb_python_syncdb.txt |
Q:
Python Tkinter Tk/Tcl usage Problem
I am using Tcl from Python Tkinter Module like below
from Tkinter import *
Tcl = Tcl().eval
Tcl("info patchlevel")
'8.3.5'
You can see Tcl version 8.3 is selected by python.
But i also have tcl8.4 in my system.
Now,how do i make python select tcl8.4 in Tkinter module.
Tcl8.3 ... | Python Tkinter Tk/Tcl usage Problem | I am using Tcl from Python Tkinter Module like below
from Tkinter import *
Tcl = Tcl().eval
Tcl("info patchlevel")
'8.3.5'
You can see Tcl version 8.3 is selected by python.
But i also have tcl8.4 in my system.
Now,how do i make python select tcl8.4 in Tkinter module.
Tcl8.3 does not have Expect package,so i can not... | [
"I think the version of Tcl/Tk is used by python is determined at compiling time. So you need to look at the code, recompile python against the version of Tcl/Tk you want to use. Maybe recompiling the _tkinter.so library is enough too, since it's loaded dynamically.\n"
] | [
2
] | [] | [] | [
"expect",
"python",
"tcl",
"tkinter"
] | stackoverflow_0000937979_expect_python_tcl_tkinter.txt |
Q:
Recursive Relationship with Google App Engine and BigTable
In a classic relational database, I have the following table:
CREATE TABLE Person(
Id int IDENTITY(1,1) NOT NULL PRIMARY KEY,
MotherId int NOT NULL REFERENCES Person(Id),
FatherId int NOT NULL REFERENCES Person(Id),
FirstName nvarchar(255))... | Recursive Relationship with Google App Engine and BigTable | In a classic relational database, I have the following table:
CREATE TABLE Person(
Id int IDENTITY(1,1) NOT NULL PRIMARY KEY,
MotherId int NOT NULL REFERENCES Person(Id),
FatherId int NOT NULL REFERENCES Person(Id),
FirstName nvarchar(255))
I am trying to convert this table into a Google App Engine tab... | [
"I think that you want SelfReferenceProperty here\nclass Person(db.Model):\n mother = db.SelfReferenceProperty(collection_name='mother_set')\n father = db.SelfReferenceProperty(collection_name='father_set')\n firstName = db.StringProperty()\n\nAlternatively, you can put the Mother and Father relations in s... | [
10
] | [] | [] | [
"bigtable",
"database_design",
"google_app_engine",
"python"
] | stackoverflow_0000938035_bigtable_database_design_google_app_engine_python.txt |
Q:
Use Django ORM as standalone
Possible Duplicates:
Use only some parts of Django?
Using only the DB part of Django
I want to use the Django ORM as standalone. Despite an hour of searching Google, I'm still left with several questions:
Does it require me to set up my Python project with a setting.py, /myApp/ direc... | Use Django ORM as standalone |
Possible Duplicates:
Use only some parts of Django?
Using only the DB part of Django
I want to use the Django ORM as standalone. Despite an hour of searching Google, I'm still left with several questions:
Does it require me to set up my Python project with a setting.py, /myApp/ directory, and modules.py file?
Can I ... | [
"Ah ok I figured it out and will post the solutions for anyone attempting to do the same thing.\nThis solution assumes that you want to create new models.\nFirst create a new folder to store your files. We'll call it \"standAlone\". Within \"standAlone\", create the following files:\n__init__.py\nmyScript.py\nsetti... | [
39
] | [] | [] | [
"django",
"orm",
"postgresql",
"python"
] | stackoverflow_0000937742_django_orm_postgresql_python.txt |
Q:
Bad Practice to run code in constructor thats likely to fail?
my question is rather a design question.
In Python, if code in your "constructor" fails, the object ends up not being defined. Thus:
someInstance = MyClass("test123") #lets say that constructor throws an exception
someInstance.doSomething() # will fail,... | Bad Practice to run code in constructor thats likely to fail? | my question is rather a design question.
In Python, if code in your "constructor" fails, the object ends up not being defined. Thus:
someInstance = MyClass("test123") #lets say that constructor throws an exception
someInstance.doSomething() # will fail, name someInstance not defined.
I do have a situation though, wher... | [
"There is a difference between a constructor in C++ and an __init__ method\nin Python. In C++, the task of a constructor is to construct an object. If it fails,\nno destructor is called. Therefore if any resources were acquired before an \nexception was thrown, the cleanup should be done before exiting the constr... | [
37,
20,
4,
3,
3,
0,
0,
0
] | [] | [] | [
"constructor",
"exception_handling",
"oop",
"python"
] | stackoverflow_0000938426_constructor_exception_handling_oop_python.txt |
Q:
Preprocessing route parameters in Python Routes
I'm using Routes for doing all the URL mapping job. Here's a typical route in my application:
map.routes('route', '/show/{title:[^/]+}', controller='generator', filter_=postprocess_title)
Quite often I have to strip some characters (like whitespace and underscore) f... | Preprocessing route parameters in Python Routes | I'm using Routes for doing all the URL mapping job. Here's a typical route in my application:
map.routes('route', '/show/{title:[^/]+}', controller='generator', filter_=postprocess_title)
Quite often I have to strip some characters (like whitespace and underscore) from the {title} parameter. Currently there's one call... | [
"I am not familiar with Routes, and therefore I do not know if what you're after is possible with Routes.\nBut perhaps you could decorate your controller methods with a decorator that strips characters from parameters as needed?\nNot sure if this would be more convenient. But to me, using a decorator has a differen... | [
0
] | [] | [] | [
"parameters",
"python",
"routes"
] | stackoverflow_0000938293_parameters_python_routes.txt |
Q:
How to match a string of a certain length with a regex
For a project of mine, I'm trying to implement a small part of the BitTorrent protocol, which can be found here. Specifically, I want to use the "Bencoding" part of it, which is a way to safely encode data for transfer over a socket. The format is as follows:
... | How to match a string of a certain length with a regex | For a project of mine, I'm trying to implement a small part of the BitTorrent protocol, which can be found here. Specifically, I want to use the "Bencoding" part of it, which is a way to safely encode data for transfer over a socket. The format is as follows:
8:a string => "a string"
i1234e => 1234
l1:a1:be => ['a', 'b... | [
"Any parser you use for this is going to need to be stateful (i.e. remember stuff), and regexes are, by and large, not stateful. They're the wrong tool for this job.\nIf those are the only data types you have to worry about, I think I'd just write custom parsers for each data type, passing control to the appropria... | [
9,
2,
2,
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000938065_python_regex.txt |
Q:
Printed representation of list
I want to format a list into a string in this way:
[1,2,3] => '1 2 3'. How to do this?
Is there any customizable formatter in Python as Common Lisp format?
A:
' '.join(str(i) for i in your_list)
A:
' '.join(str(i) for i in your_list)
First, convert any element into a string, the... | Printed representation of list | I want to format a list into a string in this way:
[1,2,3] => '1 2 3'. How to do this?
Is there any customizable formatter in Python as Common Lisp format?
| [
"' '.join(str(i) for i in your_list)\n\n",
"' '.join(str(i) for i in your_list)\n\nFirst, convert any element into a string, then join them into a unique string.\n"
] | [
11,
7
] | [] | [] | [
"python"
] | stackoverflow_0000939243_python.txt |
Q:
Purpose of @ symbols in Python?
I've noticed in several examples i see things such as this:
# Comments explaining code i think
@innerclass
or:
def foo():
"""
Basic Doc String
"""
@classmethod
Googling doesn't get me very far, for just a general definition of what this is. Also i cant find anything really in the... | Purpose of @ symbols in Python? | I've noticed in several examples i see things such as this:
# Comments explaining code i think
@innerclass
or:
def foo():
"""
Basic Doc String
"""
@classmethod
Googling doesn't get me very far, for just a general definition of what this is. Also i cant find anything really in the python documentation.
What do these ... | [
"They are called decorators. They are functions applied to other functions. Here is a copy of my answer to a similar question.\nPython decorators add extra functionality to another function.\nAn italics decorator could be like\ndef makeitalic(fn):\n def newFunc():\n return \"<i>\" + fn() + \"</i>\"\n r... | [
26,
12,
5,
1
] | [] | [] | [
"python"
] | stackoverflow_0000939426_python.txt |
Q:
Using mx:RemoteObject with web2py's @service.amfrpc decorator
I am using web2py (v1.63) and Flex 3. web2py v1.61 introduced the @service decorators, which allow you to tag a controller function with @service.amfrpc. You can then call that function remotely using http://..../app/default/call/amfrpc/[function]. See ... | Using mx:RemoteObject with web2py's @service.amfrpc decorator | I am using web2py (v1.63) and Flex 3. web2py v1.61 introduced the @service decorators, which allow you to tag a controller function with @service.amfrpc. You can then call that function remotely using http://..../app/default/call/amfrpc/[function]. See http://www.web2py.com/examples/default/tools#services. Does anybody... | [
"I have not found a way to use a RemoteObject with the @service.amfrpc decorator. However, I can use the older ActionScript code using a NetConnection (similar to what I posted originally) and pair that with a @service.amfrpc function on the web2py side. This seems to work fine. The one thing that you would want to... | [
1
] | [] | [] | [
"apache_flex",
"flex3",
"pyamf",
"python",
"web2py"
] | stackoverflow_0000927028_apache_flex_flex3_pyamf_python_web2py.txt |
Q:
How Python calculate number?
Possible Duplicate:
python - decimal place issues with floats
In [4]: 52+121.2
Out[4]: 173.19999999999999
A:
Short answer: Python uses binary arithmetic for floating-point numbers, not decimal arithmetic. Decimal fractions are not exactly representable in binary.
Long answer: Wh... | How Python calculate number? |
Possible Duplicate:
python - decimal place issues with floats
In [4]: 52+121.2
Out[4]: 173.19999999999999
| [
"Short answer: Python uses binary arithmetic for floating-point numbers, not decimal arithmetic. Decimal fractions are not exactly representable in binary.\nLong answer: What Every Computer Scientist Should Know About Floating-Point Arithmetic\n",
"If you're familiar with the idea that the number \"thirteen poin... | [
22,
8,
7,
3
] | [] | [] | [
"python"
] | stackoverflow_0000937692_python.txt |
Q:
Why no pure Python SSH1 (version 1) client implementations?
There seem to be a few good pure Python SSH2 client implementations out there, but I haven't been able to find one for SSH1. Is there some specific reason for this other than lack of interest in such a project? I am fully aware of the many SSH1 vulnerabil... | Why no pure Python SSH1 (version 1) client implementations? | There seem to be a few good pure Python SSH2 client implementations out there, but I haven't been able to find one for SSH1. Is there some specific reason for this other than lack of interest in such a project? I am fully aware of the many SSH1 vulnerabilities, but a pure Python SSH1 client implementation would still b... | [
"SSHv1 was considered deprecated in 2001, so I assume nobody really wanted to put the effort into it. I'm not sure if there's even an rfc for SSH1, so getting the full protocol spec may require reading through old source code.\nSince there are known vulnerabilities, it's not much better than telnet, which is almost... | [
3,
1
] | [] | [] | [
"python",
"ssh"
] | stackoverflow_0000936783_python_ssh.txt |
Q:
Python Extension Returned Object Etiquette
I am writing a python extension to provide access to Solaris kstat data ( in the same spirit as the shipping perl library Sun::Solaris::Kstat ) and I have a question about conditionally returning a list or a single object. The python use case would look something like:
... | Python Extension Returned Object Etiquette | I am writing a python extension to provide access to Solaris kstat data ( in the same spirit as the shipping perl library Sun::Solaris::Kstat ) and I have a question about conditionally returning a list or a single object. The python use case would look something like:
cpu_stats = cKstats.lookup(module='cpu_stat'... | [
"\"My question is it poor form to return a single object when there is only one match, and a list when there are many?\"\nIt's poor form to return inconsistent types.\nReturn a consistent type: List of kstat.\nMost Pythonistas don't like using type(result) to determine if it's a kstat or a list of kstats.\nWe'd ra... | [
7
] | [] | [] | [
"python",
"python_c_api"
] | stackoverflow_0000940563_python_python_c_api.txt |
Q:
How to pass pointer to an array in Python for a wrapped C++ function
I am new to C++/Python mixed language programming and do not have much idea about Python/C API. I just started using Boost.Python to wrap a C++ library for Python. I am stuck at wrapping a function that takes pointer to an array as an argument. F... | How to pass pointer to an array in Python for a wrapped C++ function | I am new to C++/Python mixed language programming and do not have much idea about Python/C API. I just started using Boost.Python to wrap a C++ library for Python. I am stuck at wrapping a function that takes pointer to an array as an argument. Following (2nd ctor) is its prototype in C++.
class AAF{
AAF(AAF_TYPE t);... | [
"The wrapping is right (in principle) but in\nAAF(10, [4, 5.5, 10], [1, 1, 2], 3);\n\n(as the interpreter points out) you're passing to your function python's list objects, not pointers.\nIn short, if your function needs only to work on python's lists you need to change your code to use that interface (instead of u... | [
4
] | [] | [] | [
"arrays",
"boost_python",
"pointers",
"python",
"word_wrap"
] | stackoverflow_0000940132_arrays_boost_python_pointers_python_word_wrap.txt |
Q:
Python 2.6 subprocess.call() appears to be invoking setgid behavior triggering Perl's taint checks. How can I resolve?
I've got some strange behavioral differences between Python's subprocess.call() and os.system() that appears to be related to setgid. The difference is causing Perl's taint checks to be invoked wh... | Python 2.6 subprocess.call() appears to be invoking setgid behavior triggering Perl's taint checks. How can I resolve? | I've got some strange behavioral differences between Python's subprocess.call() and os.system() that appears to be related to setgid. The difference is causing Perl's taint checks to be invoked when subprocess.call() is used, which creates problems because I do not have the ability to modify all the Perl scripts that w... | [
"I think your error is with perl, or the way it's interacting with your environment.\nYour backtick process is calling setgid for some reason. The only way I can replicate this, is to setgid on /usr/bin/perl (-rwxr-sr-x). [EDIT] Having python setgid does this too!\n[EDIT] I forgot that os.system is working for you.... | [
2,
0
] | [] | [] | [
"perl",
"python",
"subprocess"
] | stackoverflow_0000940552_perl_python_subprocess.txt |
Q:
Threading In Python
I'm new to threading and was wondering if it's bad to spawn a lot of threads for various tasks (in a server environment). Do threads take up a lot more memory/cpu compared to more linear programming?
A:
You have to consider multiple things if you want to use multiple threads:
You can only ru... | Threading In Python | I'm new to threading and was wondering if it's bad to spawn a lot of threads for various tasks (in a server environment). Do threads take up a lot more memory/cpu compared to more linear programming?
| [
"You have to consider multiple things if you want to use multiple threads:\n\nYou can only run #processors threads simultaneously. (Obvious)\nIn Python each thread is a 'kernel thread' which normally takes a non-trivial amount of resources (8 mb stack by default on linux)\nPython has a global interpreter lock, whic... | [
19,
5,
4,
2,
1,
1
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0000939754_multithreading_python.txt |
Q:
Unable to replace the word in a given folder's contents by Sed/Python/Perl
I have a project where I have folders, subfolders, and files. I need to replace the word Masi by the word Bond in each files.
I run the following Sed script called replace unsuccessfully
s/Masi/Bond/
in Zsh by
sed -f PATH/replace PATH2/pr... | Unable to replace the word in a given folder's contents by Sed/Python/Perl | I have a project where I have folders, subfolders, and files. I need to replace the word Masi by the word Bond in each files.
I run the following Sed script called replace unsuccessfully
s/Masi/Bond/
in Zsh by
sed -f PATH/replace PATH2/project/**
It gives me all files, also the ones which do not have Masi, as an out... | [
"To replace the word in all files found in the current directory and subdirectories\nperl -p -i -e 's/Masi/Bond/g' $(grep -rl Masi *)\n\nThe above won't work if you have spaces in filenames. Safer to do:\nfind . -type f -exec perl -p -i -e 's/Masi/Bond/g' {} \\;\n\nor in Mac which has spaces in filenames\nfind . -... | [
12,
3,
3,
0,
0
] | [] | [] | [
"perl",
"python",
"replace",
"sed"
] | stackoverflow_0000894802_perl_python_replace_sed.txt |
Q:
using "range" in a google app engine template for - loop
i've got an appengine project and in my template i want to do something like
{% for i in range(0, len(somelist)) %}
{{ somelist[i] }} {{ otherlist[i] }}
{% endfor %}
i've tried using 'forloop.counter' to access list items too, but that didn't work out ei... | using "range" in a google app engine template for - loop | i've got an appengine project and in my template i want to do something like
{% for i in range(0, len(somelist)) %}
{{ somelist[i] }} {{ otherlist[i] }}
{% endfor %}
i've tried using 'forloop.counter' to access list items too, but that didn't work out either. any suggestions?
regards, mux
| [
"What you might want to do instead is change the data that you're passing in to the template so that somelist and otherlist are zipped together into a single list:\ncombined_list = zip(somelist, otherlist)\n...\n{% for item in combined_list %}\n {{ item.0 }} {{ item.1 }}\n{% endfor %}\n\n"
] | [
6
] | [] | [] | [
"django_templates",
"python"
] | stackoverflow_0000941282_django_templates_python.txt |
Q:
Is it reasonable to integrate python with c for performance?
I like to use python for almost everything and always had clear in my mind that if for some reason I was to find a bottleneck in my python code(due to python's limitations), I could always use a C script integrated to my code.
But, as I started to read a... | Is it reasonable to integrate python with c for performance? | I like to use python for almost everything and always had clear in my mind that if for some reason I was to find a bottleneck in my python code(due to python's limitations), I could always use a C script integrated to my code.
But, as I started to read a guide on how to integrate python. In the article the author says:... | [
"\n* Optimising inner loops in code\n\nIsn't that about performance ?\n",
"In my experience it is rarely necessary to optimize using C. I prefer to identify bottlenecks and improve algorithms in those areas completely in Python. Using hash tables, caching, and generally re-organizing your data structures to suit ... | [
8,
8,
7,
4,
3,
2,
1
] | [] | [] | [
"c",
"performance",
"python"
] | stackoverflow_0000940982_c_performance_python.txt |
Q:
Testing time sensitive applications in Python
I've written an auction system in Django. I want to write unit tests but the application is time sensitive (e.g. the amount advertisers are charged is a function of how long their ad has been active on a website). What's a good approach for testing this type of appli... | Testing time sensitive applications in Python | I've written an auction system in Django. I want to write unit tests but the application is time sensitive (e.g. the amount advertisers are charged is a function of how long their ad has been active on a website). What's a good approach for testing this type of application?
Here's one possible solution: a DateFactory... | [
"In the link you provided, the author somewhat rejects the idea of adding additional parameters to your methods for the sake of unit testing, but in some cases I think you can justify this as just an extension of your business logic. In my opinion, it's a form of inversion of control that can make your model more ... | [
3,
1
] | [] | [] | [
"datetime",
"django",
"python",
"unit_testing"
] | stackoverflow_0000765773_datetime_django_python_unit_testing.txt |
Q:
Regular expression syntax for "match nothing"?
I have a python template engine that heavily uses regexp. It uses concatenation like:
re.compile( regexp1 + "|" + regexp2 + "*|" + regexp3 + "+" )
I can modify the individual substrings (regexp1, regexp2 etc).
Is there any small and light expression that matches noth... | Regular expression syntax for "match nothing"? | I have a python template engine that heavily uses regexp. It uses concatenation like:
re.compile( regexp1 + "|" + regexp2 + "*|" + regexp3 + "+" )
I can modify the individual substrings (regexp1, regexp2 etc).
Is there any small and light expression that matches nothing, which I can use inside a template where I don't... | [
"This shouldn't match anything:\nre.compile('$^')\n\nSo if you replace regexp1, regexp2 and regexp3 with '$^' it will be impossible to find a match. Unless you are using the multi line mode.\n\nAfter some tests I found a better solution\nre.compile('a^')\n\nIt is impossible to match and will fail earlier than the p... | [
154,
56,
17,
5,
3,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000940822_python_regex.txt |
Q:
Python - Library Problems
I'm relatively new to Python and am having problems programming with Scapy, the Python network manipulation tool. However, I can't tell if it's as much a Scapy problem as it is a being-a-Python-newbie problem. On the scapy site, they give a sample program which I'm not able to run on my o... | Python - Library Problems | I'm relatively new to Python and am having problems programming with Scapy, the Python network manipulation tool. However, I can't tell if it's as much a Scapy problem as it is a being-a-Python-newbie problem. On the scapy site, they give a sample program which I'm not able to run on my own machine:
#! /usr/bin/env pyt... | [
"With the caveat from Federico Ramponi \"You should use scapy as an interpreter by its own, not as a library\", I want to answer the non-scapy-specific parts of the question.\nQ: when installing Python libraries, do I need to change my path or anything similar?\nA: I think you are talking about changing PYTHONPATH ... | [
6,
4,
3,
1
] | [] | [] | [
"networking",
"python",
"scapy"
] | stackoverflow_0000229756_networking_python_scapy.txt |
Q:
How do I represent many to many relation in the form of Google App Engine?
class Entry(db.Model):
...
class Tag(db.Model):
...
class EntryTag(db.Model):
entry = db.ReferenceProperty(Entry, required=True, collection_name='tag_set')
tag = db.ReferenceProperty(Tag, required=True, collection_name='en... | How do I represent many to many relation in the form of Google App Engine? | class Entry(db.Model):
...
class Tag(db.Model):
...
class EntryTag(db.Model):
entry = db.ReferenceProperty(Entry, required=True, collection_name='tag_set')
tag = db.ReferenceProperty(Tag, required=True, collection_name='entry_set')
The template should be {{form.as_table}}
The question is how to make ... | [
"You will need to create a formset for your EntryTag class. For more information, see the Django formset docs.\nOtherwise, you may wish to create a custom form with a ModelMultipleChoiceField and add the EntryTag entities using a custom view.\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0000856462_google_app_engine_python.txt |
Q:
How to Change Mouse Cursor in PythonCard
How do I change the mouse cursor to indicate a waiting state using Python and PythonCard?
I didn't see anything in the documentation.
A:
PythonCard builds on top of wx, so if you import wx you should be able to build a suitable cursor (e.g. with wx.CursorFromImage), set ... | How to Change Mouse Cursor in PythonCard | How do I change the mouse cursor to indicate a waiting state using Python and PythonCard?
I didn't see anything in the documentation.
| [
"PythonCard builds on top of wx, so if you import wx you should be able to build a suitable cursor (e.g. with wx.CursorFromImage), set it (e.g. with wx.BeginBusyCursor) when your wait begins, and end it (with wx.EndBusyCursor) when your wait ends.\n"
] | [
1
] | [] | [] | [
"cursor",
"mouse",
"python",
"pythoncard",
"user_interface"
] | stackoverflow_0000942730_cursor_mouse_python_pythoncard_user_interface.txt |
Q:
Extracting YouTube Video's author using Python and YouTubeAPI
how do I get the author/username from an object using:
GetYouTubeVideoEntry(video_id=youtube_video_id_to_output)
I'm using Google's gdata.youtube.service Python library
Thanks in advance! :)
A:
So because YouTube's API is based on GData, which is bas... | Extracting YouTube Video's author using Python and YouTubeAPI | how do I get the author/username from an object using:
GetYouTubeVideoEntry(video_id=youtube_video_id_to_output)
I'm using Google's gdata.youtube.service Python library
Thanks in advance! :)
| [
"So because YouTube's API is based on GData, which is based on Atom, the 'author' object is an array with name objects, which can contain names, URLs, etc.\nThis is what you want:\n>>> client = gdata.youtube.service.YouTubeService()\n>>> video = client.GetYouTubeVideoEntry(video_id='CoYBkXD0QeU')\n>>> video.author[... | [
6,
0
] | [] | [] | [
"python",
"youtube",
"youtube_api"
] | stackoverflow_0000938742_python_youtube_youtube_api.txt |
Q:
Flash-based file upload (swfupload) fails with Apache/mod-wsgi
This question has been retitled/retagged so that others may more easily find the solution to this problem.
I am in the process of trying to migrate a project from the Django development server to a Apache/mod-wsgi environment. If you had asked me yes... | Flash-based file upload (swfupload) fails with Apache/mod-wsgi | This question has been retitled/retagged so that others may more easily find the solution to this problem.
I am in the process of trying to migrate a project from the Django development server to a Apache/mod-wsgi environment. If you had asked me yesterday I would have said the transition was going very smoothly. My... | [
"Normally apache runs as a user \"www-data\"; and you could have problems if it doesn't have read/write access. However, your setup doesn't seem to use apache to access the '/home/sk/src/sitename/uploads'; my understanding from this config file is unless it hit /static or /media, apache will hand it off WGSI, so it... | [
3,
2
] | [] | [] | [
"apache",
"file_upload",
"flash",
"mod_wsgi",
"python"
] | stackoverflow_0000943000_apache_file_upload_flash_mod_wsgi_python.txt |
Q:
How to construct a web file browser?
Goal: simple browser app, for navigating files on a web server, in a tree view.
Background: Building a web site as a learning experience, w/ Apache, mod_python, Python code. (No mod_wsgi yet.)
What tools should I learn to write the browser tree? I see JavaScript, Ajax, neit... | How to construct a web file browser? | Goal: simple browser app, for navigating files on a web server, in a tree view.
Background: Building a web site as a learning experience, w/ Apache, mod_python, Python code. (No mod_wsgi yet.)
What tools should I learn to write the browser tree? I see JavaScript, Ajax, neither of which I know. Learn them? Grab a ... | [
"First, switch to mod_wsgi.\nSecond, write a hello world in Python using mod_wsgi.\nThird, change your hello world to show the results of os.listdir().\nI think you're approximately done.\nAs you mess with this, you'll realize that transforming the content you have (information from os.listdir) into presentation in... | [
10,
1,
1,
0
] | [] | [] | [
"html",
"javascript",
"python",
"web_applications"
] | stackoverflow_0000941638_html_javascript_python_web_applications.txt |
Q:
Connect to a running instance of Visual Studio 2003 using COM, build and read output
For Visual Studio 6.0, I can connect to a running instance like:
o = GetActiveObject("MSDev.Application")
What prog ID do I use for Visual Studio 2003?
How do I execute a 'Build Solution' once I have the COM object that reference... | Connect to a running instance of Visual Studio 2003 using COM, build and read output | For Visual Studio 6.0, I can connect to a running instance like:
o = GetActiveObject("MSDev.Application")
What prog ID do I use for Visual Studio 2003?
How do I execute a 'Build Solution' once I have the COM object that references the VS2003 instance?
How do I get the string contents of the build output window after ... | [
"After a bit of research (mainly looking at EnvDTE docs), I found the solution to this myself:\nTo build current solution (code in Python):\ndef build_active_solution(progid=\"VisualStudio.DTE.7.1\"):\n from win32com.client import GetActiveObject\n dte = GetActiveObject(progid)\n sb = dte.Solution.Solution... | [
2
] | [] | [] | [
"com",
"python",
"visual_studio"
] | stackoverflow_0000943863_com_python_visual_studio.txt |
Q:
Python: defaultdict became unmarshallable object in 2.6?
Did defaultdict's become not marshal'able as of Python 2.6? The following works under 2.5, fails under 2.6 with "ValueError: unmarshallable object" on OS X 1.5.6, python-2.6.1-macosx2008-12-06.dmg from python.org:
from collections import defaultdict
import m... | Python: defaultdict became unmarshallable object in 2.6? | Did defaultdict's become not marshal'able as of Python 2.6? The following works under 2.5, fails under 2.6 with "ValueError: unmarshallable object" on OS X 1.5.6, python-2.6.1-macosx2008-12-06.dmg from python.org:
from collections import defaultdict
import marshal
dd = defaultdict(list)
marshal.dump(dd, file('/tmp/junk... | [
"Marshal was deliberately changed to not support subclasses of built-in types. Marshal was never supposed to handle defaultdicts, but happened to since they are a subclass of dict. Marshal is not a general \"persistence\" module; only None, integers, long integers, floating point numbers, strings, Unicode objects,... | [
11,
7
] | [] | [] | [
"python"
] | stackoverflow_0000665061_python.txt |
Q:
Execution of a OS command from a Python daemon
I've got a daemon.py with a callback. How should I make the handler function execute a OS command?
A:
when i learned Python some time ago, I used:
import os
os.system('ls -lt')
but it seems like in Python 3.x, the recommended use is commands or os.popen()
| Execution of a OS command from a Python daemon | I've got a daemon.py with a callback. How should I make the handler function execute a OS command?
| [
"when i learned Python some time ago, I used:\nimport os\nos.system('ls -lt')\n\nbut it seems like in Python 3.x, the recommended use is commands or os.popen()\n"
] | [
-2
] | [] | [] | [
"bash",
"command",
"handler",
"operating_system",
"python"
] | stackoverflow_0000944501_bash_command_handler_operating_system_python.txt |
Q:
Creating connection between two computers in python
The question: How do I create a python application that can connect and send packets over the internet to another computer running the same application? Is there any existing code/library I could use?
The background: I am pretty new to programming (HS senior). I'... | Creating connection between two computers in python | The question: How do I create a python application that can connect and send packets over the internet to another computer running the same application? Is there any existing code/library I could use?
The background: I am pretty new to programming (HS senior). I've created a lot of simple things in python but I've rece... | [
"Twisted is a python event-driven networking engine licensed under MIT. Means that a single machine can communicate with one or more other machines, while doing other things between data being received and sent, all asynchronously, and running a in a single thread/process.\nIt supports many protocols out of the box... | [
15,
7,
5,
2,
2,
1
] | [] | [] | [
"networking",
"python"
] | stackoverflow_0000936625_networking_python.txt |
Q:
Benefit of installing Django from .deb versus .tar.gz?
I'm starting Django development, and I can either install it from the .deb using
$ apt-get install python-django
on my Ubuntu machine, or I can download the .tar.gz from djangoproject.com, and start with that.
What are the benefits and drawbacks of each appro... | Benefit of installing Django from .deb versus .tar.gz? | I'm starting Django development, and I can either install it from the .deb using
$ apt-get install python-django
on my Ubuntu machine, or I can download the .tar.gz from djangoproject.com, and start with that.
What are the benefits and drawbacks of each approach?
| [
"Using apt-get lets your system keep track of the install (e.g. if you want to disinstall, upgrade, or the like, late). Installing from source (.tar.gz or otherwise) puts you in charge of what's what and where -- you can have multiple versions installed at various locations, etc, but there's no easy \"uninstall\" a... | [
8,
6,
4,
1,
0,
0
] | [] | [] | [
"apt_get",
"django",
"python",
"ubuntu"
] | stackoverflow_0000943242_apt_get_django_python_ubuntu.txt |
Q:
How to extract nested tables from HTML?
I have an HTML file (encoded in utf-8). I open it with codecs.open(). The file architecture is:
<html>
// header
<body>
// some text
<table>
// some rows with cells here
// some cells contains tables
</table>
// maybe some text here
<table>
// a form an... | How to extract nested tables from HTML? | I have an HTML file (encoded in utf-8). I open it with codecs.open(). The file architecture is:
<html>
// header
<body>
// some text
<table>
// some rows with cells here
// some cells contains tables
</table>
// maybe some text here
<table>
// a form and other stuff
</table>
// probably some m... | [
"Try beautiful soup\nIn principle you need to use a real parser (which Beaut. Soup is), regex cannot deal with nested elements, for computer sciencey reasons (finite state machines can't parse context-free grammars, IIRC)\n",
"You may like lxml. I'm not sure I really understood what you want to do with that struc... | [
5,
4,
2
] | [] | [] | [
"extract",
"html",
"html_table",
"python"
] | stackoverflow_0000944860_extract_html_html_table_python.txt |
Q:
Numpy: Should I use newaxis or None?
In numpy one can use the 'newaxis' object in the slicing syntax to create an axis of length one, e.g.:
import numpy as np
print np.zeros((3,5))[:,np.newaxis,:].shape
# shape will be (3,1,5)
The documentation states that one can also use None instead of newaxis, the effect is e... | Numpy: Should I use newaxis or None? | In numpy one can use the 'newaxis' object in the slicing syntax to create an axis of length one, e.g.:
import numpy as np
print np.zeros((3,5))[:,np.newaxis,:].shape
# shape will be (3,1,5)
The documentation states that one can also use None instead of newaxis, the effect is exactly the same.
Is there any reason to ch... | [
"None is allowed because numpy.newaxis is merely an alias for None.\nIn [1]: import numpy\n\nIn [2]: numpy.newaxis is None\nOut[2]: True\n\nThe authors probably chose it because they needed a convenient constant, and None was available.\nAs for why you should prefer newaxis over None: mainly it's because it's more ... | [
116
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0000944863_numpy_python.txt |
Q:
pygtk gui freezes with pyjack thread
I have a program that records audio from firewire device (FA-66) with Jack connection. The interface is created with pygtk and the recording with py-jack (http://sourceforge.net/projects/py-jack/). The recording is done in a different thread because the GUI must be used at the ... | pygtk gui freezes with pyjack thread | I have a program that records audio from firewire device (FA-66) with Jack connection. The interface is created with pygtk and the recording with py-jack (http://sourceforge.net/projects/py-jack/). The recording is done in a different thread because the GUI must be used at the same time for viewing results from the aud... | [
"You misunderstand how threads work. \nThreads don't help you in this case. \n\n\"Then when one sample is recorded, it will be analyzed and the results are\n shown in the GUI. At the same time the\n next sample is already being\n recorded.\"\n\nWRONG. Threads don't do two things at the same time. In python there... | [
2
] | [] | [] | [
"multithreading",
"pygtk",
"python"
] | stackoverflow_0000944161_multithreading_pygtk_python.txt |
Q:
Why doesn't anyone care about this MySQLdb bug? is it a bug?
TL;DR: I've supplied a patch for a bug I found and I've got 0 feedback on it. I'm wondering if it's a bug at all. This is not a rant. Please read this and if you may be affected by it check the fix.
I have found and reported this MySQLdb bug some weeks a... | Why doesn't anyone care about this MySQLdb bug? is it a bug? | TL;DR: I've supplied a patch for a bug I found and I've got 0 feedback on it. I'm wondering if it's a bug at all. This is not a rant. Please read this and if you may be affected by it check the fix.
I have found and reported this MySQLdb bug some weeks ago (edit: 6 weeks ago), sent a patch, posted it on a couple of ORM... | [
"\nWhy doesn’t anyone care about this\n MySQLdb bug?\n\nbugs can take a while to prioritize, research, verify the problem, find a fix, test the fix, make sure the fix fix does not break anything else. I would suggest you deploy a work around, since it could take some time for this fix to arrive for you.\n"
] | [
7
] | [] | [] | [
"deadlock",
"mysql",
"python"
] | stackoverflow_0000945482_deadlock_mysql_python.txt |
Q:
what are the applications of the python reload function?
I have been wondering about the reload() function in python, which seems like it can lead to problems if used without care.
Why would you want to reload a module, rather than just stop/start python again?
I imagine one application might be to test changes ... | what are the applications of the python reload function? | I have been wondering about the reload() function in python, which seems like it can lead to problems if used without care.
Why would you want to reload a module, rather than just stop/start python again?
I imagine one application might be to test changes to a module interactively.
| [
"reload is useful for reloading code that may have changed in a Python module. Usually this means a plugin system.\nTake a look at this link:\nhttp://www.codexon.com/posts/a-better-python-reload\nIt will tell you the shortcomings of reload and a possible fix.\n",
"\nI imagine one application might be to test chan... | [
6,
4,
1
] | [] | [] | [
"python"
] | stackoverflow_0000856174_python.txt |
Q:
How can I script the creation of a movie from a set of images?
I managed to get a set of images loaded using Python.
I'd like my script to take this series of images (in whatever format I need them), and create a video from them. The big limit in all this is that I am looking for something easy and simple to insta... | How can I script the creation of a movie from a set of images? | I managed to get a set of images loaded using Python.
I'd like my script to take this series of images (in whatever format I need them), and create a video from them. The big limit in all this is that I am looking for something easy and simple to install. Ideally, using the standard OS X installation procedure:
downlo... | [
"If you're not averse to using the command-line, there's the convert command from the ImageMagick package. It's available for Mac, Linux, Windows. See http://www.imagemagick.org/script/index.php.\nIt supports a huge number of image formats and you can output your movie as an mpeg file:\nconvert -quality 100 *.png o... | [
21,
9,
4
] | [] | [] | [
"macos",
"python",
"video"
] | stackoverflow_0000945250_macos_python_video.txt |
Q:
django Authentication using auth.views
User should be redirected to the Login page after registration and after logout. In both cases there must be a message displayed indicating relevant messages.
Using the django.contrib.auth.views.login how do I send these {{ info }} messages.
A possible option would be to copy... | django Authentication using auth.views | User should be redirected to the Login page after registration and after logout. In both cases there must be a message displayed indicating relevant messages.
Using the django.contrib.auth.views.login how do I send these {{ info }} messages.
A possible option would be to copy the auth.views to new registration module a... | [
"If the messages are static you can use your own templates for those views:\n(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'myapp/login.html'}\n\nFrom the docs.\n",
"I think the best solution to this problem is to use a \"flash\"-type session-based messaging system. There are severa... | [
3,
1,
0
] | [] | [] | [
"authentication",
"django",
"django_authentication",
"python"
] | stackoverflow_0000938427_authentication_django_django_authentication_python.txt |
Q:
is there a multiple format specifier in Python?
I have a data table 44 columns wide that I need to write to file. I don't want to write:
outfile.write("%i,%f,%f,$f ... )\n" % (i, a,b,c ...))
In Fortran you can specify multiple format specifiers easily:
write (*,"(3f8.3)") a,b,c
Is there a similar capability in... | is there a multiple format specifier in Python? | I have a data table 44 columns wide that I need to write to file. I don't want to write:
outfile.write("%i,%f,%f,$f ... )\n" % (i, a,b,c ...))
In Fortran you can specify multiple format specifiers easily:
write (*,"(3f8.3)") a,b,c
Is there a similar capability in Python?
| [
">>> \"%d \" * 3\n'%d %d %d '\n>>> \"%d \" * 3 % (1,2,3)\n'1 2 3 '\n\n",
"Are you asking about\nformat= \"%i\" + \",%f\"*len(row) + \"\\n\"\noutfile.write( format % ([i]+row))\n\n",
"Is not exactly the same, but you can try something like this:\nvalues=[1,2.1,3,4,5] #you can use variables instead of values of ... | [
22,
3,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0000945972_python.txt |
Q:
How to I reload global vars on every page refresh in DJango
Here is my problem. DJango continues to store all the global objects after the first run of a script. For instance, an object you instantiate in views.py globally will be there until you restart the app server. This is fine unless your object is tied t... | How to I reload global vars on every page refresh in DJango | Here is my problem. DJango continues to store all the global objects after the first run of a script. For instance, an object you instantiate in views.py globally will be there until you restart the app server. This is fine unless your object is tied to some outside resource that may time out. Now the way I was thi... | [
"Simple: Don't use global objects.\nIf you want an object inside the view, instantiate it inside the view, not as global. That way it will be collected after the view ends.\n"
] | [
6
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000947436_django_python.txt |
Q:
Custom simple Python HTTP server not serving css files
I had found written in python, a very simple http server, it's do_get method looks like this:
def do_GET(self):
try:
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers();
... | Custom simple Python HTTP server not serving css files | I had found written in python, a very simple http server, it's do_get method looks like this:
def do_GET(self):
try:
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers();
filepath = self.path
print filepath, USTAW['r... | [
"You're explicitly serving all files as Content-type: text/html, where you need to serve CSS files as Content-type: text/css. See this page on the CSS-Discuss Wiki for details. Web servers usually have a lookup table to map from file extension to Content-Type.\n",
"it seems to be returning the html mimetype for... | [
10,
6,
2
] | [] | [] | [
"css",
"http",
"python"
] | stackoverflow_0000947372_css_http_python.txt |
Q:
Coverage not showing executed lines in virtualenv
I have a project and I am trying to run nosetests with coverage. I am running in a virtualenv.
When I run
$ python setup.py nosetests
The tests run fine but coverage is not showing that any code is executed (coverage
is all 0%).
Name ... | Coverage not showing executed lines in virtualenv | I have a project and I am trying to run nosetests with coverage. I am running in a virtualenv.
When I run
$ python setup.py nosetests
The tests run fine but coverage is not showing that any code is executed (coverage
is all 0%).
Name Stmts Exec Cover Missing
----------------------... | [
"This is going to require some back and forth. How can I see your code?\nAnd why did you come to stackoverflow for an answer rather than to the developer (that is, me)? :)\n",
"try... \neasy_install \"coverage==2.85\" \n\nI was having the same issue and this solved my problem and gave me glorious coverage report... | [
2,
2
] | [] | [] | [
"code_coverage",
"macos",
"nosetests",
"python",
"virtualenv"
] | stackoverflow_0000931248_code_coverage_macos_nosetests_python_virtualenv.txt |
Q:
Custom Markup in Django
Can anyone give me an idea or perhaps some references on how to create custom markups for django using textile or Markdown(or am I thinking wrong here)?
For example: I'd like to convert the following markups(the outer bracket mean they are grouped as one tag:
[
[Contacts]
* Contact #1
* Con... | Custom Markup in Django | Can anyone give me an idea or perhaps some references on how to create custom markups for django using textile or Markdown(or am I thinking wrong here)?
For example: I'd like to convert the following markups(the outer bracket mean they are grouped as one tag:
[
[Contacts]
* Contact #1
* Contact #2
* Contact #3
[Friend ... | [
"The built in markup app uses a filter template tag to render textile, markdown and restructuredtext. If that is not what your looking for, another option is to use a 'markup' field. e.g.,\nclass TownHallUpdate(models.Model):\n content = models.TextField()\n content_html = models.TextField(editable=False)\n\n... | [
3,
1,
0,
0
] | [] | [] | [
"django",
"markdown",
"python"
] | stackoverflow_0000933500_django_markdown_python.txt |
Q:
If slicing does not create a copy of a list nor does list() how can I get a real copy of my list?
I am trying to modify a list and since my modifications were getting a bit tricky and my list large I took a slice of my list using the following code
tempList=origList[0:10]
for item in tempList:
item[-1].insert(... | If slicing does not create a copy of a list nor does list() how can I get a real copy of my list? | I am trying to modify a list and since my modifications were getting a bit tricky and my list large I took a slice of my list using the following code
tempList=origList[0:10]
for item in tempList:
item[-1].insert(0 , item[1])
del item[1]
I did this thinking that all of the modifications to the list would affec... | [
"Slicing creates a shallow copy. In your example, I see that you are calling insert() on item[-1], which means that item is a list of lists. That means that your shallow copies still reference the original objects. You can think of it as making copies of the pointers, not the actual objects.\nYour solution lies in ... | [
24,
4
] | [] | [] | [
"copy",
"list",
"python"
] | stackoverflow_0000948032_copy_list_python.txt |
Q:
User Authentication in Pylons + AuthKit
I am trying to create a web application using Pylons and the resources on the web point to the PylonsBook page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work easily with Pylons?
I tried downloading the SimpleSit... | User Authentication in Pylons + AuthKit | I am trying to create a web application using Pylons and the resources on the web point to the PylonsBook page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work easily with Pylons?
I tried downloading the SimpleSiteTemplate from the cheeseshop but wasn't able... | [
"Ok, another update on the subject. It seems that the cheeseshop template is broken. I've followed the chapter you linked in the post and it seems that authkit is working fine. There are some caveats:\n\nsqlalchemy has to be in 0.5 version\nauthkit has to be the dev version from svn (easy_install authkit==dev)\n\nI... | [
2,
2,
1,
0
] | [] | [] | [
"authentication",
"authkit",
"pylons",
"python",
"sqlalchemy"
] | stackoverflow_0000047801_authentication_authkit_pylons_python_sqlalchemy.txt |
Q:
How can I get an accurate absolute url from get_absolute_url with an included urls.py in Django?
I've building a app right now that I'm trying to keep properly decoupled from the other apps in my Django project (feel free to lecture me on keeping Django apps decoupled, I'd be happy to learn more any/all the time).... | How can I get an accurate absolute url from get_absolute_url with an included urls.py in Django? | I've building a app right now that I'm trying to keep properly decoupled from the other apps in my Django project (feel free to lecture me on keeping Django apps decoupled, I'd be happy to learn more any/all the time).
My problem is this: The get_ absolute_url() method I've written is returning a relative path based on... | [
"Welp, \nIt turns out that when I was seeing this:\n/slug-is-here\n\nI should have looked closer. What was really happening was:\n/app-pathslug-is-here\n\nI was missing a trailing slash on my app's regex in my project urls.py.\nSo yea. let that be a lesson to y'all.\n"
] | [
0
] | [] | [] | [
"django",
"models",
"python",
"regex",
"url"
] | stackoverflow_0000947797_django_models_python_regex_url.txt |
Q:
Are there memory efficiencies gained when code is wrapped in functions?
I have been working on some code. My usual approach is to first solve all of the pieces of the problem, creating the loops and other pieces of code I need as I work through the problem and then if I expect to reuse the code I go back through... | Are there memory efficiencies gained when code is wrapped in functions? | I have been working on some code. My usual approach is to first solve all of the pieces of the problem, creating the loops and other pieces of code I need as I work through the problem and then if I expect to reuse the code I go back through it and group the parts of code together that I think should be grouped to cr... | [
"Maybe you used some local variables in your function, which are implicitly released by reference counting at the end of the function, while they are not released at the end of your code segment?\n",
"You can use the Python garbage collector interface provided to more closely examine what (if anything) is being l... | [
3,
1,
0,
0,
0
] | [] | [] | [
"function",
"memory_management",
"python"
] | stackoverflow_0000919103_function_memory_management_python.txt |
Q:
method for creating a unique validation key/number
I'm using django for a web-magazine with subscriber-content. when a user purchases a subscription, the site will create a validation key, and send it to the user email address.
The validation key would be added to a list of "valid keys" until it is used.
What is ... | method for creating a unique validation key/number | I'm using django for a web-magazine with subscriber-content. when a user purchases a subscription, the site will create a validation key, and send it to the user email address.
The validation key would be added to a list of "valid keys" until it is used.
What is the best method for creating a simple yet unique key? C... | [
"I'd recommend using a GUID. They are quickly becoming industry standard for this kind of thing.\nSee how to create them here: How to create a GUID/UUID in Python\n",
"As other posters mentioned, you are looking for a GUID, of which the most popular implemntation UUID (see here) . Django extensions (see here) off... | [
2,
2,
0
] | [] | [] | [
"django",
"python",
"validation"
] | stackoverflow_0000948493_django_python_validation.txt |
Q:
IMAP4_SSL with gmail in python
We are retrieving mails from our gmail account using IMAP4_SSL and python.
The email body is retrieved in html format.
We need to convert that to plaintext.
Can anyone help us with that?
A:
Stand on the shoulders of giants...
Peter Bengtsson has worked out a solution to this exact ... | IMAP4_SSL with gmail in python | We are retrieving mails from our gmail account using IMAP4_SSL and python.
The email body is retrieved in html format.
We need to convert that to plaintext.
Can anyone help us with that?
| [
"Stand on the shoulders of giants...\nPeter Bengtsson has worked out a solution to this exact problem here.\nPeter's script uses the awesome BeautifulSoup, by Leonard Richardson, \nand Fredrik Lundh's unescape() function.\nUsing Peter's test case, you get this:\nThis is a paragraph.\n\nFoobar [1]\nhttp://two.com\n\... | [
2
] | [] | [] | [
"gmail",
"html",
"python"
] | stackoverflow_0000948761_gmail_html_python.txt |
Q:
How i can send the commands from keyboards using python. I am trying to automate mac app (GUI)
I am trying to automate a app using python. I need help to send keyboard commands through python. I am using powerBook G4.
A:
You could call AppleScript from your python script with osascript tool:
import os
cmd = """
... | How i can send the commands from keyboards using python. I am trying to automate mac app (GUI) | I am trying to automate a app using python. I need help to send keyboard commands through python. I am using powerBook G4.
| [
"You could call AppleScript from your python script with osascript tool:\nimport os\ncmd = \"\"\"\nosascript -e 'tell application \"System Events\" to keystroke \"m\" using {command down}' \n\"\"\"\n# minimize active window\nos.system(cmd)\n\n",
"To the best of my knowledge, python does not contain the ability to... | [
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0000939746_python.txt |
Q:
Error trapping when a user inputs incorect information
So, i have recently started learning python...i am writing a small script that pulls information from a csv and i need to be able to notify a user of an incorrect input
for example
the user is asked for his id number, the id number is anything from r1 to r5
i... | Error trapping when a user inputs incorect information | So, i have recently started learning python...i am writing a small script that pulls information from a csv and i need to be able to notify a user of an incorrect input
for example
the user is asked for his id number, the id number is anything from r1 to r5
i would like my script to be able to tell the user that they ... | [
"I'm not sure what are you asking for, but if you wish to check if user entered correct id, you should try regular expressions. Look at Python Documentation on module re. Or ask google for \"python re\"\nHere's an example that will check user's input:\nimport re\n\nid_patt = re.compile(r'^r[1-5]$')\ndef checkId(id)... | [
1,
1
] | [] | [] | [
"csv",
"python",
"reporting",
"user_input"
] | stackoverflow_0000949941_csv_python_reporting_user_input.txt |
Q:
Use Django Framework with Website and Stand-alone App
I'm planning on writing a web crawler and a web-based front end for it (or, at least, the information it finds). I was wondering if it's possible to use the Django framework to let the web crawler use the same MySQL backend as the website (without making the we... | Use Django Framework with Website and Stand-alone App | I'm planning on writing a web crawler and a web-based front end for it (or, at least, the information it finds). I was wondering if it's possible to use the Django framework to let the web crawler use the same MySQL backend as the website (without making the web crawler a "website" in it's self).
| [
"Yes, you can use the same database.\nSome people use Django on top of a PHP application for its admin functionality, or to build newer features with Django and its ORM.\nWhat I'm trying to say is that if you're putting data from your crawl into the same place that you will let Django store its data, you can access... | [
4,
3
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000950790_django_python.txt |
Q:
Which validating python XML api to use?
I new to xml stuff, so I have no idea which api I should use in python.
Till now I used xmlproc, but I heard it is not developed any more.
I have basically only one requirement: I want to validate against a dtd that I can choose in my program. I can't thrust the doctype thin... | Which validating python XML api to use? | I new to xml stuff, so I have no idea which api I should use in python.
Till now I used xmlproc, but I heard it is not developed any more.
I have basically only one requirement: I want to validate against a dtd that I can choose in my program. I can't thrust the doctype thing.
Performance does not really matter, so I w... | [
"For my current project, I'm using lxml, which is fairly easy to use. Validation with DTD is described on this page\n"
] | [
3
] | [] | [] | [
"dtd",
"python",
"validation",
"xml"
] | stackoverflow_0000950974_dtd_python_validation_xml.txt |
Q:
Efficient python code for printing the product of divisors of a number
I am trying to solve a problem involving printing the product of all divisors of a given number. The number of test cases is a number 1 <= t <= 300000 , and the number itself can range from 1 <= n <= 500000
I wrote the following code, but it al... | Efficient python code for printing the product of divisors of a number | I am trying to solve a problem involving printing the product of all divisors of a given number. The number of test cases is a number 1 <= t <= 300000 , and the number itself can range from 1 <= n <= 500000
I wrote the following code, but it always exceeds the time limit of 2 seconds. Are there any ways to speed up the... | [
"You need to clarify by what you mean by \"product of divisors.\" The code posted in the question doesn't work for any definition yet. This sounds like a homework question. If it is, then perhaps your instructor was expecting you to think outside the code to meet the time goals.\nIf you mean the product of unique p... | [
6,
1,
1
] | [] | [] | [
"math",
"python"
] | stackoverflow_0000942198_math_python.txt |
Q:
How to build a fully-customizable application (aka database), without lose performance/good-design?
im in the beginning of the complete restyle of an my web application, and i have some doubt about a good database-design that can be reliable, query-performance, and in the same time fully customizable by the users ... | How to build a fully-customizable application (aka database), without lose performance/good-design? | im in the beginning of the complete restyle of an my web application, and i have some doubt about a good database-design that can be reliable, query-performance, and in the same time fully customizable by the users (users wont customize the database structure, but the funcionality of the application).
So, my actual sit... | [
"As I said in my Answer to a similar question, \"Database Design is Hard.\" You are going to have to make the decision about which is better for you, normalizing the tables and bringing phone numbers and e-mail addresses into their own tables, with the associated JOIN-ing to retrieve the data, and the extra effort... | [
4,
1,
0,
0,
0
] | [] | [] | [
"database_design",
"performance",
"php",
"postgresql",
"python"
] | stackoverflow_0000951387_database_design_performance_php_postgresql_python.txt |
Q:
How do you use FCKEditor's image upload and browser with mod-wsgi?
I am using FCKEditor within a Django app served by Apache/mod-wsgi. I don't want to install php just for FCKEditor andI see FCKEditor offers image uploading and image browsing through Python. I just haven't found good instructions on how to set thi... | How do you use FCKEditor's image upload and browser with mod-wsgi? | I am using FCKEditor within a Django app served by Apache/mod-wsgi. I don't want to install php just for FCKEditor andI see FCKEditor offers image uploading and image browsing through Python. I just haven't found good instructions on how to set this all up.
So currently Django is running through a wsgi interface using ... | [
"This describes how to embed the FCK editor and enable image uploading.\nFirst you need to edit fckconfig.js to change the image upload\nURL to point to some URL inside your server.\nFCKConfig.ImageUploadURL = \"/myapp/root/imageUploader\";\n\nThis will point to the server relative URL to receive the upload.\nFCK w... | [
1,
0
] | [] | [] | [
"django",
"fckeditor",
"mod_wsgi",
"python"
] | stackoverflow_0000803613_django_fckeditor_mod_wsgi_python.txt |
Q:
sudoku obfuscated python -> perl translation
Anybody care to translate this into obfuscated perl? It's written in Python taken from: here
def r(a):i=a.find('0');~i or exit(a);[m
in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18]
from sys import*;r(argv[1]... | sudoku obfuscated python -> perl translation | Anybody care to translate this into obfuscated perl? It's written in Python taken from: here
def r(a):i=a.find('0');~i or exit(a);[m
in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18]
from sys import*;r(argv[1])
I realize it's just for fun :)
| [
"sub r{($a=shift)=~/0/g?my$i=pos:die$a;T:for$m(1..9){($i-$_)%9*(int($i/9)^int($_/9))*(int($i/27)^int($_/27)|int($i%9/3)^int($_%9/3))||$a=~/^.{$_}$m/&&next T,for 0..80;substr($a,$i,1)=$m;r($a)}}r@ARGV\n\nThe braindead translation. Longer, since Python 2's / is integer division while Perl's is floating-point.\n",
... | [
3,
2
] | [] | [] | [
"perl",
"python",
"translate"
] | stackoverflow_0000951666_perl_python_translate.txt |
Q:
caching issues in MySQL response with MySQLdb in Django
I use MySQL with MySQLdb module in Python, in Django.
I'm running in autocommit mode in this case (and Django's transaction.is_managed() actually returns False).
I have several processes interacting with the database.
One process fetches all Task models with... | caching issues in MySQL response with MySQLdb in Django | I use MySQL with MySQLdb module in Python, in Django.
I'm running in autocommit mode in this case (and Django's transaction.is_managed() actually returns False).
I have several processes interacting with the database.
One process fetches all Task models with Task.objects.all()
Then another process adds a Task model (I... | [
"This certainly seems autocommit/table locking - related.\nIf mysqldb implements the dbapi2 spec it will probably have a connection running as one single continuous transaction. When you say: 'running in autocommit mode': do you mean MySQL itself or the mysqldb module? Or Django?\nNot intermittently commiting perfe... | [
1
] | [] | [] | [
"commit",
"connection",
"django",
"mysql",
"python"
] | stackoverflow_0000952216_commit_connection_django_mysql_python.txt |
Q:
Referencing a class' method, not an instance's
I'm writing a function that exponentiates an object, i.e. given a and n, returns an. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects __mul__ method, i.e.... | Referencing a class' method, not an instance's | I'm writing a function that exponentiates an object, i.e. given a and n, returns an. Since a needs not be a built-in type, the function accepts, as a keyword argument, a function to perform multiplications. If undefined, it defaults to the objects __mul__ method, i.e. the object itself is expected to have multiplicatio... | [
"You can call unbound methods with the instance as the first parameter:\nclass A(int):\n def sqr(self):\n return A(self*self)\n\nsqr = A.sqr\na = A(5)\nprint sqr(a) # Prints 25\n\nSo in your case you don't actually need to do anything specific, just the following:\nbin_pow(a, n, sqr=A.sqr)\n\nBe aware tha... | [
4,
3,
1,
0
] | [
"I understand it's the sqr-bit at the end you want to fix. If so, I suggest getattr. Example:\nclass SquarableThingy:\n def __init__(self, i):\n self.i = i\n def squarify(self):\n return self.i**2\n\nclass MultipliableThingy:\n def __init__(self, i):\n self.i = i\n def __mul__(self, other):\n retu... | [
-1
] | [
"python"
] | stackoverflow_0000950053_python.txt |
Q:
How to sort based on dependencies?
I have an class that has a list of "dependencies" pointing to other classes of the same base type.
class Foo(Base):
dependencies = []
class Bar(Base):
dependencies = [Foo]
class Baz(Base):
dependencies = [Bar]
I'd like to sort the instances these classes generate b... | How to sort based on dependencies? | I have an class that has a list of "dependencies" pointing to other classes of the same base type.
class Foo(Base):
dependencies = []
class Bar(Base):
dependencies = [Foo]
class Baz(Base):
dependencies = [Bar]
I'd like to sort the instances these classes generate based on their dependencies. In my examp... | [
"It's called a topological sort.\ndef sort_deps(objs):\n queue = [objs with no dependencies]\n while queue:\n obj = queue.pop()\n yield obj\n for obj in objs:\n if dependencies are now satisfied:\n queue.append(obj)\n if not all dependencies are satisfied:\n ... | [
20,
5
] | [] | [] | [
"dependencies",
"python",
"sorting"
] | stackoverflow_0000952302_dependencies_python_sorting.txt |
Q:
Why won't python allow me to delete files?
I've created a python script that gets a list of files from a text file and deletes them if they're empty. It correctly detects empty files but it doesn't want to delete them. It gives me:
(32, 'The process cannot access the file because it is being used by another proc... | Why won't python allow me to delete files? | I've created a python script that gets a list of files from a text file and deletes them if they're empty. It correctly detects empty files but it doesn't want to delete them. It gives me:
(32, 'The process cannot access the file because it is being used by another process')
I've used two different tools to check wh... | [
"You need to call .close() on the file object before you try and delete it.\nEdit: And really you shouldn't be opening the file at all. os.stat() will tell you the size of a file (and 9 other values) without ever opening the file.\nThis (I think) does the same thing but is a little cleaner (IMHO):\nimport os\n\n_MA... | [
17,
9,
6,
4,
3
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0000953040_file_io_python.txt |
Q:
Explicit access to Python's built in scope
How do you explicitly access name in Python's built in scope?
One situation where I ran in to this was a in module, say called foo, which happened to have an open function. In another module foo's open function would be accessible as foo.open which works well. In foo ... | Explicit access to Python's built in scope | How do you explicitly access name in Python's built in scope?
One situation where I ran in to this was a in module, say called foo, which happened to have an open function. In another module foo's open function would be accessible as foo.open which works well. In foo itself though, open blocks the built in open. H... | [
"Use __builtin__.\ndef open():\n pass\n\nimport __builtin__\n\nprint open\nprint __builtin__.open\n\n... gives you ...\n\n<function open at 0x011E8670>\n<built-in function open> \n\n"
] | [
12
] | [
"It's something like\n__builtins__.open()\n\n"
] | [
-2
] | [
"python"
] | stackoverflow_0000953027_python.txt |
Q:
Measure Path Length in Blender Script?
In Blender (v2.48), how can I determine the length of a path (in Blender units) from a Python script?
The value is available from the GUI: With the path selected, the Editing panel contains a PrintLen button. The length appears to the right when the button is pressed.
How can... | Measure Path Length in Blender Script? | In Blender (v2.48), how can I determine the length of a path (in Blender units) from a Python script?
The value is available from the GUI: With the path selected, the Editing panel contains a PrintLen button. The length appears to the right when the button is pressed.
How can I obtain this value programmatically from a... | [
"The best idea I've found is to create a mesh from the path and sum the length of the segments (edges).\nimport Blender\n\ndef get_length(path):\n \"\"\"\n Return the length (in Blender distance units) of the path.\n \"\"\"\n mesh = Blender.Mesh.New()\n mesh.getFromObject(path)\n\n return sum(edge... | [
2
] | [] | [] | [
"blender",
"python"
] | stackoverflow_0000848499_blender_python.txt |
Q:
How do I update an object's members using a dict?
I'm writing a Django app that performs various functions, including inserting, or updating new records into the database via the URL.
So some internal application sends off a request to /import/?a=1&b=2&c=3, for example.
In the view, I want to create a new object, ... | How do I update an object's members using a dict? | I'm writing a Django app that performs various functions, including inserting, or updating new records into the database via the URL.
So some internal application sends off a request to /import/?a=1&b=2&c=3, for example.
In the view, I want to create a new object, foo = Foo() and have the members of foo set to the data... | [
"You can use the setattr function to dynamically set attributes:\nfor key,value in request.GET.items():\n setattr(foo, key, value)\n\n",
"If request.GET is a dictionary and class Foo does not use __slots__, then this should also work:\n# foo is a Foo instance\nfoo.__dict__.update(request.GET)\n\n",
"You've a... | [
19,
3,
1,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000940089_django_python.txt |
Q:
Is there a standalone alternative to activerecord-like database schema migrations?
Is there any standalone alternative to activerecord-like migrations. Something like a script that is able to track current schema version and apply outstanding migrations. Basically, these migration files could be just a plain SQL f... | Is there a standalone alternative to activerecord-like database schema migrations? | Is there any standalone alternative to activerecord-like migrations. Something like a script that is able to track current schema version and apply outstanding migrations. Basically, these migration files could be just a plain SQL files, something like:
[timestamp]_create_users.sql
reverse_[timestamp]_create_users.sql... | [
"Try http://freshmeat.net/projects/liquibase/\nIf you are using MySQL specifically, have a look at: http://www.mysqldiff.org/\nI used this to synchronize the schema of two databases (so you would have to apply the changes to a \"master\").\nThere's also http://phpmyversion.sourceforge.net/\n",
"http://code.googl... | [
2,
1,
0,
0,
0,
0
] | [] | [] | [
"mysql",
"php",
"python",
"shell",
"sql"
] | stackoverflow_0000362334_mysql_php_python_shell_sql.txt |
Q:
Error running tutorial that came along wxPython2.8 Docs and Demos
I tried the following example code from the tutorial that came along "wxPython2.8 Docs and Demos" package.
import wx
from frame import Frame
class App(wx.App):
"""Application class."""
def OnInit(self):
self.frame = Frame()
... | Error running tutorial that came along wxPython2.8 Docs and Demos | I tried the following example code from the tutorial that came along "wxPython2.8 Docs and Demos" package.
import wx
from frame import Frame
class App(wx.App):
"""Application class."""
def OnInit(self):
self.frame = Frame()
self.frame.Show()
self.SetTopWindow(self.frame)
retur... | [
"I think you should skip the \"from frame import Frame\" and change:\nself.frame = Frame()\n\nto:\nself.frame = wx.Frame()\n\n",
"Yeah, it's an ancient doc bug, see for example this 5-years-old post:-(. Fix:\n\ndelete the line that says from frame\nimport Frame\nchange the line that says self.frame\n= Frame() to ... | [
1,
0
] | [] | [] | [
"python",
"windows",
"wxpython"
] | stackoverflow_0000954132_python_windows_wxpython.txt |
Q:
Getting object's parent namespace in python?
In python it's possible to use '.' in order to access object's dictionary items. For example:
class test( object ) :
def __init__( self ) :
self.b = 1
def foo( self ) :
pass
obj = test()
a = obj.foo
From above example, having 'a' object, is it possible to g... | Getting object's parent namespace in python? | In python it's possible to use '.' in order to access object's dictionary items. For example:
class test( object ) :
def __init__( self ) :
self.b = 1
def foo( self ) :
pass
obj = test()
a = obj.foo
From above example, having 'a' object, is it possible to get from it reference to 'obj' that is a parent nam... | [
"On bound methods, you can use three special read-only parameters:\n\nim_func which returns the (unbound) function object\nim_self which returns the object the function is bound to (class instance)\nim_class which returns the class of im_self\n\nTesting around:\nclass Test(object):\n def foo(self):\n pass... | [
17,
14,
8
] | [] | [] | [
"python",
"python_datamodel"
] | stackoverflow_0000954340_python_python_datamodel.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.