content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
How to get a timestamp older than 1901
I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).
Problem is the platforms store timestamps as 32-bit signed integer... | How to get a timestamp older than 1901 | I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).
Problem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates olde... | [
"In python, there's the datetime module. Specifically, the date class will help.\nfrom datetime import date\nprint date(1850, 1, 1).weekday() # 1, which is Tuesday \n# (Mon is 0)\n\nEdit\nOr, to your specific problem, working with timedelta will help out.\nfrom datetime import datetime\ntd = datetime.now() - date... | [
4,
3,
1,
0,
0
] | [] | [] | [
"c++",
"javascript",
"python",
"timestamp"
] | stackoverflow_0001494231_c++_javascript_python_timestamp.txt |
Q:
Python App Engine uploaded image content-type
I know that I can accept image uploads by having a form that POSTs to App Engine like so:
<form action="/upload_received" enctype="multipart/form-data" method="post">
<div><input type="file" name="img"/></div>
<div><input type="submit" value="Upload Image"></div>
</for... | Python App Engine uploaded image content-type | I know that I can accept image uploads by having a form that POSTs to App Engine like so:
<form action="/upload_received" enctype="multipart/form-data" method="post">
<div><input type="file" name="img"/></div>
<div><input type="submit" value="Upload Image"></div>
</form>
Then in the Python code I can do something like... | [
"Instead of using self.request.get(fieldname), use self.request.POST[fieldname]. This returns a cgi.FieldStorage object (see the Python library docs for details), which has 'filename', 'type' and 'value' attributes.\n",
"Try the python mimetypes module, it will guess the content type and encoding for you,\ne.g.\n... | [
5,
2,
0
] | [] | [] | [
"google_app_engine",
"image",
"multipart",
"python",
"upload"
] | stackoverflow_0001409377_google_app_engine_image_multipart_python_upload.txt |
Q:
How can I translate dates and times from natural language to datetime?
I'm looking for a way to translate 'tomorrow at 6am' or 'next monday at noon' to the appropriate datetime objects.
I thought of engineering a complex set of rules, but is there another way?
A:
parsedatetime - Python module that is able to par... | How can I translate dates and times from natural language to datetime? | I'm looking for a way to translate 'tomorrow at 6am' or 'next monday at noon' to the appropriate datetime objects.
I thought of engineering a complex set of rules, but is there another way?
| [
"parsedatetime - Python module that is able to parse 'human readable' date/time expressions.\n#!/usr/bin/env python\nfrom datetime import datetime\nimport parsedatetime as pdt # $ pip install parsedatetime\n\ncal = pdt.Calendar()\nnow = datetime.now()\nprint(\"now: %s\" % now)\nfor time_string in [\"tomorrow at 6am... | [
51,
12
] | [] | [] | [
"parsing",
"python",
"python_datetime"
] | stackoverflow_0001495487_parsing_python_python_datetime.txt |
Q:
wxpython -- threads and window events
I have a wxPython application (http://www.OpenSTV.org) that counts ballots using methods that have multiple rounds. I'd like to do two things:
(1) For a large number of ballots, this can be a bit slow, so I'd like to show the user a progress dialog so he doesn't think the app... | wxpython -- threads and window events | I have a wxPython application (http://www.OpenSTV.org) that counts ballots using methods that have multiple rounds. I'd like to do two things:
(1) For a large number of ballots, this can be a bit slow, so I'd like to show the user a progress dialog so he doesn't think the application is frozen.
(2) I'd like to allow t... | [
"Use Queue to communicate and synchronize among threads, with each thread \"owning\" and exclusively interacting with a resource that's not handy to share.\nIn GUI toolkits where only the main thread can really handle the GUI, the main thread should play along -- set up and start the threads doing the actual work, ... | [
5,
3
] | [] | [] | [
"events",
"multithreading",
"python",
"window",
"wxpython"
] | stackoverflow_0001496092_events_multithreading_python_window_wxpython.txt |
Q:
How close is Python to being able to wrap it in a workbook type skin?
With my luck this question will be closed too quickly. I see a tremendous possibility for a python application that basically is like a workbook. Imagine if you will that instead of writing code you select from a menu of choices. For example,... | How close is Python to being able to wrap it in a workbook type skin? | With my luck this question will be closed too quickly. I see a tremendous possibility for a python application that basically is like a workbook. Imagine if you will that instead of writing code you select from a menu of choices. For example, the File menu would have an open command that lets the user navigate to a ... | [
"There are Python application that are based on generating code -- the most amazing one probably Resolver One, which focuses on spreadsheets (and hinges on IronPython). With that exception, however, interacting based on the UI paradigm you have in mind (pick one of this, one of that, etc) tends to be pretty limited... | [
3,
1,
0
] | [] | [] | [
"openaccess",
"python",
"wrapper"
] | stackoverflow_0001496039_openaccess_python_wrapper.txt |
Q:
How to treat the first line of a file differently in Python?
I often need to process large text files containing headers in the first line. The headers are often treated differently to the body of the file, or my processing of the body is dependent on the headers. Either way I need to treat the first line as a spe... | How to treat the first line of a file differently in Python? | I often need to process large text files containing headers in the first line. The headers are often treated differently to the body of the file, or my processing of the body is dependent on the headers. Either way I need to treat the first line as a special case.
I could use simple line iteration and set a flag:
heade... | [
"You could:\nprocessHeader(f.readline())\nfor line in f:\n processBody(line)\n\n",
"f = file(\"test\")\nprocessHeader(f.next()) #or next(f) for py3\nfor line in f:\n processBody(line)\n\nThis works.\nEdit:\nChanged .__next__ to next (they are equivalent, but I suppose next is more concise).\nRegaring file v... | [
17,
8,
3,
2
] | [] | [] | [
"file",
"iteration",
"python"
] | stackoverflow_0001496456_file_iteration_python.txt |
Q:
Aggregating multiple feeds with Universal Feed Parser
Having great luck working with single-source feed parsing in Universal Feed Parser, but now I need to run multiple feeds through it and generate chronologically interleaved output (not RSS). Seems like I'll need to iterate through URLs and stuff every entry int... | Aggregating multiple feeds with Universal Feed Parser | Having great luck working with single-source feed parsing in Universal Feed Parser, but now I need to run multiple feeds through it and generate chronologically interleaved output (not RSS). Seems like I'll need to iterate through URLs and stuff every entry into a list of dictionaries, then sort that by the entry times... | [
"You could throw the feeds into a database and then generate a new feed from this database.\nConsider looking into two feedparser-based RSS aggregators: Planet Feed Aggregator and FeedJack (Django based), or at least how they solve this problem.\n",
"Here is already suggestion to store data in the database, e.g. ... | [
2,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001496067_django_python.txt |
Q:
Problem loading transparent background sprites in pygame
I'm trying to load a transparent image into pygame using the following code:
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print '... | Problem loading transparent background sprites in pygame | I'm trying to load a transparent image into pygame using the following code:
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', fullname
raise SystemExit, messag... | [
"You call image.convert(). From the docs for Surface.convert:\n\n\"The converted Surface will have no\n pixel alphas. They will be stripped if\n the original had them. See\n Surface.convert_alpha - change the\n pixel format of an image including per\n pixel alphas for preserving or\n creating per-pixel alphas... | [
3
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0001496106_pygame_python.txt |
Q:
Guidance on optimising Python runtime for embedded systems with low system resources
My team is incorporating the Python 2.4.4 runtime into our project in order to leverage some externally developed functionality.
Our platform has a 450Mhz SH4 application core and limited memory for use by the Python runtime and ... | Guidance on optimising Python runtime for embedded systems with low system resources | My team is incorporating the Python 2.4.4 runtime into our project in order to leverage some externally developed functionality.
Our platform has a 450Mhz SH4 application core and limited memory for use by the Python runtime and application.
We have ported Python, but initial testing has highlighted the following hur... | [
"Perhaps it is hard to believe, but CPython version 2.4 never releases memory to the OS. This is allegedly fixed in verion Python 2.5.\nIn addition, performance (processor-wise) was improved in Python 2.5 and Python 2.6 on top of that.\nSee the C API section in What's new in Python 2.5, look for the item called Eva... | [
5
] | [] | [] | [
"embedded",
"garbage_collection",
"memory",
"performance",
"python"
] | stackoverflow_0001496761_embedded_garbage_collection_memory_performance_python.txt |
Q:
Python 2.5 and 2.6 and Numpy compatibility problem
In the computers of our laboratory, which have Python 2.6.2 installed in them, my program, which is an animation of the 2D random walk and diffusion, works perfectly.
However, I can't get the exact same program to work on my laptop, which has Python 2.5. By that ... | Python 2.5 and 2.6 and Numpy compatibility problem | In the computers of our laboratory, which have Python 2.6.2 installed in them, my program, which is an animation of the 2D random walk and diffusion, works perfectly.
However, I can't get the exact same program to work on my laptop, which has Python 2.5. By that not working, I mean the animation is screwed; the axis a... | [
"The various (matplotlib.pyplot) graphical backends do not behave in exactly the same way.\nYou could try setting the backend so that it is the same on both machines:\nmatplotlib.use('GTKagg') # Right after importing matplotlib\n\nFor a list of possible backends, you can do matplotlib.use('...').\n",
"Numpy for ... | [
2,
1
] | [] | [] | [
"compatibility",
"numpy",
"python"
] | stackoverflow_0001496942_compatibility_numpy_python.txt |
Q:
question related to reverse function and kwargs
To reverse lookup an url by means of name or View_name we will use reverse function in the views like below
reverse("calendarviewurl2", kwargs={"year":theyear,"month":themonth})
and reverse function signature is as follows
http://code.djangoproject.com/browser/djan... | question related to reverse function and kwargs | To reverse lookup an url by means of name or View_name we will use reverse function in the views like below
reverse("calendarviewurl2", kwargs={"year":theyear,"month":themonth})
and reverse function signature is as follows
http://code.djangoproject.com/browser/django/trunk/django/core/urlresolvers.py
def reverse(self... | [
"Didn't you look at the signature,\ndef reverse(viewname, urlconf=None, args=None, kwargs=None, \n prefix=None, current_app=None):\n\ntakes no **kwargs at all.\nkwargs={\"year\":2009,\"month\":9}\nreverse(\"name\",**kwargs)\n\nmeans \nreverse(\"name\", year=2009, month=9)\n\nwhich is completely... | [
10
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001497258_django_python.txt |
Q:
Comparing performance between ruby and python code
I have a memory and CPU intensive problem to solve and I need to benchmark the different solutions in ruby and python on different platforms.
To do the benchmark, I need to measure the time taken and the memory occupied by objects (not the entire program, but a se... | Comparing performance between ruby and python code | I have a memory and CPU intensive problem to solve and I need to benchmark the different solutions in ruby and python on different platforms.
To do the benchmark, I need to measure the time taken and the memory occupied by objects (not the entire program, but a selected list of objects) in both python and ruby.
Please ... | [
"For Python I recommend heapy\nfrom guppy import hpy\nh = hpy()\nprint h.heap()\n\nor Dowser or PySizer\nFor Ruby you can use the BleakHouse Plugin or just read this answer on memory leak debugging (ruby).\n",
"If you really need to write fast code in a language like this (and not a language far more suited to CP... | [
3,
3,
2,
1,
0
] | [] | [] | [
"memory_management",
"performance",
"python",
"ruby"
] | stackoverflow_0001490841_memory_management_performance_python_ruby.txt |
Q:
Can Python determine the class of an object accessing a method
Is there anyway to do something like this:
class A:
def foo(self):
if isinstance(caller, B):
print "B can't call methods in A"
else:
print "Foobar"
class B:
def foo(self, ref): ref.foo()
class C:
def f... | Can Python determine the class of an object accessing a method | Is there anyway to do something like this:
class A:
def foo(self):
if isinstance(caller, B):
print "B can't call methods in A"
else:
print "Foobar"
class B:
def foo(self, ref): ref.foo()
class C:
def foo(self, ref): ref.foo()
a = A();
B().foo(a) # Outputs "B can't... | [
"Assuming the caller is a method, then yes you can, by looking in the previous frame, and picking out self from the locals.\nclass Reciever:\n def themethod(self):\n frame = sys._getframe(1)\n arguments = frame.f_code.co_argcount\n if arguments == 0:\n print \"Not called from a me... | [
6,
4
] | [
"Something like this may meet your needs better:\nclass A(object):\n def foo(self):\n # do stuff\n\nclass B(A):\n def foo(self):\n raise NotImplementedError\n\nclass C(A):\n pass\n\n...but it's difficult to say without knowing exactly what you're trying to do.\n"
] | [
-1
] | [
"introspection",
"python"
] | stackoverflow_0001497683_introspection_python.txt |
Q:
Is it OK if objects from different classes interact with each other?
I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second c... | Is it OK if objects from different classes interact with each other? | I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the fir... | [
"If you're talking about passing an instance of one object to the method of a another one, then yes of course it's allowed! And it's considered fine practice.\nIf you want to know more about good object oriented coding, may I offer some suggested readings:\nDesign Patterns: Elements of Reusable Object-Oriented Sof... | [
8,
1,
1,
0,
0
] | [] | [] | [
"oop",
"python"
] | stackoverflow_0001498009_oop_python.txt |
Q:
Python - importing package classes into console global namespace
I'm having a spot of trouble getting my python classes to work within the python console. I want to automatically import all of my classes into the global namespace so I can use them without any prefix.module.names.
Here's what I've got so far...
pro... | Python - importing package classes into console global namespace | I'm having a spot of trouble getting my python classes to work within the python console. I want to automatically import all of my classes into the global namespace so I can use them without any prefix.module.names.
Here's what I've got so far...
projectname/
|-__init__.py
|
|-main_stuff/
|-__init__.py
|-main1.py
... | [
"You want to use a different form of import.\nIn projectname/main_stuff/__init__.py:\nfrom other_stuff import *\n__all__ = [\"main1\", \"main2\", \"main3\"]\n\nWhen you use a statement like this:\nimport foo\n\nYou are defining the name foo in the current module. Then you can use foo.something to get at the stuff ... | [
21
] | [] | [] | [
"console",
"global",
"import",
"namespaces",
"python"
] | stackoverflow_0001499119_console_global_import_namespaces_python.txt |
Q:
Django: form values not updating when model updates
I am creating a form that uses MultipleChoiceField. The values for this field are derived from another model. This method works fine, however, I am noticing (on the production server) that when I add a new item to the model in question (NoticeType), the form do... | Django: form values not updating when model updates | I am creating a form that uses MultipleChoiceField. The values for this field are derived from another model. This method works fine, however, I am noticing (on the production server) that when I add a new item to the model in question (NoticeType), the form does not dynamically update. I have to restart the server ... | [
"Although mherren is right that you can fix this problem by defining your choices in the __init__ method, there is an easier way: use the ModelMultipleChoiceField which is specifically designed to take a queryset, and updates dynamically.\nclass EditUserProfileForm(forms.Form):\n notifications = forms. ModelMult... | [
9,
7
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0001498763_django_django_forms_python.txt |
Q:
Running python script as another user
On a Linux box I want to run a Python script as another user.
I've already made a wrapper program in C++ that calls the script, since I've realized that the ownership of running the script is decided by the ownership of the python interpreter. After that I change the C++ progr... | Running python script as another user | On a Linux box I want to run a Python script as another user.
I've already made a wrapper program in C++ that calls the script, since I've realized that the ownership of running the script is decided by the ownership of the python interpreter. After that I change the C++ program to a different user and run the C++ prog... | [
"You can set the user with os.setuid(), and you can get the uid with pwd.\nLike so:\n>>> import pwd, os\n>>> uid = pwd.getpwnam('root')[2]\n>>> os.setuid(uid)\n\nObviously this only works if the user or executable has the permission to do so. Exactly how to set that up I don't know. Obviously it works if you are ro... | [
15,
0
] | [
"Use the command sudo.\nIn order to run a program as a user, the system must \"authenticate\" that user.\nObviously, root can run any program as any user, and any user can su to another user with a password.\nThe program sudo can be configured to allow a group of users to sudo a particular command as a particular u... | [
-1
] | [
"linux",
"python"
] | stackoverflow_0001499268_linux_python.txt |
Q:
How do I use the wx.lib.docview package?
I'm currently working on a simple wxPython app that's essentially document based. So far I've been manually implementing the usual open/save/undo/redo etc etc stuff.
It occurred to me that wxPython must have something to help me out and after a bit of searching revealed th... | How do I use the wx.lib.docview package? | I'm currently working on a simple wxPython app that's essentially document based. So far I've been manually implementing the usual open/save/undo/redo etc etc stuff.
It occurred to me that wxPython must have something to help me out and after a bit of searching revealed the docview package.
At this point though I'm ju... | [
"You might take a look at the docviewdemo.py from the wxPython Docs and Demos:\non my machine they are located:\n\nC:\\Program Files\\wxPython2.8 Docs and Demos\\samples\\pydocview\\\nC:\\Program Files\\wxPython2.8 Docs and Demos\\samples\\docview\\\n\n",
"In addition to the ones mentioned, there is quite an ext... | [
1,
1
] | [] | [] | [
"docview",
"python",
"user_interface",
"wxpython"
] | stackoverflow_0000751159_docview_python_user_interface_wxpython.txt |
Q:
http checks python
learning python here, I want to check if anybody is running a web server on my local
network, using this code, but it gives me a lot of error in the concole.
#!/usr/bin/env python
import httplib
last = 1
while last <> 255:
url = "10.1.1." + "last"
connection = httplib.HTTPConnec... | http checks python | learning python here, I want to check if anybody is running a web server on my local
network, using this code, but it gives me a lot of error in the concole.
#!/usr/bin/env python
import httplib
last = 1
while last <> 255:
url = "10.1.1." + "last"
connection = httplib.HTTPConnection("url", 80)
... | [
"I do suggest changing the while loop to the more idiomatic for loop, and handling exceptions:\n#!/usr/bin/env python\n\nimport httplib\nimport socket\n\n\nfor i in range(1, 256):\n try:\n url = \"10.1.1.%d\" % i\n connection = httplib.HTTPConnection(url, 80)\n connection.request(\"GET\",\"/... | [
5,
2,
1,
1
] | [] | [] | [
"http",
"python"
] | stackoverflow_0001495367_http_python.txt |
Q:
Python/WebApp Google App Engine - testing for user/pass in the headers
When you call a web service like this:
username = 'test12'
password = 'test34'
client = httplib2.Http(".cache")
client.add_credentials(username,password)
URL = "http://localhost:8080/wyWebServiceTest"
response, content = cli... | Python/WebApp Google App Engine - testing for user/pass in the headers | When you call a web service like this:
username = 'test12'
password = 'test34'
client = httplib2.Http(".cache")
client.add_credentials(username,password)
URL = "http://localhost:8080/wyWebServiceTest"
response, content = client.request(URL)
How do you get the username/password into variables on th... | [
"I haven't tested this code (insert smiley) but I think this is the sort of thing you need. Basically your credentials won't be in the header if your server hasn't bounced a 401 back to your client (the client needs to know the realm to know what credentials to provide).\nclass MYREALM_securepage(webapp.RequestHan... | [
7,
3,
1
] | [] | [] | [
"google_app_engine",
"python",
"web_applications"
] | stackoverflow_0001499832_google_app_engine_python_web_applications.txt |
Q:
There’s PyQuery… is there one for Ruby?
You guys know PyQuery?
I was wondering if there’s an equivalent for Ruby.
A:
There's JRails, but it's outdated. If you're just looking for a way to use JQuery with Rails though: http://railscasts.com/episodes/136-jquery
A:
Hpricot - Most jQuery-like HTML parser for Ruby
... | There’s PyQuery… is there one for Ruby? | You guys know PyQuery?
I was wondering if there’s an equivalent for Ruby.
| [
"There's JRails, but it's outdated. If you're just looking for a way to use JQuery with Rails though: http://railscasts.com/episodes/136-jquery\n",
"Hpricot - Most jQuery-like HTML parser for Ruby\n"
] | [
1,
1
] | [] | [] | [
"python",
"ruby"
] | stackoverflow_0001484963_python_ruby.txt |
Q:
Programmatically determine maximum command line length with Python
Does anyone know a portable way for Python to determine a system's maximum command line length? The program I'm working on builds a command and feeds it to subprocess. For systems with smaller command line length maximums, it is possible that the... | Programmatically determine maximum command line length with Python | Does anyone know a portable way for Python to determine a system's maximum command line length? The program I'm working on builds a command and feeds it to subprocess. For systems with smaller command line length maximums, it is possible that the command will be too long. If I can detect that, the command can be bro... | [
"Just ask sysconf:\nos.sysconf('SC_ARG_MAX')\n\n"
] | [
6
] | [] | [] | [
"command_line",
"python",
"subprocess"
] | stackoverflow_0001500542_command_line_python_subprocess.txt |
Q:
Django: How can you stop long queries from killing your database?
I'm using Django 1.1 with Mysql 5.* and MyISAM tables.
Some of my queries can take a TON of time for outliers in my data set. These lock the tables and shut the site down. Other times it seems some users cancel the request before it is done and some... | Django: How can you stop long queries from killing your database? | I'm using Django 1.1 with Mysql 5.* and MyISAM tables.
Some of my queries can take a TON of time for outliers in my data set. These lock the tables and shut the site down. Other times it seems some users cancel the request before it is done and some queries will be stuck in the "Preparing" phase locking all other queri... | [
"Unfortunately MySQL doesn't allow you an easy way to avoid this. A common method is basically to write a script that checks all running processes every X seconds (based on what you think is \"long\") and kill ones it sees are running too long. You can at least get some basic diagnostics, however, by setting log_... | [
1,
1,
0,
0,
0,
0
] | [] | [] | [
"django",
"mysql",
"python",
"timeout"
] | stackoverflow_0001353206_django_mysql_python_timeout.txt |
Q:
Named and default arguments class arguments in Python
In PHP, I have to pass the arguments in the same order as the arguments are in the constructor.
Now, in Python, take
listbox = Listbox(root, yscrollcommand=scrollbar.set)
for example.
If I had passed yscrollcommand=scrollbar.set as the third argument and yscro... | Named and default arguments class arguments in Python | In PHP, I have to pass the arguments in the same order as the arguments are in the constructor.
Now, in Python, take
listbox = Listbox(root, yscrollcommand=scrollbar.set)
for example.
If I had passed yscrollcommand=scrollbar.set as the third argument and yscrollcommand was the second argument in the constructor, would... | [
"Named arguments don't have to be in order.\nclass xyz:\n def __init__ (self, a='1', b='2'):\n print a,b\n\nxyz(b=3,a=4)\nxyz(a=5,b=6)\n\n>>4 3\n>>5 6\n\n"
] | [
4
] | [] | [] | [
"arguments",
"default",
"named",
"python"
] | stackoverflow_0001501208_arguments_default_named_python.txt |
Q:
Parsing commandline output progression containing carriage returns in real time with python
I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)
This code returns output a... | Parsing commandline output progression containing carriage returns in real time with python | I am able to transform carriage returns into new lines. The problem however is to get it running in nearly 'real time'. It will be quite stupid looking if progres bar only values are 0 and 100 :-)
This code returns output at once:
import subprocess
p = subprocess.Popen(['mplayer', '/home/user/sample.mkv'], stdout=subp... | [
"pexpect anywhere but Windows, and wexpect on Windows, are always my recommendations when you need to \"defeat buffering\" and read a subprocess's output \"in near real-time\", as you put it. Since the subprocess you're running most likely buffers its output differently when it's outputting to a terminal vs. anythi... | [
2,
1,
0
] | [
"You need to do two things:\n\nYou must make sure that mplayer flushes the output for every line (should happen with progress output that gets printed into the same line).\nYou must read the output line by line. Instead of calling communicate(), you must close the p.stdin and then read p.stdout until EOF.\n\n"
] | [
-1
] | [
"carriage_return",
"parsing",
"python",
"real_time"
] | stackoverflow_0001486305_carriage_return_parsing_python_real_time.txt |
Q:
Python XML Serializers
Can some recommend an XML serializer that is element or attribute centric, and that doesn't use key-value pairs.
For example, GAE db.model has a to_xml() function but it writes out like this:
<property name="firstname" type="string">John</property>
<property name="lastname" type="strin... | Python XML Serializers | Can some recommend an XML serializer that is element or attribute centric, and that doesn't use key-value pairs.
For example, GAE db.model has a to_xml() function but it writes out like this:
<property name="firstname" type="string">John</property>
<property name="lastname" type="string">Doe</property>
<propert... | [
"pyxslt.serialize looks closest to your specs but not a 100% map (for example, it doesn't record the type -- just turns everything into strings). Could still be a good basis from where to customize (maybe by copy / paste / edit, if it doesn't offer all the hooks you need for a cleaner customization).\n"
] | [
2
] | [] | [] | [
"python",
"xml_serialization"
] | stackoverflow_0001500575_python_xml_serialization.txt |
Q:
Parsing out data using BeautifulSoup in Python
I am attempting to use BeautifulSoup to parse through a DOM tree and extract the names of authors. Below is a snippet of HTML to show the structure of the code I'm going to scrape.
<html>
<body>
<div class="list-authors">
<span class="descriptor">Authors:</span>
<a ... | Parsing out data using BeautifulSoup in Python | I am attempting to use BeautifulSoup to parse through a DOM tree and extract the names of authors. Below is a snippet of HTML to show the structure of the code I'm going to scrape.
<html>
<body>
<div class="list-authors">
<span class="descriptor">Authors:</span>
<a href="/find/astro-ph/1/au:+Lin_D/0/1/0/all/0/1">Dach... | [
"just use findAll for the divs link you do for the links\nfor authordiv in soup.findAll('div', attrs={'class': 'list-authors'}):\n",
"Since link is already taken from an iterable, you don't need to subindex link -- you can just do link.contents[0].\nprint link.contents[0] with your new example with two separate <... | [
13,
1
] | [] | [] | [
"beautifulsoup",
"html",
"parsing",
"python"
] | stackoverflow_0001501690_beautifulsoup_html_parsing_python.txt |
Q:
How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python?
How to display a SOAP message generated by ZSI.ServiceProxy and a respond from a Web Service when a Web Service method is invoked?
A:
Here is some documentation on the ServiceProxy class. The constructor accepts a tracefile argume... | How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python? | How to display a SOAP message generated by ZSI.ServiceProxy and a respond from a Web Service when a Web Service method is invoked?
| [
"Here is some documentation on the ServiceProxy class. The constructor accepts a tracefile argument which can be any object with a write method, so this looks like what you are after. Modifying the example from the documentation:\nfrom ZSI import ServiceProxy\nimport BabelTypes\nimport sys\n\ndbgfile = open('dbgfil... | [
3
] | [] | [] | [
"python",
"web_services",
"zsi"
] | stackoverflow_0001497038_python_web_services_zsi.txt |
Q:
Python regex question
I am wondering what would be a pythonic solution for this question.
In "aa67bc54c9", is there any way to print "aa" 67 times, "bc" 54 times and so on, using regular expressions?
A:
This would be a concise way:
import re
s = "aa67bc54c9"
print ''.join(t * int(n) for t, n in re.findall(r"([a... | Python regex question | I am wondering what would be a pythonic solution for this question.
In "aa67bc54c9", is there any way to print "aa" 67 times, "bc" 54 times and so on, using regular expressions?
| [
"This would be a concise way:\nimport re\n\ns = \"aa67bc54c9\"\nprint ''.join(t * int(n) for t, n in re.findall(r\"([a-z]+)([0-9]+)\", s))\n\nThis solution uses a regular expression to match \"one or more letters followed by one or more numbers\", searching for all of them in the input string. Then it uses a list c... | [
3,
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0001501772_python_regex.txt |
Q:
cProfile and Python: Finding the specific line number that code spends most time on
I'm using cProfile, pstats and Gprof2dot to profile a rather long python script.
The results tell me that the most time is spent calling a method in an object I've defined. However, what I would really like is to know exactly what ... | cProfile and Python: Finding the specific line number that code spends most time on | I'm using cProfile, pstats and Gprof2dot to profile a rather long python script.
The results tell me that the most time is spent calling a method in an object I've defined. However, what I would really like is to know exactly what line number within that function is eating up the time.
Any idea's how to get this addit... | [
"There is a line profiler in python written by Robert Kern.\n",
"Suppose the amount of time being \"eaten up\" is some number, like 40%. Then if you just interrupt the program or pause it at a random time, the probability is 40% that you will see it, precisely exposed on the call stack. Do this 10 times, and on 4... | [
3,
2,
2
] | [] | [] | [
"line",
"numbers",
"profiler",
"python",
"scripting"
] | stackoverflow_0001500564_line_numbers_profiler_python_scripting.txt |
Q:
Python Decorator for GAE Web-Service Security Check
In this post, Nick suggested a decoartor:
Python/WebApp Google App Engine - testing for user/pass in the headers
I'm writing an API to expose potentially dozens of methods as web-services, so the decorator sounds like a great idea.
I tried to start coding one b... | Python Decorator for GAE Web-Service Security Check | In this post, Nick suggested a decoartor:
Python/WebApp Google App Engine - testing for user/pass in the headers
I'm writing an API to expose potentially dozens of methods as web-services, so the decorator sounds like a great idea.
I tried to start coding one based on this sample:
http://groups.google.com/group/goog... | [
"Class decorators were added in Python 2.6.\nYou'll have to manually wrap the class or think of another solution to work under 2.5. How about writing a decorator for the get method instead?\n",
"You need to write a method decorator, not a class decorator: As lost-theory points out, class decorators don't exist in... | [
2,
2
] | [] | [] | [
"decorator",
"google_app_engine",
"python",
"web_services"
] | stackoverflow_0001500982_decorator_google_app_engine_python_web_services.txt |
Q:
Using CherryPy as a blocking/non-threading server for easier debugging
Is it possible to use the CherrPy server as a blocking/non-threading server (for easier debugging?)
A:
No. Not only does the wsgiserver start its own set of worker threads (10 by default, but even if you only specified 1 that's still 1 thread... | Using CherryPy as a blocking/non-threading server for easier debugging | Is it possible to use the CherrPy server as a blocking/non-threading server (for easier debugging?)
| [
"No. Not only does the wsgiserver start its own set of worker threads (10 by default, but even if you only specified 1 that's still 1 thread for the listening socket and 1 worker thread). Even if that were not true, if you use the rest of CherryPy (i.e. the engine), it runs that 1 listener thread in a separate thre... | [
3
] | [] | [] | [
"cherrypy",
"debugging",
"python"
] | stackoverflow_0001502431_cherrypy_debugging_python.txt |
Q:
Paster cannot stop daemon
I'm using the following command in my pylons app in an attempt to stop the daemon on the server:
paster serve --daemon dev.ini stop
This is the error I get:
No PID file exists in paster.pid
Could not stop daemon; aborting
Wondering how I can stop this daemon so I can reload dev.ini.
Tha... | Paster cannot stop daemon | I'm using the following command in my pylons app in an attempt to stop the daemon on the server:
paster serve --daemon dev.ini stop
This is the error I get:
No PID file exists in paster.pid
Could not stop daemon; aborting
Wondering how I can stop this daemon so I can reload dev.ini.
Thanks!
| [
"kill the process.\n"
] | [
0
] | [] | [] | [
"command_line",
"paster",
"pylons",
"python",
"ssh"
] | stackoverflow_0001502568_command_line_paster_pylons_python_ssh.txt |
Q:
What language could I use for fast execution of this database summarization task?
So I wrote a Python program to handle a little data processing
task.
Here's a very brief specification in a made-up language of the computation I want:
parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatt... | What language could I use for fast execution of this database summarization task? | So I wrote a Python program to handle a little data processing
task.
Here's a very brief specification in a made-up language of the computation I want:
parse "%s %lf %s" aa bb cc | group_by aa | quickselect --key=bb 0:5 | \
flatten | format "%s %lf %s" aa bb cc
That is, for each line, parse out a word, a floating-... | [
"I have a hard time believing that any script without any prior knowledge of the data (unlike MySql which has such info pre-loaded), would be faster than a SQL approach.\nAside from the time spent parsing the input, the script needs to \"keep\" sorting the order by array etc...\nThe following is a first guess at wh... | [
9,
6,
3,
3,
3,
2,
2,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0
] | [] | [] | [
"apache_pig",
"lisp",
"ocaml",
"python",
"sql"
] | stackoverflow_0001467898_apache_pig_lisp_ocaml_python_sql.txt |
Q:
basic unique ModelForm field for Google App Engine
I do not care about concurrency issues.
It is relatively easy to build unique form field:
from django import forms
class UniqueUserEmailField(forms.CharField):
def clean(self, value):
self.check_uniqueness(super(UniqueUserEmailField, self).clean(value))... | basic unique ModelForm field for Google App Engine | I do not care about concurrency issues.
It is relatively easy to build unique form field:
from django import forms
class UniqueUserEmailField(forms.CharField):
def clean(self, value):
self.check_uniqueness(super(UniqueUserEmailField, self).clean(value))
def check_uniqueness(self, value):
same_us... | [
"quick and dirty way would be:\n\nmake check_uniqueness classmethod\nuse custom field check in ModelForm, like this:\nclass User(forms.ModelForm): \n email = forms.EmailField() \ndef clean_email(self):\n data = self.cleaned_data['email']\n original = self.instance.email\n if original == data:\n ... | [
1
] | [] | [] | [
"app_engine_patch",
"django",
"google_app_engine",
"python"
] | stackoverflow_0001502818_app_engine_patch_django_google_app_engine_python.txt |
Q:
Problem loading a specific website through Qt Webkit
I am currently using the following PyQt code to create a simple browser:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.robeez.com"))
web.show(... | Problem loading a specific website through Qt Webkit | I am currently using the following PyQt code to create a simple browser:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.robeez.com"))
web.show()
sys.exit(app.exec_())
Websites like google.com or stack... | [
"try arora (a very simple wrapping on top of QtWebKit); if it works, its your code. if it doesn't, its the website.\n",
"For some reason http://www.robeeez.com which I think redirects to rebeez.com DOES work.\nIn some cases rebeez.com sends out a blank index.html page, dillo and wget also receive \nnothing as doe... | [
0,
0,
0
] | [] | [] | [
"pyqt",
"python",
"qtwebkit",
"webkit"
] | stackoverflow_0001111267_pyqt_python_qtwebkit_webkit.txt |
Q:
What's the most pythonic way to ensure that all elements of a list are different?
I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.
This is the way I do it now:
If there are two elements:
try:
assert(x[0... | What's the most pythonic way to ensure that all elements of a list are different? | I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion.
This is the way I do it now:
If there are two elements:
try:
assert(x[0] != x[1])
except:
print debug_info
raise Exception("throw to caller")
If ther... | [
"Maybe something like this:\nif len(x) == len(set(x)):\n print \"all elements are unique\"\nelse:\n print \"elements are not unique\"\n\n",
"The most popular answers are O(N) (good!-) but, as @Paul and @Mark point out, they require the list's items to be hashable. Both @Paul and @Mark's proposed approaches ... | [
26,
18,
7,
2,
1,
0,
0
] | [] | [] | [
"list",
"python",
"unique"
] | stackoverflow_0001501118_list_python_unique.txt |
Q:
Sanitising user input using Python
What is the best way to sanitize user input for a Python-based web application? Is there a single function to remove HTML characters and any other necessary characters combinations to prevent an XSS or SQL injection attack?
A:
Here is a snippet that will remove all tags not on ... | Sanitising user input using Python | What is the best way to sanitize user input for a Python-based web application? Is there a single function to remove HTML characters and any other necessary characters combinations to prevent an XSS or SQL injection attack?
| [
"Here is a snippet that will remove all tags not on the white list, and all tag attributes not on the attribues whitelist (so you can't use onclick).\nIt is a modified version of http://www.djangosnippets.org/snippets/205/, with the regex on the attribute values to prevent people from using href=\"javascript:...\",... | [
29,
23,
13,
6,
4,
0,
0
] | [] | [] | [
"python",
"xss"
] | stackoverflow_0000016861_python_xss.txt |
Q:
Dynamic column formatting in SQL - and a backend to store the formatting
I'm trying to create a system in Python in which one can select a number of rows from a set of tables, which are to be formatted in a user-defined way. Let's say the table a has a set of columns, some of which include a date or timestamp valu... | Dynamic column formatting in SQL - and a backend to store the formatting | I'm trying to create a system in Python in which one can select a number of rows from a set of tables, which are to be formatted in a user-defined way. Let's say the table a has a set of columns, some of which include a date or timestamp value. The user-defined format for each column should be stored in another table, ... | [
"It seems to me a stored procedure or a sub-select would work well here, though I haven't tested it. Let's say you store a date_format for each user in the users table.\nSELECT to_char((SELECT date_format FROM users WHERE users.id=123), column) FROM table;\n\nYour mileage may vary.\n",
"Pull the dates out as Unix... | [
0,
0
] | [] | [] | [
"database",
"database_design",
"postgresql",
"python",
"sql"
] | stackoverflow_0001503621_database_database_design_postgresql_python_sql.txt |
Q:
Fixture loading works with loaddata but fails silently in unit test in Django
I can load the fixture file in my django application by using loaddata:
manage.py loaddata palamut
The fixture palamut.yaml is in the directory palamut/fixtures/
I have a unit test module service_tests.py in palamut/tests/. Its content... | Fixture loading works with loaddata but fails silently in unit test in Django | I can load the fixture file in my django application by using loaddata:
manage.py loaddata palamut
The fixture palamut.yaml is in the directory palamut/fixtures/
I have a unit test module service_tests.py in palamut/tests/. Its content is here:
import unittest
from palamut.models import *
from palamut.service import ... | [
"Your TestCase should be an instance of django.test.TestCase, not unittest.TestCase\n"
] | [
9
] | [] | [] | [
"django",
"fixtures",
"python",
"unit_testing"
] | stackoverflow_0001504255_django_fixtures_python_unit_testing.txt |
Q:
Fitting a bimodal distribution to a set of values
Given a 1D array of values, what is the simplest way to figure out what the best fit bimodal distribution to it is, where each 'mode' is a normal distribution? Or in other words, how can you find the combination of two normal distributions that bests reproduces the... | Fitting a bimodal distribution to a set of values | Given a 1D array of values, what is the simplest way to figure out what the best fit bimodal distribution to it is, where each 'mode' is a normal distribution? Or in other words, how can you find the combination of two normal distributions that bests reproduces the 1D array of values?
Specifically, I'm interested in im... | [
"What you are trying to do is called a Gaussian Mixture model. The standard approach to solving this is using Expectation Maximization, scipy svn includes a section on machine learning and em called scikits. I use it a a fair bit.\n",
"I suggest using the awesome scipy package.\nIt provides a few methods for opti... | [
4,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0001504378_algorithm_python.txt |
Q:
Python as a Windows Watchdog
Hi I'm considering using Python to make a watchdog app on Windows XP that will perform the following actions:
Restart Windows at a given time.
Start an exe application.
Run a timer to check: is an application still running
I know of the existence of PyWin32, but I hear that the API i... | Python as a Windows Watchdog | Hi I'm considering using Python to make a watchdog app on Windows XP that will perform the following actions:
Restart Windows at a given time.
Start an exe application.
Run a timer to check: is an application still running
I know of the existence of PyWin32, but I hear that the API is not complete. So my question is ... | [
"Since you only want this to work on Windows, the easiest way to do that is to use os.system and make system-specific calls from within a Python program. \nUse the built in Windows tool to run programs at a particular time.\nUse shutdown -r to reboot Windows. \nUse tasklist to list all processes, then search that l... | [
3
] | [] | [] | [
"python",
"winapi"
] | stackoverflow_0001504794_python_winapi.txt |
Q:
Communicate with backend job from web server or web page
I have an "appliance" (for lack of better description) running linux.
Currently I ssh into the box to launch jobs. This isn't friendly enough for my users, so I'm putting together a simple web UI to launch the script. A job runs for anywhere from 10 seconds ... | Communicate with backend job from web server or web page | I have an "appliance" (for lack of better description) running linux.
Currently I ssh into the box to launch jobs. This isn't friendly enough for my users, so I'm putting together a simple web UI to launch the script. A job runs for anywhere from 10 seconds to several hours. The web UI needs to reflect the status of th... | [
"I do this in a number of projects. A web-app (mostly Python/CGI) that spawns a separate python script (using subprocess) which instantly daemonizes itself to do the work. The web-app then continues to issue AJAX requests to check on the daemon process progress (I use simple txt files for communication, database w... | [
2,
0
] | [] | [] | [
"backend",
"linux",
"python"
] | stackoverflow_0001504729_backend_linux_python.txt |
Q:
How to markup form fields with in Django
I wasn't able to find a way to identify the type of a field in a django template. My solution was to create a simple filter to access the field and widget class names. I've included the code below in case it's helpful for someone else.
Is there a better approach?
## agen... | How to markup form fields with in Django | I wasn't able to find a way to identify the type of a field in a django template. My solution was to create a simple filter to access the field and widget class names. I've included the code below in case it's helpful for someone else.
Is there a better approach?
## agency/tagutils/templatetags/fieldtags.py
#########... | [
"class MyForm(forms.Form):\n myfield = forms.CharField(widget=forms.TextInput(attrs={'class' : 'myfieldclass'}))\n\nor, with a ModelForm\nclass MyForm(forms.ModelForm):\n class Meta:\n model = MyModel\n widgets = {\n 'myfield': forms.TextInput(attrs={'class': 'myfieldclass'}),\n ... | [
31
] | [] | [] | [
"django",
"django_forms",
"django_models",
"django_templates",
"python"
] | stackoverflow_0001453488_django_django_forms_django_models_django_templates_python.txt |
Q:
PHP Import Foreign Class' Method into MyClass
Wondering if this is possible in PHP Land:
Let's say I have a class as follows:
class myClass{
var $myVar;
...
myMethod(){
$this->myVar = 10;
}
}
and another class:
class anotherClass {
...
addFive(){
$this->myVar += 5;
}
}
The 'anothe... | PHP Import Foreign Class' Method into MyClass | Wondering if this is possible in PHP Land:
Let's say I have a class as follows:
class myClass{
var $myVar;
...
myMethod(){
$this->myVar = 10;
}
}
and another class:
class anotherClass {
...
addFive(){
$this->myVar += 5;
}
}
The 'anotherClass' is 3500 lines long and I just want the sing... | [
"A better approach would be to move the complex method into its own class. Then both of your classes can instantiate it, pass any necessary data, and call the method.\n",
"The easiest way to do this is have one class extend the other\nclass myClass extends anotherClass {\n}\n\nThe myClass class now has access to ... | [
2,
2,
0
] | [] | [] | [
"anonymous_methods",
"closures",
"oop",
"php",
"python"
] | stackoverflow_0001505621_anonymous_methods_closures_oop_php_python.txt |
Q:
Visual representation of nodes in Python
I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?
The different solutions tha... | Visual representation of nodes in Python | I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?
The different solutions that popped in my head were to use a GUI library ... | [
"Not sure if this is applicable to your situation, but have you looked at graphviz? \nIt has decent python bindings for it and I've used it for visualizing dependencies which sometimes end up looking like trees.\n",
"Instead of using graphviz directly, consider using the visualization tools included in NetworkX. ... | [
6,
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0001505131_python.txt |
Q:
Making a portable (exe) with Python 3.1?
Is there a way to make a portable/stand-alone exe for python apps?
I've read about p2exe but it doesn't support the latest version. I'm reluctant to go to 2.6 because I'd rather stay with the latest version instead of worrying about incompatibilities as soon as 2.6 becomes... | Making a portable (exe) with Python 3.1? | Is there a way to make a portable/stand-alone exe for python apps?
I've read about p2exe but it doesn't support the latest version. I'm reluctant to go to 2.6 because I'd rather stay with the latest version instead of worrying about incompatibilities as soon as 2.6 becomes too outdated.
| [
"cx_freeze has worked for me. Here's a link. The page claims to support 3.1. Good luck!\nhttp://cx-freeze.sourceforge.net/\n"
] | [
13
] | [] | [] | [
"py2exe",
"python"
] | stackoverflow_0001505783_py2exe_python.txt |
Q:
PyQt4 Highlighting
I'm trying to add some syntax highlighting to a text editor in PyQt4. I've found an example in the documentation which works find when compiled from C++ but when i convert it to Python/PyQt it no longer works.
The part of the code that fails (no longer highlights anything) is:
def highlightCurre... | PyQt4 Highlighting | I'm trying to add some syntax highlighting to a text editor in PyQt4. I've found an example in the documentation which works find when compiled from C++ but when i convert it to Python/PyQt it no longer works.
The part of the code that fails (no longer highlights anything) is:
def highlightCurrentLine(self):
extra... | [
"Ok... turns out i wasn't going mad, i was just using an out of date version of PyQt4.\nFor information the version of PyQt4 that ships with Ubuntu 9.04 is 4.4.4 but this functionality seems to require 4.5+.\nI've upgraded to PyQt4 4.6 and it works fine (plus 4.6 seems to have some nice new functionality too).\n",
... | [
1,
0
] | [] | [] | [
"pyqt4",
"python",
"qt4"
] | stackoverflow_0001472044_pyqt4_python_qt4.txt |
Q:
How to pick certain elements of x-tuple returned by a function?
I am a newbie to Python. Consider the function str.partition() which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?
I can currently do either:
# Int... | How to pick certain elements of x-tuple returned by a function? | I am a newbie to Python. Consider the function str.partition() which returns a 3-tuple. If I am interested in only elements 0 and 2 of this tuple, what is the best way to pick only certain elements out of such a tuple?
I can currently do either:
# Introduces "part1" variable, which is useless
(part0, part1, part2) = st... | [
"Underscore is often used as a name for stuff you do not need, so something like this would work:\npart0, _, part2 = str.partition(' ')\n\nIn this particular case, you could do this, but it isn't a pretty solution:\npart0, part2 = str.partition(' ')[::2]\n\nA more esoteric solution:\nfrom operator import itemgetter... | [
13,
4,
2,
1,
0
] | [] | [] | [
"iterable_unpacking",
"list",
"python",
"tuples"
] | stackoverflow_0001502470_iterable_unpacking_list_python_tuples.txt |
Q:
blackle.com queries
I'm trying to query blackle.com for searches, but I get an 403 HTTP error. Can somebody point out what is wrong here?
#!/usr/bin/env python
import urllib2
ss = raw_input('Please enter search string: ')
response = "http://www.google.com/cse?cx=013269018370076798483:gg7jrrhpsy4&cof=FORID:1&q=" +... | blackle.com queries | I'm trying to query blackle.com for searches, but I get an 403 HTTP error. Can somebody point out what is wrong here?
#!/usr/bin/env python
import urllib2
ss = raw_input('Please enter search string: ')
response = "http://www.google.com/cse?cx=013269018370076798483:gg7jrrhpsy4&cof=FORID:1&q=" + ss + "&sa=Search"
urllib... | [
"HTTP 403 means \"forbidden\" (see here for a good explanation): google.com doesn't want to let you access that resource. Since it does let browsers access it, presumably it's identifying you as a robot (automated code, not interactive user browser), through user agent checking and the like. Have you checked robots... | [
2
] | [] | [] | [
"python",
"search"
] | stackoverflow_0001505958_python_search.txt |
Q:
Need a HTTPS-capable Python XML-RPC server
I already have a very simple threading XML-RPC server in Python:
from SocketServer import ThreadingMixIn
class AsyncXMLRPCServer(ThreadingMixIn, SimpleXMLRPCServer):
pass
server = AsyncXMLRPCServer(('localhost', 9999))
server.register_instance(some_object())
server.s... | Need a HTTPS-capable Python XML-RPC server | I already have a very simple threading XML-RPC server in Python:
from SocketServer import ThreadingMixIn
class AsyncXMLRPCServer(ThreadingMixIn, SimpleXMLRPCServer):
pass
server = AsyncXMLRPCServer(('localhost', 9999))
server.register_instance(some_object())
server.serve_forever()
Now I want to make it accessible... | [
"The standard library doesn't support HTTPS servers. There is a Cookbook Recipe using an OpenSSL module. There is also a Twisted solution.\n"
] | [
5
] | [] | [] | [
"https",
"python",
"ssl",
"xml_rpc"
] | stackoverflow_0001506379_https_python_ssl_xml_rpc.txt |
Q:
Duplicate Insertions in Database using sqlite, sqlalchemy, python
I am learning Python and, through the help of online resources and people on this site, am getting the hang of it. In this first script of mine, in which I'm parsing Twitter RSS feed entries and inserting the results into a database, there is one re... | Duplicate Insertions in Database using sqlite, sqlalchemy, python | I am learning Python and, through the help of online resources and people on this site, am getting the hang of it. In this first script of mine, in which I'm parsing Twitter RSS feed entries and inserting the results into a database, there is one remaining problem that I cannot fix. Namely, duplicate entries are being ... | [
"It looks like you included SQLAlchemy into a previously existing script that didn't use SQLAlchemy. There are too many moving parts here that none of us apparently understand well enough.\nI would recommend starting from scratch. Don't use threading. Don't use sqlalchemy. To start maybe don't even use an SQL d... | [
2
] | [] | [] | [
"duplicates",
"python",
"sqlalchemy",
"sqlite",
"twitter"
] | stackoverflow_0001506023_duplicates_python_sqlalchemy_sqlite_twitter.txt |
Q:
SQLAlchemy - MapperExtension.before_delete not called
I have question regarding the SQLAlchemy. I have database which contains Items, every Item has assigned more Records (1:n). And the Record is partially stored in the database, but it also has an assigned file (1:1) on the filesystem.
What I want to do is to del... | SQLAlchemy - MapperExtension.before_delete not called | I have question regarding the SQLAlchemy. I have database which contains Items, every Item has assigned more Records (1:n). And the Record is partially stored in the database, but it also has an assigned file (1:1) on the filesystem.
What I want to do is to delete the assigned file when the Record is removed from the d... | [
"A delete + insert of two records that ultimately have the same primary key within a single flush are converted into a single update right now. this is not the best behavior - it really should delete then insert, so that the various events assigned to those activities are triggered as expected (not just mapper ex... | [
4
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0001496429_python_sqlalchemy.txt |
Q:
Why doesn't os.system('set foo=bar') work?
Possibly a stupid question: Why can't I set an environment variable with this?
os.system('set foo=bar') # on windows
I'm aware of os.environ, and that works for me. I'm just confused about why the former doesn't work.
A:
See the discussion here -- export and set are b... | Why doesn't os.system('set foo=bar') work? | Possibly a stupid question: Why can't I set an environment variable with this?
os.system('set foo=bar') # on windows
I'm aware of os.environ, and that works for me. I'm just confused about why the former doesn't work.
| [
"See the discussion here -- export and set are both shell commands, and whether on Windows or Unix, they're still inevitably being addressed to a child process running the shell (be it bash, cmd.exe, whatever) and so bereft of any further action when that child process terminates (i.e., when os.system returns to th... | [
11
] | [] | [] | [
"environment",
"environment_variables",
"python"
] | stackoverflow_0001506579_environment_environment_variables_python.txt |
Q:
Network programming abstraction, decomposition
I have a problem as follows:
Server process 1
Constantly sends updates that occur to a datastore
Server process 2
Clients contact the server, which queries the datastore, and returns a result
The thing is, the results that process 1 and process 2 are sending back ... | Network programming abstraction, decomposition | I have a problem as follows:
Server process 1
Constantly sends updates that occur to a datastore
Server process 2
Clients contact the server, which queries the datastore, and returns a result
The thing is, the results that process 1 and process 2 are sending back the client are totally different and unrelated.
How ... | [
"If you can restrict yourself to Twisted, I recommend to use Perspective Broker. It's essentially an RPC system, and doesn't care much about the notion of \"client\" and \"server\" - either the initiator of a TCP connection or the responder can start RPC calls in PB. \nSo server 1 would accept registration calls wi... | [
1,
1,
0
] | [] | [] | [
"network_programming",
"networking",
"python",
"twisted"
] | stackoverflow_0001505744_network_programming_networking_python_twisted.txt |
Q:
What are the advantages of faster server side scripting languages?
Typical performance of Python scripts are about 5 times faster than PHP. What are the advantages of using faster server side scripting languages? Will the speed ever be felt by website visitors? Can PHP's performance be compensated by faster server... | What are the advantages of faster server side scripting languages? | Typical performance of Python scripts are about 5 times faster than PHP. What are the advantages of using faster server side scripting languages? Will the speed ever be felt by website visitors? Can PHP's performance be compensated by faster server processors?
| [
"According to Andy B. King, in Website Optimization:\n\nFor Google an increase in page load time from 0.4 second to 0.9 seconds decreased traffic and ad revenues by 20%. For Amazon every 100 ms increase in load times decreased sales with 1%.\n\nhttp://www.svennerberg.com/2008/12/page-load-times-vs-conversion-rates/... | [
13,
10,
4,
1
] | [] | [] | [
"performance",
"php",
"python",
"scripting",
"webserver"
] | stackoverflow_0001507175_performance_php_python_scripting_webserver.txt |
Q:
urllib2: submitting a form and then redirecting
My goal is to come up with a portable urllib2 solution that would POST a form and then redirect the user to what comes out.
The POSTing part is simple:
request = urllib2.Request('https://some.site/page', data=urllib.urlencode({'key':'value'}))
response = urllib2.urlo... | urllib2: submitting a form and then redirecting | My goal is to come up with a portable urllib2 solution that would POST a form and then redirect the user to what comes out.
The POSTing part is simple:
request = urllib2.Request('https://some.site/page', data=urllib.urlencode({'key':'value'}))
response = urllib2.urlopen(request)
Providing data sets request type to POS... | [
"The standard way to follow redirects with urllib2 is to use the HTTPRedirectHandler.\n(Not sure what you mean by 'what comes out' but I'm assuming a standard http redirect here, javascript redirect is a different beast)\n# Created handler\nredirectionHandler = urllib2.HTTPRedirectHandler() \n\n# 2 apply the handle... | [
3,
2,
0
] | [] | [] | [
"google_app_engine",
"python",
"urllib2"
] | stackoverflow_0001507170_google_app_engine_python_urllib2.txt |
Q:
remove inner border on gtk.Button
I would like to remove border on a gtk.Button and also set its size fixed. How can I accomplish that?
My button looks like that:
b = gtk.Button()
b.set_relief(gtk.RELIEF_NONE)
Thanks!
p.d: I'm using pygtk
A:
You can use gtk.Widget.set_size_request to set a fixed size for the... | remove inner border on gtk.Button | I would like to remove border on a gtk.Button and also set its size fixed. How can I accomplish that?
My button looks like that:
b = gtk.Button()
b.set_relief(gtk.RELIEF_NONE)
Thanks!
p.d: I'm using pygtk
| [
"You can use gtk.Widget.set_size_request to set a fixed size for the widget. Note that this is generally a bad idea, since the user may want a larger font size than you had planned for, etc.\nAs for removing the border, gtk.Button can often take up more space than you wish it would. You can try to set some of the s... | [
2
] | [
"I don't think the EventBox can send button events like \"activated\" and \"clicked\".\n"
] | [
-1
] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0001383663_gtk_pygtk_python.txt |
Q:
JavaFX or RIA desktop app (on dvd) also available on the web?
Is it possible to develop an application easily available on the web that also can be distributed on DVD (installer or started from the dvd)?
For the moment, we use static html (frameset!) pages (generated by xml files), with one difference: pdf's are o... | JavaFX or RIA desktop app (on dvd) also available on the web? | Is it possible to develop an application easily available on the web that also can be distributed on DVD (installer or started from the dvd)?
For the moment, we use static html (frameset!) pages (generated by xml files), with one difference: pdf's are only on the DVD version, the web version only shows a preview of the... | [
"I think if you design it correctly to begin with, a JavaFX app can be interchanged between web-app and desktop-app relatively easily. However, I've only done this with very simple apps (specifically, Tic-Tac-Toe!), so I'm sure there might exist some caveats that I am unaware of (thus the \"design it correctly\" ca... | [
0,
0,
0,
0
] | [] | [] | [
"java",
"javafx",
"python",
"turbogears",
"web_applications"
] | stackoverflow_0001346723_java_javafx_python_turbogears_web_applications.txt |
Q:
Doing CRUD in Turbogears
Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions?
A:
You... | Doing CRUD in Turbogears | Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions?
| [
"You should really take a look at sprox ( http://sprox.org/ ).\nIt builds on RESTController, is very straight forward, well documented (imo), generates forms and validation \"magically\" from your database and leaves you with a minimum of code to write. I really enjoy working with it.\nHope that helps you :)\n",
... | [
3,
2,
0,
0
] | [] | [] | [
"crud",
"python",
"turbogears"
] | stackoverflow_0000128689_crud_python_turbogears.txt |
Q:
Why is it that my thumbnail PIL function won't work the 2nd time?
def create_thumbnail(f, width=200, height=100):
im = Image.open(f)
im.thumbnail((width, height), Image.ANTIALIAS)
thumbnail_file = StringIO()
im.save(thumbnail_file, 'JPEG')
thumbnail_file.seek(0)
return thumbnail_file
It se... | Why is it that my thumbnail PIL function won't work the 2nd time? |
def create_thumbnail(f, width=200, height=100):
im = Image.open(f)
im.thumbnail((width, height), Image.ANTIALIAS)
thumbnail_file = StringIO()
im.save(thumbnail_file, 'JPEG')
thumbnail_file.seek(0)
return thumbnail_file
It seems that my error is "IOError: cannot identify image file"...based on... | [
"The only thing I can think of is that you are running on Windows, in which case Image.open() will open a file handler but does not close it. (That behaviour does not occur on Linux/Unix - the file is closed by the end of your code, and it doesn't matter if it isn't anyway).\n"
] | [
2
] | [] | [] | [
"python",
"python_imaging_library"
] | stackoverflow_0001508355_python_python_imaging_library.txt |
Q:
distutils setup.py and %post %postun
I am newbie.
I am buidling rpm package for my own app and decided to use distutils to do achieve it. I managed to create some substitue of %post by using advice from this website, which i really am thankfull for, but i am having problems with %postun.
Let me describe what i hav... | distutils setup.py and %post %postun | I am newbie.
I am buidling rpm package for my own app and decided to use distutils to do achieve it. I managed to create some substitue of %post by using advice from this website, which i really am thankfull for, but i am having problems with %postun.
Let me describe what i have done. In setup.py i run command that cre... | [
"Yes, you can specify a post install script, all you need is to declare in the bdist_rpm in the options arg the file you want to use:\nsetup(\n...\noptions = {'bdist_rpm':{'post_install' : 'post_install',\n 'post_uninstall' : 'post_uninstall'}},\n...)\n\nIn the post_uninstall file, put he cod... | [
2,
0
] | [] | [] | [
"distutils",
"python",
"rpm",
"specifications"
] | stackoverflow_0001407021_distutils_python_rpm_specifications.txt |
Q:
KeyError with dict.fromkeys() and dict-like object
In Python, you can use a dictionary as the first argument to dict.fromkeys(), e.g.:
In [1]: d = {'a': 1, 'b': 2}
In [2]: dict.fromkeys(d)
Out[2]: {'a': None, 'b': None}
I tried to do the same with a dict-like object, but that always raises a KeyError, e.g.:
In [... | KeyError with dict.fromkeys() and dict-like object | In Python, you can use a dictionary as the first argument to dict.fromkeys(), e.g.:
In [1]: d = {'a': 1, 'b': 2}
In [2]: dict.fromkeys(d)
Out[2]: {'a': None, 'b': None}
I tried to do the same with a dict-like object, but that always raises a KeyError, e.g.:
In [1]: class SemiDict:
...: def __init__(self):
.... | [
"To create the dict, fromkeys iterates over its argument. So it must be an iterator. One way to make it work is to add an __iter__ method to your dict-like:\ndef __iter__(self):\n return iter(self.d)\n\n",
"instance of SemiDict is not a sequence. I'd imagine the most obvious solution would be to inherit from d... | [
6,
1
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0001509153_dictionary_python.txt |
Q:
How to search XPath inside Python ClientForm object?
I've got a form, returned by Python mechanize Browser and got via forms() method. How can I perform XPath search inside form node, that is, among descendant nodes of the HTML form node? TIA
Upd:
How to save html code of the form?
A:
By parsing the browser cont... | How to search XPath inside Python ClientForm object? | I've got a form, returned by Python mechanize Browser and got via forms() method. How can I perform XPath search inside form node, that is, among descendant nodes of the HTML form node? TIA
Upd:
How to save html code of the form?
| [
"By parsing the browser contents with lxml, which has xpath support.\n"
] | [
1
] | [] | [] | [
"mechanize",
"python"
] | stackoverflow_0001509404_mechanize_python.txt |
Q:
How do I get fluent in Python?
Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic.
What is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that.... | How do I get fluent in Python? | Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic.
What is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incor... | [
"Read other people's code. Write some of your own code. Repeat for a year or two.\nStudy the Python documentation and learn the built-in modules.\nRead Python in a Nutshell.\nSubscribe your RSS reader to the Python tag on Stack Overflow.\n",
"Have you read the Python Cookbook? It's a pretty good source for Pyth... | [
11,
8,
7,
5,
3,
3,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0001507041_python.txt |
Q:
How to arrange the source code of an application made with SQLAlchemy and a graphic interface?
I'm developing an application using SQLAlchemy and wxPython that I'm trying to keep distributed in separated modules consisting of Business logic, ORM and GUI.
I'm not completely sure how to do this in a pythonic way.
Gi... | How to arrange the source code of an application made with SQLAlchemy and a graphic interface? | I'm developing an application using SQLAlchemy and wxPython that I'm trying to keep distributed in separated modules consisting of Business logic, ORM and GUI.
I'm not completely sure how to do this in a pythonic way.
Given that mapping() has to be called in orther for the objects to be used, I thought of putting it on... | [
"I find this document by Jp Calderone to be a great tip on how to (not) structure your python project. Following it you won't have issues. I'll reproduce the entire text here:\n\nFilesystem structure of a Python project\nDo:\n\nname the directory something\n related to your project. For example,\n if your project... | [
6
] | [] | [] | [
"directory_structure",
"python",
"sqlalchemy",
"version_control"
] | stackoverflow_0001506887_directory_structure_python_sqlalchemy_version_control.txt |
Q:
Is there anything like Project Sprouts but implemented in Python?
Since our entire build system is written in Python, I'm wondering if there is anything like Sprouts that I could leverage to integrate Flex builds / development into our codebase?
Sprouts looks nice and all, but I don't want to introduce another b... | Is there anything like Project Sprouts but implemented in Python? | Since our entire build system is written in Python, I'm wondering if there is anything like Sprouts that I could leverage to integrate Flex builds / development into our codebase?
Sprouts looks nice and all, but I don't want to introduce another build-time dependency to our projects (namely Ruby).
Thanks
| [
"No, I don't believe there is anything similar for Python.\nIt looks like Sprouts is made up of a lot of Rake build files, so you could try to roll your own build system in Python using tools like Paver, fabric, Buildout recipes, paster templates, etc. That would give you the ability to generate new projects like S... | [
3
] | [] | [] | [
"apache_flex",
"python",
"ruby"
] | stackoverflow_0001508743_apache_flex_python_ruby.txt |
Q:
How to tell when nosetest is running programmatically
nosetest is the default test framework in Turbogeras 2.0. The application has a websetup.py module that initialise the database. I use mysql for my development and production environment and websetup works fine, but nosetest uses sqlite on memory and when it ... | How to tell when nosetest is running programmatically | nosetest is the default test framework in Turbogeras 2.0. The application has a websetup.py module that initialise the database. I use mysql for my development and production environment and websetup works fine, but nosetest uses sqlite on memory and when it tries to initialise the DB sends an error:
TypeError: SQLi... | [
"I don't use TurboGears, but is there not a setting or global somewhere that indicates that the tests are running? In large systems, there are often small changes that need to be made when running tests. Switching between SQLite and MySQL is just one example.\n",
"Presumably if nose is running, the 'nose' top-l... | [
0,
0
] | [] | [] | [
"nosetests",
"python",
"sqlalchemy"
] | stackoverflow_0001500214_nosetests_python_sqlalchemy.txt |
Q:
Catch contents of PHP session under Apache with Python (mod_wsgi)?
Is there a way to catch the contents of the PHP session variable $_SESSION['user_id'] with a mod_wsgi Python script? I'm running a script in the background that will decide whether or not the user may proceed to view the document.
I would like to d... | Catch contents of PHP session under Apache with Python (mod_wsgi)? | Is there a way to catch the contents of the PHP session variable $_SESSION['user_id'] with a mod_wsgi Python script? I'm running a script in the background that will decide whether or not the user may proceed to view the document.
I would like to do something like this:
def allow_access(environ, host):
allow_access... | [
"If it's possible, it's not easy; apache stores session variables in files in a special format.\nYour best option might be to write a php page that prints all session variables. (Hard-code it to only serve to localhost.) Open the url to that page from within your python script. Add a header to the url request wit... | [
3,
3
] | [] | [] | [
"apache",
"mod_wsgi",
"python"
] | stackoverflow_0001509641_apache_mod_wsgi_python.txt |
Q:
match an alternative url - regular expression django urls
I want a Django URL with just 2 alternatives /module/in/ or /module/out/
I'm using
url(r'^(?P<status>\w+[in|out])/$',
'by_status',
name='module_by-status'),
But it matches other patterns like /module/i/, /module/n/ and /module/ou/.
Any hint is appreciate... | match an alternative url - regular expression django urls | I want a Django URL with just 2 alternatives /module/in/ or /module/out/
I'm using
url(r'^(?P<status>\w+[in|out])/$',
'by_status',
name='module_by-status'),
But it matches other patterns like /module/i/, /module/n/ and /module/ou/.
Any hint is appreciated :)
| [
"Try r'^(?P<status>in|out)/$'\nYou need to remove \\w+, which matches one or more alphanumeric characters or underscores. The regular expression suggested in bstpierre's answer, '^(?P<status>\\w+(in|out))/$' will match helloin, good_byeout and so on.\nNote that if you use the vertical bar (pipe) character | in your... | [
10,
1
] | [] | [] | [
"django",
"django_urls",
"python",
"regex"
] | stackoverflow_0001506646_django_django_urls_python_regex.txt |
Q:
Can seek and tell work with UTF-8 encoded documents in Python?
I have an application that generates some large log files > 500MB.
I have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all int... | Can seek and tell work with UTF-8 encoded documents in Python? | I have an application that generates some large log files > 500MB.
I have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all into memory.
I thus want to scan the document once, build an index and ... | [
"If true, this sounds like a bug or limitation of the codecs module, as it's probably confusing byte and character offsets.\nI would use the regular open() function for opening the file, then seek()/tell() will give you byte offsets that are always consistent. Whenever you want to read, use f.readline().decode('utf... | [
3,
2,
1,
0
] | [] | [] | [
"codec",
"python",
"seek",
"utf_8"
] | stackoverflow_0001510188_codec_python_seek_utf_8.txt |
Q:
How to use Sphinx auto-documentation when Python file won't compile
This question is even harder today because I haven't had any luck using the search function on the Sphinx homepage today.
I have a group of modules that I want to be documented from the docstrings. However, these are not pure Python scripts. They ... | How to use Sphinx auto-documentation when Python file won't compile | This question is even harder today because I haven't had any luck using the search function on the Sphinx homepage today.
I have a group of modules that I want to be documented from the docstrings. However, these are not pure Python scripts. They won't compile as is, because they are run from a C# application that crea... | [
"Well, you could try:\n\nWrapping the usage of injected_method in a try/except.\nWriting a script that filters out all python-code that is run on import time, and feeds the result into Sphinx.\nYou could....ok, I have no more ideas. :)\n\n",
"Perhaps you could define injected_method as a empty function so that th... | [
3,
0,
0
] | [] | [] | [
"ironpython",
"python",
"python_sphinx"
] | stackoverflow_0001506673_ironpython_python_python_sphinx.txt |
Q:
fast string modification in python
This is partially a theoretical question:
I have a string (say UTF-8), and I need to modify it so that each character (not byte) becomes 2 characters, for instance:
"Nissim" becomes "N-i-s-s-i-m-"
"01234" becomes "0a1b2c3d4e"
and so on.
I would suspect that naive concatenation... | fast string modification in python | This is partially a theoretical question:
I have a string (say UTF-8), and I need to modify it so that each character (not byte) becomes 2 characters, for instance:
"Nissim" becomes "N-i-s-s-i-m-"
"01234" becomes "0a1b2c3d4e"
and so on.
I would suspect that naive concatenation in a loop would be too expensive (it I... | [
"@gnosis, beware of all the well-intentioned responders saying you should measure the times: yes, you should (because programmers' instincts are often off-base about performance), but measuring a single case, as in all the timeit examples proffered so far, misses a crucial consideration -- big-O.\nYour instincts ar... | [
12,
2,
2,
1,
1,
0,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0001508464_python_string.txt |
Q:
RESTful APIs in Django for GETTING information from a server
Any idea of a RESTful APIs in Django for GETTING information from a server?
What I want to do is fetch the errors from the server into a database.
For example:
The Live server has examplewebsite.com, any thing goes wrong with that website should POST th... | RESTful APIs in Django for GETTING information from a server | Any idea of a RESTful APIs in Django for GETTING information from a server?
What I want to do is fetch the errors from the server into a database.
For example:
The Live server has examplewebsite.com, any thing goes wrong with that website should POST the error, where the Django app GET the errors and insert them into ... | [
"Take a look at Piston, which calls itself a 'mini-framework for Django for creating RESTful APIs.'\n",
"Are you just trying to fetch data over HTTP? If so, what about urllib2?\n"
] | [
2,
0
] | [] | [] | [
"api",
"django",
"python",
"rest"
] | stackoverflow_0001509621_api_django_python_rest.txt |
Q:
How to make this Python program compile?
I have this Python code:
import re
s = "aa67bc54c9"
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
And I get this error message when I try to run it:
File "<stdin>", line 1
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
... | How to make this Python program compile? | I have this Python code:
import re
s = "aa67bc54c9"
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
And I get this error message when I try to run it:
File "<stdin>", line 1
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
^
SyntaxError: invalid syntax
How can I... | [
"for starts a loop, so you need to end the line with a :, and put the loop body, indented, on the following lines.\nEDIT:\nFor further information I suggest you go to the main documentation.\n",
"You need a colon (:) on the end of the line.\nAnd after that line, you will need an indented statement(s) of what to a... | [
7,
4
] | [] | [] | [
"python",
"syntax_error"
] | stackoverflow_0001510609_python_syntax_error.txt |
Q:
Follow-up on iterating over a graph using XML minidom
This is a follow-up to the question (Link)
What I intend on doing is using the XML to create a graph using NetworkX. Looking at the DOM structure below, all nodes within the same node should have an edge between them, and all nodes that have attended the sam... | Follow-up on iterating over a graph using XML minidom | This is a follow-up to the question (Link)
What I intend on doing is using the XML to create a graph using NetworkX. Looking at the DOM structure below, all nodes within the same node should have an edge between them, and all nodes that have attended the same conference should have a node to that conference. To summ... | [
"\nI'm unsure about how to connect authors to each other.\n\nYou need to generate (author, otherauthor) pairs so you can add them as edges. The typical way to do that would be a nested iteration:\nfor thing in things:\n for otherthing in things:\n add_edge(thing, otherthing)\n\nThis is a naïve implementat... | [
0,
0
] | [] | [] | [
"parsing",
"python",
"xmldom"
] | stackoverflow_0001510447_parsing_python_xmldom.txt |
Q:
Django model refactoring and migration
I'd like to refactor a number of django apps in a way which involves moving Models from one app into another where they can be more readily reused.
A number of these models have either ForeignKey relationships or M2M relationships to other models (such as User). For example... | Django model refactoring and migration | I'd like to refactor a number of django apps in a way which involves moving Models from one app into another where they can be more readily reused.
A number of these models have either ForeignKey relationships or M2M relationships to other models (such as User). For example:
class Department(models.Model):
name =... | [
"Have you looked at using a migration tool such as South or django-evolution?\n",
"You can very easily solve the immediate problem by just providing a related_name argument to the ForeignKey in either the new or old model, exactly as the error message tells you to. Not confident that will solve all your problems ... | [
6,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001510215_django_django_models_python.txt |
Q:
Retrieving tags for a specific queryset with django-tagging
I'm using django-tagging, and am trying to retrieve a list of tags for a specific queryset. Here's what I've got:
tag = Tag.objects.get(name='tag_name')
queryset = TaggedItem.objects.get_by_model(Article, tag)
tags = Tag.objects.usage_for_queryse... | Retrieving tags for a specific queryset with django-tagging | I'm using django-tagging, and am trying to retrieve a list of tags for a specific queryset. Here's what I've got:
tag = Tag.objects.get(name='tag_name')
queryset = TaggedItem.objects.get_by_model(Article, tag)
tags = Tag.objects.usage_for_queryset(queryset, counts=True)
"queryset" appropriately returns a numb... | [
"This appears to be a bug in django-tagging. A patch has been written, but it has not yet been committed to trunk. Find the patch here:\nhttp://code.google.com/p/django-tagging/issues/detail?id=44\n"
] | [
1
] | [] | [] | [
"django",
"django_tagging",
"python"
] | stackoverflow_0001510936_django_django_tagging_python.txt |
Q:
Parsing large pseudo-xml files in python
I'm trying to parse* a large file (> 5GB) of structured markup data. The data format is essentially XML but there is no explicit root element. What's the most efficient way to do that?
The problem with SAX parsers is that they require a root element, so either I've to add a... | Parsing large pseudo-xml files in python | I'm trying to parse* a large file (> 5GB) of structured markup data. The data format is essentially XML but there is no explicit root element. What's the most efficient way to do that?
The problem with SAX parsers is that they require a root element, so either I've to add a pseudo element to the data stream (is there a... | [
"http://docs.python.org/library/xml.sax.html\nNote, that you can pass a 'stream' object to xml.sax.parse. This means you can probably pass any object that has file-like methods (like read) to the parse call... Make your own object, which will firstly put your virtual root start-tag, then the contents of file, then ... | [
11,
1,
1,
1
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0001508938_python_xml.txt |
Q:
Can Django/Javascript handle conditional "Ajax" responses to HTTP POST requests?
How do I design a Django/Javascript application to provide for conditional Ajax responses to conventional HTTP requests?
On the server, I have a custom-built Form object. When the browser POSTS the form's data, the server checks the ... | Can Django/Javascript handle conditional "Ajax" responses to HTTP POST requests? | How do I design a Django/Javascript application to provide for conditional Ajax responses to conventional HTTP requests?
On the server, I have a custom-built Form object. When the browser POSTS the form's data, the server checks the submitted data against existing data and rules (eg, if the form adds some entity to a ... | [
"Although you can arrange for your views to examine the request data to decide if the response should be an AJAXish or plain HTML, I don't really recommend it. Put AJAX request handlers in a separate URL structure, for instance all your regular html views have urls like /foo/bar and a corresponding api call for th... | [
3,
3,
0
] | [] | [] | [
"ajax",
"django",
"javascript",
"python"
] | stackoverflow_0001511049_ajax_django_javascript_python.txt |
Q:
Venn Diagram from a list of sentences
I have a list of many sentences in Excel on each row in a column. I have like 3 or more columns with such sentences. There are some common sentences in these. Is it possible to create a script to create a Venn diagram and get the common ones between all.
Example: These are se... | Venn Diagram from a list of sentences | I have a list of many sentences in Excel on each row in a column. I have like 3 or more columns with such sentences. There are some common sentences in these. Is it possible to create a script to create a Venn diagram and get the common ones between all.
Example: These are sentences in a column. Similarly there are di... | [
"This is my interpretation of the question...\nGive the data file z.csv (export your data from excel into a csv file)\n\"Blood lymphocytes from cancer\",\"Blood lymphocytes from sausages\",\"Ovarian tumor_Grade III\"\n\"Blood lymphocytes from patients\",\"Ovarian tumor_Grade III\",\"Peritoneum tumor_Grade IV\"\n\"O... | [
2,
0
] | [] | [] | [
"python",
"venn_diagram"
] | stackoverflow_0001510972_python_venn_diagram.txt |
Q:
Pretty graphs and charts in Python
What are the available libraries for creating pretty charts and graphs in a Python application?
A:
I'm the one supporting CairoPlot and I'm very proud it came up here.
Surely matplotlib is great, but I believe CairoPlot is better looking.
So, for presentations and websites, it'... | Pretty graphs and charts in Python | What are the available libraries for creating pretty charts and graphs in a Python application?
| [
"I'm the one supporting CairoPlot and I'm very proud it came up here.\nSurely matplotlib is great, but I believe CairoPlot is better looking.\nSo, for presentations and websites, it's a very good choice.\nToday I released version 1.1. If interested, check it out at CairoPlot v1.1\nEDIT: After a long and cold winter... | [
50,
38,
18,
15,
6,
6,
4,
4,
4,
3,
3,
3,
1,
0,
0
] | [] | [] | [
"graphics",
"python"
] | stackoverflow_0000052652_graphics_python.txt |
Q:
Queue for producers and consumers in a tree
I am reading up on how to utilize Python Queues to send and receive short messages between nodes. I am simulating a set of nodes that are in a nice tree structure. I want some of these nodes to send a fixed-size data to its parent. Once this parent receives data from som... | Queue for producers and consumers in a tree | I am reading up on how to utilize Python Queues to send and receive short messages between nodes. I am simulating a set of nodes that are in a nice tree structure. I want some of these nodes to send a fixed-size data to its parent. Once this parent receives data from some of its child-nodes, it will "process" it and se... | [
"I'm not commenting on the python code in particular, but as far as your queues are designed, it seems you just need one queue in the node 1,2,3 scenario you were describing. Basically, you have one queue, where you have node 1 and node 2 putting messages to, and node 3 reading from.\nYou should be able to tell no... | [
1
] | [] | [] | [
"python",
"queue"
] | stackoverflow_0001511359_python_queue.txt |
Q:
Using lambda for a constraint function
import numpy
from numpy import asarray
Initial = numpy.asarray [2.0, 4.0, 5.0, 3.0, 5.0, 6.0] # Initial values to start with
bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000), (1.0, 5000), (2, 1000000)]
# actual passed bounds
b1 = lambda x: numpy.asarray([1.... | Using lambda for a constraint function | import numpy
from numpy import asarray
Initial = numpy.asarray [2.0, 4.0, 5.0, 3.0, 5.0, 6.0] # Initial values to start with
bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000), (1.0, 5000), (2, 1000000)]
# actual passed bounds
b1 = lambda x: numpy.asarray([1.4*x[0] - x[0]])
b2 = lambda x: numpy.asar... | [
"Based on the comment from Robert Kern, I have removed my previous answer. Here are the constraints as continuous functions:\nb1 = lambda x: x[4]-x[0] if x[4]<1.2*x[0] else 1.4*x[0]-x[4]\nb2 = lambda x: x[5]-x[1] if x[5]<1.2*x[1] else 1.4*x[1]-x[5]\nb3 = lambda x: x[2]-x[3]\n\nNote: Python 2.5 or greater is require... | [
1
] | [] | [] | [
"lambda",
"numpy",
"python",
"scipy"
] | stackoverflow_0001511354_lambda_numpy_python_scipy.txt |
Q:
Link Checker (Spider Crawler)
I am looking for a link checker to spider my website and log invalid links, the problem is that I have a Login page at the start which is required. What i want is a link checker to run through the command post login details then spider the rest of the website.
Any ideas guys will be ... | Link Checker (Spider Crawler) | I am looking for a link checker to spider my website and log invalid links, the problem is that I have a Login page at the start which is required. What i want is a link checker to run through the command post login details then spider the rest of the website.
Any ideas guys will be appreciated.
| [
"I've just recently solved a similar problem like this:\nimport urllib\nimport urllib2\nimport cookielib\n\nlogin = 'user@host.com'\npassword = 'secret'\n\ncookiejar = cookielib.CookieJar()\nurlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))\n\n# adjust this to match the form's field names\nva... | [
3,
2
] | [] | [] | [
"hyperlink",
"python",
"web_crawler"
] | stackoverflow_0001510211_hyperlink_python_web_crawler.txt |
Q:
Please help me with this program to parse a file into an XML file
To parse an input text file and generate a) an XML file and b) an SVG (also XML) file.
The input text file (input.txt) contains the description of a number of produce distribution centers and storage centers around the country. Each line describes e... | Please help me with this program to parse a file into an XML file | To parse an input text file and generate a) an XML file and b) an SVG (also XML) file.
The input text file (input.txt) contains the description of a number of produce distribution centers and storage centers around the country. Each line describes either a single distribution center (dcenter) or a storage center, each ... | [
"Suppose the input is in string s; either from direct assignment or from file.read:\ns=\"\"\"dcenter: code=d1, loc=San Jose, x=100, y=100, ctype=ct1\ndcenter: code=d2, loc=San Ramon, x=300, y=200, ctype=ct2\nstorage: code=s1, locFrom=d1, x=50, y=50, rtype=rt1\nstorage: code=s2, locFrom=d1, x=-50,y=100, rtype=rt1\"\... | [
0
] | [] | [] | [
"fileparsing",
"python",
"xml"
] | stackoverflow_0001511950_fileparsing_python_xml.txt |
Q:
Python/Ruby as mobile OS
I was wondering why smartphone/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.
What would be the reasoning behind a mobile OS being written in Python... | Python/Ruby as mobile OS | I was wondering why smartphone/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.
What would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic l... | [
"In general it's all of these things. Memory, speed, and probably most importantly programmer familiarity. Apple has a huge investment in Objective C, Java is known by basically everyone, and C# is very popular as well. If you're trying for mass programmer appeal it makes sense to start with something popular, even... | [
14,
2,
2,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [] | [] | [
"dynamic_languages",
"mobile",
"operating_system",
"python",
"ruby"
] | stackoverflow_0000816212_dynamic_languages_mobile_operating_system_python_ruby.txt |
Q:
Python loop | "do-while" over a tree
Is there a more Pythonic way to put this loop together?:
while True:
children = tree.getChildren()
if not children:
break
tree = children[0]
UPDATE:
I think this syntax is probably what I'm going to go with:
while tree.getChildren():
tree = tree.getChil... | Python loop | "do-while" over a tree | Is there a more Pythonic way to put this loop together?:
while True:
children = tree.getChildren()
if not children:
break
tree = children[0]
UPDATE:
I think this syntax is probably what I'm going to go with:
while tree.getChildren():
tree = tree.getChildren()[0]
| [
"children = tree.getChildren()\nwhile children:\n tree = children[0]\n children = tree.getChildren()\n\nIt would be easier to suggest something if I knew what kind of collection api you're working with. In a good api, you could probably do something like\nwhile tree.hasChildren():\n children = tree.getChil... | [
4,
2,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0001511506_python.txt |
Q:
Generic Foreign Keys and get_or_create in django 1.0: Broken?
As you can see, create() works, but get_or_create() doesn't. Am I missing something obvious here?
In [7]: f = FeedItem.objects.create(source=u, dest=q, type="greata")
In [8]: f, created = FeedItem.objects.get_or_create(source=u, dest=q, type="greata")
... | Generic Foreign Keys and get_or_create in django 1.0: Broken? | As you can see, create() works, but get_or_create() doesn't. Am I missing something obvious here?
In [7]: f = FeedItem.objects.create(source=u, dest=q, type="greata")
In [8]: f, created = FeedItem.objects.get_or_create(source=u, dest=q, type="greata")
-------------------------------------------------------------------... | [
"Look like there's different logic used in create and get_or_create as in get_or_create there is no source argument but src_object_id and src_content_type but it is easy to resolve this - pass scr_object_id as u.id and src_content_type as u.content_type (same with dest).\nOr use try/except & create.\n"
] | [
2
] | [] | [] | [
"django",
"foreign_keys",
"python"
] | stackoverflow_0001512152_django_foreign_keys_python.txt |
Q:
Mod_python produces no output
Just installed and configured mod_python 3.2.8 on a CentOS 5 (Apache 2.2.3) server with Python 2.4.3. It is loaded fine by Apache.
I activated the mpinfo test page and it works. So I wrote a simple "Hello World" with the following code:
from mod_python import apache
def handler(req):... | Mod_python produces no output | Just installed and configured mod_python 3.2.8 on a CentOS 5 (Apache 2.2.3) server with Python 2.4.3. It is loaded fine by Apache.
I activated the mpinfo test page and it works. So I wrote a simple "Hello World" with the following code:
from mod_python import apache
def handler(req):
req.content_type = 'text/plain... | [
"Don't use mod_python. \nA common mistake is to take mod_python as \"mod_php, but for python\" and that is not true. mod_python is more suited to writing apache extensions, not web applications. \nThe standartized protocol to use between python web applications and web servers (not only apache) is WSGI. Using it en... | [
2,
1,
0
] | [] | [] | [
"apache",
"mod_python",
"python"
] | stackoverflow_0001508406_apache_mod_python_python.txt |
Q:
What is a good reference for Server side development?
I am more interested in the design of the code (i.e functional design vs object oriented design). What are the best practices and what is the communities thoughts on this subject?
Not that it should matter, but I am working with Apache and Python technology st... | What is a good reference for Server side development? | I am more interested in the design of the code (i.e functional design vs object oriented design). What are the best practices and what is the communities thoughts on this subject?
Not that it should matter, but I am working with Apache and Python technology stack.
| [
"If you are using Apache+Python, this sounds like you are using Python for dynamic web pages. In that case, I would strongly urge you to look into Django. There are also other Python web development environments, but Django is perhaps the most popular; and it has excellent documentation such as The Django Book. ... | [
2
] | [] | [] | [
"apache",
"architecture",
"python"
] | stackoverflow_0001512155_apache_architecture_python.txt |
Q:
Is there any framework like RoR on Python 3000?
One of the feature I like in RoR is the db management, it can hide all the sql statement, also, it is very easy to change different db in RoR, is there any similar framework in Python 3000?
A:
This answer was awfully outdated. The current state of afairs is:
Djang... | Is there any framework like RoR on Python 3000? | One of the feature I like in RoR is the db management, it can hide all the sql statement, also, it is very easy to change different db in RoR, is there any similar framework in Python 3000?
| [
"This answer was awfully outdated. The current state of afairs is:\n\nDjango is close to supporting Python 3\nCherryPy supports Python 3 since version 3.2\nPyramid has Python 3 support since 1.3\nBottle, which is a lightweight WSGI micro web-framework, supports Python 3\n\nI'm sure this list will keep growing every... | [
5,
2,
1,
0
] | [
"There's Django but it works with Python 2.3+ only for now.\n"
] | [
-1
] | [
"frameworks",
"python",
"python_3.x",
"ruby_on_rails"
] | stackoverflow_0001510084_frameworks_python_python_3.x_ruby_on_rails.txt |
Q:
Python: how to write a data struct to a file as text (not pickled)
Is there a way to write python data structs to a file as text.
e.g. an app is running and has a variable/object: OPTIONS = ('ON', 'OFF', )
I need to write/merge the OPTIONS tuple into another file, not as a
pickled object, but as text, verbatim: O... | Python: how to write a data struct to a file as text (not pickled) | Is there a way to write python data structs to a file as text.
e.g. an app is running and has a variable/object: OPTIONS = ('ON', 'OFF', )
I need to write/merge the OPTIONS tuple into another file, not as a
pickled object, but as text, verbatim: OPTIONS = ('ON', 'OFF', )
I could traverse the tuple, and one by one writ... | [
"You could use repr (repr works well with things that have a __repr__() method):\n>>> OPTIONS=('ON', 'OFF', )\n>>> \"OPTIONS=\"+repr(OPTIONS)\n\"OPTIONS=('ON', 'OFF')\"\n\n",
"fout.write(str(OPTIONS)) does what you want in this case, but no doubt in many others it won't; repr instead of str may be closer to your ... | [
4,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0001512401_python.txt |
Q:
Determining if stdout for a Python process is redirected
I've noticed that curl can tell whether or not I'm redirecting its output (in which case it puts up a progress bar).
Is there a reasonable way to do this in a Python script? So:
$ python my_script.py
Not redirected
$ python my_script.py > output.txt
Redire... | Determining if stdout for a Python process is redirected | I've noticed that curl can tell whether or not I'm redirecting its output (in which case it puts up a progress bar).
Is there a reasonable way to do this in a Python script? So:
$ python my_script.py
Not redirected
$ python my_script.py > output.txt
Redirected!
| [
"import sys\n\nif sys.stdout.isatty():\n print \"Not redirected\"\nelse:\n sys.stderr.write(\"Redirected!\\n\")\n\n",
"Actually, what you want to do here is find out if stdin and stdout are the same thing.\n$ cat test.py\nimport os\nprint os.fstat(0) == os.fstat(1)\n$ python test.py\nTrue\n$ python test.py ... | [
43,
14,
4
] | [] | [] | [
"python"
] | stackoverflow_0001512457_python.txt |
Q:
How to access file metadata with Python?
I'm trying to write a program in python that retrieves and updates file metadata on windows. I've tried searching on Google regarding what modules to use but I haven't found anything very concrete or useful.
Some people suggested the stat module which can give you info such... | How to access file metadata with Python? | I'm trying to write a program in python that retrieves and updates file metadata on windows. I've tried searching on Google regarding what modules to use but I haven't found anything very concrete or useful.
Some people suggested the stat module which can give you info such as file access and last modification. But I'm... | [
"Essentially as I said here less than an hour ago,\n\nApparently, you need to use the\n Windows Search API looking for\n System.Keywords -- you can access the\n API directly via ctypes, or indirectly\n (needing win32 extensions) through the\n API's COM Interop assembly. Sorry, I\n have no vista installation o... | [
2
] | [] | [] | [
"metadata",
"python",
"windows"
] | stackoverflow_0001512600_metadata_python_windows.txt |
Q:
How to save data with Python?
I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue s... | How to save data with Python? | I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful code ... | [
"From your description JSON encoding is the secure and fast solution. There is a json module in python2.6, you can use it like this:\nimport json\nobj = {'key1': 'value1', 'key2': [1, 2, 3, 4], 'key3': 1322}\nencoded = json.dumps(obj)\nobj = json.loads(encoded)\n\nJSON format is human readable and is very similar t... | [
23,
3,
2,
1,
1,
1,
1
] | [] | [] | [
"data_structures",
"python",
"save"
] | stackoverflow_0001389738_data_structures_python_save.txt |
Q:
Converting urls into lowercase?
Is there any straightforward to convert all incoming urls to lowercase before they get matched against urlpatterns in run_wsgi_app(webapp.WSGIApplication(urlpatterns))?
A:
You'd have to wrap the instance of WSGIApplication with your own WSGI app that lowercases the URL in the WSG... | Converting urls into lowercase? | Is there any straightforward to convert all incoming urls to lowercase before they get matched against urlpatterns in run_wsgi_app(webapp.WSGIApplication(urlpatterns))?
| [
"You'd have to wrap the instance of WSGIApplication with your own WSGI app that lowercases the URL in the WSGI environment -- but then the environment would just stay modified, which may have other unpleasant effects. Why not just add (?i) to the regex patterns you use in urlpatterns instead?\n",
"I wonder if you... | [
3,
0
] | [] | [] | [
"google_app_engine",
"python",
"web_applications"
] | stackoverflow_0001512389_google_app_engine_python_web_applications.txt |
Q:
wx.TextCtrl.LoadFile()
I am trying to display search result data quickly. I have all absolute file paths for files on my network drive(s) in a single, ~50MB text file. The python script makes a single pass over every line in this file [kept on the local drive] in a second or less, and that is acceptable. That is ... | wx.TextCtrl.LoadFile() | I am trying to display search result data quickly. I have all absolute file paths for files on my network drive(s) in a single, ~50MB text file. The python script makes a single pass over every line in this file [kept on the local drive] in a second or less, and that is acceptable. That is the time it takes to gather ... | [
"Are people really going to read (or need) all 10MB in a text control? Probably not.\nSuggest that, you load on demand by paging in portions of the data.\nOr better still, provide some user search functionality that narrows down the results to the information of interest.\n",
"You can load all the data at once wi... | [
0,
0
] | [] | [] | [
"file_io",
"mmap",
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0001507075_file_io_mmap_python_wxpython_wxwidgets.txt |
Q:
text diff on django/google appengine
I am developing a wiki using django which i plan to deploy later in google appengine. Is it possible to deploy textdiff like system in appengine?
A:
The difflib package can be useful for generating diffs. It's written in pure Python and it's in the standard Python library, so... | text diff on django/google appengine | I am developing a wiki using django which i plan to deploy later in google appengine. Is it possible to deploy textdiff like system in appengine?
| [
"The difflib package can be useful for generating diffs. It's written in pure Python and it's in the standard Python library, so I'd expect it to be available in Google App Engine.\n"
] | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001512966_django_python.txt |
Q:
Any python OpenID server available?
I'd like to host my own OpenID provider. Is there anything available in Python?
A:
poit is a standalone, single-user OpenID server implemented in Python, using python-openid. (It's a project I started)
| Any python OpenID server available? | I'd like to host my own OpenID provider. Is there anything available in Python?
| [
"poit is a standalone, single-user OpenID server implemented in Python, using python-openid. (It's a project I started)\n"
] | [
7
] | [] | [] | [
"openid",
"python"
] | stackoverflow_0000941296_openid_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.