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:
Can I store objects in Python class members?
I'm writing a game in Python with the Pygame2 multimedia library, but I'm more accustomed to developing games with ActionScript 3. In AS3, I don't think it was possible to store an object in a static variable, because static variables were initialized before objects cou... | Can I store objects in Python class members? | I'm writing a game in Python with the Pygame2 multimedia library, but I'm more accustomed to developing games with ActionScript 3. In AS3, I don't think it was possible to store an object in a static variable, because static variables were initialized before objects could be instantiated.
However, in Python, I'm not s... | [
"You can do this:\nclass Test:\n counter = 0\n def __init__(self):\n Test.counter += 1\n print Test.counter\n\nAnd it works as expected.\n",
"Yes.\nAs with most python try it and see.\nIt will be instantiated when a Test object is created. ie your assignment to test1\nThe counter object is created per cla... | [
3,
3
] | [] | [] | [
"actionscript_3",
"instantiation",
"pygame",
"python"
] | stackoverflow_0001290798_actionscript_3_instantiation_pygame_python.txt |
Q:
Django MVC pattern for non database driven models?
I'm just working my way through Django, and really liking it so far, but I have an issue and I'm not sure what the typical way to solve it.
Suppose I have a View which is supposed to be updated when some complex Python object is updated, but this object is not dri... | Django MVC pattern for non database driven models? | I'm just working my way through Django, and really liking it so far, but I have an issue and I'm not sure what the typical way to solve it.
Suppose I have a View which is supposed to be updated when some complex Python object is updated, but this object is not driven by the database, say it is driven by AJAX calls or d... | [
"Your models.py can be (and sometimes is) empty. You are not obligated to have a model which maps to a database. \nYou should still have a models.py file, to make Django's admin happy. The models.py file name is important, and it's easier to have an empty file than to try and change the file expected by various ... | [
38
] | [] | [] | [
"django",
"model_view_controller",
"models",
"python"
] | stackoverflow_0001290891_django_model_view_controller_models_python.txt |
Q:
Python capture output from wget?
Is it possible to capture output from wget and other command line programs that use curses?
Here is what I have right now:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=0)
for line in p.stdout:
print "a"
This works fine for programs that have simple output, but not... | Python capture output from wget? | Is it possible to capture output from wget and other command line programs that use curses?
Here is what I have right now:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=0)
for line in p.stdout:
print "a"
This works fine for programs that have simple output, but not for wget and other programs that use ... | [
"I don't believe that wget is using curses.\nNormally when I want to use wget in a script I'd use the -O - option to force its output to stdout. I suspect you're trying to capture the text that you normally see on your console when you're running it, which would be stderr.\nFrom the command line, outside of Python... | [
7
] | [] | [] | [
"python"
] | stackoverflow_0001290910_python.txt |
Q:
IsPointInsideSegment(pt, line) in Python
Is there a nice way to determine if a point lies within a 3D line segment?
I know there are algorithms that determine the distance between a point and line segment, but I'm wondering if there's something more compact or efficient.
A:
Given three points A, B, and C -- wher... | IsPointInsideSegment(pt, line) in Python | Is there a nice way to determine if a point lies within a 3D line segment?
I know there are algorithms that determine the distance between a point and line segment, but I'm wondering if there's something more compact or efficient.
| [
"Given three points A, B, and C -- where AB is your line and C is your other point, you can also restate your problem as two lines, AB and AC. If the angle between AB and AC is zero (i.e. if the area of the triangle ABC is zero) then your point C is on the line.\nIf you think about this in terms of angles, you can... | [
4,
1,
0
] | [] | [] | [
"geometry",
"python"
] | stackoverflow_0001290779_geometry_python.txt |
Q:
Checking for group membership (Many to Many in Django)
I have two models in Django: groups and entries. Groups has a many-to-many field that connects it to entries. I want to select all entries that have a group (as not all do!) and be able to access their group.title field.
I've tried something along the lines of... | Checking for group membership (Many to Many in Django) | I have two models in Django: groups and entries. Groups has a many-to-many field that connects it to entries. I want to select all entries that have a group (as not all do!) and be able to access their group.title field.
I've tried something along the lines of:
t = Entries.objects.select_related().exclude(group=None)
... | [
"You don't show the model code, so I can't be sure, but instead of t[0].groups, I think you want:\nfor g in t[0].groups.all():\n print g.title\n\n"
] | [
3
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001291167_django_python.txt |
Q:
Confused by Django's claim to MVC, what is it exactly?
So what exactly is Django implementing?
Seems like there are
Models
Views
Templates
Models = Database mappings
Views = Grab relevant data from the
models and formats it via templates
Templates = Display HTML depending on data given by Views
EDIT: S. Lott c... | Confused by Django's claim to MVC, what is it exactly? | So what exactly is Django implementing?
Seems like there are
Models
Views
Templates
Models = Database mappings
Views = Grab relevant data from the
models and formats it via templates
Templates = Display HTML depending on data given by Views
EDIT: S. Lott cleared a lot up with this in an edit to a previous post, bu... | [
"Django's developers have a slightly non-traditional view on the MVC paradigm. They actually address this question in their FAQs, which you can read here. In their own words:\n\nIn our interpretation of MVC, the “view” describes the data that gets presented to the user. It’s not necessarily how the data looks, but ... | [
23
] | [] | [] | [
"design_patterns",
"django",
"model_view_controller",
"python"
] | stackoverflow_0001291213_design_patterns_django_model_view_controller_python.txt |
Q:
python regex help: unknown information to skip
I'm having trouble with the needed regular expression... I'm sure I need to probably be using some combination of 'lookaround' or conditional expressions, but I'm at a loss.
I have a data string like:
pattern1 pattern2 pattern3 unwanted-groups pattern4 random number o... | python regex help: unknown information to skip | I'm having trouble with the needed regular expression... I'm sure I need to probably be using some combination of 'lookaround' or conditional expressions, but I'm at a loss.
I have a data string like:
pattern1 pattern2 pattern3 unwanted-groups pattern4 random number of tokens pattern5 optional1 optional2 more unknown u... | [
"If all the data is in that format I'd go with split instead. I think it will be faster.\n\nstr = \"regex1 regex2 regex3 unwanted-regex regex4 random number of tokens regex5 optregex1 optregex2 more unknown unwanted junk separated with white spaces optregex3 optregex4 etc\"\nparts = str.split() # now you have each ... | [
4,
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0001290205_python_regex.txt |
Q:
Abstraction and client/server architecture questions for Python game program
Here is where I am at presently. I am designing a card game with the aim of utilizing major components for future work. The part that is hanging me up is creating a layer of abstraction between the server and the client(s). A server is st... | Abstraction and client/server architecture questions for Python game program | Here is where I am at presently. I am designing a card game with the aim of utilizing major components for future work. The part that is hanging me up is creating a layer of abstraction between the server and the client(s). A server is started, and then one or more clients can connect (locally or remotely). I am design... | [
"Read up on RESTful architectures.\nYour fat client can use REST. It will use urllib2 to make RESTful requests of a server. It can exchange data in JSON notation.\nA web client can use REST. It can make simple browser HTTP requests or a Javascript component can make more sophisticated REST requests using JSON.\n... | [
2,
2,
2
] | [] | [] | [
"abstraction",
"client_server",
"python"
] | stackoverflow_0001291179_abstraction_client_server_python.txt |
Q:
When I catch an exception, how do I get the type, file, and line number of the previous frame?
From this question, I'm now doing error handling one level down. That is, I call a function which calls another larger function, and I want where it failed in that larger function, not in the smaller function. Specific e... | When I catch an exception, how do I get the type, file, and line number of the previous frame? | From this question, I'm now doing error handling one level down. That is, I call a function which calls another larger function, and I want where it failed in that larger function, not in the smaller function. Specific example. Code is:
import sys, os
def workerFunc():
return 4/0
def runTest():
try:
p... | [
"Add a line:\n tb = tb.tb_next\n\njust after your call to sys.exc_info.\nSee the docs here under \"Traceback objects\".\n",
"tb.tb_next is your friend:\nimport sys, os\n\ndef workerFunc():\n return 4/0\n\ndef runTest():\n try:\n print workerFunc()\n except:\n ty,val,tb = sys.exc_info()\n... | [
4,
3,
2
] | [] | [] | [
"error_handling",
"exception",
"exception_handling",
"python"
] | stackoverflow_0001291438_error_handling_exception_exception_handling_python.txt |
Q:
scrollbar for statictext in wxpython?
is possible to add a scrollbar to a statictext in wxpython?
the thing is that i'm creating this statictext:
self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,label=u'some text here',name='staticText1', parent=self.panel1, pos=wx.Point(16, 96),
... | scrollbar for statictext in wxpython? | is possible to add a scrollbar to a statictext in wxpython?
the thing is that i'm creating this statictext:
self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,label=u'some text here',name='staticText1', parent=self.panel1, pos=wx.Point(16, 96),
size=wx.Size(408, 216),style=wx.ST_... | [
"wx.StaticText is designed to never respond to mouse events and never take user focus. Given that this is its role in life, it seems that a scrollbar would be inconsistent with its purpose.\nThere are two ways to get what you want: 1) You could use a regular TextCtrl with the style TE_READONLY (see here); or 2) y... | [
4
] | [] | [] | [
"python",
"scrollbar",
"wxpython"
] | stackoverflow_0001290736_python_scrollbar_wxpython.txt |
Q:
Django : get entries of today and SplitDateTime Widget?
I used : SplitDateTimeWidget to split DateTime field ,
appointment = forms.DateTimeField(widget=forms.SplitDateTimeWidget)
In the template side i manage to use datePicker and TimePicker for each field , using jQuery .
When i try to filter the entries regard... | Django : get entries of today and SplitDateTime Widget? | I used : SplitDateTimeWidget to split DateTime field ,
appointment = forms.DateTimeField(widget=forms.SplitDateTimeWidget)
In the template side i manage to use datePicker and TimePicker for each field , using jQuery .
When i try to filter the entries regarding to today date as in this code :
d = datetime.date.today()... | [
"Fix your timezone settings, in settings.py TIME_ZONE\nDefault: 'America/Chicago'\nSome excerpts of useful info from the docs:\n\nA string representing the time zone\n for this installation. See available\n choices. \n(...)\nNote that this is the time zone to which Django will convert all\n dates/times -- not ne... | [
2
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0001291537_django_django_forms_python.txt |
Q:
google python data example: pizza party
hey i started learning python and am quite confused as how the google data library works.
google has a pizza party example over at this link
can anyone here please take the time to explain how it is being done. i would be so grateful.
WHAT I UNDERSTAND:
<entry xmlns='http://... | google python data example: pizza party | hey i started learning python and am quite confused as how the google data library works.
google has a pizza party example over at this link
can anyone here please take the time to explain how it is being done. i would be so grateful.
WHAT I UNDERSTAND:
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:p='http://example... | [
"%s is a string placeholder, and % is the string interpolation operator. See the Python docs on string formatting for more information.\natom.core is a Python module to work with Atom feeds.\n",
"Given that this question is about Python and involves a pizza party, I'd say you were biting off more than you can che... | [
2,
0
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0001292095_python_xml.txt |
Q:
How to open a file and find the longest length of a line and then print it out
Here's is what I have done so far but the length function isn't working.
import string
def main():
print " This program reads from a file and then prints out the"
print " line with the longest length the line ,or with the highe... | How to open a file and find the longest length of a line and then print it out | Here's is what I have done so far but the length function isn't working.
import string
def main():
print " This program reads from a file and then prints out the"
print " line with the longest length the line ,or with the highest sum"
print " of ASCII values , or the line with the greatest number of words"... | [
"For Python 2.5 to 2.7.12\nprint max(open(your_filename, 'r'), key=len)\n\nFor Python 3 and up\nprint(max(open(your_filename, 'r'), key=len))\n\n",
"large_line = ''\nlarge_line_len = 0\nfilename = r\"C:\\tmp\\TestFile.txt\"\n\nwith open(filename, 'r') as f:\n for line in f:\n if len(line) > large_line_l... | [
32,
6,
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0001292630_python.txt |
Q:
Which development environment should I use for developing Google App Engine with Python?
I would like to ask which IDE should I use for developing applications for Google App Engine with Python language?
Is Eclipse suitable or is there any other development environment better?
Please give me some advices!
Thank yo... | Which development environment should I use for developing Google App Engine with Python? | I would like to ask which IDE should I use for developing applications for Google App Engine with Python language?
Is Eclipse suitable or is there any other development environment better?
Please give me some advices!
Thank you!
| [
"Eclipse with the PyDev plugin is very nice. Recent versions even go out of their way to support App Engine, with builtin support for uploading your project, etc without having to use the command line scripts. \nSee the Pydev blog for more documentation on the App Engine integration.\n",
"I think the answers you ... | [
4,
3,
2,
0,
0
] | [] | [] | [
"google_app_engine",
"ide",
"python"
] | stackoverflow_0001287606_google_app_engine_ide_python.txt |
Q:
Storing dynamically generated code as string or as code object?
I'm hacking a little template engine. I've a class (pompously named the template compiler) that produce a string of dynamically generated code.
for instance :
def dynamic_function(arg):
#statement
return rendered_template
At rendering time, I cal... | Storing dynamically generated code as string or as code object? | I'm hacking a little template engine. I've a class (pompously named the template compiler) that produce a string of dynamically generated code.
for instance :
def dynamic_function(arg):
#statement
return rendered_template
At rendering time, I call the built-in function exec against this code, with a custom globals... | [
"You don't mention where you are going to store these templates, but if you are persisting them \"permanently\", keep in mind that Python doesn't guarantee byte-code compatibility across major versions. So either choose a method that does guarantee compatibility (like storing the source code), or also store enough... | [
2,
1,
0
] | [] | [] | [
"exec",
"python"
] | stackoverflow_0001292994_exec_python.txt |
Q:
bulk insert in db table
I'm having an array I want to insert in a single query in a table. Any idea?
A:
If you are using dbapi to access the database, then the connection.executemany() method works.
con.executemany("INSERT INTO some_table (field) VALUES (?)", [(v,) for v in your_array])
The format of the bindpa... | bulk insert in db table | I'm having an array I want to insert in a single query in a table. Any idea?
| [
"If you are using dbapi to access the database, then the connection.executemany() method works.\ncon.executemany(\"INSERT INTO some_table (field) VALUES (?)\", [(v,) for v in your_array])\n\nThe format of the bindparameter depends on the database, sqlite uses ?, mysql uses %s, postgresl uses %s or %(key)s if passin... | [
3,
1,
0
] | [] | [] | [
"database",
"python"
] | stackoverflow_0001293056_database_python.txt |
Q:
How to find the sum of a ASCII value in a file to find the max number of ASCII and to print out the name of the highest sum of ASCII value
Here is the code I'm working with
def ascii_sum():
x = 0
infile = open("30075165.txt","r")
for line in infile:
return sum([ord(x) for x in line])
infile... | How to find the sum of a ASCII value in a file to find the max number of ASCII and to print out the name of the highest sum of ASCII value | Here is the code I'm working with
def ascii_sum():
x = 0
infile = open("30075165.txt","r")
for line in infile:
return sum([ord(x) for x in line])
infile.close()
This code only prints out the first ASCII value in the file not the max ASCII value
| [
"max(open(fname), key=lambda line: sum(ord(i) for i in line))\n\n",
"This is a snippet from an answer to one to of your previous questions\ndef get_file_data(filename):\n def ascii_sum(line):\n return sum([ord(x) for x in line])\n def word_count(line):\n return len(line.split(None))\n\n fil... | [
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0001293404_python.txt |
Q:
Human readable cookie information using cookielib?
Is there a way to print the cookies stored in a cookielib.CookieJar in a human-readable way?
I'm scraping a site and I'd like to know if the same cookies are set when I use my script as when I use the browser.
A:
import urllib2
from cookielib import CookieJar, D... | Human readable cookie information using cookielib? | Is there a way to print the cookies stored in a cookielib.CookieJar in a human-readable way?
I'm scraping a site and I'd like to know if the same cookies are set when I use my script as when I use the browser.
| [
"import urllib2\nfrom cookielib import CookieJar, DefaultCookiePolicy\npolicy = DefaultCookiePolicy(\nrfc2965=True, strict_ns_domain=DefaultCookiePolicy.DomainStrict)\ncj = CookieJar(policy)\nopener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))\nr = opener.open(\"http://somewebsite.com\")\n\n[str(i) for i... | [
1
] | [] | [] | [
"cookies",
"python"
] | stackoverflow_0001293828_cookies_python.txt |
Q:
Best way to obtain indexed access to a Python queue, thread-safe
I have a queue (from the Queue module), and I want to get indexed access into it. (i.e., being able to ask for item number four in the queue, without removing it from the queue.)
I saw that a queue uses a deque internally, and deque has indexed acces... | Best way to obtain indexed access to a Python queue, thread-safe | I have a queue (from the Queue module), and I want to get indexed access into it. (i.e., being able to ask for item number four in the queue, without removing it from the queue.)
I saw that a queue uses a deque internally, and deque has indexed access. The question is, how can I use the deque without (1) messing up the... | [
"import Queue\n\nclass IndexableQueue(Queue):\n def __getitem__(self, index):\n with self.mutex:\n return self.queue[index]\n\nIt's of course crucial to release the mutex whether the indexing succeeds or raises an IndexError, and I'm using a with statement for that. In older Python versions, try/finally wo... | [
14
] | [] | [] | [
"deque",
"multithreading",
"python",
"queue"
] | stackoverflow_0001293966_deque_multithreading_python_queue.txt |
Q:
How to insert / retrieve a file stored as a BLOB in a MySQL db using python
I want to write a python script that populates a database with some information. One of the columns in my table is a BLOB that I would like to save a file to for each entry.
How can I read the file (binary) and insert it into the DB using... | How to insert / retrieve a file stored as a BLOB in a MySQL db using python | I want to write a python script that populates a database with some information. One of the columns in my table is a BLOB that I would like to save a file to for each entry.
How can I read the file (binary) and insert it into the DB using python? Likewise, how can I retrieve it and write that file back to some arbitr... | [
"thedata = open('thefile', 'rb').read()\nsql = \"INSERT INTO sometable (theblobcolumn) VALUES (%s)\"\ncursor.execute(sql, (thedata,))\n\nThat code of course works as written only if your table has just the BLOB column and what\nyou want to do is INSERT, but of course you could easily tweak it to add more columns,\n... | [
18,
0
] | [] | [] | [
"blob",
"file_io",
"mysql",
"python"
] | stackoverflow_0001294385_blob_file_io_mysql_python.txt |
Q:
how to register more than 10 apps in Google App Engine
Anyone knows any "legal" way to surpass the 10-app-limit Google imposes?
I wouldn't mind to pay, or anything, but I wasn't able to find a way to have more
than 10 apps and can't either remove one.
A:
Call or write to Google! Google's policies are very exact ... | how to register more than 10 apps in Google App Engine | Anyone knows any "legal" way to surpass the 10-app-limit Google imposes?
I wouldn't mind to pay, or anything, but I wasn't able to find a way to have more
than 10 apps and can't either remove one.
| [
"Call or write to Google! Google's policies are very exact and very strict, because they are catering to thousands of developers, and thus need those standards and uniformity. But if you have a good reason for needing more than 10, and you can get a real person at the end of a telephone line, I'd think you'd have a... | [
3
] | [] | [] | [
"google_app_engine",
"python",
"registration"
] | stackoverflow_0001294618_google_app_engine_python_registration.txt |
Q:
Python subprocess question
I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.
My ideal situation would be to have a cross platform generic technique that involved only the standard python ... | Python subprocess question | I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.
My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess gets prett... | [
"Use the multiprocessing module in the Python 2.6 standard library. \nIt has a Queue class that can be used for both reading and writing.\n",
"I do this in a separate thread, using message queues to communicate between the threads. In my case the subprocess prints % complete to stdout. I wanted the main thread... | [
3,
1,
0,
0
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0001110804_python_subprocess.txt |
Q:
Sandboxing / copying a module in two separate places to prevent overwriting or monkey patching
Using these four files, all in the same directory:
splitter.py
#imagine this is a third-party library
SPLIT_CHAR = ','
class Splitter(object):
def __init__(self, s, split_char=None):
self.orig = s
if... | Sandboxing / copying a module in two separate places to prevent overwriting or monkey patching | Using these four files, all in the same directory:
splitter.py
#imagine this is a third-party library
SPLIT_CHAR = ','
class Splitter(object):
def __init__(self, s, split_char=None):
self.orig = s
if not split_char:
self.splitted = s.split(SPLIT_CHAR)
a.py
#this person makes the mistak... | [
"\"Is there a way to prevent this result?\"\nYes. Find the people who monkeypatched the module and make them stop.\nMonkeypatching doesn't require fancy code work-arounds. It requires people to simply cooperate.\nIf you write a module and some co-worker makes a mess of it, you should talk to that co-worker. It's... | [
2,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0001293879_python.txt |
Q:
HTML snippet from Python
I'm new to Python and CGI, so this may be trivial. But I'd like Python to produce a block of HTML whenever a visitor loads a page.
<html>
<body>
<!-- Beautiful website with great content -->
<!-- Suddenly... -->
<h1> Here's Some Python Output </h1>
<!-- RUN PYTHON SCRIPT, display output -... | HTML snippet from Python | I'm new to Python and CGI, so this may be trivial. But I'd like Python to produce a block of HTML whenever a visitor loads a page.
<html>
<body>
<!-- Beautiful website with great content -->
<!-- Suddenly... -->
<h1> Here's Some Python Output </h1>
<!-- RUN PYTHON SCRIPT, display output -->
</body>
</html>
Using a P... | [
"Use AJAX client-side, or templates server side. \nA template will allow you to keep most of your page static, but use a server-side scripting language (like Python) to fill in the dynamic bits. There are lots of good posts on Python template systems on Stackoverflow. Here's one\nAJAX will allow you to update a p... | [
3
] | [] | [] | [
"cgi",
"html",
"python"
] | stackoverflow_0001295446_cgi_html_python.txt |
Q:
Can't get Beaker sessions to work (KeyError)
I'm a newb to the Python world and am having the dangest time with getting sessions to work in my web frameworks. I've tried getting Beaker sessions to work with the webpy framework and the Juno framework. And in both frameworks I always get a KeyError when I try to ... | Can't get Beaker sessions to work (KeyError) | I'm a newb to the Python world and am having the dangest time with getting sessions to work in my web frameworks. I've tried getting Beaker sessions to work with the webpy framework and the Juno framework. And in both frameworks I always get a KeyError when I try to start the session.
Here is the error message in we... | [
"You haven't created the session object yet, so you can't find it in the environment (the KeyError simply means \"beaker.session is not in this dictionary\").\nNote that I don't know either webpy nor beaker very well, so I can't give you deeper advice, but from what I understand from the docs and source this should... | [
2
] | [] | [] | [
"django",
"python",
"session",
"web.py"
] | stackoverflow_0001290840_django_python_session_web.py.txt |
Q:
How to replace Python function while supporting all passed in parameters
I'm looking for a way to decorate an arbitrary python function, so that an alternate function is called instead of the original, with all parameters passed as a list or dict.
More precisely, something like this (where f is any function, and r... | How to replace Python function while supporting all passed in parameters | I'm looking for a way to decorate an arbitrary python function, so that an alternate function is called instead of the original, with all parameters passed as a list or dict.
More precisely, something like this (where f is any function, and replacement_f takes a list and a dict):
def replace_func(f, replacement_f):
... | [
"why don't you just try:\nf = replacement_f\n\nexample:\n>>> def rep(*args):\n print(*args, sep=' -- ')\n\n>>> def ori(*args):\n print(args)\n\n>>> ori('dfef', 32)\n('dfef', 32)\n>>> ori = rep\n>>> ori('dfef', 32)\ndfef -- 32\n\n",
"Although I think SilentGhost's answer is the best solution if it works for ... | [
4,
1,
0,
0
] | [] | [] | [
"decorator",
"keyword_argument",
"python"
] | stackoverflow_0001295415_decorator_keyword_argument_python.txt |
Q:
Evaluate a script (e.g. Python) in Java for Android platform
Is it possible to evaluate a string of python code (or Perl) from Java when developing Android applications?
I am trying to do something like evaluating a text-input script:
String script = text1.getText().toString();
String result = PythonRuntime.evalua... | Evaluate a script (e.g. Python) in Java for Android platform | Is it possible to evaluate a string of python code (or Perl) from Java when developing Android applications?
I am trying to do something like evaluating a text-input script:
String script = text1.getText().toString();
String result = PythonRuntime.evaluate(script);
text2.setText(result);
| [
"In case you weren't aware of it, the Android Scripting Environment might be useful to you, though I don't think it does exactly what you're looking for.\n",
"Jython and its derivatives should be able to do this. See also Jythondroid.\n"
] | [
5,
4
] | [] | [] | [
"android",
"java",
"python",
"scripting"
] | stackoverflow_0001295720_android_java_python_scripting.txt |
Q:
Getting DOM tree of XML document
Does anyone know how I would get a DOM instance (tree) of an XML file in Python. I am trying to compare two XML documents to eachother that may have elements and attributes in different order. How would I do this?
A:
Personally, whenever possible, I'd start with elementtree (pref... | Getting DOM tree of XML document | Does anyone know how I would get a DOM instance (tree) of an XML file in Python. I am trying to compare two XML documents to eachother that may have elements and attributes in different order. How would I do this?
| [
"Personally, whenever possible, I'd start with elementtree (preferably the C implementation that comes with Python's standard library, or the lxml implementation, but that's essentialy a matter of higher speed, only). It's not a standard-compliant DOM, but holds the same information in a more Pythonic and handier w... | [
2,
1,
0
] | [] | [] | [
"dom",
"python",
"xml"
] | stackoverflow_0001294654_dom_python_xml.txt |
Q:
Numpy: Is there an array size limit?
I'm learning to use Numpy and I wanted to see the speed difference in the summation of a list of numbers so I made this code:
np_array = numpy.arange(1000000)
start = time.time()
sum_ = np_array.sum()
print time.time() - start, sum_
>>> 0.0 1783293664
python_list = range(1000... | Numpy: Is there an array size limit? | I'm learning to use Numpy and I wanted to see the speed difference in the summation of a list of numbers so I made this code:
np_array = numpy.arange(1000000)
start = time.time()
sum_ = np_array.sum()
print time.time() - start, sum_
>>> 0.0 1783293664
python_list = range(1000000)
start = time.time()
sum_ = sum(python... | [
"The standard list switched over to doing arithmetic with the long type when numbers got larger than a 32-bit int.\nThe numpy array did not switch to long, and suffered from integer overflow. The price for speed is smaller range of values allowed.\n>>> 499999500000 % 2**32\n1783293664L\n\n",
"Numpy is creating a... | [
9,
9,
6
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0001295994_numpy_python.txt |
Q:
simple python script to block nokia n73 screen
i want that upon opening my N73's camera cover,the camera software keeps working as usual,but that it is blocked by a black screen covering the whole screen so that it appears that the camera is not working... I know my requirement is weired but i need this.. ;)
Can a... | simple python script to block nokia n73 screen | i want that upon opening my N73's camera cover,the camera software keeps working as usual,but that it is blocked by a black screen covering the whole screen so that it appears that the camera is not working... I know my requirement is weired but i need this.. ;)
Can anyone guide me to write a python script that does ex... | [
"I'm rather sceptical whether this can be achieved with PyS60. First of all, AFAIK for PyS60 program you'd need to start the interpreter environment first, autostarting when camera starts probably won't be possible.\nAlso, opening the camera cover probably does not have any callback so you won't be able to detect i... | [
0
] | [] | [] | [
"camera",
"n73",
"pys60",
"python"
] | stackoverflow_0001296359_camera_n73_pys60_python.txt |
Q:
Getting system status in python
Is there any way to get system status in python, for example the amount of memory free, processes that are running, cpu load and so on.
I know on linux I can get this from the /proc directory, but I would like to do this on unix and windows as well.
A:
I don't know of any such lib... | Getting system status in python | Is there any way to get system status in python, for example the amount of memory free, processes that are running, cpu load and so on.
I know on linux I can get this from the /proc directory, but I would like to do this on unix and windows as well.
| [
"I don't know of any such library/ package that currently supports both Linux and Windows. There's libstatgrab which doesn't seem to be very actively developed (it already supports a decent variety of Unix platforms though) and the very active PSI (Python System Information) which works on AIX, Linux, SunOS and Dar... | [
8,
7
] | [] | [] | [
"operating_system",
"python"
] | stackoverflow_0001296703_operating_system_python.txt |
Q:
What is the best way to handle rotating sprites for a top-down view game
I am working on a top-down view 2d game at the moment and I am learning a ton about sprites and sprite handling. My question is how to handle a set of sprites that can be rotated in as many as 32 directions.
At the moment a given object has i... | What is the best way to handle rotating sprites for a top-down view game | I am working on a top-down view 2d game at the moment and I am learning a ton about sprites and sprite handling. My question is how to handle a set of sprites that can be rotated in as many as 32 directions.
At the moment a given object has its sprite sheet with all of the animations oriented with the object pointing a... | [
"The 32 directions for the sprite translate into 32 rotations by 11.25 degrees. \nYou can reduce the number of precalculated images to 8 you only calculate the first 90 degrees (11.25, 22.5, 33.75, 45.0, 56.25, 67.5, 78.75, 90.0) and use the flip operations dynamically. Flips are much faster because they essentiall... | [
4,
2,
1
] | [] | [] | [
"pygame",
"python",
"sprite"
] | stackoverflow_0001275482_pygame_python_sprite.txt |
Q:
Does IronPython implement python standard library?
I tried IronPython some time ago and it seemed that it implements only python language, and uses .NET for libraries. Is this still the case? Can one use python modules from IronPython?
A:
The IronPython installer includes the Python standard library. Otherwise, ... | Does IronPython implement python standard library? | I tried IronPython some time ago and it seemed that it implements only python language, and uses .NET for libraries. Is this still the case? Can one use python modules from IronPython?
| [
"The IronPython installer includes the Python standard library. Otherwise, you can use the standard library from a compatible Python install (IPy 2.0 -> CPy 2.5, IPy 2.6 -> CPy 2.6). Either copy the Python Lib directory to the IronPython folder, or set IRONPYTHONPATH.\nDo note that only the pure Pyton modules will ... | [
9,
4,
3,
0
] | [] | [] | [
"ironpython",
"python"
] | stackoverflow_0001296640_ironpython_python.txt |
Q:
Efficiency of using a Python list as a queue
A coworker recently wrote a program in which he used a Python list as a queue. In other words, he used .append(x) when needing to insert items and .pop(0) when needing to remove items.
I know that Python has collections.deque and I'm trying to figure out whether to spe... | Efficiency of using a Python list as a queue | A coworker recently wrote a program in which he used a Python list as a queue. In other words, he used .append(x) when needing to insert items and .pop(0) when needing to remove items.
I know that Python has collections.deque and I'm trying to figure out whether to spend my (limited) time to rewrite this code to use i... | [
"Some answers claimed a \"10x\" speed advantage for deque vs list-used-as-FIFO when both have 1000 entries, but that's a bit of an overbid:\n$ python -mtimeit -s'q=range(1000)' 'q.append(23); q.pop(0)'\n1000000 loops, best of 3: 1.24 usec per loop\n$ python -mtimeit -s'import collections; q=collections.deque(range(... | [
79,
47,
22,
5,
2
] | [] | [] | [
"list",
"memory_leaks",
"python"
] | stackoverflow_0001296511_list_memory_leaks_python.txt |
Q:
Python sendto() not working on 3.1 (works on 2.6)
For some reason, the following seems to work perfectly on my ubuntu machine running python 2.6 and returns an error on my windows xp box running python 3.1
from socket import socket, AF_INET, SOCK_DGRAM
data = 'UDP Test Data'
port = 12345
hostname = '192.168.0.1'
u... | Python sendto() not working on 3.1 (works on 2.6) | For some reason, the following seems to work perfectly on my ubuntu machine running python 2.6 and returns an error on my windows xp box running python 3.1
from socket import socket, AF_INET, SOCK_DGRAM
data = 'UDP Test Data'
port = 12345
hostname = '192.168.0.1'
udp = socket(AF_INET,SOCK_DGRAM)
udp.sendto(data, (hostn... | [
"In Python 3, the string (first) argument must be of type bytes or buffer, not str. You'll get that error message if you supply the optional flags parameter. Change data to:\ndata = b'UDP Test Data'\nYou might want to file a bug report about that at the python.org bug tracker. [EDIT: already filed as noted by Da... | [
6,
4
] | [] | [] | [
"python",
"sendto",
"ubuntu",
"udp",
"windows"
] | stackoverflow_0001297505_python_sendto_ubuntu_udp_windows.txt |
Q:
Python WWW macro
i need something like iMacros for Python. It would be great to have something like that:
browse_to('www.google.com')
type_in_input('search', 'query')
click_button('search')
list = get_all('<p>')
Do you know something like that?
Thanks in advance,
Etam.
A:
Almost a direct fulfillment of the wish... | Python WWW macro | i need something like iMacros for Python. It would be great to have something like that:
browse_to('www.google.com')
type_in_input('search', 'query')
click_button('search')
list = get_all('<p>')
Do you know something like that?
Thanks in advance,
Etam.
| [
"Almost a direct fulfillment of the wishes in the question - twill.\n\ntwill is a simple language that allows users to browse the Web from a command-line interface. With twill, you can navigate through Web sites that use forms, cookies, and most standard Web features.\ntwill supports automated Web testing and has a... | [
7,
6,
0
] | [] | [] | [
"python",
"screen_scraping"
] | stackoverflow_0001294862_python_screen_scraping.txt |
Q:
Python class method - Is there a way to make the calls shorter?
I am playing around with Python, and I've created a class in a different package from the one calling it. In this class, I've added a class method which is being called from my main function. Again, they are in separate packages. The line to call t... | Python class method - Is there a way to make the calls shorter? | I am playing around with Python, and I've created a class in a different package from the one calling it. In this class, I've added a class method which is being called from my main function. Again, they are in separate packages. The line to call the class method is much longer than I thought it would be from the ex... | [
"from config.TestClass import TestClass\nTestClass.add_key( \"mykey\", \"newvalue\" )\n\n"
] | [
13
] | [] | [] | [
"class_method",
"python"
] | stackoverflow_0001297583_class_method_python.txt |
Q:
Writing a tail -f python script that doesn't utilize 100% CPU
Here's a simple implementation of tail -f written in python. The problem with this is with the looping nature, this script likes to hog a lot of the CPU time. If it's something one would like to run as a forked process/daemon, it would be an inefficient... | Writing a tail -f python script that doesn't utilize 100% CPU | Here's a simple implementation of tail -f written in python. The problem with this is with the looping nature, this script likes to hog a lot of the CPU time. If it's something one would like to run as a forked process/daemon, it would be an inefficient start.
What's a solution to have a CPU efficient tail -f written i... | [
"I don't know of an implementation that's going to be extremely efficient AND portable between Windows on one side, and just about every other system on the other. Just about everywhere, I'd use the select module of the standard library (which can be based on system level functionality such as select, kqueue, etc) ... | [
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0001297563_algorithm_python.txt |
Q:
Why there is a difference in "import" vs. "import *"?
"""module a.py"""
test = "I am test"
_test = "I am _test"
__test = "I am __test"
=============
~ $ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license"... | Why there is a difference in "import" vs. "import *"? | """module a.py"""
test = "I am test"
_test = "I am _test"
__test = "I am __test"
=============
~ $ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from a import *
>>> test
'I am t... | [
"Variables with a leading \"_\" (underbar) are not public names and will not be imported when from x import * is used.\nHere, _test and __test are not public names.\nFrom the import statement description:\n\nIf the list of identifiers is replaced\n by a star ('*'), all public names\n defined in the module are bou... | [
21
] | [] | [] | [
"import",
"python"
] | stackoverflow_0001297766_import_python.txt |
Q:
SQLAlchemy(Postgres) and transaction
I want a record from a table(queue) to be selected, locked(no other process can edit this record) and updated at a later point in time.
I assumed if I put the whole querying and updating in a transaction, no other process can edit/query the same record. But I am not quite able ... | SQLAlchemy(Postgres) and transaction | I want a record from a table(queue) to be selected, locked(no other process can edit this record) and updated at a later point in time.
I assumed if I put the whole querying and updating in a transaction, no other process can edit/query the same record. But I am not quite able to achieve this.
def move(one, two):
fro... | [
"Either make your transaction isolation level serializable, or fetch the record for updating via query.with_lockmode('update').\n"
] | [
1
] | [] | [] | [
"postgresql",
"python",
"sqlalchemy"
] | stackoverflow_0001296994_postgresql_python_sqlalchemy.txt |
Q:
Python: Which modules for a discussion site?
A site should be ready in 6 days. I am not allowed to use any framework such as Django. I am going to use:
Python modules
HTMLGen to generate HTML code from class-based description
SQLObject, relational tables onto Python's class model
?
Other
Python 2.5
A variant of... | Python: Which modules for a discussion site? | A site should be ready in 6 days. I am not allowed to use any framework such as Django. I am going to use:
Python modules
HTMLGen to generate HTML code from class-based description
SQLObject, relational tables onto Python's class model
?
Other
Python 2.5
A variant of the Postgres schema
Super Smack for testing the s... | [
"How about Jinja for templating? It will be much faster than working with autogenerated html.\nhttp://pypi.python.org/pypi/Jinja2/2.0\n",
"I think TurboGears started out as a project to collect best-of-breed packages together with some glue code to stitch them together. I think the latest incarnation uses Pylons... | [
3,
1
] | [] | [] | [
"module",
"postgresql",
"python",
"web"
] | stackoverflow_0001297350_module_postgresql_python_web.txt |
Q:
Is there an easy way to use a python tempfile in a shelve (and make sure it cleans itself up)?
Basically, I want an infinite size (more accurately, hard-drive rather than memory bound) dict in a python program I'm writing. It seems like the tempfile and shelve modules are naturally suited for this, however, I can'... | Is there an easy way to use a python tempfile in a shelve (and make sure it cleans itself up)? | Basically, I want an infinite size (more accurately, hard-drive rather than memory bound) dict in a python program I'm writing. It seems like the tempfile and shelve modules are naturally suited for this, however, I can't see how to use them together in a safe manner. I want the tempfile to be deleted when the shelve i... | [
"I would rather inherit from shelve.Shelf, and override the close method (*) to unlink the files. Notice that, depending on the specific dbm module being used, you may have more than one file that contains the shelf. One solution could be to create a temporary directory, rather than a temporary file, and remove any... | [
1
] | [] | [] | [
"python",
"shelve",
"temporary_files"
] | stackoverflow_0001298037_python_shelve_temporary_files.txt |
Q:
Passing kwargs from template to view?
As you may be able to tell from my questions, I'm new to both python and django. I would like to allow dynamic filter specifications of query sets from my templates using **kwargs. I'm thinking like a select box of a bunch of kwargs. For example:
<select id="filter">
<op... | Passing kwargs from template to view? | As you may be able to tell from my questions, I'm new to both python and django. I would like to allow dynamic filter specifications of query sets from my templates using **kwargs. I'm thinking like a select box of a bunch of kwargs. For example:
<select id="filter">
<option value="physician__isnull=True">Unassig... | [
"Rather than face the horrible dangers of SQL injection, why not just assign a value to each select option and have your form-handling view run the selected query based on the value.\nPassing the parameters for a DB query from page to view is just asking for disaster. Django is built to avoid this sort of thing.\n"... | [
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001269544_django_python.txt |
Q:
Running a plain python interpreter in presense of ipython with manage.py shell
I have ipython installed, I want to run a plain python interpreter instead with manage.py shell.
So I try,
python2.5 manage.py shell --plain
Which gave me an error, and text which suggest that --plain was passed to ipython
So I read, h... | Running a plain python interpreter in presense of ipython with manage.py shell | I have ipython installed, I want to run a plain python interpreter instead with manage.py shell.
So I try,
python2.5 manage.py shell --plain
Which gave me an error, and text which suggest that --plain was passed to ipython
So I read, http://docs.djangoproject.com/en/dev/ref/django-admin/
which suggets
django-admin.py... | [
"If the reason you want to use python's interpretor over iPython's is because you need to paste the doc tests, you can try typing\n%doctest_mode\n\nin the ipython console instead\nIn [1]: %doctest_mode\n*** Pasting of code with \">>>\" or \"...\" has been enabled.\nException reporting mode: Plain\nDoctest mode is: ... | [
1,
0
] | [] | [] | [
"django",
"django_manage.py",
"python"
] | stackoverflow_0001295492_django_django_manage.py_python.txt |
Q:
--home or --prefix in python package install?
When you build and install a python package, you have two choices: --home and --prefix.
I never really got the difference between the two (I always use --home) but if I understood correctly one is deprecated and the other is "the way to go"™.
Am I wrong ?
A:
Accordin... | --home or --prefix in python package install? | When you build and install a python package, you have two choices: --home and --prefix.
I never really got the difference between the two (I always use --home) but if I understood correctly one is deprecated and the other is "the way to go"™.
Am I wrong ?
| [
"According to the Installing Python Modules documentation, the \"standard\" way is to specify neither, and to let Python install it in either /usr/local/lib/pythonX.Y/site-packages on *nix or C:\\Python\\ on Windows.\nBut, if you do decide to go for an alternate method, you can specify --home to name the base insta... | [
4
] | [] | [] | [
"installation",
"python"
] | stackoverflow_0001298036_installation_python.txt |
Q:
Py2Exe - "The application configuration is incorrect."
I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm ... | Py2Exe - "The application configuration is incorrect." | I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.
The client does not have administrator ... | [
"Give GUI2exe a shot; it's developed by Andrea Gavana who's big in the wxpython community and wraps a bunch of the freezers, including py2exe. It's likely a dll issue, try searching the wxpython list archive. This thread may be of use.\n",
"I've ran into this myself and my random Googling has pointed me to seve... | [
3,
1,
1,
0
] | [] | [] | [
"compilation",
"py2exe",
"python",
"wxpython"
] | stackoverflow_0000441256_compilation_py2exe_python_wxpython.txt |
Q:
Match all urls that aren't wrapped into tag
I am seeking for a regular expression pattern that could match urls in HTML that aren't wrapped into 'a' tag, in order to wrap them into 'a' tag further (i.e. highlight all non-highlighted links).
Input is simple HTML with 'a', 'b', 'i', 'br', 'p' 'img' tags allowed. Al... | Match all urls that aren't wrapped into tag | I am seeking for a regular expression pattern that could match urls in HTML that aren't wrapped into 'a' tag, in order to wrap them into 'a' tag further (i.e. highlight all non-highlighted links).
Input is simple HTML with 'a', 'b', 'i', 'br', 'p' 'img' tags allowed. All other HTML tags shouldn't appear in the input, b... | [
"You could use BeautifulSoup or similar to exclude all urls that are already part of links. \nThen you can match the plain text with one of the url regular expressions that's already out there (google \"url regular expression\", which one you want depends on how fancy you want to get).\n",
"Parsing HTML with a si... | [
5,
5
] | [
"Thanks guys! Below is my solution:\nfrom django.utils.html import urlize # Yes, I am using Django's urlize to do all dirty work :)\n\ndef urlize_html(value):\n \"\"\"\n Urlizes text containing simple HTML tags.\n \"\"\"\n A_IMG_REGEX = r'(<[aA][^>]+>[^<]+</[aA]>|<[iI][mM][gG][^>]+>)'\n a_img_re = re... | [
-2
] | [
"python",
"regex"
] | stackoverflow_0001296778_python_regex.txt |
Q:
Handling international dates in python
I have a date that is either in German for e.g,
2. Okt. 2009
and also perhaps as
2. Oct. 2009
How do I convert this into an ISO datetime (or Python datetime)?
Solved by using this snippet:
for l in locale.locale_alias:
worked = False
try:
locale.setlocale(lo... | Handling international dates in python | I have a date that is either in German for e.g,
2. Okt. 2009
and also perhaps as
2. Oct. 2009
How do I convert this into an ISO datetime (or Python datetime)?
Solved by using this snippet:
for l in locale.locale_alias:
worked = False
try:
locale.setlocale(locale.LC_TIME, l)
worked = True
e... | [
"http://docs.python.org/library/locale.html\nThe datetime module is already locale-aware.\nIt's something like the following\n# German locale\nloc = locale.setlocale(locale.LC_TIME, (\"de\",\"de\"))\ntry:\n date = datetime.date.strptime(input, \"%d. %b. %Y\")\nexcept:\n # English locale\n loc = locale.s... | [
11,
3
] | [] | [] | [
"datetime",
"internationalization",
"locale",
"python"
] | stackoverflow_0001299377_datetime_internationalization_locale_python.txt |
Q:
Python re question - sub challenge
I want to add a href links to all words prefixed with # or ! or @
If this is the text
Check the #bamboo and contact @Fred re #bamboo #garden
should be converted to:
Check the <a href="/what/bamboo">#bamboo</a> and contact <a href="/who/fred">@Fred</a> re <a href="/what/bamboo">#b... | Python re question - sub challenge | I want to add a href links to all words prefixed with # or ! or @
If this is the text
Check the #bamboo and contact @Fred re #bamboo #garden
should be converted to:
Check the <a href="/what/bamboo">#bamboo</a> and contact <a href="/who/fred">@Fred</a> re <a href="/what/bamboo">#bamboo</a> <a href="/what/garden">#garden... | [
"I'd do it with a single match and a function picking the \"place\". I.e.:\nimport re\n\nplaces = {'#': 'what',\n '@': 'who',\n '!': 'why',\n }\n\ndef replace(m):\n all = m.group(0)\n first, rest = all[0], all[1:]\n return '<a href=\"/%s/%s\">%s</a>' % (\n places[first], rest, all)\n... | [
5
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0001300350_python_regex.txt |
Q:
HTTPResponse - Return organised data (table?)
My Webservice is currently returning a HTTPResponse which contains thousands of data from a mySQL database (via a Objects.filter). It's currently just displating them in a very boring way!
I'm looking to organised this data in some way. What would be ideal is two thing... | HTTPResponse - Return organised data (table?) | My Webservice is currently returning a HTTPResponse which contains thousands of data from a mySQL database (via a Objects.filter). It's currently just displating them in a very boring way!
I'm looking to organised this data in some way. What would be ideal is two things:
The possibility of having a table and maybe havi... | [
"Do you need to return pure HTML (as opposed to, say, JSON and Javascript to show it)? If so, the <table> tag of HTML seems to be what you want; and this is a way to have a scrollbar on the table.\n"
] | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001300310_django_python.txt |
Q:
Error while importing SQLObject on Windows
I am getting following error while importing SQLObject on Window. Does anyone knows what is this error about and how to solve it?
==============================
from sqlobject import *
File "c:\python26\lib\site-packages\sqlobject-0.10.4-py2.6.egg\sqlobject\__init__... | Error while importing SQLObject on Windows | I am getting following error while importing SQLObject on Window. Does anyone knows what is this error about and how to solve it?
==============================
from sqlobject import *
File "c:\python26\lib\site-packages\sqlobject-0.10.4-py2.6.egg\sqlobject\__init__.py", line 5, in <module>
from main import *... | [
"Looks like your c:\\python26\\lib\\site-packages\\sqlobject-0.10.4-py2.6.egg file may be truncated or otherwise damaged. How does it compare to a freshly downloaded one (in terms of both length and checksum)?\n"
] | [
0
] | [] | [] | [
"python",
"sqlobject",
"windows"
] | stackoverflow_0001299849_python_sqlobject_windows.txt |
Q:
Best Python Library for Downloading and Extracting Addresses
I've just been given a project which involves the following steps
Grab an email from a POP3 address
Open an attachment from the email
Extract the To: email address
Add this to a global suppression list
I'd like to try and do this in Python even though... | Best Python Library for Downloading and Extracting Addresses | I've just been given a project which involves the following steps
Grab an email from a POP3 address
Open an attachment from the email
Extract the To: email address
Add this to a global suppression list
I'd like to try and do this in Python even though I could it in PHP in half the time (this is because I dont know a... | [
"Two bits from the standard library: poplib to grab the email via POP3, email to slice and dice it as you wish.\n"
] | [
2
] | [] | [] | [
"email",
"pop3",
"python"
] | stackoverflow_0001300479_email_pop3_python.txt |
Q:
Python - substr
I need to be able to get the last digit of a number.
i.e., I need 2 to be returned from: 12.
Like this in PHP: $minute = substr(date('i'), -1) but I need this in Python.
Any ideas
A:
last_digit = str(number)[-1]
A:
Use the % operator:
x = 12 % 10 # returns 2
y = 25 % 10 # returns 5
z =... | Python - substr | I need to be able to get the last digit of a number.
i.e., I need 2 to be returned from: 12.
Like this in PHP: $minute = substr(date('i'), -1) but I need this in Python.
Any ideas
| [
"last_digit = str(number)[-1]\n\n",
"Use the % operator:\n x = 12 % 10 # returns 2\n y = 25 % 10 # returns 5\n z = abs(-25) % 10 # returns 5\n\n",
"Python distinguishes between strings and numbers (and actually also between numbers of different kinds, i.e., int vs float) so the best solution depends on wh... | [
9,
8,
2
] | [] | [] | [
"php",
"python",
"substr"
] | stackoverflow_0001300610_php_python_substr.txt |
Q:
Multidimensional list(array) reassignment problem
Good day coders and codereses,
I am writing a piece of code that goes through a pile of statistical data and returns what I ask from it. To complete its task the method reads from one multidimensional array and writes into another one. The piece of code giving me p... | Multidimensional list(array) reassignment problem | Good day coders and codereses,
I am writing a piece of code that goes through a pile of statistical data and returns what I ask from it. To complete its task the method reads from one multidimensional array and writes into another one. The piece of code giving me problems is:
writer.variables[variable][:, :, :, :] = re... | [
"The size of a slice with 0:5 is not 6 as you say: it's 5. The upper limit is excluded in slicing (as it most always is, in Python). Don't know whether that's your actual problem or just a typo in your question...\n"
] | [
2
] | [] | [] | [
"list",
"netcdf",
"numpy",
"python",
"scipy"
] | stackoverflow_0001300648_list_netcdf_numpy_python_scipy.txt |
Q:
Hierarchical data output from App Engine Datastore to JSON?
I have a large hierarchical dataset in the App Engine Datastore. The hierarchy is preserved by storing the data in Entity groups, so that I can pull a whole tree by simply knowing the top element key like so:
query = db.Query().ancestor(db.get(key))
The ... | Hierarchical data output from App Engine Datastore to JSON? | I have a large hierarchical dataset in the App Engine Datastore. The hierarchy is preserved by storing the data in Entity groups, so that I can pull a whole tree by simply knowing the top element key like so:
query = db.Query().ancestor(db.get(key))
The question: How do I now output this data as JSON and preserve the ... | [
"I imagine you're referring to this code and the \"flattening\" you mention is done by lines 51-52:\n if isinstance(obj, db.GqlQuery):\n return list(obj)\n\nwhile the rest of the code is fine for your purpose. So, how would you like to represent a GQL query, since you don't what a JS array (Python list) of t... | [
1
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"json",
"python"
] | stackoverflow_0001300694_google_app_engine_google_cloud_datastore_json_python.txt |
Q:
Writing Python/Django view to "join" across three models/tables
Just begin my Python/Django experience and i have a problem :-)
So i have a model.py like this:
from django.db import models
class Priority(models.Model):
name = models.CharField(max_length=100)
class Projects(models.Model):
name = models.Ch... | Writing Python/Django view to "join" across three models/tables | Just begin my Python/Django experience and i have a problem :-)
So i have a model.py like this:
from django.db import models
class Priority(models.Model):
name = models.CharField(max_length=100)
class Projects(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length=... | [
"Your view doesn't have to do much.\ntasks = Tasks.objects.all()\n\nProvide this to your template.\nYour template can then do something like the following.\n{% for t in tasks %}\n name: {{t.name}}\n description: {{t.description}}\n priority: **{{t.priority.name}}**\n{% endfor %}\n\n",
"There are many way... | [
2,
0
] | [] | [] | [
"django_views",
"python"
] | stackoverflow_0001300657_django_views_python.txt |
Q:
On Google AppEngine what is the best way to merge two tables?
If I have two tables, Company and Sales, and I want to display both sets of data in a single list, how would I do this on Google App Engine using GQL?
The models are:
class Company(db.Model):
companyname = db.StringProperty()
companyid... | On Google AppEngine what is the best way to merge two tables? | If I have two tables, Company and Sales, and I want to display both sets of data in a single list, how would I do this on Google App Engine using GQL?
The models are:
class Company(db.Model):
companyname = db.StringProperty()
companyid = db.StringProperty()
salesperson = db.StringProperty()
class ... | [
"You've said in a comment that there's a 1-1 relationship between sales and companies. So you could get the data in the same order:\ndef company(request): \n companys = db.GqlQuery(\"SELECT * FROM Company ORDER BY companyid\").fetch(1000)\n sales = db.GqlQuery(\"SELECT * FROM Sales ORDER BY companyid\").fetch(100... | [
1,
0,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0001295832_google_app_engine_python.txt |
Q:
Unescape/unquote binary strings in (extended) url encoding in python
for analysis I'd have to unescape URL-encoded binary strings (non-printable characters most likely). The strings sadly come in the extended URL-encoding form, e.g. "%u616f". I want to store them in a file that then contains the raw binary values,... | Unescape/unquote binary strings in (extended) url encoding in python | for analysis I'd have to unescape URL-encoded binary strings (non-printable characters most likely). The strings sadly come in the extended URL-encoding form, e.g. "%u616f". I want to store them in a file that then contains the raw binary values, eg. 0x61 0x6f here.
How do I get this into binary data in python? (urlli... | [
"\nThe strings sadly come in the extended URL-encoding form, e.g. \"%u616f\"\n\nIncidentally that's not anything to do with URL-encoding. It's an arbitrary made-up format produced by the JavaScript escape() function and pretty much nothing else. If you can, the best thing to do would be to change the JavaScript to ... | [
3,
1,
0
] | [] | [] | [
"binary",
"python",
"urlencode"
] | stackoverflow_0001298319_binary_python_urlencode.txt |
Q:
What regex can I use to capture groups from this string?
Assume the following strings:
A01B100
A01.B100
A01
A01............................B100 ( whatever between A and B )
The thing is, the numbers should be \d+, and in all of the strings A will always be present, while B may not. A will always be followed by o... | What regex can I use to capture groups from this string? | Assume the following strings:
A01B100
A01.B100
A01
A01............................B100 ( whatever between A and B )
The thing is, the numbers should be \d+, and in all of the strings A will always be present, while B may not. A will always be followed by one or more digits, and so will B, if present. What regex could... | [
"\nMust A precede B? Assuming yes.\nCan B appear more than once? Assuming no. \nCan B appear except as part of a B-number group? Assuming no.\n\nThen,\nA\\d+.*?(B\\d+)?\n\nusing the lazy .*? or\nA\\d+[^B]*(B\\d+)?\n\nwhich is more efficient but requires that B be a single character.\nEDIT: Upon further reflection, ... | [
3,
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0001301257_python_regex.txt |
Q:
mod_python problem?
I have been working on a website using mod_python, python, and SQL Alchemy when I ran into a strange problem: When I query the database for all of the records, it returns the correct result set; however, when I refresh the page, it returns me a result set with that same result set appended to i... | mod_python problem? | I have been working on a website using mod_python, python, and SQL Alchemy when I ran into a strange problem: When I query the database for all of the records, it returns the correct result set; however, when I refresh the page, it returns me a result set with that same result set appended to it. I get more result sets... | [
"Not that I've ever heard of, but it's impossible to tell without some code to look at.\nMaybe you initialised your result set list as a global, or shared member, and then appended results to it when the application was called without resetting it to empty? A classic way of re-using lists accidentally is to put one... | [
0,
0
] | [] | [] | [
"mod_python",
"python",
"sqlalchemy"
] | stackoverflow_0001301000_mod_python_python_sqlalchemy.txt |
Q:
Beginner at testing Python code, need help!
I don't do tests, but I'd like to start. I have some questions :
Is it ok to use the unittest module for that? From what I understand, the unittest module will run any method starting with test.
if I have a separate directory for the tests ( consider a directory named t... | Beginner at testing Python code, need help! | I don't do tests, but I'd like to start. I have some questions :
Is it ok to use the unittest module for that? From what I understand, the unittest module will run any method starting with test.
if I have a separate directory for the tests ( consider a directory named tests ), how would I import the code I'm testing? ... | [
"Another good way to start tests with your Python code is use the doctest module, whereby you include tests inside method and class comments. The neat bit is that these serve as code examples, and therefore, partial documentation. Extremely easy to do, too.\n",
"It's fine to use unittest. This module will run met... | [
5,
4,
2,
2
] | [] | [] | [
"python",
"testing"
] | stackoverflow_0001299672_python_testing.txt |
Q:
How do you enable auto-scrolling on GtkSourceView2?
I am having a problem with GtkSourceView used from Python.
Two major problems:
1) When a user types text into the GtkSourceView, and types past the bottom of the visible text, the GtkSourceView does not autoscroll to the users cursor.
This wouldnt be so bad, exce... | How do you enable auto-scrolling on GtkSourceView2? | I am having a problem with GtkSourceView used from Python.
Two major problems:
1) When a user types text into the GtkSourceView, and types past the bottom of the visible text, the GtkSourceView does not autoscroll to the users cursor.
This wouldnt be so bad, except:
2) The arrow keys, page up and page down keys, do not... | [
"Ok I just figured this out.\nI was adding the GtkSourceView2 into a GtkScrolledWindow.\nOnly, it was adding a ViewPort first via ScrolledWindow.add_with_viewport().\nThis disables part of the scrolling behavior via keyboard.\nInstead, use ScrolledWindow.add(), and the ViewPort is skipped and the GtkAdjustments tak... | [
0
] | [] | [] | [
"gtk",
"python"
] | stackoverflow_0001250566_gtk_python.txt |
Q:
django admin: company branches must manage only their records across many models
One company with many branches across the world using the same app. Each branch's supervisor, signing into the same /admin, should see and be able to manage only their records across many models (blog, galleries, subscribed users, cli... | django admin: company branches must manage only their records across many models | One company with many branches across the world using the same app. Each branch's supervisor, signing into the same /admin, should see and be able to manage only their records across many models (blog, galleries, subscribed users, clients list, etc.).
How to solve it best within django? I need a flexible and reliable ... | [
"There is a nice tutorial here on Django Admin. It includes customizing the Admin to add row-level permissions (which, as i understand it, is what you want).\n"
] | [
1
] | [] | [] | [
"django",
"django_admin",
"personalization",
"python"
] | stackoverflow_0001301757_django_django_admin_personalization_python.txt |
Q:
Counting python method calls within another method
I'm actually trying doing this in Java, but I'm in the process of teaching myself python and it made me wonder if there was an easy/clever way to do this with wrappers or something.
I want to know how many times a specific method was called inside another method. ... | Counting python method calls within another method | I'm actually trying doing this in Java, but I'm in the process of teaching myself python and it made me wonder if there was an easy/clever way to do this with wrappers or something.
I want to know how many times a specific method was called inside another method. For example:
def foo(z):
#do something
return re... | [
"Sounds like almost the textbook example for decorators!\ndef counted(fn):\n def wrapper(*args, **kwargs):\n wrapper.called += 1\n return fn(*args, **kwargs)\n wrapper.called = 0\n wrapper.__name__ = fn.__name__\n return wrapper\n\n@counted\ndef foo():\n return\n\n>>> foo()\n>>> foo.cal... | [
22,
7,
2
] | [] | [] | [
"profiling",
"python"
] | stackoverflow_0001301735_profiling_python.txt |
Q:
Fastest ways to key-wise add a list of dicts together in python
Say I have a bunch of dictionaries
a = {'x': 1.0, 'y': 0.5, 'z': 0.25 }
b = {'w': 0.5, 'x': 0.2 }
There's only two there, but the question is regarding an arbitary amount.
What's the fastest way to find the mean value for each key? The dicts are qui... | Fastest ways to key-wise add a list of dicts together in python | Say I have a bunch of dictionaries
a = {'x': 1.0, 'y': 0.5, 'z': 0.25 }
b = {'w': 0.5, 'x': 0.2 }
There's only two there, but the question is regarding an arbitary amount.
What's the fastest way to find the mean value for each key? The dicts are quite sparse, so there will be a lot of cases where lots of keys aren't ... | [
"It may be proven through profiling that this isn't quite the fastest but...\nimport collections\n\na = {'x': 1.0, 'y': 0.5, 'z': 0.25 }\nb = {'w': 0.5, 'x': 0.2 }\ndicts = [a,b]\n\ntotals = collections.defaultdict(list)\navg = {}\n\nfor D in dicts:\n for key,value in D.iteritems():\n totals[key].append(v... | [
2,
2,
1,
0,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0001301149_dictionary_python.txt |
Q:
unable to import libxml2mod from the python script
File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in <module>
import libxml2mod
ImportError: /usr/local/lib/python2.5/site-packages/libxml2mod.so:
undefined symbol:xmlTextReaderSetup
>>> import libxml2mod
>>> import libxml2
>>>
on Pyt... | unable to import libxml2mod from the python script | File "/usr/local/lib/python2.5/site-packages/libxml2.py", line 1, in <module>
import libxml2mod
ImportError: /usr/local/lib/python2.5/site-packages/libxml2mod.so:
undefined symbol:xmlTextReaderSetup
>>> import libxml2mod
>>> import libxml2
>>>
on Python Prompt it works fine !!
can anyone has idea why my p... | [
"I can only suggest that your paths are different for some reason. Either that, or you are not using the same python interpreter in both cases.\nI have experienced this when I happen to have a couple of interpreters, and the wrong one is either default, or specified in the #! section of the script.\n"
] | [
2
] | [] | [] | [
"importerror",
"python"
] | stackoverflow_0001301167_importerror_python.txt |
Q:
Python PEP8 printing wrapped strings without indent
There is probably an easy answer for this, just not sure how to tease it out of my searches.
I adhere to PEP8 in my python code, and I'm currently using OptionParser for a script I'm writing. To prevent lines from going beyond a with of 80, I use the backslash wh... | Python PEP8 printing wrapped strings without indent | There is probably an easy answer for this, just not sure how to tease it out of my searches.
I adhere to PEP8 in my python code, and I'm currently using OptionParser for a script I'm writing. To prevent lines from going beyond a with of 80, I use the backslash where needed.
For example:
if __name__=='__main__':
us... | [
"Use automatic string concatenation + implicit line continuation:\nlong_string = (\"Line 1 \"\n \"Line 2 \"\n \"Line 3 \")\n\n\n>>> long_string\n'Line 1 Line 2 Line 3 '\n\n",
"This works:\nif __name__=='__main__':\n usage = ('%prog [options]\\nWithout any options, will display 10 ra... | [
28,
3,
1
] | [] | [] | [
"pep8",
"python",
"word_wrap"
] | stackoverflow_0001302364_pep8_python_word_wrap.txt |
Q:
Produce multiple files from a single file in python
I have a file like below.
Sequence A.1.1 Bacteria
ATGCGCGATATAGGCCT
ATTATGCGCGCGCGC
Sequence A.1.2 Virus
ATATATGCGCCGCGCGTA
ATATATATGCGCGCCGGC
Sequence B.1.21 Chimpanzee
ATATAGCGCGCGCGCGAT
ATATATATGCGCG
Sequence C.21.4 Human
ATATATATGCCGCGCG
... | Produce multiple files from a single file in python | I have a file like below.
Sequence A.1.1 Bacteria
ATGCGCGATATAGGCCT
ATTATGCGCGCGCGC
Sequence A.1.2 Virus
ATATATGCGCCGCGCGTA
ATATATATGCGCGCCGGC
Sequence B.1.21 Chimpanzee
ATATAGCGCGCGCGCGAT
ATATATATGCGCG
Sequence C.21.4 Human
ATATATATGCCGCGCG
ATATAATATC
I want to make separate files for sequences ... | [
"It's not 100% clear what you want to do, but something like:\ncurrout = None\nseqname2file = dict()\n\nfor line in open('thefilewhosenameyoudonottellus.txt'):\n if line.startswith('Sequence '): \n seqname = line[9] # A or B or C\n if seqname not in seqname2file:\n filename = 'outputfileforsequence_... | [
2,
0
] | [] | [] | [
"file",
"python"
] | stackoverflow_0001302499_file_python.txt |
Q:
python for firefox extensions?
Can I use python in firefox extensions? Does it work?
A:
Yes, through an extension for mozilla, Python Extension (pythonext).
Originally hosted in mozdev, PythonExt project have move to Google code, you can see it in PythonExt in Google code.
| python for firefox extensions? | Can I use python in firefox extensions? Does it work?
| [
"Yes, through an extension for mozilla, Python Extension (pythonext).\nOriginally hosted in mozdev, PythonExt project have move to Google code, you can see it in PythonExt in Google code.\n"
] | [
25
] | [] | [] | [
"firefox",
"firefox_addon",
"plugins",
"python"
] | stackoverflow_0001302567_firefox_firefox_addon_plugins_python.txt |
Q:
cutdown uuid further to make short string
I need to generate unique record id for the given unique string.
I tried using uuid format which seems to be good.
But we feel that is lengthly.
so we need to cutdown the uuid string 9f218a38-12cd-5942-b877-80adc0589315 to smaller. By removing '-' we can save 4 chars. W... | cutdown uuid further to make short string | I need to generate unique record id for the given unique string.
I tried using uuid format which seems to be good.
But we feel that is lengthly.
so we need to cutdown the uuid string 9f218a38-12cd-5942-b877-80adc0589315 to smaller. By removing '-' we can save 4 chars. What is the safest part to remove from uuid? We ... | [
"Why not instead just convert it to a base 64 string? You can cut it down to 22 characters that way.\nStoring UUID as base64 String\n",
"If you are using MS-SQL you should probably just use the uniqueindentifier datatype, it is both compact (16 bytes) and since the SQL engine knows about it it can optimize indexe... | [
10,
3,
2,
2,
0
] | [] | [] | [
"c#",
"python",
"string",
"uniqueidentifier",
"uuid"
] | stackoverflow_0001302057_c#_python_string_uniqueidentifier_uuid.txt |
Q:
What possible values does datetime.strptime() accept for %Z?
Python's datetime.strptime() is documented as supporting a timezone in the %Z field. So, for example:
In [1]: datetime.strptime('2009-08-19 14:20:36 UTC', "%Y-%m-%d %H:%M:%S %Z")
Out[1]: datetime.datetime(2009, 8, 19, 14, 20, 36)
However, "UTC" seems to... | What possible values does datetime.strptime() accept for %Z? | Python's datetime.strptime() is documented as supporting a timezone in the %Z field. So, for example:
In [1]: datetime.strptime('2009-08-19 14:20:36 UTC', "%Y-%m-%d %H:%M:%S %Z")
Out[1]: datetime.datetime(2009, 8, 19, 14, 20, 36)
However, "UTC" seems to be the only timezone I can get it to support:
In [2]: datetime.st... | [
"I gather they are GMT, UTC, and whatever is listed in time.tzname.\n>>> for t in time.tzname:\n... print t\n...\nEastern Standard Time\nEastern Daylight Time\n>>> datetime.strptime('2009-08-19 14:20:36 Eastern Standard Time', \"%Y-%m-%d %H:%M:%S %Z\")\ndatetime.datetime(2009, 8, 19, 14, 20, 36)\n>>> datetime.s... | [
9,
4
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0001302701_datetime_python.txt |
Q:
Django popup box Error?? Running development web server
I have my Django site up and running, and everything works fine EXCEPT:
When I first go to my site http://127.0.0.1:8000
A popup box comes up and says
"The page at http://127.0.0.1:8000 says"
And just sits there
You have to hit OK before anything is displayed... | Django popup box Error?? Running development web server | I have my Django site up and running, and everything works fine EXCEPT:
When I first go to my site http://127.0.0.1:8000
A popup box comes up and says
"The page at http://127.0.0.1:8000 says"
And just sits there
You have to hit OK before anything is displayed.
What is going on here?
| [
"You must have a Javascript alert box in your template somewhere.\n"
] | [
1
] | [] | [] | [
"django",
"python",
"webserver"
] | stackoverflow_0001302040_django_python_webserver.txt |
Q:
Convert a nested dataset to a flat dataset, while retaining enough data to convert it back to nested set
Say I have a dataset like
(1, 2, (3, 4), (5, 6), (7, 8, (9, 0)))
I want to convert it to a (semi) flat representation like,
(
(1, 2),
(1, 2, 3, 4),
(1, 2, 5, 6),
(1, 2, 7, 8),
(1, 2, 7, 8, 9, 0),
)
If you use... | Convert a nested dataset to a flat dataset, while retaining enough data to convert it back to nested set | Say I have a dataset like
(1, 2, (3, 4), (5, 6), (7, 8, (9, 0)))
I want to convert it to a (semi) flat representation like,
(
(1, 2),
(1, 2, 3, 4),
(1, 2, 5, 6),
(1, 2, 7, 8),
(1, 2, 7, 8, 9, 0),
)
If you use this, (taken from SO)
def flatten(iterable):
for i, item in enumerate(iterable):
if hasattr(item,... | [
"This will give the example output. Don't know if that's really the best way of representing the model you want, though...\ndef combineflatten(seq):\n items= tuple(item for item in seq if not isinstance(item, tuple))\n yield items\n for item in seq:\n if isinstance(item, tuple):\n for yie... | [
2,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0001302653_algorithm_python.txt |
Q:
How to set initial size for a dictionary in Python?
I'm putting around 4 million different keys into a Python dictionary.
Creating this dictionary takes about 15 minutes and consumes about 4GB of memory on my machine. After the dictionary is fully created, querying the dictionary is fast.
I suspect that dictionary... | How to set initial size for a dictionary in Python? | I'm putting around 4 million different keys into a Python dictionary.
Creating this dictionary takes about 15 minutes and consumes about 4GB of memory on my machine. After the dictionary is fully created, querying the dictionary is fast.
I suspect that dictionary creation is so resource consuming because the dictionary... | [
"With performance issues it's always best to measure. Here are some timings:\n d = {}\n for i in xrange(4000000):\n d[i] = None\n # 722ms\n\n d = dict(itertools.izip(xrange(4000000), itertools.repeat(None)))\n # 634ms\n\n dict.fromkeys(xrange(4000000))\n # 558ms\n\n s = set(xrange(4000000))\n dict.fromkeys(s)\n... | [
43,
11,
7,
4,
2,
1
] | [] | [] | [
"dictionary",
"performance",
"python"
] | stackoverflow_0001298636_dictionary_performance_python.txt |
Q:
Python / ADOX: 'The specified module could not be found.' (win32 extensions)
I'm running pywin32 for python 2.5.
I'm following the instructions for python ADO given at http://www.ecp.cc/pyado.html.
Creating an ADODB.Recordset object works fine. But when I try to create an ADOX.Catalog object I get an error:
>>> ... | Python / ADOX: 'The specified module could not be found.' (win32 extensions) | I'm running pywin32 for python 2.5.
I'm following the instructions for python ADO given at http://www.ecp.cc/pyado.html.
Creating an ADODB.Recordset object works fine. But when I try to create an ADOX.Catalog object I get an error:
>>> cat=win32com.client.Dispatch(r'ADOX.Catalog')
Traceback (most recent call last):
... | [
"Solution: even though ADOX was showing up in the COM browser as an available library, it wasn't \"registered\" properly. Following the instructions here, I executed the following at the Start->Run prompt:\n\nregsvr32 \"C:\\Program Files\\Common Files\\System\\ado\\msadox.dll\"\n\nNote that this is on a WinXP SP2 ... | [
4
] | [] | [] | [
"adodb",
"adox",
"python",
"pywin32"
] | stackoverflow_0001290472_adodb_adox_python_pywin32.txt |
Q:
Mutex in Python Twisted
I'm using the Twisted framework, and am getting RPCs asynchronously. I have another function which does a task every 2 seconds, and sleeps in between. This is called through reactor.callInThread. These depend on a shared resources, so I need some thread-safe way of accessing them. How does ... | Mutex in Python Twisted | I'm using the Twisted framework, and am getting RPCs asynchronously. I have another function which does a task every 2 seconds, and sleeps in between. This is called through reactor.callInThread. These depend on a shared resources, so I need some thread-safe way of accessing them. How does one go about using critical s... | [
"Though you can use threads in twisted, the usual idiom with twisted is to do RPC asyncronously using a single thread. Thats one of its advantages. The twisted framework will run the reactor and call your handler events when RPC results are ready for you. Then your code runs, and when your handler exits, control go... | [
2,
0
] | [] | [] | [
"locking",
"multithreading",
"mutex",
"python",
"twisted"
] | stackoverflow_0001051652_locking_multithreading_mutex_python_twisted.txt |
Q:
Interface with remote computers using Python
I've just become the system admin for my research group's cluster and, in this respect, am a novice. I'm trying to make a few tools to monitor the network and need help getting started implementing them with python (my native tongue).
For example, I would like to view w... | Interface with remote computers using Python | I've just become the system admin for my research group's cluster and, in this respect, am a novice. I'm trying to make a few tools to monitor the network and need help getting started implementing them with python (my native tongue).
For example, I would like to view who is logged onto remote machines. By hand, I'd ss... | [
"Here's a simple, cheap solution to get you started\nfrom subprocess import *\np = Popen('ssh servername who', shell=True, stdout=PIPE)\np.wait()\nprint p.stdout.readlines()\n\nreturns (eg)\n['usr pts/0 2009-08-19 16:03 (kakapo)\\n',\n 'usr pts/1 2009-08-17 15:51 (kakapo)\\n',\n 'usr pt... | [
2,
2,
1,
1,
0,
0
] | [] | [] | [
"monitoring",
"networking",
"python"
] | stackoverflow_0001303047_monitoring_networking_python.txt |
Q:
Django RSS Feed Problems
I'm working on a blogging application, and trying to made just a simple RSS feed system function. However, I'm running into an odd bug that doesn't make a lot of sense to me. I understand what's likely going on, but I don't understand why. My RSS Feed class is below:
class RSSFeed(Feed):
... | Django RSS Feed Problems | I'm working on a blogging application, and trying to made just a simple RSS feed system function. However, I'm running into an odd bug that doesn't make a lot of sense to me. I understand what's likely going on, but I don't understand why. My RSS Feed class is below:
class RSSFeed(Feed):
title = settings.BLOG_NAME
... | [
"Changing to:\nclass RSSFeed(Feed):\n title = settings.BLOG_NAME\n link = \"/blog/\"\n description = \"Recent Posts\"\n\n def items(self):\n return Story.objects.all().order_by('-created')[:10]\n\nFixed it. Not sure I totally understand it.. but whatev. :)\n",
"have you defined\ndef get_absolut... | [
4,
1
] | [] | [] | [
"django",
"django_rss",
"python"
] | stackoverflow_0001297426_django_django_rss_python.txt |
Q:
Python thread dump
Is there a way to get a thread dump from a running Python process?
Similar to kill -3 on a Java process.
A:
I havent seen anything built-in, but I have seen a solution here which can be exposed via http console. The solution iterates over all threads and outputs the stack.
| Python thread dump | Is there a way to get a thread dump from a running Python process?
Similar to kill -3 on a Java process.
| [
"I havent seen anything built-in, but I have seen a solution here which can be exposed via http console. The solution iterates over all threads and outputs the stack.\n"
] | [
5
] | [] | [] | [
"python"
] | stackoverflow_0001302991_python.txt |
Q:
Shortest hash in python to name cache files
What is the shortest hash (in filename-usable form, like a hexdigest) available in python? My application wants to save cache files for some objects. The objects must have unique repr() so they are used to 'seed' the filename. I want to produce a possibly unique filename... | Shortest hash in python to name cache files | What is the shortest hash (in filename-usable form, like a hexdigest) available in python? My application wants to save cache files for some objects. The objects must have unique repr() so they are used to 'seed' the filename. I want to produce a possibly unique filename for each object (not that many). They should not... | [
"The birthday paradox applies: given a good hash function, the expected number of hashes before a collision occurs is about sqrt(N), where N is the number of different values that the hash function can take. (The wikipedia entry I've pointed to gives the exact formula). So, for example, if you want to use no more t... | [
38,
27,
8,
4,
1,
1,
1,
0
] | [] | [] | [
"hash",
"python"
] | stackoverflow_0001303021_hash_python.txt |
Q:
setting option in config file using SafeConfigParser
I'm trying to set an option (xdebug.profiler_enable) in my php.ini file using python's ConfigParser object. here is the code:
section in php.ini file im trying to modify
[xdebug]
;XDEBUG SETTINGS
;turn on the profiler?
xdebug.profiler_enable=0
xdebug.profiler_ap... | setting option in config file using SafeConfigParser | I'm trying to set an option (xdebug.profiler_enable) in my php.ini file using python's ConfigParser object. here is the code:
section in php.ini file im trying to modify
[xdebug]
;XDEBUG SETTINGS
;turn on the profiler?
xdebug.profiler_enable=0
xdebug.profiler_append=1
xdebug.profiler_enable_trigger=0
xdebug.trace_o... | [
"phpIni.write(open(phpIniLocation, 'w'))\n\ndocs.\n"
] | [
2
] | [] | [] | [
"file_io",
"linux",
"python",
"ubuntu"
] | stackoverflow_0001303697_file_io_linux_python_ubuntu.txt |
Q:
How can I convert a URL query string into a list of tuples using Python?
I am struggling to convert a url to a nested tuple.
# Convert this string
str = 'http://somesite.com/?foo=bar&key=val'
# to a tuple like this:
[(u'foo', u'bar'), (u'key', u'val')]
I assume I need to be doing something like:
url = 'http://s... | How can I convert a URL query string into a list of tuples using Python? | I am struggling to convert a url to a nested tuple.
# Convert this string
str = 'http://somesite.com/?foo=bar&key=val'
# to a tuple like this:
[(u'foo', u'bar'), (u'key', u'val')]
I assume I need to be doing something like:
url = 'http://somesite.com/?foo=bar&key=val'
url = url.split('?')
get = ()
for param in ur... | [
"I believe you are looking for the urlparse module.\n\nThis module defines a standard\n interface to break Uniform Resource\n Locator (URL) strings up in components\n (addressing scheme, network location,\n path etc.), to combine the components\n back into a URL string, and to convert\n a “relative URL” to an... | [
29,
0
] | [] | [] | [
"parsing",
"python",
"url"
] | stackoverflow_0001302688_parsing_python_url.txt |
Q:
how to install new packages with python 3.1.1?
I've tried to install pip on windows, but it's not working:
giving me ImportError: No module named pkg_resources
easy_install doesn't have version 3.1 or so, just 2.5, and should be replaced by pim.
is there easy way to install it on windows?
A:
setuptools doesn't ... | how to install new packages with python 3.1.1? | I've tried to install pip on windows, but it's not working:
giving me ImportError: No module named pkg_resources
easy_install doesn't have version 3.1 or so, just 2.5, and should be replaced by pim.
is there easy way to install it on windows?
| [
"setuptools doesn't quite work on Python 3.1 yet. Try installing packages with regular distutils, or use binary packages (.exe, .msi) provided by the package author.\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0001304638_python.txt |
Q:
User-specific model in Django
I have a model containing items, which has many different fields. There is another model which assigns a set of this field to each user using a m2m-relation.
I want to achieve, that in the end, every user has access to a defined set of fields of the item model, and he only sees these ... | User-specific model in Django | I have a model containing items, which has many different fields. There is another model which assigns a set of this field to each user using a m2m-relation.
I want to achieve, that in the end, every user has access to a defined set of fields of the item model, and he only sees these field in views, he can only edit th... | [
"One way to do this would be to break the Item model up into the parts that are individually assignable to a user. If you have fixed user types (admin, customer, team etc.) who can always see the same set of fields, these parts would be whole groups of fields. If it's very dynamic and you want to be able to set up ... | [
0,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001304608_django_django_models_python.txt |
Q:
How to populate a list with items.count() from a queryset sorted by a datetime field
I had a hard time formulating the title, so please edit it if you have a better one :)
I'm trying to display some statistics using the pygooglechart. And I am using Django to get the database items out of the database.
The databas... | How to populate a list with items.count() from a queryset sorted by a datetime field | I had a hard time formulating the title, so please edit it if you have a better one :)
I'm trying to display some statistics using the pygooglechart. And I am using Django to get the database items out of the database.
The database items has a datetime field wich i want to "sort on". What i really want is to populate a... | [
"Assuming you're running Django 1.1 or a fairly recent checkout, you can use the new aggregation features. Something like:\ncounts = MyModel.objects.values('datettimefield').annotate(Count('datettimefield'))\n\nThis actually gets you a list of dictionaries:\n[{'datetimefield':<date1>, 'datettimefield__count':<count... | [
2,
0
] | [] | [] | [
"django",
"pygooglechart",
"python"
] | stackoverflow_0001302999_django_pygooglechart_python.txt |
Q:
python 3.1 with pydev
I am now moving to eclipse for my python development. I have pydev installed but it is showing grammar support up to python version 3.0. My question is can I use python 3.1 with 3.0 grammar? Has the grammar changed from version 3.0 to 3.1?
I am using eclipse 3.4.2 and pydev 1.4.7
A:
grammar... | python 3.1 with pydev | I am now moving to eclipse for my python development. I have pydev installed but it is showing grammar support up to python version 3.0. My question is can I use python 3.1 with 3.0 grammar? Has the grammar changed from version 3.0 to 3.1?
I am using eclipse 3.4.2 and pydev 1.4.7
| [
"grammar hasn't changed, some modules have.\n"
] | [
10
] | [] | [] | [
"eclipse",
"pydev",
"python",
"python_3.x"
] | stackoverflow_0001305218_eclipse_pydev_python_python_3.x.txt |
Q:
Django: do I need to restart Apache when deploying?
I just noted an annoying factor: Django requires either a restart of the server or CGI access to work. The first option is not feasible if you don't have access to the Apache server process. The second, as far as I know, is detrimental to performance, and in gene... | Django: do I need to restart Apache when deploying? | I just noted an annoying factor: Django requires either a restart of the server or CGI access to work. The first option is not feasible if you don't have access to the Apache server process. The second, as far as I know, is detrimental to performance, and in general the idea of running a CGI makes me uncomfortable.
I a... | [
"Use the WSGI standard, through mod_wsgi. You don't have to restart Apache, merely update the mtime on the .wsgi file. \n",
"I usually don't restart the server, but force-reload the configuration. On an Ubuntu Hardy server, that is\nsudo /etc/init.d/apache2 force-reload\n\nand it's done almost immediately.\n",
... | [
6,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001302411_django_python.txt |
Q:
How to delete entries in a dictionary with a given flag in python?
I have a dictionary, lets call it myDict, in Python that contains a set of similar dictionaries which all have the entry "turned_on : True" or "turned_on : False". I want to remove all the entries in myDict that are off, e.g. where "turned_on : Fal... | How to delete entries in a dictionary with a given flag in python? | I have a dictionary, lets call it myDict, in Python that contains a set of similar dictionaries which all have the entry "turned_on : True" or "turned_on : False". I want to remove all the entries in myDict that are off, e.g. where "turned_on : False". In Ruby I would do something like this:
myDict.delete_if { |id,dict... | [
"You mean like this?\nmyDict = {\"id1\" : {\"turned_on\": True}, \"id2\" : {\"turned_on\": False}}\nresult = dict((a, b) for a, b in myDict.items() if b[\"turned_on\"])\n\noutput:\n{'id1': {'turned_on': True}}\n\n",
"Straight-forward way:\ndef delete_if_not(predicate_key, some_dict):\n for key, subdict in some... | [
7,
5,
3,
1
] | [] | [] | [
"dictionary",
"python",
"ruby"
] | stackoverflow_0001305437_dictionary_python_ruby.txt |
Q:
Python japanese module is not found
I run following python script.
pygame2exe.py
ImportError: No module named japanese
What's wrong?
Do not you know solutions?
A:
The script makes use of japanese encoding
# -*- coding: sjis -*-
[...]
args.append('japanese,encodings');
It's a shame cause it could use UTF-8 t... | Python japanese module is not found | I run following python script.
pygame2exe.py
ImportError: No module named japanese
What's wrong?
Do not you know solutions?
| [
"The script makes use of japanese encoding\n# -*- coding: sjis -*-\n\n[...]\n\nargs.append('japanese,encodings');\n\nIt's a shame cause it could use UTF-8 that works out of the box. \nYou can't run this script unless you install the japanese module. I can't find any reference of it on the web, and I can read in the... | [
1,
0
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0001305042_pygame_python.txt |
Q:
upload file with Python Mechanize
When I run the following script:
from mechanize import Browser
br = Browser()
br.open(url)
br.select_form(name="edit_form")
br['file'] = 'file.txt'
br.submit()
I get: ValueError: value attribute is readonly
And I still get the same error when I add:
br.form.set_all_readonly(False... | upload file with Python Mechanize | When I run the following script:
from mechanize import Browser
br = Browser()
br.open(url)
br.select_form(name="edit_form")
br['file'] = 'file.txt'
br.submit()
I get: ValueError: value attribute is readonly
And I still get the same error when I add:
br.form.set_all_readonly(False)
So, how can I use Python Mechanize t... | [
"This is how to do it properly with Mechanize:\nbr.form.add_file(open(filename), 'text/plain', filename)\n\n",
"twill is built on mechanize and makes scripting web forms a breeze. See python-www-macro.\n>>> from twill import commands\n>>> print commands.formfile.__doc__\n\n>> formfile <form> <field> <filename> [ ... | [
18,
2
] | [] | [] | [
"file",
"forms",
"mechanize",
"python",
"upload"
] | stackoverflow_0001299855_file_forms_mechanize_python_upload.txt |
Q:
Difference between accessing an instance attribute and a class attribute
I have a Python class
class pytest:
i = 34
def func(self):
return "hello world"
When I access pytest.i, I get 34. I can also do this another way:
a = pytest()
a.i
This gives 34 as well.
If I try to access the (non-existing) ... | Difference between accessing an instance attribute and a class attribute | I have a Python class
class pytest:
i = 34
def func(self):
return "hello world"
When I access pytest.i, I get 34. I can also do this another way:
a = pytest()
a.i
This gives 34 as well.
If I try to access the (non-existing) pytest.j, I get
Traceback (most recent call last):
File "<pyshell#6>", line 1,... | [
"No, these are two different things.\nIn Python, everything is an object. Classes are objects, functions are objects and instances are objects. Since everything is an object, everything behaves in a similar way. In your case, you create a class instance (== an object with the type \"Class\") with the name \"pytest\... | [
7,
0
] | [] | [] | [
"class",
"instance",
"python"
] | stackoverflow_0001304868_class_instance_python.txt |
Q:
Dynamic list slicing
Good day code knights,
I have a tricky problem that I cannot see a simple solution for. And the history of the humankind states that there is a simple solution for everything (excluding buying presents)
Here is the problem:
I need an algorithm that takes multidimensional lists and a filter dic... | Dynamic list slicing | Good day code knights,
I have a tricky problem that I cannot see a simple solution for. And the history of the humankind states that there is a simple solution for everything (excluding buying presents)
Here is the problem:
I need an algorithm that takes multidimensional lists and a filter dictionary, processes them an... | [
"I'm not sure I understood your question. But I think the slice object is what you are looking for:\nFirst instead of an empty tuple use None to include all values in time\nfilters= {'x':(0,20), 'y':(3), 'z':(1,2), 'time':None}\n\nThen build a slice dictionary like this:\nd = dict(\n (k, slice(*v) if isinst... | [
3,
2
] | [] | [] | [
"algorithm",
"list",
"multidimensional_array",
"python"
] | stackoverflow_0001307019_algorithm_list_multidimensional_array_python.txt |
Q:
Extracting the To: header from an attachment of an email
I am using python to open an email on the server (POP3). Each email has an attachment which is a forwarded email itself.
I need to get the "To:" address out of the attachment.
I am using python to try and help me learn the language and I'm not that good ye... | Extracting the To: header from an attachment of an email | I am using python to open an email on the server (POP3). Each email has an attachment which is a forwarded email itself.
I need to get the "To:" address out of the attachment.
I am using python to try and help me learn the language and I'm not that good yet !
The code I have already is this
import poplib, email, mim... | [
"Without having an email in my inbox that is representative, it's difficult to work this one through (I've never used poplib). Having said that, some things that might help from my little bit of investigation:\nFirst of all, make lots of use of the command line interface to python and the dir() and help() function... | [
1
] | [] | [] | [
"email",
"mime",
"pop3",
"python"
] | stackoverflow_0001306026_email_mime_pop3_python.txt |
Q:
How do I programmatically pull lists/arrays of (itunes urls to) apps in the iphone app store?
I'd like to know how to pragmatically pull lists of apps from the iphone app store. I'd code this in python (via the google app engine) or in an iphone app. My goal would be to select maybe 5 of them and present them to... | How do I programmatically pull lists/arrays of (itunes urls to) apps in the iphone app store? | I'd like to know how to pragmatically pull lists of apps from the iphone app store. I'd code this in python (via the google app engine) or in an iphone app. My goal would be to select maybe 5 of them and present them to the user. (for instance a top 5 kind of thing, or advanced filtering or queries)
| [
"Unfortunately the only API that seems to be around for Apple's app store is a commercial offering from ABTO; nobody seems to have developed a free one. I'm afraid you'll have to resort to \"screen scraping\" -- urlget things, use beautifulsoup or the like for interpreting the HTML you get, and be ready to fix brea... | [
1
] | [] | [] | [
"app_store",
"arrays",
"google_app_engine",
"iphone",
"python"
] | stackoverflow_0001307322_app_store_arrays_google_app_engine_iphone_python.txt |
Q:
Python question regarding a server listener
I wrote a plug-in for the jetbrains tool teamcity. It is pretty much just a server listener that listens for a build being triggered and outputs some text files with information about different builds like what triggered it, how many changes there where etc etc. After I ... | Python question regarding a server listener | I wrote a plug-in for the jetbrains tool teamcity. It is pretty much just a server listener that listens for a build being triggered and outputs some text files with information about different builds like what triggered it, how many changes there where etc etc. After I finished that I wrote a python script that could ... | [
"Unless you get get notified by having the build server contact you, the only way to do it is to poll. You can either spawn a thread as indicated in other comments, you just have your main script sleep and poll.\nSomething like:\nwait=True\nwhile wait:\n url=urllib.urlopen('http://'+username+':'+password+'@local... | [
2,
0
] | [] | [] | [
"multithreading",
"plugins",
"python",
"sleep",
"teamcity"
] | stackoverflow_0001307371_multithreading_plugins_python_sleep_teamcity.txt |
Q:
Python logging SMTPHandler - handling offline SMTP server
I have setup the logging module for my new python script. I have two handlers, one sending stuff to a file, and one for email alerts. The SMTPHandler is setup to mail anything at the ERROR level or above.
Everything works great, unless the SMTP connection... | Python logging SMTPHandler - handling offline SMTP server | I have setup the logging module for my new python script. I have two handlers, one sending stuff to a file, and one for email alerts. The SMTPHandler is setup to mail anything at the ERROR level or above.
Everything works great, unless the SMTP connection fails. If the SMTP server does not respond or authentication ... | [
"Exceptions which occur during logging should not stop your script, though they may cause a traceback to be printed to sys.stderr. In order to prevent this printout, do the following:\nlogging.raiseExceptions = 0\n\nThis is not the default (because in development you typically want to know about failures) but in pr... | [
5,
0
] | [] | [] | [
"handler",
"logging",
"python"
] | stackoverflow_0001304593_handler_logging_python.txt |
Q:
In Django how to show a list of objects by year
I have theses models:
class Year(models.Model):
name = models.CharField(max_length=15)
date = models.DateField()
class Period(models.Model):
name = models.CharField(max_length=15)
date = models.DateField()
class Notice(models.Model):
year = mode... | In Django how to show a list of objects by year | I have theses models:
class Year(models.Model):
name = models.CharField(max_length=15)
date = models.DateField()
class Period(models.Model):
name = models.CharField(max_length=15)
date = models.DateField()
class Notice(models.Model):
year = models.ForeignKey(Year)
period = models.ForeignKey(Pe... | [
"Luckily Django has some built-in template tags that will help you. Probably the main one you want is regroup:\n{% regroup notices by year as year_list %}\n\n\n{% for year in year_list %}\n <h2>{{ year.grouper }}<h2>\n\n <ul>\n {% for notice in year.list %}\n <li>{{ notice.text }}</li>\n {% endfor %}\n </u... | [
2,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001308169_django_python.txt |
Q:
Calling Python from Objective-C
I'm developing a Python/ObjC application and I need to call some methods in my Python classes from ObjC.
I've tried several stuffs with no success.
How can I call a Python method from Objective-C?
My Python classes are being instantiated in Interface Builder. How can I call a meth... | Calling Python from Objective-C | I'm developing a Python/ObjC application and I need to call some methods in my Python classes from ObjC.
I've tried several stuffs with no success.
How can I call a Python method from Objective-C?
My Python classes are being instantiated in Interface Builder. How can I call a method from that instance?
| [
"Use PyObjC.\nIt is included with Leopard & later.\n>>> from Foundation import *\n>>> a = NSArray.arrayWithObjects_(\"a\", \"b\", \"c\", None)\n>>> a\n(\n a,\n b,\n c\n)\n>>> a[1]\n'b'\n>>> a.objectAtIndex_(1)\n'b'\n>>> type(a)\n<objective-c class NSCFArray at 0x7fff708bc178>\n\nIt even works with iP... | [
17
] | [] | [] | [
"cocoa",
"objective_c",
"python"
] | stackoverflow_0001308079_cocoa_objective_c_python.txt |
Q:
How I can add a Widget or a Region to an Status Icon in PyGTK
This is my first question in StackOverflow, so I would try to explain my self the best I can.
I made an small app trying to emularte the windows Procastination Killer Application, using pygtk and pygame for the sound alerts.
Here is a video of my little... | How I can add a Widget or a Region to an Status Icon in PyGTK | This is my first question in StackOverflow, so I would try to explain my self the best I can.
I made an small app trying to emularte the windows Procastination Killer Application, using pygtk and pygame for the sound alerts.
Here is a video of my little app running http://www.youtube.com/watch?v=FmE-QPA9p-8
My Issue is... | [
"GTK+ doesn't support arbitrary widgets in the notification area, because these don't work well in Windows. You probably want to write a panel applet instead -- here's a tutorial for panel applets in PyGTK.\n"
] | [
2
] | [] | [] | [
"gtk",
"pygtk",
"python",
"tray",
"trayicon"
] | stackoverflow_0001308679_gtk_pygtk_python_tray_trayicon.txt |
Q:
Python egg: where is it installed?
I'm trying to install py-appscript on the mac using 'sudo easy_install appscript'.
The command runs and I get a message saying "Installed /Library/Python/..../appscript=0.20.0-py2.5-maxosx-10.5-i386.egg".
However, when I run a tool that required this (osaglue) I get an error that... | Python egg: where is it installed? | I'm trying to install py-appscript on the mac using 'sudo easy_install appscript'.
The command runs and I get a message saying "Installed /Library/Python/..../appscript=0.20.0-py2.5-maxosx-10.5-i386.egg".
However, when I run a tool that required this (osaglue) I get an error that py-appscript isn't installed. My guess ... | [
"You can found all your avaiable packages in the sys.path. Start the pythonshell and type in this code:\nimport sys\nprint sys.path\n\n",
"What does which python return?\nUpdate: Ok, so go into /usr/bin and do a ls -l | grep python. Does /usr/bin/python link to the OSX installation?\nIf it does not, I had the sam... | [
4,
0,
0
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0001304122_macos_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.