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 2.6.4 property decorators not working I've seen many examples online and in this forum of how to create properties in Python with special getters and setters. However, I can't get the special getter and setter methods to execute, nor can I use the @property decorator to transform a property as readonly. I'...
Python 2.6.4 property decorators not working
I've seen many examples online and in this forum of how to create properties in Python with special getters and setters. However, I can't get the special getter and setter methods to execute, nor can I use the @property decorator to transform a property as readonly. I'm using Python 2.6.4 and here is my code. Differen...
[ "PathInfo must subclass object.\nLike this:\nclass PathInfo(object):\n\nProperties work only on new style classes.\n" ]
[ 22 ]
[]
[]
[ "decorator", "properties", "python" ]
stackoverflow_0002240351_decorator_properties_python.txt
Q: Why does Nose not see any of my environmental variables? I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables. So far, the errors: AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE' I fixed this by exporting DJANGO_SE...
Why does Nose not see any of my environmental variables?
I'm just getting started using Nose and Nosetests and my tests are failing because Nose can't see the environmental variables. So far, the errors: AttributeError: 'Settings' object has no attribute 'DJANGO_SETTINGS_MODULE' I fixed this by exporting DJANGO_SETTINGS_MODULE from .bash_profile export DJANGO_SETTINGS_MODULE...
[ "As Alok said, Nose doesn't call BaseDatabaseCreation.create_test_db('None') from django.db.backends.creation so you will need to set this setting manually. \nI was not able to get that to work.\nHowever, I found NoseDjango. \nInstall NoseDjango with: \neasy_install django-nose \n\nSince django-nose extends Djan...
[ 2, 1 ]
[]
[]
[ "django", "nose", "python" ]
stackoverflow_0002240067_django_nose_python.txt
Q: blocking channels vs async message passing I've noticed two methods to "message passing". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference Erlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed ...
blocking channels vs async message passing
I've noticed two methods to "message passing". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference Erlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed in a FIFO basis. Once the first process sends th...
[ "My experience in Erlang programming is that when you expect a high messaging rate (that is, a faster producer than consumer) then you add your own flow control. A simple scenario\n\nThe consumer will: send message, wait for ack, then repeat. \nThe producer will: wait for message, send ack when message received and...
[ 8, 4 ]
[]
[]
[ "actor", "erlang", "python", "python_stackless", "stackless" ]
stackoverflow_0002239731_actor_erlang_python_python_stackless_stackless.txt
Q: Will shell scripts called from python persist after the python script ends? As part of an automated test, I have a python script that needs to call two shell scripts that start two different servers that need to interact after the calling script ends. (It's actually a jython script, but I'm not sure that matters a...
Will shell scripts called from python persist after the python script ends?
As part of an automated test, I have a python script that needs to call two shell scripts that start two different servers that need to interact after the calling script ends. (It's actually a jython script, but I'm not sure that matters at this point.) What can I do to ensure that the servers stay up after the python ...
[ "Python threads will all die with Python. Also, os.system is blocking. But that's okay -- if the command that os.system() runs launches a new process (but not a child process), all will be fine. On Windows, for instance, if the command begins with \"start\" the \"start\"'d process will remain after Python dies. ...
[ 2, 1, 0, 0, 0 ]
[]
[]
[ "automation", "jython", "python", "sh" ]
stackoverflow_0002240494_automation_jython_python_sh.txt
Q: How can I detect errors programatically when building an egg with setuptools? If I have a script that builds eggs, basically by running python setup.py bdist_egg --exclude-source-files for a number of setup.py files that use setuptools to define how eggs are built, is there an easy way to determine if there were ...
How can I detect errors programatically when building an egg with setuptools?
If I have a script that builds eggs, basically by running python setup.py bdist_egg --exclude-source-files for a number of setup.py files that use setuptools to define how eggs are built, is there an easy way to determine if there were any errors in building the egg? A situation I had recently, was that there was a sy...
[ "distutils use the py_compile.compile() function to compile source files. This function takes a doraise argument, that when set to True raises an exception on compilation errors (the default is to print the errors to stderr). distutils don't call py_compile.compile() with doraise=True, so compilation is not aborted...
[ 5 ]
[]
[]
[ "compiler_errors", "error_handling", "python", "setuptools" ]
stackoverflow_0002230843_compiler_errors_error_handling_python_setuptools.txt
Q: Is CherryPy a robust webserver (ie, is it reliable under a huge load like Apache)? I'm wondering because CherryPy is, from my knowledge, built purely in Python, which is obviously slower than C et al. Does this mean that it's only good for dev / testing environments, or could I use it behind NGINX like I use Apach...
Is CherryPy a robust webserver (ie, is it reliable under a huge load like Apache)?
I'm wondering because CherryPy is, from my knowledge, built purely in Python, which is obviously slower than C et al. Does this mean that it's only good for dev / testing environments, or could I use it behind NGINX like I use Apache with Fast CGI currently?
[ "CherryPy's WSGI server is about as fast as a pure-Python WSGI server is going to get. I personally use it behind Nginx in production, but even standalone on my dev machine I can load each instance with several hundred requests / sec. without problems.\nCan you find a faster server? Yes. Is CherryPy a robust web s...
[ 19, 4 ]
[]
[]
[ "cherrypy", "python", "webserver" ]
stackoverflow_0002240700_cherrypy_python_webserver.txt
Q: Is there a significant overhead by using different versions of sha hashing (hashlib module) The hashlib Python module provides the following hash algorithms constructors: md5(), sha1(), sha224(), sha256(), sha384(), and sha512(). Assuming I don't want to use md5, is there a big difference in using, say, sha1 inste...
Is there a significant overhead by using different versions of sha hashing (hashlib module)
The hashlib Python module provides the following hash algorithms constructors: md5(), sha1(), sha224(), sha256(), sha384(), and sha512(). Assuming I don't want to use md5, is there a big difference in using, say, sha1 instead of sha512? I want to use something like hashlib.shaXXX(hashString).hexdigest(), but as it's ju...
[ "Why not just benchmark it?\n>>> def sha1(s):\n... return hashlib.sha1(s).hexdigest()\n...\n>>> def sha512(s):\n... return hashlib.sha512(s).hexdigest()\n...\n>>> t1 = timeit.Timer(\"sha1('asdf' * 100)\", \"from __main__ import sha1\")\n>>> t512 = timeit.Timer(\"sha512('asdf' * 100)\", \"from __main__ impor...
[ 23, 6 ]
[]
[]
[ "hash", "hashlib", "python" ]
stackoverflow_0002241013_hash_hashlib_python.txt
Q: running clock and triggering constantly running a clock and trigger an other function for every 5 seconds. Please give me idea how to do this. Thanks a bunch A: >>> import sched, time >>> s = sched.scheduler(time.time, time.sleep) >>> def print_time(): ... s.enter(5, 1, print_time, ()) ... print "From p...
running clock and triggering
constantly running a clock and trigger an other function for every 5 seconds. Please give me idea how to do this. Thanks a bunch
[ ">>> import sched, time\n>>> s = sched.scheduler(time.time, time.sleep)\n>>> def print_time():\n... s.enter(5, 1, print_time, ())\n... print \"From print_time\", time.time()\n... \n>>> s.enter(0, 1, print_time, ())\nEvent(time=1265846894.4069381, priority=1, action=<function print_time at 0xb7d1ab1c>, argum...
[ 4, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0002241234_python.txt
Q: Is there a Python ebXML client? I am trying to use a remote web service with an ebXML/SOAP interface from my python application and am hitting a wall about how to best accomplish it. So far, what I can find are lots of Java interface bindings but none for Python. Do I have to start my project over in Java? A: Do...
Is there a Python ebXML client?
I am trying to use a remote web service with an ebXML/SOAP interface from my python application and am hitting a wall about how to best accomplish it. So far, what I can find are lots of Java interface bindings but none for Python. Do I have to start my project over in Java?
[ "Doesn't look too hopeful at http://pypi.python.org/pypi?%3Aaction=search&term=ebXML&submit=search\nDo you know if there is a C library?\n" ]
[ 0 ]
[]
[]
[ "ebxml", "python" ]
stackoverflow_0002241149_ebxml_python.txt
Q: When Does It Make Sense To Rewrite A Python Module in C? In a game that I am writing, I use a 2D vector class which I have written to handle the speeds of the objects. This is called a large number of times every frame as there are a lot of objects on the screen, so any increase I can make in its speed will be use...
When Does It Make Sense To Rewrite A Python Module in C?
In a game that I am writing, I use a 2D vector class which I have written to handle the speeds of the objects. This is called a large number of times every frame as there are a lot of objects on the screen, so any increase I can make in its speed will be useful. It is pretty simple, consisting mostly of wrappers to the...
[ "If you're vector-munging, give numpy a try first. Chances are you will get speeds not far from C if you utilize numpy's vector manipulation functions wisely.\nOther than that, your question is very heuristic. If your code is too slow:\n\nProfile it - chances are you'll be able to improve it in Python\nUse the corr...
[ 14, 9, 1, 0, 0 ]
[]
[]
[ "c", "optimization", "python" ]
stackoverflow_0002096334_c_optimization_python.txt
Q: I've got Python built using VS2008, how do I install it? I'm working with boost::python and wanted to build the whole thing to make sure I can pull it off. However, I don't see any install script or way to build the MSI so I can install it. Anyone know where the directions are? Or the projects I could use to mak...
I've got Python built using VS2008, how do I install it?
I'm working with boost::python and wanted to build the whole thing to make sure I can pull it off. However, I don't see any install script or way to build the MSI so I can install it. Anyone know where the directions are? Or the projects I could use to make an MSI file? Doing this on linux seems trivial: make install...
[ "All of this is much easier with MinGW, plus there's the fact that it's likely to be compatible with the ABI of the official package so that you can just install that instead and only build extensions with MinGW.\n", "Well, the python mailing list was some help.\nTurns out there is an tools/msi directory and in t...
[ 0, 0 ]
[]
[]
[ "boost", "python", "windows_installer" ]
stackoverflow_0002232579_boost_python_windows_installer.txt
Q: more pythonic way of finding element in list that maximizes a function OK, I have this simple function that finds the element of the list that maximizes the value of another positive function. def get_max(f, s): # f is a function and s is an iterable best = None best_value = -1 for element in s: ...
more pythonic way of finding element in list that maximizes a function
OK, I have this simple function that finds the element of the list that maximizes the value of another positive function. def get_max(f, s): # f is a function and s is an iterable best = None best_value = -1 for element in s: this_value = f(element) if this_value > best_value: ...
[ "def get_max(f, s):\n return max(s, key=f)\n\n" ]
[ 15 ]
[]
[]
[ "coding_style", "list", "maximize", "python" ]
stackoverflow_0002242489_coding_style_list_maximize_python.txt
Q: (python) docstring is causing indentation error def getText(nodelist): """Extracts the text between XML tags I took this directly from http://docs.python.org/library/xml.dom.minidom.html. For example, if I have a tag <Tag>525</Tag> this method returns me '525' """ rc = "" for node in nodel...
(python) docstring is causing indentation error
def getText(nodelist): """Extracts the text between XML tags I took this directly from http://docs.python.org/library/xml.dom.minidom.html. For example, if I have a tag <Tag>525</Tag> this method returns me '525' """ rc = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: ...
[ "Your docstring starts with tabs. Make your code only use spaces for indentation (or only tabs), including the indentation for the docstrings.\n", "Make sure you are not mixing spaces and tabs for your indentation\n" ]
[ 16, 3 ]
[]
[]
[ "indentation", "python" ]
stackoverflow_0002243009_indentation_python.txt
Q: Django and VirtualEnv Development/Deployment Best Practices Just curious how people are deploying their Django projects in combination with virtualenv More specifically, how do you keep your production virtualenv's synched correctly with your development machine? I use git for scm but I don't have my virtualenv ...
Django and VirtualEnv Development/Deployment Best Practices
Just curious how people are deploying their Django projects in combination with virtualenv More specifically, how do you keep your production virtualenv's synched correctly with your development machine? I use git for scm but I don't have my virtualenv inside the git repo - should I, or is it best to use the pip free...
[ "I just set something like this up at work using pip, Fabric and git. The flow is basically like this, and borrows heavily from this script:\n\nIn our source tree, we maintain a requirements.txt file. We'll maintain this manually.\nWhen we do a new release, the Fabric script creates an archive based on whatever t...
[ 21, 4 ]
[]
[]
[ "django", "git", "python", "virtualenv" ]
stackoverflow_0002241055_django_git_python_virtualenv.txt
Q: Getting certain attribute value using XPath From the following HTML snippet: <link rel="index" href="/index.php" /> <link rel="contents" href="/getdata.php" /> <link rel="copyright" href="/blabla.php" /> <link rel="shortcut icon" href="/img/all/favicon.ico" /> I'm trying to get the href value of the link tag with...
Getting certain attribute value using XPath
From the following HTML snippet: <link rel="index" href="/index.php" /> <link rel="contents" href="/getdata.php" /> <link rel="copyright" href="/blabla.php" /> <link rel="shortcut icon" href="/img/all/favicon.ico" /> I'm trying to get the href value of the link tag with rel value = "shortcut icon", I'm trying to achie...
[ "Like this:\ndata = \"\"\"<link rel=\"index\" href=\"/index.php\" />\n<link rel=\"contents\" href=\"/getdata.php\" />\n<link rel=\"copyright\" href=\"/blabla.php\" />\n<link rel=\"shortcut icon\" href=\"/img/all/favicon.ico\" />\n\"\"\"\n\nfrom lxml import etree\n\nd = etree.HTML(data)\n\nd.xpath('//link[@rel=\"sho...
[ 21 ]
[]
[]
[ "python", "xpath" ]
stackoverflow_0002243131_python_xpath.txt
Q: How to distuingish between Django's automatically created ManyToMany through-models and manually defined ones? Say we have models: from django.db import models class AutomaticModel(models.Model): others = models.ManyToManyField('OtherModel') class ManualModel(models.Model): others = models.ManyToManyFiel...
How to distuingish between Django's automatically created ManyToMany through-models and manually defined ones?
Say we have models: from django.db import models class AutomaticModel(models.Model): others = models.ManyToManyField('OtherModel') class ManualModel(models.Model): others = models.ManyToManyField('OtherModel', through='ThroughModel') class OtherModel(models.Model): pass class ThroughModel(models.Model):...
[ "Well, South developers seemed to know it: model is autogenerated if\n# Django 1.0/1.1\n(not field.rel.through)\nor\n# Django 1.2+\ngetattr(getattr(field.rel.through, \"_meta\", None), \"auto_created\", False)\n\nWoohoo!\n" ]
[ 2 ]
[]
[]
[ "django", "django_models", "many_to_many", "python" ]
stackoverflow_0002238504_django_django_models_many_to_many_python.txt
Q: How to efficiently get the k bigger elements of a list? What´s the most efficient, elegant and pythonic way of solving this problem? Given a list (or set or whatever) of n elements, we want to get the k biggest ones. ( You can assume k<n/2 without loss of generality, I guess) For example, if the list were: l = [9,...
How to efficiently get the k bigger elements of a list?
What´s the most efficient, elegant and pythonic way of solving this problem? Given a list (or set or whatever) of n elements, we want to get the k biggest ones. ( You can assume k<n/2 without loss of generality, I guess) For example, if the list were: l = [9,1,6,4,2,8,3,7,5] n = 9, and let's say k = 3. What's the most...
[ "Use nlargest from heapq module\nfrom heapq import nlargest\nlst = [9,1,6,4,2,8,3,7,5]\nnlargest(3, lst) # Gives [9,8,7]\n\nYou can also give a key to nlargest in case you wanna change your criteria:\nfrom heapq import nlargest\ntags = [ (\"python\", 30), (\"ruby\", 25), (\"c++\", 50), (\"lisp\", 20) ]\nnlargest(2,...
[ 68, 16, 9, 4, 4 ]
[]
[]
[ "algorithm", "performance", "python", "sorting" ]
stackoverflow_0002243542_algorithm_performance_python_sorting.txt
Q: Venn Diagram up to 4 lists - outputting the intersections and unique sets in my work I use a lot of Venn diagrams, and so far I've been relying on the web-based "Venny". This offers the nice option to export the various intersections (i.e., the elements belonging only to that specific intersection). Also, it does ...
Venn Diagram up to 4 lists - outputting the intersections and unique sets
in my work I use a lot of Venn diagrams, and so far I've been relying on the web-based "Venny". This offers the nice option to export the various intersections (i.e., the elements belonging only to that specific intersection). Also, it does diagrams up to 4 lists. Problem is, doing this with large lists (4K+ elements) ...
[ "Assuming you have python 2.6 or better:\n>>> from itertools import combinations\n>>>\n>>> data = dict(\n... list1 = set(list(\"alphabet\")),\n... list2 = set(list(\"fiddlesticks\")),\n... list3 = set(list(\"geography\")),\n... list4 = set(list(\"bovinespongiformencephalopathy\")),\n... )\n>>>\n>>> variatio...
[ 7 ]
[]
[]
[ "list", "python", "venn_diagram" ]
stackoverflow_0002243690_list_python_venn_diagram.txt
Q: Change dynamically the contents of a matplotlib plot I while ago, I was comparing the output of two functions using python and matplotlib. The result was as good as simple, since plotting with matplotlib is quite easy: I just plotted two arrays with different markers. Piece of cake. Now I find myself with the same...
Change dynamically the contents of a matplotlib plot
I while ago, I was comparing the output of two functions using python and matplotlib. The result was as good as simple, since plotting with matplotlib is quite easy: I just plotted two arrays with different markers. Piece of cake. Now I find myself with the same problem, but now I have a lot of pair of curves to compar...
[ "Well I managed to do it with an event handler for mouse clicks. I will change it for something more useful, but I post my solution anyway.\nimport matplotlib.pyplot as plt\n\nfigure = plt.figure()\n# plotting\nplt.plot([1,2,3],[10,20,30],'bo-')\nplt.grid()\nplt.legend()\n\ndef on_press(event):\n print 'you pres...
[ 9, 2, 2 ]
[]
[]
[ "matplotlib", "plot", "python" ]
stackoverflow_0002050728_matplotlib_plot_python.txt
Q: How to replace launchd scheduling with a Python program The Mac OS X system startup program launchd enables job scheduling (similar to cron.) By creating a launchd agent, one can trigger programs through one of the following events: an interval of time has elapsed a certain calendar date has come a file path has ...
How to replace launchd scheduling with a Python program
The Mac OS X system startup program launchd enables job scheduling (similar to cron.) By creating a launchd agent, one can trigger programs through one of the following events: an interval of time has elapsed a certain calendar date has come a file path has been modified something has been placed in a certain director...
[ "For the filesystem-monitoring problem, perhaps you are looking for pyfsevents. According to this post,\n\nFSEvents API notifies your application\n when changes occur in the file system.\n You can use file system events to\n monitor directories for any changes,\n such as the creation, modification, or\n remova...
[ 1 ]
[]
[]
[ "launchd", "macos", "python" ]
stackoverflow_0002244261_launchd_macos_python.txt
Q: Python Virtualbox API I have made a command-line interface for virtualbox such that the virtualbox can be controlled from a remote machine. now I am trying to implement the commmand-line interface using python virtualbox api. For that I have downloaded the pyvb package (python api documentation shows functions th...
Python Virtualbox API
I have made a command-line interface for virtualbox such that the virtualbox can be controlled from a remote machine. now I am trying to implement the commmand-line interface using python virtualbox api. For that I have downloaded the pyvb package (python api documentation shows functions that can be used for implemen...
[ "startVM is in pyvb.vb.VB class. Also, it's not 'name of vm', as docs explain startVM should be called with pyvb.vm.vbVM as a first parameter and not a string.\n" ]
[ 3 ]
[]
[]
[ "api", "python", "virtualbox" ]
stackoverflow_0002244368_api_python_virtualbox.txt
Q: Comparing list item values to other items in other list in Python I want to compare the values in one list to the values in a second list and return all those that are in the first list but not in the second i.e. list1 = ['one','two','three','four','five'] list2 = ['one','two','four'] would return 'three' and 'fi...
Comparing list item values to other items in other list in Python
I want to compare the values in one list to the values in a second list and return all those that are in the first list but not in the second i.e. list1 = ['one','two','three','four','five'] list2 = ['one','two','four'] would return 'three' and 'five'. I have only a little experience with python, so this may turn out ...
[ "set(list1).difference(set(list2))\n", "Use sets to get the difference between the lists:\n>>> list1 = ['one','two','three','four','five']\n>>> list2 = ['one','two','four']\n>>> set(list1) - set(list2)\nset(['five', 'three'])\n\n", "with set.difference:\n>>> list1 = ['one','two','three','four','five']\n>>> list...
[ 8, 6, 1, 0, 0 ]
[]
[]
[ "plone", "python", "zope" ]
stackoverflow_0002244443_plone_python_zope.txt
Q: Using Djangos ImageField to upload an image, rename it to a random filename and create thumbnail Hay guys, I've wrote a simple upload method for my pictures class Picture(models.Model): path = models.CharField(max_length=200) filename = models.CharField(max_length=200) car = models.ForeignKey('Car') ...
Using Djangos ImageField to upload an image, rename it to a random filename and create thumbnail
Hay guys, I've wrote a simple upload method for my pictures class Picture(models.Model): path = models.CharField(max_length=200) filename = models.CharField(max_length=200) car = models.ForeignKey('Car') thumb_path = models.CharField(max_length=200) created_on = models.DateField(auto_now_add=True) ...
[ "You could use an adapted version of:\nhttp://www.djangosnippets.org/snippets/1100/\nOr depending on what exactly you need to do you can consider a template filter based approach something like this:\nhttp://www.djangosnippets.org/snippets/1887/\n" ]
[ 1 ]
[]
[]
[ "django", "file", "python", "upload" ]
stackoverflow_0002244537_django_file_python_upload.txt
Q: getting specific xml nodes attributes This might be a newbie question :) but it's irritating me since I'm new to XML. I have the following xml file: <assetsMain> <assetParent type='character' shortName='char'> <asset> pub </asset> <asset> car </asset> </assetParent> <assetParent t...
getting specific xml nodes attributes
This might be a newbie question :) but it's irritating me since I'm new to XML. I have the following xml file: <assetsMain> <assetParent type='character' shortName='char'> <asset> pub </asset> <asset> car </asset> </assetParent> <assetParent type='par' shortName='pr'> <asset> ...
[ "An answer using lxml.etree. Xpath would probably be reusable in another capable library:\n>>> from lxml import etree\n>>> data = \"\"\"<assetsMain>\n... <assetParent type='character' shortName='char'>\n... <asset>pub</asset>\n... <asset>car</asset>\n... </assetParent>\n... <assetParent type='par' shortName='pr'>\n...
[ 3, 0 ]
[]
[]
[ "python", "xml" ]
stackoverflow_0002244629_python_xml.txt
Q: Threads in twisted... how to use them properly? I need to write a simple app that runs two threads: - thread 1: runs at timed periods, let's say every 1 minute - thread 2: just a 'normal' while True loop that does 'stuff' if not the requirement to run at timed interval I would have not looked at twisted at all, bu...
Threads in twisted... how to use them properly?
I need to write a simple app that runs two threads: - thread 1: runs at timed periods, let's say every 1 minute - thread 2: just a 'normal' while True loop that does 'stuff' if not the requirement to run at timed interval I would have not looked at twisted at all, but simple sleep(60) is not good enough and constructio...
[ "You didn't explain why you actually need threads here. If you had, I might have been able to explain why you don't need them. ;)\nThat aside, I can confirm that your basic understanding of things is correct. One possible misunderstanding I can clear up, though, is the notion that \"python threads\" and \"Twisted...
[ 5, 2 ]
[]
[]
[ "multithreading", "python", "timedelay", "twisted" ]
stackoverflow_0002243266_multithreading_python_timedelay_twisted.txt
Q: How to extract unique values from nested dictionary with Python? I like to make a function that puts out a list of all values that are in a dictionary. The list must not contain any double items. The list also has to be in alphabetical order. I'm kind of new to Python, I can't come any further than printing all th...
How to extract unique values from nested dictionary with Python?
I like to make a function that puts out a list of all values that are in a dictionary. The list must not contain any double items. The list also has to be in alphabetical order. I'm kind of new to Python, I can't come any further than printing all the values of the dictionary with the iteritems() function. The dictiona...
[ "the simplest way would be:\n>>> d = {1: 'sadf', 2: 'sadf', 3: 'asdf'}\n>>> sorted(set(d.itervalues()))\n['asdf', 'sadf']\n\nprint it as you like.\nFor your update question answer would be:\n>>> films = set()\n>>> _ = [films.update(dic) for dic in critics.itervalues()]\n>>> sorted(films)\n['Just My Luck', 'Lady in ...
[ 4, 0 ]
[]
[]
[ "dictionary", "python" ]
stackoverflow_0002244795_dictionary_python.txt
Q: Spawning WSGI example (practical approach to WSGI) I'm trying to understand how WSGI works. I know I could read the specs, but I'd still want to know how do I create a spawning application? A complete "hello world". Could someone show me an example? With everything, file naming, creating the module, running it. Ev...
Spawning WSGI example (practical approach to WSGI)
I'm trying to understand how WSGI works. I know I could read the specs, but I'd still want to know how do I create a spawning application? A complete "hello world". Could someone show me an example? With everything, file naming, creating the module, running it. Every and each step. Thanks. (NB: while spawning seems a g...
[ "From what I can see in the documentation, Spawning just runs stock WSGI apps, which means that you just write a WSGI script and then invoke Spawning against it:\nspawn helloworld.simple_app\nspawn helloworld.simple_app middleware.Upperware\n\nAs always, make sure you have installed any modules it depends on, such ...
[ 3 ]
[]
[]
[ "python", "wsgi", "wsgiserver" ]
stackoverflow_0002244897_python_wsgi_wsgiserver.txt
Q: How to count both sides of many-to-many relationship in Google App Engine Consider a GAE (python) app that lets users comment on songs. The expected number of users is 1,000,000+. The expected number of songs is 5,000. The app must be able to: Give the number of songs a user has commented on Give the number of ...
How to count both sides of many-to-many relationship in Google App Engine
Consider a GAE (python) app that lets users comment on songs. The expected number of users is 1,000,000+. The expected number of songs is 5,000. The app must be able to: Give the number of songs a user has commented on Give the number of users who have commented on a song Counter management must be transactional so...
[ "You really shouldn't have to worry about handling the user's count of songs on which they have commented inside a transaction because it seems unlikely that a User would be able to comment on more than one song at a time, right?\nNow, it is definitely the case that many users could be commenting on the same song a...
[ 1 ]
[]
[]
[ "data_modeling", "google_app_engine", "python", "python_datamodel" ]
stackoverflow_0002244850_data_modeling_google_app_engine_python_python_datamodel.txt
Q: Uncatchable exception in Python The issue came up in this question, which I'll recapitulate in this code: import csv FH = open('data.csv','wb') line1 = [97,44,98,44,99,10] line2 = [100,44,101,44,102,10] for n in line1 + line2: FH.write(chr(n)) FH.write(chr(0)) FH.close() import _csv FH = open('data.csv') rea...
Uncatchable exception in Python
The issue came up in this question, which I'll recapitulate in this code: import csv FH = open('data.csv','wb') line1 = [97,44,98,44,99,10] line2 = [100,44,101,44,102,10] for n in line1 + line2: FH.write(chr(n)) FH.write(chr(0)) FH.close() import _csv FH = open('data.csv') reader = csv.reader(FH) for line in read...
[ "You are not putting the \"try\" block at the right place to catch this exception. In other words, this exception is \"catchable\", just revisit the question you have referenced.\nThe traceback clearly states that the problem is on the line with the \"for\" statement.\n", "It's not uncatchable, you're just trying...
[ 7, 4, 0, 0 ]
[]
[]
[ "exception", "python" ]
stackoverflow_0002245243_exception_python.txt
Q: how to measure execution time of functions (automatically) in Python I need to have a base class which I will use to inherit other classes which I would like to measure execution time of its functions. So intead of having something like this: class Worker(): def doSomething(self): start = time.time() ...
how to measure execution time of functions (automatically) in Python
I need to have a base class which I will use to inherit other classes which I would like to measure execution time of its functions. So intead of having something like this: class Worker(): def doSomething(self): start = time.time() ... do something elapsed = (time.time() - start) pr...
[ "One way to do this would be with a decorator (PEP for decorators) (first of a series of tutorial articles on decorators). Here's an example that does what you want.\nfrom functools import wraps\nfrom time import time\n\ndef timed(f):\n @wraps(f)\n def wrapper(*args, **kwds):\n start = time()\n result = f(*...
[ 64, 10, 6 ]
[]
[]
[ "oop", "python" ]
stackoverflow_0002245161_oop_python.txt
Q: Python - Check network map I'm looking for some help on logic, the code is not very Pythonic I'm still learning. We map the Z: drive to different locations all the time. Here is what I'm trying to accomplish 1: Check for an old map on Z: say \192.168.1.100\old 2: Map the new location to Z: say \192.168.1.200\new ...
Python - Check network map
I'm looking for some help on logic, the code is not very Pythonic I'm still learning. We map the Z: drive to different locations all the time. Here is what I'm trying to accomplish 1: Check for an old map on Z: say \192.168.1.100\old 2: Map the new location to Z: say \192.168.1.200\new 3: Make sure the new Z: mapping ...
[ "I've put together a script based on the one you laid out which I believe accomplishes what you have described.\nI've tried to do it in a way that's both Pythonic and follows good programming principles.\nIn particular, I've done the following:\n\nmodularize much of the functionality into reusable functions\navoide...
[ 3 ]
[]
[]
[ "python" ]
stackoverflow_0002244767_python.txt
Q: How to go from list of words to a list of distinct letters in Python Using Python, I'm trying to convert a sentence of words into a flat list of all distinct letters in that sentence. Here's my current code: words = 'She sells seashells by the seashore' ltr = [] # Convert the string that is "words" to a list of ...
How to go from list of words to a list of distinct letters in Python
Using Python, I'm trying to convert a sentence of words into a flat list of all distinct letters in that sentence. Here's my current code: words = 'She sells seashells by the seashore' ltr = [] # Convert the string that is "words" to a list of its component words word_list = [x.strip().lower() for x in words.split(' ...
[ "Sets provide a simple, efficient solution.\nwords = 'She sells seashells by the seashore'\n\nunique_letters = set(words.lower())\nunique_letters.discard(' ') # If there was a space, remove it.\n\n", "set([letter.lower() for letter in words if letter != ' '])\n\nEdit: I just tried it and found this will also work...
[ 13, 3, 3, 2, 2, 0, 0 ]
[]
[]
[ "distinct", "filter", "letters", "list_comprehension", "python" ]
stackoverflow_0002245903_distinct_filter_letters_list_comprehension_python.txt
Q: Group form fields in django? Is there a way in Django to group some fields from a ModelForm? For example, if there's a model with fields like: age, gender, dob, q1, q2, q3 and a form is created based in such Model, can I group the fields like: info_fields = (age, gender, dob) and response_fields = (q1, q2, q3). Th...
Group form fields in django?
Is there a way in Django to group some fields from a ModelForm? For example, if there's a model with fields like: age, gender, dob, q1, q2, q3 and a form is created based in such Model, can I group the fields like: info_fields = (age, gender, dob) and response_fields = (q1, q2, q3). This would be helpful to display all...
[ "See this post, I believe your hinting at using fieldsets in a ModelForm.\nDjango and fieldsets on ModelForm\n" ]
[ 1 ]
[]
[]
[ "django", "django_forms", "django_templates", "python" ]
stackoverflow_0002245612_django_django_forms_django_templates_python.txt
Q: python chaco axis labels time formatting In Enthought's Chaco, the TimeFormatter class is used to format the time string of the tick labels. is there a way to specify the time format (something like time.strftime()). the source code now hard-codes the format when displaying month and day of the month to the amer...
python chaco axis labels time formatting
In Enthought's Chaco, the TimeFormatter class is used to format the time string of the tick labels. is there a way to specify the time format (something like time.strftime()). the source code now hard-codes the format when displaying month and day of the month to the american style (MMDD). I would like to add some fl...
[ "Honestly, the easiest way is going to be to monkeypatch the TimeFormatter's _formats dictionary:\nfrom enthought.chaco.scales.formatters import TimeFormatter\nTimeFormatter._formats['days'] = ('%d/%m', '%d%a',)\n\nIf you don't want to do this, then you need to subclass TimeFormatter. That's easy. What's more cum...
[ 4 ]
[]
[]
[ "chaco", "python" ]
stackoverflow_0002173632_chaco_python.txt
Q: How do I deal with multiple common user interfaces? I'm working on a python application that runs on 2 different platforms, namely regular desktop linux and Maemo 4. We use PyGTK on both platforms but on Maemo there are a bunch of little tweaks to make it look nice which are implemented as follows: if util.platfor...
How do I deal with multiple common user interfaces?
I'm working on a python application that runs on 2 different platforms, namely regular desktop linux and Maemo 4. We use PyGTK on both platforms but on Maemo there are a bunch of little tweaks to make it look nice which are implemented as follows: if util.platform.MAEMO: # do something fancy for maemo else: # r...
[ "You could wind up much of this in a factory:\ndef createSpec():\n if util.platform.MAEMO: return Maemo4Spec()\n elif util.platform.MAEMO5: return Maemo5Spec()\n return StandardPyGTKSpec()\n\nThen, somewhere early in your code, you just call that factory:\n spec = createSpec()\n\nNow, everywhere else you had con...
[ 10, 0, 0 ]
[]
[]
[ "code_reuse", "maemo", "pygtk", "python", "user_interface" ]
stackoverflow_0002022448_code_reuse_maemo_pygtk_python_user_interface.txt
Q: Python: Monitoring and killing/throttling spawned processes based on load, time, etc I have a queue of workers that spawn external third party apps using subprocess. I'd like to control how much of the overall resources of my server these process consume. Some of these external apps also tend to hang for unknown r...
Python: Monitoring and killing/throttling spawned processes based on load, time, etc
I have a queue of workers that spawn external third party apps using subprocess. I'd like to control how much of the overall resources of my server these process consume. Some of these external apps also tend to hang for unknown reasons, fixed with a restart. What's a good way to: Monitor the overall server load (say,...
[ "Functions to get load average and kill process are available in standard python library (os.getloadavg(), os.kill(), subprocess.Popen.kill()). There is a psutil package for the rest (psutil.Process.get_cpu_times(), psutil.Process.get_cpu_percent(), psutil.Process.get_memory_info(), psutil.Process.get_memory_percen...
[ 4, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001654922_python.txt
Q: python web framework large project I need your advices to choose a Python Web Framework for developing a large project: Database (Postgresql)will have at least 500 tables, most of them with a composite primary key, lots of constraints, indexes & queries. About 1,500 views for starting. The project belongs to the f...
python web framework large project
I need your advices to choose a Python Web Framework for developing a large project: Database (Postgresql)will have at least 500 tables, most of them with a composite primary key, lots of constraints, indexes & queries. About 1,500 views for starting. The project belongs to the financial area. Alwasy new requirements a...
[ "Django has been used by many large organizations (Washington Post, etc.) and can connect with Postgresql easily enough. I use it fairly often and have had no trouble.\n", "Yes. An ORM is essential for mapping SQL stuff to objects. \nYou have three choices.\n\nUse someone else's ORM\nRoll your own.\nTry to exe...
[ 12, 8, 5, 3, 2, 1, 0 ]
[]
[]
[ "frameworks", "python", "web_frameworks" ]
stackoverflow_0001003131_frameworks_python_web_frameworks.txt
Q: Is ActiveMQ's failover mechanism supported by C# (openwire) & python (stomp) clients? I'd like to use ActiveMQ to connect python service with C# clients. Is there a way to specify failover connection in C# (openwire) and python (Stomp)? The ActiveMQ will be configured Shared File System Master Slave. A: C# clien...
Is ActiveMQ's failover mechanism supported by C# (openwire) & python (stomp) clients?
I'd like to use ActiveMQ to connect python service with C# clients. Is there a way to specify failover connection in C# (openwire) and python (Stomp)? The ActiveMQ will be configured Shared File System Master Slave.
[ "C# client supports failover see: http://issues.apache.org/activemq/browse/AMQNET-26.\nPython client probably doesn't support it.\n" ]
[ 2 ]
[]
[]
[ "activemq", "c#", "nms", "python", "stomp" ]
stackoverflow_0002223460_activemq_c#_nms_python_stomp.txt
Q: How does one run Spawning with Django within a virtualenv? Because of the way Eventlet, which Spawning depends on, installs itself, it can't be installed into a virtualenv. The following error (wrapped for readability) illustrates: Running eventlet-0.9.4/setup.py -q bdist_egg --dist-dir \ /tmp/easy_install-m_s75...
How does one run Spawning with Django within a virtualenv?
Because of the way Eventlet, which Spawning depends on, installs itself, it can't be installed into a virtualenv. The following error (wrapped for readability) illustrates: Running eventlet-0.9.4/setup.py -q bdist_egg --dist-dir \ /tmp/easy_install-m_s75o/eventlet-0.9.4/egg-dist-tmp-fAZK_u error: SandboxViolation: ch...
[ "The following five commands worked without any problems. How are you installing spawning?\nvirtualenv test\ncd test/\n. bin/activate\neasy_install spawning\npython -c 'import spawning'\n\n" ]
[ 3 ]
[]
[]
[ "django", "python", "spawning", "virtualenv", "wsgi" ]
stackoverflow_0002245430_django_python_spawning_virtualenv_wsgi.txt
Q: stream socket send/receive broadcast messages? I browsed the python socket docs and google for two days but I did not find any answer. Yeah I am a network programming newbie :) I would like to implement some LAN chatting system with specific function for our needs. I am at the very beginning. I was able to impleme...
stream socket send/receive broadcast messages?
I browsed the python socket docs and google for two days but I did not find any answer. Yeah I am a network programming newbie :) I would like to implement some LAN chatting system with specific function for our needs. I am at the very beginning. I was able to implement a client-server model where the client connects t...
[ "The broadcast is defined by the destination address.\nFor example if your own ip is 192.168.1.2, the broadcast address would be 192.168.1.255 (in most cases)\nIt is not related directly to python and will probably not be in its documentation. You are searching for network \"general\" knowledge, to a level much hig...
[ 4 ]
[]
[]
[ "python" ]
stackoverflow_0002247228_python.txt
Q: Python String Method Conundrum The following code is supposed to print MyWords after removing SpamWords[0]. However; instead of returning "yes" it instead returns "None". Why is it returning "None"? MyWords = "Spam yes" SpamWords = ["SPAM"] SpamCheckRange = 0 print ((MyWords.upper()).split()).remove(SpamWords[Spam...
Python String Method Conundrum
The following code is supposed to print MyWords after removing SpamWords[0]. However; instead of returning "yes" it instead returns "None". Why is it returning "None"? MyWords = "Spam yes" SpamWords = ["SPAM"] SpamCheckRange = 0 print ((MyWords.upper()).split()).remove(SpamWords[SpamCheckRange])
[ "Because remove is a method that changes the mutable list object it's called on, and returns None.\nl= MyWords.upper().split()\nl.remove(SpamWords[SpamCheckRange])\n# l is ['YES']\n\nPerhaps you want:\n>>> [word for word in MyWords.split() if word.upper() not in SpamWords]\n['yes']\n\n", "remove is a method of li...
[ 7, 0 ]
[]
[]
[ "methods", "python", "string" ]
stackoverflow_0002247600_methods_python_string.txt
Q: Associative Matrices? I'm working on a project where I need to store a matrix of numbers indexed by two string keys. The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows. Similarly, if a row key exists for any column then it should exist for all columns. The obvious...
Associative Matrices?
I'm working on a project where I need to store a matrix of numbers indexed by two string keys. The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows. Similarly, if a row key exists for any column then it should exist for all columns. The obvious way to express this is wit...
[ "Why not just use a standard matrix, but then have two dictionaries - one that converts the row keys to row indices and one that converts the columns keys to columns indices. You could make your own structure that would work this way fairly easily I think. You just make a class that contains the matrix and the two ...
[ 2, 0, 0 ]
[]
[]
[ "associative_array", "d", "data_structures", "matrix", "python" ]
stackoverflow_0002247197_associative_array_d_data_structures_matrix_python.txt
Q: How can you access the "calling" object through a RelatedManager in Django? Say I have a model with a foreign key to a Django Auth user: class Something(models.Model): user = models.ForeignKey(User, related_name='something') I can then access this model through a RelatedManager: u = User.objects.create_user(...
How can you access the "calling" object through a RelatedManager in Django?
Say I have a model with a foreign key to a Django Auth user: class Something(models.Model): user = models.ForeignKey(User, related_name='something') I can then access this model through a RelatedManager: u = User.objects.create_user('richardhenry', 'richard@example.com', 'password') u.something.all() My question...
[ "Managers are only directly connected to the model they manage. So in this case, your Manager would be connected to Something, but not directly to User. \nAlso, Managers begin with querysets, not objects, so you'll have to work from there.\nKeep in mind that to use your custom methods with a RelatedManager you need...
[ 2 ]
[]
[]
[ "django", "python" ]
stackoverflow_0002247508_django_python.txt
Q: Anyone benchmarked virtual machine performance for build servers? We have been trying to use virtual machines for build servers. Our build servers are all running WinXP32 and we are hosting them on VMWare Server 2.0 running on Ubuntu 9.10. We build a mix of C, C++, python packages, and other various deployment t...
Anyone benchmarked virtual machine performance for build servers?
We have been trying to use virtual machines for build servers. Our build servers are all running WinXP32 and we are hosting them on VMWare Server 2.0 running on Ubuntu 9.10. We build a mix of C, C++, python packages, and other various deployment tasks (installers, 7z files, archives, etc). The management using VMWar...
[ "Disk IO is definitely a problem here, you just can't do any significant amount of disk IO activity when you're backing it up with a single spindle. The 32MB cache on a single SATA drive is going to be saturated just by your Host and a couple of Guest OS's ticking over. If you look at the disk queue length counter ...
[ 8 ]
[]
[]
[ "automation", "build", "c++", "python", "vmware" ]
stackoverflow_0002247755_automation_build_c++_python_vmware.txt
Q: Python best way to check for existing key Which is the more efficient/faster/better way to check if a key exists? if 'subject' in request.POST: subject = request.POST['subject'] else: // handle error OR try: subject = request.POST['subject'] except KeyError: // handle error A: The latter (try/ex...
Python best way to check for existing key
Which is the more efficient/faster/better way to check if a key exists? if 'subject' in request.POST: subject = request.POST['subject'] else: // handle error OR try: subject = request.POST['subject'] except KeyError: // handle error
[ "The latter (try/except) form is generally the better form. \ntry blocks are very cheap but catching an exception can be more expensive. A containment check on a dict tends to be cheap, but not cheaper than nothing. I suspect there will be a balance of efficiency depending on how often 'subject' is really there. Ho...
[ 47, 6, 4, 2, 1, 1, 0 ]
[ "subject = request.POST.get(\"subject\")\nif subject is None:\n ...\n\n:)\n" ]
[ -1 ]
[ "python" ]
stackoverflow_0002247412_python.txt
Q: Python: Identifying a numeric string? I tried a couple of approaches, I am really only concerned with performance, not correctness. I noticed that the regex based implementation is about 3-4x slower than the one that uses type coercion. Is there another, more efficient way of doing this? def IsNumber(x): try: ...
Python: Identifying a numeric string?
I tried a couple of approaches, I am really only concerned with performance, not correctness. I noticed that the regex based implementation is about 3-4x slower than the one that uses type coercion. Is there another, more efficient way of doing this? def IsNumber(x): try: _ = float(x) except ValueError:...
[ "First of all, they're not doing the same thing. Floats can be specified as \"1e3\", for example, and float() will accept that. It's also not coercion, but conversion.\nSecondly, don't import re in IsNumber2, especially if you're trying to use it with timeit. Do the import outside of the function.\nFinally, it d...
[ 6, 2, 2, 0 ]
[]
[]
[ "coercion", "python", "regex" ]
stackoverflow_0002248185_coercion_python_regex.txt
Q: Python Jabber/XMPP client library for Twisted I am looking for a Python library for writing Jabber/XMPP clients using the Twisted framework. A: Wokkel is your best bet. It's an enhancement on the core Twisted Words functionality built into Twisted. It has several major users, include the guys behind Stanziq/S...
Python Jabber/XMPP client library for Twisted
I am looking for a Python library for writing Jabber/XMPP clients using the Twisted framework.
[ "Wokkel is your best bet. It's an enhancement on the core Twisted Words functionality built into Twisted. It has several major users, include the guys behind Stanziq/Strophe.\n", "Twisted Words\n" ]
[ 12, 3 ]
[]
[]
[ "python", "twisted", "xmpp" ]
stackoverflow_0002248587_python_twisted_xmpp.txt
Q: Python: Embed Chaco in PyQt4 Mystery How do i go about adding Chaco to an existing PyQt4 application? Hours of searches yielded little (search for yourself). So far i've figured i need the following lines: import os os.environ['ETS_TOOLKIT']='qt4' i could not find PyQt4-Chaco code anywhere on the internets i woul...
Python: Embed Chaco in PyQt4 Mystery
How do i go about adding Chaco to an existing PyQt4 application? Hours of searches yielded little (search for yourself). So far i've figured i need the following lines: import os os.environ['ETS_TOOLKIT']='qt4' i could not find PyQt4-Chaco code anywhere on the internets i would be very grateful to anyone filling in th...
[ "I just saw this today. It is absolutely possible and fairly straightforward to embed Chaco inside Qt as well as WX. In fact, all of the examples, when run with your ETS_TOOLKIT environment var set to \"qt4\", are doing exactly this. (Chaco requires there to be an underlying GUI toolkit.)\nI have written a small...
[ 8, 7, 0 ]
[ "I don't know Chaco but a quick look tells me that this is not possible.\nBoth Chaco and PyQt are graphical toolkits designed to interact with the user. Chaco is plot oriented and PyQt more application oriented. Each one has its own way of managing what a window is, how to detect user clicks, how to handle paint ev...
[ -1 ]
[ "chaco", "pyqt", "pyqt4", "python" ]
stackoverflow_0002148279_chaco_pyqt_pyqt4_python.txt
Q: Python error while using MysqlDb - sets module is deprecated I'm currently getting the warning every time I run a Python script that uses MySQLdb: /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet I'd rather not mess with th...
Python error while using MysqlDb - sets module is deprecated
I'm currently getting the warning every time I run a Python script that uses MySQLdb: /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet I'd rather not mess with their lib if possible. I'm on Ubuntu server. Anyone know an easy way...
[ "Do this before the mysql module is imported\nimport warnings\nwarnings.filterwarnings(action=\"ignore\", message='the sets module is deprecated')\nimport sets\n\n", "You can ignore the warning using the warnings module, or the -W argument to Python. Don't ignore all DeprecationWarnings, though, just the ones fro...
[ 6, 1, 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0002248531_mysql_python.txt
Q: (python) issue bash commands from within python script (alla perl system($cmd)) Within a python script, I want to issue a command. In perl, I could define a command, save it as a variable (here, $cmd) then type system($cmd) and then the command is executed. How can i do that in python? A: You can use os.system()...
(python) issue bash commands from within python script (alla perl system($cmd))
Within a python script, I want to issue a command. In perl, I could define a command, save it as a variable (here, $cmd) then type system($cmd) and then the command is executed. How can i do that in python?
[ "You can use os.system(), but prefer subprocess instead.\n", "Another good choice is \"commands\" module: http://docs.python.org/library/commands.html.\n", "you can use os.system(), or the newer subprocess module. Other possible alternatives (for older Python versions) include these. (eg os.spawn*,os.popen*,etc...
[ 6, 1, 0 ]
[]
[]
[ "bash", "python" ]
stackoverflow_0002248259_bash_python.txt
Q: Simulate a device driver crash in linux. Have python reload it I have a web camera running in Linux using the uvcvideo module. And I'm using a python application to access the web camera and display the image. I want the python program to handle it if the web camera for some reason don't work anymore. Have tested ...
Simulate a device driver crash in linux. Have python reload it
I have a web camera running in Linux using the uvcvideo module. And I'm using a python application to access the web camera and display the image. I want the python program to handle it if the web camera for some reason don't work anymore. Have tested with just unloading the module. Works fine if i just unload the modu...
[ "Do you mean USB camera ? I don't know about forced unloading while module is in use, but this won't happen and is not a good simulation of camera not working anymore. Try to handle camera disconnection /reconnection gracefully first.\nI don't know what you are trying to achieve when simulating driver crash, but yo...
[ 4, 2, 1 ]
[]
[]
[ "linux", "python" ]
stackoverflow_0002243674_linux_python.txt
Q: SQLAlchemy ForeignKey relation via an intermediate table Suppose that I have a table Articles, which has fields article_id, content and it contains one article with id 1. I also have a table Categories, which has fields category_id (primary key), category_name, and it contains one category with id 10. Now suppose ...
SQLAlchemy ForeignKey relation via an intermediate table
Suppose that I have a table Articles, which has fields article_id, content and it contains one article with id 1. I also have a table Categories, which has fields category_id (primary key), category_name, and it contains one category with id 10. Now suppose that I have a table ArticleProperties, that adds properties to...
[ "Assuming I understand you question correctly, then No, you can't model that relationship as you have suggested. (It would help if you described your desired result, rather than your perceived solution)\nWhat I think you may want is a many-to-many mapping table called ArticleCategories, consisting of 2 int columns...
[ 1 ]
[]
[]
[ "python", "sqlalchemy" ]
stackoverflow_0002234030_python_sqlalchemy.txt
Q: subprocess.Popen(..).communicate(..) throw away data at random when used with graphviz! I am using graphviz's dot to generate some svg graphs for a web application. I call dot using Popen: p = subprocess.Popen(u'/usr/bin/dot -Kfdp -Tsvg', shell=True,\ stdin=subprocess.PIPE, stdout=subprocess.PIPE) str ...
subprocess.Popen(..).communicate(..) throw away data at random when used with graphviz!
I am using graphviz's dot to generate some svg graphs for a web application. I call dot using Popen: p = subprocess.Popen(u'/usr/bin/dot -Kfdp -Tsvg', shell=True,\ stdin=subprocess.PIPE, stdout=subprocess.PIPE) str = u'long-unicode-string-i-want-to-convert' (stdout,stderr) = p.communicate(str) What hap...
[ "Sounds like you should be doing:\nstdout, stderr = p.communicate(str.encode('utf-8'))\n\n(except, of course, that you shouldn't shadow the builtin str.) The unicode type in Python holds unicode data, not UTF-8. If you want UTF-8, you need to explicitly encode it.\nOn top of that, there's no reason to use shell=Tru...
[ 3 ]
[]
[]
[ "graphviz", "pipe", "popen", "python", "subprocess" ]
stackoverflow_0002248795_graphviz_pipe_popen_python_subprocess.txt
Q: AppEngine 'explicitly cancelled' error I'm using Google AppEngine and the deferred library, with the Mapper class, as described here (with some improvements as in here). In some iterations of the mapper I get the following error: CancelledError: The API call datastore_v3.Put() was explicitly cancelled. The Mapper...
AppEngine 'explicitly cancelled' error
I'm using Google AppEngine and the deferred library, with the Mapper class, as described here (with some improvements as in here). In some iterations of the mapper I get the following error: CancelledError: The API call datastore_v3.Put() was explicitly cancelled. The Mapper usually runs fine, I used to have a higher ...
[ "After a DeadlineExceededError, you are allowed a short amount of grace time to handle the exception, eg defer the remainder of the computation.\nIf you run out of grace time the CancelledError kicks in.\nThere should be no way to catch/handle the CancelledError\n" ]
[ 1 ]
[]
[]
[ "google_app_engine", "google_cloud_datastore", "python", "scheduled_tasks" ]
stackoverflow_0002248811_google_app_engine_google_cloud_datastore_python_scheduled_tasks.txt
Q: Formatting an output file I'm currently indexing my music collection with python. Ideally I'd like my output file to be formatted as; "Artist; Album; Tracks - length - bitrate - md5 Artist2; Album2; Tracks - length - bitrate - md5" But I can't seem to work out how to achieve this. Any ...
Formatting an output file
I'm currently indexing my music collection with python. Ideally I'd like my output file to be formatted as; "Artist; Album; Tracks - length - bitrate - md5 Artist2; Album2; Tracks - length - bitrate - md5" But I can't seem to work out how to achieve this. Any suggestions?
[ ">>> import textwrap\n>>> class Album(object):\n... def __init__(self, title, artist, tracks, length, bitrate, md5):\n... self.title=title\n... self.artist=artist\n... self.tracks=tracks\n... self.length=length\n... self.bitrate=bitrate\n... self.md5=md5\n... ...
[ 1, 1 ]
[]
[]
[ "formatting", "logging", "python", "text" ]
stackoverflow_0002249162_formatting_logging_python_text.txt
Q: How to check contents of a folder using Python How can you check the contents of a file with python, and then copy a file from the same folder and move it to a new location? I have Python 3.1 but i can just as easily port to 2.6 thank you! A: for example import os,shutil root="/home" destination="/tmp" directory...
How to check contents of a folder using Python
How can you check the contents of a file with python, and then copy a file from the same folder and move it to a new location? I have Python 3.1 but i can just as easily port to 2.6 thank you!
[ "for example\nimport os,shutil\nroot=\"/home\"\ndestination=\"/tmp\"\ndirectory = os.path.join(root,\"mydir\")\nos.chdir(directory)\nfor file in os.listdir(\".\"):\n flag=\"\"\n #check contents of file ?\n for line in open(file):\n if \"something\" in line:\n flag=\"found\"\n if flag==\"...
[ 3, 1 ]
[]
[]
[ "cpython", "directory", "python" ]
stackoverflow_0002249132_cpython_directory_python.txt
Q: MongoDB/py-mongo for queries with date functions Im looking to use a document database such as MongoDB but looking through the documents I cant find much on queries that involve date functions. For example lets say that I'm asking one of the following questions of the DB: "Tell me all the people who bought a prod...
MongoDB/py-mongo for queries with date functions
Im looking to use a document database such as MongoDB but looking through the documents I cant find much on queries that involve date functions. For example lets say that I'm asking one of the following questions of the DB: "Tell me all the people who bought a product on tuesday" "Get me all sales and group by month" ...
[ "For the first query the best bet would be to do a range query for dates in between the start and end of tuesday. Something like:\ndb.foo.find({\"purchase_date\": {\"$gt\": monday_midnight, \"$lte\": tuesday_midnight}})\n\nThis will be nicer syntactically when the following case is finished, so might want to vote f...
[ 3 ]
[]
[]
[ "mongodb", "pymongo", "python" ]
stackoverflow_0002248146_mongodb_pymongo_python.txt
Q: Python MediaWiki table regex (find strings of a particular format, then extract substrings within) I'm trying to find all strings of the format {{rdex|001|001|Bulbasaur|2|Grass|Poison}} in a large text file, and then extract the substrings corresponding to the first 001 and to Bulbasaur, perhaps as a tuple. I'm as...
Python MediaWiki table regex (find strings of a particular format, then extract substrings within)
I'm trying to find all strings of the format {{rdex|001|001|Bulbasaur|2|Grass|Poison}} in a large text file, and then extract the substrings corresponding to the first 001 and to Bulbasaur, perhaps as a tuple. I'm assuming regex with capturing groups can be used for both; could anybody tell me the appropriate regex to ...
[ "re.match('^{{[^|]+\\|([^|]+)\\|[^|]+\\|([^|]+)\\|[^|]+\\|[^|]+\\|[^|]+\\}}$', S).groups()\n\n", "import re\ntext=\"\"\"{{rdex|001|001|Bulbasaur|2|Grass|Poison}}\"\"\"\nre.findall(\"\\{\\{[^|]+\\|(\\d+)\\|\\d+\\|([^|]+)\",text)\n[('001', 'Bulbasaur')]\n\n", "line=\"{{rdex|001|001|Bulbasaur|2|Grass|Poison}}\"\ns...
[ 1, 1, 0 ]
[]
[]
[ "mediawiki", "python", "regex" ]
stackoverflow_0002249340_mediawiki_python_regex.txt
Q: How to improve the throughput of request_logs on Google App Engine Downloading logs from App Engine is nontrivial. Requests are batched; appcfg.py does not use normal file IO but rather a temporary file (in reverse chronological order) which it ultimately appends to the local log file; when appending, the need to ...
How to improve the throughput of request_logs on Google App Engine
Downloading logs from App Engine is nontrivial. Requests are batched; appcfg.py does not use normal file IO but rather a temporary file (in reverse chronological order) which it ultimately appends to the local log file; when appending, the need to find the "sentinel" makes log rotation difficult since one must leave en...
[ "You can increase the per-request batch size of logs. In the latest SDK (1.3.1), check out google_appengine/google/appengine/tools/appcfg.py around like 861 (RequestLogLines method of LogsRequester class). You can modify the \"limit\" parameter.\nI am using 1000 and it works pretty well.\n" ]
[ 1 ]
[]
[]
[ "google_app_engine", "logging", "python" ]
stackoverflow_0002249530_google_app_engine_logging_python.txt
Q: How to generate data model from sql schema in Django? Our website uses a PHP front-end and a PostgreSQL database. We don't have a back-end at the moment except phpPgAdmin. The database admin has to type data into phpPgAmin manually, which is error-prone and tedious. We want to use Django to build a back-end. The d...
How to generate data model from sql schema in Django?
Our website uses a PHP front-end and a PostgreSQL database. We don't have a back-end at the moment except phpPgAdmin. The database admin has to type data into phpPgAmin manually, which is error-prone and tedious. We want to use Django to build a back-end. The database has a few dozen of tables already there. Is it poss...
[ "Yes it is possible, using the inspectdb command:\npython manage.py inspectdb\n\nor\npython manage.py inspectdb > models.py\n\nto get them in into the file\nThis will look at the database configured in your settings.py and outputs model classes to standard output.\nAs Ignacio pointed out, there is a guide for your ...
[ 51, 2 ]
[]
[]
[ "database", "django", "python" ]
stackoverflow_0002249489_database_django_python.txt
Q: Python lazy iterator I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression: g = (i for i in range(1000) if i % 3 == i % 2) This one, however fails on construction: g = (line.strip() for line in open('xxx', 'r') if len(line) > 10) I do not have the ...
Python lazy iterator
I am trying to understand how and when iterator expressions get evaluated. The following seems to be a lazy expression: g = (i for i in range(1000) if i % 3 == i % 2) This one, however fails on construction: g = (line.strip() for line in open('xxx', 'r') if len(line) > 10) I do not have the file named 'xxx'. However,...
[ "The iteration over the file returned by the call to open() is lazy. The call to open() is not.\n", "From the documentation:\n\nVariables used in the generator\n expression are evaluated lazily in a\n separate scope when the next()\n method is called for the generator\n object (in the same fashion as for\n n...
[ 6, 6 ]
[]
[]
[ "lazy_evaluation", "python" ]
stackoverflow_0002249651_lazy_evaluation_python.txt
Q: Convert unicode string to array of bytes I'm using OpenGL and I need to pass to a function array of bytes. glCallLists(len('text'), GL_UNSIGNED_BYTES, 'text'); This way it's working fine. But I need to pass unicode text. I think that it should work like this: text = u'unicode text' glCallLists(len(text), GL_UNSIG...
Convert unicode string to array of bytes
I'm using OpenGL and I need to pass to a function array of bytes. glCallLists(len('text'), GL_UNSIGNED_BYTES, 'text'); This way it's working fine. But I need to pass unicode text. I think that it should work like this: text = u'unicode text' glCallLists(len(text), GL_UNSIGNED_SHORT, convert_to_array_of_words(text)); ...
[ "The UTF encoding that takes up 2 bytes per character is UTF-16:\nprint repr(u'あいうえお'.encode('utf-16be'))\nprint repr(u'あいうえお'.encode('utf-16le'))\n\n" ]
[ 2 ]
[]
[]
[ "python", "unicode" ]
stackoverflow_0002249817_python_unicode.txt
Q: Can we get the following flexibility in Python as In Perl Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python. I just want to check whether I can have the same degree of flexibility as in Python. In Python : page = form.getvalue("page") str = 'This is stri...
Can we get the following flexibility in Python as In Perl
Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python. I just want to check whether I can have the same degree of flexibility as in Python. In Python : page = form.getvalue("page") str = 'This is string : ' + str(int(page) + 1) In Perl : $str = 'This is string :...
[ "No, since Python is strongly typed. If you keep page as an int you can do the following:\ns = 'This is string : %d' % (page + 1,)\n\n", "It looks like page is a str\npage = form.getvalue(\"page\")\nS = 'This is string : %d'%(int(page)+1)\n\notherwise make page an int\npage = int(form.getvalue(\"page\"))\nS = 'Th...
[ 7, 1, 1, 0 ]
[]
[]
[ "perl", "python" ]
stackoverflow_0002249419_perl_python.txt
Q: Django not translating Bittorrent query string properly I'm writing a small Bittorrent tracker on top of the Django framework, as part of a larger project. However, I'm having problems with decoding the "info_hash" parameter of the announce request. Basically, uTorrent takes the SHA1 hash of the torrent in questio...
Django not translating Bittorrent query string properly
I'm writing a small Bittorrent tracker on top of the Django framework, as part of a larger project. However, I'm having problems with decoding the "info_hash" parameter of the announce request. Basically, uTorrent takes the SHA1 hash of the torrent in question and URL encodes the hex representation of it, which is then...
[ "What is your settings.DEFAULT_ENCODING? Also how deoes the hash look like in HTTP headers? It shouldn't be modified at all during encoding as below:\n>>> import urllib\n>>> urllib.urlencode({'hash':\"A44B44B0EE8D85A9F7135489D522A19DA2C87C91\"})\n'hash=A44B44B0EE8D85A9F7135489D522A19DA2C87C91'\n\nSince:\n>>> urllib...
[ 1, 0 ]
[]
[]
[ "bittorrent", "django", "encoding", "python" ]
stackoverflow_0002249947_bittorrent_django_encoding_python.txt
Q: Django Master-Detail View Plugins Let's say I have 3 django apps, app Country, app Social and app Financial. Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view. Each country's details include their Social details (from the so...
Django Master-Detail View Plugins
Let's say I have 3 django apps, app Country, app Social and app Financial. Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view. Each country's details include their Social details (from the social app) and their Financial details (...
[ "2 common solution I use for this problem: \nPartial Templates:\nCreate a template for rendering \"social\" and \"financial\" that does not need stuff from the view, other than the object it is working on (and uses the objects functions or template tags to render it).\nthen you can easily {% include %} it (and set...
[ 2 ]
[]
[]
[ "django", "django_templates", "django_views", "master_detail", "python" ]
stackoverflow_0002249285_django_django_templates_django_views_master_detail_python.txt
Q: Use psycopg2 to obtain long value from PostgreSQl I am facing problem in retrieving long value from PostgreSQL I use the following SQL command : SELECT *, (extract(epoch FROM start_timestamp) * 1000) FROM lot WHERE EXTRACT(EPOCH FROM lot.start_timestamp) * 1000 >=1265299200000 AND EXTRACT(EPOCH FROM lot.start_ti...
Use psycopg2 to obtain long value from PostgreSQl
I am facing problem in retrieving long value from PostgreSQL I use the following SQL command : SELECT *, (extract(epoch FROM start_timestamp) * 1000) FROM lot WHERE EXTRACT(EPOCH FROM lot.start_timestamp) * 1000 >=1265299200000 AND EXTRACT(EPOCH FROM lot.start_timestamp) * 1000 <=1265990399999 ORDER BY start_timesta...
[ "I have the same results using both psycopg2 and pygres. While this select returns float value you can modify your code to format returned value:\ndef format_float_fld(v):\n #return str(v)\n return ('%20.0f' % (v)).strip()\n\nIf you use str(s) then you will get scientific notation.\nYou can also change query ...
[ 1 ]
[]
[]
[ "postgresql", "python" ]
stackoverflow_0002250135_postgresql_python.txt
Q: Replace a word in a file I am new to Python programming... I have a .txt file....... It looks like.. 0,Salary,14000 0,Bonus,5000 0,gift,6000 I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code.. Thanks in advance. Nimmyliji A: I know that you...
Replace a word in a file
I am new to Python programming... I have a .txt file....... It looks like.. 0,Salary,14000 0,Bonus,5000 0,gift,6000 I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code.. Thanks in advance. Nimmyliji
[ "I know that you're asking about Python, but forgive me for suggesting that perhaps a different tool is better for the job. :) It's a one-liner via sed:\nsed 's/^0,/1,/' yourtextfile.txt > output.txt\n\nThis applies the regex /^0,/ (which matches any 0, that occurs at the beginning of a line) to each line and repla...
[ 4, 3, 2, 2 ]
[]
[]
[ "file", "python" ]
stackoverflow_0002250357_file_python.txt
Q: Can someone help me with this JAVA SAXParser? I've been fiddling for 3 hours and I can't get this F***** parser to work. Sorry for cursing. I don't understand why I can't find one decent tutorial that does exactly what I want. I just want to send the function a String/XML. Then, parse it. it's not that hard. In ...
Can someone help me with this JAVA SAXParser?
I've been fiddling for 3 hours and I can't get this F***** parser to work. Sorry for cursing. I don't understand why I can't find one decent tutorial that does exactly what I want. I just want to send the function a String/XML. Then, parse it. it's not that hard. In python, I can do it with my eyes closed. Awesome, f...
[ "You have to extends your default handler DefaultHandler. For example, try this:\n saxParser.parse( new InputSource(new StringReader(thexml)) , new DefaultHandler()\n {\n public void startElement(String uri, String localName, String qName, Attributes attributes)\n ...
[ 3, 3, 2, 0, 0 ]
[]
[]
[ "java", "python", "xml" ]
stackoverflow_0002250450_java_python_xml.txt
Q: Python returning the wrong length of string when using special characters I have a string ë́aúlt that I want to get the length of a manipulate based on character positions and so on. The problem is that the first ë́ is being counted twice, or I guess ë is in position 0 and ´ is in position 1. Is there any possible...
Python returning the wrong length of string when using special characters
I have a string ë́aúlt that I want to get the length of a manipulate based on character positions and so on. The problem is that the first ë́ is being counted twice, or I guess ë is in position 0 and ´ is in position 1. Is there any possible way in Python to have a character like ë́ be represented as 1? I'm using UTF-8...
[ "UTF-8 is an unicode encoding which uses more than one byte for special characters. If you don't want the length of the encoded string, simple decode it and use len() on the unicode object (and not the str object!).\nHere are some examples:\n>>> # creates a str literal (with utf-8 encoding, if this was\n>>> # speci...
[ 22, 6, 1, 0, 0 ]
[]
[]
[ "character_encoding", "python" ]
stackoverflow_0002247205_character_encoding_python.txt
Q: app-engine (python) Modeling relationships, am I doing it wrong? Using the following models I am trying to figure out a way to generate a news feed of sorts so that when a user logs in they are presented with a list of upcoming events for bars that they choose to follow. Will I be able to query something like “SEL...
app-engine (python) Modeling relationships, am I doing it wrong?
Using the following models I am trying to figure out a way to generate a news feed of sorts so that when a user logs in they are presented with a list of upcoming events for bars that they choose to follow. Will I be able to query something like “SELECT * FROM Barevent WHERE parent_bar IN UserprofileInstance.following”...
[ "Your model and your query should work fine, and it would not be inefficient. The one thing that you will want to keep in mind is that if Barprofile entities are deleted, you may want to manually remove their keys from the following property of each Userprofile. Having an orphaned Barprofile reference will not brea...
[ 1, 1, 0 ]
[]
[]
[ "google_app_engine", "google_cloud_datastore", "python" ]
stackoverflow_0002246727_google_app_engine_google_cloud_datastore_python.txt
Q: How to do drag & drop with wxWidgets module of Python? I'm using Python and I want to do a drag & drop interface. For example, with a large picture whose size is bigger then the screen, I want to click on it and drag it to see other parts. Something like "google maps"! In google maps if we click two times we do "z...
How to do drag & drop with wxWidgets module of Python?
I'm using Python and I want to do a drag & drop interface. For example, with a large picture whose size is bigger then the screen, I want to click on it and drag it to see other parts. Something like "google maps"! In google maps if we click two times we do "zoom" but if we click one time and while pressed, we move the...
[ "I found the solution over here:\nhttp://www.java2s.com/Code/Python/Event/Mouseactiondrag.htm\nWith this code I can do what I want!\nAnd the name was only Mouse Drag and not Mouse Drag and Drop (soz)\n" ]
[ 0 ]
[]
[]
[ "drag_and_drop", "python", "wxpython", "wxwidgets" ]
stackoverflow_0002237725_drag_and_drop_python_wxpython_wxwidgets.txt
Q: Django MySql Raw Query Error - Parameter index out of range This view is running fine on plain pyton/Django/mysql on Windows I'm porting this to run over jython/Django/mysql and it gives error - Exception received is : error setting index [10] [SQLCode: 0] Parameter index out of range (10 > number of parameter...
Django MySql Raw Query Error - Parameter index out of range
This view is running fine on plain pyton/Django/mysql on Windows I'm porting this to run over jython/Django/mysql and it gives error - Exception received is : error setting index [10] [SQLCode: 0] Parameter index out of range (10 > number of parameters, which is 0). [SQLCode: 0], [SQLState: S1009] The Query is -...
[ "It's indeed a parameter style problem. You have to use ? instead of %s.\nHere is how you reproduce the error you are getting:\nshell> jython\n>>> from com.ziclix.python.sql import zxJDBC\n>>> (d, v) = \"jdbc:mysql://localhost/test\", \"org.gjt.mm.mysql.Driver\"\n>>> cnx = zxJDBC.connect(d, None, None, v)\n>>> cur ...
[ 2, 0 ]
[]
[]
[ "django", "jython", "mysql", "python" ]
stackoverflow_0002248321_django_jython_mysql_python.txt
Q: Using subprocess.call to crop an image I'm having trouble in my python script, and I don't understand it : subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) Returns "invalid argument - -crop" But if I run this from the command line, it works fine : convert test.jpg -crop 80x10+9...
Using subprocess.call to crop an image
I'm having trouble in my python script, and I don't understand it : subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg']) Returns "invalid argument - -crop" But if I run this from the command line, it works fine : convert test.jpg -crop 80x10+90+980 +repage test.jpg What am I missing he...
[ "Is there more than one convert in the system? Try an absolute path to the command you want?\n", "What about using the python image library instead? That seems much more reliable than to call a subprocess (especially for error handling...).\n", "file is a _____builtin_____ class. Overriding it may produce unwan...
[ 2, 1, 1, 1 ]
[]
[]
[ "imagemagick", "python" ]
stackoverflow_0002250933_imagemagick_python.txt
Q: MySQL select query not working with limit, offset parameters I am running MySQL 5.1 on my windows vista installation. The table in question uses MyISAM, has about 10 million rows. It is used to store text messages posted by users on a website. I am trying to run the following query on it, query = "select id, text...
MySQL select query not working with limit, offset parameters
I am running MySQL 5.1 on my windows vista installation. The table in question uses MyISAM, has about 10 million rows. It is used to store text messages posted by users on a website. I am trying to run the following query on it, query = "select id, text from messages order by id limit %d offset %d" %(limit, offset) w...
[ "Have you checked the table with myisamchk?\n" ]
[ 0 ]
[]
[]
[ "mysql", "python" ]
stackoverflow_0002249331_mysql_python.txt
Q: render users' equations in Python I am a very new/inexperienced Python programmer. I teach maths and am trying to create a GUI graph-plotting package suitable for schoolchildren. As well as plotting a graph, I would ideally like to render the equation a user enters [eg. y = (x^2)/3] in a nicely formatted style - i...
render users' equations in Python
I am a very new/inexperienced Python programmer. I teach maths and am trying to create a GUI graph-plotting package suitable for schoolchildren. As well as plotting a graph, I would ideally like to render the equation a user enters [eg. y = (x^2)/3] in a nicely formatted style - ideally updating in real-time as the use...
[ "You could look at how Lybniz does it. Or you could use Lybniz. Just saying.\n", "Perhaps you could make use of SymPy's printing capabilities.\n", "I am not sure whether you intend to have your students build this plotting tool in python or you want to build the tool yourself so they can use it to e.g., visuali...
[ 8, 3, 2, 0 ]
[]
[]
[ "equation", "matplotlib", "python", "wxpython" ]
stackoverflow_0002247757_equation_matplotlib_python_wxpython.txt
Q: How to test a folder for new files using python How would you go about testing to see if 2 folders contain the same files, and then to be able to manipulate ONLY the file which is new. A = listdir('C:/') B = listdir('D:/') If A==B ... I know this could be used to test if directories are different but is there a ...
How to test a folder for new files using python
How would you go about testing to see if 2 folders contain the same files, and then to be able to manipulate ONLY the file which is new. A = listdir('C:/') B = listdir('D:/') If A==B ... I know this could be used to test if directories are different but is there a better way? And if A and B are the same, except B has...
[ "http://docs.python.org/library/filecmp.html\nhttp://docs.python.org/library/filecmp.html#the-dircmp-class\nimport filecmp\ncompare = filecmp.dircmp( \"C:/\", \"D:/\" )\nfor f in compare.left_only:\n print \"C: new\", f\nfor f in compare.right_only:\n print \"D: new\", f\n\n", "A = set(os.listdir('C:\\\\'))...
[ 8, 4 ]
[]
[]
[ "directory", "file", "python" ]
stackoverflow_0002251751_directory_file_python.txt
Q: Python# screenshot failure I am using PIL(Python Imaging Library) for grabbing the image. But grabber() throws the following error message if I minimized the window img=ImageGrab.grab() File "C:\Python26\lib\site-packages\PIL\ImageGrab.py", line 47, in grab size, data = grabber() IOError: screen grab failed M...
Python# screenshot failure
I am using PIL(Python Imaging Library) for grabbing the image. But grabber() throws the following error message if I minimized the window img=ImageGrab.grab() File "C:\Python26\lib\site-packages\PIL\ImageGrab.py", line 47, in grab size, data = grabber() IOError: screen grab failed My browser shot factory is instal...
[ "There is a very similar question located here - it even has some alternatives and solutions, and (as Adam Bernier has written), imagegrab works only on Windows. \n" ]
[ 0 ]
[]
[]
[ "python", "python_imaging_library" ]
stackoverflow_0002116368_python_python_imaging_library.txt
Q: What behaviour is preferred? (Embedding Python) I'm embedding Python into an application. MyClass.name is a property of str type: >>> foo = MyClass() >>> foo.name 'Default Name' Should I allow users to do this: >>> foo.name = 123 >>> foo.name '123' or not? >>> foo.name = 123 Traceback (most recent call last): ...
What behaviour is preferred? (Embedding Python)
I'm embedding Python into an application. MyClass.name is a property of str type: >>> foo = MyClass() >>> foo.name 'Default Name' Should I allow users to do this: >>> foo.name = 123 >>> foo.name '123' or not? >>> foo.name = 123 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: name m...
[ "Definitely raise a TypeError rather than attempting to automatically coerce. Normally I would be conservative about saying that something is \"pythonic\" or not – it's one of those words that really just means \"the speaker thinks that this is good\" – but if it means anything at all, it must refer to adhering to...
[ 4, 1 ]
[]
[]
[ "python" ]
stackoverflow_0002252089_python.txt
Q: ImageField not failing at IOError exception Hay, i have a model which saves 2 images class Picture(models.Model): picture = models.ImageField(upload_to=make_filename) thumbnail = models.ImageField(upload_to=make_thumb_filename) car = models.ForeignKey('Car') created_on = models.DateField(auto_now_a...
ImageField not failing at IOError exception
Hay, i have a model which saves 2 images class Picture(models.Model): picture = models.ImageField(upload_to=make_filename) thumbnail = models.ImageField(upload_to=make_thumb_filename) car = models.ForeignKey('Car') created_on = models.DateField(auto_now_add=True) updated_on = models.DateField(auto_n...
[ "The code that (I assume) throws the IOError is being run after you call the super(Picture,self).save() method. Because of this, the picture getting written to the database even if the exception is thrown.\nYou just need to move the super call to after the setup code.\nAs an aside, if you're overriding save I'd rec...
[ 1 ]
[]
[]
[ "django", "imagefield", "ioerror", "python" ]
stackoverflow_0002252355_django_imagefield_ioerror_python.txt
Q: Class Inheritance I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am h...
Class Inheritance
I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am hitting problems. I have...
[ "I would say you messed up class definition with function stuff. It should look more like this:\nclass Test(object):\n\n def __init__(self):\n self.a = 20\n self.b = 30\n\nif __name__ == '__main__':\n test_instance = Test()\n\nand\nfrom class1 import Test\n\nclass Test2(Test):\n\n def e(self)...
[ 13, 1 ]
[]
[]
[ "class", "inheritance", "python" ]
stackoverflow_0002252620_class_inheritance_python.txt
Q: What are my options for doing multithreaded/concurrent programming in Python? I'm writing a simple site spider and I've decided to take this opportunity to learn something new in concurrent programming in Python. Instead of using threads and a queue, I decided to try something else, but I don't know what would sui...
What are my options for doing multithreaded/concurrent programming in Python?
I'm writing a simple site spider and I've decided to take this opportunity to learn something new in concurrent programming in Python. Instead of using threads and a queue, I decided to try something else, but I don't know what would suit me. I have heard about Stackless, Celery, Twisted, Tornado, and other things. I d...
[ "Tornado is a web server, so it wouldn't help you much in writing a spider. Twisted is much more general (and, inevitably, complex), good for all kinds of networking tasks (and with good integration with the event loop of several GUI frameworks). Indeed, there used to be a twisted.web.spider (but it was removed y...
[ 4, 2, 1 ]
[]
[]
[ "concurrency", "multithreading", "parallel_processing", "python", "python_stackless" ]
stackoverflow_0002249126_concurrency_multithreading_parallel_processing_python_python_stackless.txt
Q: Getting raw post data in Google App Engine Python API I am trying to get raw data sent as post to Google App engine, using self.request.get('content'), but in vain. It returns empty. I am sure the data is being sent from the client, coz I checked with another simple server code. Any idea what I am doing wrong? I a...
Getting raw post data in Google App Engine Python API
I am trying to get raw data sent as post to Google App engine, using self.request.get('content'), but in vain. It returns empty. I am sure the data is being sent from the client, coz I checked with another simple server code. Any idea what I am doing wrong? I am using the following code on the client side generating th...
[ "self.request.get('content') will give you data sent with the argument name 'content'. If you want the raw post data, use self.request.body.\n", "Try submitting the POST data with a content type other than application/x-www-form-urlencoded, which is the default when a form is submitted by a browser. If you use ...
[ 7, 4 ]
[]
[]
[ "google_app_engine", "iphone", "post", "python", "request" ]
stackoverflow_0002251584_google_app_engine_iphone_post_python_request.txt
Q: How to run command line python script in django view? I have a .py file that a php file runs like this: $link = exec(dirname(__FILE__) . /xxx.py ' .excapeshellarg($url) . '2>&1', $output, $exit_code); I want to run the xxx.py in my django view and asign the output to a variable. The xxx.py file has a def main(ur...
How to run command line python script in django view?
I have a .py file that a php file runs like this: $link = exec(dirname(__FILE__) . /xxx.py ' .excapeshellarg($url) . '2>&1', $output, $exit_code); I want to run the xxx.py in my django view and asign the output to a variable. The xxx.py file has a def main(url) function and if __name__ == '__main__': at the bottom. I...
[ "\nIs there a way I can edit the xxx.py file and call the def main function from my view?\n\nYes. Modify the main function so that it returns its results as a string rather than printing it to stdout, which is what it appears to be doing at the moment.\nThen, from inside your view, you can do something like:\nimpo...
[ 2 ]
[]
[]
[ "command_line", "django", "python", "scripting" ]
stackoverflow_0002252741_command_line_django_python_scripting.txt
Q: Site name appearing in django URLs I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.) Let's say that the site name is 'mysite'. So for example: <a href="{% url myapp.views.myview "myparam" %}">Link text</a> is producing: <a href="/mysite/foo/b...
Site name appearing in django URLs
I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.) Let's say that the site name is 'mysite'. So for example: <a href="{% url myapp.views.myview "myparam" %}">Link text</a> is producing: <a href="/mysite/foo/bar">Link text</a> when I want it to pro...
[ "Check your modpython configuration, if you've got one. There may be a line that looks like PythonOption django.root /mysite Remove that.\n", "Are you sure, that this is the rendered version? Docs say, that an absolute url should be produced, i.e. /mysite/foo/bar. Are you checking source in the browser? Try pri...
[ 6, 1 ]
[]
[]
[ "django", "django_urls", "python", "url" ]
stackoverflow_0002252593_django_django_urls_python_url.txt
Q: "De-instrument" an instantiated object from the sqlalchemy ORM Is there an easy way to "de-instrument" an instantiated class coming from sqlalchemy's ORM, i.e., turn it into a regular object? I.e., suppose I have a Worker class that's mapped to a worker table: class Worker(object): def earnings(self): ...
"De-instrument" an instantiated object from the sqlalchemy ORM
Is there an easy way to "de-instrument" an instantiated class coming from sqlalchemy's ORM, i.e., turn it into a regular object? I.e., suppose I have a Worker class that's mapped to a worker table: class Worker(object): def earnings(self): return self.wage*self.hours mapper(Worker,workers) where wo...
[ "If you need to permanently deinstrument a class, just dispose of the mapper:\nsqlalchemy.orm.class_mapper(Worker).dispose()\n\nSQLAlchemy instrumentation lives as property descriptors on the class object. So if you need separate deinstrumented versions of objects you'll need to create a version of the class that d...
[ 5, 0 ]
[]
[]
[ "optimization", "python", "sqlalchemy" ]
stackoverflow_0002249694_optimization_python_sqlalchemy.txt
Q: "Error when calling the metaclass bases" when declaring class inside a module Let me start by saying, I also get the same error whey defining __init__ and running super()'s __init__. I only simplified it down to this custom method to see if the error still happened. import HTMLParser class Spider(HTMLParser): ...
"Error when calling the metaclass bases" when declaring class inside a module
Let me start by saying, I also get the same error whey defining __init__ and running super()'s __init__. I only simplified it down to this custom method to see if the error still happened. import HTMLParser class Spider(HTMLParser): """ Just a subclass. """ This alone in a module raises the following erro...
[ "And the answer is that I'm a complete noob. This is a module, not a class, but I'll leave this up here in case other noobs run into the same problem.\nSolution:\nfrom HTMLParser import HTMLParser\n\nEach time I think I'm starting to become a pro, something like this happens :(\n" ]
[ 33 ]
[]
[]
[ "python" ]
stackoverflow_0002253816_python.txt
Q: Python: ball isn't defined I get this error: Traceback (most recent call last): File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module> ball[i][j]=sphere() NameError: name 'ball' is not defined when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it? #2D-wave #VPython from ...
Python: ball isn't defined
I get this error: Traceback (most recent call last): File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module> ball[i][j]=sphere() NameError: name 'ball' is not defined when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it? #2D-wave #VPython from visual import * #ball array #re...
[ "No, ball is not defined. You need to create a list() before you can start assigning to the list's indices. Similarly the nested lists need to be created before you assign to them. Try this:\nball = [None] * 5\n\nfor i in range(5):\n ball[i] = [None] * 5\n\n for j in range(5):\n ball[i][j]=sphere()\n\n...
[ 3, 3, 1, 1, 1 ]
[]
[]
[ "arrays", "python" ]
stackoverflow_0002254009_arrays_python.txt
Q: In python, what is more efficient? Modifying lists or strings? Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same? As an example, let's say I have two binary strings "11011" and "01001". If I represent these...
In python, what is more efficient? Modifying lists or strings?
Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same? As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let's say I get...
[ ">>> a = \"11011\"\n>>> b = \"01001\"\n>>> import timeit\n>>> def strslice():\n return a[:3] + b[3:]\n\n>>> def lstslice():\n return list(a)[:3] + list(b)[3:]\n>>> c = list(a)\n>>> d = list(b)\n>>> def lsts():\n return c[:3] + d[3:]\n\n>>> timeit.timeit(strslice)\n0.5103488475836432\n>>> timeit.timeit(lsts...
[ 7, 5, 4, 0 ]
[]
[]
[ "list", "python", "string" ]
stackoverflow_0002253234_list_python_string.txt
Q: How to create graphs in Delphi application I need to create graphs on the fly about specific process, with some informative texts and colors. In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi? I'm using Delphi 2007. Also Python alte...
How to create graphs in Delphi application
I need to create graphs on the fly about specific process, with some informative texts and colors. In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi? I'm using Delphi 2007. Also Python alternative could be considered, but I'd prefer pure...
[ "You can use SimpleGraph from DelphiArea.\nA have test and use it and it's a great component. Freeware with sources. \n\nRegards.\n", "@Harriv, You can try WinGraphviz wich is a COM Wrapper for Graphviz.\ncheck this link for more info.\n\n", "TMS also have a diagram studio and a workflow studio\nand a post abou...
[ 6, 3, 1, 1 ]
[]
[]
[ "delphi", "graph", "python" ]
stackoverflow_0002252779_delphi_graph_python.txt
Q: Django flatpages and a catchall startpage I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running. As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore. (r'^', 'myproject.mysite.views.startpage'), I know flatpag...
Django flatpages and a catchall startpage
I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running. As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore. (r'^', 'myproject.mysite.views.startpage'), I know flatpages uses a 404 hook, but how do you configure th...
[ "I believe this is what you want (with a $):\n(r'^$', 'myproject.mysite.views.startpage')\n\nIt should catch only empty requests.\n", "This regex matches everything, so no wonder that flatpages are not working - they are only fallback, activated on 404 error. And with this regex you don't give a chance for 404 er...
[ 4, 2 ]
[]
[]
[ "django", "django_flatpages", "python" ]
stackoverflow_0002254366_django_django_flatpages_python.txt
Q: Django-tinymce not working; Getting a normal textarea instead I'm trying to use django-tinymce to make fields that are editable through Django's admin with a TinyMCE field. I am using tinymce.models.HTMLField as the field for this. The problem is it's not working. I get a normal textarea. I check the HTML source, ...
Django-tinymce not working; Getting a normal textarea instead
I'm trying to use django-tinymce to make fields that are editable through Django's admin with a TinyMCE field. I am using tinymce.models.HTMLField as the field for this. The problem is it's not working. I get a normal textarea. I check the HTML source, and it seems like all the code needed for TinyMCE is there. I also ...
[ "What are your webserver and web browser. Perhaps it is trying to set the gzip/bzip header and the server isn't processing it... so it goes out plaintext but the client expects compressed?\n" ]
[ 0 ]
[]
[]
[ "django", "django_admin", "javascript", "python", "tinymce" ]
stackoverflow_0002254398_django_django_admin_javascript_python_tinymce.txt
Q: Python Import and 'object has no attribute' with Qt From research on Stack Overflow and other sites I'm 99% sure that the problem I'm having is due to incorrect importing. Below is a QLabel sub class that I'm using to respond to some mouse events: import Qt import sys class ASMovableLabel(Qt.QLabel): def mo...
Python Import and 'object has no attribute' with Qt
From research on Stack Overflow and other sites I'm 99% sure that the problem I'm having is due to incorrect importing. Below is a QLabel sub class that I'm using to respond to some mouse events: import Qt import sys class ASMovableLabel(Qt.QLabel): def mouseReleaseEvent(self, event): button = event.but...
[ "Try\nself.frameRect().setTopLeft(Qt.QPoint(event.x, event.y))\n\ninstead of\nself.frameRect.setTopLeft(Qt.QPoint(event.x, event.y))\n\n" ]
[ 1 ]
[]
[]
[ "import", "pyqt", "python", "qt" ]
stackoverflow_0002254708_import_pyqt_python_qt.txt
Q: Receive output of python script from PHP? I want to launch a python script similar to this web crawler, wait for it to finish, process the data in php, then return the results to the user. From what I hear, getting the output from python is trivial, but the above script is doing stuff in parallel, so just printing...
Receive output of python script from PHP?
I want to launch a python script similar to this web crawler, wait for it to finish, process the data in php, then return the results to the user. From what I hear, getting the output from python is trivial, but the above script is doing stuff in parallel, so just printing stuff as it finishes won't give me any kind of...
[ "I suggest a file, you can dump structured data for example to JSON or YAML (both is easily writable and readable in both Python and PHP).\nWhy is \"printing stuff as it finishes\" not usable? Writing file and then reading it is basically the same. You don't have to use only print in Python, you can use standard ou...
[ 1 ]
[]
[]
[ "php", "python" ]
stackoverflow_0002254827_php_python.txt
Q: tarfile: determine compression of an open tarball I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression....
tarfile: determine compression of an open tarball
I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression. AFAICS TarFile class doesn't provide any public interf...
[ "Ok, I have found a better solution.\nf = t.fileobj.__class__(newfn, 'w')\n\n", "Tar doesn't compress, it concatenates (which is why TarFile won't tell you what compression method is used, because there isn't one). \nAre you trying to find out if it's a tar.gz, tar.bz2, or tar.Z ?\n", "When you open the tarfile...
[ 2, 1, 1 ]
[]
[]
[ "python", "tarfile" ]
stackoverflow_0002254017_python_tarfile.txt
Q: Return all non-overlapping matches of pattern in string In Python I can use re.findall(pattern, string) to return all non-overlapping matches of pattern in a string. For example, in the following SVG path command: import re spam = "M317.0,169.7C311.1,170.5 285.7,146.8 300.7,178.57 L 321.4,175.01" eggs = re.findall...
Return all non-overlapping matches of pattern in string
In Python I can use re.findall(pattern, string) to return all non-overlapping matches of pattern in a string. For example, in the following SVG path command: import re spam = "M317.0,169.7C311.1,170.5 285.7,146.8 300.7,178.57 L 321.4,175.01" eggs = re.findall("([A-Za-z]|-?[0-9]+\.?[0-9]*(?:e-?[0-9]*)?)", spam) print(eg...
[ "SLRE - Super Light Regular Expression library\nSLRE is an ANSI C library that implements a tiny subset of Perl regular expressions. It is primarily targeted for developers who want to parse configuation files, where speed is unimportant. It is in single .c file, easily modifiable for custom needs. For example, if ...
[ 5, 2 ]
[]
[]
[ "c++", "pattern_matching", "python", "regex" ]
stackoverflow_0002255302_c++_pattern_matching_python_regex.txt
Q: Extra data about objects in django templates I have django objects: class Event(models.Model): title = models.CharField(max_length=255) event_start_date = models.DateField(null=True, blank='true') ... class RegistrationDate(models.Model): event = models.ForeignKey(tblEvents) date_type = models.Ch...
Extra data about objects in django templates
I have django objects: class Event(models.Model): title = models.CharField(max_length=255) event_start_date = models.DateField(null=True, blank='true') ... class RegistrationDate(models.Model): event = models.ForeignKey(tblEvents) date_type = models.CharField(max_length=10, choices=registration_date_t...
[ "Add a property to your Event class e.g.:\nclass Event:\n # stuff here\n\n @property\n def status(self):\n # do the same thing here as in your status function\n return status\n\nThe you can do in your template:\n{{ event.status }}\n\n", "I think you can make that function you wrote a class method of Ev...
[ 5, 2 ]
[]
[]
[ "django", "django_models", "django_templates", "python" ]
stackoverflow_0002255488_django_django_models_django_templates_python.txt
Q: How can I import a C++ python extension into a module in another directory? Here is the directory structure: app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py sub2.so test_sub2.py The folder app is on my PYTHONPATH All of the __init__.py files are emp...
How can I import a C++ python extension into a module in another directory?
Here is the directory structure: app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py sub2.so test_sub2.py The folder app is on my PYTHONPATH All of the __init__.py files are empty. The shared library sub2.so is a C++ extension module that I compiled using c...
[ "The way to import it is to import app.sub2.sub2, from any source file. Your test should actually live outside of app and use that module-path to get to the extension module.\n", "Try \nimport .app.sub2.sub2 \n\nin your mod1.py file\n", "Use relative imports:\nfrom ..sub2.sub2 import A\n\nThis is similar to a r...
[ 2, 0, 0 ]
[]
[]
[ "import", "module", "python" ]
stackoverflow_0002255543_import_module_python.txt
Q: Different results from converting a file from iso-8859-1 to utf-8 iconv in shell vs calling it from python with subprocess Well, this could be a simple question, to be frank I'm a little confused with encodings an all those things. Let's suppose I have the file 01234.txt which is iso-8859-1. When I do: iconv --fr...
Different results from converting a file from iso-8859-1 to utf-8 iconv in shell vs calling it from python with subprocess
Well, this could be a simple question, to be frank I'm a little confused with encodings an all those things. Let's suppose I have the file 01234.txt which is iso-8859-1. When I do: iconv --from-code=iso-8859-1 --to-code=utf-8 01234.txt > 01234_utf8.txt It gives me the desired result, but when I do the same thing with ...
[ "You wrote: \"In the python file I've used coding: utf-8 and coding: iso-8859-1.\"\nOnly the first of those will be used. Secondly, that specifies the encoding of the Python source file in which it appears, so that the Python compiler can do its job. Consequently it is absolutely nothing to do with the encodings of...
[ 1 ]
[]
[]
[ "iconv", "python", "subprocess" ]
stackoverflow_0002255509_iconv_python_subprocess.txt
Q: Pylons: Routes information availability from templates I'm building a Pylons application using evoque as our templating engine, though I think my question is relevant to other template engines. I have a base template that I'm using for our pages, and that base template does all the includes for CSS and Javascript ...
Pylons: Routes information availability from templates
I'm building a Pylons application using evoque as our templating engine, though I think my question is relevant to other template engines. I have a base template that I'm using for our pages, and that base template does all the includes for CSS and Javascript files. I'd like to perform conditional test to include/exclu...
[ "You can pull the controller and action information from environ['pylons.routes_dict']['controller'] and ['action'].\nI'm not sure if environ is passed into the tmpl_context by default, but if not, you can just add something like this to the BaseController.__before__ method:\nc.routes_dict = environ['pylons.routes_...
[ 2 ]
[]
[]
[ "pylons", "python", "routes", "templates" ]
stackoverflow_0002255026_pylons_python_routes_templates.txt
Q: Sharing scripts that require a virtualenv to be activated I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated. Now I want to share those scr...
Sharing scripts that require a virtualenv to be activated
I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated. Now I want to share those scripts with other users on the server, but without requiring them...
[ "Use the following magic(5) at the start of the script.\n#!/usr/bin/env python\n\nChange which virtualenv is active and it'll use the python from that virtualenv.\nDeactivate the virtualenv, it still runs.\n", "I would vote for adding a shebang line in scriptname pointing to the correct virtualenv python. You jus...
[ 106, 6, -1 ]
[]
[]
[ "python", "virtualenv" ]
stackoverflow_0002253712_python_virtualenv.txt