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:
How do I make a menu that does not require the user to press [enter] to make a selection?
I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user.
The problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way... | How do I make a menu that does not require the user to press [enter] to make a selection? | I've got a menu in Python. That part was easy. I'm using raw_input() to get the selection from the user.
The problem is that raw_input (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far:
import sys
... | [
"On Windows:\nimport msvcrt\nanswer=msvcrt.getch()\n\n",
"On Linux:\n\nset raw mode\nselect and read the keystroke\nrestore normal settings\n\n\nimport sys\nimport select\nimport termios\nimport tty\n\ndef getkey():\n old_settings = termios.tcgetattr(sys.stdin)\n tty.setraw(sys.stdin.fileno())\n select.s... | [
10,
9,
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0000001829_python.txt |
Q:
File size differences after copying a file to a server vía FTP
I have created a PHP-script to update a web server that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file... | File size differences after copying a file to a server vía FTP | I have created a PHP-script to update a web server that is live inside a local directory.
I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server.
Once I download ... | [
"Do you need to open the locfile in binary using rb?\nf = open (locfile, \"rb\")\n\n",
"Well if you go under the properties of your file in Windows or a *nix environment, you will notice two sizes. One is the sector size, and one is the actual size. The sector size is the number of sectors in bytes that are use... | [
17,
3,
0
] | [] | [] | [
"ftp",
"ftplib",
"php",
"python",
"webserver"
] | stackoverflow_0000002311_ftp_ftplib_php_python_webserver.txt |
Q:
Programmatically talking to a Serial Port in OS X or Linux
I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /... | Programmatically talking to a Serial Port in OS X or Linux | I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial .
When i do this everything seems to be hunky... | [
"/dev/cu.xxxxx is the \"callout\" device, it's what you use when you establish a connection to the serial device and start talking to it. /dev/tty.xxxxx is the \"dialin\" device, used for monitoring a port for incoming calls for e.g. a fax listener.\n",
"have you tried watching the traffic between the GUI and the... | [
5,
0
] | [] | [] | [
"linux",
"macos",
"python",
"serial_port"
] | stackoverflow_0000003976_linux_macos_python_serial_port.txt |
Q:
Get a preview JPEG of a PDF on Windows?
I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.
On the Mac I am spawning sips. Is there something similarly simple I can do on Windows?
A:
ImageMagick delegates the PDF->bitmap conversion to GhostScript anywa... | Get a preview JPEG of a PDF on Windows? | I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.
On the Mac I am spawning sips. Is there something similarly simple I can do on Windows?
| [
"ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the ps:alpha delegate in ImageMagick, just adjusted to use JPEG as output):\ngs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \\\n-dMaxBitmap=500000000 -dLas... | [
44,
16,
5
] | [] | [] | [
"image",
"pdf",
"python",
"windows"
] | stackoverflow_0000000502_image_pdf_python_windows.txt |
Q:
Best way to abstract season/show/episode data
Basically, I've written an API to www.thetvdb.com in Python. The current code can be found here.
It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:
print tvdbinstance[1][23]['episodename'] # get the name of episo... | Best way to abstract season/show/episode data | Basically, I've written an API to www.thetvdb.com in Python. The current code can be found here.
It grabs data from the API as requested, and has to store the data somehow, and make it available by doing:
print tvdbinstance[1][23]['episodename'] # get the name of episode 23 of season 1
What is the "best" way to abstra... | [
"OK, what you need is classobj from new module. That would allow you to construct exception classes dynamically (classobj takes a string as an argument for the class name). \nimport new\nmyexc=new.classobj(\"ExcName\",(Exception,),{})\ni=myexc(\"This is the exc msg!\")\nraise i\n\nthis gives you:\nTraceback (most r... | [
7,
4,
0,
0,
0
] | [] | [] | [
"data_structures",
"python"
] | stackoverflow_0000005966_data_structures_python.txt |
Q:
Python Regular Expressions to implement string unescaping
I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what...
>>> import re
>>> mystring = r"This is \n a test \r"
>>> p... | Python Regular Expressions to implement string unescaping | I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what...
>>> import re
>>> mystring = r"This is \n a test \r"
>>> p = re.compile( "\\\\(\\S)" )
>>> p.sub( "\\1", mystring )
'This... | [
"Isn't that what Anders' second example does?\nIn 2.5 there's also a string-escape encoding you can apply:\n>>> mystring = r\"This is \\n a test \\r\"\n>>> mystring.decode('string-escape')\n'This is \\n a test \\r'\n>>> print mystring.decode('string-escape')\nThis is \n a test \n>>> \n\n",
"Well, I think you migh... | [
10,
3,
1,
0,
0
] | [] | [] | [
"backreference",
"python",
"regex"
] | stackoverflow_0000013791_backreference_python_regex.txt |
Q:
What's the best way to distribute python command-line tools?
My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..
Can I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?
... | What's the best way to distribute python command-line tools? | My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..
Can I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?
| [
"Try the entry_points.console_scripts parameter in the setup() call. As described in the setuptools docs, this should do what I think you want.\nTo reproduce here:\nfrom setuptools import setup\n\nsetup(\n # other arguments here...\n entry_points = {\n 'console_scripts': [\n 'foo = package.m... | [
38
] | [] | [] | [
"command_line",
"packaging",
"python"
] | stackoverflow_0000017893_command_line_packaging_python.txt |
Q:
Introducing Python
The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development.
But, currently, one of the developers has seen the light of Django (the company has on... | Introducing Python | The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development.
But, currently, one of the developers has seen the light of Django (the company has only developed in PHP to d... | [
"I recently introduced Python to my company, which does consulting work for the Post Office. I did this by waiting until there was a project for which I would be the only programmer, then getting permission to do this new project in Python. I then did another small project in Python with similarly impressive resu... | [
15,
4,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"php",
"python"
] | stackoverflow_0000019654_php_python.txt |
Q:
How to check set of files conform to a naming scheme
I have a bunch of files (TV episodes, although that is fairly arbitrary) that I want to check match a specific naming/organisation scheme..
Currently: I have three arrays of regex, one for valid filenames, one for files missing an episode name, and one for valid... | How to check set of files conform to a naming scheme | I have a bunch of files (TV episodes, although that is fairly arbitrary) that I want to check match a specific naming/organisation scheme..
Currently: I have three arrays of regex, one for valid filenames, one for files missing an episode name, and one for valid paths.
Then, I loop though each valid-filename regex, if ... | [
"\nI want to add a rule that checks for\n the presence of a folder.jpg file in\n each directory, but to add this would\n make the code substantially more messy\n in it's current state..\n\nThis doesn't look bad. In fact your current code does it very nicely, and Sven mentioned a good way to do it as well:\n\nG... | [
2,
0
] | [] | [] | [
"naming",
"python",
"validation"
] | stackoverflow_0000019030_naming_python_validation.txt |
Q:
Date/time conversion using time.mktime seems wrong
>>> import time
>>> time.strptime("01-31-2009", "%m-%d-%Y")
(2009, 1, 31, 0, 0, 0, 5, 31, -1)
>>> time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1))
1233378000.0
>>> 60*60*24 # seconds in a day
86400
>>> 1233378000.0 / 86400
14275.208333333334
time.mktime should retu... | Date/time conversion using time.mktime seems wrong | >>> import time
>>> time.strptime("01-31-2009", "%m-%d-%Y")
(2009, 1, 31, 0, 0, 0, 5, 31, -1)
>>> time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1))
1233378000.0
>>> 60*60*24 # seconds in a day
86400
>>> 1233378000.0 / 86400
14275.208333333334
time.mktime should return the number of seconds since the epoch. Since I'm givi... | [
"Short answer: Because of timezones.\nThe Epoch is in UTC.\nFor example, I'm on IST (Irish Standard Time) or UTC+1. time.mktime() is relative to my timezone, so on my system this refers to\n>>> time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1))\n1233360000.0\n\nBecause you got the result 1233378000, that would suggest ... | [
7,
3,
2,
0
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0000021961_datetime_python.txt |
Q:
Does PHP have an equivalent to this type of Python string substitution?
Python has this wonderful way of handling string substitutions using dictionaries:
>>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'}
'The Stackoverflow site rocks because it rocks'
I love this becaus... | Does PHP have an equivalent to this type of Python string substitution? | Python has this wonderful way of handling string substitutions using dictionaries:
>>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'}
'The Stackoverflow site rocks because it rocks'
I love this because you can specify a value once in the dictionary and then replace it all over... | [
"function subst($str, $dict){\n return preg_replace(array_map(create_function('$a', 'return \"/%\\\\($a\\\\)s/\";'), array_keys($dict)), array_values($dict), $str);\n }\n\nYou call it like so:\necho subst('The %(site)s site %(adj)s because it %(adj)s', array('site'=>'Stackoverflow', 'adj'=>'rocks'));\n\n",
"@M... | [
5,
4,
1
] | [] | [] | [
"php",
"python",
"string"
] | stackoverflow_0000028165_php_python_string.txt |
Q:
How do I create an xml document in python
Here is my sample code:
from xml.dom.minidom import *
def make_xml():
doc = Document()
node = doc.createElement('foo')
node.innerText = 'bar'
doc.appendChild(node)
return doc
if __name__ == '__main__':
make_xml().writexml(sys.stdout)
when I run the... | How do I create an xml document in python | Here is my sample code:
from xml.dom.minidom import *
def make_xml():
doc = Document()
node = doc.createElement('foo')
node.innerText = 'bar'
doc.appendChild(node)
return doc
if __name__ == '__main__':
make_xml().writexml(sys.stdout)
when I run the above code I get this:
<?xml version="1.0" ?>
... | [
"@Daniel\nThanks for the reply, I also figured out how to do it with the minidom (I'm not sure of the difference between the ElementTree vs the minidom)\n\n\nfrom xml.dom.minidom import *\ndef make_xml():\n doc = Document();\n node = doc.createElement('foo')\n node.appendChild(doc.createTextNode('bar'))\n ... | [
13,
9
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0000029243_python_xml.txt |
Q:
Proprietary plug-ins for GPL programs: what about interpreted languages?
I am developing a GPL-licensed application in Python and need to know if the GPL allows my program to use proprietary plug-ins. This is what the FSF has to say on the issue:
If a program released under the GPL uses plug-ins, what are the req... | Proprietary plug-ins for GPL programs: what about interpreted languages? | I am developing a GPL-licensed application in Python and need to know if the GPL allows my program to use proprietary plug-ins. This is what the FSF has to say on the issue:
If a program released under the GPL uses plug-ins, what are the requirements for the licenses of a plug-in?
It depends on how the program invokes... | [
"\nhe distinction between fork/exec and dynamic linking, besides being kind of artificial,\n\nI don't think its artificial at all. Basically they are just making the division based upon the level of integration. If the program has \"plugins\" which are essentially fire and forget with no API level integration, th... | [
7,
1,
0
] | [] | [] | [
"interpreted_language",
"licensing",
"open_source",
"plugins",
"python"
] | stackoverflow_0000031412_interpreted_language_licensing_open_source_plugins_python.txt |
Q:
Install Python to match directory layout in OS X 10.5
The default Python install on OS X 10.5 is 2.5.1 with a FAT 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past, I have run Apache and MySQL to match this install in 32 bit mode (even stripping out the 64 bit stuff from Ap... | Install Python to match directory layout in OS X 10.5 | The default Python install on OS X 10.5 is 2.5.1 with a FAT 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past, I have run Apache and MySQL to match this install in 32 bit mode (even stripping out the 64 bit stuff from Apache to make it work).
I want to upgrade Python to 64 bit. ... | [
"Not sure I entirely understand your question, but can't you simply build and install a 64 bit version and then create symbolic links so that /Library/Python/2.5 and below point to your freshly built version of python?\n",
"Personally, I wouldn't worry about it until you see a problem. Messing with the default p... | [
1,
1,
1,
0,
0
] | [] | [] | [
"64_bit",
"macos",
"python"
] | stackoverflow_0000029856_64_bit_macos_python.txt |
Q:
ssh hangs when command invoked directly, but exits cleanly when run interactive
I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr.
I want to automate the p... | ssh hangs when command invoked directly, but exits cleanly when run interactive | I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr.
I want to automate the process of logging on to the remote machine, launching the process, and retrieving the... | [
"\ns = p.stderr.readline()\n\n\nI suspect it's the above line. When you invoke a command directly through ssh, you don't get your full pty (assuming Linux), and thus no stderr to read from.\nWhen you log in interactively, stdin, stdout, and stderr are set up for you, and so your script works.\n",
"what if you do... | [
3,
0
] | [] | [] | [
"python",
"ssh"
] | stackoverflow_0000033475_python_ssh.txt |
Q:
Why does Python's iter() on a mapping return iterkeys() instead of iteritems()?
It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?
A:
Check out this thread for a discussio... | Why does Python's iter() on a mapping return iterkeys() instead of iteritems()? | It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?
| [
"Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change).\n"
] | [
11
] | [] | [] | [
"iteration",
"mapping",
"python"
] | stackoverflow_0000035569_iteration_mapping_python.txt |
Q:
Django ImageField core=False in newforms admin
In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields.
I get the following error:
TypeError: __init__() got an unexpected keyword argument 'core'
[Edit] However, by just removing the core argument I get a "This ... | Django ImageField core=False in newforms admin | In the transition to newforms admin I'm having difficulty figuring out how specify core=False for ImageFields.
I get the following error:
TypeError: __init__() got an unexpected keyword argument 'core'
[Edit] However, by just removing the core argument I get a "This field is required." error in the admin interface on ... | [
"To get rid of \"This field is required,\" you need to make it not required, by using blank=True (and possibly null=True as well, if it's not a CharField).\n",
"The core attribute isn't used anymore.\nFrom Brian Rosner's Blog:\n\nYou can safely just remove any and all core arguments. They are no longer used. newf... | [
5,
4,
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0000034209_django_django_models_python.txt |
Q:
Programmatically editing Python source
This is something that I think would be very useful. Basically, I'd like there to be a way to edit Python source programmatically without requiring human intervention. There are a couple of things I would like to do with this:
Edit the configuration of Python apps that use... | Programmatically editing Python source | This is something that I think would be very useful. Basically, I'd like there to be a way to edit Python source programmatically without requiring human intervention. There are a couple of things I would like to do with this:
Edit the configuration of Python apps that use source modules for configuration.
Set up a ... | [
"Python's standard library provides pretty good facilities for working with Python source; note the tokenize and parser modules.\n",
"I had the same issue and I simply opened the file and did some replace: then reload the file in the Python interpreter. This works fine and is easy to do. \nOtherwise AFAIK you hav... | [
6,
0,
0
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0000032385_file_io_python.txt |
Q:
"The system cannot find the file specified" when invoking subprocess.Popen in python
I'm trying to use svnmerge.py to merge some files. Under the hood it uses python, and when I use it I get an error - "The system cannot find the file specified". Colleagues at work are running the same version of svnmerge.py, and ... | "The system cannot find the file specified" when invoking subprocess.Popen in python | I'm trying to use svnmerge.py to merge some files. Under the hood it uses python, and when I use it I get an error - "The system cannot find the file specified". Colleagues at work are running the same version of svnmerge.py, and of python (2.5.2, specifically r252:60911) without an issue.
I found this link, which desc... | [
"It's a bug, see the documentation of subprocess.Popen. There either needs to be a \"shell=True\" option, or the first argument needs to be a sequence ['svn', '--version']. As it is now, Popen is looking for an executable named, literally, \"svn --version\" which it doesn't find.\nI don't know why it would work for... | [
21
] | [] | [] | [
"python",
"svn_merge"
] | stackoverflow_0000036324_python_svn_merge.txt |
Q:
How do I add data to an existing model in Django?
Currently, I am writing up a bit of a product-based CMS as my first project.
Here is my question. How can I add additional data (products) to my Product model?
I have added '/admin/products/add' to my urls.py, but I don't really know where to go from there. How wou... | How do I add data to an existing model in Django? | Currently, I am writing up a bit of a product-based CMS as my first project.
Here is my question. How can I add additional data (products) to my Product model?
I have added '/admin/products/add' to my urls.py, but I don't really know where to go from there. How would i build both my view and my template? Please keep in... | [
"You will want to wire your URL to the Django create_object generic view, and pass it either \"model\" (the model you want to create) or \"form_class\" (a customized ModelForm class). There are a number of other arguments you can also pass to override default behaviors.\nSample URLconf for the simplest case:\nfrom... | [
7
] | [
"This topic is covered in Django tutorials.\n",
"Follow the Django tutorial for setting up the \"admin\" part of an application. This will allow you to modify your database.\nDjango Admin Setup\nAlternatively, you can just connect directly to the database using the standard tools for whatever database type you ar... | [
-1,
-2
] | [
"django",
"python"
] | stackoverflow_0000036812_django_python.txt |
Q:
How can I simply inherit methods from an existing instance?
Below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name.
import cgi
class ClassX(object):
pass # ... with own __repr__
class Cl... | How can I simply inherit methods from an existing instance? | Below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name.
import cgi
class ClassX(object):
pass # ... with own __repr__
class ClassY(object):
pass # ... with own __repr__
inst_x=ClassX()
in... | [
"\nVery close, but then I lose everything from ClassX. Below is something a collegue gave me that does do the trick, but it's hideous. There has to be a better way.\n\nLooks like you're trying to set up some sort of proxy object scheme. That's doable, and there are better solutions than your colleague's, but first ... | [
2,
2,
0,
0,
0,
0
] | [] | [] | [
"inheritance",
"object",
"oop",
"python"
] | stackoverflow_0000037479_inheritance_object_oop_python.txt |
Q:
Why is the subprocess.Popen class not named Subprocess?
The primary class in the subprocess module is name Popen, and represents a subprocess. Popen sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does ... | Why is the subprocess.Popen class not named Subprocess? | The primary class in the subprocess module is name Popen, and represents a subprocess. Popen sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple like, say... | [
"Now, I'm not saying that this is the greatest name in the world, but here was the idea as I understand it.\nOriginally, the popen family was in the os module and was an implementation of the venerable posix popen. The movement to the subprocess module would have been an opportune time to rename them, but I guess ... | [
8,
5
] | [
"I suppose the name was chosen because the functionality subprocess is replacing was formerly in the os module as the os.popen function. There could be even ways to automate migration between the two.\n"
] | [
-1
] | [
"python",
"subprocess"
] | stackoverflow_0000038197_python_subprocess.txt |
Q:
Retrieving an Oracle timestamp using Python's Win32 ODBC module
Given an Oracle table created using the following:
CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME ZONE);
Using the Python ODBC module from its Win32 extensions (from the win32all package), I tried the following:
import dbi, odbc
connection = odbc... | Retrieving an Oracle timestamp using Python's Win32 ODBC module | Given an Oracle table created using the following:
CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME ZONE);
Using the Python ODBC module from its Win32 extensions (from the win32all package), I tried the following:
import dbi, odbc
connection = odbc.odbc("Driver=Oracle in OraHome92;Dbq=SERVER;Uid=USER;Pwd=PASSWD")
c... | [
"I believe this is a bug in the Oracle ODBC driver. Basically, the Oracle ODBC driver does not support the TIMESTAMP WITH (LOCAL) TIME ZONE data types, only the TIMESTAMP data type. As you have discovered, one workaround is in fact to use the TO_CHAR method.\nIn your example you are not actually reading the time zo... | [
2,
1
] | [] | [] | [
"ora_00932",
"oracle",
"python"
] | stackoverflow_0000038435_ora_00932_oracle_python.txt |
Q:
Ruby "is" equivalent
Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location).
A:
Use a.equal? b
http://www.ruby-doc.org/core/classes/Object.html
Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine ob... | Ruby "is" equivalent | Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location).
| [
"Use a.equal? b\nhttp://www.ruby-doc.org/core/classes/Object.html\n\nUnlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b). \n\n",
"You could also use __id__. This gives you the objects internal ID number... | [
13,
2
] | [] | [] | [
"python",
"ruby"
] | stackoverflow_0000035634_python_ruby.txt |
Q:
Why is my instance variable not in __dict__?
If I create a class A as follows:
class A:
def __init__(self):
self.name = 'A'
Inspecting the __dict__ member looks like {'name': 'A'}
If however I create a class B:
class B:
name = 'B'
__dict__ is empty.
What is the difference between the two, and why... | Why is my instance variable not in __dict__? | If I create a class A as follows:
class A:
def __init__(self):
self.name = 'A'
Inspecting the __dict__ member looks like {'name': 'A'}
If however I create a class B:
class B:
name = 'B'
__dict__ is empty.
What is the difference between the two, and why doesn't name show up in B's __dict__?
| [
"B.name is a class attribute, not an instance attribute. It shows up in B.__dict__, but not in b = B(); b.__dict__.\nThe distinction is obscured somewhat because when you access an attribute on an instance, the class dict is a fallback. So in the above example, b.name will give you the value of B.name.\n",
"cla... | [
46,
12
] | [] | [] | [
"python"
] | stackoverflow_0000035805_python.txt |
Q:
Javascript equivalent of Python's locals()?
In Python one can get a dictionary of all local and global variables in the current scope with the built-in functions locals() and globals(). Is there some equivalent way of doing this in Javascript? For instance, I would like to do something like the following:
var fo... | Javascript equivalent of Python's locals()? | In Python one can get a dictionary of all local and global variables in the current scope with the built-in functions locals() and globals(). Is there some equivalent way of doing this in Javascript? For instance, I would like to do something like the following:
var foo = function(){ alert('foo'); };
var bar = functi... | [
"\nlocals() - No. \nglobals() - Yes.\n\nwindow is a reference to the global scope, like globals() in python.\nglobals()[\"foo\"]\n\nis the same as:\nwindow[\"foo\"]\n\n",
"Well, I don't think that there is something like that in js. You can always use eval instead of locals(). Like this: \neval(s+\"()\");\n\nYou ... | [
18,
4,
3,
0,
0
] | [
"AFAIK, no. If you just want to check the existence of a given variable, you can do it by testing for it, something like this:\nif (foo) foo();\n\n"
] | [
-1
] | [
"javascript",
"python"
] | stackoverflow_0000039960_javascript_python.txt |
Q:
Using C in a shared multi-platform POSIX environment
I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if mayb... | Using C in a shared multi-platform POSIX environment | I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,... | [
"Launching a Python interpreter instance just to select the right binary to run would be much heavier than you need. I'd distribute a shell .rc file which provides aliases.\nIn /shared/bin, you put the various binaries: /shared/bin/toolname-mac, /shared/bin/toolname-debian-x86, /shared/bin/toolname-netbsd-dreamcas... | [
2,
1,
0,
0
] | [] | [] | [
"c",
"cross_platform",
"posix",
"python",
"scripting"
] | stackoverflow_0000039847_c_cross_platform_posix_python_scripting.txt |
Q:
cx_Oracle: how do I get the ORA-xxxxx error number?
In a try/except block, how do I extract the Oracle error number?
A:
try:
cursor.execute("select 1 / 0 from dual")
except cx_Oracle.DatabaseError, e:
error, = e
print "Code:", error.code
print "Message:", error.message
This results in the following ... | cx_Oracle: how do I get the ORA-xxxxx error number? | In a try/except block, how do I extract the Oracle error number?
| [
"try:\n cursor.execute(\"select 1 / 0 from dual\")\nexcept cx_Oracle.DatabaseError, e:\n error, = e\n print \"Code:\", error.code\n print \"Message:\", error.message\n\nThis results in the following output:\nCode: 1476\nMessage: ORA-01476: divisor is equal to zero\n\n"
] | [
13
] | [] | [] | [
"cx_oracle",
"oracle",
"python"
] | stackoverflow_0000040586_cx_oracle_oracle_python.txt |
Q:
Is there a python module for regex matching in zip files
I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files.
Is there any python module which can do a regex ... | Is there a python module for regex matching in zip files | I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files.
Is there any python module which can do a regex match on the files without unzipping it. Is there a simple way... | [
"There's nothing that will automatically do what you want.\nHowever, there is a python zipfile module that will make this easy to do. Here's how to iterate over the lines in the file.\n#!/usr/bin/python\n\nimport zipfile\nf = zipfile.ZipFile('myfile.zip')\n\nfor subfile in f.namelist():\n print subfile\n dat... | [
10,
0,
0,
0
] | [] | [] | [
"python",
"regex",
"text_processing",
"zip"
] | stackoverflow_0000014281_python_regex_text_processing_zip.txt |
Q:
How do I do monkeypatching in python?
I've had to do some introspection in python and it wasn't pretty:
name = sys._getframe(1).f_code
name = "%s:%d %s()" %(os.path.split(name.co_filename)[1],name.co_firstlineno,name.co_name)
To get something like
foo.py:22 bar() blah blah
In our debugging output.
I'd ideally li... | How do I do monkeypatching in python? | I've had to do some introspection in python and it wasn't pretty:
name = sys._getframe(1).f_code
name = "%s:%d %s()" %(os.path.split(name.co_filename)[1],name.co_firstlineno,name.co_name)
To get something like
foo.py:22 bar() blah blah
In our debugging output.
I'd ideally like to prepend anything to stderr with this ... | [
"A print statement does its IO through \"sys.stdout.write\" so you can override sys.stdout if you want to manipulate the print stream.\n",
"The python inspect module makes this a lot easier and cleaner. \n"
] | [
3,
1
] | [] | [] | [
"monkeypatching",
"python"
] | stackoverflow_0000041562_monkeypatching_python.txt |
Q:
Standard way to open a folder window in linux?
I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.
On OSX, I can open a window in the finder with
os.system('open "%s"' % foldername)
and on Windows with
os.startfile(foldername)
What... | Standard way to open a folder window in linux? | I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.
On OSX, I can open a window in the finder with
os.system('open "%s"' % foldername)
and on Windows with
os.startfile(foldername)
What about unix/linux? Is there a standard way to do thi... | [
"os.system('xdg-open \"%s\"' % foldername)\n\nxdg-open can be used for files/urls also\n",
"this would probably have to be done manually, or have as a config item since there are many file managers that users may want to use. Providing a way for command options as well.\nThere might be an function that launches t... | [
15,
0,
0
] | [] | [] | [
"cross_platform",
"desktop",
"linux",
"python"
] | stackoverflow_0000041969_cross_platform_desktop_linux_python.txt |
Q:
Pure Python library to generate Identicons?
Does anyone know of a FOSS Python lib for generating Identicons? I've looked, but so far I haven't had much luck.
A:
I've found two implementations:
http://coderepos.org/share/browser/lang/python/misc/identicon.py
http://code.google.com/p/visicon/
| Pure Python library to generate Identicons? | Does anyone know of a FOSS Python lib for generating Identicons? I've looked, but so far I haven't had much luck.
| [
"I've found two implementations:\nhttp://coderepos.org/share/browser/lang/python/misc/identicon.py\nhttp://code.google.com/p/visicon/\n"
] | [
12
] | [] | [] | [
"identicon",
"python"
] | stackoverflow_0000042093_identicon_python.txt |
Q:
How can I get a commit message from a bzr post-commit hook?
I'm trying to write a bzr post-commit hook for my private bugtracker, but I'm stuck at the function signature of
post_commit(local, master, old_revno, old_revid, new_revno, mew_revid)
How can I extract the commit message for the branch from this with bz... | How can I get a commit message from a bzr post-commit hook? | I'm trying to write a bzr post-commit hook for my private bugtracker, but I'm stuck at the function signature of
post_commit(local, master, old_revno, old_revid, new_revno, mew_revid)
How can I extract the commit message for the branch from this with bzrlib in Python?
| [
"And the answer is like so:\ndef check_commit_msg(local, master, old_revno, old_revid, new_revno, new_revid):\n branch = local or master\n revision = branch.repository.get_revision(new_revid)\n print revision.message\n\nlocal and master are Branch objects, so once you have a revision, it's easy to extract ... | [
5
] | [] | [] | [
"bazaar",
"dvcs",
"python"
] | stackoverflow_0000043099_bazaar_dvcs_python.txt |
Q:
Can the HTTP version or headers affect the visual appearance of a web page?
I know, I would have thought the answer was obviously "no" as well, but I am experiencing a strange situation where when I view my site from our staging server it appears slightly larger than when I view it from my local dev server. I hav... | Can the HTTP version or headers affect the visual appearance of a web page? | I know, I would have thought the answer was obviously "no" as well, but I am experiencing a strange situation where when I view my site from our staging server it appears slightly larger than when I view it from my local dev server. I have used Charles to confirm that all of the content -- the HTML, the images, the CS... | [
"Have you tried View -> Zoom -> Reset on both sites?\n"
] | [
9
] | [] | [] | [
"django",
"firefox",
"python"
] | stackoverflow_0000045013_django_firefox_python.txt |
Q:
Python packages - import by class, not file
Say I have the following file structure:
app/
app.py
controllers/
__init__.py
project.py
plugin.py
If app/controllers/project.py defines a class Project, app.py would import it like this:
from app.controllers.project import Project
I'd like to just be a... | Python packages - import by class, not file | Say I have the following file structure:
app/
app.py
controllers/
__init__.py
project.py
plugin.py
If app/controllers/project.py defines a class Project, app.py would import it like this:
from app.controllers.project import Project
I'd like to just be able to do:
from app.controllers import Project
H... | [
"You need to put\nfrom project import Project\n\nin controllers/__init__.py.\nNote that when Absolute imports become the default (Python 2.7?), you will want to add a dot before the module name (to avoid collisions with a top-level model named project), i.e.,\nfrom .project import Project\n\n"
] | [
103
] | [] | [] | [
"package",
"python"
] | stackoverflow_0000045122_package_python.txt |
Q:
Where can I find the time and space complexity of the built-in sequence types in Python
I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online?
A:
Checkout the TimeComplexity... | Where can I find the time and space complexity of the built-in sequence types in Python | I've been unable to find a source for this information, short of looking through the Python source code myself to determine how the objects work. Does anyone know where I could find this online?
| [
"Checkout the TimeComplexity page on the py dot org wiki. It covers set/dicts/lists/etc at least as far as time complexity goes.\n",
"Raymond D. Hettinger does an excellent talk (slides) about Python's built-in collections called 'Core Python Containers - Under the Hood'. The version I saw focussed mainly on set ... | [
19,
15,
2
] | [] | [] | [
"big_o",
"complexity_theory",
"performance",
"python",
"sequences"
] | stackoverflow_0000045228_big_o_complexity_theory_performance_python_sequences.txt |
Q:
Pylons error - 'MySQL server has gone away'
I'm using Pylons (a python framework) to serve a simple web application, but it seems to die from time to time, with this in the error log: (2006, 'MySQL server has gone away')
I did a bit of checking, and saw that this was because the connections to MySQL were not being... | Pylons error - 'MySQL server has gone away' | I'm using Pylons (a python framework) to serve a simple web application, but it seems to die from time to time, with this in the error log: (2006, 'MySQL server has gone away')
I did a bit of checking, and saw that this was because the connections to MySQL were not being renewed. This shouldn't be a problem though, bec... | [
"I think I fixed it. It's turns out I had a simple config error. My ini file read:\nsqlalchemy.default.url = [connection string here]\nsqlalchemy.pool_recycle = 1800\n\nThe problem is that my environment.py file declared that the engine would only map keys with the prefix: sqlalchemy.default so pool_recycle was ign... | [
8,
2
] | [] | [] | [
"mysql",
"pylons",
"python"
] | stackoverflow_0000008154_mysql_pylons_python.txt |
Q:
Django: Print url of view without hardcoding the url
Can i print out a url /admin/manage/products/add of a certain view in a template?
Here is the rule i want to create a link for
(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
I would like to have /manage/products/add in... | Django: Print url of view without hardcoding the url | Can i print out a url /admin/manage/products/add of a certain view in a template?
Here is the rule i want to create a link for
(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}),
I would like to have /manage/products/add in a template without hardcoding it. How can i do this?
Edit... | [
"You can use get_absolute_url, but that will only work for a particular object. Since your object hasn't been created yet, it won't work in this case.\nYou want to use named URL patterns. Here's a quick intro:\nChange the line in your urls.py to:\n(r'^manage/products/add/$', create_object, {'model': Product, 'pos... | [
17,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000047207_django_python.txt |
Q:
Python: No module named core.exceptions
I'm trying to get Google AppEngine to work on my Debian box and am getting the following error when I try to access my page:
<type 'exceptions.ImportError'>: No module named core.exceptions
The same app works fine for me when I run it on my other Ubuntu box, so I know it's... | Python: No module named core.exceptions | I'm trying to get Google AppEngine to work on my Debian box and am getting the following error when I try to access my page:
<type 'exceptions.ImportError'>: No module named core.exceptions
The same app works fine for me when I run it on my other Ubuntu box, so I know it's not a problem with the app itself. However, ... | [
"core.exceptions is part of django; what version of django do you have installed? The AppEngine comes with the appropriate version for whatever release you've downloaded (in the lib/django directory). It can be installed by going to that directory and running python setup.py install\n"
] | [
6
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0000048777_google_app_engine_python.txt |
Q:
Python descriptor protocol analog in other languages?
Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other lan... | Python descriptor protocol analog in other languages? | Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other languages. Is it likely absent from other languages because of... | [
"I've not heard of a direct equivalent either. You could probably achieve the same effect with macros, especially in a language like Lisp which has extremely powerful macros.\nI wouldn't be at all surprised if other languages start to incorporate something similar because it is so powerful.\n",
"Ruby and C# both ... | [
4,
0
] | [] | [] | [
"encapsulation",
"language_features",
"python"
] | stackoverflow_0000034243_encapsulation_language_features_python.txt |
Q:
How do I implement a pre-commit hook script in SVN that calls dos2unix to validate checked-in file
I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.
I would like to modify this script to validate that the check-in file does not have a Carriage R... | How do I implement a pre-commit hook script in SVN that calls dos2unix to validate checked-in file | I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.
I would like to modify this script to validate that the check-in file does not have a Carriage Return in the EOL formatting. The EOL format is CR LF in Windows and LF in Unix. When a User checks-in co... | [
"I think you can avoid a commit hook script in this case by using the svn:eol-style property as described in the SVNBook:\n\nEnd-of-Line Character Sequences\nSubversion Properties\n\nThis way SVN can worry about your line endings for you.\nGood luck!\n",
"What exactly are you trying to do?\nOf course, there are n... | [
4,
1
] | [] | [] | [
"dos2unix",
"python",
"svn"
] | stackoverflow_0000048562_dos2unix_python_svn.txt |
Q:
What language should I learn as a bridge to C (and derivatives)
The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn t... | What language should I learn as a bridge to C (and derivatives) | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C
| [
"It's not clear why you need a bridge language. Why don't you start working with C directly? C is a very simple language itself. I think that hardest part for C learner is pointers and everything else related to memory management. Also C lang is oriented on structured programming, so you will need to learn how to i... | [
15,
7,
5,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0
] | [] | [] | [
"c",
"python"
] | stackoverflow_0000049195_c_python.txt |
Q:
How do you create a weak reference to an object in Python?
How do you create a weak reference to an object in Python?
A:
>>> import weakref
>>> class Object:
... pass
...
>>> o = Object()
>>> r = weakref.ref(o)
>>> # if the reference is still active, r() will be o, otherwise None
>>> do_something_with_o(r(... | How do you create a weak reference to an object in Python? | How do you create a weak reference to an object in Python?
| [
">>> import weakref\n>>> class Object:\n... pass\n...\n>>> o = Object()\n>>> r = weakref.ref(o)\n>>> # if the reference is still active, r() will be o, otherwise None\n>>> do_something_with_o(r()) \n\nSee the wearkref module docs for more details.\nYou can also use weakref.proxy to create an object that proxies... | [
13
] | [] | [] | [
"python",
"weak_references"
] | stackoverflow_0000050923_python_weak_references.txt |
Q:
Best way to extract data from a FileMaker Pro database in a script?
My job would be easier, or at least less tedious if I could come up with an automated way (preferably in a Python script) to extract useful information from a FileMaker Pro database. I am working on Linux machine and the FileMaker database is on t... | Best way to extract data from a FileMaker Pro database in a script? | My job would be easier, or at least less tedious if I could come up with an automated way (preferably in a Python script) to extract useful information from a FileMaker Pro database. I am working on Linux machine and the FileMaker database is on the same LAN running on an OS X machine. I can log into the webby interfac... | [
"It has been a really long time since I did anything with FileMaker Pro, but I know that it does have capabilities for an ODBC (and JDBC) connection to be made to it (however, I don't know how, or if, that translates to the linux/perl/python world though). \nThis article shows how to share/expose your FileMaker da... | [
6,
4,
2
] | [] | [] | [
"filemaker",
"linux",
"perl",
"python",
"scripting"
] | stackoverflow_0000028668_filemaker_linux_perl_python_scripting.txt |
Q:
Java -> Python?
Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa?
A:
List comprehensions. I often find myself filtering/mapping lists, and being able to say [line.replace("spam","eggs") for line in open("some... | Java -> Python? | Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa?
| [
"\nList comprehensions. I often find myself filtering/mapping lists, and being able to say [line.replace(\"spam\",\"eggs\") for line in open(\"somefile.txt\") if line.startswith(\"nee\")] is really nice.\nFunctions are first class objects. They can be passed as parameters to other functions, defined inside other ... | [
47,
16,
5,
3,
2
] | [] | [] | [
"java",
"python"
] | stackoverflow_0000049824_java_python.txt |
Q:
Large Python Includes
I have a file that I want to include in Python but the included file is fairly long and it'd be much neater to be able to split them into several files but then I have to use several include statements.
Is there some way to group together several files and include them all at once?
A:
Put f... | Large Python Includes | I have a file that I want to include in Python but the included file is fairly long and it'd be much neater to be able to split them into several files but then I have to use several include statements.
Is there some way to group together several files and include them all at once?
| [
"\nPut files in one folder. \nAdd __init__.py file to the folder. Do necessary imports in __init__.py\nReplace multiple imports by one:\nimport folder_name \n\nSee Python Package Management\n",
"Yes, take a look at the \"6.4 Packages\" section in http://docs.python.org/tut/node8.html:\nBasically, you can place a... | [
8,
6
] | [] | [] | [
"python"
] | stackoverflow_0000053027_python.txt |
Q:
Getting international characters from a web page?
I want to scrape some information off a football (soccer) web page using simple python regexp's. The problem is that players such as the first chap, ÄÄRITALO, comes out as ÄÄRITALO!
That is, html uses escaped markup for the special characters, such as &#... | Getting international characters from a web page? | I want to scrape some information off a football (soccer) web page using simple python regexp's. The problem is that players such as the first chap, ÄÄRITALO, comes out as ÄÄRITALO!
That is, html uses escaped markup for the special characters, such as Ä
Is there a simple way of reading the html into the... | [
"I would recommend BeautifulSoup for HTML scraping. You also need to tell it to convert HTML entities to the corresponding Unicode characters, like so:\n>>> from BeautifulSoup import BeautifulSoup \n>>> html = \"<html>ÄÄRITALO!</html>\"\n>>> soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML... | [
7,
2,
0
] | [] | [] | [
"html",
"parsing",
"python",
"unicode"
] | stackoverflow_0000053224_html_parsing_python_unicode.txt |
Q:
Why are SQL aggregate functions so much slower than Python and Java (or Poor Man's OLAP)
I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this query on my Macbook Pro while Java and Python perform the same calculation in under 20 ms (350,000 rows):
SELECT count(id), avg(a), avg(b), avg(c), avg(d) ... | Why are SQL aggregate functions so much slower than Python and Java (or Poor Man's OLAP) | I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this query on my Macbook Pro while Java and Python perform the same calculation in under 20 ms (350,000 rows):
SELECT count(id), avg(a), avg(b), avg(c), avg(d) FROM tuples;
Is this normal behaviour when using a SQL database?
The schema (the table holds ... | [
"I would say your test scheme is not really useful. To fulfill the db query, the db server goes through several steps:\n\nparse the SQL\nwork up a query plan, i. e. decide on which indices to use (if any), optimize etc.\nif an index is used, search it for the pointers to the actual data, then go to the appropriate ... | [
15,
12,
6,
3,
3,
1,
1,
1,
0,
0
] | [] | [] | [
"aggregate",
"olap",
"optimization",
"python",
"sql"
] | stackoverflow_0000051553_aggregate_olap_optimization_python_sql.txt |
Q:
Does re.compile() or any given Python library call throw an exception?
I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, w... | Does re.compile() or any given Python library call throw an exception? | I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s) a... | [
"Well, re.compile certainly may:\n>>> import re\n>>> re.compile('he(lo')\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"C:\\Python25\\lib\\re.py\", line 180, in compile\n return _compile(pattern, flags)\n File \"C:\\Python25\\lib\\re.py\", line 233, in _compile\n raise... | [
13,
7
] | [] | [] | [
"exception",
"python",
"regex"
] | stackoverflow_0000058119_exception_python_regex.txt |
Q:
Can distutils create empty __init__.py files?
If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
A:
In Python, __init__.py files actually have a meaning! They mean that the folder they are... | Can distutils create empty __init__.py files? | If all of my __init__.py files are empty, do I have to store them into version control, or is there a way to make distutils create empty __init__.py files during installation?
| [
"In Python, __init__.py files actually have a meaning! They mean that the folder they are in is a Python module. As such, they have a real role in your code and should most probably be stored in Version Control.\nYou could well imagine a folder in your source tree that is NOT a Python module, for example a folder c... | [
7,
4
] | [] | [] | [
"distutils",
"python",
"version_control"
] | stackoverflow_0000060352_distutils_python_version_control.txt |
Q:
python regex to match multi-line preprocessor macro
What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.
Here's the regex:
\s*#define(.*\\\n)+[\S]+(?!\\)
It... | python regex to match multi-line preprocessor macro | What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.
Here's the regex:
\s*#define(.*\\\n)+[\S]+(?!\\)
It should match all of this:
#define foo(x) if(x) \
doSomet... | [
"This is a simple test program I knocked up:\n#!/usr/bin/env python\n\nTEST1=\"\"\"\n#include \"Foo.h\"\n#define bar foo\\\\\n x\n#include \"Bar.h\"\n\"\"\"\n\nTEST2=\"\"\"\n#define bar foo\n#define x 1 \\\\\n 12 \\\\\n 2 \\\\\\\\ 3\nFoobar\n\"\"\"\n\nTEST3=\"\"\"\n#define foo(x) if(x) \\\\\ndoSomething(x)... | [
6,
4
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000060685_python_regex.txt |
Q:
How do I write a python HTTP server to listen on multiple ports?
I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?
What I'm doing now:
class MyRequestHandler(BaseHTTPServer.BaseHTT... | How do I write a python HTTP server to listen on multiple ports? | I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?
What I'm doing now:
class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def doGET
[...]
class ThreadingHTTPServer(Threa... | [
"Sure; just start two different servers on two different ports in two different threads that each use the same handler. Here's a complete, working example that I just wrote and tested. If you run this code then you'll be able to get a Hello World webpage at both http://localhost:1111/ and http://localhost:2222/\n... | [
40,
6,
6
] | [] | [] | [
"python",
"webserver"
] | stackoverflow_0000060680_python_webserver.txt |
Q:
Comparing runtimes
I am trying to get some accurate runtime comparisons of PHP vs Python (and potentially any other language that I have to include). Timing within a script is not my problem but timing within a script does not account for everything from the moment the request is made to run the script to output.
... | Comparing runtimes | I am trying to get some accurate runtime comparisons of PHP vs Python (and potentially any other language that I have to include). Timing within a script is not my problem but timing within a script does not account for everything from the moment the request is made to run the script to output.
1) Is it actually worth... | [
"If your idea is to compare the languages, I'd say anything outside them is not relevant for comparison purposes. \nNonetheless you can use the time command to measure everything and can compare it with the timing within a script.\nLike this:\n$ time script.php\nHI!\n\nreal 0m3.218s\nuser 0m0.080s\nsys 0m... | [
4,
1,
1
] | [] | [] | [
"benchmarking",
"php",
"python"
] | stackoverflow_0000062079_benchmarking_php_python.txt |
Q:
Passing on named variable arguments in python
Say I have the following methods:
def methodA(arg, **kwargs):
pass
def methodB(arg, *args, **kwargs):
pass
In methodA I wish to call methodB, passing on the kwargs. However, it seems that if I define methodA as follows, the second argument will be passed on a... | Passing on named variable arguments in python | Say I have the following methods:
def methodA(arg, **kwargs):
pass
def methodB(arg, *args, **kwargs):
pass
In methodA I wish to call methodB, passing on the kwargs. However, it seems that if I define methodA as follows, the second argument will be passed on as positional rather than named variable arguments.
... | [
"Put the asterisks before the kwargs variable. This makes Python pass the variable (which is assumed to be a dictionary) as keyword arguments.\nmethodB(\"argvalue\", **kwargs)\n\n",
"As an aside: When using functions instead of methods, you could also use functools.partial:\nimport functools\n\ndef foo(arg, **kwa... | [
34,
2,
1
] | [] | [] | [
"python",
"variadic_functions"
] | stackoverflow_0000051412_python_variadic_functions.txt |
Q:
How to add method using metaclass
How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":
def bar(self):
print "bar"
class MetaFoo(type):
def __new__(cls, name, bases, dict):
dict["foobar"]... | How to add method using metaclass | How do I add an instance method to a class using a metaclass (yes I do need to use a metaclass)? The following kind of works, but the func_name will still be "foo":
def bar(self):
print "bar"
class MetaFoo(type):
def __new__(cls, name, bases, dict):
dict["foobar"] = bar
return type(name, bases,... | [
"Try dynamically extending the bases that way you can take advantage of the mro and the methods are actual methods:\nclass Parent(object):\n def bar(self):\n print \"bar\"\n\nclass MetaFoo(type):\n def __new__(cls, name, bases, dict):\n return type(name, (Parent,) + bases, dict)\n\nclass Foo(obj... | [
15,
2
] | [] | [] | [
"metaclass",
"python"
] | stackoverflow_0000065400_metaclass_python.txt |
Q:
How create threads under Python for Delphi
I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.
Is it possible to create threads which keep running even if the script execution ends (but not the host process, wh... | How create threads under Python for Delphi | I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.
Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed that the progr... | [
"Python has its own threading module that comes standard, if it helps. You can create thread objects using the threading module.\nthreading Documentation\nthread Documentation\nThe thread module offers low level threading and synchronization using simple Lock objects.\nAgain, not sure if this helps since you're usi... | [
2,
0,
0
] | [] | [] | [
"delphi",
"python"
] | stackoverflow_0000063681_delphi_python.txt |
Q:
python cgi on IIS
How do you set up IIS so that you can call python scripts from asp pages?
Ok, so I found the answer to that question here: http://support.microsoft.com/kb/276494
So on to my next question: How do you call a cgi script from within classic asp (vb) code? Particularly one which is not in the web roo... | python cgi on IIS | How do you set up IIS so that you can call python scripts from asp pages?
Ok, so I found the answer to that question here: http://support.microsoft.com/kb/276494
So on to my next question: How do you call a cgi script from within classic asp (vb) code? Particularly one which is not in the web root directory.
| [
"You could also do it this way.\n",
"I don't believe that VBScript as hosted by IIS has any way of executing an external process. If you are using python as an AXscripting engine then you could just use the sys module. If the script you're calling is actually meant to be a cgi script you'll have to mimic all th... | [
2,
1
] | [] | [] | [
"asp_classic",
"cgi",
"iis",
"python",
"vbscript"
] | stackoverflow_0000061781_asp_classic_cgi_iis_python_vbscript.txt |
Q:
Nice Python wrapper for Yahoo's Geoplanet web service?
Has anybody created a nice wrapper around Yahoo's geo webservice "GeoPlanet" yet?
A:
After a brief amount of Googling, I found nothing that looks like a wrapper for this API, but I'm not quite sure if a wrapper is what is necessary for GeoPlanet.
According... | Nice Python wrapper for Yahoo's Geoplanet web service? | Has anybody created a nice wrapper around Yahoo's geo webservice "GeoPlanet" yet?
| [
"After a brief amount of Googling, I found nothing that looks like a wrapper for this API, but I'm not quite sure if a wrapper is what is necessary for GeoPlanet. \nAccording to Yahoo's documentation for GeoPlanet, requests are made in the form of an HTTP GET messages which can very easily be made using Python's h... | [
2
] | [] | [] | [
"gis",
"python",
"yahoo"
] | stackoverflow_0000064185_gis_python_yahoo.txt |
Q:
Decorating a parent class method
I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but not in the parent class.
Essentially, I am trying to accomplish the following:
class foo(Object):
def meth1(self, val):
self.value = val
... | Decorating a parent class method | I would like to make a child class that has a method of the parent class where the method is a 'classmethod' in the child class but not in the parent class.
Essentially, I am trying to accomplish the following:
class foo(Object):
def meth1(self, val):
self.value = val
class bar(foo):
meth1 = classmetho... | [
"I'm also not entirely sure what the exact behaviour you want is, but assuming its that you want bar.meth1(42) to be equivalent to foo.meth1 being a classmethod of bar (with \"self\" being the class), then you can acheive this with:\ndef convert_to_classmethod(method):\n return classmethod(method.im_func)\n\ncla... | [
4,
3,
0
] | [] | [] | [
"inheritance",
"oop",
"python"
] | stackoverflow_0000066636_inheritance_oop_python.txt |
Q:
Change command Method for Tkinter Button in Python
I create a new Button object but did not specify the command option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created?
A:
Though Eli Courtwright's program will work fine¹, what you really seem to ... | Change command Method for Tkinter Button in Python | I create a new Button object but did not specify the command option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created?
| [
"Though Eli Courtwright's program will work fine¹, what you really seem to want though is just a way to reconfigure after instantiation any attribute which you could have set when you instantiated². How you do so is by way of the configure() method.\nfrom Tkinter import Tk, Button\n\ndef goodbye_world():\n prin... | [
37,
2
] | [] | [] | [
"python",
"tkinter",
"user_interface"
] | stackoverflow_0000068327_python_tkinter_user_interface.txt |
Q:
Best way to open a socket in Python
I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?
A:
Opening sockets in python is pretty simple. You really just need something like this:
import socket
so... | Best way to open a socket in Python | I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?
| [
"Opening sockets in python is pretty simple. You really just need something like this:\nimport socket\nsock = socket.socket()\nsock.connect((address, port))\n\nand then you can send() and recv() like any other socket\n",
"OK, this code worked\ns = socket.socket()\ns.connect((ip,port))\ns.send(\"my request\\r\")\n... | [
81,
21,
10
] | [] | [] | [
"networking",
"python",
"tcp"
] | stackoverflow_0000068774_networking_python_tcp.txt |
Q:
mod_python/MySQL error on INSERT with a lot of data: "OperationalError: (2006, 'MySQL server has gone away')"
When doing an INSERT with a lot of data, ie:
INSERT INTO table (mediumtext_field) VALUES ('...lots of text here: about 2MB worth...')
MySQL returns
"OperationalError: (2006, 'MySQL server has gone away'... | mod_python/MySQL error on INSERT with a lot of data: "OperationalError: (2006, 'MySQL server has gone away')" | When doing an INSERT with a lot of data, ie:
INSERT INTO table (mediumtext_field) VALUES ('...lots of text here: about 2MB worth...')
MySQL returns
"OperationalError: (2006, 'MySQL server has gone away')"
This is happening within a minute of starting the script, so it is not a timeout issue. Also, mediumtext_field ... | [
"check the max_packet setting in your my.cnf file. this determines the largest amount of data you can send to your mysql server in a single statement. exceeding this values results in that error.\n"
] | [
1
] | [] | [] | [
"mysql",
"mysql_error_2006",
"python",
"xampp"
] | stackoverflow_0000067180_mysql_mysql_error_2006_python_xampp.txt |
Q:
Using the docstring from one method to automatically overwrite that of another method
The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be docume... | Using the docstring from one method to automatically overwrite that of another method | The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute.
Advanced users can create their own subclasses to exten... | [
"Well, if you don't mind copying the original method in the subclass, you can use the following technique.\nimport new\n\ndef copyfunc(func):\n return new.function(func.func_code, func.func_globals, func.func_name,\n func.func_defaults, func.func_closure)\n\nclass Metaclass(type):\n def... | [
4,
2,
1,
0,
0
] | [] | [] | [
"metaclass",
"python"
] | stackoverflow_0000071817_metaclass_python.txt |
Q:
Is there a common way to check in Python if an object is any function type?
I have a function in Python which is iterating over the attributes returned from dir(obj), and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use callable() ... | Is there a common way to check in Python if an object is any function type? | I have a function in Python which is iterating over the attributes returned from dir(obj), and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use callable() for this, but I don't want to include classes. The best I've come up with so far... | [
"The inspect module has exactly what you want:\ninspect.isroutine( obj )\n\nFYI, the code is:\ndef isroutine(object):\n \"\"\"Return true if the object is any kind of function or method.\"\"\"\n return (isbuiltin(object)\n or isfunction(object)\n or ismethod(object)\n or ismet... | [
17,
5,
3,
1
] | [] | [] | [
"python",
"types"
] | stackoverflow_0000074092_python_types.txt |
Q:
libxml2-p25 on OS X 10.5 needs sudo?
When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.
I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any i... | libxml2-p25 on OS X 10.5 needs sudo? | When trying to use libxml2 as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.
I have installed python25 and all libxml2 and libxml2-py25 related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo?
| [
"Check your path by running:\n'echo $PATH'\n\n",
"I would suspect the permissions on the library. Can you do a strace or similar to find out the filenames it's looking for, and then check the permissions on them?\n",
"The PATH environment variable was the mistake.\n"
] | [
3,
0,
0
] | [] | [] | [
"libxml2",
"macos",
"python"
] | stackoverflow_0000068541_libxml2_macos_python.txt |
Q:
Python and "re"
A tutorial I have on Regex in python explains how to use the re module in python, I wanted to grab the URL out of an A tag so knowing Regex I wrote the correct expression and tested it in my regex testing app of choice and ensured it worked. When placed into python it failed:
result = re.match("a_r... | Python and "re" | A tutorial I have on Regex in python explains how to use the re module in python, I wanted to grab the URL out of an A tag so knowing Regex I wrote the correct expression and tested it in my regex testing app of choice and ensured it worked. When placed into python it failed:
result = re.match("a_regex_of_pure_awesomen... | [
"In Python, there's a distinction between \"match\" and \"search\"; match only looks for the pattern at the start of the string, and search looks for the pattern starting at any location within the string.\nPython regex docs\nMatching vs searching\n",
"from BeautifulSoup import BeautifulSoup \n\nsoup = BeautifulS... | [
20,
4,
3,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0000072393_python_regex.txt |
Q:
iBATIS for Python?
At my current gig, we use iBATIS through Java to CRUD our databases. I like the abstract qualities of the tool, especially when working with legacy databases, as it doesn't impose its own syntax on you.
I'm looking for a Python analogue to this library, since the website only has Java/.NET/Ruby... | iBATIS for Python? | At my current gig, we use iBATIS through Java to CRUD our databases. I like the abstract qualities of the tool, especially when working with legacy databases, as it doesn't impose its own syntax on you.
I'm looking for a Python analogue to this library, since the website only has Java/.NET/Ruby versions available. I ... | [
"iBatis sequesters the SQL DML (or the definitions of the SQL) in an XML file. It specifically focuses on the mapping between the SQL and some object model defined elsewhere.\nSQL Alchemy can do this -- but it isn't really a very complete solution. Like iBatis, you can merely have SQL table definitions and a mapp... | [
10,
1
] | [] | [] | [
"ibatis",
"orm",
"python"
] | stackoverflow_0000077731_ibatis_orm_python.txt |
Q:
Random in python 2.5 not working?
I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use.
Am I missing something?
A:
You probably have a file named random.py or random.pyc in your working directory. That's shadowing the built-in random module. You need ... | Random in python 2.5 not working? | I am trying to use the import random statement in python, but it doesn't appear to have any methods in it to use.
Am I missing something?
| [
"You probably have a file named random.py or random.pyc in your working directory. That's shadowing the built-in random module. You need to rename random.py to something like my_random.py and/or remove the random.pyc file.\nTo tell for sure what's going on, do this:\n>>> import random\n>>> print random.__file__\n... | [
36,
3,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0000074430_python.txt |
Q:
Redirect command to input of another in Python
I would like to replicate this in python:
gvimdiff <(hg cat file.txt) file.txt
(hg cat file.txt outputs the most recently committed version of file.txt)
I know how to pipe the file to gvimdiff, but it won't accept another file:
$ hg cat file.txt | gvimdiff file.txt -... | Redirect command to input of another in Python | I would like to replicate this in python:
gvimdiff <(hg cat file.txt) file.txt
(hg cat file.txt outputs the most recently committed version of file.txt)
I know how to pipe the file to gvimdiff, but it won't accept another file:
$ hg cat file.txt | gvimdiff file.txt -
Too many edit arguments: "-"
Getting to the python... | [
"It can be done. As of Python 2.5, however, this mechanism is Linux-specific and not portable:\nimport subprocess\nimport sys\n\nfile = sys.argv[1]\np1 = subprocess.Popen(['hg', 'cat', file], stdout=subprocess.PIPE)\np2 = subprocess.Popen([\n 'gvimdiff',\n '/proc/self/fd/%s' % p1.stdout.fileno(),\n file])\... | [
10,
2,
2
] | [
"It just dawned on me that you are probably looking for one of the popen functions.\nfrom: http://docs.python.org/lib/module-popen2.html\npopen3(cmd[, bufsize[, mode]])\n Executes cmd as a sub-process. Returns the file objects (child_stdout, child_stdin, child_stderr). \nnamaste,\nMark\n"
] | [
-1
] | [
"bash",
"diff",
"python",
"redirect",
"vimdiff"
] | stackoverflow_0000078431_bash_diff_python_redirect_vimdiff.txt |
Q:
How to check for memory leaks in Guile extension modules?
I develop an extension module for Guile, written in C. This extension module embeds a Python interpreter.
Since this extension module invokes the Python interpreter, I need to verify that it properly manages the memory occupied by Python objects.
I found... | How to check for memory leaks in Guile extension modules? | I develop an extension module for Guile, written in C. This extension module embeds a Python interpreter.
Since this extension module invokes the Python interpreter, I need to verify that it properly manages the memory occupied by Python objects.
I found that the Python interpreter is well-behaved in its own memory ... | [
"You've got a couple options. One is to write a supressions file for valgrind that turns off reporting of stuff that you're not working on. Python has such a file, for example: \nhttp://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp\nIf valgrind doesn't like your setup, another possibility is using ... | [
7
] | [] | [] | [
"guile",
"memory_leaks",
"python",
"valgrind"
] | stackoverflow_0000078900_guile_memory_leaks_python_valgrind.txt |
Q:
How do I get started processing email related to website activity?
I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server t... | How do I get started processing email related to website activity? | I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for automa... | [
"There are some pretty serious concerns here for how to send email automatically, and here are a few:\nUse an email library. Python includes one called 'email'. This is your friend, it will stop you from doing anything tragically wrong. Read an example from the Python Manual.\nSome points that will stop you from ge... | [
4,
2
] | [] | [] | [
"email",
"python"
] | stackoverflow_0000079602_email_python.txt |
Q:
How to skip sys.exitfunc when unhandled exceptions occur
As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?
import atexit
def helloworld():
print("Hello World!")
atexit.register(helloworld)
raise Exception(... | How to skip sys.exitfunc when unhandled exceptions occur | As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?
import atexit
def helloworld():
print("Hello World!")
atexit.register(helloworld)
raise Exception("Good bye cruel world!")
outputs
Traceback (most recent call ... | [
"I don't really know why you want to do that, but you can install an excepthook that will be called by Python whenever an uncatched exception is raised, and in it clear the array of registered function in the atexit module.\nSomething like that :\nimport sys\nimport atexit\n\ndef clear_atexit_excepthook(exctype, va... | [
7,
0
] | [
"If you call\nimport os\nos._exit(0)\n\nthe exit handlers will not be called, yours or those registered by other modules in the application.\n"
] | [
-1
] | [
"atexit",
"exception",
"python"
] | stackoverflow_0000080993_atexit_exception_python.txt |
Q:
How to use form values from an unbound form
I have a web report that uses a Django form (new forms) for fields that control the query used to generate the report (start date, end date, ...). The issue I'm having is that the page should work using the form's initial values (unbound), but I can't access the cleaned_... | How to use form values from an unbound form | I have a web report that uses a Django form (new forms) for fields that control the query used to generate the report (start date, end date, ...). The issue I'm having is that the page should work using the form's initial values (unbound), but I can't access the cleaned_data field unless I call is_valid(). But is_valid... | [
"If you add this method to your form class:\ndef get_cleaned_or_initial(self, fieldname):\n if hasattr(self, 'cleaned_data'):\n return self.cleaned_data.get(fieldname)\n else:\n return self[fieldname].field.initial\n\nyou could then re-write your code as:\nif request.method == 'G... | [
7,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0000075621_django_python.txt |
Q:
Asynchronous Programming in Python Twisted
I'm having trouble developing a reverse proxy in Twisted. It works, but it seems overly complex and convoluted. So much of it feels like voodoo.
Are there any simple, solid examples of asynchronous program structure on the web or in books? A sort of best practices guide? ... | Asynchronous Programming in Python Twisted | I'm having trouble developing a reverse proxy in Twisted. It works, but it seems overly complex and convoluted. So much of it feels like voodoo.
Are there any simple, solid examples of asynchronous program structure on the web or in books? A sort of best practices guide? When I complete my program I'd like to be able t... | [
"Twisted contains a large number of examples. One in particular, the \"evolution of Finger\" tutorial, contains a thorough explanation of how an asynchronous program grows from a very small kernel up to a complex system with lots of moving parts. Another one that might be of interest to you is the tutorial about ... | [
65
] | [] | [] | [
"asynchronous",
"python",
"twisted"
] | stackoverflow_0000080617_asynchronous_python_twisted.txt |
Q:
What IDE to use for Python?
What IDEs ("GUIs/editors") do others use for Python coding?
A:
Results
Spreadsheet version
Alternatively, in plain text: (also available as a a screenshot)
Bracket Matching -. .- Line Numbering
Smart Indent -. | | .- UML Editing ... | What IDE to use for Python? | What IDEs ("GUIs/editors") do others use for Python coding?
| [
"\nResults\nSpreadsheet version\n\nAlternatively, in plain text: (also available as a a screenshot)\n Bracket Matching -. .- Line Numbering\n Smart Indent -. | | .- UML Editing / Viewing\n Source Control Integration -. | | | | .- Code Folding\n ... | [
1293
] | [] | [] | [
"editor",
"ide",
"python"
] | stackoverflow_0000081584_editor_ide_python.txt |
Q:
Testing GUI code: should I use a mocking library?
Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests f... | Testing GUI code: should I use a mocking library? | Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to mak... | [
"If you are writing your tests after you've written your code and making them pass, you are not doing TDD (nor are you getting any benefits of Test-First or Test-Driven development.. check out SO questions for definitive books on TDD)\n\nOne of the things I've noticed with\n using mocker is that it's easier to\n ... | [
8
] | [
"Unit tests are really useful when you refactor your code (ie. completely rewrite or move a module). As long as you have unit tests before you do the big changes, you'll have confidence that you havent forgotten to move or include something when you finish.\n",
"Please remember that TDD is not a panaceum. It's ha... | [
-2,
-3
] | [
"python",
"tdd",
"unit_testing",
"user_interface"
] | stackoverflow_0000079454_python_tdd_unit_testing_user_interface.txt |
Q:
HTML parser in Python
Using the Python Documentation I found the HTML parser but I have no idea which library to import to use it, how do I find this out (bearing in mind it doesn't say on the page).
A:
You probably really want BeautifulSoup, check the link for an example.
But in any case
>>> import HTMLParser
... | HTML parser in Python | Using the Python Documentation I found the HTML parser but I have no idea which library to import to use it, how do I find this out (bearing in mind it doesn't say on the page).
| [
"You probably really want BeautifulSoup, check the link for an example. \nBut in any case\n>>> import HTMLParser\n>>> h = HTMLParser.HTMLParser()\n>>> h.feed('<html></html>')\n>>> h.get_starttag_text()\n'<html>'\n>>> h.close()\n\n",
"Try:\nimport HTMLParser\n\nIn Python 3.0, the HTMLParser module has been renamed... | [
24,
20,
4,
4,
4,
3,
1,
1
] | [] | [] | [
"import",
"python"
] | stackoverflow_0000071151_import_python.txt |
Q:
Best server-side framework for heavy RIA based application?
What do the collective beleive to be the best platform to use as a backend to AJAX / Flex / Silverlight applications and why?
We are undergoing a technology review and I would like to know some other opinions.
Is It Java, Grails, Python, Rails, ColdFusion... | Best server-side framework for heavy RIA based application? | What do the collective beleive to be the best platform to use as a backend to AJAX / Flex / Silverlight applications and why?
We are undergoing a technology review and I would like to know some other opinions.
Is It Java, Grails, Python, Rails, ColdFusion, something else?
| [
"There is no definitive answer. However, I would choose a light solution, like Python or Rails, over Java or ColdFusion.\nYou may want to investigate C# ASP.NET + Silverlight combo. Microsoft made it highly integrated, which is double-edged sword. But in many cases this helps.\nYou may also want to review existing ... | [
2
] | [] | [] | [
"java",
"python",
"ria"
] | stackoverflow_0000082599_java_python_ria.txt |
Q:
Classes in Python
In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class?
So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the... | Classes in Python | In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class?
So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for section... | [
"A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with different numbers, like so.\nclass dog(object):\n def __init__(self, height, width, lenght):\n self.height = height\n self.width = width\n self.length = length\n\n def re... | [
5,
2,
1,
1,
1,
1
] | [] | [] | [
"class",
"python"
] | stackoverflow_0000064141_class_python.txt |
Q:
PythonWin's python interactive shell calling constructors twice?
While answering Static class variables in Python
I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?
PythonWin 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Ma... | PythonWin's python interactive shell calling constructors twice? | While answering Static class variables in Python
I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?
PythonWin 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright informat... | [
"My guess is as follows. The PythonWin editor offers autocomplete for an object, i.e. when you type myobject. it offers a little popup of all the availble method names. So I think when you type X(). it's creating an instance of X in the background and doing a dir or similar to find out the attributes of the objec... | [
3,
2,
1
] | [] | [] | [
"activestate",
"python",
"python_2.x"
] | stackoverflow_0000081191_activestate_python_python_2.x.txt |
Q:
Why isn't the 'len' function inherited by dictionaries and lists in Python
example:
a_list = [1, 2, 3]
a_list.len() # doesn't work
len(a_list) # works
Python being (very) object oriented, I don't understand why the 'len' function isn't inherited by the object.
Plus I keep trying the wrong solution since it appea... | Why isn't the 'len' function inherited by dictionaries and lists in Python | example:
a_list = [1, 2, 3]
a_list.len() # doesn't work
len(a_list) # works
Python being (very) object oriented, I don't understand why the 'len' function isn't inherited by the object.
Plus I keep trying the wrong solution since it appears as the logical one to me
| [
"Guido's explanation is here:\n\nFirst of all, I chose len(x) over x.len() for HCI reasons (def __len__() came much later). There are two intertwined reasons actually, both HCI:\n(a) For some operations, prefix notation just reads better than postfix — prefix (and infix!) operations have a long tradition in mathema... | [
45,
13,
11,
6,
2,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0000083983_python.txt |
Q:
How can I access App Engine through a Corporate proxy?
I have corporate proxy that supports https but not HTTP CONNECT (even after authentication). It just gives 403 Forbidden in response anything but HTTP or HTTPS URLS. It uses HTTP authenication, not NTLM. It is well documented the urllib2 does not work with htt... | How can I access App Engine through a Corporate proxy? | I have corporate proxy that supports https but not HTTP CONNECT (even after authentication). It just gives 403 Forbidden in response anything but HTTP or HTTPS URLS. It uses HTTP authenication, not NTLM. It is well documented the urllib2 does not work with https thru a proxy. App Engine trys to connect to a https URL u... | [
"Do you mean it uses http basic-auth before allowing proxying, and does it then allow 'connect'.\nThen you should be able to tunnel over it using http-tunnel or proxytunnel\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0000064362_google_app_engine_python.txt |
Q:
How can I get Emacs' key bindings in Python's IDLE?
I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?
A:
IDLE provides Emacs keybindings without having to install other software.
Open up the menu item Options -> Configure ... | How can I get Emacs' key bindings in Python's IDLE? | I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?
| [
"IDLE provides Emacs keybindings without having to install other software. \n\nOpen up the menu item Options -> Configure IDLE...\nGo to Keys tab\nIn the drop down menu on the right\nside of the dialog change the select\nto \"IDLE Classic Unix\"\n\nIt's not the true emacs key bindings but you get the basics like mo... | [
6,
2,
0
] | [] | [] | [
"emacs",
"ide",
"keyboard",
"python"
] | stackoverflow_0000055365_emacs_ide_keyboard_python.txt |
Q:
How to best implement simple crash / error reporting?
What would be the best way to implement a simple crash / error reporting mechanism?
Details: my app is cross-platform (mac/windows/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a trac... | How to best implement simple crash / error reporting? | What would be the best way to implement a simple crash / error reporting mechanism?
Details: my app is cross-platform (mac/windows/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a traceback (which I already generate and show in my error dialog... | [
"The web service is the best way, but there are some caveats:\n\nYou should always ask the user if it is ok to send error feedback information.\nYou should be prepared to fail gracefully if there are network errors. Don't let a failure to report a crash impede recovery!\nYou should avoid including user identifying ... | [
6,
3,
1,
1,
0,
0
] | [] | [] | [
"cross_platform",
"error_reporting",
"python"
] | stackoverflow_0000085985_cross_platform_error_reporting_python.txt |
Q:
Search for host with MAC-address using Python
I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?
A:
You need ARP. Python's standard library... | Search for host with MAC-address using Python | I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?
| [
"You need ARP. Python's standard library doesn't include any code for that, so you either need to call an external program (your OS may have an 'arp' utility) or you need to build the packets yourself (possibly with a tool like Scapy.\n",
"I don't think there is a built in way to get it from Python itself. \nMy ... | [
13,
1,
1,
1,
0,
0,
0
] | [
"as python was not meant to deal with OS-specific issues (it's supposed to be interpreted and cross platform), i would execute an external command to do so:\nin unix the command is ifconfig\nif you execute it as a pipe you get the desired result:\nimport os\nmyPipe = os.popen2(\"/sbin/ifconfig\",\"a\")\nprint(myPip... | [
-1
] | [
"network_programming",
"python"
] | stackoverflow_0000085577_network_programming_python.txt |
Q:
Running multiple sites from a single Python web framework
I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I've also seen some brutish if and elif statements for every site as shown in the following code, which I would like to avoid.
if site == '... | Running multiple sites from a single Python web framework | I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I've also seen some brutish if and elif statements for every site as shown in the following code, which I would like to avoid.
if site == 'site1':
...
elif site == 'site2:
...
What are some goo... | [
"Django has this built in. See the sites framework.\nAs a general technique, include a 'host' column in your database schema attached to the data you want to be host-specific, then include the Host HTTP header in the query when you are retrieving data.\n",
"Using Django on apache with mod_python, I host multiple... | [
11,
7,
3,
3
] | [] | [] | [
"frameworks",
"python"
] | stackoverflow_0000085119_frameworks_python.txt |
Q:
Setting Environment Variables for Mercurial Hook
I am trying to call a shell script that sets a bunch of environment variables on our server from a mercurial hook. The shell script gets called fine when a new changegroup comes in, but the environment variables aren't carrying over past the call to the shell script... | Setting Environment Variables for Mercurial Hook | I am trying to call a shell script that sets a bunch of environment variables on our server from a mercurial hook. The shell script gets called fine when a new changegroup comes in, but the environment variables aren't carrying over past the call to the shell script.
My hgrc file on the respository looks like this:
[ho... | [
"Shell scripts can't modify their enviroment. \nhttp://tldp.org/LDP/abs/html/gotchas.html\n\nA script may not export variables back to its parent process, the shell, or to the environment. Just as we learned in biology, a child process can inherit from a parent, but not vice versa\n\n$ cat > eg.sh \nexport FOO=\"ba... | [
2
] | [] | [] | [
"mercurial",
"mercurial_hook",
"python",
"shell"
] | stackoverflow_0000088194_mercurial_mercurial_hook_python_shell.txt |
Q:
How do I unit test an __init__() method of a python class with assertRaises()?
I have a class:
class MyClass:
def __init__(self, foo):
if foo != 1:
raise Error("foo is not equal to 1!")
and a unit test that is supposed to make sure the incorrect arg passed to the constructor properly raises an error:
... | How do I unit test an __init__() method of a python class with assertRaises()? | I have a class:
class MyClass:
def __init__(self, foo):
if foo != 1:
raise Error("foo is not equal to 1!")
and a unit test that is supposed to make sure the incorrect arg passed to the constructor properly raises an error:
def testInsufficientArgs(self):
foo = 0
self.assertRaises((Error), myClass =... | [
"'Error' in this example could be any exception object. I think perhaps you have read a code example that used it as a metasyntatic placeholder to mean, \"The Appropriate Exception Class\".\nThe baseclass of all exceptions is called 'Exception', and most of its subclasses are descriptive names of the type of error ... | [
33,
7,
1
] | [] | [] | [
"exception",
"python",
"unit_testing"
] | stackoverflow_0000088325_exception_python_unit_testing.txt |
Q:
In Python, how do you take tokenized input such as with the C++?
In C++, I can have take input like this:
cin >> a >> b >> c;
And a can be int, b can be float, and c can be whatever... How do I do the same in python?
input() and raw_input(), the way I'm using them, don't seem to be giving me the desired results.... | In Python, how do you take tokenized input such as with the C++? | In C++, I can have take input like this:
cin >> a >> b >> c;
And a can be int, b can be float, and c can be whatever... How do I do the same in python?
input() and raw_input(), the way I'm using them, don't seem to be giving me the desired results.
| [
"You generally shouldn't use input() in production code. If you want an int and then a float, try this:\n>>> line = raw_input().split()\n>>> a = int(line[0])\n>>> b = float(line[1])\n>>> c = \" \".join(line[2:])\n\nIt all depends on what exactly you're trying to accomplish, but remember that readability counts. Obs... | [
4,
3,
0
] | [] | [] | [
"c++",
"input",
"python"
] | stackoverflow_0000088554_c++_input_python.txt |
Q:
How do i generate a histogram for a given probability distribution (for functional testing a server)?
I am trying to automate functional testing of a server using a realistic frequency distribution of requests. (sort of load testing, sort of simulation)
I've chosen the Weibull distribution as it "sort of" matches ... | How do i generate a histogram for a given probability distribution (for functional testing a server)? | I am trying to automate functional testing of a server using a realistic frequency distribution of requests. (sort of load testing, sort of simulation)
I've chosen the Weibull distribution as it "sort of" matches the distribution I've observed (ramps up quickly, drops off quickly but not instantly)
I use this distribut... | [
"Why don't you try The Grinder 3 to load test your server, it comes with all this and more prebuilt, and it supports python as a scripting language\n",
"Slightly longer but probably more readable rework of your last four lines:\nsamples = [0 for i in xrange(how_many_days + 1)]\nfor s in xrange(how_many_responses)... | [
1,
1,
1,
0,
0,
0
] | [] | [] | [
"python",
"simulation",
"statistics",
"stress_testing"
] | stackoverflow_0000053786_python_simulation_statistics_stress_testing.txt |
Q:
What are the pros and cons of the various Python implementations?
I am relatively new to Python, and I have always used the standard cpython (v2.5) implementation.
I've been wondering about the other implementations though, particularly Jython and IronPython. What makes them better? What makes them worse? Wha... | What are the pros and cons of the various Python implementations? | I am relatively new to Python, and I have always used the standard cpython (v2.5) implementation.
I've been wondering about the other implementations though, particularly Jython and IronPython. What makes them better? What makes them worse? What other implementations are there?
I guess what I'm looking for is a su... | [
"Jython and IronPython are useful if you have an overriding need to interface with existing libraries written in a different platform, like if you have 100,000 lines of Java and you just want to write a 20-line Python script. Not particularly useful for anything else, in my opinion, because they are perpetually a f... | [
15,
6,
3,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0000086134_python.txt |
Q:
I need to write code in python for comparing text of two documents using fingerprint techniques
I need to write code in python language for comparing the text of document using fingerprint techniques. I do not know to take fingerprint of a document or to generate fingerprint of a document. I'm asking if anyone kno... | I need to write code in python for comparing text of two documents using fingerprint techniques | I need to write code in python language for comparing the text of document using fingerprint techniques. I do not know to take fingerprint of a document or to generate fingerprint of a document. I'm asking if anyone knows the method or has source code for generating fingerprints of documents which is stored in bits for... | [
"If you want message digests (cryptographic hashes), use the hashlib library. Here's an example (IPython session):\n\n In [1]: import hashlib\n\n In [2]: md = hashlib.sha256(open('/tmp/Calendar.xls', 'rb').read())\n\n In [3]: md.hexdigest()\n Out[3]: '8517f1eae176f1a20de78d879f81f23de503cfd6b8e4be1d798fb2342934b187... | [
4,
4
] | [] | [] | [
"diff",
"python"
] | stackoverflow_0000091183_diff_python.txt |
Q:
Will everything in the standard library treat strings as unicode in Python 3.0?
I'm a little confused about how the standard library will behave now that Python (from 3.0) is unicode-based. Will modules such as CGI and urllib use unicode strings or will they use the new 'bytes' type and just provide encoded data?
... | Will everything in the standard library treat strings as unicode in Python 3.0? | I'm a little confused about how the standard library will behave now that Python (from 3.0) is unicode-based. Will modules such as CGI and urllib use unicode strings or will they use the new 'bytes' type and just provide encoded data?
| [
"Logically a lot of things like MIME-encoded mail messages, URLs, XML documents, and so on should be returned as bytes not strings. This could cause some consternation as the libraries start to be nailed down for Python 3 and people discover that they have to be more aware of the bytes/string conversions than they ... | [
12,
7,
1
] | [] | [] | [
"cgi",
"python",
"python_3.x",
"string",
"unicode"
] | stackoverflow_0000091205_cgi_python_python_3.x_string_unicode.txt |
Q:
NI CVI with Python
I'd like to integrate a Python IDLE-esque command prompt interface into an existing NI-CVI (LabWindows) application. I've tried to follow the Python.org discussions but seem to get lost in the details. Is there a resource out there for dummies like me?
A:
Here is a python sample code calling... | NI CVI with Python | I'd like to integrate a Python IDLE-esque command prompt interface into an existing NI-CVI (LabWindows) application. I've tried to follow the Python.org discussions but seem to get lost in the details. Is there a resource out there for dummies like me?
| [
"Here is a python sample code calling a CVI.\nThere are DaqMx python bindings too.\n"
] | [
1
] | [] | [] | [
"cvi",
"labview",
"labwindows",
"python"
] | stackoverflow_0000091666_cvi_labview_labwindows_python.txt |
Q:
Django + FCGID on Fedora Core 9 -- what am I missing?
Fedora Core 9 seems to have FCGID instead of FastCGI as a pre-built, YUM-managed module. [I'd rather not have to maintain a module outside of YUM; so no manual builds for me or my sysadmins.]
I'm trying to launch Django through the runfastcgi interface (per th... | Django + FCGID on Fedora Core 9 -- what am I missing? | Fedora Core 9 seems to have FCGID instead of FastCGI as a pre-built, YUM-managed module. [I'd rather not have to maintain a module outside of YUM; so no manual builds for me or my sysadmins.]
I'm trying to launch Django through the runfastcgi interface (per the FastCGI deployment docs).
What I'm seeing is the result... | [
"Why don't you try modwsgi? It sounds as the preffered way these days for WSGI applications such as Django.\nIf you don't wan't to compile stuff for Fedora Core, that might be trickier.\nRegarding to your first question, this seems to solve the fcgid configuration problem. \nNote that you don't want to run the djan... | [
3
] | [] | [] | [
"apache2",
"django",
"fastcgi",
"fcgid",
"python"
] | stackoverflow_0000092373_apache2_django_fastcgi_fcgid_python.txt |
Q:
Is there a pretty printer for python data?
Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.)
The default way to display them is just one massive linear dump which just wraps over and over and you h... | Is there a pretty printer for python data? | Working with python interactively, it's sometimes necessary to display a result which is some arbitrarily complex data structure (like lists with embedded lists, etc.)
The default way to display them is just one massive linear dump which just wraps over and over and you have to parse carefully to read it.
Is there some... | [
"from pprint import pprint\na = [0, 1, ['a', 'b', 'c'], 2, 3, 4]\npprint(a)\n\nNote that for a short list like my example, pprint will in fact print it all on one line. However, for more complex structures it does a pretty good job of pretty printing data.\n",
"Somtimes YAML can be good for this.\nimport yaml\na ... | [
29,
11,
8,
3
] | [] | [] | [
"prettify",
"python"
] | stackoverflow_0000091810_prettify_python.txt |
Q:
How to associated the cn in an ssl cert of pyOpenSSL verify_cb to a generated socket
I am a little new to pyOpenSSL. I am trying to figure out how to associate the generated socket to an ssl cert. verify_cb gets called which give me access to the cert and a conn but how do I associate those things when this happ... | How to associated the cn in an ssl cert of pyOpenSSL verify_cb to a generated socket | I am a little new to pyOpenSSL. I am trying to figure out how to associate the generated socket to an ssl cert. verify_cb gets called which give me access to the cert and a conn but how do I associate those things when this happens:
cli,addr = self.server.accept()
| [
"After the handshake is complete, you can get the client certificate. While the client certificate is also available in the verify callback (verify_cb), there's not really any reason to try to do anything aside from verify the certificate in that callback. Setting up an application-specific mapping is better done... | [
5
] | [] | [] | [
"pyopenssl",
"python"
] | stackoverflow_0000096508_pyopenssl_python.txt |
Q:
What's the easiest non-memory intensive way to output XML from Python?
Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?
A:
I think you'll find XMLGenerator from xml.sax.saxutils ... | What's the easiest non-memory intensive way to output XML from Python? | Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?
| [
"I think you'll find XMLGenerator from xml.sax.saxutils is the closest thing to what you want.\n\nimport time\nfrom xml.sax.saxutils import XMLGenerator\nfrom xml.sax.xmlreader import AttributesNSImpl\n\nLOG_LEVELS = ['DEBUG', 'WARNING', 'ERROR']\n\n\nclass xml_logger:\n def __init__(self, output, encoding):\n ... | [
15,
2,
0,
-4
] | [
"I've always had good results with lxml. It's a pain to install, as it's mostly a wrapper around libxml2, but lxml.etree tree objects have a .write() method that takes a file-like object to stream to.\nfrom lxml.etree import XML\n\ntree = XML('<root><a><b/></a></root>')\ntree.write(your_file_object)\n\n",
"Secon... | [
-1,
-2
] | [
"python",
"streaming",
"xml"
] | stackoverflow_0000093710_python_streaming_xml.txt |
Q:
How to load a python module into a fresh interactive shell in Komodo?
When using PyWin I can easily load a python file into a fresh interactive shell and I find this quite handy for prototyping and other exploratory tasks.
I would like to use Komodo as my python editor, but I haven't found a replacement for PyWin'... | How to load a python module into a fresh interactive shell in Komodo? | When using PyWin I can easily load a python file into a fresh interactive shell and I find this quite handy for prototyping and other exploratory tasks.
I would like to use Komodo as my python editor, but I haven't found a replacement for PyWin's ability to restart the shell and reload the current module. How can I d... | [
"I use Komodo Edit, which might be a little less sophisticated than full Komodo.\nI create a \"New Command\" with %(python) -i %f as the text of the command. I have this run in a \"New Console\". I usually have the starting directory as %p, the top of the project directory.\nThe -i option runs the file and drops ... | [
5
] | [] | [] | [
"interpreter",
"komodo",
"python",
"shell"
] | stackoverflow_0000097513_interpreter_komodo_python_shell.txt |
Q:
What does BlazeDS Livecycle Data Services do, that something like PyAMF or RubyAMF not do?
I'm doing a tech review and looking at AMF integration with various backends (Rails, Python, Grails etc).
Lots of options are out there, question is, what do the Adobe products do (BlazeDS etc) that something like RubyAMF / ... | What does BlazeDS Livecycle Data Services do, that something like PyAMF or RubyAMF not do? | I'm doing a tech review and looking at AMF integration with various backends (Rails, Python, Grails etc).
Lots of options are out there, question is, what do the Adobe products do (BlazeDS etc) that something like RubyAMF / pyAMF don't?
| [
"Other than NIO (RTMP) channels, LCDS include also the \"data management\" features. \nUsing this feature, you basically implement, in an ActionScript class, a CRUD-like interface defined by LCDS, and you get:\n\nautomatic progressive list loading (large lists/datagrids loads while scrolling)\nautomatic crud manage... | [
3,
3,
2,
1
] | [] | [] | [
"apache_flex",
"blazeds",
"python",
"ruby",
"ruby_on_rails"
] | stackoverflow_0000077198_apache_flex_blazeds_python_ruby_ruby_on_rails.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.