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: python list boundary Is there a boundary on list and dictionary in python? if there is, what is the limit? A: I think by boundary you mean whether there is an upper bound on the number of elements in a list or dict. Python does not define any limits on them, so they can be as big as the memory available on your ...
python list boundary
Is there a boundary on list and dictionary in python? if there is, what is the limit?
[ "I think by boundary you mean whether there is an upper bound on the number of elements in a list or dict. Python does not define any limits on them, so they can be as big as the memory available on your machine permits. \n", "Actually, currently hash implementation for inner Python objects use 32 bit hashes --so...
[ 6, 3, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005092356_python.txt
Q: Using Python, how do I tell if a rectangle and a shape overlap? I'm writing a program in Python. I have a series of shapes (polygons, defined as a sequence of coordinate pairs) and I need to tell if they overlap a particular rectangle. Is there an easy algorithm for handling this? Or, better, is there a pure Pyt...
Using Python, how do I tell if a rectangle and a shape overlap?
I'm writing a program in Python. I have a series of shapes (polygons, defined as a sequence of coordinate pairs) and I need to tell if they overlap a particular rectangle. Is there an easy algorithm for handling this? Or, better, is there a pure Python library that can handle these calculations for me?
[ "Presuming your \"arbitrary shapes\" are indeed polygons (given that they're described as coordinate pairs), determining if they overlap (in any language) is a relatively trivial calculation. You merely need to compute if any side of polygon A intersects any other side of polygon B.\nIf you need an example, there'...
[ 3 ]
[]
[]
[ "geometry", "python" ]
stackoverflow_0005092592_geometry_python.txt
Q: python incorrect timezone conversion using pytz I wrote the following script in python to convert datetime from any given timezone to EST. from datetime import datetime, timedelta from pytz import timezone import pytz utc = pytz.utc # Converts char representation of int to numeric representation '121'->12...
python incorrect timezone conversion using pytz
I wrote the following script in python to convert datetime from any given timezone to EST. from datetime import datetime, timedelta from pytz import timezone import pytz utc = pytz.utc # Converts char representation of int to numeric representation '121'->121, '-1729'->-1729 def toInt(ch): ret = 0 ...
[ "Firstly slightly less insane implementation:\nimport datetime\nimport pytz\n\nEST = pytz.timezone('US/Eastern')\n\ndef convert2EST(date, time, tzone):\n dt = datetime.datetime.strptime(date+time, '%Y%m%d%H:%M:%S')\n tz = pytz.timezone(tzone)\n dt = tz.localize(dt)\n return dt.astimezone(EST)\n\nNow, we...
[ 8, 2 ]
[]
[]
[ "python", "pytz", "timezone" ]
stackoverflow_0005086419_python_pytz_timezone.txt
Q: Use app engine yaml parser in scripts I have some configuration files I want to write in yaml and read in a Python script running on Google app engine. Given that app engine uses app.yaml, index.yaml among others it seems reasonable to assume there is a python yaml parser available. How can I gain access to this ...
Use app engine yaml parser in scripts
I have some configuration files I want to write in yaml and read in a Python script running on Google app engine. Given that app engine uses app.yaml, index.yaml among others it seems reasonable to assume there is a python yaml parser available. How can I gain access to this parser (what is the import) and where can I...
[ "The YAML library is included with the AppEngine SDK. It is located in google_appengine/lib/yaml. You should be able to use it in your AppEngine code just by having import yaml in your code.\nFor non-AppEngine work, a quick Google search reveals http://pyyaml.org/ home to many and various Python implementations.\n"...
[ 9 ]
[]
[]
[ "google_app_engine", "python", "yaml" ]
stackoverflow_0005093080_google_app_engine_python_yaml.txt
Q: Py2exe Directory Structure I use Py2exe to package a Python application with quite a few dependant packages. While Py2exe works flawlessly the resulting dist/ folder with the executable contains a large number (10-15) of support files (.dll, .pyd, .zip). Ideally I would like to be able to place all of these depend...
Py2exe Directory Structure
I use Py2exe to package a Python application with quite a few dependant packages. While Py2exe works flawlessly the resulting dist/ folder with the executable contains a large number (10-15) of support files (.dll, .pyd, .zip). Ideally I would like to be able to place all of these dependant files in a folder called sup...
[ "An effective solution is to bundle everything in an standalone executable using\nbundle_files:1\nin your setup.py py2exe options.\n" ]
[ 2 ]
[]
[]
[ "py2exe", "python" ]
stackoverflow_0003148483_py2exe_python.txt
Q: How do I register custom filter in Google App Engine template system? According to Django documentation I've registered my filter: from google.appengine.ext.webapp import template # ... register = template.create_template_register() @register.filter(name='wld') def wld(result): if result == 1 : return "win" ...
How do I register custom filter in Google App Engine template system?
According to Django documentation I've registered my filter: from google.appengine.ext.webapp import template # ... register = template.create_template_register() @register.filter(name='wld') def wld(result): if result == 1 : return "win" if result == 0 : return "loss" if result == 0.5 : return "draw" r...
[ "Once you have created your custom tag library, you need to register it with the Django template engine:\nfrom google.appengine.ext.webapp import template\ntemplate.register_template_library('path.to.lib')\n\nNote that the call template.register_template_library is a wrapper that is provided as part of the AppEngin...
[ 12, 0 ]
[]
[]
[ "django", "django_templates", "google_app_engine", "python" ]
stackoverflow_0005091596_django_django_templates_google_app_engine_python.txt
Q: Binary Image Corner Detection I have a matrix that represents a binary image (1 for each cell that represents "black" pixels and 0 for "white" ones). The black pixels represent the figures (shape and fill) of the image and the white ones the background. What I want to do is to detect the corners of the figures rep...
Binary Image Corner Detection
I have a matrix that represents a binary image (1 for each cell that represents "black" pixels and 0 for "white" ones). The black pixels represent the figures (shape and fill) of the image and the white ones the background. What I want to do is to detect the corners of the figures represented in the matrix. 2 examples:...
[ "Try the opencv libraries, they have python bindings and a lot of algorithms to do corner detection.\nmy2c\n", "If I understand you correctly there is a template using C++ that allows you to scan each pixel, and you could do that and replace the black's with 1's and white with 0's.\nI had to do a similar thing wh...
[ 5, 0 ]
[]
[]
[ "algorithm", "c++", "image_processing", "python", "robotics" ]
stackoverflow_0005090168_algorithm_c++_image_processing_python_robotics.txt
Q: Python unescape URL I have got a url in this form - http:\\/\\/en.wikipedia.org\\/wiki\\/The_Truman_Show. How can I make it normal url. I have tried using urllib.unquote without much success. I can always use regular expressions or some simple string replace stuff. But I believe that there is a better way to hand...
Python unescape URL
I have got a url in this form - http:\\/\\/en.wikipedia.org\\/wiki\\/The_Truman_Show. How can I make it normal url. I have tried using urllib.unquote without much success. I can always use regular expressions or some simple string replace stuff. But I believe that there is a better way to handle this...
[ "urllib.unquote is for replacing %xx escape codes in URLs with the characters they represent. It won't be useful for this.\nYour \"simple string replace stuff\" is probably the best solution.\n", "Have you tried using json.loads from the json module?\n>>> json.loads('\"http:\\\\/\\\\/en.wikipedia.org\\\\/wiki\\\\...
[ 11, 5, 1 ]
[]
[]
[ "python", "url" ]
stackoverflow_0004312197_python_url.txt
Q: Parallel Tasking Concurrency with Dependencies on Python like GNU Make I'm looking for a method or possibly a philosophical approach for how to do something like GNU Make within python. Currently, we utilize makefiles to execute processing because the makefiles are extremely good at parallel runs with changing si...
Parallel Tasking Concurrency with Dependencies on Python like GNU Make
I'm looking for a method or possibly a philosophical approach for how to do something like GNU Make within python. Currently, we utilize makefiles to execute processing because the makefiles are extremely good at parallel runs with changing single option: -j x. In addition, gnu make already has the dependency stacks ...
[ "You might want to have a look a jug. It's a task-based parallelisation framework that includes dependency tracking.\n", "Have also a look at Waf, it's less complicated than Scons.\n\nWaf is a Python-based framework for\n configuring, compiling and installing\n applications. Here are perhaps the\n most import...
[ 3, 1, 0, 0, 0 ]
[]
[]
[ "concurrency", "dependencies", "makefile", "parallel_processing", "python" ]
stackoverflow_0005092851_concurrency_dependencies_makefile_parallel_processing_python.txt
Q: Implementing a macro recorder for a python gui? I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks...
Implementing a macro recorder for a python gui?
I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks pass through a single class that logged actions. Un...
[ "Thinking in high level, this is what I'd do:\nDevelop a decorator function, with which I'd decorate every event-handling functions.\nThis decorator functions would take note of thee function called, and its parameters (and possibly returning values) in a unified data-structure - taking care, on this data structur...
[ 1, 1, 0 ]
[]
[]
[ "macros", "python", "recorder", "user_interface" ]
stackoverflow_0005093153_macros_python_recorder_user_interface.txt
Q: Python 2.6 threading KeyError with Apache I'm running Apache, installed using macports on OS X, to serve a Django app. I'm getting many lines in the Apache error_log like these: [Wed Feb 23 11:35:42 2011] [error] Exception KeyError: KeyError(-1606572256,) in <module 'threading' from '/opt/local/Library/Frameworks/...
Python 2.6 threading KeyError with Apache
I'm running Apache, installed using macports on OS X, to serve a Django app. I'm getting many lines in the Apache error_log like these: [Wed Feb 23 11:35:42 2011] [error] Exception KeyError: KeyError(-1606572256,) in <module 'threading' from '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/thr...
[ "That bug is almost a year old. Update mod_wsgi.\n" ]
[ 2 ]
[]
[]
[ "apache", "macos", "multithreading", "python" ]
stackoverflow_0005094012_apache_macos_multithreading_python.txt
Q: Syntax Error that I can't find I'm pulling my hairs here... import os import random MAC = (0,0,":",0,0,":") chars = ('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e') a = 5 while (a <= 17): if a == 6 | a == 9 | a == 12 | a == 15: MAC.append(":") else: MAC.append(chars(random.randomint(0,15))...
Syntax Error that I can't find
I'm pulling my hairs here... import os import random MAC = (0,0,":",0,0,":") chars = ('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e') a = 5 while (a <= 17): if a == 6 | a == 9 | a == 12 | a == 15: MAC.append(":") else: MAC.append(chars(random.randomint(0,15)) a += 1 print MAC What am I doin...
[ "You're looking for the logical or (or) and not the bitwise or (|).\nChars is not a function, but an array. Use array subscripts to get at values. (i.e. chars[rand] and not chars(rand).\nYou're missing a parenthesis after the append random char line.\nYou also can't append to tuples, need to make MAC a list.\nThe r...
[ 4, 2, 1, 1 ]
[]
[]
[ "python", "syntax_error" ]
stackoverflow_0005094183_python_syntax_error.txt
Q: How to run another process in a loop on a different thread I am creating a GUI application(wxPython). I need to run another (.exe) application from the GUI application. The subprocess will perform some operation on a user action and return an output to the GUI application I am running this subprocess in a loop, so...
How to run another process in a loop on a different thread
I am creating a GUI application(wxPython). I need to run another (.exe) application from the GUI application. The subprocess will perform some operation on a user action and return an output to the GUI application I am running this subprocess in a loop, so that constantly the subprocess is available to execute. What I ...
[ "1) Make 'proc' a instance attribute, so you can call it's terminate() or kill() methods before exiting.\nself.thread = threading.Thread(target=self.run, args=())\nself.thread.setDaemon(True)\nself.thread.start()\n\ndef run(self):\n while self.is_listening:\n cmd = ['application.exe']\n self.proc =...
[ 2 ]
[]
[]
[ "multithreading", "python", "subprocess", "user_interface", "wxpython" ]
stackoverflow_0005093446_multithreading_python_subprocess_user_interface_wxpython.txt
Q: Taking a screenshot with Pyglet [Fix'd] In the pyglet docs, I found: The following example shows how to grab a screenshot of your application window: pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png') However when using this, everything will stop until I click the mouse. Is there a...
Taking a screenshot with Pyglet [Fix'd]
In the pyglet docs, I found: The following example shows how to grab a screenshot of your application window: pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png') However when using this, everything will stop until I click the mouse. Is there another way to get the screen contents in Pygl...
[ "Okay, here is a complete working example in pyglet. It shows the text \"hello world\" taking a random walk around the window and dumps the screenshot (using the exact same line of code you posted) every time you press a key.\nimport pyglet, random\n\nwindow = pyglet.window.Window()\n\nlabel = pyglet.text.Label('He...
[ 10, 1 ]
[]
[]
[ "events", "pyglet", "python", "screenshot" ]
stackoverflow_0004986662_events_pyglet_python_screenshot.txt
Q: How should I deal with latency in game development? I'm working on a hobby project consisting of a multi-player web browser game. It is my first and I have just stumbled into the latency issue. I am trying to make user control as smooth as possible and latency is getting in the way. I reckon that average latencie...
How should I deal with latency in game development?
I'm working on a hobby project consisting of a multi-player web browser game. It is my first and I have just stumbled into the latency issue. I am trying to make user control as smooth as possible and latency is getting in the way. I reckon that average latencies might be around 80-200ms and that for virtually-smooth ...
[ "Question 1) Yes, but if you're doing real time movement like that, I would consider rendering it locally (using collision detection and what not) and then validation on the server to ensure they didn't cheat it (i.e. update the position on the server every second, and make sure they could have gone from A to B in ...
[ 5, 1 ]
[]
[]
[ "latency", "pygame", "python" ]
stackoverflow_0005094697_latency_pygame_python.txt
Q: Can a decorator be working with a lambda expression at runtime? def attrs(**kwds): def decorate(f): for k in kwds: setattr(f, k, kwds[k]) return f return decorate @attrs(argument_types=(int, int,), returns=int) def add(a, b): return a + b Here I need the add()...
Can a decorator be working with a lambda expression at runtime?
def attrs(**kwds): def decorate(f): for k in kwds: setattr(f, k, kwds[k]) return f return decorate @attrs(argument_types=(int, int,), returns=int) def add(a, b): return a + b Here I need the add() can be with the ability to show its acceptable parameter type. but c...
[ "Decorator syntax is merely syntactic sugar, albeit one that directs people's thoughts into interesting directions.\n@expr\ndef f(...):\n ...\n\nis identical to\ndef f(...):\n ...\nf = expr(f)\n\nSo you can just use attrs(argument_types=..., ...)(lambda: ...).\n", "The @ syntax is just syntactic sugar for c...
[ 15, 12 ]
[]
[]
[ "decorator", "lambda", "python" ]
stackoverflow_0005094914_decorator_lambda_python.txt
Q: Output dictionary to csv file I have a nested dictionary in the following format, used for internationalization (this allows our translators and non-programmers to edit this file as necessary; my backup plan is to use JSON format, but this would not be as suitable for these users..). dict[LANGUAGE][KEY] = VALUE I...
Output dictionary to csv file
I have a nested dictionary in the following format, used for internationalization (this allows our translators and non-programmers to edit this file as necessary; my backup plan is to use JSON format, but this would not be as suitable for these users..). dict[LANGUAGE][KEY] = VALUE I output this into a csv file in the...
[ "It is hard to suggest an alternative format suitable for manual editing by non-technical users without knowing the exact details of the data structures you want to store there (e.g. the nested dicts/lists that you mention).\nOne obvious suggestion is to stick with a computer-friendly format and provide a usable GU...
[ 0 ]
[]
[]
[ "csv", "json", "python" ]
stackoverflow_0005094995_csv_json_python.txt
Q: ElementTree namespace incovenience I can't control quality of XML that I get. In some cases it is: <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> ... </COLLADA> in others I get: <COLLADA>...</COLLADA> and I guess I should also handle <collada:COLLADA xmlns:collada="http://www.co...
ElementTree namespace incovenience
I can't control quality of XML that I get. In some cases it is: <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> ... </COLLADA> in others I get: <COLLADA>...</COLLADA> and I guess I should also handle <collada:COLLADA xmlns:collada="http://www.collada.org/2005/11/COLLADASchema"> ... ...
[ "My usual recommendation is to preprocess it first, to normalize the namespaces. This has two benefits: the normalization code is highly reusable, because it doesn't depend on how the data is being processed subsequently; and the logic to process the data is considerably simplified.\nIf the documents only use this ...
[ 1 ]
[]
[]
[ "elementtree", "lxml", "python", "xml" ]
stackoverflow_0005093613_elementtree_lxml_python_xml.txt
Q: Python 3.1 and win32api dll not found error Hello i got a clean python 3.1.3 install and then went for the latest version of pywin32 module from here http://sourceforge.net/projects/pywin32/files/pywin32/ but when i try to import win32api it gives me this error Traceback (most recent call last): File "", lin...
Python 3.1 and win32api dll not found error
Hello i got a clean python 3.1.3 install and then went for the latest version of pywin32 module from here http://sourceforge.net/projects/pywin32/files/pywin32/ but when i try to import win32api it gives me this error Traceback (most recent call last): File "", line 1, in import win32api ImportError: DLL...
[ "Which of the files did you download and install? You need to install one of the installers, and not the source file (unless you can build it). \nThis can help to find which DLL it's trying to find: http://www.dependencywalker.com/\n" ]
[ 2 ]
[]
[]
[ "python", "python_3.x", "pywin32" ]
stackoverflow_0005094783_python_python_3.x_pywin32.txt
Q: How to ensure a safe file sync with sqlite and NFS I have recently converted my workspace file format for my application to sqlite. In order to ensure robust operation on NFS I've used a common update policy, I do all modifications to a copy stored in a temp location on the local harddisk. Only when saving do I ...
How to ensure a safe file sync with sqlite and NFS
I have recently converted my workspace file format for my application to sqlite. In order to ensure robust operation on NFS I've used a common update policy, I do all modifications to a copy stored in a temp location on the local harddisk. Only when saving do I modify the original file (potentially on NFS) by copying...
[ "SQLite NFS issues are due to broken caching and locking. If your process is the only one accessing the file on NFS then you'll be ok.\nThe SQLite backup API was designed to solve exactly your problem. You can either backup directly to the NFS database or to another local temp file and then copy that. The backup...
[ 2 ]
[]
[]
[ "nfs", "python", "sqlalchemy", "sqlite" ]
stackoverflow_0005043327_nfs_python_sqlalchemy_sqlite.txt
Q: PyThon How do I pass a object to another class? I just want to access some_object within class hello: def GET() from wsgiref.simple_server import make_server import web urls = ( '/(.*)', 'hello' ) class hello: def GET(self, name): return some_object if __name__ == '__main__': data = [] ...
PyThon How do I pass a object to another class?
I just want to access some_object within class hello: def GET() from wsgiref.simple_server import make_server import web urls = ( '/(.*)', 'hello' ) class hello: def GET(self, name): return some_object if __name__ == '__main__': data = [] some_object = ParentObj.func(data) app = web.ap...
[ "You could make some_object a member of the class itself.\nUnder your '__main__' section, set some_object as a class member of the hello class, like so:\nhello.some_object = some_object\n\nThen change hello.GET to return the member of the class:\nclass hello:\n def GET(self, name):\n return self.some_obje...
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0005095485_python.txt
Q: Simplest way to switch the linux user for the web-server (django) without sudo? Aim: to create user friendly web interface to linux program without any ssh (console) terrible stuff. I have chosen Python + Django + Apache. Problem: user should login through the browser to linux user and then all user`s requests sho...
Simplest way to switch the linux user for the web-server (django) without sudo?
Aim: to create user friendly web interface to linux program without any ssh (console) terrible stuff. I have chosen Python + Django + Apache. Problem: user should login through the browser to linux user and then all user`s requests should be served on behalf of this linux user. By now, server is run as root and when us...
[ "You can include the wsgi user in the sudoers file, and limit the commands and arguments it can run. Why can't you use sudo?\nfor example:\nCmnd_Alias TRUSTED_CMDS = /bin/su johndoe /some/command, \\\n /bin/su janedoe /some/command\n\nmy_wsgi_user ALL = NOPASSWD: TRUSTED_CMDS\n\nFr...
[ 1, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0005090999_django_python.txt
Q: How to turn python list comprehensions into xml I need a little help on finding a tutorial or sample on taking a list comprehension and merging that with a data file from csv and turning all that into an xml file. From reading various python books & pdfs like ditp,IYOCGwP, learnpythonthe hardway,, lxml tut, think ...
How to turn python list comprehensions into xml
I need a little help on finding a tutorial or sample on taking a list comprehension and merging that with a data file from csv and turning all that into an xml file. From reading various python books & pdfs like ditp,IYOCGwP, learnpythonthe hardway,, lxml tut, think python and online searches I am most of the way there...
[ "I created a file with name 'pattern.txt' and following content (with this indentation).\nNotice the 8 %s put at strategic places.\n <event event-tag=\"%s\">\n <facets name=\"header\">\n <categories name=\"processing\">\n <instance instance-tag=\"0\">\n <proper...
[ 0, 0 ]
[]
[]
[ "csv", "list", "python", "xml" ]
stackoverflow_0005011083_csv_list_python_xml.txt
Q: Match but not return regular expression between two matches I'm trying to retrieve two distinct items without matching the term in between using regular expressions: [[A]] son of [[B]] I thought this would work: \[\[[A-Za-z\s]+\]\](?:(.*son of.*))\[\[[\|,A-Za-z\s]+\]\] but it's not quite working. How can I match A...
Match but not return regular expression between two matches
I'm trying to retrieve two distinct items without matching the term in between using regular expressions: [[A]] son of [[B]] I thought this would work: \[\[[A-Za-z\s]+\]\](?:(.*son of.*))\[\[[\|,A-Za-z\s]+\]\] but it's not quite working. How can I match A and B without returning "son of"?
[ "I assume you have a string like [[Worf]] son of [[Mogh]], from which you want to \"return\" (i.e. match) [[Worf]] and [[Mogh]]. To do so, you'll need capturing groups (parentheses) around the portions of the regular expression you want to capture (aka \"return\"). In order to not return son of, you'll also need to...
[ 4, 1, 0, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0005095748_python_regex.txt
Q: Pretty Print Formatting Issue in Python str = "" for i in range(1,91): str = str + '-' print "+", '{:^90}'.format(str), "+" for elem in cursor: print "|", '{:^8}'.format(elem['classid']), \ "|", '{:^8}'.format(elem['dept']), \ "|", '{:^8}'.format(elem['coursenum']), \ ...
Pretty Print Formatting Issue in Python
str = "" for i in range(1,91): str = str + '-' print "+", '{:^90}'.format(str), "+" for elem in cursor: print "|", '{:^8}'.format(elem['classid']), \ "|", '{:^8}'.format(elem['dept']), \ "|", '{:^8}'.format(elem['coursenum']), \ "|", '{:^8}'.format(elem['area']), \ ...
[ "Python 2.6 does not support zero-length field names in format strings.\nprint \"+\", '{0:^90}'.format(''), \"+\"\n\n" ]
[ 6 ]
[]
[]
[ "pretty_print", "python" ]
stackoverflow_0005096017_pretty_print_python.txt
Q: How to handle array of strings (char **) in ctypes in a 64-bit environment? I'm using ctypes to work with libgphoto2 in Python. The following code succeeds on a 32-bit machine, but fails with a Segmentation Fault on a 64-bit machine (Linux, Ubuntu): import ctypes gp = ctypes.CDLL('libgphoto2.so') a = gp.gp_librar...
How to handle array of strings (char **) in ctypes in a 64-bit environment?
I'm using ctypes to work with libgphoto2 in Python. The following code succeeds on a 32-bit machine, but fails with a Segmentation Fault on a 64-bit machine (Linux, Ubuntu): import ctypes gp = ctypes.CDLL('libgphoto2.so') a = gp.gp_library_version(0) x = ctypes.c_char_p.from_address(a) x.value libphoto2, ctypes and p...
[ "The problem is that, by default, ctypes assumes that all functions return int, which is 32 bits. But, on a 64-bit system, a pointer is 64 bits, so you're dropping the upper 32 bits from the pointer return value, so you then get a segfault when you try to dereference that invalid pointer.\nYou can change the expec...
[ 3, 1 ]
[]
[]
[ "64_bit", "arrays", "ctypes", "python", "string" ]
stackoverflow_0005095944_64_bit_arrays_ctypes_python_string.txt
Q: Should class-specific "constants" still be declared at module level? In PEP 8, it's stated that "Constants are usually defined on a module level […]". This makes sense for the standard library, where constants tend to pertain to the entire module rather than a particular class (e.g. zlib.MAX_WBITS or re.UNICODE)....
Should class-specific "constants" still be declared at module level?
In PEP 8, it's stated that "Constants are usually defined on a module level […]". This makes sense for the standard library, where constants tend to pertain to the entire module rather than a particular class (e.g. zlib.MAX_WBITS or re.UNICODE). I'm currently writing a module, however, where the constants are all rel...
[ "Clearly, class-based constants belong in the class. Stick with your second example. Remember PEP8 is not handed down from the Almighty. It's just good ideas: tradition, reason and experience can temper the meaning of scripture.\nHungrarian_prefix_notation is needless. That's one reason you have classes.\n", ...
[ 14, 0 ]
[]
[]
[ "naming_conventions", "python" ]
stackoverflow_0005096025_naming_conventions_python.txt
Q: Django: Display a custom error message for admin validation error I'm using Django 1.2.4. I have a model that has a field that needs to be validated. When validation fails, I'd like to display a custom error message to the user. Model editing is done in the admin interface. This is what I'm doing currently: def c...
Django: Display a custom error message for admin validation error
I'm using Django 1.2.4. I have a model that has a field that needs to be validated. When validation fails, I'd like to display a custom error message to the user. Model editing is done in the admin interface. This is what I'm doing currently: def clean_fields(self, exclude=None): # do validation if problem: ...
[ "Without looking, it sounds like the admin is looking for an iterable as the value for field_name. Try:\nraise ValidationError({'field_name': [\"error message\",]})\n\nI think the admin expects any number of validation messages to be associated with each field on a form.\n" ]
[ 18 ]
[]
[]
[ "django", "django_admin", "python", "validation" ]
stackoverflow_0005096082_django_django_admin_python_validation.txt
Q: How do I authenticate a urllib2 script in order to access HTTPS web services from a Django site? everybody. I'm working on a django/mod_wsgi/apache2 website that serves sensitive information using https for all requests and responses. All views are written to redirect if the user isn't authenticated. It also has s...
How do I authenticate a urllib2 script in order to access HTTPS web services from a Django site?
everybody. I'm working on a django/mod_wsgi/apache2 website that serves sensitive information using https for all requests and responses. All views are written to redirect if the user isn't authenticated. It also has several views that are meant to function like RESTful web services. I'm now in the process of writing ...
[ "Please excuse my answering my own question, but - for the record this seems to have solved it:\nIt turns out I needed to set the HTTP Referer header to the login page url in the request where I post the login information.\nreq.add_header( 'Referer', login_url )\n\nThe reason is explained on the Django CSRF documen...
[ 5, 4 ]
[]
[]
[ "django", "https", "python", "urllib2", "web_services" ]
stackoverflow_0005082128_django_https_python_urllib2_web_services.txt
Q: Jython and the xml.sax parser - strange error I am just getting started with Python/Jython and the SAX parser (xml.sax). I wrote a simple content handler as a test. from __future__ import with_statement from xml.sax import make_parser, handler from xml.sax.handler import ContentHandler class CountingHandler(Con...
Jython and the xml.sax parser - strange error
I am just getting started with Python/Jython and the SAX parser (xml.sax). I wrote a simple content handler as a test. from __future__ import with_statement from xml.sax import make_parser, handler from xml.sax.handler import ContentHandler class CountingHandler(ContentHandler): def __init__(self): self...
[ "I think it's this bug: http://bugs.jython.com/issue1488. Fixed in Jython 2.5.2-b1: http://www.jython.org/latest.html\n", "When you insert print type(input) after your with statement, what do you see?\nWhen you revert to old-style \"try/finally\" code instead of \"with\", does it work for all files?\nWhat is diff...
[ 1, 0 ]
[]
[]
[ "jython", "python", "sax", "xml" ]
stackoverflow_0005096436_jython_python_sax_xml.txt
Q: Django hideously slow with 8000 model instances (How to drop PostgreSQL database)? I have a Django installation running on the development server. I recently used python manage.py loaddata 8000models.json. Now everything is super slow. Pages won't load. python manage.py flush does not return. ModelType.objects.cou...
Django hideously slow with 8000 model instances (How to drop PostgreSQL database)?
I have a Django installation running on the development server. I recently used python manage.py loaddata 8000models.json. Now everything is super slow. Pages won't load. python manage.py flush does not return. ModelType.objects.count() does not return. (Or maybe they will return if I wait a sufficiently long time.) W...
[ "Ctrl-Z just stops the process, it does not kill it. (I assume you're using bash) type jobs in your terminal, and you should see the old processes still running.\nOnce you kill all the jobs that are accessing the PostgreSQL database, you should be able to drop, create, and syncdb as you expect.\n", "Have you trie...
[ 1, 0 ]
[]
[]
[ "database", "django", "postgresql", "python" ]
stackoverflow_0005093964_database_django_postgresql_python.txt
Q: Set parent in a ModelForm in Google App Engine I want to create an Entity Group relationship in an Entity that is being created through a ModelForm. How do I pass the parent instance and set the parent= attribute in the ModelForm? A: I'll be interested to see if you get any good solutions to this problem. My ow...
Set parent in a ModelForm in Google App Engine
I want to create an Entity Group relationship in an Entity that is being created through a ModelForm. How do I pass the parent instance and set the parent= attribute in the ModelForm?
[ "I'll be interested to see if you get any good solutions to this problem. My own solution, which is far from elegant, is to do this:\nbook = models.Book(title='Foo')\nchapter = models.Chapter(parent=book, title='dummy')\nform = forms.ChapterForm(request.POST, request.FILES, instance=chapter)\n\nBasically, I first ...
[ 4, 0 ]
[]
[]
[ "app_engine_patch", "django", "google_app_engine", "python" ]
stackoverflow_0002097225_app_engine_patch_django_google_app_engine_python.txt
Q: Are Java and C# as "customizable" as Python? At the time of asking, I am using Python most of the time, and I have not used Java or C# much, although I have a (basic) idea of how they work. I am thinking to possibly start to use Java or C# more, but it seems from the little I know about them that they aren't as "c...
Are Java and C# as "customizable" as Python?
At the time of asking, I am using Python most of the time, and I have not used Java or C# much, although I have a (basic) idea of how they work. I am thinking to possibly start to use Java or C# more, but it seems from the little I know about them that they aren't as "customizable" as Python, but I may be wrong. By "cu...
[ "Python being a fully dynamic language is always going to have the advantage here over more static languages like C# and Java. Java and C# have also traditionally targeted more conservative markets, making them more conservative by design. Although C# gains more and more dynamic oriented features with each new rele...
[ 5, 2 ]
[]
[]
[ "c#", "java", "python" ]
stackoverflow_0005096662_c#_java_python.txt
Q: Automatically posting to facebook page with python I want to make a script that lets me post to my facebook fan page (which I'm an admin of) As far as I've seen, Most graph api examples are about making facebook apps in python and make them communicate with python, which is quite different from what I want. Also T...
Automatically posting to facebook page with python
I want to make a script that lets me post to my facebook fan page (which I'm an admin of) As far as I've seen, Most graph api examples are about making facebook apps in python and make them communicate with python, which is quite different from what I want. Also The graph api requires the oauth token, which the documen...
[ "First You need to get your Facebook_App_Id and Facebook_App_Secret, from facebook which you will get when you register your app.\nThen you include the needed urls.\nredirect_client_url = 'http://your-redirect-url'\naccess_token_url = 'https://graph.facebook.com/oauth/access_token?client_id='+consumer_key+'&redirec...
[ 6 ]
[]
[]
[ "django", "facebook", "facebook_page", "python" ]
stackoverflow_0005096597_django_facebook_facebook_page_python.txt
Q: File upload via FTP gaieerror Python 2.6 I'm trying to upload a text file to an FTP server, but I am getting this error: gaierror: [Errno 11004] getaddrinfo failed Here is my code. s = ftplib.FTP("ftp://xbrera.co.cc", "myuser", "mypass") f = open(path + "LD.txt", "r") s.storbinary("STOR " +...
File upload via FTP gaieerror Python 2.6
I'm trying to upload a text file to an FTP server, but I am getting this error: gaierror: [Errno 11004] getaddrinfo failed Here is my code. s = ftplib.FTP("ftp://xbrera.co.cc", "myuser", "mypass") f = open(path + "LD.txt", "r") s.storbinary("STOR " + path + "LD.txt") f.close() s....
[ "Change your code to s = ftplib.FTP(\"xbrera.co.cc\", \"myuser\", \"mypass\"). The ftp:// is only mandatory for a URI but the ftplib library expect the hostname of your FTP server.\n" ]
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0005097058_python.txt
Q: WSGI Exception - Port block I probably should go to Server Fault with this, but I don't know how to exactly spell the problem, it seems that port 80 on my machine(Xubuntu 9.10) is blocked by something, the only clue I've got is this: Django version 1.2.3, using settings 'settings' Development server is running at ...
WSGI Exception - Port block
I probably should go to Server Fault with this, but I don't know how to exactly spell the problem, it seems that port 80 on my machine(Xubuntu 9.10) is blocked by something, the only clue I've got is this: Django version 1.2.3, using settings 'settings' Development server is running at http://0.0.0.0:80/ Quit the serve...
[ "\"Error: You don't have permission to access that port\" \nThat's the bottom line. You don't have access.\nPort 80 requires a privileged process like Apache. The built-in server with Django is not privileged and should not be used for anything but development.\n" ]
[ 5 ]
[]
[]
[ "django", "linux", "python" ]
stackoverflow_0005097140_django_linux_python.txt
Q: what is this error when deploying google python-appengine application? this is the error message .. any help will be appreciated . 2011-02-23 23:09:11 Running command: "['C:\\Python25\\pythonw.exe', '-u', 'C:\\Program Files\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=adham587@gmail.com', '--pa...
what is this error when deploying google python-appengine application?
this is the error message .. any help will be appreciated . 2011-02-23 23:09:11 Running command: "['C:\\Python25\\pythonw.exe', '-u', 'C:\\Program Files\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=adham587@gmail.com', '--passin', 'update', 'C:\\Users\\adham\\Desktop\\images']" Application: refacing...
[ "This problem can occur if an update is started and does not finish for whatever reason. As the error message notes, the correct thing to do is to give appcfg.py the rollback command. That will undo the failed changes and reset your app so it is ready for an update. \n" ]
[ 4 ]
[ "Try \neasy_install ssl\n\nThe message says that module is missing.\n@Adam: duly noted. I apologize for missing the \"Warning text\". \nI believe his error will go away in a while since another operation might be going on at the same time. He should install ssl module nevertheless. If after a while and it doesn't h...
[ -1 ]
[ "google_app_engine", "python" ]
stackoverflow_0005097171_google_app_engine_python.txt
Q: Int Object Is Not Iterable I have come across a problem that I don't know how to resolve involving Dijkstra's algorithm - here is my code: infinity = 1000000 invalid_node = -1 #startNode = 0 class Node: distFromSource = infinity previous = invalid_node visited = False def populateNodeTable(): no...
Int Object Is Not Iterable
I have come across a problem that I don't know how to resolve involving Dijkstra's algorithm - here is my code: infinity = 1000000 invalid_node = -1 #startNode = 0 class Node: distFromSource = infinity previous = invalid_node visited = False def populateNodeTable(): nodeTable = [] f = open("twoD...
[ "Try this:\nfor i in nodeTable:\n\nwhy are you trying to iterate over numNodes? You just defined one line above as the length of the table.\nBut appending to the same table in the loop doesn't make sense. And it does not work together with the code that reads the file. Also the Node class isn't usable at all ...\n"...
[ 2, 0, 0 ]
[]
[]
[ "dijkstra", "python" ]
stackoverflow_0005097727_dijkstra_python.txt
Q: Python 2.7.1: Inconsistent output from os.path.isdir() I'm building a Python ISO generation app, and I'm getting some wierd output from os.path.isdir(). I'm running Arch Linux with Python 2.7.1. I have the following folder structure: /home/andrew/create_iso/Raw_Materials/ /home/andrew/create_iso/Raw_Materials/test...
Python 2.7.1: Inconsistent output from os.path.isdir()
I'm building a Python ISO generation app, and I'm getting some wierd output from os.path.isdir(). I'm running Arch Linux with Python 2.7.1. I have the following folder structure: /home/andrew/create_iso/Raw_Materials/ /home/andrew/create_iso/Raw_Materials/test_cd/ [andrew@Cydonia Raw_Materials]$ ls -l total 4 drwxr-xr-...
[ "'test_cd' by itself is not a directory. You need to do an os.path.join to get the absolute path to the directory, and then call isdir on that.\n", "You need to append folders to the '/home/andrew'... path.\nfolder_path = '/home/andrew/create_iso/Raw_Materials/'\nfor folder in os.listdir(folder_path):\n os.pa...
[ 5, 4, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005097258_python.txt
Q: Jython and the SAX Parser: No more than 64000 entities allowed? I've done a simple test of the xml.sax parser in Jython on a large XML file (800 MB) and encountered the following error: Traceback (most recent call last): File "src/project/xmltools.py", line 92, in <module> sys.exit(main()) File "src/projec...
Jython and the SAX Parser: No more than 64000 entities allowed?
I've done a simple test of the xml.sax parser in Jython on a large XML file (800 MB) and encountered the following error: Traceback (most recent call last): File "src/project/xmltools.py", line 92, in <module> sys.exit(main()) File "src/project/xmltools.py", line 87, in main parser.parse(open(argv[1], "r"))...
[ "Try setting the entityExpansionLimit property to a higher value than 64000. See http://download.oracle.com/javase/1.5.0/docs/guide/xml/jaxp/JAXP-Compatibility_150.html#JAXP_security.\n" ]
[ 5 ]
[]
[]
[ "jython", "python", "sax", "saxparser", "xml" ]
stackoverflow_0005097823_jython_python_sax_saxparser_xml.txt
Q: How do I tag textfiles with hunpos in nltk? Can someone help me with the syntax for hunpos tagging a corpus in nltk? What do I import for the hunpos.HunPosTagger module? How do I HunPosTag the corpus? See the code below. import nltk from nltk.corpus import PlaintextCorpusReader from nltk.corpus.util import L...
How do I tag textfiles with hunpos in nltk?
Can someone help me with the syntax for hunpos tagging a corpus in nltk? What do I import for the hunpos.HunPosTagger module? How do I HunPosTag the corpus? See the code below. import nltk from nltk.corpus import PlaintextCorpusReader from nltk.corpus.util import LazyCorpusLoader corpus_root = './' reader =...
[ "import nltk \nfrom nltk.tag.hunpos import HunposTagger\nfrom nltk.tokenize import word_tokenize\n\ncorpus = \"so how do i hunpos tag my ntuen ? i can't get the following code to work.\"\n#please help me to correct my python syntax errors, i'm new to python \n#but i really need this to work. sorry\n##from nltk.tag ...
[ 5 ]
[]
[]
[ "corpus", "nltk", "pos_tagger", "python" ]
stackoverflow_0005088448_corpus_nltk_pos_tagger_python.txt
Q: getting keyboard back from tkinter I'm working on a graphical app, and at the start of the run I'd like to ask the user a single configuration question. The graphical framework (Panda3D) has ugly default dialog boxes, so I'd like to use something like tkInter to provide a modal dialog. I tried this: import Tkinter...
getting keyboard back from tkinter
I'm working on a graphical app, and at the start of the run I'd like to ask the user a single configuration question. The graphical framework (Panda3D) has ugly default dialog boxes, so I'd like to use something like tkInter to provide a modal dialog. I tried this: import Tkinter import tkMessageBox root = Tkinter.Tk(...
[ "Have you tried:\ngrab_release(self)\nWhich does: Release grab for this widget if currently set.\nWhere \"A grab directs all events to this and descendant\nwidgets in the application.\"\nas in:\nroot.grab_release()\n\nHope you haven't tried this one.\n" ]
[ 2 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0003895068_python_tkinter.txt
Q: Reading a file in Python without an extension I want to read a (basically a text file) file without an extension in Python 2.6. I have tried the following codes with the following errors.. for infile in glob.glob(os.path.join(path + "Bookmarks",'*')): review_file = open(infile,'r').read() print review_file...
Reading a file in Python without an extension
I want to read a (basically a text file) file without an extension in Python 2.6. I have tried the following codes with the following errors.. for infile in glob.glob(os.path.join(path + "Bookmarks",'*')): review_file = open(infile,'r').read() print review_file -> global name glob is not defined f = open(path,...
[ "\nIf you want to use the glob module, you have to import it first:\nimport glob\nfor infile in glob.glob(os.path.join(path, '*')):\n review_file = open(infile,'r').read()\n print review_file\n\nAre you sure that your file does not contain the binary data you are getting?\n\n", "Have you tried it opening in...
[ 5, 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005095642_python.txt
Q: Does anyone know how to configure the hunpos wrapper class on nltk? i've tried the following code and installed from http://code.google.com/p/hunpos/downloads/list english-wsj-1.0 hunpos-1.0-linux.tgz i've extracted the file onto '~/' directory and when i tried the following python code: import nltk from nltk...
Does anyone know how to configure the hunpos wrapper class on nltk?
i've tried the following code and installed from http://code.google.com/p/hunpos/downloads/list english-wsj-1.0 hunpos-1.0-linux.tgz i've extracted the file onto '~/' directory and when i tried the following python code: import nltk from nltk.tag import hunpos from nltk.tag.hunpos import HunposTagger import os, sy...
[ "You're very close to the solution. Move the hunpos-tag executable to /home/ubi/bin and it should be able to find it then. This caused me some trouble too when I was first trying to use hunpos.\n" ]
[ 4 ]
[]
[]
[ "nlp", "nltk", "pos_tagger", "python" ]
stackoverflow_0005091389_nlp_nltk_pos_tagger_python.txt
Q: MySQL server has gone away I've recently moved from my local web.py/apache setup to a shared host and I'm trying to match my home configuration. One issue that is popping up is an OperationalError "MySQL server has gone away". Searching around the internet, people who come across this error tended to be inactive ...
MySQL server has gone away
I've recently moved from my local web.py/apache setup to a shared host and I'm trying to match my home configuration. One issue that is popping up is an OperationalError "MySQL server has gone away". Searching around the internet, people who come across this error tended to be inactive for the space of hours. This ha...
[ "Check the docs at: http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess\nSetting processes=1 actually leaves multiprocessing on, which may be why you're getting concurrent access to the same sql connection. \nAlso it appears you're using SQLAlchemy, so maybe try turning on QueuePool or N...
[ 1 ]
[]
[]
[ "mod_wsgi", "mysql", "python", "sqlalchemy", "web.py" ]
stackoverflow_0005097005_mod_wsgi_mysql_python_sqlalchemy_web.py.txt
Q: Nltk installation In want to setup python's nltk library including wordnet in such a way that it can be easily copied from development system to production server, without having requirement for downloading wordnet separately. Any suggestion would be helpful... A: When you download wordnet through NLTK it puts w...
Nltk installation
In want to setup python's nltk library including wordnet in such a way that it can be easily copied from development system to production server, without having requirement for downloading wordnet separately. Any suggestion would be helpful...
[ "When you download wordnet through NLTK it puts wordnet in the nltk_data folder on your system. On my system it's in the home folder. ~/nltk_data/corpora/wordnet The files of wordnet should be available there. You may be able to transfer those files to your production server and point nltk at them to find them....
[ 0 ]
[]
[]
[ "nlp", "nltk", "python", "wordnet" ]
stackoverflow_0003965850_nlp_nltk_python_wordnet.txt
Q: Python Regular Expression with optional but greedy groups I'm trying to write a regular expression to match a string that may or may not contain two tags. I need the expression to return me all five elements of the string, depending on whether they exist, but when I make the tags optional, the wildcard bits seem t...
Python Regular Expression with optional but greedy groups
I'm trying to write a regular expression to match a string that may or may not contain two tags. I need the expression to return me all five elements of the string, depending on whether they exist, but when I make the tags optional, the wildcard bits seem to gobble them up: Inputs could be: text{a}more{b}words {a}tex...
[ "Try the following regex: ^(.*(?={a})|.*?)({a})?(.*(?={b})|.*)({b})?(.*?)$\nimport re\n\ninputs = ['{a}text{b}test', 'text', 'text{b}text', 'text{b}', 'text{a}text']\np = re.compile(r\"^(.*(?={a})|.*?)({a})?(.*(?={b})|.*)({b})?(.*?)$\")\nfor input in inputs:\n print p.match(input).groups()\n\nOutput:\n('', '{a}'...
[ 4, 0, 0, 0, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0005095437_python_regex.txt
Q: Starting new project: database abstraction in Python, best practice for retaining option of MySQL or PostgreSQL without ORM I want to retain the flexibility of switching between MySQL and PostgreSQL without the awkwardness of using an ORM - SQL is a fantastic language and i would like to retain it's power without ...
Starting new project: database abstraction in Python, best practice for retaining option of MySQL or PostgreSQL without ORM
I want to retain the flexibility of switching between MySQL and PostgreSQL without the awkwardness of using an ORM - SQL is a fantastic language and i would like to retain it's power without the additional overhead of an ORM. So...is there a best practice for abstraction the database layer of a Python application to pr...
[ "While SQLAlchemy is a great option. There are others. If you find that SQLAlchemy is not to your liking here are some other ORMs that may work out better for you. Some of them are more lightweight, so it may be more what you're looking for.\nhttp://coobs.eu.org/xrecord/ -- From the description sounds like what ...
[ 2, 1 ]
[]
[]
[ "abstraction", "database", "mysql", "postgresql", "python" ]
stackoverflow_0005090901_abstraction_database_mysql_postgresql_python.txt
Q: Idiomatic List Wrapper In Google App Engine, I make lists of referenced properties much like this: class Referenced(BaseModel): name = db.StringProperty() class Thing(BaseModel): foo_keys = db.ListProperty(db.Key) def __getattr__(self, attrname): if attrname == 'foos': return Refe...
Idiomatic List Wrapper
In Google App Engine, I make lists of referenced properties much like this: class Referenced(BaseModel): name = db.StringProperty() class Thing(BaseModel): foo_keys = db.ListProperty(db.Key) def __getattr__(self, attrname): if attrname == 'foos': return Referenced.get(self.foo_keys) ...
[ "If you want to modify things like this, you shouldn't be changing __getattr__ on the model; instead, you should write a custom Property class.\nAs you've observed, though, creating a workable 'ReferenceListProperty' is difficult and involved, and there are many subtle edge cases. I would recommend sticking with th...
[ 2 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0005097047_google_app_engine_python.txt
Q: Killing individual Apache processes in mod_python We are having a problem with individual apache processes utilizing large amounts of memory, depending on the request, and never releasing it back to the main system. Since these requests can happen at any time, over time the web server is pushed into swap, renderi...
Killing individual Apache processes in mod_python
We are having a problem with individual apache processes utilizing large amounts of memory, depending on the request, and never releasing it back to the main system. Since these requests can happen at any time, over time the web server is pushed into swap, rendering it unresponsive even to SSH. Worse, after the reque...
[ "I'd say that even it is possible, it would be a tremendous hack (and instable) - you should set-up a process external to apache in this case, that would supervise running processes and kill an individual apache when it goes beyond memory/time predefined limits.\nSuch a script can be kept running continuously with ...
[ 0 ]
[]
[]
[ "apache", "mod_python", "python" ]
stackoverflow_0005096057_apache_mod_python_python.txt
Q: how to get feedparser to send a cache-control header? I'm using python feedparser in an aggregator client that runs behind a squid proxy. I want it to send a cache-control: max-age=600 header in the request, so that we get a reasonably up-to-date response. (At the moment the feeds are returned by the proxy from ...
how to get feedparser to send a cache-control header?
I'm using python feedparser in an aggregator client that runs behind a squid proxy. I want it to send a cache-control: max-age=600 header in the request, so that we get a reasonably up-to-date response. (At the moment the feeds are returned by the proxy from its cache, even days after they changed, which is reasonabl...
[ "It seems to me there are two ways:\n1- wait for http://code.google.com/p/feedparser/issues/detail?id=224 to be fixed. I put up a patch that lets you send extra_headers={'Cache-control': 'max-age=0'} and we'll see if they accept it.\n2- monkeypatch in to urllib2 to put some extra headers on the request, which seem...
[ 2, 2 ]
[]
[]
[ "feedparser", "http", "python", "rss" ]
stackoverflow_0003623460_feedparser_http_python_rss.txt
Q: Feedparser-basics how to I'm very new to Feedparser and have returned to Python after a long break so would appreciate any help. I've tried the docs, which are very good, but I'm still slightly lagging. How would I get Feedparser to take an rss feed and from that get the title and description of the first 10 item...
Feedparser-basics how to
I'm very new to Feedparser and have returned to Python after a long break so would appreciate any help. I've tried the docs, which are very good, but I'm still slightly lagging. How would I get Feedparser to take an rss feed and from that get the title and description of the first 10 items and label each item independ...
[ "import feedparser\nf = feedparser.parse('http://domain/feed')\n# f contains a dictionary key 'entries'\n# entries is a list of dictionaries with 'title' and 'content' keys\nfor e in f['entries']:\n print e.get('title', '')\n print e.get('summary', '')\n\nHope that helps.\n" ]
[ 6 ]
[]
[]
[ "feedparser", "python", "rss" ]
stackoverflow_0002326404_feedparser_python_rss.txt
Q: Handle Unicode characters with Python regexes I'm writing a simple application where I want to replace certain words with other words. I'm running into problems with words that use single quotes such as aren't, ain't, isn't. I have a text file with the following aren’t=ain’t hello=hey I parse the text file and cr...
Handle Unicode characters with Python regexes
I'm writing a simple application where I want to replace certain words with other words. I'm running into problems with words that use single quotes such as aren't, ain't, isn't. I have a text file with the following aren’t=ain’t hello=hey I parse the text file and create a dictionary out of it u'aren\u2019t' = u'ain\...
[ "I guess your problem is:\ntext = u\"aren't\"\n\ninstead of:\ntext = u\"aren’t\"\n\n(note the different apostrophes?)\nHere's your code modified to make it work:\n#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport re\n\nd = {\n u'aren’t': u'ain’t',\n u'hello': u'hey'\n }\n#text = u\"aren't\"\ntext = ...
[ 3, 0, 0, 0 ]
[]
[]
[ "python", "regex", "unicode", "utf_8" ]
stackoverflow_0005098151_python_regex_unicode_utf_8.txt
Q: python lambda, filtering out non alpha characters i'm trying to keep only the letters in a string. i am trying to do something like this: s = '1208uds9f8sdf978qh39h9i#H(&#*H(&H97dgh' s_ = lambda: letter if letter.isalpha(), s this errors out. how would a working version look? A: Alternately: s_ = filter(lambda ...
python lambda, filtering out non alpha characters
i'm trying to keep only the letters in a string. i am trying to do something like this: s = '1208uds9f8sdf978qh39h9i#H(&#*H(&H97dgh' s_ = lambda: letter if letter.isalpha(), s this errors out. how would a working version look?
[ "Alternately:\ns_ = filter(lambda c: c.isalpha(), s)\n\n", "how about\nre.sub('[^a-zA-Z]','', s)\n\nor\n\"\".join([x for x in s if x.isalpha()])\n\n", "You don't need a lambda function:\nresult = ''.join(c for c in input_str if c.isalpha())\n\nIf you really want to use a lambda function you could write it as fo...
[ 5, 4, 3, 3, 1, 0, 0 ]
[]
[]
[ "lambda", "python" ]
stackoverflow_0005097092_lambda_python.txt
Q: PIP and SlikSVN under a proxy I am trying to checkout a subversion repository using PIP, since I am under a proxy I am calling PIP using the --proxy parameter: pip install svn+http://django-compress.googlecode.com/svn/trunk/ --proxy=myproxy:8080 While PIP itself works fine under the proxy, it seen that its not p...
PIP and SlikSVN under a proxy
I am trying to checkout a subversion repository using PIP, since I am under a proxy I am calling PIP using the --proxy parameter: pip install svn+http://django-compress.googlecode.com/svn/trunk/ --proxy=myproxy:8080 While PIP itself works fine under the proxy, it seen that its not passing the proxy parameter to the S...
[ "It is an open bug[1] and there is not solution to this problem right now.\nIf you find an answer, please, comment in pip's issue tracker.\n[1] - https://github.com/pypa/pip/issues/227\n" ]
[ 2 ]
[]
[]
[ "pip", "proxy", "python", "svn" ]
stackoverflow_0005085545_pip_proxy_python_svn.txt
Q: Google App Engine: how to tell sort location for a user value? In my Main model I have a total_value and I sort with this value. When a user enters a value I wish to tell the user the order of his total_value. How do I do this? In other words, if total_values in database are 5,8,10,25 and a user enters a total_val...
Google App Engine: how to tell sort location for a user value?
In my Main model I have a total_value and I sort with this value. When a user enters a value I wish to tell the user the order of his total_value. How do I do this? In other words, if total_values in database are 5,8,10,25 and a user enters a total_value of 15 how do I tell him that he will be in the 4th place? Thanks...
[ "You need to write a query which counts the number of values smaller than the user's total_value. This may be slow if there are many Main entities. In that case, you may wish to only count the first N values smaller, and then stop (e.g., tell the user they are ranked 1000+). Your query might look like this:\n# g...
[ 2, 2, 1 ]
[]
[]
[ "google_app_engine", "python", "sorting" ]
stackoverflow_0005099012_google_app_engine_python_sorting.txt
Q: Finding words that are the reverse of each other in a file Sorry for this newbie question, just got starting. I want a simple program to look in a file for reverse words, so a wrote this source, but it doesn't work. After it goes into the second "for" loop, it doesn't go back to the first loop, instead it ends the...
Finding words that are the reverse of each other in a file
Sorry for this newbie question, just got starting. I want a simple program to look in a file for reverse words, so a wrote this source, but it doesn't work. After it goes into the second "for" loop, it doesn't go back to the first loop, instead it ends the program. Any clue? def is_reverse(word1, word2): if len(w...
[ "for word1 in fin iterates line-by-line, so word1 is really a line, not a word. Is that what you intended?\nfor word2 in fin is using the same iterator, so I think it will consume all the input, and for word1 in fin will only be done once.\nSo the simplest change is to have two files, file1 and file2, and re-open ...
[ 3, 1, 0, 0 ]
[]
[]
[ "file", "for_loop", "iterator", "loops", "python" ]
stackoverflow_0005097663_file_for_loop_iterator_loops_python.txt
Q: Need help with Classes in Python I'm making a program that imports a custom widget that is a class (it inherits from the Tkinter Frame widget). It all works great until I get to binding. To reduce confusion we'll call the main application app, the module it's importing the widget from lib, and the widget that's be...
Need help with Classes in Python
I'm making a program that imports a custom widget that is a class (it inherits from the Tkinter Frame widget). It all works great until I get to binding. To reduce confusion we'll call the main application app, the module it's importing the widget from lib, and the widget that's being imported into app will be called c...
[ "I think you just want:\nloc = app.EOG()\n\nThen, loc is an instance of EOG, and loc.element_click is a bound method, so it works as intended.\n" ]
[ 2 ]
[]
[]
[ "class", "import", "module", "python", "tkinter" ]
stackoverflow_0005099592_class_import_module_python_tkinter.txt
Q: Python modulus result is incorrect I am totally stumped. I was computing the cipher of the number 54 in RSA with the following values: p=5; q=29; n=145 d=9; e=137 So the number 54 encrypted would be: 54^137 mod 145 or equivalently in python: import math math.pow(54,137)%145 My calculator gives me 24, my python st...
Python modulus result is incorrect
I am totally stumped. I was computing the cipher of the number 54 in RSA with the following values: p=5; q=29; n=145 d=9; e=137 So the number 54 encrypted would be: 54^137 mod 145 or equivalently in python: import math math.pow(54,137)%145 My calculator gives me 24, my python statement gives me 54.0. Python is clearly...
[ ">>> pow(54,137,145)\n24\n\nmath.pow is floating point. You don't want that. Floating-point values have less than 17 digits of useful precision. The 54**137 has 237 digits.\n", "That's because using the math module is basically just a Python wrapper for the C math library which doesn't have arbitrary precision...
[ 14, 9 ]
[]
[]
[ "python" ]
stackoverflow_0005099745_python.txt
Q: connecting Python 2.6.1 with MySQLdb I am using Python 2.6.1 and I want to connect to MySQLdb, I installed mySQL in my system, and I am trying to connect MySQL-python-1.2.2.win32-py2.6 from http://www.codegood.com/archives/4 site but its not working while running my application its saying that No module named MyS...
connecting Python 2.6.1 with MySQLdb
I am using Python 2.6.1 and I want to connect to MySQLdb, I installed mySQL in my system, and I am trying to connect MySQL-python-1.2.2.win32-py2.6 from http://www.codegood.com/archives/4 site but its not working while running my application its saying that No module named MySQLdb please any one provide me the proper ...
[ "The best setup for Windows that I've found:\nhttp://www.codegood.com/downloads?dl_cat=2\nEDIT: Removed original link (it's an ad farm now :( )\n", "The module is not likely in your python search path..\nCheck to see if that module is in your Python Path... In windows...you may find it in the registry\nHKLM\\Soft...
[ 13, 4, 2, 0, 0, 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0001135625_mysql_python.txt
Q: pyqt, webkit and facebook authentication? Are there any examples how to authenticate your desktop Facebook application using PyQT and embedded webkit? This is to provide better user experience than opening Facebook authentication page in a separate browser window. A: I don't believe you can open an "authentica...
pyqt, webkit and facebook authentication?
Are there any examples how to authenticate your desktop Facebook application using PyQT and embedded webkit? This is to provide better user experience than opening Facebook authentication page in a separate browser window.
[ "I don't believe you can open an \"authentication page\" in a separate window under Facebook's terms (I used to work for Zynga, and we couldn't then, so I don't know how you'd achieve this now legally). \nSecond, you're looking into the QWebkit backwards I believe. From a UI perspective this is supposed to provide ...
[ 0 ]
[]
[]
[ "facebook", "pyqt", "python", "webkit" ]
stackoverflow_0003371549_facebook_pyqt_python_webkit.txt
Q: Binary Data To Unicode Among all the encodings available here http://docs.python.org/library/codecs.html which one is the one I should use for decoding binary data into unicode without it becoming corrupted when I encode it back to string? I've used raw_unicode_data and it doesn't work. Example: I upload picture i...
Binary Data To Unicode
Among all the encodings available here http://docs.python.org/library/codecs.html which one is the one I should use for decoding binary data into unicode without it becoming corrupted when I encode it back to string? I've used raw_unicode_data and it doesn't work. Example: I upload picture in a POST (but not as file at...
[ "If you want to post binary data use the base64 encoding.\nhttp://docs.python.org/library/base64.html\n", "\"Binary data\" is not text, therefore converting it to a unicode is meaningless. If there is text embedded in the binary data then extract it first and decode using the encoding given in the specification f...
[ 7, 3, 1 ]
[]
[]
[ "binary", "character_encoding", "encoding", "python", "unicode" ]
stackoverflow_0005094919_binary_character_encoding_encoding_python_unicode.txt
Q: Figuring out what REALLY went wrong when an `ImportError` is raised Take Django for instance, in manage.py: try: import settings except ImportError: sys.stderr.write("Error: Can't find the file 'settings.py'...") Seems legit, but what happens when settings imports non_existant_lib_foo? Well, you're sent o...
Figuring out what REALLY went wrong when an `ImportError` is raised
Take Django for instance, in manage.py: try: import settings except ImportError: sys.stderr.write("Error: Can't find the file 'settings.py'...") Seems legit, but what happens when settings imports non_existant_lib_foo? Well, you're sent on a goose chase for all the possible things you could have done with PATH...
[ "Basically the problem is that your error message is wrong - there are other reasons why import can fail, not just wrong paths. ImportError simply means \"you cannot use this module, look at the traceback to find out why\", you just jumped to a conclusion. \nIf you want to display \"Can't find the file\" then you ...
[ 5, 1 ]
[ "\nOne thing I've found really frustrating is that when you trap an import error you're really going down a deep rabbit hole right away.\n\nTake the hint.\nDo not trap import errors ever. The manage.py example is not a best practice.\nDo not do that.\nimport errors should be very, very rare.\n" ]
[ -2 ]
[ "exception", "python", "python_import" ]
stackoverflow_0005099931_exception_python_python_import.txt
Q: Can python modules be used from Java programs using Jython without modification? Can Python code be used from Java using Jython, without modifying the Python code in a way which will prevent it from working correctly in CPython? If yes, what steps would have to be taken (in the Java code)? If not, what are the rea...
Can python modules be used from Java programs using Jython without modification?
Can Python code be used from Java using Jython, without modifying the Python code in a way which will prevent it from working correctly in CPython? If yes, what steps would have to be taken (in the Java code)? If not, what are the reasons that this cannot be done (so far)?
[ "\nPython modules can depend on certain Python versions (e.g. Python 3 vs Python 2 and even may require a minimum Python version (e.g. 2.6) in case of using dedicated language features introduced in some Python version)\nPython modules may depend on C extensions which won't work with Jython\nPython modules may use ...
[ 3 ]
[]
[]
[ "cpython", "java", "jython", "python" ]
stackoverflow_0005099816_cpython_java_jython_python.txt
Q: Upstart problem with virtualenv - Python/Ubuntu I'm using upstart in order to start this script: pre-start script sudo export WORKON_HOME=~/.envs sudo source /usr/local/bin/virtualenvwrapper.sh sudo workon env1 end script start on runlevel [2345] stop on runlevel [!2345] exec python /home/radiant/www...
Upstart problem with virtualenv - Python/Ubuntu
I'm using upstart in order to start this script: pre-start script sudo export WORKON_HOME=~/.envs sudo source /usr/local/bin/virtualenvwrapper.sh sudo workon env1 end script start on runlevel [2345] stop on runlevel [!2345] exec python /home/radiant/www/staging/django_project/manage.py celerycam > /home/r...
[ "I'm not an upstart expert - but I think the problem is that you're trying to sudo those commands. If upstart is using the stock \"sudo\", you're trying to run shell functions as commands - which you can't do.\nTry dropping the sudo part of this to see if it works.\npre-start script\n export WORKON_HOME=~/.envs...
[ 2, 1 ]
[]
[]
[ "django", "python", "ubuntu", "upstart", "virtualenv" ]
stackoverflow_0004555602_django_python_ubuntu_upstart_virtualenv.txt
Q: Python wmi c.Win32_PerfFormattedData_PerfOS_Processor win7 error >>> for i in c.Win32_PerfFormattedData_PerfOS_Processor(): ... print i ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "c:\work\pythonsv\vendor\wmi.py", line 1029, in __getattr__ return getattr (self._namesp...
Python wmi c.Win32_PerfFormattedData_PerfOS_Processor win7 error
>>> for i in c.Win32_PerfFormattedData_PerfOS_Processor(): ... print i ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "c:\work\pythonsv\vendor\wmi.py", line 1029, in __getattr__ return getattr (self._namespace, attribute) File "C:\Python25\Lib\site-packages\win32com\client\...
[ "AttributeError means that the object c doesn't have an attribute Win32_PerfFormattedData_PerfOS_Processor.\nThe \"\" indicates that Python asked c to describe itself and c returned the string \"\" (which obviously isn't terribly helpful). It appears you've created c, so it would illuminate the problem more if you ...
[ 0, 0 ]
[]
[]
[ "python", "windows_7", "wmi" ]
stackoverflow_0005076755_python_windows_7_wmi.txt
Q: Difference of calling inherited methods in subclass? For Python 2.5 and later, with new style class, what's the difference of the following code snippets for invoking inherited methods in a subclass? class A(object): def foo(self): pass class B(A): def __init__(self): self.foo() class C(A...
Difference of calling inherited methods in subclass?
For Python 2.5 and later, with new style class, what's the difference of the following code snippets for invoking inherited methods in a subclass? class A(object): def foo(self): pass class B(A): def __init__(self): self.foo() class C(A): def __init__(self): super(C, self).foo()
[ "As long as you are dealing with single inheritance classes like the example you gave,\nthere is not much difference. In either case, python uses the method resolution order(mro), \n(which you can examine by printing C.__mro__) to find out the first occurance of the method\nfoo. These both resolve to your base clas...
[ 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005100688_python.txt
Q: Python: Inject attribute into object created by C library I'm trying to inject an attribute into lxml.etree._Element, but as that module is completely implemented in C, setattr fails: Traceback (most recent call last): [...] setattr(node.getroottree().getroot(), "attributeName", value) AttributeError: 'lxml.et...
Python: Inject attribute into object created by C library
I'm trying to inject an attribute into lxml.etree._Element, but as that module is completely implemented in C, setattr fails: Traceback (most recent call last): [...] setattr(node.getroottree().getroot(), "attributeName", value) AttributeError: 'lxml.etree._Element' object has no attribute 'attributeName' The use ...
[ "You generally can't, as instances of C-defined types typically don't have per-instance __dict__ entries to hold arbitrary attributes.\nA workaround for cases when a subclass or wrapper class won't work is to create a helper dictionary at the module level that maps the object you have to additional information. If ...
[ -1 ]
[]
[]
[ "code_injection", "lxml", "python", "setattr" ]
stackoverflow_0005101701_code_injection_lxml_python_setattr.txt
Q: How does Apache know the names of the handlers in each module? I was reading the following: http://modules.apache.org/doc/API.html Please explain how Apache knows the name of the handler to call. The CGI Module has the following handlers: int translate_scriptalias (request_rec *); int type_scriptalias (request_rec...
How does Apache know the names of the handlers in each module?
I was reading the following: http://modules.apache.org/doc/API.html Please explain how Apache knows the name of the handler to call. The CGI Module has the following handlers: int translate_scriptalias (request_rec *); int type_scriptalias (request_rec *); int cgi_handler (request_rec *); Another module might have som...
[ "They're (eventually) members of the module struct at the bottom of the first snippet.\n" ]
[ 0 ]
[]
[]
[ "apache", "apache_modules", "python" ]
stackoverflow_0005101617_apache_apache_modules_python.txt
Q: Evaluating subset of a list using in operator I have following test code. a = ['a', 'b', 'c', 'd', 'e'] c = a * 3 b = a but b in c returns False. b is a sub sequence of c and the list c contains b. So why is it returning false? Thanks in advance. A: b in c Does not work because b looks like: ['a', 'b', 'c', 'd...
Evaluating subset of a list using in operator
I have following test code. a = ['a', 'b', 'c', 'd', 'e'] c = a * 3 b = a but b in c returns False. b is a sub sequence of c and the list c contains b. So why is it returning false? Thanks in advance.
[ "b in c\n\nDoes not work because b looks like:\n['a', 'b', 'c', 'd', 'e']\n\nand c looks like:\n['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e']\n\nIn other words, b is not an element of the sequence. Instead, b is a subsequence. If you were to construct c as follows:\nc = [a, a, a]\n\n...
[ 5, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005101199_python.txt
Q: What is the best way to build a database from a MS Word document? Please advise me on how to approach this problem: I have a sequential list of metadata in a document in MS Word. The basic idea is to create a Python algorithm to iterate over the information, retrieving just the name of the PROCESS, when is made a ...
What is the best way to build a database from a MS Word document?
Please advise me on how to approach this problem: I have a sequential list of metadata in a document in MS Word. The basic idea is to create a Python algorithm to iterate over the information, retrieving just the name of the PROCESS, when is made a queue, from a database. Example metadata: Process: Process Walker (196...
[ "Check out AntiWord for converting the document to plaintext, then grep and sed to convert to a format you can pipe into your script.\n", "Recent versions of Word allow you to save documents in XML format. This can either be done by explicitly \"saving as\" and choosing XML, or unzipping a .docx file and parsing ...
[ 3, 2 ]
[]
[]
[ "algorithm", "database", "python" ]
stackoverflow_0005102333_algorithm_database_python.txt
Q: Convert a tuple into a dictionary I've looked all over the internet and consulted a few books but I can't seem to find an example that illustrates what I am trying to do. I loathe to ask this on SO because it feels like a really basic question but I've been banging my head against the wall for the last few hours s...
Convert a tuple into a dictionary
I've looked all over the internet and consulted a few books but I can't seem to find an example that illustrates what I am trying to do. I loathe to ask this on SO because it feels like a really basic question but I've been banging my head against the wall for the last few hours so here it goes: How do i turn this: ...
[ "{'item': [dict(value=value, label=label) for value, label in item]}\n\n", ">>> item = ((100,'May'),(160,'June'),(300,'July'),(140,'August'))\n>>> keys = ('value','label')\n>>> dd = {'item' : [dict(zip(keys,pair)) for pair in item]}\n>>>\n>>> import pprint\n>>> pprint.pprint(dd)\n{'item': [{'label': 'May', 'value...
[ 9, 1, 0 ]
[]
[]
[ "dictionary", "python", "tuples" ]
stackoverflow_0005102477_dictionary_python_tuples.txt
Q: Syntax error in urls.py . How to debug it? The error is this "\t(r'ajax/lookup/^$','ajaxlookup',name='ajax_lookup'),\n")) I have installed geonode and in that I have put ajax_select to do autocomplete. But my URLs.py is giving an error My urls.py looks like this from django.conf.urls.defaults import patterns,...
Syntax error in urls.py . How to debug it?
The error is this "\t(r'ajax/lookup/^$','ajaxlookup',name='ajax_lookup'),\n")) I have installed geonode and in that I have put ajax_select to do autocomplete. But my URLs.py is giving an error My urls.py looks like this from django.conf.urls.defaults import patterns, url js_info_dict = { 'packages': ('geonode...
[ "Tuples do not support keyword arguments. Convert the entry to a url() call.\n", "it should be: \nurlpatterns += patterns('geonode.ajax_select.views',\n (r'^ajax/lookup/$','ajaxlookup',name='ajax_lookup'),\n )\n\nthe \"^\" was at the end :)\n" ]
[ 2, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0005102407_django_python.txt
Q: .PY into .EXE Python 2.6 I'm trying to convert my .PY script into a .EXE file, in the process I have tried PY2EXE with the following command line.. python C:\Users\Noob\Desktop\setup.py py2exe -p ftplib -> -p ftplib is for my module import. When I use this code, I'm left with an .EXE and a bunch of files, if I tak...
.PY into .EXE Python 2.6
I'm trying to convert my .PY script into a .EXE file, in the process I have tried PY2EXE with the following command line.. python C:\Users\Noob\Desktop\setup.py py2exe -p ftplib -> -p ftplib is for my module import. When I use this code, I'm left with an .EXE and a bunch of files, if I take the .EXE out then it will co...
[ "You should not be taking the exe out of your folder and executing. Just execute it from the dist directory where got created, it has the python26.dll which the executable needs. If you want to ship it, zip the dist directory and ship it. Otherwise you have to create an installer using specific installer software l...
[ 1, 1 ]
[]
[]
[ "py2exe", "python", "sockets" ]
stackoverflow_0005099830_py2exe_python_sockets.txt
Q: ignoring manage.py with Mercurial (hg .hgignore) i'm using mercurial for my project in Django, and i need to ignore the manage.py. I've my .hgignore like this syntax: glob *.pyc *.html~ *.js~ manage.py settings_local.py media/ when i make changes to settings_local.py it working fine, but when i change manage.py t...
ignoring manage.py with Mercurial (hg .hgignore)
i'm using mercurial for my project in Django, and i need to ignore the manage.py. I've my .hgignore like this syntax: glob *.pyc *.html~ *.js~ manage.py settings_local.py media/ when i make changes to settings_local.py it working fine, but when i change manage.py the .hgignore does not work Thanks in advance!!
[ "The .hgignore file only tells relevant commands to avoid picking up new files when you ask them to find files to add to your repository by scanning the directories and finding new and removed files.\nThe two I can remember, there might be more, are:\nhg addremove\nhg commit --addremove\n\nThat's it. If you either ...
[ 4, 3, 1 ]
[]
[]
[ "django", "hgignore", "mercurial", "python" ]
stackoverflow_0005097864_django_hgignore_mercurial_python.txt
Q: Writing python script for a Mac on a linux or windows machine I wrote a python script for a friend to make a job task easier. Now her company wants to pay me for another script (woot!). However she works on a Mac and I have only a Windows pc and an Ubuntu pc. While python is multi-platform, I ran into a problem wi...
Writing python script for a Mac on a linux or windows machine
I wrote a python script for a friend to make a job task easier. Now her company wants to pay me for another script (woot!). However she works on a Mac and I have only a Windows pc and an Ubuntu pc. While python is multi-platform, I ran into a problem with the first script that was only happening on her Mac. So is there...
[ "As long as you stick to the common and POSIX/UNIX interfaces, it will work equally fine on both Ubuntu and OS X barring any deep magic. Since you haven't described the problem, that's the only advice that can be given.\n", "Questions about OS emulators are probably better placed at http://superuser.com (but I'm ...
[ 1, 0 ]
[]
[]
[ "multiplatform", "python" ]
stackoverflow_0005102909_multiplatform_python.txt
Q: find the "overlap" between 2 python lists Given 2 lists: a = [3,4,5,5,5,6] b = [1,3,4,4,5,5,6,7] I want to find the "overlap": c = [3,4,5,5,6] I'd also like it if i could extract the "remainder" the part of a and b that's not in c. a_remainder = [5,] b_remainder = [1,4,7,] Note: a has three 5's in it and b has ...
find the "overlap" between 2 python lists
Given 2 lists: a = [3,4,5,5,5,6] b = [1,3,4,4,5,5,6,7] I want to find the "overlap": c = [3,4,5,5,6] I'd also like it if i could extract the "remainder" the part of a and b that's not in c. a_remainder = [5,] b_remainder = [1,4,7,] Note: a has three 5's in it and b has two. b has two 4's in it and a has one. The res...
[ "collection.Counter available in Python 2.7 can be used to implement multisets that do exactly what you want.\na = [3,4,5,5,5,6]\nb = [1,3,4,4,5,5,6,7]\n\na_multiset = collections.Counter(a)\nb_multiset = collections.Counter(b)\n\noverlap = list((a_multiset & b_multiset).elements())\na_remainder = list((a_multiset ...
[ 22, 15, 6, 4, 2, 1, 0 ]
[ "I don't think you should actually use this solution, but I took this opportunity to practice with lambda functions and here is what I came up with :)\na = [3,4,5,5,5,6]\nb = [1,3,4,4,5,5,6,7]\ndedup = lambda x: [set(x)] if len(set(x)) == len(x) else [set(x)] + dedup([x[i] for i in range(1, len(x)) if x[i] == x[i-1...
[ -1 ]
[ "list", "python" ]
stackoverflow_0005094083_list_python.txt
Q: py2exe + sqlalchemy + sqlite problem I am playing around with getting some basic stuff to work in Python before i go into full speed dev mode. Here are the specifics: Python 2.5.4 PyQt4 4.4.3 SqlAlchemy 0.5.2 py2exe 0.6.9 setuptools 0.6c9 pysqlite 2.5.1 setup.py: from distutils.core import setup import py2exe se...
py2exe + sqlalchemy + sqlite problem
I am playing around with getting some basic stuff to work in Python before i go into full speed dev mode. Here are the specifics: Python 2.5.4 PyQt4 4.4.3 SqlAlchemy 0.5.2 py2exe 0.6.9 setuptools 0.6c9 pysqlite 2.5.1 setup.py: from distutils.core import setup import py2exe setup(windows=[{"script" : "main.py"}], opti...
[ "you need to include the sqlalchemy.databases.sqlite package\nsetup(\n windows=[{\"script\" : \"main.py\"}],\n options={\"py2exe\" : {\n \"includes\": [\"sip\", \"PyQt4.QtSql\"],\n \"packages\": [\"sqlalchemy.databases.sqlite\"]\n}})\n\n", "you need change to sqlalchemy.dialects.sqlite package\nsetup(\n ...
[ 31, 5 ]
[]
[]
[ "py2exe", "python", "sqlalchemy", "sqlite" ]
stackoverflow_0000582449_py2exe_python_sqlalchemy_sqlite.txt
Q: shell with django environment in eclipse,pydev giving syntax error ``>>>python manage.py syncdb File "<console>", line 1 python manage.py syncdb SyntaxError: invalid syntax ^`` What could the problem be? Extra Info if it might help - Python - 2.6 Django - 1.2.5 Eclipse - 3.6.0 Pydev - 1....
shell with django environment in eclipse,pydev giving syntax error
``>>>python manage.py syncdb File "<console>", line 1 python manage.py syncdb SyntaxError: invalid syntax ^`` What could the problem be? Extra Info if it might help - Python - 2.6 Django - 1.2.5 Eclipse - 3.6.0 Pydev - 1.6.5
[ "Yeah, @chris is right, your trying to run a file with a Python interpreter from within an interactive shell.\nIf you add Django (org.python.pydev.django.djangoNature) to the list of your project natures, you can then right click on your project in the resources view and you then have the Django submenu from where ...
[ 0 ]
[]
[]
[ "django", "eclipse", "pydev", "python", "shell" ]
stackoverflow_0005102530_django_eclipse_pydev_python_shell.txt
Q: How to escape character '.' in python string replacement via the operator % I want to do the following "@file %(unitname).C" % {'unitname':'Test'} but it complains about the '.C'. How can I escape the '.' character? A: You don't. You fix the format specifier. "@file %(unitname)s.C" % {'unitname':'Test'} A: An...
How to escape character '.' in python string replacement via the operator %
I want to do the following "@file %(unitname).C" % {'unitname':'Test'} but it complains about the '.C'. How can I escape the '.' character?
[ "You don't. You fix the format specifier.\n\"@file %(unitname)s.C\" % {'unitname':'Test'}\n\n", "Another option is,\n\"@file {unitname}.C\".format(unitname='Test')\n\nThis may be preferable, since format() will be the new standard in Python 3.\n" ]
[ 7, 0 ]
[]
[]
[ "formatting", "python", "string" ]
stackoverflow_0005102099_formatting_python_string.txt
Q: How to call a function in a pyGTK timeout? When I try to call a function using a timeout in pyGtk, I receive the error message TypeError: second argument not callable. All I want to do is call a very simple function from within the time out. To illustrate my proble, I have simply prepared the function do_nothing t...
How to call a function in a pyGTK timeout?
When I try to call a function using a timeout in pyGtk, I receive the error message TypeError: second argument not callable. All I want to do is call a very simple function from within the time out. To illustrate my proble, I have simply prepared the function do_nothing to illustrate my problem. def do_nothing(self): ...
[ "You're calling the function:\nself.do_nothing()\n\nYou want to pass the function:\nself.do_nothing\n\nOmit the parentheses.\n", "Pass self.do_nothing and not self.do_nothing()\nself.do_nothing is callable \n\nself.do_nothing() returns a value and that return value is not a callable \n", "try instead:\nself.che...
[ 6, 1, 1 ]
[]
[]
[ "pygtk", "python" ]
stackoverflow_0004060324_pygtk_python.txt
Q: Python - decorator - trying to access the parent class of a method This doesn't work: def register_method(name=None): def decorator(method): # The next line assumes the decorated method is bound (which of course it isn't at this point) cls = method.im_class cls.my_attr = 'FOO BAR' ...
Python - decorator - trying to access the parent class of a method
This doesn't work: def register_method(name=None): def decorator(method): # The next line assumes the decorated method is bound (which of course it isn't at this point) cls = method.im_class cls.my_attr = 'FOO BAR' def wrapper(*args, **kwargs): method(*args, **kwargs) ...
[ "I don't think you can do what you want to do with a decorator (quick edit: with a decorator of the method, anyway). The decorator gets called when the method gets constructed, which is before the class is constructed. The reason your code isn't working is because the class doesn't exist when the decorator is calle...
[ 8, 2 ]
[]
[]
[ "decorator", "python" ]
stackoverflow_0003885459_decorator_python.txt
Q: webservices in python i want to create a webservice (SOAP & REST) in python which cab be called from iphone, now i have install python 2.7.1 on Ubuntu 10.04.2 LTS using Putty. so now i am searching for a nice and easy framework that helps me in creating webservices and web programming. I have searched a lot but c...
webservices in python
i want to create a webservice (SOAP & REST) in python which cab be called from iphone, now i have install python 2.7.1 on Ubuntu 10.04.2 LTS using Putty. so now i am searching for a nice and easy framework that helps me in creating webservices and web programming. I have searched a lot but confused with the combinatio...
[ "Duplicate of \nPython soap using soaplib (server) and suds (client)\nSuds/soaplib is fine for working wit SOAP client/server side.\nREST is a different story. I think you should first choose one of the many Python web-frameworks.\n\"Pyramid\" - part of the Pylons projects - is a very strong but open-to-all-sides w...
[ 1, 0 ]
[]
[]
[ "frameworks", "python", "web_services" ]
stackoverflow_0005104215_frameworks_python_web_services.txt
Q: developing a chat website I want to develop a anonymous chat website like http://omgele.com. I know that this website is developed in python using twisted matrix framework. Using twisted matrix it's easy to develop such website. But I am very comfortable in Java and have 1 year's experience with it, and dont kn...
developing a chat website
I want to develop a anonymous chat website like http://omgele.com. I know that this website is developed in python using twisted matrix framework. Using twisted matrix it's easy to develop such website. But I am very comfortable in Java and have 1 year's experience with it, and dont know python. What should I do? S...
[ "Learn python. \nThis will add one very powerful tool to your toolbox. \nAlso twisted can do much more than just chat which will help you in future.\n", "I would politely ask the people at omgele.com for a copy of their code and study it to \n\nlearn Python and twisted matrix\ndecide to use it or if I decide agai...
[ 6, 1, 1, 0, 0 ]
[]
[]
[ "chat", "java", "python", "twisted" ]
stackoverflow_0002460407_chat_java_python_twisted.txt
Q: How to get max id of ticket list in a trac environment? I'm developing a small utility script for trac which needs to know which is the max ticket id present in each environment. At this time (with trac 0.11) I'm getting this extracting directly from the trac database with sqlite api, but since we have several env...
How to get max id of ticket list in a trac environment?
I'm developing a small utility script for trac which needs to know which is the max ticket id present in each environment. At this time (with trac 0.11) I'm getting this extracting directly from the trac database with sqlite api, but since we have several environments with different database systems, the intended small...
[ "Why do you need to write custom code for the DB connection? There are Trac objects for getting a database connection that abstracts from the actual DB backend.\nSee the Trac Database API. For 0.11, you should use Environment.get_db_cnx(), get a Cursor object with the .cursor() method and run your query.\n", "One...
[ 2, 1 ]
[]
[]
[ "command_line", "python", "trac" ]
stackoverflow_0005104210_command_line_python_trac.txt
Q: Python/Django AMQP? I have a Django web application which creates and saves jobs in a database. For every job I have to send email and export data to another system. I want to make asynchronous. What is the recommended way to do tasks like this? It has to be reliable (no jobs missed if the service is stopped acc...
Python/Django AMQP?
I have a Django web application which creates and saves jobs in a database. For every job I have to send email and export data to another system. I want to make asynchronous. What is the recommended way to do tasks like this? It has to be reliable (no jobs missed if the service is stopped accidentally). There has to...
[ "I would look into using http://celeryproject.org/ and in your case you could probably use https://github.com/ask/django-celery to simplify integration with your existing application although using celery yourself within your django project should be pretty straightforward as well.\nCelery provides a function/class...
[ 6, 1 ]
[]
[]
[ "amqp", "django", "message_queue", "python" ]
stackoverflow_0005105279_amqp_django_message_queue_python.txt
Q: run python module without the pyc extension I have a compiled Python 2.6 program on Linux called abc.pyc. If I run ./abc.pyc it runs fine. However if I rename it to abc (i.e, without the pyc extension) it fails to run. It gives the error message: ImportError: No module named abc How can I run my program without...
run python module without the pyc extension
I have a compiled Python 2.6 program on Linux called abc.pyc. If I run ./abc.pyc it runs fine. However if I rename it to abc (i.e, without the pyc extension) it fails to run. It gives the error message: ImportError: No module named abc How can I run my program without the .pyc extension? UPDATED: I want to run the c...
[ "Create a file named 'abc' which contains:\n#!/bin/sh\n/usr/bin/env python -m abc\n\nor is that giving away too much valuable source code if they can read that?\nNote also that .pyc files aren't portable between different versions of Python. Redistributing the source really would be best for that reason quite apart...
[ 6, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0005105271_python.txt
Q: Submit button still sends email I have a view called send_confirmation email - which basically sends emails. I want to add a button that can delete an order no. on that same form. Unfortunately. If I add a button that says to delete that order, then, for some reason, my program thinks that this is the send mail bu...
Submit button still sends email
I have a view called send_confirmation email - which basically sends emails. I want to add a button that can delete an order no. on that same form. Unfortunately. If I add a button that says to delete that order, then, for some reason, my program thinks that this is the send mail button and will instead send an email e...
[ "First of all, your code would submit a confirmation regardless of delete.\nSecond, your request.POST.get('delete') is failing, because there is no 'delete' in POST. \nSet the submit button name attribute to 'delete': <input type=\"submit\" name=\"delete\" />\ndef send_confirmation_email(request, order_no = 0, serv...
[ 0 ]
[]
[]
[ "django", "email", "html", "python" ]
stackoverflow_0005105493_django_email_html_python.txt
Q: Python Map in Class functions Very simple I have this: for i in self.Abilities: i.OnTimer(amount) Can i have something like this instead? map(Ability.OnTimer,self.Abilities,amount) I want to use map with class functions but i can't get it to work. A: You should use map to calculate a list of values, not fo...
Python Map in Class functions
Very simple I have this: for i in self.Abilities: i.OnTimer(amount) Can i have something like this instead? map(Ability.OnTimer,self.Abilities,amount) I want to use map with class functions but i can't get it to work.
[ "You should use map to calculate a list of values, not for its side effects. If you're performing a sequence of actions, it's more readable to use the for loop. People will more easily understand the intent of your code.\n", "You could use functools.partial to provide arguments to a function before calling it:\...
[ 6, 4 ]
[]
[]
[ "python" ]
stackoverflow_0005105555_python.txt
Q: Losing variable scope inside a Python decorator This simple decorator works as expected: def protect(*permissions): def outer(f): def inner(*args): print permissions[0] return f(*args) return inner return outer @protect('protected') def func(var): return var...
Losing variable scope inside a Python decorator
This simple decorator works as expected: def protect(*permissions): def outer(f): def inner(*args): print permissions[0] return f(*args) return inner return outer @protect('protected') def func(var): return var print func('something') The output is: protected s...
[ "In my mind I could figure out what is going on - let me try to spell it out:\nit has to do with Python not \"perceiving\" the \"permissions\" variable as existing on the scopes outside the \"inner\" function - since when \"inner\" itself is defined, \"permissions\" would long have been defined in the 'outsidemost'...
[ 1, 0 ]
[]
[]
[ "decorator", "python", "scope" ]
stackoverflow_0005096765_decorator_python_scope.txt
Q: Enlarging plot in mplot3D I'm trying to compose an image with both 2D and 3D plot. so far I've done the following: import idlsave import matplotlib from matplotlib import * import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.patches import Ellipse from matplot...
Enlarging plot in mplot3D
I'm trying to compose an image with both 2D and 3D plot. so far I've done the following: import idlsave import matplotlib from matplotlib import * import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib.patches import Ellipse from matplotlib import rc rc('font',**{'fam...
[ "Change ax.dist for the 3D plot. This will cause the rendered graphic to fill more of the subplot area. Here is a similar question. You may find some more info there.\nYou may also want to adjust the widths of the subplots with respect to each other (increase the width of the 3d plot and shrink the 2D plots. Thi...
[ 2 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0005102838_matplotlib_python.txt
Q: python: subprocess.call threads problem Hello people within the while True processing never ends, even if I use q.task_done, what is wrong? fileQueue = Queue() def submit(i, q): global filespath while True: filename = q.get() retVT = subprocess.call("python abc.py -f %s" % (filespath + filenam...
python: subprocess.call threads problem
Hello people within the while True processing never ends, even if I use q.task_done, what is wrong? fileQueue = Queue() def submit(i, q): global filespath while True: filename = q.get() retVT = subprocess.call("python abc.py -f %s" % (filespath + filename), shell=True, stdout=open('/dev/null', 'w')...
[ "What are the program listings for abc.py and def.py? Are you sure that the commands you are executing ever end? Try running it with the two subprocess.call() lines commented out and see if it works as intended. If it suddenly works, then the problem is somewhere related to the scripts you're calling outside of ...
[ 0 ]
[]
[]
[ "multithreading", "python", "subprocess" ]
stackoverflow_0005098334_multithreading_python_subprocess.txt
Q: BaseHTTPRequestHandler hangs when being run by pythonw.exe 3.1 The following code works fine with python.exe but fails with pythonw.exe. I'm using Python 3.1 on Windows 7. from http.server import BaseHTTPRequestHandler, HTTPServer class FooHandler(BaseHTTPRequestHandler): def do_POST(self): length = i...
BaseHTTPRequestHandler hangs when being run by pythonw.exe 3.1
The following code works fine with python.exe but fails with pythonw.exe. I'm using Python 3.1 on Windows 7. from http.server import BaseHTTPRequestHandler, HTTPServer class FooHandler(BaseHTTPRequestHandler): def do_POST(self): length = int(self.headers['Content-Length']) data = self.rfile.read(le...
[ "You are printing to stdout. pythonw.exe doens't have a stdout, as it's not connected to a terminal. My guess is that this has something to do with it.\nTry to redirect stdout to a file, or quicker, remove the print().\n" ]
[ 1 ]
[]
[]
[ "http", "python", "python_3.x", "pythonw" ]
stackoverflow_0005106132_http_python_python_3.x_pythonw.txt
Q: What is the proper format for a JSON Response? I've worked with several different APIs where I needed to parse JSON. And in all cases the Response is constructed a bit differently. I now need to expose some data via a JSON API and want to know the proper way to deliver that Response. Here is an example of what I ...
What is the proper format for a JSON Response?
I've worked with several different APIs where I needed to parse JSON. And in all cases the Response is constructed a bit differently. I now need to expose some data via a JSON API and want to know the proper way to deliver that Response. Here is an example of what I have now, however some users (one using Java) are ha...
[ "It looks valid according to http://json.parser.online.fr/ (random json parser). Its in the other code i'd say ;)\n", "How exactly are you generating this response? Are you doing it yourself?\nI see you have a dangling comma at the end of the last element in publishers (i.e. after the value Kaissa Chess & Games)....
[ 1, 0 ]
[]
[]
[ "java", "json", "python", "response" ]
stackoverflow_0005106914_java_json_python_response.txt
Q: How to find out what methods, properties, etc a python module possesses Lets say I import a module. In order for me to make the best use of it, I would like to know what properties, methods, etc. that I can use. Is there a way to find that out? As an example: Determining running programs in Python In this line: os...
How to find out what methods, properties, etc a python module possesses
Lets say I import a module. In order for me to make the best use of it, I would like to know what properties, methods, etc. that I can use. Is there a way to find that out? As an example: Determining running programs in Python In this line: os.system('WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Proc...
[ "As for Python modules, you can do\n>>> import module\n>>> help(module)\n\nand you'll get a list of supported methods (more exactly, you get the docstring, which might not contain every single method). If you want that, you can use\n>>> dir(module)\n\nalthough now you'd just get a long list of all properties, metho...
[ 70, 21, 4, 2 ]
[]
[]
[ "import", "python" ]
stackoverflow_0005103329_import_python.txt
Q: Emacs 23 built-in python.el indentation broken using tabs with width 4 I've been using the version of python.el found here for a couple of years in Emacs 23 without incident. I decided to try the stock python.el, and ran into a strange issue: When using tabs for indentation and a tab width of 4, the stock python...
Emacs 23 built-in python.el indentation broken using tabs with width 4
I've been using the version of python.el found here for a couple of years in Emacs 23 without incident. I decided to try the stock python.el, and ran into a strange issue: When using tabs for indentation and a tab width of 4, the stock python.el will indent two tab characters for every level instead of 1. With a tab...
[ "I think I've figured this out after digging through the source code for the stock Emacs 23 python.el and the newest python.el on the block.\nGiven these settings in a python-mode buffer, indentation with tabs and a tab-width of 4 works as expected in stock python.el:\n(setq indent-tabs-mode t\n tab-width 4\n ...
[ 4, 1 ]
[]
[]
[ "emacs", "indentation", "python", "tabs" ]
stackoverflow_0005098874_emacs_indentation_python_tabs.txt
Q: how to upload stored image in datastore in google appengine? I have an image stored as Blob in data store in google appengine (python) .. i want to upload this image to a server . 1- what is required to be done to upload this stored image to the server ? A: If the API that you are dealing with wants to have a UR...
how to upload stored image in datastore in google appengine?
I have an image stored as Blob in data store in google appengine (python) .. i want to upload this image to a server . 1- what is required to be done to upload this stored image to the server ?
[ "If the API that you are dealing with wants to have a URL from which to fetch the image, what you can do is set up a handler that will serve the image from the blob.\nThe AppEngine Docs lay out what you need to do in your code. Is there something specific about those instructions that you don't understand?\n" ]
[ 0 ]
[]
[]
[ "google_app_engine", "google_cloud_datastore", "image", "python" ]
stackoverflow_0005107450_google_app_engine_google_cloud_datastore_image_python.txt
Q: Django Page Caching (Trouble with db)? I'm having a bit of an odd issue in Django 1.2.4. I have a page that lets the user declare front end settings. These settings are represented in the following models: class Setting(models.Model): """ Maintains a key-value pair for some front-end editable setting. ...
Django Page Caching (Trouble with db)?
I'm having a bit of an odd issue in Django 1.2.4. I have a page that lets the user declare front end settings. These settings are represented in the following models: class Setting(models.Model): """ Maintains a key-value pair for some front-end editable setting. """ class Meta: abstract = True...
[ "The problem is that you are defining these at the class level in the admin. They therefore get evaluated when the class definition is executed, ie at process startup.\nMove the dictionary definition into the change_view method itself.\n", "Do you save the setting in the session? Did you update the session after ...
[ 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0005100338_django_python.txt
Q: Combining two potentials in python So I need to define the potential in python. I have infinite square well potential, and it has, in the middle the potential barrier. For the barrier I have this: V_x = zeros([Npts],float) for i in range(0,Npts,1): if x[i] > 0 and x[i]<width: V_x[i]=v0 Npts is the...
Combining two potentials in python
So I need to define the potential in python. I have infinite square well potential, and it has, in the middle the potential barrier. For the barrier I have this: V_x = zeros([Npts],float) for i in range(0,Npts,1): if x[i] > 0 and x[i]<width: V_x[i]=v0 Npts is the the length of the x, and x is defined a...
[ "I would suggest just using a number for your infinite potential that is a few orders (3-4) of magnitude larger than your finite potential. It will not make much of a difference in the energies of your states to make it any larger. In fact, you'll quickly be limited more by the precision of the floats used when sol...
[ 1, 0 ]
[]
[]
[ "physics", "python" ]
stackoverflow_0005084295_physics_python.txt
Q: How can I use a DLL from Python I am trying to load a DLL in Python, I want to use its eConnect() function using ctypes What I know from the source code of the DLL: from the *.cpp source code: bool eConnect( const char *host, UINT port, int clientId=0); from the dependency walker tool: function ordinal is 6 and u...
How can I use a DLL from Python
I am trying to load a DLL in Python, I want to use its eConnect() function using ctypes What I know from the source code of the DLL: from the *.cpp source code: bool eConnect( const char *host, UINT port, int clientId=0); from the dependency walker tool: function ordinal is 6 and undecorated name is ?eConnect@EClientS...
[ "To make things easier, more Pythonic, you might want to look into ctypesgen:\nhttp://code.google.com/p/ctypesgen/\nIt will generate proper wrapper functions, data types and such for you. If you just want to know how to use ctypes, might as well start with the tutorial:\nhttp://docs.python.org/library/ctypes.html\...
[ 4, 1, 0, 0, 0 ]
[]
[]
[ "ctypes", "dllimport", "python" ]
stackoverflow_0005095072_ctypes_dllimport_python.txt