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:
Flush the console screen with special unicode class workaround for windows console
I"m trying to make a simple text progress bar in windows console and also display utf8 characters.
The problem isn't that the unicode characters won't display, they will.
It's that in order to make the unicode characters display I u... | Flush the console screen with special unicode class workaround for windows console | I"m trying to make a simple text progress bar in windows console and also display utf8 characters.
The problem isn't that the unicode characters won't display, they will.
It's that in order to make the unicode characters display I used a class to tell sys.stdout what to do. This has interfered with the normal flush() f... | [
"Maybe you should use the more primitive method of using backspace to remove previous number?\nOr do something like:\ndef progress(num): \n sys.stdout.write(\"\\r\"+20*\" \"+\"\\r\"+str(num)+\"% τοις εκατό...\") \n\nto overwrite with spaces after return and do second return.\nI do not see any flashing when I ... | [
1
] | [] | [] | [
"console",
"python",
"utf_8"
] | stackoverflow_0003582309_console_python_utf_8.txt |
Q:
Safe expression parser in Python
How can I allow users to execute mathematical expressions in a safe way?
Do I need to write a full parser?
Is there something like ast.literal_eval(), but for expressions?
A:
The examples provided with Pyparsing include several expression parsers:
https://github.com/pyparsing/py... | Safe expression parser in Python | How can I allow users to execute mathematical expressions in a safe way?
Do I need to write a full parser?
Is there something like ast.literal_eval(), but for expressions?
| [
"The examples provided with Pyparsing include several expression parsers:\n\nhttps://github.com/pyparsing/pyparsing/blob/master/examples/fourFn.py is a conventional arithmetic infix notation parser/evaluator implementation using pyparsing. (Despite its name, this actually does 5-function arithmetic, plus several tr... | [
10,
3,
1,
0
] | [
"maths functions will consist of numeric and punctuation characters, possible 'E' or 'e' if you allow scientific notation for rational numbers, and the only (other) legal use of alpha characters will be if you allow/provide specific maths functions (e.g. stddev). So, should be trivial to run along the string for a... | [
-2
] | [
"parsing",
"python"
] | stackoverflow_0003582403_parsing_python.txt |
Q:
Twisted and starpy error (python)
I'm using this:
from twisted.web.client import getPage
df = getPage(url) # there is some url
I'm getting the following error. Please can anyone guide me on this
ERROR:twsited:Unhandled error in Deferred:
ERROR:twsited:Unhandled Error
Traceback (most recent call last):
File "/us... | Twisted and starpy error (python) | I'm using this:
from twisted.web.client import getPage
df = getPage(url) # there is some url
I'm getting the following error. Please can anyone guide me on this
ERROR:twsited:Unhandled error in Deferred:
ERROR:twsited:Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/sta... | [
"The code posted is not complete. The error is not due to getPage.\nFrom the stack trace clues, this uses AMIProtocol (line receiver) .\nI guess some where you have to specify your protocol channel in AMIProtocol \nsetVar(self, channel, variable, value) in star.py.\nThis is not a twisted issue.\n"
] | [
0
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0003566344_python_twisted.txt |
Q:
Checking ogg-Files using Python on OSX and Linux
I am writing a python module which checks several media and document formats whether the files correct or somehow corrupted/wrong formatted. It returns an error message or - if the file is correct - some information about the file (e.g. framerate, channels, ...)
Now... | Checking ogg-Files using Python on OSX and Linux | I am writing a python module which checks several media and document formats whether the files correct or somehow corrupted/wrong formatted. It returns an error message or - if the file is correct - some information about the file (e.g. framerate, channels, ...)
Now I am looking for a python module which I can use to c... | [
"Have you looked at Hachoir? It 'extracts metadata from multimedia files', including Ogg Vorbis.\nThe different file format parsers give differing levels of detail, and I haven't tried the Vorbis one, but it might be what you are looking for. Here's an example of metatdata extraction from an AVI file:\n$ hachoir-me... | [
2
] | [] | [] | [
"audio",
"python"
] | stackoverflow_0003582737_audio_python.txt |
Q:
MacPorts for Python on Leopard
I haven't found any concrete language on the terminal commands for installing python 3.1 on Leopard using MacPorts. I already have 2.5.1 on Leopard by way of Apple. I don't want to mess with this version & I think having the newer version of Python running from my opt/local file woul... | MacPorts for Python on Leopard | I haven't found any concrete language on the terminal commands for installing python 3.1 on Leopard using MacPorts. I already have 2.5.1 on Leopard by way of Apple. I don't want to mess with this version & I think having the newer version of Python running from my opt/local file would be better. Also SQL3 comes packed ... | [
"\nI haven't found any concrete language on the terminal commands for installing python 3.1 on Leopard using MacPorts.\n\nsudo port install python31 will install Python 3.1 (into /opt/local). In general, port install <portname> will install a port. You can find ports using port search <string> or search online.\n\n... | [
2,
0
] | [] | [] | [
"django",
"macports",
"osx_leopard",
"python"
] | stackoverflow_0002600125_django_macports_osx_leopard_python.txt |
Q:
Python: Error --> setting an array element with a sequence
The data-element is a float-number and no sequence (I think). But I get the error "setting an array element with a sequence".
folder = r"C:\Dokumente und Einstellungen\ssc"
contents=os.listdir(folder)
ar = zeros((81,81,256),int)
filenumber = 0
for d in c... | Python: Error --> setting an array element with a sequence | The data-element is a float-number and no sequence (I think). But I get the error "setting an array element with a sequence".
folder = r"C:\Dokumente und Einstellungen\ssc"
contents=os.listdir(folder)
ar = zeros((81,81,256),int)
filenumber = 0
for d in contents:
if str(".bin") in d:
filename = os.path.joi... | [
"Do you mean ar[filenumber,k,m] = data? I don't think you can index it with filename.\n"
] | [
1
] | [] | [] | [
"arrays",
"multidimensional_array",
"numpy",
"python"
] | stackoverflow_0003582948_arrays_multidimensional_array_numpy_python.txt |
Q:
Delete all files/directories except two specific directories
So, there seems to be a few questions asking about removing files/directories matching certain cases, but I'm looking for the exact opposite: Delete EVERYTHING in a folder that DOESN'T match my provided examples.
For example, here is an example director... | Delete all files/directories except two specific directories | So, there seems to be a few questions asking about removing files/directories matching certain cases, but I'm looking for the exact opposite: Delete EVERYTHING in a folder that DOESN'T match my provided examples.
For example, here is an example directory tree:
.
|-- coke
| |-- diet
| |-- regular
| `-- vanilla
|-... | [
"This command will leave only the desired files in their original directories:\nfind test \\( ! -path \"test/mtndew/livewire/*\" ! -path \"test/icecream/cupcake/*\" \\) -delete\n\nNo need for cpio. It works on Ubuntu, Debian 5, and Mac OS X.\nOn Linux, it will report that it cannot delete non-empty directories, whi... | [
6,
4,
3,
2,
2,
2,
0,
0,
0,
0
] | [] | [] | [
"bash",
"linux",
"python"
] | stackoverflow_0000862388_bash_linux_python.txt |
Q:
How to add items to wx.ScrolledPanel?
I want to add dynamically captured images in hierarchical structure (one after one). I want to add them to wx.ScrolledPanel
ScrolledPanel definition - updated
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
#self.sizer.Add(self.hbox)
self.scroll = scrolled.ScrolledPanel(sel... | How to add items to wx.ScrolledPanel? | I want to add dynamically captured images in hierarchical structure (one after one). I want to add them to wx.ScrolledPanel
ScrolledPanel definition - updated
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
#self.sizer.Add(self.hbox)
self.scroll = scrolled.ScrolledPanel(self, id = -1, pos = wx.DefaultPosition, size ... | [
"Here is a crude but runnable example of what you want, there is a slight glitch in it thought that I haven't figured out the cause of yet! (You just need to put a thumbnail size jpg called \"image.jpg\" in the same directory as the script)\nimport wx\nimport wx.lib.scrolledpanel as scrolled\n\nclass ImageDlg(wx.D... | [
1
] | [] | [] | [
"python",
"scroll",
"wxpython"
] | stackoverflow_0003582696_python_scroll_wxpython.txt |
Q:
How do I install python gtkmozembed package or is there a replacement of python GtkMozEmbed in windows?
self.widget = gtkmozembed.MozEmbed()
self.widget.set_size_request(x + 18, y)
I can't find a binary installer of gtkmozembed,
is there an equivalent that can do the above ?
A:
You should specify what OS/platfo... | How do I install python gtkmozembed package or is there a replacement of python GtkMozEmbed in windows? | self.widget = gtkmozembed.MozEmbed()
self.widget.set_size_request(x + 18, y)
I can't find a binary installer of gtkmozembed,
is there an equivalent that can do the above ?
| [
"You should specify what OS/platform you're on. Binary installers are OS-specific.\nAlso you should specify more accurately what you're trying to do. The code is pretty much out of context and it can be hard to see what you're trying to do.\nI'm assuming you're trying to have an embedded browser widget in your Pyth... | [
0
] | [] | [] | [
"package",
"python"
] | stackoverflow_0002635577_package_python.txt |
Q:
KeyError when trying to save model instance. Django
KeyError when trying to save model instance.
It has to react on post_save signal than save instance...
Code:
from django.db.models.signals import post_save
class PlaylistEntry(models.Model):
playlist=models.ForeignKey(Playlist)
media=models.ForeignKey(Me... | KeyError when trying to save model instance. Django | KeyError when trying to save model instance.
It has to react on post_save signal than save instance...
Code:
from django.db.models.signals import post_save
class PlaylistEntry(models.Model):
playlist=models.ForeignKey(Playlist)
media=models.ForeignKey(Media)
order=models.PositiveIntegerField(default=900000... | [
"From your comments what you're trying to do is update ordering. Rather than use a signal, override the save method. \ndef save(self, *args, **kwargs):\n # Only do this if it's the first time we're saving.\n if not self.id:\n entries = PlaylistEntry.objects.order_by('-order')\n try:\n ... | [
1,
0
] | [] | [] | [
"django",
"python",
"signals"
] | stackoverflow_0003577470_django_python_signals.txt |
Q:
Test for email charsets with python
I want to import emails from an mbox format into a Django app. All database tables are Unicode. My problem: sometimes the wrong charset is given, sometimes none at all. What is the best way to deal with these encoding issues?
So far, I merely nest exceptions to try the two most ... | Test for email charsets with python | I want to import emails from an mbox format into a Django app. All database tables are Unicode. My problem: sometimes the wrong charset is given, sometimes none at all. What is the best way to deal with these encoding issues?
So far, I merely nest exceptions to try the two most common charsets I receive mails in (utf-8... | [
"You could ask the excellent chardet library to guess the encoding.\n\"Character encoding auto-detection in Python 2 and 3. As smart as your browser. Open source.\"\n",
"I'm sorry but your strategy is WRONG.\nFirstly, there are encodings that were deliberately designed to fly under the 7-bit ASCII radar so that t... | [
1,
0
] | [] | [] | [
"email",
"python",
"unicode"
] | stackoverflow_0003532641_email_python_unicode.txt |
Q:
How to model a m2m relation where the related table can be a city, a region (state) or a country
In Django I have theses models:
class Artist(models.Model):
name = models.CharField(max_length=128)
born_place = models.ForeignKey(???)
dead_place = models.ForeignKey(???)
live_places = models.ManyToMan... | How to model a m2m relation where the related table can be a city, a region (state) or a country | In Django I have theses models:
class Artist(models.Model):
name = models.CharField(max_length=128)
born_place = models.ForeignKey(???)
dead_place = models.ForeignKey(???)
live_places = models.ManyToManyField(???)
work_places = models.ManyToManyField(???)
class Country(models.Model):
iso = mode... | [
"\nAll the places (born_place, dead_place, live_places, work_places) can be a City or a Region or a Country.\n\nWhat you need in this case is a generic foreign key. In Django this can be achieved through the handy contenttypes framework.\nFrom the documentation:\n\nThere are three parts to setting up a GenericForei... | [
1,
1,
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003580849_django_python.txt |
Q:
How do I apply a patch from gist to the Django source?
I want to try out a patch on gist that modifies the source code of Django:
gist: 550436
How do I do it? I have never used git so a step by step instruction would be greatly appreciated.
A:
You can use patch to apply diffs. Make sure you're in your django sou... | How do I apply a patch from gist to the Django source? | I want to try out a patch on gist that modifies the source code of Django:
gist: 550436
How do I do it? I have never used git so a step by step instruction would be greatly appreciated.
| [
"You can use patch to apply diffs. Make sure you're in your django source directory (or wherever you want to apply the patch), and run something like patch -p1 < downloaded-patch.diff.\nYou may want to experiment with the -p argument if it fails; -p tells patch to strip some of the directory prefix for each file in... | [
7
] | [] | [] | [
"git",
"github",
"patch",
"python"
] | stackoverflow_0003582849_git_github_patch_python.txt |
Q:
Overriding __new__ and __init__ in Python
Possible Duplicate:
Python's use of __new__ and __init__ ?
The way I understand it, __init__ is different from a constructor in Java, because __init__ only initializes an object that has already been constructed implicitly (because __init__ is called after __new__). Howe... | Overriding __new__ and __init__ in Python |
Possible Duplicate:
Python's use of __new__ and __init__ ?
The way I understand it, __init__ is different from a constructor in Java, because __init__ only initializes an object that has already been constructed implicitly (because __init__ is called after __new__). However, everything that I have ever needed to def... | [
"__new__ actually happens before an object exists. It's a static method of the type. Uses of __new__ are when you want to control the creation of new objects, e.g. a singleton. If your __new__ always returns the same instance of an object, it's a singleton. You can't do that with __init__.\nGenerally, in \"python a... | [
13,
3
] | [] | [] | [
"python"
] | stackoverflow_0003584042_python.txt |
Q:
error while trying to connect with a cisco 2600 router through python in windows
The code i have given is
import telnetlib
HOST="X"
user ="X"
password="X"
en_password="x"
tn=telnetlib.Telnet(HOST)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
tn=telnetlib.Telnet(H... | error while trying to connect with a cisco 2600 router through python in windows | The code i have given is
import telnetlib
HOST="X"
user ="X"
password="X"
en_password="x"
tn=telnetlib.Telnet(HOST)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
tn=telnetlib.Telnet(HOST)
File "C:\Python27\lib\telnetlib.py", line 209, in __init__
self.... | [
"It's a connection timeout - if you're not having a other networking issues then it's simply that the router is not accepting connections on the default telnet port. Are you sure you can connect via port 23? Can you use a telnet client to connect?\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0003582970_python.txt |
Q:
How do you create a video file upload form with Django?
I want a user to be able to upload a video from their computer or record it right from their webcam, then fill out other information with a form. I'm writing this app with Django.
A:
Recording directly from the web cam is not as simple as uploading an exist... | How do you create a video file upload form with Django? | I want a user to be able to upload a video from their computer or record it right from their webcam, then fill out other information with a form. I'm writing this app with Django.
| [
"Recording directly from the web cam is not as simple as uploading an existing video file. You may need to look into one of the many video streaming protocols and handle that via a server such as red5. This approach would require the use of Flash or something similar.\n",
"The Django documentation should be abl... | [
1,
0,
0
] | [] | [] | [
"django",
"file_upload",
"forms",
"python",
"video"
] | stackoverflow_0003580778_django_file_upload_forms_python_video.txt |
Q:
Need performance on postGIS with GeoDjango
This is the first time I'm using GeoDjango with postGIS. After installation and some tests with everything running fine I am concerned about query performance when table rows will grow.
I'm saving in a geometry point longitudes and latitudes that I get from Google geocodi... | Need performance on postGIS with GeoDjango | This is the first time I'm using GeoDjango with postGIS. After installation and some tests with everything running fine I am concerned about query performance when table rows will grow.
I'm saving in a geometry point longitudes and latitudes that I get from Google geocoding (WGS84, or SRID 4326). My problem is that dis... | [
"If you can fit your working area into a map projection, that will always be faster, as there are fewer math calls necessary for things like distance calculations. However, if you have truly global data, suck it up: use geography. If you only have continental USA data, use something like EPSG:2163 http://spatialref... | [
3,
3,
0
] | [] | [] | [
"django",
"geodjango",
"postgis",
"python"
] | stackoverflow_0003547699_django_geodjango_postgis_python.txt |
Q:
How to properly add quotes to a string using python?
I want to add a set of (double) quotes to a python string if they are missing but the string can also contain quotes.
The purpose of this is to quote all command that are not already quoted because Windows API requires you to quote the entire command line when y... | How to properly add quotes to a string using python? | I want to add a set of (double) quotes to a python string if they are missing but the string can also contain quotes.
The purpose of this is to quote all command that are not already quoted because Windows API requires you to quote the entire command line when you execute a process using _popen().
Here are some strings... | [
"Your problem is inconsistent.\nConsider the two cases\n\n\"\"a\" b\"\n\"a\" \"b\"\n\nThe former is interpreted as a pre-quoted string with 'nested quotes', but the latter is interpreted as separately-quoted strings. Here are some examples that highlight the issue.\n\n\" \"a\" \"b\" \"\n\" \"a\" b\"\n\"a \"\"b\"\n\... | [
8,
4,
3
] | [
"You have three cases:\n\nString is less than two characters long: add quotes\nString has quotes at s[0] and at s[1]: don't add quotes\nAdd quotes\n\nAnd by \"add quotes\" I mean simply construct '\"'+string+'\"' and return it.\nTranslate to if-statements, and you're done.\n"
] | [
-1
] | [
"python",
"string"
] | stackoverflow_0003584005_python_string.txt |
Q:
Create a python function at runtime to match a variable number of dictionary entries
I'm making a program to calculate latency from a tcpdump/pcap file and I want to be able to specify rules on the command line to correlate packets -- i.e. find the time taken between sending a packet matching rule A to receiving a... | Create a python function at runtime to match a variable number of dictionary entries | I'm making a program to calculate latency from a tcpdump/pcap file and I want to be able to specify rules on the command line to correlate packets -- i.e. find the time taken between sending a packet matching rule A to receiving a packet matching rule B (concrete example would be a FIX NewOrderSingle being sent and a c... | [
"Don't use lambdas. They are late binding. Perhaps you want a partial from functools, but even that seems too complex.\nYour data coming in has field names, numbers and values, right? \nYour command-line parameters use field numbers and values, right?\nYou want a dictionary keyed by field number. In that case, ... | [
2
] | [] | [] | [
"dynamic",
"lambda",
"matching",
"python"
] | stackoverflow_0003585225_dynamic_lambda_matching_python.txt |
Q:
How to use less than and equal to in an assert statement in python
When I run the following:
growthRates = [3, 4, 5, 0, 3]
for each in growthRates:
print each
assert growthRates >= 0, 'Growth Rate is not between 0 and 100'
assert growthRates <= 100, 'Growth Rate is not between 0 and 100'
I get:
3
Trac... | How to use less than and equal to in an assert statement in python | When I run the following:
growthRates = [3, 4, 5, 0, 3]
for each in growthRates:
print each
assert growthRates >= 0, 'Growth Rate is not between 0 and 100'
assert growthRates <= 100, 'Growth Rate is not between 0 and 100'
I get:
3
Traceback (most recent call last):
File "ps4.py", line 132, in <module>
... | [
"Do:\nassert each >= 0, 'Growth Rate is not between 0 and 100'\n\nnot:\nassert growthRates >= 0, 'Growth Rate is not between 0 and 100'\n\n",
"assert 0 <= each <= 100, 'Growth Rate %i is not between 0 and 100.' % each\n\nYour asserts do not fail of course then, but now the growthRates > 100 because growthRates is... | [
15,
6,
4,
2,
0
] | [] | [] | [
"assert",
"comparison",
"python"
] | stackoverflow_0003585443_assert_comparison_python.txt |
Q:
Python decorators and class inheritance
I'm trying to use decorators in order to manage the way users may or may not access resources within a web application (running on Google App Engine). Please note that I'm not allowing users to log in with their Google accounts, so setting specific access rights to specific ... | Python decorators and class inheritance | I'm trying to use decorators in order to manage the way users may or may not access resources within a web application (running on Google App Engine). Please note that I'm not allowing users to log in with their Google accounts, so setting specific access rights to specific routes within app.yaml is not an option.
I us... | [
"Your original code, with two small tweaks, should also work. A class-based approach seems rather heavy-weight for such a simple decorator:\nclass RequestHandler(webapp.RequestHandler):\n\n # The decorator is now a class method.\n @classmethod # Note the 'klass' argument, similar to 'self' on an instance ... | [
4,
1
] | [] | [] | [
"decorator",
"python",
"subclassing",
"web_applications"
] | stackoverflow_0003378949_decorator_python_subclassing_web_applications.txt |
Q:
How to Get a Certain Number of Elements from a Django Database
I have a simple class:
class BlogPost(models.Model):
title = models.CharField(max_length=150)
...
timestamp = models.DateTimeField()
How can I get the last five items from the database?
I tried to do this:
posts = BlogPost.objects.<any cod... | How to Get a Certain Number of Elements from a Django Database | I have a simple class:
class BlogPost(models.Model):
title = models.CharField(max_length=150)
...
timestamp = models.DateTimeField()
How can I get the last five items from the database?
I tried to do this:
posts = BlogPost.objects.<any code>
| [
"You need to invest some time in Reading The Friggin' Manual. Django is one of the best documented open source projects on the planet.\nHer's the specific thing you want to read, Limiting QuerySets, but you really need to read the whole page (and a few others) if you are going to do anything meaningful with Django.... | [
7,
1,
0,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003585919_django_django_models_python.txt |
Q:
gtk idle_add not running?
I have a two-thread application: GUI, and some background work. I'm trying to send requests to the main thread to do GUI updates (move a progress bar), but it doesn't seem to work. I've boiled it down to a really minimal example:
import pygtk
pygtk.require('2.0')
import glib
import gtk
i... | gtk idle_add not running? | I have a two-thread application: GUI, and some background work. I'm trying to send requests to the main thread to do GUI updates (move a progress bar), but it doesn't seem to work. I've boiled it down to a really minimal example:
import pygtk
pygtk.require('2.0')
import glib
import gtk
import threading
import sys
impo... | [
"You need to init glib's thread support before using glib in a multi-threaded environment. Just call:\nglib.threads_init()\n\nBefore calling into glib functions.\n",
"Why not use glib.timeout_add_seconds(1, idle) and return False from idle() instead of starting a thread and then sleeping 1 second? Starting an idl... | [
4,
3,
0
] | [] | [] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0003579221_gtk_pygtk_python.txt |
Q:
Can I make a program reading from a piped stdin AND keyboard?
Can I write a python program that read from a piped stdin and keyboard?
What I mean? I want to be able to use it in this way:
tail -f LOGFILE | myscript.py
see the log lines appearing in the screen and type commands with the keyboard?
This sounds like ... | Can I make a program reading from a piped stdin AND keyboard? | Can I write a python program that read from a piped stdin and keyboard?
What I mean? I want to be able to use it in this way:
tail -f LOGFILE | myscript.py
see the log lines appearing in the screen and type commands with the keyboard?
This sounds like 2 stdin and that confuse me. Is it possible or is it conceptually w... | [
"Possible solution would be to grab the users current tty and attach a file stream to the corresponding /dev/tty entry.\nThis may allow you to grab the keyboard input while using stdin as your piped log file.\n",
"Make your script take a file argument, then use bash's ability to create an anonymous fifo:\nmyscrip... | [
4,
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0003584857_python.txt |
Q:
How can I get 'urlpatterns = __import__()' to work like a normal import statement?
I'm trying to create an import statement that's pluggable with other projects.
This statement is located in urls.py
So this works:
from forum.urls import urlpatterns
# Base Class: <type 'list'>
But this doesn't work:
from set... | How can I get 'urlpatterns = __import__()' to work like a normal import statement? | I'm trying to create an import statement that's pluggable with other projects.
This statement is located in urls.py
So this works:
from forum.urls import urlpatterns
# Base Class: <type 'list'>
But this doesn't work:
from settings import ROOT_URLCONF as project_urls
urlpatterns = __import__(project_urls)
# Base ... | [
"So you want to have import statements that are relative to earlier imports? \nDefinitely something I tried at one point. I had some very long import statements that had a common root, so I tried to factor it out. I could not get it to work with straight import statements, but maybe I didn't try hard enough.\nKe... | [
1,
0
] | [] | [] | [
"python",
"python_import",
"python_module"
] | stackoverflow_0003586152_python_python_import_python_module.txt |
Q:
Why my program freezing while I am listening socket
So, here is some code:
obj.HOST = ""
obj.PORT = int(port.get()) # it's 100% correct PORT number
obj.srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
obj.srv.bind((obj.HOST, obj.PORT))
obj.srv.listen(1)
obj.sock, obj.addr = obj.srv.accept()
class Client(th... | Why my program freezing while I am listening socket | So, here is some code:
obj.HOST = ""
obj.PORT = int(port.get()) # it's 100% correct PORT number
obj.srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
obj.srv.bind((obj.HOST, obj.PORT))
obj.srv.listen(1)
obj.sock, obj.addr = obj.srv.accept()
class Client(threading.Thread):
def __init__(self,from_):
i... | [
"Not sure what the obj is.\nBut you are not sending anything from the server to client. \non the server side, you could do some thing like this :\nconn, addr = srv.accept()\nprint 'Connected by', addr\nconn.send(\"confirm\")\nconn.close()\n\nThis will accept a single connection, send some data \"confirm\", close co... | [
0
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0003586452_python_sockets.txt |
Q:
Merits of Bash Script v. Python Script for Shell-Command-Heavy Utility
I need to write a script to do the following:
Monitor a queuing system, which is accessible by shell commands.
Create directories from templates using a mix of inline text editing, cp/mv, command line scripts, and compiled c++ programs.
Check ... | Merits of Bash Script v. Python Script for Shell-Command-Heavy Utility | I need to write a script to do the following:
Monitor a queuing system, which is accessible by shell commands.
Create directories from templates using a mix of inline text editing, cp/mv, command line scripts, and compiled c++ programs.
Check for error conditions.
Write files on error conditions.
Note: 2D arrays woul... | [
"If you can't find a reason to switch it's probably because there's no reason.\nI started to switch python because some of my scripts require some templating process that was easier to do in other than shell script. \nThere were also another scripts which required configuration file parsing or parameter parsing th... | [
7,
3,
3
] | [] | [] | [
"bash",
"performance",
"python",
"refactoring",
"shell"
] | stackoverflow_0003585912_bash_performance_python_refactoring_shell.txt |
Q:
How to manage several python subprojects with setuptools?
I'm wondering about the correct/easiest/most pythonic way of dealing with subprojects that you want have using the same base package. We currently have a file structure like this:
trunk\
proj1\setup.py
company_name\__init__.py + proj1's code
... | How to manage several python subprojects with setuptools? | I'm wondering about the correct/easiest/most pythonic way of dealing with subprojects that you want have using the same base package. We currently have a file structure like this:
trunk\
proj1\setup.py
company_name\__init__.py + proj1's code
proj2\setup.py
company_name\__init__.py + proj2's ... | [
"While I can't vouch for the pythonity of my solution, I did finally get the different applications running together alright. I was on the right track with the namespace packages, but instead of trying to have one super-project in the trunk, I added the namespace_packages line in the setup.py of each individual pro... | [
7
] | [] | [] | [
"name_conflict",
"namespace_package",
"package",
"python",
"setuptools"
] | stackoverflow_0003574799_name_conflict_namespace_package_package_python_setuptools.txt |
Q:
DEADLOCK_WRAP error when using Berkeley Db in python (bsddb)
I am using a berkdb to store a huge list of key-value pairs but for some reason when i try to access some of the data later i get this error:
try:
key = 'scrape011201-590652'
contenttext = contentdict[key]
except:
print the error
<type 'exce... | DEADLOCK_WRAP error when using Berkeley Db in python (bsddb) | I am using a berkdb to store a huge list of key-value pairs but for some reason when i try to access some of the data later i get this error:
try:
key = 'scrape011201-590652'
contenttext = contentdict[key]
except:
print the error
<type 'exceptions.KeyError'> 'scrape011201-590652' in
contenttext = content... | [
"I'm pretty certain the DeadlockWrap stuff is not relevant here. It's simply a way to automagically provide retries with a back-off strategy. In other words, if the database manipulation fails, it waits a little bit then tries again, a number of times before finally failing.\nYou seem to be getting a KeyError from ... | [
4,
0
] | [] | [] | [
"berkeley_db",
"bsddb",
"python"
] | stackoverflow_0002569227_berkeley_db_bsddb_python.txt |
Q:
Pythonic Object Instantiation question
I have a Sleep class (object) and within that class a sleepInSeconds() method.
Is there any difference between doing this:
wait = Sleep()
wait.sleepInSeconds(10)
And doing this:
wait = Sleep().sleepInSeconds(10)
or
Sleep().sleepInSeconds(10)
Which is more correct (or 'Pyt... | Pythonic Object Instantiation question | I have a Sleep class (object) and within that class a sleepInSeconds() method.
Is there any difference between doing this:
wait = Sleep()
wait.sleepInSeconds(10)
And doing this:
wait = Sleep().sleepInSeconds(10)
or
Sleep().sleepInSeconds(10)
Which is more correct (or 'Pythonic'), what kinds of problems could I run ... | [
"If sleepInSeconds is a static method (seen from a functional point of view) you are misusing the sleep class as a namespace. Sounds a bit like a java background.\nYou could perhaps better make sleepInSeconds a function in the module namespace (not in a class) as python has very good namespace support.\nIf you stil... | [
4,
4,
3,
3
] | [] | [] | [
"object",
"python"
] | stackoverflow_0003587137_object_python.txt |
Q:
Python - Dynamic Nested List
So I'm trying to generate a nested list in Python based on a width and a height. This is what I have so far:
width = 4
height = 5
row = [None]*width
map = [row]*height
Now, this obviously isn't quite right. When printed it looks fine:
[[None, None, None, None],
[None,... | Python - Dynamic Nested List | So I'm trying to generate a nested list in Python based on a width and a height. This is what I have so far:
width = 4
height = 5
row = [None]*width
map = [row]*height
Now, this obviously isn't quite right. When printed it looks fine:
[[None, None, None, None],
[None, None, None, None],
[None, None, ... | [
"When you do [row]*height you end up with the same list object in each row. The row array reference is repeated in each row which means each row is actually pointing to the same list object. Hence modifying one row actually modifies all rows.\nTake a look at what happens when you print the id() for each row. They'r... | [
12,
1
] | [] | [] | [
"list",
"nested",
"python"
] | stackoverflow_0003587215_list_nested_python.txt |
Q:
Work with JSON in Python
{"required_items":[
{
"filename":"abcd",
"no":"3"
},
{
"filename":"abc",
"no":"2"
}
]}
I am not getting the code of... | Work with JSON in Python | {"required_items":[
{
"filename":"abcd",
"no":"3"
},
{
"filename":"abc",
"no":"2"
}
]}
I am not getting the code of the JSON format in Python - ... | [
"# data.txt\n\n{\"required_items\":[\n {\n \"filename\":\"abcd\",\n \"no\":\"3\"\n },\n {\n \"filename\":\"abc\",\n \"no\":\"2\"\n }\n ]}\n\n\n# parser... | [
5
] | [] | [] | [
"json",
"python"
] | stackoverflow_0003587023_json_python.txt |
Q:
Python & HTML: Make user login to use website
I'm creating a website with a database search functionality, but I want to make the user login or create a account first to use the search functionality. How do I do this? And what is the easiest way to carry the login session forward. I.E. the user only has to login o... | Python & HTML: Make user login to use website | I'm creating a website with a database search functionality, but I want to make the user login or create a account first to use the search functionality. How do I do this? And what is the easiest way to carry the login session forward. I.E. the user only has to login once to do many searches.
| [
"Look at Web Frameworks for Python, and select one of the listed\nPopular Full-Stack Frameworks (Django, TurboGears, ...).\nEach framework provides its own session support.\nSO discussions, for example choosing-a-web-application-framework-in-python,\ncan help you choose one that meets your requirements.\n",
"If y... | [
3,
0
] | [] | [] | [
"html",
"plone",
"python"
] | stackoverflow_0003442732_html_plone_python.txt |
Q:
Python - very confused about method and while loop
I have this method:
def is_active(self):
if self.is_current_node():
return True
cur_children = self.get_children()
while cur_children is not None:
for child in cur_children:
if child.is_current_node():
return... | Python - very confused about method and while loop | I have this method:
def is_active(self):
if self.is_current_node():
return True
cur_children = self.get_children()
while cur_children is not None:
for child in cur_children:
if child.is_current_node():
return True
raise Exception(child.display_name)
... | [
"If the first child in the list .is_current_node(), then the exception will never be raised in your first snippet.\nEverything you have for evidence is supporting the idea that either self.is_current_node() is always true, or the first scanned child .is_current_node(). Given the third code snippet, the latter seems... | [
2,
1,
0
] | [] | [] | [
"python",
"while_loop"
] | stackoverflow_0003587345_python_while_loop.txt |
Q:
oauth & POSTing JSON
Reading section 9.1 of OAuth Core 1.0, I only see a reference to performing POST requests using content-type of application/x-www-form-urlencoded.
How does one go about performing POST requests with JSON data in the request body?
How does handle the signing? Is it at all possible?
Can this... | oauth & POSTing JSON | Reading section 9.1 of OAuth Core 1.0, I only see a reference to performing POST requests using content-type of application/x-www-form-urlencoded.
How does one go about performing POST requests with JSON data in the request body?
How does handle the signing? Is it at all possible?
Can this work on AppEngine?
| [
"I have urlencoded the JSON, then unencoded on the other end in the past. I don't really know anything about AppEngine though, sorry.\n"
] | [
0
] | [] | [] | [
"google_app_engine",
"json",
"oauth",
"python"
] | stackoverflow_0003587454_google_app_engine_json_oauth_python.txt |
Q:
django modeladmin list_display
I'm trying to play with the Django's official tutorial. Specifically the modeladmin list_display:
http://docs.djangoproject.com/en/1.2/intro/tutorial02/#customize-the-admin-change-list
How can I add a column that displays the number of choices for each poll in the list?
Thanks!
A:
... | django modeladmin list_display | I'm trying to play with the Django's official tutorial. Specifically the modeladmin list_display:
http://docs.djangoproject.com/en/1.2/intro/tutorial02/#customize-the-admin-change-list
How can I add a column that displays the number of choices for each poll in the list?
Thanks!
| [
"You don't need to edit your model, to calculate columns for admin on the fly create a function in the ModelAdmin object that takes a second param, this will be the regular Poll model instance. Than write code just like you would in a model, you can ignore the self here since it doesn't have what you want.\nclass ... | [
3,
1
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0003586149_django_django_admin_python.txt |
Q:
Foreignkeyfield - verbose name not shown in form
my verbose_name of a foreignkeyfield isn't printed in my forms. (I create the modelforms via modelformset_factory
model
class MOrders(models.Model):
amount = models.IntegerField('Bestellmenge', null=True, blank=True)
order_date = models.DateField('Bestelldat... | Foreignkeyfield - verbose name not shown in form | my verbose_name of a foreignkeyfield isn't printed in my forms. (I create the modelforms via modelformset_factory
model
class MOrders(models.Model):
amount = models.IntegerField('Bestellmenge', null=True, blank=True)
order_date = models.DateField('Bestelldatum')
id = models.AutoField(primary_key=True)
m... | [
"m_product_types = models.ForeignKey(MProductTypes, \n verbose_name = u'Produktart',\n )\n\n"
] | [
15
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003587613_django_django_models_python.txt |
Q:
Python error, only in the command window. Causes site to hang when loading
I receive this error when files are loading and sometimes after they have stopped loading. It only happens with this site, not with my other django sites. I can't make any sense of this one. Can anyone tell me what's going wrong here?
A:
... | Python error, only in the command window. Causes site to hang when loading |
I receive this error when files are loading and sometimes after they have stopped loading. It only happens with this site, not with my other django sites. I can't make any sense of this one. Can anyone tell me what's going wrong here?
| [
"Your server is too slow or it doesn't responds (networking problem, not a Python problem), that's what happens.\n\nonly in the command window\n\n?\n",
"Too large an upload? Your front end interrupted the transfer somehow? Could be anything. We'll need more details to pin point the problem. Also, does this happen... | [
1,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003587747_django_python.txt |
Q:
Google App Engine: Webtest simulating logged in user and administrator
from the webtest documentation I learn that:
The best way to simulate
authentication is if your application
looks in environ['REMOTE_USER'] to see
if someone is authenticated. Then you
can simply set that value, like:
app.get('/secret... | Google App Engine: Webtest simulating logged in user and administrator | from the webtest documentation I learn that:
The best way to simulate
authentication is if your application
looks in environ['REMOTE_USER'] to see
if someone is authenticated. Then you
can simply set that value, like:
app.get('/secret', extra_environ=dict(REMOTE_USER='bob'))
I am trying to do the same thing ... | [
"Set User:\nos.environ['USER_EMAIL'] = 'info@example.com'\n\nSet Admin:\nos.environ['USER_IS_ADMIN'] = '1'\n\nThis is how my whole test looks like. My example uses webtest, nose, nosegae and gaetestbed. \nclass TestingRoutes(WebTestCase, unittest.TestCase):\n\n APPLICATION = application()\n\n def tearDown(sel... | [
6
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003587022_google_app_engine_python.txt |
Q:
Python: Pickling highly-recursive objects without using `setrecursionlimit`
I've been getting RuntimeError: maximum recursion depth exceeded when trying to pickle a highly-recursive tree object. Much like this asker here.
He solved his problem by setting the recursion limit higher with sys.setrecursionlimit. But I... | Python: Pickling highly-recursive objects without using `setrecursionlimit` | I've been getting RuntimeError: maximum recursion depth exceeded when trying to pickle a highly-recursive tree object. Much like this asker here.
He solved his problem by setting the recursion limit higher with sys.setrecursionlimit. But I don't want to do that: I think that's more of a workaround than a solution. Beca... | [
"I suppose that most people never use recursive structures of such depth. Since easiest serialization implementations are recursive, you're going to only see them.\nIf I were you I'd not use an openly recursive data structure here. Instead I'd number every node and use a link table that efficiently translates a num... | [
3,
2,
1,
1
] | [] | [] | [
"pickle",
"python",
"recursion"
] | stackoverflow_0002912841_pickle_python_recursion.txt |
Q:
Pickle vs output to a file in python
I have a program that outputs some lists that I want to store to work with later. For example, suppose it outputs a list of student names and another list of their midterm scores. I can store this output in the following two ways:
Standard File Output way:
newFile = open('tria... | Pickle vs output to a file in python | I have a program that outputs some lists that I want to store to work with later. For example, suppose it outputs a list of student names and another list of their midterm scores. I can store this output in the following two ways:
Standard File Output way:
newFile = open('trialWrite1.py','w')
newFile.write(str(firstNa... | [
"I think the csv module might be a good fit here, since CSV is a standard format that can be both read and written by Python (and many other languages), and it's also human-readable. Usage could be as simple as \nwith open('trialWrite1.py','wb') as fileobj:\n newFile = csv.writer(fileobj)\n newFile.writerow(f... | [
6,
3,
0
] | [] | [] | [
"file_io",
"pickle",
"python"
] | stackoverflow_0003588023_file_io_pickle_python.txt |
Q:
python: keep char only if it is within this list
i have a list:
a = ['a','b','c'.........'A','B','C'.........'Z']
and i have string:
string1= 's#$%ERGdfhliisgdfjkskjdfW$JWLI3590823r'
i want to keep ONLY those characters in string1 that exist in a
what is the most effecient way to do this? perhaps instead of havi... | python: keep char only if it is within this list | i have a list:
a = ['a','b','c'.........'A','B','C'.........'Z']
and i have string:
string1= 's#$%ERGdfhliisgdfjkskjdfW$JWLI3590823r'
i want to keep ONLY those characters in string1 that exist in a
what is the most effecient way to do this? perhaps instead of having a be a list, i should just make it a string? like t... | [
"This should be faster.\n>>> import re\n>>> string1 = 's#$%ERGdfhliisgdfjkskjdfW$JWLI3590823r'\n>>> a = ['E', 'i', 'W']\n>>> r = re.compile('[^%s]+' % ''.join(a))\n>>> print r.sub('', string1)\nEiiWW\n\nThis is even faster than that.\n>>> all_else = ''.join( chr(i) for i in range(256) if chr(i) not in set(a) )\n>>>... | [
7,
5,
3,
1,
0
] | [] | [] | [
"list",
"python",
"string"
] | stackoverflow_0003588452_list_python_string.txt |
Q:
Localization of GUI built with Glade and Python (Gtk)
I have made an application using Glade and Python and I would like to make several localizations.
I know how to localize strings that are in the Python code, I just encapsule all the strings that are supposed to be localized with _() and than specify the transl... | Localization of GUI built with Glade and Python (Gtk) | I have made an application using Glade and Python and I would like to make several localizations.
I know how to localize strings that are in the Python code, I just encapsule all the strings that are supposed to be localized with _() and than specify the translation of the string in a .po file.
But how do I tell a stri... | [
"You should be able to create a *.pot file from a *.glade file using intltool-extract --type=gettext/glade foo.glade, and intltool supposedly knows what is translatable.\nAlso, I suggest you look into GtkBuilder if you didn't do that already (you can save GtkBuilder interface files from recent Glade 3 versions, and... | [
4
] | [] | [] | [
"gettext",
"glade",
"pygtk",
"python",
"user_interface"
] | stackoverflow_0003586071_gettext_glade_pygtk_python_user_interface.txt |
Q:
Number of floats between two floats
Say I have two Python floats a and b, is there an easy way to find out how many representable real numbers are between the two in IEEE-754 representation (or whatever representation the machine used is using)?
A:
AFAIK, IEEE754 floats have an interesting property. If you have ... | Number of floats between two floats | Say I have two Python floats a and b, is there an easy way to find out how many representable real numbers are between the two in IEEE-754 representation (or whatever representation the machine used is using)?
| [
"AFAIK, IEEE754 floats have an interesting property. If you have float f, then\n(*(int*)&f + 1)\n\nunder certain conditions, is the next representable floating point number. So for floats a and b\n*(int*)&a - *(int*)&b\n\nWill give you the amount of floating point numbers between those numbers.\nSee http://www.cygn... | [
13,
12,
3,
0
] | [] | [] | [
"floating_point",
"ieee_754",
"python"
] | stackoverflow_0003587880_floating_point_ieee_754_python.txt |
Q:
python + windows: run exe as if it's unrelated to the current process
I know I can use subprocess.Popen to run an executable, and potentially redirect stdin and stdout to files / using pipes to my process. Is there a way to run an executable such that the spawned process has no relation to the current Python proce... | python + windows: run exe as if it's unrelated to the current process | I know I can use subprocess.Popen to run an executable, and potentially redirect stdin and stdout to files / using pipes to my process. Is there a way to run an executable such that the spawned process has no relation to the current Python process, however? Meaning, I want to start a process in the same way as if I wou... | [
"On Windows, see os.startfile().\n"
] | [
1
] | [] | [] | [
"process",
"python",
"pywin32",
"subprocess",
"windows"
] | stackoverflow_0003550605_process_python_pywin32_subprocess_windows.txt |
Q:
urllib2.urlopen throws 404 exception for urls that browser opens
The following url (and others like it) can be opened in a browser but causes urllib2.urlopen to throw a 404 exception: http://store.ovi.com/#/applications?categoryId=20&fragment=1&page=1
geturl() returns the same url (no redirect). The headers are co... | urllib2.urlopen throws 404 exception for urls that browser opens | The following url (and others like it) can be opened in a browser but causes urllib2.urlopen to throw a 404 exception: http://store.ovi.com/#/applications?categoryId=20&fragment=1&page=1
geturl() returns the same url (no redirect). The headers are copied and pasted from firebug. I tried passing in the headers as a dict... | [
"Given a URL like:\nhttp://store.ovi.com/#/applications?categoryId=20&fragment=1&page=2\n\nThe bit that browsers fetch is just:\nhttp://store.ovi.com/\n\nEverything to the right of that is a ‘fragment identifier’, which is not passed to the server at all (evidently, if you try, it will get confused). Instead, the H... | [
3
] | [] | [] | [
"debugging",
"exception",
"http",
"python",
"urllib2"
] | stackoverflow_0003589003_debugging_exception_http_python_urllib2.txt |
Q:
Pluggable Python program
I want to make a PyQt4 program that supports plugins. Basically I want the user to be able to write QWidget subclasses in PyQt4 and add/remove them from the main application window via a GUI. How would I do that, especially the plugin mechanism?
A:
First, use a QFileDialog or more conven... | Pluggable Python program | I want to make a PyQt4 program that supports plugins. Basically I want the user to be able to write QWidget subclasses in PyQt4 and add/remove them from the main application window via a GUI. How would I do that, especially the plugin mechanism?
| [
"First, use a QFileDialog or more conveniently the static function QFileDialog.getOpenFileName to let the user pick the .py file they want to \"plug into\" your GUI.\nNext, if you want to allow importing the plugin from anywhere on the disk (as opposed to, from specific directories previously added to your sys.path... | [
6,
0
] | [] | [] | [
"pluggable",
"plugins",
"pyqt4",
"python",
"qt"
] | stackoverflow_0003588915_pluggable_plugins_pyqt4_python_qt.txt |
Q:
Tkinter removing standard window in Ubuntu
Is there a command similar to "wm_overrideredirect" for Ubuntu? I want My program to be displayed without the standard window.
A:
Ubuntu's desktop manager is Gnome, which should support wm_overrideredirect as well as any other. What's going wrong for you when you try ... | Tkinter removing standard window in Ubuntu | Is there a command similar to "wm_overrideredirect" for Ubuntu? I want My program to be displayed without the standard window.
| [
"Ubuntu's desktop manager is Gnome, which should support wm_overrideredirect as well as any other. What's going wrong for you when you try that? Can you show (by editing your Q) some as-tiny-as-possible Python/Tkinter script that does not behave the way you want, and tell us how it does behave and how you'd like ... | [
3,
1
] | [] | [] | [
"python",
"tkinter",
"ubuntu",
"window"
] | stackoverflow_0003589185_python_tkinter_ubuntu_window.txt |
Q:
How to show a vertical rule at the beginning of the current line?
I'm looking for a way in vim to easily visualize the various indent levels of python code. It would help if there was always a vertical rule at the beginning of the current line. That way I can scan down the code to see where the current block ends.... | How to show a vertical rule at the beginning of the current line? | I'm looking for a way in vim to easily visualize the various indent levels of python code. It would help if there was always a vertical rule at the beginning of the current line. That way I can scan down the code to see where the current block ends. Are there any plugins out there that do this?
| [
"You could simply emulate indentation guides. It's simpler and more effective, in my opinion. Please, take a look at my answer to the question about indentation guides.\n",
"The first thing that comes to mind is that you could benefit from a plugin that implements code folding.\nHere is a tutorial with examples... | [
5,
1,
0,
0,
0
] | [] | [] | [
"highlighting",
"indentation",
"python",
"vim"
] | stackoverflow_0003588162_highlighting_indentation_python_vim.txt |
Q:
Django, database retrieval not working but deleting fields and adding new fields is working
I have been able to get my database queries to work properly for deleting existing entries and also adding new entries to the database but I am completely stumped as to why I am unable to retrieve anything from my database.... | Django, database retrieval not working but deleting fields and adding new fields is working | I have been able to get my database queries to work properly for deleting existing entries and also adding new entries to the database but I am completely stumped as to why I am unable to retrieve anything from my database. I am trying a query such as:
from web1.polls.models import Poll
retquery = Poll.objects.all()
pr... | [
"if you have provide well __unicode__ method to your model, you won't have such problem...\nhttp://www.djangoproject.com/documentation/models/str/\n\n",
"I finally figured this out, I am leaving this up since this can be really confusing for someone fairly new to Python, such as myself, as Django's docs don't mak... | [
1,
0
] | [] | [] | [
"django",
"mysql",
"python"
] | stackoverflow_0003589055_django_mysql_python.txt |
Q:
python enumeration class for ORM purposes
EDITED QUESTION
I'm trying to create a class factory that can generate enumeration-like classes with the following properties:
Class is initialized from the list
of allowed values (i.e., it's
automatically generated!).
Class creates one instance of itself
for each of the ... | python enumeration class for ORM purposes | EDITED QUESTION
I'm trying to create a class factory that can generate enumeration-like classes with the following properties:
Class is initialized from the list
of allowed values (i.e., it's
automatically generated!).
Class creates one instance of itself
for each of the allowed value.
Class does not allow the creatio... | [
"new answer based on updates\nI think that this satisfies all of your specified requirements. If not, we can probably add whatever you need.\ndef enum(classname, values):\n class EnumMeta(type):\n def __iter__(cls):\n return cls._instances.itervalues()\n\n class EnumType(object):\n __... | [
3,
0,
0
] | [] | [] | [
"enumeration",
"python",
"sqlalchemy"
] | stackoverflow_0003588996_enumeration_python_sqlalchemy.txt |
Q:
Error configuring Django to run customized comments framework
I'm having an issue with setting up a Django website which uses the Django comments framework on my server. The site runs fine when run locally (using manage.py runserver) but when pushed live I'm getting the error:
ImproperlyConfigured at /
The COMMENT... | Error configuring Django to run customized comments framework | I'm having an issue with setting up a Django website which uses the Django comments framework on my server. The site runs fine when run locally (using manage.py runserver) but when pushed live I'm getting the error:
ImproperlyConfigured at /
The COMMENTS_APP setting refers to a non-existing package.
My server is an apa... | [
"See if alternate WSGI script described at end of:\nhttp://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html\nmakes a difference. If it does, would be nice if can help us work out why. Still trying to get some confirmation on why so can work out if people using Django wrong, of whether Django WSGI ad... | [
0,
0
] | [] | [] | [
"apache",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0003575195_apache_django_mod_wsgi_python.txt |
Q:
How can I add some string to a list in order to make a count word? [Python]
I want to simply add some word to a list and then count how many words are in there...
And check if the word isn't in the list already.
How can I do it?
A:
A list can be used for this, but if speed is important and order doesn't matter t... | How can I add some string to a list in order to make a count word? [Python] | I want to simply add some word to a list and then count how many words are in there...
And check if the word isn't in the list already.
How can I do it?
| [
"A list can be used for this, but if speed is important and order doesn't matter then a set will be faster.\n>>> S = set(['a', 'b', 'c'])\n>>> S\nset(['a', 'c', 'b'])\n>>> 'b' in S\nTrue\n>>> S.add('d')\n>>> S\nset(['a', 'c', 'b', 'd'])\n>>> S.add('b')\n>>> S\nset(['a', 'c', 'b', 'd'])\n\n",
"You can add a word t... | [
4,
2
] | [] | [] | [
"list",
"python",
"windows"
] | stackoverflow_0003589667_list_python_windows.txt |
Q:
Facebook connect with django/python
I've been stuck on this for a while. I can't seem to get facebook login to pop up when following the google tutorial:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/al... | Facebook connect with django/python | I've been stuck on this for a while. I can't seem to get facebook login to pop up when following the google tutorial:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({app... | [
"New Facebook API requires asynchronous load:\n<div id=\"fb-root\"></div>\n<script>\n window.fbAsyncInit = function() {\n //[here goes your code:]\n FB.init({appId:'137101656332358', status: true, cookie: true, xfbml: true});\n FB.Event.subscribe('auth.sessionChange', function(response) {\n if (res... | [
1
] | [] | [] | [
"django",
"facebook",
"python"
] | stackoverflow_0003588785_django_facebook_python.txt |
Q:
Creating a gui around a python script using Tkinter
I have an existing python script and I want to wrap it in a GUI. Since I already have tkinter installed I would like to use it if possible. At the moment my script has many places where it asks for user input using raw_input(). I would like to replace these wi... | Creating a gui around a python script using Tkinter | I have an existing python script and I want to wrap it in a GUI. Since I already have tkinter installed I would like to use it if possible. At the moment my script has many places where it asks for user input using raw_input(). I would like to replace these with either a modal pop-up asking for user input or (prefer... | [
"UI toolkits usually have an event-driven model where the main loop is in the toolkit itself. This is probably different from your current synchronous, interactive model (where the program just pauses while waiting for input)\nThe best would be to try to refactor your program and factor-out the view part (look up t... | [
2
] | [] | [] | [
"python",
"tkinter",
"user_input"
] | stackoverflow_0003589817_python_tkinter_user_input.txt |
Q:
How do I store then retrieve Python-native data structures into and from a file?
I am reading an XML file and reorganizing the desired data into Python data structures (lists, tuples, etc.)
For example, one of my XML parser modules produces the following data:
# data_miner.py
animals = ['Chicken', 'Sheep', 'Cattle... | How do I store then retrieve Python-native data structures into and from a file? | I am reading an XML file and reorganizing the desired data into Python data structures (lists, tuples, etc.)
For example, one of my XML parser modules produces the following data:
# data_miner.py
animals = ['Chicken', 'Sheep', 'Cattle', 'Horse']
population = [150, 200, 50, 30]
Then I have a plotter module that roughly... | [
"The pickle module, or its faster equivalent cPickle, should serve your needs well.\nSpecifically:\n# data_miner.py\nimport pickle\n\nanimals = ['Chicken', 'Sheep', 'Cattle', 'Horse']\npopulation = [150, 200, 50, 30]\n\nwith open('data_miner.pik', 'wb') as f:\n pickle.dump([animals, population], f, -1)\n\nand\n# p... | [
6,
2,
1,
0
] | [] | [] | [
"file",
"pickle",
"python"
] | stackoverflow_0003589615_file_pickle_python.txt |
Q:
Display simple calendar on screen in python S60 (pyS60)
I am trying to develop a simple calendar based application using pyS60. I need to display a calendar as part of the form. I have searched but I couldn't find anything useful in the e32calendar documentation. I can get a calendar on the canvas but its not inte... | Display simple calendar on screen in python S60 (pyS60) | I am trying to develop a simple calendar based application using pyS60. I need to display a calendar as part of the form. I have searched but I couldn't find anything useful in the e32calendar documentation. I can get a calendar on the canvas but its not interactive. But i want one which is interactive ( just like inbu... | [
"Python module for py60 has a calendar module, which provides calendar services like reading, creating entries, setting alarms.\nPlease look into the documentation at http://wiki.opensource.nokia.com/projects/PyS60\nIn Doc, Section 7.2.2 provides a way to do that : \nCalendarDb objects represent a live view into th... | [
0
] | [] | [] | [
"calendar",
"pys60",
"python",
"s60"
] | stackoverflow_0003589824_calendar_pys60_python_s60.txt |
Q:
Cannot change content of list within list. Can anybody explain why?
I have a month variable which is a list of lists of tuples. Each list represents a week and each day is a tuple of the day of the month and the week day. I wish to make my month a list of lists of month days. I tried to do it like this:
for week i... | Cannot change content of list within list. Can anybody explain why? | I have a month variable which is a list of lists of tuples. Each list represents a week and each day is a tuple of the day of the month and the week day. I wish to make my month a list of lists of month days. I tried to do it like this:
for week in month:
week = [day[0] for day in week]
for [[(1, 1), (2, 2)], [(3,... | [
"No, the variable you are iterating on is never a \"reference\" (as in C++'s reference).\nYou should understand the for loop as\nmonth_iter = iter(month)\ntry:\n while True:\n week = next(month_iter)\n # here begins your code\n week = [day[0] for day in week]\n # here ends your code\nexcept StopIterati... | [
2,
2,
1,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0003590222_list_python.txt |
Q:
django annotation and filtering
Hopefully this result set is explanatory enough:
title text total_score already_voted
------------- ------------ ----------- -------------
BP Oil spi... Recently i... 5 0
J-Lo back ... Celebrity ... 7 1
Don't ... | django annotation and filtering | Hopefully this result set is explanatory enough:
title text total_score already_voted
------------- ------------ ----------- -------------
BP Oil spi... Recently i... 5 0
J-Lo back ... Celebrity ... 7 1
Don't Stop... If there w... 9 ... | [
"I cannot think of a way to include the boolean condition. Perhaps others can answer that better.\nHow about thinking a bit differently? If you don't mind executing two queries you can filter your articles based on whether the currently logged in user has voted on them or not. Something like this:\nall_articles = ... | [
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003590416_django_django_models_python.txt |
Q:
Need Help Creating GAE Datastore Loader Class?
Need Help Creating GAE Datastore Loader Class for uploading data using appcfg.py?
Any other way to simplified this process?
is there any detailed example better than here
When try using bulkloader.yaml:
Uploading data records.
[INFO ] Logging to bulkloader-log-2010... | Need Help Creating GAE Datastore Loader Class? | Need Help Creating GAE Datastore Loader Class for uploading data using appcfg.py?
Any other way to simplified this process?
is there any detailed example better than here
When try using bulkloader.yaml:
Uploading data records.
[INFO ] Logging to bulkloader-log-20100701.041515
[INFO ] Throttling transfers:
[INFO ... | [
"I've created config.yaml with bulkloader config, and also written simple helper function to process None-references. I don't know why it's not done in original helper.\nThe helper (file helpers.py is very simple, just place it to the same directory where you placed config.yaml):\nfrom google.appengine.api import d... | [
3,
0
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0003148352_google_app_engine_google_cloud_datastore_python.txt |
Q:
Django Model design
I needed some help in model design. I wanted a model where a user can associate himself with numerous emails by submitting them from a form. And when the user wants to use the websites contact form, he can choose the email he wants a reply on. Will it be something like this :
class Email(model... | Django Model design | I needed some help in model design. I wanted a model where a user can associate himself with numerous emails by submitting them from a form. And when the user wants to use the websites contact form, he can choose the email he wants a reply on. Will it be something like this :
class Email(models.Model):
author = mo... | [
"Your example means each Contact can have a single email address, and each email address can belong to multiple contacts. This is the wrong way round, i.e. you should put the ForeignKey on the Email model.\nThis should let you store multiple email addresses for each user.\nclass Email(models.Model):\n email = mo... | [
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0003550086_django_django_models_python.txt |
Q:
How can I make a while True break if certain key is pressed? [Python]
My script make a while True: begin with the F4 pressed, but I want it to stop when the F2 is pressed, how can I do it?
I'm trying this (using pyhook) but doesn't work...
def onKeyboardEvent(event):
if event.KeyID == 115: #F4
whi... | How can I make a while True break if certain key is pressed? [Python] | My script make a while True: begin with the F4 pressed, but I want it to stop when the F2 is pressed, how can I do it?
I'm trying this (using pyhook) but doesn't work...
def onKeyboardEvent(event):
if event.KeyID == 115: #F4
while True:
selectAndCopy(468,722)
getClipboard()
... | [
"You're not changing event within your loop, so you wouldn't expect event.KeyID to suddenly become 113 when it was 115 previously.\nWhat you might do is, on handling an F4 keypress, start a timer that does the selectAndCopy every two seconds. When you get another event with an F2 keystroke, kill the timer.\nIt coul... | [
1,
0
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0003589172_python_windows.txt |
Q:
instantiate python class from class available as string , only in memory!
I'm using Reportlab to create PDFs. I'm creating two PDFs which I want to merge after I created them. Reportlab provides a way to save a pycanvas (source) (which is basically my pdf file in memory) as a python file, and calling the method do... | instantiate python class from class available as string , only in memory! | I'm using Reportlab to create PDFs. I'm creating two PDFs which I want to merge after I created them. Reportlab provides a way to save a pycanvas (source) (which is basically my pdf file in memory) as a python file, and calling the method doIt(filename) on that python file, will recreate the pdf file. This is great, si... | [
"This seems like a really long way around to what you want. Doesn't Reportlab have a Canvas class from which you can pull the PDF document? I don't see why generated Python source code should be involved here.\nBut if for some reason it is necessary, then you can use StringIO to \"write\" the source to a string, ... | [
1,
0
] | [] | [] | [
"python",
"reportlab"
] | stackoverflow_0003590166_python_reportlab.txt |
Q:
Parsing JavaScript argument values in python
Is there a way to parse the argument values passed to a JavaScript function in python?
I want to be able to automatically document JavaScript function calls in order to make sure they have the right arguments passed to them.
For example, in:
function mymethod(fruit, v... | Parsing JavaScript argument values in python | Is there a way to parse the argument values passed to a JavaScript function in python?
I want to be able to automatically document JavaScript function calls in order to make sure they have the right arguments passed to them.
For example, in:
function mymethod(fruit, vegetable, drink) {
// dummy function
}
functi... | [
"You'll need a full JavaScript parser unless you know in advance that your JavaScript code follows some conventions you know in advance. Regular expressions are not up to the task, because they are not good for matching nested structures like parentheses.\nPython has many parser generator tools: Python parsing too... | [
1
] | [] | [] | [
"arguments",
"javascript",
"parsing",
"python",
"regex"
] | stackoverflow_0003590629_arguments_javascript_parsing_python_regex.txt |
Q:
PyGTK: adding text over widgets
I'm developing a GTK app, and would like to print some messages over existing widgets rather than displaying them in the status bar, kind of like the way Mendeley does it when no document is selected:
(as opposed to what is displayed in the right pane when you select a document:)
... | PyGTK: adding text over widgets | I'm developing a GTK app, and would like to print some messages over existing widgets rather than displaying them in the status bar, kind of like the way Mendeley does it when no document is selected:
(as opposed to what is displayed in the right pane when you select a document:)
Should I dynamically create a panel, ... | [
"You don't need to destroy the label, even nothing forces you to do so, neither create it dynamically. You could create it when you need it or glade could do it for you. This is a minimal example but, as you notice, both labels are created only once.\nimport gtk\n\nlabels = []\n\ndef changeLabel(widget):\n l = p... | [
2
] | [] | [] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0003590690_gtk_pygtk_python.txt |
Q:
py2exe: Reduce size of the library archive
I just created my first py2exe executable and noticed that with the EXE, there is a ZIP file created with the size of around 1.4 MB.
My question is, can I reduce the size of this or is it expected that the typical size of an EXE generated with py2exe will be ~ 4 MB (that... | py2exe: Reduce size of the library archive | I just created my first py2exe executable and noticed that with the EXE, there is a ZIP file created with the size of around 1.4 MB.
My question is, can I reduce the size of this or is it expected that the typical size of an EXE generated with py2exe will be ~ 4 MB (that means with all the files: python2.6dll, library... | [
"Short answer to your size reduction question is yes. Long answer I am not going to provide here, but instead direct you to py2exe's OptimizingSize wiki page.\nI hope this helps ;)\n",
"After changing those setup.py parameters i also run UPX on DLLs and executables and repack library.zip with 7-zip, works well.\... | [
7,
3
] | [] | [] | [
"py2exe",
"python"
] | stackoverflow_0003528763_py2exe_python.txt |
Q:
Bind arbitrary Python objects to CherryPy sessions
I'm using CherryPy to make a web-based frontend for SymPy that uses an asynchronous process library on the server side to allow for processing multiple requests at once without waiting for each one to complete. So as to allow for the frontend to function as expec... | Bind arbitrary Python objects to CherryPy sessions | I'm using CherryPy to make a web-based frontend for SymPy that uses an asynchronous process library on the server side to allow for processing multiple requests at once without waiting for each one to complete. So as to allow for the frontend to function as expected, I am using one process for the entirety of each ses... | [
"You can create your own session type, derived from CherryPy's base session. Use its clean_up method to do your cleanup.\nLook at cherrypy/lib/sessions.py for details and sample session implementations.\n"
] | [
1
] | [] | [] | [
"asynchronous",
"cherrypy",
"multithreading",
"python",
"session"
] | stackoverflow_0003591020_asynchronous_cherrypy_multithreading_python_session.txt |
Q:
Image bit manipulation in Python
I have an application that receives a pointer to JPEG data from a camera API wrapped with ctypes, converts it to a wx.Image, and displays the images as a movie.
One of required features is to set two of the components of a pixel equal to the third. E.g, my pixel in RGB format is (1... | Image bit manipulation in Python | I have an application that receives a pointer to JPEG data from a camera API wrapped with ctypes, converts it to a wx.Image, and displays the images as a movie.
One of required features is to set two of the components of a pixel equal to the third. E.g, my pixel in RGB format is (100,200,255), I want to set the the R a... | [
"You could try using the Python Imaging Library (PIL) - this is a library for manipulating images.\nYou can find information about converting between a wxPython image and a PIL image here, or you can load the jpeg directly into a PIL image.\nOnce you have converted your wx image into a PIL image I think this will d... | [
1,
1
] | [] | [] | [
"bitmap",
"ctypes",
"image_processing",
"python",
"wxwidgets"
] | stackoverflow_0003578373_bitmap_ctypes_image_processing_python_wxwidgets.txt |
Q:
developing a scalabe chat system
I am a java developer and am pretty comfortable with develeoping webapps in java/jsp/servlets.
I want to develop a video web based chat website.people should be able to chat with each other using my website.People dont need to use any client app installed on their pc in order to ch... | developing a scalabe chat system | I am a java developer and am pretty comfortable with develeoping webapps in java/jsp/servlets.
I want to develop a video web based chat website.people should be able to chat with each other using my website.People dont need to use any client app installed on their pc in order to chat with others.
My website should be s... | [
"I'm a little confused: the requirement is that users don't need any software installed on their PC? How can that be? You need something.\nGiven two months, I think you only have two options:\n\nFlash\nSkype\n\nLike you said, because you have two months to get it up and running, you're best off not learning a new... | [
1,
1
] | [] | [] | [
"chat",
"java",
"python",
"twisted",
"video_streaming"
] | stackoverflow_0003589780_chat_java_python_twisted_video_streaming.txt |
Q:
Uses of Jython while programming
I recently started learning Python and came accross the term Jython.
From the Google search results, I thereby concluded that it is indeed a very important term.
What is the experience programming/coding using Jython?
A:
Jython is just an implementation of the Python interpreter ... | Uses of Jython while programming | I recently started learning Python and came accross the term Jython.
From the Google search results, I thereby concluded that it is indeed a very important term.
What is the experience programming/coding using Jython?
| [
"Jython is just an implementation of the Python interpreter that runs on the JVM (Java Virtual Machine).\n\nWhat is JPython?\nJPython is an implementation of the\nPython programming language which is\ndesigned to run on the Java(tm)\nPlatform. It consists of a compiler to\ncompile Python source code down to\nJava b... | [
14,
4
] | [
"My recommendation to you: Forget about Jython and IronPython. Nobody uses them except the beginners and their developers. As for Jython, it's much slower, less robust, and less reliable than Python (aka CPython). It doesn't have the significant number of \"batteries\" that come Python; moreover, threading, process... | [
-8
] | [
"jython",
"python"
] | stackoverflow_0003591171_jython_python.txt |
Q:
Transaction on GAE entity property
I am trying to create a vote function that increases the class URL.votes +1 when clicked. This is a two part question:
How do you pull the entity key? (I think you need the key to distinguish which vote property is being modified?)
How do you then write the 'a href' for the link... | Transaction on GAE entity property | I am trying to create a vote function that increases the class URL.votes +1 when clicked. This is a two part question:
How do you pull the entity key? (I think you need the key to distinguish which vote property is being modified?)
How do you then write the 'a href' for the link to perform the vote?
Thanks!
Models:
... | [
"The answer includes a few things:\n\nYou need to use a Query string to pass the data on for the VoteHandler \n\na href=\"/vote?url_id={{url.key.id}}\">{{ url.votes }} votes - {{ url.website }} - {{ url.user.account }} - {{ url.created|date:\"M d, Y\" }}\n\nClicking a vote link, is a get() not a post(). Then you us... | [
1,
0
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0003585943_google_app_engine_google_cloud_datastore_python.txt |
Q:
Django - make file I/O thread safe
I want to read and write python-source-files from the file system in a thread-safe way.
open("n2.py","w").write(my_new_py_class)
from myproject import n2
#do something with n2
I assume that this is not thread-safe, since a request2 could modify the file before request1 is loadin... | Django - make file I/O thread safe | I want to read and write python-source-files from the file system in a thread-safe way.
open("n2.py","w").write(my_new_py_class)
from myproject import n2
#do something with n2
I assume that this is not thread-safe, since a request2 could modify the file before request1 is loading and executing it. I would like to achi... | [
"Why are you making your application modify its own files? This is not only incredibly evil, metaprogramming is orders of magnitude harder to understand debug. Plus, python caches modules it imports, so it's not really easy to reload that. And, last but not least, you don't have to writ the code to a file to execut... | [
4,
0
] | [] | [] | [
"django",
"python",
"thread_safety"
] | stackoverflow_0003590510_django_python_thread_safety.txt |
Q:
How can I organise program, which should have non-blocking connection on Python?
My question is next:
I want to write a program which should connect to the same program on the other machine, and both this program should exchange some information. I can't set up non-blocking connection. How can it be?
A:
Take a l... | How can I organise program, which should have non-blocking connection on Python? | My question is next:
I want to write a program which should connect to the same program on the other machine, and both this program should exchange some information. I can't set up non-blocking connection. How can it be?
| [
"Take a look at the asyncore library: http://docs.python.org/library/asyncore.html\nAnd specifically, the asynchat examples: http://docs.python.org/library/asynchat.html#asynchat.async_chat\nIt should do exactly what you need here.\n",
"The most simple solution to have a non-blocking socket in Python is just to u... | [
1,
0,
0
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0003591505_python_sockets.txt |
Q:
Transforming early modern English into 20th century spelling using the NLTK
I have a list of strings that are all early modern English words ending with 'th.' These include hath, appointeth, demandeth, etc. -- they are all conjugated for the third person singular.
As part of a much larger project (using my compute... | Transforming early modern English into 20th century spelling using the NLTK | I have a list of strings that are all early modern English words ending with 'th.' These include hath, appointeth, demandeth, etc. -- they are all conjugated for the third person singular.
As part of a much larger project (using my computer to convert the Gutenberg etext of Gargantua and Pantagruel into something more ... | [
"ethrema() is not a method of the type str, you have to use the following :\neth1 = [ethrema(w) for w in text]\n#AND\neth2 = [ethremb(w) for w in text]\n\nEDIT (to answer comment) : \nethremb(ethrema(word)) wouldn't work until you made some little changes to your functions : \ndef ethrema(word):\n if word.endswi... | [
6
] | [] | [] | [
"nlp",
"nltk",
"python",
"text"
] | stackoverflow_0003591673_nlp_nltk_python_text.txt |
Q:
Why are sets bigger than lists in python?
Why is the size of sets in Python noticeably larger than that of lists with same elements?
a = set(range(10000))
b = list(range(10000))
print('set size = ', a.__sizeof__())
print('list size = ', b.__sizeof__())
output:
set size = 524488
list size = 90088
A:
The set uses... | Why are sets bigger than lists in python? | Why is the size of sets in Python noticeably larger than that of lists with same elements?
a = set(range(10000))
b = list(range(10000))
print('set size = ', a.__sizeof__())
print('list size = ', b.__sizeof__())
output:
set size = 524488
list size = 90088
| [
"The set uses more memory than the list as it stores a table of hashes of all the elements so it can quickly detect duplicate entries and so on. This is why every set member must be hashable.\n"
] | [
19
] | [] | [] | [
"list",
"python",
"set"
] | stackoverflow_0003591727_list_python_set.txt |
Q:
Paraview and Python on Mac OSX
I've installed the binary distribution of paraview on OSX. When running this I can access the python interpreter from the Tools -> Python Shell. However I cannot figure out which libraries I need to add to PYTHONPATH in order to access VTK and Paraview functionality directly from Pyt... | Paraview and Python on Mac OSX | I've installed the binary distribution of paraview on OSX. When running this I can access the python interpreter from the Tools -> Python Shell. However I cannot figure out which libraries I need to add to PYTHONPATH in order to access VTK and Paraview functionality directly from Python.
Of course I could just compile ... | [
"I am basing my answer on recently built Paraview 3.9.0 from the CVS. But you should be able to access ParaView directly from your regular Python if you add:\n<Paraview-Bld-Directory>/Utilities/VTKPythonWrapping/site-packages\n<Paraview-Bld-Directory>/bin\n\nto your PYTHONPATH variable.\nDid this same approach fa... | [
2
] | [] | [] | [
"macos",
"paraview",
"python",
"vtk"
] | stackoverflow_0003317993_macos_paraview_python_vtk.txt |
Q:
Export mail from Gmail
At one point it was possible to use scripts like libgmail and gmail.py (can't post more than one hyperlink) to export mail from Gmail accounts. Both of those seem to not work anymore — I can't even log in with them. I assume it's because there's been some changes in Gmail. Is there still ... | Export mail from Gmail | At one point it was possible to use scripts like libgmail and gmail.py (can't post more than one hyperlink) to export mail from Gmail accounts. Both of those seem to not work anymore — I can't even log in with them. I assume it's because there's been some changes in Gmail. Is there still any way to do this?
| [
"Gmail supports IMAP and POP, which are common protocols for accessing email. You should be able to use use any working IMAP or POP library for Python to download your email. If you want tag/folder information, you'll need to stick to IMAP.\n",
"As far as I know neither libgmail nor gmail.py are compatible with t... | [
7,
1
] | [] | [] | [
"gmail",
"python"
] | stackoverflow_0003592015_gmail_python.txt |
Q:
Cannot select item from QListView with custom QStyledItemDelegate
I want to render each row with HTML code. The rendering works but -at least for me- items cannot be selected individually.
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
###########################################################... | Cannot select item from QListView with custom QStyledItemDelegate | I want to render each row with HTML code. The rendering works but -at least for me- items cannot be selected individually.
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
####################################################################
def main():
app = QApplication(sys.argv)
w = MyWin... | [
"I believe what you should do is detect selected items in your HTMLDelegate.paint method and fill the background with \"highlight\" color if such items detected. I've slightly changed your paint method, pls, check if it works for you\ndef paint(self, painter, option, index):\n painter.save()\n\n # highlight s... | [
5
] | [] | [] | [
"pyqt",
"pyqt4",
"python"
] | stackoverflow_0003472651_pyqt_pyqt4_python.txt |
Q:
Output of proc.communicate() does not format newlines in django python
I have a subprocess using communicate to get the output ans saving it to my database:
p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE)
syncoutput = p.communicate()
check.log = syncoutput
It all works fine, but the out... | Output of proc.communicate() does not format newlines in django python | I have a subprocess using communicate to get the output ans saving it to my database:
p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE)
syncoutput = p.communicate()
check.log = syncoutput
It all works fine, but the output from communicate looks like this:
('sending incremental file list\n\nsen... | [
"syncoutput,sync_error = p.communicate()\nprint(syncoutput)\n\np.communicate() returns a 2-tuple, composed of the output from stdout and stderr. When you print the 2-tuple, you see the \\n characters. When you print the string (of the new syncoutput), you will get formatted text.\n"
] | [
4
] | [] | [] | [
"django",
"django_views",
"popen",
"python"
] | stackoverflow_0003592750_django_django_views_popen_python.txt |
Q:
Parsing HTML easily like PyQuery in Python 2.5
I am writing an app for GAE (Python 2.5) and I was wondering if there is any library like PyQuery (which runs on Python 2.6+).
All I have to do is to load an HTML file and get the content of a especific tag through its ID. In PyQuery, or even Python2.6's libraries lik... | Parsing HTML easily like PyQuery in Python 2.5 | I am writing an app for GAE (Python 2.5) and I was wondering if there is any library like PyQuery (which runs on Python 2.6+).
All I have to do is to load an HTML file and get the content of a especific tag through its ID. In PyQuery, or even Python2.6's libraries like lxml, it is very easy, but I don't know how to do ... | [
"BeautifulSoup should be what you are looking for.\n",
"BeautifulSoup is a common choice for HTML parsing, and is compatible with Python 2.5.\n"
] | [
4,
2
] | [] | [] | [
"google_app_engine",
"html",
"python"
] | stackoverflow_0003592872_google_app_engine_html_python.txt |
Q:
How to filter a numpy.ndarray by date?
I have a 2d numpy.array, where the first column contains datetime.datetime objects, and the second column integers:
A = array([[2002-03-14 19:57:38, 197],
[2002-03-17 16:31:33, 237],
[2002-03-17 16:47:18, 238],
[2002-03-17 18:29:31, 239],
[2002-03-... | How to filter a numpy.ndarray by date? | I have a 2d numpy.array, where the first column contains datetime.datetime objects, and the second column integers:
A = array([[2002-03-14 19:57:38, 197],
[2002-03-17 16:31:33, 237],
[2002-03-17 16:47:18, 238],
[2002-03-17 18:29:31, 239],
[2002-03-17 20:10:11, 240],
[2002-03-18 16:18:... | [
"You could do this:\nfrom_date=datetime.datetime(2002,3,17,0,0,0)\nto_date=from_date+datetime.timedelta(days=1)\nidx=(A[:,0]>from_date) & (A[:,0]<=to_date)\nprint(A[idx])\n# array([[2002-03-17 16:31:33, 237],\n# [2002-03-17 16:47:18, 238],\n# [2002-03-17 18:29:31, 239],\n# [2002-03-17 20:10:11,... | [
8,
2
] | [] | [] | [
"datetime",
"numpy",
"python",
"scipy"
] | stackoverflow_0003592593_datetime_numpy_python_scipy.txt |
Q:
Reading input from remote control device on macs
How could I read input from a remote control device on a mac (iMac, Mac Mini, etc.) and handle actions based on differently pressed buttons in python?
I would like to map the button-press events to my custom app instead of "Front Row". What actions should I take to ... | Reading input from remote control device on macs | How could I read input from a remote control device on a mac (iMac, Mac Mini, etc.) and handle actions based on differently pressed buttons in python?
I would like to map the button-press events to my custom app instead of "Front Row". What actions should I take to do that and what python libraries to use to handle the... | [
"The Remote Control Wrapper 2 library is an Objective C class to handle interaction with Apple Remote Control (and, I believe, also some other such \"remote-control-like\" devices). To use some Objective C code from Python, see pyobjc.\n"
] | [
3
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0003592867_macos_python.txt |
Q:
Porting a threaded C program to Python
As an exercise, I would like to port some of the functionality of a threaded C program (using pthreads) to Python.
The C program spawns a thread to (almost) constantly iterate through certain directories, filling a data structure with their contents; these directories change ... | Porting a threaded C program to Python | As an exercise, I would like to port some of the functionality of a threaded C program (using pthreads) to Python.
The C program spawns a thread to (almost) constantly iterate through certain directories, filling a data structure with their contents; these directories change crazy frequently (it's a mail queue).
The ... | [
"The \"problems with concurrency\" with CPython are basically only ones of not being able to use multiple cores from within the same process (you need multiple processes for that) -- apart from that, the threading abilities of Python aren't all that different from C's (though it's easier to port to/from Java's earl... | [
3,
2
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0003593006_multithreading_python.txt |
Q:
Iterative printing over parallel lists to print columns in Python
I have vsort and vsorta, both lists with equal numbers of items that should be right next to each other (about 250 elements per list). I want to print them as parallel columns, like so:
>>> for x,y in vsort,vsorta:
... print x, y
...
Traceback ... | Iterative printing over parallel lists to print columns in Python | I have vsort and vsorta, both lists with equal numbers of items that should be right next to each other (about 250 elements per list). I want to print them as parallel columns, like so:
>>> for x,y in vsort,vsorta:
... print x, y
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueErr... | [
"Try:\nfor x, y in zip(vsort, vsorta):\n print x, y\n\nzip takes some number of lists and makes them into one list of tuples.\n"
] | [
8
] | [] | [] | [
"collections",
"list",
"printing",
"python"
] | stackoverflow_0003593040_collections_list_printing_python.txt |
Q:
Python invalid syntax
lastPosition = GPS.getActualPosition()
I m trying to compile a code which is about sending sms through telit module.
above statement is giving an error. I couldn't understand, GPS library is in the place where it's supposed to be and I imported it.
import SER
import MOD
import MDM
import GPS... | Python invalid syntax | lastPosition = GPS.getActualPosition()
I m trying to compile a code which is about sending sms through telit module.
above statement is giving an error. I couldn't understand, GPS library is in the place where it's supposed to be and I imported it.
import SER
import MOD
import MDM
import GPS
syntaxError: invalid synt... | [
"The post the OP referred to (in a comment -- not a great idea, @gheddo! edit your Q instead!), here, has exactly this code (I'm copying and pasting only the two relevant lines):\ndef get_gps():\ngpspos = GPS.getActualPosition() #Read GPS position\n\nsee the problem? No indentation for the second line! Therefore,... | [
3,
0
] | [] | [] | [
"python",
"syntax_error"
] | stackoverflow_0003592693_python_syntax_error.txt |
Q:
How to make integration test for DB at google App. engine?
I'am wondering, how to write integration tests, that involves DB interaction, for Google app engine?
It's seems - no problem to run this test at Google, on "live" db, using GAEUnit SO Thread
But, this seems bad practice to me, because it's live environment... | How to make integration test for DB at google App. engine? | I'am wondering, how to write integration tests, that involves DB interaction, for Google app engine?
It's seems - no problem to run this test at Google, on "live" db, using GAEUnit SO Thread
But, this seems bad practice to me, because it's live environment.
Google has provided examples of such tests, for java, but not ... | [
"You might also want to take a look at Fixture. It lets you easily create datasets that are loaded in a datastore stub at the beginning of every test. This answer has a specific example.\n",
"Use NoseGAE. It sets up the development environment so you can test datastore and other APIs. Then, and this one is not re... | [
1,
0
] | [] | [] | [
"google_app_engine",
"python",
"unit_testing"
] | stackoverflow_0003592436_google_app_engine_python_unit_testing.txt |
Q:
Add page break to Reportlab Canvas object
I need to generate a 2 pages pdf report. Pages are completely independent. tried using:
mycanvas.drawString(x, y, "Printing on Page 1")
mycanvas._pageNumer = 2
mycanvas.drawString(x, y, "Printing on Page 2")
and:
mycanvas.drawString(x, y, "Printing on Page 1")
P = PageBre... | Add page break to Reportlab Canvas object | I need to generate a 2 pages pdf report. Pages are completely independent. tried using:
mycanvas.drawString(x, y, "Printing on Page 1")
mycanvas._pageNumer = 2
mycanvas.drawString(x, y, "Printing on Page 2")
and:
mycanvas.drawString(x, y, "Printing on Page 1")
P = PageBreak()
P.drawOn(mycanvas, 0, 1000)
mycanvas.drawS... | [
"Just call mycanvas.showPage() once page 1 is done -- this way, the rest of the output goes to page 2. See the docs.\n"
] | [
45
] | [] | [] | [
"python",
"reportlab"
] | stackoverflow_0003593193_python_reportlab.txt |
Q:
Removing Tags from HTML Parsed with BeautifulSoup
I'm new to python and I'm using BeautifulSoup to parse a website and then extract data. I have the following code:
for line in raw_data: #raw_data is the parsed html separated into smaller blocks
d = {}
d['name'] = line.find('div', {'class':'torrentname'}).... | Removing Tags from HTML Parsed with BeautifulSoup | I'm new to python and I'm using BeautifulSoup to parse a website and then extract data. I have the following code:
for line in raw_data: #raw_data is the parsed html separated into smaller blocks
d = {}
d['name'] = line.find('div', {'class':'torrentname'}).find('a')
print d['name']
<a href="/ubuntu-9-10-de... | [
"Use the \".text\" property:\nd['name'] = line.find('div', {'class':'torrentname'}).find('a').text\n\nOr do a join on findAll(text=True):\nanchor = line.find('div', {'class':'torrentname'}).find('a')\nd['name'] = ''.join(anchor.findAll(text=True))\n\n"
] | [
3
] | [] | [] | [
"beautifulsoup",
"html",
"parsing",
"python"
] | stackoverflow_0003585725_beautifulsoup_html_parsing_python.txt |
Q:
How do I yield a pre-unpacked list?
I have a list that is created within an itertools.groupby operation:
def yield_unpacked_list():
for key, grp in itertools.groupby(something_to_groupby, key=lambda x: x[0]):
subset_of_grp = list(item[2] for item in list(grp))
yield key, subset_of_grp
If, for ... | How do I yield a pre-unpacked list? | I have a list that is created within an itertools.groupby operation:
def yield_unpacked_list():
for key, grp in itertools.groupby(something_to_groupby, key=lambda x: x[0]):
subset_of_grp = list(item[2] for item in list(grp))
yield key, subset_of_grp
If, for example, subset_of_grp turns out to be [1... | [
"yield (key,) + tuple(subset_of_grp)\n",
"def yield_unpacked_list():\n for key, grp in itertools.groupby(something_to_groupby, key=lambda x: x[0]):\n yield (key,) + tuple(item[2] for item in grp)\n\nFrom the result you want for printing, it's clear that you want to yield a tuple -- no idea why you call ... | [
5,
2
] | [] | [] | [
"group_by",
"iterable_unpacking",
"python",
"python_itertools",
"yield"
] | stackoverflow_0003593475_group_by_iterable_unpacking_python_python_itertools_yield.txt |
Q:
Why doesn't sys.stdout.write('\b') backspace against newlines?
Compare:
for item in range(0, 5):
sys.stdout.write('c')
for item in range(0, 5):
sys.stdout.write('\b')
Works as you would imagine, but:
for item in range(0, 5):
sys.stdout.write('\n')
for item in range(0, 5):
sys.stdout.write('\b')
s... | Why doesn't sys.stdout.write('\b') backspace against newlines? | Compare:
for item in range(0, 5):
sys.stdout.write('c')
for item in range(0, 5):
sys.stdout.write('\b')
Works as you would imagine, but:
for item in range(0, 5):
sys.stdout.write('\n')
for item in range(0, 5):
sys.stdout.write('\b')
still leaves you with five newline characters. Any ideas?
| [
"It may seem reasonable today to expect backspace to be able to work over newline characters, on a console but that would not be backward compatible with teletypes as there is no reverse linefeed.\n",
"This is about the behavior of console windows: backspaces only work within a line, they won't backup over newlin... | [
17,
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0003593339_python.txt |
Q:
Associating properties to Class objects
I would like to define properties for classes, and be able to access them before I actually instantiate an object of that class.
I'll give some context. My application handles a library of components. Each component is mapped to a Python class. Now I want to know what config... | Associating properties to Class objects | I would like to define properties for classes, and be able to access them before I actually instantiate an object of that class.
I'll give some context. My application handles a library of components. Each component is mapped to a Python class. Now I want to know what configuration a component needs, before actually in... | [
"A class name is defined once the body is executed. This happens when the file containing the class is imported. This is not the same as creation of an instance of a class.\nclass A(object):\n \"\"\" doc \"\"\"\n config = []\n def __init__(def):\n pass\nA.config.append(('n', 'number of burz to insti... | [
1,
1,
1
] | [] | [] | [
"class",
"metaprogramming",
"python"
] | stackoverflow_0003593605_class_metaprogramming_python.txt |
Q:
How do you grab a value from the scope from a string
from module import * # adds 'BlahRenderer', 'FooRenderer', 'BarRenderer', etc.
class MyClass
def __init__(self, value)
renderer = "%sRenderer" % value
self.RendererClass = ????
I know this can be done by doing the import inside __init__ and ... | How do you grab a value from the scope from a string | from module import * # adds 'BlahRenderer', 'FooRenderer', 'BarRenderer', etc.
class MyClass
def __init__(self, value)
renderer = "%sRenderer" % value
self.RendererClass = ????
I know this can be done by doing the import inside __init__ and then doing locals()[renderer] but how do I do it if the im... | [
"Try globals() instead of locals().\nAlthough it may be better that your module defines a dictionary or Factory to map each value into a Renderer e.g.\nrenderers = {'Blah': BlahRenderer, 'Foo': FooRenderer, ...}\n\n"
] | [
3
] | [] | [] | [
"python"
] | stackoverflow_0003594267_python.txt |
Q:
Make a video using Python+GST from a set of `YYYY-MM-DD`-dated pictures
I have a directory with a set of YYYY-MM-DD-dated files in as so:
pictures/
2010-08-14.png
2010-08-17.png
2010-08-18.png
How can I use Python GStreamer to turn these files into a video? The filenames must remain the same.
I have a... | Make a video using Python+GST from a set of `YYYY-MM-DD`-dated pictures | I have a directory with a set of YYYY-MM-DD-dated files in as so:
pictures/
2010-08-14.png
2010-08-17.png
2010-08-18.png
How can I use Python GStreamer to turn these files into a video? The filenames must remain the same.
I have a program that can turn incrementally numbered PNGs into a video, I just need ... | [
"The easiest would be to create link/rename those file to a sequence number (that should be easily doable with a n=0 for f in $(ls * | sort); do ln -s $f $n && $n=$((n+1))\nThen you should be able to do:\ngst-launch multifilesrc location=%d ! pngdec ! theoraenc ! oggmux ! filesink location=movie.ogg\n\nIt would hav... | [
0,
0,
0
] | [] | [] | [
"gstreamer",
"python",
"rfc3339",
"video"
] | stackoverflow_0003520464_gstreamer_python_rfc3339_video.txt |
Q:
removing /n from list of words - python
I have a list as below
['Jellicle', 'Cats', 'are', 'black', 'and', 'white,\nJellicle', 'Cats', 'are', 'rather', 'small;\nJellicle', 'Cats', 'are', 'merry', 'and', 'bright,\nAnd', 'pleasant', 'to', 'hear', 'when', 'they', 'caterwaul.\nJellicle', 'Cats', 'have', 'cheerful', '... | removing /n from list of words - python | I have a list as below
['Jellicle', 'Cats', 'are', 'black', 'and', 'white,\nJellicle', 'Cats', 'are', 'rather', 'small;\nJellicle', 'Cats', 'are', 'merry', 'and', 'bright,\nAnd', 'pleasant', 'to', 'hear', 'when', 'they', 'caterwaul.\nJellicle', 'Cats', 'have', 'cheerful', 'faces,\nJellicle', 'Cats', 'have', 'bright', ... | [
"The simplest (although not the best performing) is probably to join then split:\nl = ('\\n'.join(l)).split('\\n')\n\nIn fact it looks like you created this list by splitting on space. If so, you might want to reconsider how to create this list in the first place to avoid this extra step. You can split directly to ... | [
2,
1,
0
] | [] | [] | [
"list",
"python",
"string"
] | stackoverflow_0003594448_list_python_string.txt |
Q:
Google App Engine w/ Django - InboundMailHandler appears to only work once
I'm writing an app for Google App Engine (with Python and Django) that needs to receive email and add some elements of the received email messages to a datastore. I am a very novice programmer.
The problem is that the script I specify to ha... | Google App Engine w/ Django - InboundMailHandler appears to only work once | I'm writing an app for Google App Engine (with Python and Django) that needs to receive email and add some elements of the received email messages to a datastore. I am a very novice programmer.
The problem is that the script I specify to handle incoming email appears to only run once (until the script is touched).
Send... | [
"Handlers are matched in order. .* matches any request, so the email handler will never match at all. Put .* last.\n"
] | [
5
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0003593902_django_google_app_engine_python.txt |
Q:
Keeping multiple clients showing up-to-date information in Python?
I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing ol... | Keeping multiple clients showing up-to-date information in Python? | I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the databa... | [
"You could use triggers. When an information is updated send a signal (is up to you choose how, maybe just an udp packet) to all blotters that will update their information consequentially. Postgresql could be scripted using python.\n",
"To receive messages (e.g. the UDP package suggested by the other poster or a... | [
0,
0
] | [] | [] | [
"network_programming",
"python"
] | stackoverflow_0003594631_network_programming_python.txt |
Q:
How to transform a key pressed into a different one in pygtk
I'm trying to make my pygtk application behave the way openoffice calc does, regarding the decimal point. This means that when receiving a KP_Decimal key (the dot in the keypad) I want my entries to show whatever the decimal point is in the current loca... | How to transform a key pressed into a different one in pygtk | I'm trying to make my pygtk application behave the way openoffice calc does, regarding the decimal point. This means that when receiving a KP_Decimal key (the dot in the keypad) I want my entries to show whatever the decimal point is in the current locale (dot or comma, appropriately).
I've searched for a long while n... | [
"One way you could do this is by subclassing gtk.Entry, like so:\nimport gtk\nimport locale\n\nclass NumericEntry(gtk.Entry):\n __gsignals__ = {\n 'key_press_event': 'override'\n }\n def do_key_press_event(self, event):\n if event.keyval == gtk.gdk.keyval_from_name('KP_Decimal'):\n ... | [
2
] | [] | [] | [
"gtk",
"localization",
"pygtk",
"python"
] | stackoverflow_0003161317_gtk_localization_pygtk_python.txt |
Q:
Python CSV DictReader/Writer issues
I'm trying to extract a bunch of lines from a CSV file and write them into another, but I'm having some problems.
import csv
f = open("my_csv_file.csv", "r")
r = csv.DictReader(f, delimiter=',')
fieldnames = r.fieldnames
target = open("united.csv", 'w')
w = csv.DictWriter(unit... | Python CSV DictReader/Writer issues | I'm trying to extract a bunch of lines from a CSV file and write them into another, but I'm having some problems.
import csv
f = open("my_csv_file.csv", "r")
r = csv.DictReader(f, delimiter=',')
fieldnames = r.fieldnames
target = open("united.csv", 'w')
w = csv.DictWriter(united, fieldnames=fieldnames)
while True:
t... | [
"I don't know either, but since all you're doing is copying lines from one file to another why are you bothering with the csv stuff at all? Why not something like:\nf = open(\"my_csv_file.csv\", \"r\")\ntarget = open(\"united.csv\", 'w')\n\nf.readline()\nf.readline()\nfor line in f:\n target.write(line)\n\n",
... | [
14,
13,
1,
1
] | [] | [] | [
"csv",
"python"
] | stackoverflow_0001202855_csv_python.txt |
Q:
Why does printer changes resolution? User, background, what?
I am runing a .bat file from a php using exec on a Windwos php server, where php is run using fast-cgi (and nginx). The command line to run this script is
pclose(popen("start / ". $cmd, "r"));
Where $cmd is somethign like "mybatfile.bat 45 1"
Whe... | Why does printer changes resolution? User, background, what? | I am runing a .bat file from a php using exec on a Windwos php server, where php is run using fast-cgi (and nginx). The command line to run this script is
pclose(popen("start / ". $cmd, "r"));
Where $cmd is somethign like "mybatfile.bat 45 1"
When I run the batch file manually it runs a python program to read a... | [
"Cracked it!\nThe user who is running the server has never logged in (naturally) so they have never changed their screen resolution from 90 dpi. \nI on the other hand, have changed by screen resolution because I use large fonts. \nSo when I ran the print it printed in 120 dpi. When the server ran it, it printed in ... | [
0
] | [] | [] | [
"php",
"printing",
"python",
"resolution",
"windows"
] | stackoverflow_0003592385_php_printing_python_resolution_windows.txt |
Q:
Python: What ways of making data available to plugins?
I'm implementing a simple plugin framework for a little Python program and wonder what the different existing practices are for passing data to plugins.
At this stage, I see two alternatives:
pass task-specific data to plugins, don't give plugins access to an... | Python: What ways of making data available to plugins? | I'm implementing a simple plugin framework for a little Python program and wonder what the different existing practices are for passing data to plugins.
At this stage, I see two alternatives:
pass task-specific data to plugins, don't give plugins access to any other data
pass all the data to which any plugin should ha... | [
"I like the way wxPython does events. Pass an event object to the plugin with what you think is the relevant data, but also provide an API for every plugin to access the full state of the application.\nFor example, in wxMouseEvent has x and y properties. But also (like every other event object) has get GetEventObje... | [
1
] | [] | [] | [
"plugins",
"python",
"variables"
] | stackoverflow_0003595000_plugins_python_variables.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.