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:
Compile Python 2.5.5 on OS X 10.6
I would like to install Python 2.5.5 to use with Google apps but have been having a very hard time tracking down instructions on how to do so. I am thinking the following might work but was wondering if anyone had successfully built it?
./configure --prefix=/usr/local/python2.5.5 ... | Compile Python 2.5.5 on OS X 10.6 | I would like to install Python 2.5.5 to use with Google apps but have been having a very hard time tracking down instructions on how to do so. I am thinking the following might work but was wondering if anyone had successfully built it?
./configure --prefix=/usr/local/python2.5.5 MACOSX_DEPLOYMENT_TARGET=10.6 --enable-... | [
"You should install it via MacPorts, which makes this a piece of cake. After you have it installed...\n$ sudo port install python25\n\n",
"You should install it via Fink, which makes this a piece of cake. After you have it installed...\n$ fink install python25\n\nFink has more packages than MacPorts.\n",
"Ass... | [
1,
1,
0,
0
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0003821957_macos_python.txt |
Q:
How do I store a list (or dict) of key terms from a regular expression? -Python
I am quite new at python and regex so please bear with me.
I am trying to read in a file, match a particular name using a regex while ignoring the case, and store each time I find it. For example, if the file is composed of Bill bill b... | How do I store a list (or dict) of key terms from a regular expression? -Python | I am quite new at python and regex so please bear with me.
I am trying to read in a file, match a particular name using a regex while ignoring the case, and store each time I find it. For example, if the file is composed of Bill bill biLl biLL, I need to store each variation in a dictionary or list.
Current code:
impor... | [
"I'd use findall:\nre.findall(r'bill', open(filename).read(), re.I)\n\nEasy as pie:\n>>> s = 'fooBiLL bill BILL bIlL foo bar'\n>>> import re\n>>> re.findall(r'bill', s, re.I)\n['BiLL', 'bill', 'BILL', 'bIlL']\n\n",
"I think that you want re.findall. This is of course available on the compiled regular expression a... | [
2,
1
] | [] | [] | [
"dictionary",
"python",
"regex"
] | stackoverflow_0003824373_dictionary_python_regex.txt |
Q:
Multiple versions of django admin page for the same model
In my django admin section, I'd like to show different versions of the admin page depending on what kind of user is currently logged in. I can think of a couple ways this might work, but haven't figured out how to do any of them.
Perhaps I could put logic ... | Multiple versions of django admin page for the same model | In my django admin section, I'd like to show different versions of the admin page depending on what kind of user is currently logged in. I can think of a couple ways this might work, but haven't figured out how to do any of them.
Perhaps I could put logic into the admin.ModelAdmin to look at the current user and chang... | [
"There are quite a few hooks provided in the ModelAdmin class for this sort of thing.\nOne possibility would be to override the get_form method. This takes the request, as well as the object being edited, so you could get the current user from there, and return different ModelForms dependent on the user.\nIt's wort... | [
1
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0003824468_django_django_admin_python.txt |
Q:
What are good specs/libraries for closed network communication in python?
The situation is that I have a small datacenter, with each server running python instances. It's not your usual distributed worker setup, as each server has a specific role with an appropriate long-running process.
I'm looking for good ways ... | What are good specs/libraries for closed network communication in python? | The situation is that I have a small datacenter, with each server running python instances. It's not your usual distributed worker setup, as each server has a specific role with an appropriate long-running process.
I'm looking for good ways to implement the the cross-server communication. REST seems like overkill. XML-... | [
"Twisted's Perspective Broker is an extremely easy to use and robust mechanism for cross-server communication. It's definitely worth a look.\n",
"It wasn't obvious from your question but if getting answers back synchronously doesn't matter to you (i.e., you are just asking for work to be performed) you might want... | [
2,
1
] | [] | [] | [
"network_protocols",
"python"
] | stackoverflow_0003823420_network_protocols_python.txt |
Q:
Python structure always stuck at 0 no matter what value you assign to it?
I was writing a module to compact bits to be passed to C program, but keep getting errors. After some tests, I found out that the field a of class Blah is stuck at 0 no matter what. Does anyone know if this is a bug or if I'm doing something... | Python structure always stuck at 0 no matter what value you assign to it? | I was writing a module to compact bits to be passed to C program, but keep getting errors. After some tests, I found out that the field a of class Blah is stuck at 0 no matter what. Does anyone know if this is a bug or if I'm doing something wrong here?
Sorry, I forgot to mention I'm using python 3.1.2 from http://www.... | [
"You could omit the 3rd field as a workaround.\n>>> import ctypes\n>>> class Blah(ctypes.Structure):\n... _fields_ = [(\"a\", ctypes.c_uint64), ('b', ctypes.c_uint16), ('c', ctypes.c_uint8), ('d', ctypes.c_uint8)]\n... \n>>> x = Blah(0xDEAD,0xBEEF,0x44,0x12)\n>>> hex(x.a)\n'0xdead'\n>>> hex(x.b)\n'0xbeef'\n\nI gu... | [
1
] | [] | [] | [
"python",
"structure"
] | stackoverflow_0003824617_python_structure.txt |
Q:
Python datetime TypeError, integer expected
I'm pretty new to Python, so hopefully the problem I'm having has a simple solution.
At work we always us either Shell (ksh) or Perl for all of our scripting work. Since python has been shipped with Solaris for some time now, it has (finally) been given the green light a... | Python datetime TypeError, integer expected | I'm pretty new to Python, so hopefully the problem I'm having has a simple solution.
At work we always us either Shell (ksh) or Perl for all of our scripting work. Since python has been shipped with Solaris for some time now, it has (finally) been given the green light as a scripting platform. I've started prototyping ... | [
"Strongly consider using datetime.datetime.strptime:\nimport datetime\n\ntests=[\"201009211100\",\"201009211199\"]\nfor fileTime in tests:\n try:\n date=datetime.datetime.strptime(fileTime,'%Y%m%d%H%M')\n print(date)\n except ValueError as err:\n print(fileTime,err)\n\n# 2010-09-21 11:00:... | [
5,
1,
0
] | [] | [] | [
"python",
"scripting"
] | stackoverflow_0003825056_python_scripting.txt |
Q:
How do I write to the apache log files when using mod_wsgi
I have a Django project where I have been logging to a file using the standard library logging module. For a variety of reasons I would like to change it so that it writes to the Apache log files. I've seen quite a bit of discussion of how to do this wit... | How do I write to the apache log files when using mod_wsgi | I have a Django project where I have been logging to a file using the standard library logging module. For a variety of reasons I would like to change it so that it writes to the Apache log files. I've seen quite a bit of discussion of how to do this with mod_python, but not mod_wsgi. How do I do this for a project ... | [
"Mostly, we use logging and write to sys.stderr. That seems to write to the Apache error_log.\n"
] | [
13
] | [] | [] | [
"apache",
"logging",
"mod_wsgi",
"python"
] | stackoverflow_0003824923_apache_logging_mod_wsgi_python.txt |
Q:
How to apply a function to every element in a list using Linq in C# like the method reduce() in python?
How to apply a function to every element in a list using Linq in C# like the method reduce() in python?
A:
Assuming you're talking about this reduce function, the equivalent in C# and LINQ is Enumerable.Aggreg... | How to apply a function to every element in a list using Linq in C# like the method reduce() in python? | How to apply a function to every element in a list using Linq in C# like the method reduce() in python?
| [
"Assuming you're talking about this reduce function, the equivalent in C# and LINQ is Enumerable.Aggregate.\nQuick example:\nvar list = Enumerable.Range(5, 3); // [5, 6, 7]\nConsole.WriteLine(\"Aggregation: {0}\", list.Aggregate((a, b) => (a + b)));\n// Result is \"Aggregation: 18\"\n\n",
"Enumerable.Aggregate is... | [
11,
2
] | [] | [] | [
"c#",
"linq",
"python"
] | stackoverflow_0003825200_c#_linq_python.txt |
Q:
Selenium and Python: remove \n from returned selenium.get_text()
When I call selenium.get_text("foo") on a certain element it returns back a different value depending on what browser I am working in due to the way each browser handles newlines.
Example:
An elements string is "hello[newline]how are you today?[newli... | Selenium and Python: remove \n from returned selenium.get_text() | When I call selenium.get_text("foo") on a certain element it returns back a different value depending on what browser I am working in due to the way each browser handles newlines.
Example:
An elements string is "hello[newline]how are you today?[newline]Very well, thank you."
When selenium gets this back from IE it gets... | [
"I ended up just doing a check of what browser I was running and then returning the string with the '\\n ' replaced with '\\n' if the browser was firefox.\n"
] | [
0
] | [] | [] | [
"python",
"selenium"
] | stackoverflow_0003824734_python_selenium.txt |
Q:
Computing number of sub-queries in Google AppEngine
How can I determine how many sub-queries are required for a single top-level query on app engine (python)?
I am playing around with the IN operator, and I am curious if there is any way to be notified if I over-step my 30 sub-query limit.
A:
If you try to execu... | Computing number of sub-queries in Google AppEngine | How can I determine how many sub-queries are required for a single top-level query on app engine (python)?
I am playing around with the IN operator, and I am curious if there is any way to be notified if I over-step my 30 sub-query limit.
| [
"If you try to execute a query which would spawn too many sub-queries then you would get this error:\nBadArgumentError: Cannot satisfy query -- too many subqueries (max: 30, got 31). Probable cause: too many IN/!= filters in query.\n\nIf you wanted to check before trying to execute the query, you could check the le... | [
4
] | [] | [] | [
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0003825845_google_app_engine_google_cloud_datastore_python.txt |
Q:
Regular Expressions: How would I extract a given word using a regular expression?
How would I extract the word 'wrestle' from the following:
type=weaksubj len=1 word1=wrestle pos1=verb stemmed1=y priorpolarity=negative
using a regular expression?
A:
The question is not very clear, but I guess this is what you a... | Regular Expressions: How would I extract a given word using a regular expression? | How would I extract the word 'wrestle' from the following:
type=weaksubj len=1 word1=wrestle pos1=verb stemmed1=y priorpolarity=negative
using a regular expression?
| [
"The question is not very clear, but I guess this is what you are looking for:\nword1=(\\w+)\n\nYour match will be in the 1st group. Here's some sample Python code:\nimport re\nyourstring = 'type=weaksubj len=1 word1=wrestle pos1=verb stemmed1=y priorpolarity=negative'\n\nm = re.search(r'word1=(\\w+)', yourstring)\... | [
6,
2,
0,
0,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003823599_python_regex.txt |
Q:
INVALID SYNTAX ERROR for 'else' statement in python
I am trying to write a quicksort program in python, however I'm getting an invalid syntax error at else statement in the second last line below:
import random
n=int(raw_input("Enter the size of the list: ")) # size of the list
intlist = [0]*n
for num in range(n)... | INVALID SYNTAX ERROR for 'else' statement in python | I am trying to write a quicksort program in python, however I'm getting an invalid syntax error at else statement in the second last line below:
import random
n=int(raw_input("Enter the size of the list: ")) # size of the list
intlist = [0]*n
for num in range(n):
intlist[num]=random.randint(0,10*n)
pivot=random.c... | [
"add a colon after the else so that it looks like else:. and pick up a good tutorial ;)\n",
"Looks like you need a ':' after \"else\".\n"
] | [
5,
2
] | [] | [] | [
"if_statement",
"python",
"syntax_error"
] | stackoverflow_0003826236_if_statement_python_syntax_error.txt |
Q:
Key bindings or workflow suggestions for managing breakpoints with pydbgr in Emacs 23.2
I have pydbgr working well now in Emacs 23.2 with virtualenv. But I am confused why breakpoints are not established from the source code buffer after running M-x pydbgr - as they would be e.g. when using pdb.
I tried invoking ... | Key bindings or workflow suggestions for managing breakpoints with pydbgr in Emacs 23.2 | I have pydbgr working well now in Emacs 23.2 with virtualenv. But I am confused why breakpoints are not established from the source code buffer after running M-x pydbgr - as they would be e.g. when using pdb.
I tried invoking C-cC-b but this does not toggle breakpoints on the selected line as one would hope/expect.
N... | [
"A recent change in emacs-dbgr on http://github.com/rocky/emacs-dbgr adds this. There are a number of other issues regarding breakpoint synchronization. emacs-dbgr is a work in progress, not a finished product. \n"
] | [
0
] | [] | [] | [
"configuration",
"debugging",
"emacs",
"python"
] | stackoverflow_0003821639_configuration_debugging_emacs_python.txt |
Q:
Pythons M2Crypto raises exception in ssl_ctx_load_verify_locations when loading certificates
M2Crypto raises a TypeError when loading SSL CA certificates. I'm getting the path of an SSL certificate from an instance of a Django model. My code worked perfectly because I was pulling the path of the certificate from... | Pythons M2Crypto raises exception in ssl_ctx_load_verify_locations when loading certificates | M2Crypto raises a TypeError when loading SSL CA certificates. I'm getting the path of an SSL certificate from an instance of a Django model. My code worked perfectly because I was pulling the path of the certificate from a Django model
My code:
from M2Crypto import SSL
from django.db import models
class MyModel(mo... | [
"Just worked it out!\nThe load_verify_locations() function is expecting a string object, not a unicode object.\nDjango uses unicode by default, so the certificate path needs to be converted to a string before passed into load_verify_locations(). So:\nctx.load_verify_locations(str(m.ca_file))\n\n"
] | [
2
] | [] | [] | [
"django",
"m2crypto",
"python",
"ssl_certificate"
] | stackoverflow_0003826694_django_m2crypto_python_ssl_certificate.txt |
Q:
Pythonic way of copying an iterable object
For a small project I'm working on I need to cycle through a list. For each element of this cycle I have to start another cycle through the same list, with the former element as first element of the new cycle. For example I'd like to be able to produce something like this... | Pythonic way of copying an iterable object | For a small project I'm working on I need to cycle through a list. For each element of this cycle I have to start another cycle through the same list, with the former element as first element of the new cycle. For example I'd like to be able to produce something like this:
1, 2, 3, 4, 1, 2, 3, 4, 1, ...
2, 3, 4, 1, 2, ... | [
"\nIs there a best-practice in situations\n where one wants a copy of an iterable?\n\nitertools.tee gives you two iterators that each yield the same items as the original, but it takes the original and memorizes everything it yields, so you can't use the original anymore. It wouldn't help here though, because it w... | [
7
] | [] | [] | [
"copy",
"cycle",
"python",
"python_itertools"
] | stackoverflow_0003826746_copy_cycle_python_python_itertools.txt |
Q:
match two strings with letters in random order in python
if I have 2 strings like:
a = "hello"
b = "olhel"
I want to use a regular expression (or something else?) to see if the two strings contain the same letters. In my example a would = b because they have the same letters. How can this be achieved?
A:
a = "... | match two strings with letters in random order in python | if I have 2 strings like:
a = "hello"
b = "olhel"
I want to use a regular expression (or something else?) to see if the two strings contain the same letters. In my example a would = b because they have the same letters. How can this be achieved?
| [
"a = \"hello\"\nb = \"olhel\"\nprint sorted(a) == sorted(b)\n\n",
"An O(n) algorithm is to create a dictionary of counts of each letter and then compare the dictionaries.\nIn Python 2.7 or newer this can be done using collections.Counter:\n>>> from collections import Counter\n>>> Counter('hello') == Counter('olhe... | [
10,
4
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003826867_python_regex.txt |
Q:
python-couchdb pager hitting recursion depth limit
I am creating a pager that returns documents from an Apache CouchDB map function from python-couchdb. This generator expression is working well, until it hits the max recursion depth. How can it be improved to move to iteration, rather than recursion?
def page(db,... | python-couchdb pager hitting recursion depth limit | I am creating a pager that returns documents from an Apache CouchDB map function from python-couchdb. This generator expression is working well, until it hits the max recursion depth. How can it be improved to move to iteration, rather than recursion?
def page(db, view_name, limit, include_docs=True, **opts):
"""
... | [
"Here's something to get you started. You didn't specify what *opts might be; if you only need startkey and startkey_docid to start the recursion, and not some other fields, then you can get rid of the extra function.\nObviously, untested.\ndef page_key(db, view_name, limit, startkey, startkey_docid, inc_docs=True... | [
0,
0,
0
] | [] | [] | [
"couchdb",
"python"
] | stackoverflow_0003826647_couchdb_python.txt |
Q:
PyQt4 SIGNAL/SLOT problem when using sub-directories
Thanks in advance for taking the time to read this. Apologies that it is somewhat verbose. But hopefully it fully explains the problem. Stripped code demonstrating the issue is included.
I'm having an issue with PyQt4 SIGNAL/SLOTS. While I can make everything wo... | PyQt4 SIGNAL/SLOT problem when using sub-directories | Thanks in advance for taking the time to read this. Apologies that it is somewhat verbose. But hopefully it fully explains the problem. Stripped code demonstrating the issue is included.
I'm having an issue with PyQt4 SIGNAL/SLOTS. While I can make everything work fine if I am writing in a single file, I can't make thi... | [
"For starters, is there a reason you're using a very old version of the PyQt release document? The new one is: here\nThere are a few things you are doing that are a bit unusual. Generally import statements in python are placed at the top of the file (to more easily see dependencies), but I assume you're doing this ... | [
2
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"qt",
"qt4"
] | stackoverflow_0003827013_pyqt_pyqt4_python_qt_qt4.txt |
Q:
Extract data from large structured file using Java/Python
I have a large text file (~100MB) that need to be parsed to extract information. I would like to find an efficient way of doing it. The file is structured in block:
Mon, 01 Jan 2010 01:01:01
Token1 = ValueXYZ
Token2 = ValueABC
Token3 = ValuePQR
...
... | Extract data from large structured file using Java/Python | I have a large text file (~100MB) that need to be parsed to extract information. I would like to find an efficient way of doing it. The file is structured in block:
Mon, 01 Jan 2010 01:01:01
Token1 = ValueXYZ
Token2 = ValueABC
Token3 = ValuePQR
...
TokenX = Value123
Mon, 01 Jan 2010 01:02:01
Token1 = Value... | [
"Usually, we do something like this. The re library pretty much handles it. The use of a generator function copes the the nested structure.\ndef gen_blocks( my_file ):\n header_pat= re.compile( r\"\\w3, \\d2 \\w3 \\d4 \\d2:\\d2:\\d2\" )\n detail_pat = re.compile( r\"\\s2\\S*\\s+=\\s+\\S*\" )\n lines = []... | [
0,
0,
0,
0,
0
] | [] | [] | [
"file",
"java",
"performance",
"python"
] | stackoverflow_0003825160_file_java_performance_python.txt |
Q:
Matplotlib point annotation, no scaling
I'd like to annotate a plot in matplotlib with filled and non-filled dots. I can create a circle patch, but the circle scales with my axes which is not my desired effect.
I can achieve this with
plt.plot(x,y,'.',markersize=10)
plt.plot(x,y,'o',markersize=10)
but both marke... | Matplotlib point annotation, no scaling | I'd like to annotate a plot in matplotlib with filled and non-filled dots. I can create a circle patch, but the circle scales with my axes which is not my desired effect.
I can achieve this with
plt.plot(x,y,'.',markersize=10)
plt.plot(x,y,'o',markersize=10)
but both markers are filled even if I set markerfacecolor=N... | [
"From the sources it looks like you need to set markerfacecolor to 'none' and None.\nCan you try this?\nRef : http://www.mathworks.com/help/techdoc/ref/errorbarseriesproperties.html\n"
] | [
1
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0003827247_matplotlib_python.txt |
Q:
Trying to format Google App Engine DateTimeProperty for template
I'm using the Tornado framework (Python) on GAE. I'm still kind of new to the whole MVC concept and GAE... and having a dang of a time trying to figure out how to do this.
I have a table (model) Post with the fields user, text, creation_date.
I pull... | Trying to format Google App Engine DateTimeProperty for template | I'm using the Tornado framework (Python) on GAE. I'm still kind of new to the whole MVC concept and GAE... and having a dang of a time trying to figure out how to do this.
I have a table (model) Post with the fields user, text, creation_date.
I pull all the posts in the code and then send it to the template. I want t... | [
"Assuming you are using Tornado's template module, it includes the datetime module. I have not used Tornado's template module, but you should be able to use:\nentity.datetime_property.strftime('%m-%d-%y')\n\nIf you want to process your models before sending them to the template try something like:\nclass HomeHandl... | [
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003826441_google_app_engine_python.txt |
Q:
(Usage of Class Variables) Pythonic - or nasty habit learnt from java?
Hello Pythoneers: the following code is only a mock up of what I'm trying to do, but it should illustrate my question.
I would like to know if this is dirty trick I picked up from Java programming, or a valid and Pythonic way of doing things: b... | (Usage of Class Variables) Pythonic - or nasty habit learnt from java? | Hello Pythoneers: the following code is only a mock up of what I'm trying to do, but it should illustrate my question.
I would like to know if this is dirty trick I picked up from Java programming, or a valid and Pythonic way of doing things: basically I'm creating a load of instances, but I need to track 'static' data... | [
"Class variables are perfectly Pythonic in my opinion.\nJust watch out for one thing. An instance variable can hide a class variable:\nx.counter = 5 # creates an instance variable in the object x.\nprint x.counter # instance variable, prints 5\nprint y.counter # class variable, prints 2\nprint myclass.counter #... | [
7,
4,
2,
2,
1
] | [] | [] | [
"class",
"coding_style",
"python"
] | stackoverflow_0003826077_class_coding_style_python.txt |
Q:
Importing between two applications in a django project
I've got two applications (app1 and app2) in my django project.
I'm curious if there is a way to import things between applications.
baseProject
--app1
----models.py
----etc..
--app2
----models.py
----etc..
I'd like to be able, while in app2, to import so... | Importing between two applications in a django project | I've got two applications (app1 and app2) in my django project.
I'm curious if there is a way to import things between applications.
baseProject
--app1
----models.py
----etc..
--app2
----models.py
----etc..
I'd like to be able, while in app2, to import something from the models section of app1. Is there an intend... | [
"You can definitely do that, just import it as usual. Many authentication/registration-related apps import models from the \"django.contrib.auth\" app that comes with Django. You are free to import from any app, whether you wrote it or not.\nYou just need to make sure the apps are on your PYTHONPATH, so that they... | [
5,
1
] | [] | [] | [
"django",
"import",
"python"
] | stackoverflow_0003827542_django_import_python.txt |
Q:
Python kill thread
I'm trying to kill a thread in python. An exception would be the preferred way to do it, as a graceful exit of the run method of the thread through a try:except: pair would allow to close resources.
I tried : Is there any way to kill a Thread in Python? , but is specifies that is doesn't work wh... | Python kill thread | I'm trying to kill a thread in python. An exception would be the preferred way to do it, as a graceful exit of the run method of the thread through a try:except: pair would allow to close resources.
I tried : Is there any way to kill a Thread in Python? , but is specifies that is doesn't work while the code is executin... | [
"In general, raising asynchronous exceptions is difficult to handle properly. This is because, rather than having single, specific points of code where an exception may be generated--and therefore where exception handling needs to be tested--instead, an exception may be generated after any bytecode instruction. T... | [
4
] | [] | [] | [
"multithreading",
"python",
"sleep"
] | stackoverflow_0003827545_multithreading_python_sleep.txt |
Q:
Python and C interaction - callback function
I'm trying to make a key logger for Mac OS for one of my research projects.
I have a C code which will grab keystroke and write them to a text file. (The following code I have taken out some not important stuff)
What I need to do now is just like PyHook, instead of writ... | Python and C interaction - callback function | I'm trying to make a key logger for Mac OS for one of my research projects.
I have a C code which will grab keystroke and write them to a text file. (The following code I have taken out some not important stuff)
What I need to do now is just like PyHook, instead of write the data to a text file,
to pass a Python callb... | [
"It's easy - Just Follow the instructions - Calling Python Functions from C (Update March 2022: for Python3, see the corresponding chapter in Extending and Embedding the Python Interpreter).\nAlternatively if you are trying to call C/C++ functions from Python you can use SWIG or one of Python's module CTypes\n"
] | [
4
] | [] | [] | [
"c",
"python"
] | stackoverflow_0003827780_c_python.txt |
Q:
using python.ctypes with cygwin
I want to use python's (2.6.5) ctypes with cygwin, but I don't know how to load a dll.
I tried various variants like
>>> form ctypes import *
>>> cdll.LoadLibrary("/lib/libcairo.dll.a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2... | using python.ctypes with cygwin | I want to use python's (2.6.5) ctypes with cygwin, but I don't know how to load a dll.
I tried various variants like
>>> form ctypes import *
>>> cdll.LoadLibrary("/lib/libcairo.dll.a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/ctypes/__init__.py", line 431, in ... | [
"You won't be able to load an import library with the Python ctypes module; it has to be an actual DLL. I used both the cygwin crypt library and the crypt DLL import library as examples with a late model Cygwin on Win7.\n\nPython 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)\n[GCC 4.3.4 20090804 (release) 1] on cygwin\... | [
4
] | [] | [] | [
"ctypes",
"cygwin",
"python"
] | stackoverflow_0003826484_ctypes_cygwin_python.txt |
Q:
How to get out of def ()
for example i have def Hello():
and here is the code
def Hello():
F = 'Y'
if F == 'Y':
#here i want get out of the Hello() to Hey()! by how!
A:
To exit the 'Hello' function:
def Hello():
F = 'Y'
if F == 'Y':
return
You can use 'return' to exit a function before the end (though... | How to get out of def () | for example i have def Hello():
and here is the code
def Hello():
F = 'Y'
if F == 'Y':
#here i want get out of the Hello() to Hey()! by how!
| [
"To exit the 'Hello' function:\ndef Hello():\n F = 'Y'\n if F == 'Y':\n return\n\nYou can use 'return' to exit a function before the end (though there is a school of thought that frowns on this, as it makes it slightly harder to form a solid picture of the execution flow).\nThis will go on to the 'Hey' function i... | [
4
] | [] | [] | [
"python"
] | stackoverflow_0003828135_python.txt |
Q:
Transfer files from windows machine to remote solaris machine using python script
i used following code to establish connection between my local machine and the remote machine :
import os, sys, ftplib
nonpassive=False
remotesite= '10.88.203.21:22'
remoteuser='root'
remotepass='v-peg8!@#'
localdir= "c:\\.."
print ... | Transfer files from windows machine to remote solaris machine using python script | i used following code to establish connection between my local machine and the remote machine :
import os, sys, ftplib
nonpassive=False
remotesite= '10.88.203.21:22'
remoteuser='root'
remotepass='v-peg8!@#'
localdir= "c:\\.."
print "connecting"
connection=ftplib.FTP(remotesite)
print "successfully connected"
connect... | [
"You need to specify the port as a separate argument, not in the way you have it in remotesite. Try:\nremotesite = '10.88.203.21'\nport = 22\nconnection = ftplib.FTP(remotesite, port)\n\nSee the FTP docs for more information.\n",
"If its port 22, then you are using wrong port, since most systems use 22 for SSH pr... | [
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0003827986_python.txt |
Q:
Google app engine, multiple languages
i'm working on on a project with DJango but i'm also thinking about going the Jython route. By doing so...since i'll be using the java instance instead of cpython wouldn't I be able to use java, scala, ruby and other other languages that run on top of the jvm if need be?
A:
... | Google app engine, multiple languages | i'm working on on a project with DJango but i'm also thinking about going the Jython route. By doing so...since i'll be using the java instance instead of cpython wouldn't I be able to use java, scala, ruby and other other languages that run on top of the jvm if need be?
| [
"Scala works on GAE.\nSo does Ruby.\nIf you want to know about other JVM languages, google search for google app engine followed by the name of the language of interest.\n\nAlso see this page.\n",
"I'm not sure how good the Jython Java Interop is. But with Clojure you can generate Java classes pretty easy if it i... | [
1,
0
] | [] | [] | [
"django",
"google_app_engine",
"python",
"scala"
] | stackoverflow_0003825694_django_google_app_engine_python_scala.txt |
Q:
upload file not working in google app engine
it should works but hitting the submit button redirect my page to http://localhost:8082/sign (http://localhost:8082 being the path to my app). There's no such path in my application thus it return a link broken page. Is this a common problem?
A:
Yes, but this isn't an... | upload file not working in google app engine | it should works but hitting the submit button redirect my page to http://localhost:8082/sign (http://localhost:8082 being the path to my app). There's no such path in my application thus it return a link broken page. Is this a common problem?
| [
"Yes, but this isn't an App Engine problem. If you do a form post to a URL that doesn't exist, it will return a 404 (I'm suspecting you modified the guestbook app, which posts to /sign and didn't change where the post on that app goes to).\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003828158_google_app_engine_python.txt |
Q:
GAE webapp application internationalization with Babel
How would you go about internationalizing a Google App Engine webapp application using BABEL? I am looking here for all the stages:
Marking the strings to be translated.
Extracting them.
Traslating
Configuring your app to load the right language requested by ... | GAE webapp application internationalization with Babel | How would you go about internationalizing a Google App Engine webapp application using BABEL? I am looking here for all the stages:
Marking the strings to be translated.
Extracting them.
Traslating
Configuring your app to load the right language requested by the browser
| [
"1) use _() (or gettext()) in your code and templates. Translated strings set in the module globals or class definitions should use some form of lazy gettext(), because i18n won't be available when the modules are imported.\n2) Extract all translations using pybabel. Here we pass two directories to be scanned: the ... | [
11
] | [] | [] | [
"google_app_engine",
"internationalization",
"python",
"python_babel",
"web_applications"
] | stackoverflow_0003821312_google_app_engine_internationalization_python_python_babel_web_applications.txt |
Q:
Find text dialog with wxpython
Does anyone have a very simple example of using a find dialog with a text component in wxpython?
Thanks in advance.
A:
The use of wx.FindReplaceDialog is not so straighforward as we could expect from its name.
This dialog gives you a dialog widget with parameters and entries for a... | Find text dialog with wxpython | Does anyone have a very simple example of using a find dialog with a text component in wxpython?
Thanks in advance.
| [
"The use of wx.FindReplaceDialog is not so straighforward as we could expect from its name.\nThis dialog gives you a dialog widget with parameters and entries for a search (or replace) action, You can read these parameters and the string to find from the dialog (actually from the event or from the wx.FindReplaceDat... | [
3
] | [
"Use the wiki\nimport wx\n\nclass MyDialog(wx.Dialog):\n def __init__(self, parent, id, title):\n wx.Dialog.__init__(self, parent, id, title)\n\nclass MyApp(wx.App):\n def OnInit(self):\n dia = MyDialog(None, -1, \"simpledialog.py\")\n dia.ShowModal()\n dia.Destroy()\n retur... | [
-2
] | [
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0003827587_python_wxpython_wxwidgets.txt |
Q:
Any yahoo messenger lib for python?
Is there any lib available to connect to yahoo messenger using either the standard protocol or the http way from python?
A:
Google is your friend.
The Python Package Index has several modules to do with Yahoo, including this one which matches your requirements.
A:
There is ... | Any yahoo messenger lib for python? | Is there any lib available to connect to yahoo messenger using either the standard protocol or the http way from python?
| [
"Google is your friend.\nThe Python Package Index has several modules to do with Yahoo, including this one which matches your requirements.\n",
"There is also the Yahoo IM SDK that might help.\n"
] | [
5,
1
] | [] | [] | [
"python",
"yahoo_messenger"
] | stackoverflow_0000997419_python_yahoo_messenger.txt |
Q:
strange python behaviour with mixing globals/parameters and function named 'top'
The following code (not directly in an interpreter, but execute as file)
def top(deck):
pass
def b():
global deck
produces the error
SyntaxError: name 'deck' is local and global
on python2.6.4 and
SyntaxError: name 'deck' i... | strange python behaviour with mixing globals/parameters and function named 'top' | The following code (not directly in an interpreter, but execute as file)
def top(deck):
pass
def b():
global deck
produces the error
SyntaxError: name 'deck' is local and global
on python2.6.4 and
SyntaxError: name 'deck' is parameter and global
on python 3.1
python2.4 seems to accept this code, so does the... | [
"It looks like it is a bug in the symbol table handling. Python/symtable.c has some code that (although somewhat obfuscated) does indeed treat 'top' as a special identifier:\nif (!GET_IDENTIFIER(top) ||\n !symtable_enter_block(st, top, ModuleBlock, (void *)mod, 0)) {\n PySymtable_Free(st);\n return NULL;\n... | [
13
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0003828611_python_python_3.x.txt |
Q:
how to do non blocking accept() in Python?
I cannot use threads thus I want to write a server program that can be interrupted after a while:
d = show_non_modal_dialog("serving clients")
s = socket(...)
s.bind(...)
s.listen()
while (!user_pressed_cancel())
{
s.accept() # timed accept for like 1 second
if timed... | how to do non blocking accept() in Python? | I cannot use threads thus I want to write a server program that can be interrupted after a while:
d = show_non_modal_dialog("serving clients")
s = socket(...)
s.bind(...)
s.listen()
while (!user_pressed_cancel())
{
s.accept() # timed accept for like 1 second
if timed_out:
continue
serve_client
close_client... | [
"Use a non-blocking socket and call accept on that.\ns.setblocking(0)\n\nYou could also set a timeout for blocking socket operations\nsocket.settimeout(value)\n\nThere also seems to be an issue in your code\naccept() returns a (conn, address) pair value. so your code should have been\nconn, address = s.accept()\n\n... | [
6
] | [] | [] | [
"nonblocking",
"python",
"sockets"
] | stackoverflow_0003829067_nonblocking_python_sockets.txt |
Q:
Cant get a custom ItemDelegate to work
first off, im new to python and pyqt so please bear with me.
Im using a QTableView with a QSqlTableModel everything works as intended.
The last column of the view contains only 0 and 1 as value which i want to display as checkbox and this column should be editable.
Ive read t... | Cant get a custom ItemDelegate to work | first off, im new to python and pyqt so please bear with me.
Im using a QTableView with a QSqlTableModel everything works as intended.
The last column of the view contains only 0 and 1 as value which i want to display as checkbox and this column should be editable.
Ive read that you should subclass QItemDelegate which ... | [
"I think it would be simpler to create your own model basing QSqlTableModel, and for your 0/1 column return QVariant() for QDisplayRole and return Qt::Checked/Qt::Unchecked for Qt::CheckStateRole depending on value. For all other cases return QSqlTableModel::data\nclass MySqlTableModel: public QSqlTableModel\n{\npu... | [
1,
0
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"qt",
"qt4"
] | stackoverflow_0003811862_pyqt_pyqt4_python_qt_qt4.txt |
Q:
Problem with web code generator designer
I want to write a web-based code generator for a Python crawler. Its aim is to automatically generate code so a developer doesn't need to write it, but I've run into this problem: in one of my project's webpages, there are some checkboxes, buttons, etc. Each of them generat... | Problem with web code generator designer | I want to write a web-based code generator for a Python crawler. Its aim is to automatically generate code so a developer doesn't need to write it, but I've run into this problem: in one of my project's webpages, there are some checkboxes, buttons, etc. Each of them generates some Python code and writes it to a common ... | [
"You need to separate out the idea of what code to generate from the events triggering generation.\nWhat code is generated is governed by the combined set of all the checkboxes that are checked.\nTriggering code generation occurs each time any of them are changed. You need to regenerate everything at that time.\nIn... | [
0
] | [] | [] | [
"code_generation",
"python",
"robot",
"web_crawler"
] | stackoverflow_0003829405_code_generation_python_robot_web_crawler.txt |
Q:
Google appengine-db.key()
Hi am going through the docs of GAE and needed a small clarification. If I have my db model something like this:-
class Phone(Model):
phone_name = db.StringProperty()
r = Phone(Nokia, key_name='first')
r.put()
Now if I have to retrieve this entity but I dont know the key, can I constr... | Google appengine-db.key() | Hi am going through the docs of GAE and needed a small clarification. If I have my db model something like this:-
class Phone(Model):
phone_name = db.StringProperty()
r = Phone(Nokia, key_name='first')
r.put()
Now if I have to retrieve this entity but I dont know the key, can I construct the key like this:
k=db.Key... | [
"You're close. The only major difference is that you have to pass the actual class instead of a string representing the class name, and that you have to use the Key.from_path() factory method rather than the default constructor:\nclass Phone(Model):\n phone_name = db.StringProperty()\n\nr = Phone(phone_name='Nokia... | [
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003829740_google_app_engine_python.txt |
Q:
adding a subpackage from a different path
I have a python package called zypp. It is generated via swig and the rpm package (called python-zypp) puts it in:
rpm -ql python-zypp
/usr/lib64/python2.6/site-packages/_zypp.so
/usr/lib64/python2.6/site-packages/zypp.py
Now, I have a different project which provides an ... | adding a subpackage from a different path | I have a python package called zypp. It is generated via swig and the rpm package (called python-zypp) puts it in:
rpm -ql python-zypp
/usr/lib64/python2.6/site-packages/_zypp.so
/usr/lib64/python2.6/site-packages/zypp.py
Now, I have a different project which provides an additional sets of APIs. Pure python. Plus some... | [
"If I understand your question correctly, you want to use the development version of that module instead of the installed module. Therefore, you can use\n\nPYTHONPATH\nFrom the Module Search Path documentation:\n\nWhen a module named spam is imported, the interpreter searches for a file named spam.py in the current... | [
2
] | [] | [] | [
"load_path",
"python"
] | stackoverflow_0003829779_load_path_python.txt |
Q:
Open source Twitter clone (in Ruby/Python)
Is there any production ready open source twitter clones written in Ruby or Python ?
I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc)
Thanks !
A:
I know of twissandra which is an ... | Open source Twitter clone (in Ruby/Python) | Is there any production ready open source twitter clones written in Ruby or Python ?
I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc)
Thanks !
| [
"I know of twissandra which is an open source clone. Of course I doubt it meets your need of feature rich implementations.\n",
"http://github.com/rnielsen/twetter\nFrom their readme:\nTwetter is an implementation of the twitter.com API, designed for use in situations where internet access is not available but a l... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"ruby",
"twitter"
] | stackoverflow_0003758440_python_ruby_twitter.txt |
Q:
Python, using os.system - Is there a way for Python script to move past this without waiting for call to finish?
I am trying to use Python (through Django framework) to make a Linux command line call and have tried both os.system and os.open but for both of these it seems that the Python script hangs after making ... | Python, using os.system - Is there a way for Python script to move past this without waiting for call to finish? | I am trying to use Python (through Django framework) to make a Linux command line call and have tried both os.system and os.open but for both of these it seems that the Python script hangs after making the command line call as the call is for instantiating a server (so it never "finishes" as its meant to be long-runnin... | [
"I'm not sure, but I think the subprocess module with its Popen is much more flexible than os.popen. If I recall correctly it includes asynchronous process spawning, which I think is what you're looking for.\nEdit: It's been a while since I used the subprocess module, but if I'm not mistaken, subprocess.Popen retur... | [
9,
2,
0
] | [] | [] | [
"command_line",
"django",
"os.system",
"python"
] | stackoverflow_0003830036_command_line_django_os.system_python.txt |
Q:
How to call a self.value in a class function definition in python?
How could I call a self.value in a definition of a function?
class toto :
def __init__(self):
self.titi = "titi"
def printiti(self,titi=self.titi):
print(titi)
A:
This is how it is done:
def printiti(self, titi=None):... | How to call a self.value in a class function definition in python? | How could I call a self.value in a definition of a function?
class toto :
def __init__(self):
self.titi = "titi"
def printiti(self,titi=self.titi):
print(titi)
| [
"This is how it is done:\n def printiti(self, titi=None):\n if titi is None:\n titi = self.titi\n print titi\n\nThis is a common python idiom (setting default value of argument to None and checking it in method's body).\n",
"class Toto:\n def __init__(self):\n self.titi = \"titi\"\n\n de... | [
6,
2
] | [] | [] | [
"class",
"function",
"python",
"self"
] | stackoverflow_0003830447_class_function_python_self.txt |
Q:
openid with django
I found a lot of options but this one https://launchpad.net/django-openid-auth
looks good. sadly I can't find examples/HOWTO about this?Does anyone point/redirect me to correct urls?
A:
Here is a little howto:
http://bazaar.launchpad.net/~django-openid-auth/django-openid-auth/trunk/annotate/h... | openid with django | I found a lot of options but this one https://launchpad.net/django-openid-auth
looks good. sadly I can't find examples/HOWTO about this?Does anyone point/redirect me to correct urls?
| [
"Here is a little howto:\nhttp://bazaar.launchpad.net/~django-openid-auth/django-openid-auth/trunk/annotate/head:/README.txt\nAlso you have exact usage examples here:\nhttp://bazaar.launchpad.net/~django-openid-auth/django-openid-auth/trunk/files/head:/example_consumer/\nYou could also look at this solution here - ... | [
4
] | [] | [] | [
"django",
"openid",
"python"
] | stackoverflow_0003827861_django_openid_python.txt |
Q:
Can't configure node.js for make install on OS X (Snow Leopard)
I cloned the node git repo but the "waf" build tool that comes with node seems to not work with the latest version of Python.
$ ./configure
Traceback (most recent call last):
File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in <module>
... | Can't configure node.js for make install on OS X (Snow Leopard) | I cloned the node git repo but the "waf" build tool that comes with node seems to not work with the latest version of Python.
$ ./configure
Traceback (most recent call last):
File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in <module>
import Scripting
File "/Users/greim/nodestuff/node/tools/wafadm... | [
"Ithe waf project page says \n\nCompatibility from Python 2.3 to 3.1 is maintained (and Jython 2.5)\n\nI think it currently does this by running 2to3.py when unpacking so if you had run first with python2 then it might be wrong. The waf1.6 branch I think is python3 clean\nReading the node.js code the node people ex... | [
3,
1
] | [] | [] | [
"node.js",
"python",
"waf"
] | stackoverflow_0003819313_node.js_python_waf.txt |
Q:
How to read pcks#7 personal digital certificates with python?
is it possible to read personal digital certificates with extension Pcks#7 ( http://en.wikipedia.org/wiki/X.509#Certificate_filename_extensions ) with python?
I have to develop an application using Django that authenticate its users by reading their cer... | How to read pcks#7 personal digital certificates with python? | is it possible to read personal digital certificates with extension Pcks#7 ( http://en.wikipedia.org/wiki/X.509#Certificate_filename_extensions ) with python?
I have to develop an application using Django that authenticate its users by reading their certificate.
In an initial step we are going to use an external servic... | [
"You've tagged your question with \"django\" and you've mentioned logging in users using certificates. Sorry to say the rest of your question doesn't make much sense to me.\nIf your question is \"How to I authenticate users in my Django website using SSL certificate authentication?\"\nThen my suggestion would be to... | [
2
] | [] | [] | [
"digital_certificate",
"django",
"python"
] | stackoverflow_0003829619_digital_certificate_django_python.txt |
Q:
textmate >> vim for python - teething troubles: especially indenting
I'm (attempting) to move from textmate to vim [macvim to be exact] as my primary editor. I have already installed snipmate - wondering if there are other plugins you would suggest I install?
In particular I seem to be having a lot of trouble with... | textmate >> vim for python - teething troubles: especially indenting | I'm (attempting) to move from textmate to vim [macvim to be exact] as my primary editor. I have already installed snipmate - wondering if there are other plugins you would suggest I install?
In particular I seem to be having a lot of trouble with indenting (<< seems to really do some very strange/unpredictable things),... | [
"For source code,\n:h =\n\nIn a nutshell, in normal mode inside a block you wish to work with:\n\n=a{ to re-indent a block. =a} and =aB work as well.\n=2a{ to re-indent this block and its outer block.\nIf you happen to stand on a brace then =% will re-indent up to the matching brace.\n>a{ to increase the indent of ... | [
2,
2,
0
] | [] | [] | [
"macvim",
"python",
"textmate",
"vim"
] | stackoverflow_0003830334_macvim_python_textmate_vim.txt |
Q:
How do I get some slot/function to be executed when a certain QTableWidgetItem is checked / unchecked in PyQt
I have a dynamically created table, that has N rows and M QTableWidgetItems (that are only used as checkboxes) per row - I need to run code that knows the row and the column whenever a checkbox is checked ... | How do I get some slot/function to be executed when a certain QTableWidgetItem is checked / unchecked in PyQt | I have a dynamically created table, that has N rows and M QTableWidgetItems (that are only used as checkboxes) per row - I need to run code that knows the row and the column whenever a checkbox is checked or unchecked.
My CheckBox subclass looks like:
class CheckBox(QTableWidgetItem):
def __init__(self):
QT... | [
"The simplest solution is probably connecting to the cellChanged(int, int) signal of the QTableWidget; take a look at the following example: \nimport sys\nfrom PyQt4.QtGui import *\nfrom PyQt4.QtCore import *\n\n#signal handler\ndef myCellChanged(row, col):\n print row, col\n\n#just a helper function to setup t... | [
2
] | [] | [] | [
"pyqt4",
"python",
"qt4",
"qtablewidget",
"qtablewidgetitem"
] | stackoverflow_0003829349_pyqt4_python_qt4_qtablewidget_qtablewidgetitem.txt |
Q:
Is there a more elegant / pythonic way to express this construct?
itemList = ["a","b","c","d","e","f","g","h"]
aa = "NULL"
bb = "NULL"
cc = "NULL"
for item in itemList:
aa = bb
bb = cc
cc = item
if aa == "NULL":
continue
print "%s_%s_%s" % (aa, bb, cc)
A:
>>> ['_'.join(itemList[i:i+3]... | Is there a more elegant / pythonic way to express this construct? | itemList = ["a","b","c","d","e","f","g","h"]
aa = "NULL"
bb = "NULL"
cc = "NULL"
for item in itemList:
aa = bb
bb = cc
cc = item
if aa == "NULL":
continue
print "%s_%s_%s" % (aa, bb, cc)
| [
">>> ['_'.join(itemList[i:i+3]) for i in range(len(itemList)-2)]\n['a_b_c', 'b_c_d', 'c_d_e', 'd_e_f', 'e_f_g', 'f_g_h']\n\nor if you insist on printing:\n>>> for i in range(len(itemList)-2):\n print('_'.join(itemList[i:i+3]))\n\n",
"import itertools\ndef windows(iterable, length=2):\n return itertools.izip... | [
9,
1,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0003830727_list_python.txt |
Q:
TypeError: instancemethod expected at least 2 arguments, got 0
Django 1.1.2 & Python 2.6.5
I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix... | TypeError: instancemethod expected at least 2 arguments, got 0 | Django 1.1.2 & Python 2.6.5
I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix for this bug. Has anybody dealt with something similar before?
Her... | [
"For the benefit of whoever else might run into this, the error is caused by a combination of using django-multilingual and django.db's F object. Rewriting the code to eliminate F objects solved the issue. \nThe root cause is actually a bug in Python, for more info see http://bugs.python.org/issue1515\n"
] | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003736112_django_python.txt |
Q:
Check memory usage of subprocess in Python
I'm developing an application in Python on Ubuntu and I'm running external binaries from within python using subprocess. Since these binaries are generated at run time and can go rogue, I need to keep a strict tab on the amount of memory footprint and runtime of these bin... | Check memory usage of subprocess in Python |
I'm developing an application in Python on Ubuntu and I'm running external binaries from within python using subprocess. Since these binaries are generated at run time and can go rogue, I need to keep a strict tab on the amount of memory footprint and runtime of these binaries. Is there someway I can limit or monitor ... | [
"You can use Python's resource module to set limits before spawning your subprocess.\nFor monitoring, resource.getrusage() will give you summarized information over all your subprocesses; if you want to see per-subprocess information, you can do the /proc trick in that other comment (non-portable but effective), or... | [
13,
6
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0003830658_python_subprocess.txt |
Q:
twisted: no exception trace if error from a callback
Consider the following code:
df = defer.Deferred()
def hah(_): raise ValueError("4")
df.addCallback(hah)
df.callback(hah)
When it runs, that exception just gets eaten. Where did it go? How can I get it to be displayed? Doing defer.setDebugging(True) has no effe... | twisted: no exception trace if error from a callback | Consider the following code:
df = defer.Deferred()
def hah(_): raise ValueError("4")
df.addCallback(hah)
df.callback(hah)
When it runs, that exception just gets eaten. Where did it go? How can I get it to be displayed? Doing defer.setDebugging(True) has no effect.
I ask this because other times, I get a printout sayin... | [
"The exception is still sitting in the Deferred. There are two possible outcomes at this point:\n\nYou could add an errback to the Deferred. As soon as you do, it will get called with a Failure containing the exception that was raised.\nYou could let the Deferred be garbage collected (explicitly delete df, or ret... | [
7
] | [] | [] | [
"deferred",
"error_handling",
"python",
"twisted"
] | stackoverflow_0003826233_deferred_error_handling_python_twisted.txt |
Q:
ensuring dynamic image urls in a web-app: use a blob store?
I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired.
If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stop... | ensuring dynamic image urls in a web-app: use a blob store? | I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired.
If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out o... | [
"lighty's mod_secdownload has worked well for me to solve this issue. You can read more about it at http://redmine.lighttpd.net/wiki/1/Docs:ModSecDownload\nThe lighttpd wiki also has a generic article about your problem: http://redmine.lighttpd.net/wiki/1/HowToFightDeepLinking\n",
"Why so complicated? \nServe the... | [
2,
1
] | [
"A combination of your two ideas (copy to a dir, expire when session expires) could be generalized to creating a new dir (could be as simple as a symlink) every 15 minutes. When generating the new symlink, also remove the one that's an hour old by now. Always link to the newest name in your code.\n"
] | [
-1
] | [
"blob",
"nginx",
"python",
"sqlite",
"web_applications"
] | stackoverflow_0003830294_blob_nginx_python_sqlite_web_applications.txt |
Q:
dynamic values in kwargs
I have a layer which helps me populating records from the form to tables and viceversa, it does some input checking, etc.
Now several methods of this layer which are called several times in different parts of the webform take the same parameters, so I wanted to pack them at the begining o... | dynamic values in kwargs | I have a layer which helps me populating records from the form to tables and viceversa, it does some input checking, etc.
Now several methods of this layer which are called several times in different parts of the webform take the same parameters, so I wanted to pack them at the begining of the codefile.
kwargs(): re... | [
"Python objects are pointers (though they are not directly manipulatable by the user.)\nSo if you create a list like this:\n>>> a = [1, 2, 3]\n\nand then store it in a dictionary:\n>>> b = { 'key': a, 'anotherkey': 'spam' }\n\nyou will find modifications to the value in the dictionary also modify the original list:... | [
2
] | [] | [] | [
"asp.net",
"ironpython",
"python",
"webforms"
] | stackoverflow_0003830530_asp.net_ironpython_python_webforms.txt |
Q:
Advanced sorting criteria for a list of nested tuples
I have a list of nested tuples of the form:
[(a, (b, c)), ...]
Now I would like to pick the element which maximizes a while minimizing b and c at the same time. For example in
[(7, (5, 1)), (7, (4, 1)), (6, (3, 1))]
the winner should be
(7, (4, 1))
Any help ... | Advanced sorting criteria for a list of nested tuples | I have a list of nested tuples of the form:
[(a, (b, c)), ...]
Now I would like to pick the element which maximizes a while minimizing b and c at the same time. For example in
[(7, (5, 1)), (7, (4, 1)), (6, (3, 1))]
the winner should be
(7, (4, 1))
Any help is appreciated.
| [
">>> max(lst, key=lambda x: (x[0], -x[1][0], -x[1][1]))\n(7, (4, 1))\n\n",
"In my understanding, you want to sort decreasingly by a, and ascendingly by b, then by c. If that's right, you can do it like so:\n>>> l=[(7, (5, 1)), (7, (4, 1)), (6, (3, 2)), (6, (3, 1))]\n>>> sorted(l, key = lambda x: (-x[0], x[1]))\n[... | [
4,
4
] | [] | [] | [
"list",
"python",
"sorting",
"tuples"
] | stackoverflow_0003831449_list_python_sorting_tuples.txt |
Q:
New to Python: Replacing a string by its position in a line
Let's say I got a file with three lines of this structure:
foo
Black sheep: 500
bar
What I'd like to do is an iteration to change "Black sheep: 500" to 600, 700 and so on, replacing the old one. I can think of a way of doing it by search&replace, but I'm... | New to Python: Replacing a string by its position in a line | Let's say I got a file with three lines of this structure:
foo
Black sheep: 500
bar
What I'd like to do is an iteration to change "Black sheep: 500" to 600, 700 and so on, replacing the old one. I can think of a way of doing it by search&replace, but I'm looking for a more elegant way by replacing a certain position (... | [
"We can simply mimick the awk behaviour in a couple of lines :)\nfor line in lines:\n if line.startswith('Black'):\n line_parts = line.split()\n print line_parts[0], line_parts[1], 600\n else:\n print line\n\nCause that's basically what awk does, split on whitespace.\n",
">>> for line i... | [
0,
0
] | [] | [] | [
"python",
"replace"
] | stackoverflow_0003831562_python_replace.txt |
Q:
mod_python Apache configuration
I am having issues with getting my Mod Python to work properly.
I have followed mod_python manual found here
So here is my Apache setup (I am using Virtual Hosts):
<VirtualHost *:80>
ServerName hostname
DocumentRoot "C:/Documents and Settings/username/hostname/www"
<Dir... | mod_python Apache configuration | I am having issues with getting my Mod Python to work properly.
I have followed mod_python manual found here
So here is my Apache setup (I am using Virtual Hosts):
<VirtualHost *:80>
ServerName hostname
DocumentRoot "C:/Documents and Settings/username/hostname/www"
<Directory "C:/Documents and Settings/use... | [
"I figured it out. My Directory did not match my DocumentRoot.\nI appreciate the replies regarding mod_wsgi. I will eventually move to wsgi but I am still learning how to use Python for web development and I basically defaulted to learn using mod_python.\n",
"If you can stop using mod_python as it is abandoned no... | [
1,
0
] | [] | [] | [
"mod_python",
"python"
] | stackoverflow_0003831332_mod_python_python.txt |
Q:
Django randomly order users in admin
I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems:
Applying a custom filter to the User model, and
Displaying a random set of users.
On #1, I've tried using User.username.random_filter = True, but it comes bac... | Django randomly order users in admin | I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems:
Applying a custom filter to the User model, and
Displaying a random set of users.
On #1, I've tried using User.username.random_filter = True, but it comes back with an AttributeError saying that User ... | [
"If I were you (and I am), I would stop trying to integrate this functionality with the Django admin site. Speaking from experience, you'll find that what you're trying to do is much easier to implement as regular views. Sure, it isn't be as pretty, but something that works beats something that's pretty but doesn't... | [
1,
0
] | [] | [] | [
"customization",
"django_admin",
"python"
] | stackoverflow_0003822857_customization_django_admin_python.txt |
Q:
How do the compression codecs work in Python?
I'm querying a database and archiving the results using Python, and I'm trying to compress the data as I write it to the log files. I'm having some problems with it, though.
My code looks like this:
log_file = codecs.open(archive_file, 'w', 'bz2')
for id, f1, f2, f3 i... | How do the compression codecs work in Python? | I'm querying a database and archiving the results using Python, and I'm trying to compress the data as I write it to the log files. I'm having some problems with it, though.
My code looks like this:
log_file = codecs.open(archive_file, 'w', 'bz2')
for id, f1, f2, f3 in cursor:
log_file.write('%s %s %s %s\n' % (id,... | [
"As other posters have noted, the issue is that the codecs library doesn't use an incremental encoder to encode the data; instead it encodes every snippet of data fed to the write method as a compressed block. This is horribly inefficient, and just a terrible design decision for a library designed to work with str... | [
2,
1,
0,
0
] | [] | [] | [
"bzip2",
"gzip",
"python",
"python_2.x"
] | stackoverflow_0003824239_bzip2_gzip_python_python_2.x.txt |
Q:
matplotlib pyplot colorbar question
Dear all, I'm trying to perform a scatter plot with color with an associated color bar. I would like the colorbar to have string values rather than numerical values, as I'm comparing two different data sets each one with different colorvalues (but in any case between a maximum a... | matplotlib pyplot colorbar question | Dear all, I'm trying to perform a scatter plot with color with an associated color bar. I would like the colorbar to have string values rather than numerical values, as I'm comparing two different data sets each one with different colorvalues (but in any case between a maximum and minimum values). Here the code I'm usi... | [
"cbar.ax.set_yticklabels(['Low','High'])\n\nFor example,\nimport numpy as np\nimport matplotlib.cm as cm\nimport matplotlib.pyplot as plt\n\ndata = np.random.random((10, 4))\ndata2 = np.random.random((10, 4))\nplt.subplots_adjust(bottom = 0.1)\nplt.xlabel(r'$\\partial \\Delta/\\partial\\Phi[$mm$/^{\\circ}]$', fonts... | [
11
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0003831569_matplotlib_python.txt |
Q:
Best way to change the value of "settings" from within a Python test case?
I'm writing unit tests in Python for the first time, for a Django app. I've struck a problem. In order to test a particular piece of functionality, I need to change the value of one of the app's settings. Here's my first attempt:
def test_i... | Best way to change the value of "settings" from within a Python test case? | I'm writing unit tests in Python for the first time, for a Django app. I've struck a problem. In order to test a particular piece of functionality, I need to change the value of one of the app's settings. Here's my first attempt:
def test_in_list(self):
mango.settings.META_LISTS = ('tags',)
tags = Document(file... | [
"In models.py, use import mango.settings. You can then set a variable in your test code like you would any other:\nmango.settings.foo = 'bar'\n\nA module is a singleton. You can change the values in its namespace from anywhere in your code.\nBut this won't work if you use from mango.settings import *, since that ex... | [
6,
2,
2,
1
] | [] | [] | [
"django",
"namespaces",
"python",
"unit_testing"
] | stackoverflow_0003830000_django_namespaces_python_unit_testing.txt |
Q:
Printing negative values as hex in python
I have the following code snippet in C++:
for (int x = -4; x < 5; ++x)
printf("hex x %d 0x%08X\n", x, x);
And its output is
hex x -4 0xFFFFFFFC
hex x -3 0xFFFFFFFD
hex x -2 0xFFFFFFFE
hex x -1 0xFFFFFFFF
hex x 0 0x00000000
hex x 1 0x00000001
hex x 2 0x00000002
hex... | Printing negative values as hex in python | I have the following code snippet in C++:
for (int x = -4; x < 5; ++x)
printf("hex x %d 0x%08X\n", x, x);
And its output is
hex x -4 0xFFFFFFFC
hex x -3 0xFFFFFFFD
hex x -2 0xFFFFFFFE
hex x -1 0xFFFFFFFF
hex x 0 0x00000000
hex x 1 0x00000001
hex x 2 0x00000002
hex x 3 0x00000003
hex x 4 0x00000004
If I try th... | [
"You need to explicitly restrict the integer to 32-bits:\nfor x in range(-4,5):\n print \"hex x %d 0x%08X\" % (x, x & 0xffffffff)\n\n"
] | [
19
] | [] | [] | [
"number_formatting",
"python"
] | stackoverflow_0003831833_number_formatting_python.txt |
Q:
Task fanout - how to bulk add Tasks to the Queue - more than 5
I am using a task (queueing-task) to queue multiple others tasks — fanout. When I try to use Queue.add with task argument being a list of Task instances with more than 5 element's and in transaction… I get this error.
JointException: taskqueue.Datasto... | Task fanout - how to bulk add Tasks to the Queue - more than 5 | I am using a task (queueing-task) to queue multiple others tasks — fanout. When I try to use Queue.add with task argument being a list of Task instances with more than 5 element's and in transaction… I get this error.
JointException: taskqueue.DatastoreError caused by:
<class 'google.appengine.api.datastore_error... | [
"One solution close to solving your problem is to add one transactional task that fans-out the remaining tasks. Just add the one fan-out task in your existing transaction.\nUnless there is a business logic reason to do so, do not re-run a task that has already run. Preventing tasks from being re-inserted (i.e. du... | [
2
] | [] | [] | [
"google_app_engine",
"python",
"task_queue"
] | stackoverflow_0003831197_google_app_engine_python_task_queue.txt |
Q:
Focus-follows-mouse in wxPython?
I'm developing an application that contains a number of panes. See the screenshot:
The left settings pane is a wx.ScrolledPanel that contains a number of wx.Panels.
The top events pane is a wx.grid.Grid.
The bottom data pane is a wx.Panel that contains a wx.grid.Grid.
The middle p... | Focus-follows-mouse in wxPython? | I'm developing an application that contains a number of panes. See the screenshot:
The left settings pane is a wx.ScrolledPanel that contains a number of wx.Panels.
The top events pane is a wx.grid.Grid.
The bottom data pane is a wx.Panel that contains a wx.grid.Grid.
The middle plot pane is a wx.Panel containing an ... | [
"This is Windows' behaviour - it works as you expect under GTK. Personally, I'd leave your app as it is, for consistency with other Windows applications, and install WizMouse\n"
] | [
2
] | [] | [] | [
"python",
"wxpython",
"wxwidgets"
] | stackoverflow_0003785938_python_wxpython_wxwidgets.txt |
Q:
How to search the correct directory for imports
I am trying to test some code. The main script requires imports from a number of subdirectories. The structure of the scripts is like this (I edited it to make it clear that dir1 and 2 are subdirectories of build):
build
ascript.py
dir1
script2.py
dir2
... | How to search the correct directory for imports | I am trying to test some code. The main script requires imports from a number of subdirectories. The structure of the scripts is like this (I edited it to make it clear that dir1 and 2 are subdirectories of build):
build
ascript.py
dir1
script2.py
dir2
script3.py
subdir1
script4.py
script... | [
"The commands set PYTHONPATH=C:\\texttool1\\build and dir1\\script2.py should work perfectly. Make sure you\n\ntype them as two commands in the same console (or in one batch script)\nuse the absolute path to the folder containing the modules\n\nMoreover, executable scripts are often written in a way that they must ... | [
1,
0
] | [] | [] | [
"environment_variables",
"path",
"python",
"windows_xp"
] | stackoverflow_0003832114_environment_variables_path_python_windows_xp.txt |
Q:
403 error when trying to run CherryPy behind Apache
I am trying to run CherryPy behind Apache using mod_rewrite, as described in the CherryPy documentation (BehindApache, ModRewrite), and it is not working.
Edit: Earlier, my description of this problem was somewhat inaccurate. It seems like I forgot to restart Apa... | 403 error when trying to run CherryPy behind Apache | I am trying to run CherryPy behind Apache using mod_rewrite, as described in the CherryPy documentation (BehindApache, ModRewrite), and it is not working.
Edit: Earlier, my description of this problem was somewhat inaccurate. It seems like I forgot to restart Apache during some of my attempts. I have revised the questi... | [
"I run CherryPy behind Apache in a very similar way. Apache serves static content itself, and any URLs starting with 'cp' are servied by CherryPy. CherryPy is listening on port 8500. Here's what works for me in httpd.conf:\nRewriteMap escape int:escape\n [...]\nRewriteRule ^/cp\\/(.*) http://localhost:8500/cp/${e... | [
4,
0
] | [] | [] | [
"apache",
"cherrypy",
"python"
] | stackoverflow_0003807711_apache_cherrypy_python.txt |
Q:
Install particular version with easy_install
I'm trying to install lxml. I've had a look at the website, and version 2.2.8 looked reasonable to me but when I did easy_install lxml, it installed version 2.3.beta1 which is not really what I want I presume.
What is the best way to fix this and how can I force easy_in... | Install particular version with easy_install | I'm trying to install lxml. I've had a look at the website, and version 2.2.8 looked reasonable to me but when I did easy_install lxml, it installed version 2.3.beta1 which is not really what I want I presume.
What is the best way to fix this and how can I force easy_install to install a particular version?
(Mac os x 1... | [
"I believe the way to specify a version would be like this:\neasy_install lxml==2.2.8\n\nI (and most other Python users I suspect) stopped using easy_install and started using pip some time ago, so a solution in those terms is:\neasy_install pip\npip install lxml==2.2.8\n\n(pip has several benefits, including an un... | [
142,
18,
7
] | [] | [] | [
"easy_install",
"python",
"version"
] | stackoverflow_0003833011_easy_install_python_version.txt |
Q:
Is there a way to call a function right before a PyQt application ends?
I am collecting usage stats for my applications which include how much each session lasts. However, I can't seem to be able to save this information because None Of the signals I tried yet actually succeeds to call my report_session function. ... | Is there a way to call a function right before a PyQt application ends? | I am collecting usage stats for my applications which include how much each session lasts. However, I can't seem to be able to save this information because None Of the signals I tried yet actually succeeds to call my report_session function.
This are the signals I have already tried:
lastWindowClosed()
aboutToQuit()... | [
"The method that Mark Byers posted will run after the main widget has been closed, meaning that its controls will no longer be available. \nIf you need to work with any values from controls on your form, you will want to capture the close event and do your work there:\nclass MainWidget(QtGui.QWidget):\n\n #...\n... | [
8,
5,
5,
1
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"signals_slots",
"user_interface"
] | stackoverflow_0003832880_pyqt_pyqt4_python_signals_slots_user_interface.txt |
Q:
How can I retrieve a Google Talk users Status Message
I'd like to be able to retrieve a users Google Talk Status Message with Python, it's really hard to find documentation on how to use some of the libraries out there.
A:
I don't have anything to hand with xmpp installed, but here's some old code I had lying ar... | How can I retrieve a Google Talk users Status Message | I'd like to be able to retrieve a users Google Talk Status Message with Python, it's really hard to find documentation on how to use some of the libraries out there.
| [
"I don't have anything to hand with xmpp installed, but here's some old code I had lying around that might help you. You'll want to update the USERNAME/PASSWORD to your own values for test purposes.\nThings to note: users logged in to Google Talk get a random presence string on their userid: that doesn't matter if ... | [
0
] | [] | [] | [
"google_talk",
"python",
"xmpp"
] | stackoverflow_0003831641_google_talk_python_xmpp.txt |
Q:
Python IMAP call
I am using the imap library to access my unread messages on gmail and to print out the subjects, is there a way to make sure that the messages being read are still tagged as unread.
Thanks
A:
Use PEEK instead. For example, something like:
typ, data = imap_conn.fetch(uid, '(BODY.PEEK[TEXT])')
A... | Python IMAP call | I am using the imap library to access my unread messages on gmail and to print out the subjects, is there a way to make sure that the messages being read are still tagged as unread.
Thanks
| [
"Use PEEK instead. For example, something like:\ntyp, data = imap_conn.fetch(uid, '(BODY.PEEK[TEXT])')\n\n",
"For info, Yours is an inverse question of this one\n\nParse Gmail with Python and mark all older than date as \"read\"\n\nUse peek, so that you do not affect the message.\nBut you should also be able to ... | [
3,
1
] | [] | [] | [
"email",
"imap",
"python"
] | stackoverflow_0003833428_email_imap_python.txt |
Q:
Python: numpy and matplotlib anomaly
This is the first time I am using matplotlib and numpy.
Here goes the problem:
If I goto python cli, the intended code works fine. Here is that code
>>> from numpy import *
>>> y = array([1,2])
>>> y = append(y, y[len(y) - 1]+1)
>>> y
array([1, 2, 3])
But if I use it with matp... | Python: numpy and matplotlib anomaly | This is the first time I am using matplotlib and numpy.
Here goes the problem:
If I goto python cli, the intended code works fine. Here is that code
>>> from numpy import *
>>> y = array([1,2])
>>> y = append(y, y[len(y) - 1]+1)
>>> y
array([1, 2, 3])
But if I use it with matplotlib in a script I get this error.
line ... | [
"When you assign to a variable inside a function, python creates a new variable that has local scope, and this new variable also hides the global variable.\nSo, the x and y inside onkeypress are local to the function. Hence, from python's point of view, they are uninitialized, and hence the error.\nAs GWW points ou... | [
3,
2,
2
] | [] | [] | [
"matplotlib",
"numpy",
"python"
] | stackoverflow_0003833717_matplotlib_numpy_python.txt |
Q:
What's BLUE from CCP Stackless presentations?
In Stackless Python in Eve, there is some talk about "BLUE" objects in Python.
Does anyone know details about this technology?
A:
It's a codename for a framework CCP probably developed internally for EVE Online. EVE Online installations come with blue.dll. There is a... | What's BLUE from CCP Stackless presentations? | In Stackless Python in Eve, there is some talk about "BLUE" objects in Python.
Does anyone know details about this technology?
| [
"It's a codename for a framework CCP probably developed internally for EVE Online. EVE Online installations come with blue.dll. There is a python API to it (import blue).\nDigging into blue.dll reveals:\nDescription: CCP Blue Framework\n$ strings blue.dll | egrep \"python|Py\" | less\nBlueObjectBuilderPython\nBlueE... | [
3
] | [] | [] | [
"python",
"stackless"
] | stackoverflow_0003831954_python_stackless.txt |
Q:
Forcing an interrupt between threads through a singleton object (academic)
I'm sure this is not a very pythonic situation. But I'm not actually using this in any production code, I'm just considering how (if?) this could work. It doesn't have to be python specific, but I'd like a solution that at least WORKS withi... | Forcing an interrupt between threads through a singleton object (academic) | I'm sure this is not a very pythonic situation. But I'm not actually using this in any production code, I'm just considering how (if?) this could work. It doesn't have to be python specific, but I'd like a solution that at least WORKS within python framework.
Basically, I have a thread safe singleton object that implem... | [
"In Python, there is a somewhat undocumented way of raising an exception in another thread, though there are some caveats. See this recipe for \"killable threads\":\nhttp://code.activestate.com/recipes/496960-thread2-killable-threads/\nhttp://sebulba.wikispaces.com/recipe+thread2\n"
] | [
1
] | [] | [] | [
"multithreading",
"python",
"singleton"
] | stackoverflow_0003833659_multithreading_python_singleton.txt |
Q:
Using a try/catch to retry the same method
I have a class whose methods require that a certain class field exists correctly. That class field is set in the constructor and it's read from a config file, and it may or may not get the correct data from that config file. If the data is incorrect, it will have the wron... | Using a try/catch to retry the same method | I have a class whose methods require that a certain class field exists correctly. That class field is set in the constructor and it's read from a config file, and it may or may not get the correct data from that config file. If the data is incorrect, it will have the wrong data in the class field and the class method w... | [
"I'm a bit surprised that you don't want the MyClass instance to stick around for later use, but, given that this is your intention, your code is correct and concise -- it does what you state you want without any \"obvious flaw\". I'm not sure which objects you think ugly and which ones you think pretty, but witho... | [
3,
1,
0
] | [] | [] | [
"exception",
"exception_handling",
"python"
] | stackoverflow_0003833378_exception_exception_handling_python.txt |
Q:
testing for numeric equality when variable is modified inside loop
I am new to python and I was writing something like:
t = 0.
while t<4.9:
t = t + 0.1
if t == 1.:
... do something ...
I noticed that the if statement was never being executed. So I modified the code to look like this:
''' Ca... | testing for numeric equality when variable is modified inside loop | I am new to python and I was writing something like:
t = 0.
while t<4.9:
t = t + 0.1
if t == 1.:
... do something ...
I noticed that the if statement was never being executed. So I modified the code to look like this:
''' Case a'''
t = 0.
while t<4.9:
t = t + 0.1
print(t)
print(t == 5.... | [
"The problem is that binary floating point arithmetic is not precise so you will get small errors in the calculations. In particular the number 0.1 has no exact binary representation. When you calculate using floating point numbers the very small errors cause the result to be slightly incorrect from what you might ... | [
7,
4
] | [] | [] | [
"floating_point",
"python"
] | stackoverflow_0003834253_floating_point_python.txt |
Q:
pygtk: What class should my custom widgets inherit from?
When making a custom widget in pygtk, what class should it inherit from? I want to be able to put the widget inside other widgets, but I don't want other people to put stuff in mine. Usually I make my widgets inherit from gtk.HBox or gtk.VBox, and that works... | pygtk: What class should my custom widgets inherit from? | When making a custom widget in pygtk, what class should it inherit from? I want to be able to put the widget inside other widgets, but I don't want other people to put stuff in mine. Usually I make my widgets inherit from gtk.HBox or gtk.VBox, and that works fine, but it is possible then for someone to do a pack_start(... | [
"If your custom widget contains other (probably standard) widgets, you could simply raise an exception in the overridden pack_ methods. That way, nobody can put stuff in it (easily). Inside your class, you then have to use super(...).pack_xxx instead of self.pack_xxx.\nBut it's probably better to derive from gtk.Co... | [
0
] | [] | [] | [
"gtk",
"inheritance",
"pygtk",
"python"
] | stackoverflow_0003834570_gtk_inheritance_pygtk_python.txt |
Q:
Python - what is the accepted money calculation technique?
Take the following example:
>>> from decimal import Decimal
>>> nrml_price = Decimal('0.59')
>>> discounted = nrml_price / 3 # Taking 2/3 off the price with a coupon
Decimal('0.1966666666666666666666666667') # Customers don't have fractions of a penny
>>... | Python - what is the accepted money calculation technique? | Take the following example:
>>> from decimal import Decimal
>>> nrml_price = Decimal('0.59')
>>> discounted = nrml_price / 3 # Taking 2/3 off the price with a coupon
Decimal('0.1966666666666666666666666667') # Customers don't have fractions of a penny
>>> (nrml_price / 3).quantize(D('0.00')) # So I quantize to get 2... | [
"\"is there an accepted way to do this sort of thing\"\nYes. Accountants do it all the time.\nIndeed COBOL does this really well.\nThe Python decimal package has a bunch of rounding options that you set in the context. Almost always the decimal.ROUND_HALF_DOWN or decimal.ROUND_HALF_EVEN options are what you want ... | [
8,
5
] | [] | [] | [
"concurrency",
"currency",
"python"
] | stackoverflow_0003834657_concurrency_currency_python.txt |
Q:
Python: Compare dict with a static reference?
I have to check if a dictionary is the same as it was yesterday, if it has changed.
In PHP I could have serialized an array and compared the resulting strings from yesterday and today. However, I don't know how to do it in Py. I've read a little about Pickle and maybe ... | Python: Compare dict with a static reference? | I have to check if a dictionary is the same as it was yesterday, if it has changed.
In PHP I could have serialized an array and compared the resulting strings from yesterday and today. However, I don't know how to do it in Py. I've read a little about Pickle and maybe it could be done with md5 somehow?
So basically I n... | [
"The problem with dictionaries is their undefined order. You must make sure you always get the same result of equal dictionaries (if you want to compare them as strings).\nYou could do it in multiple ways:\n1) Python hash (only for checking equality; hash implementation might be specific to the Python version!)\npr... | [
4,
1,
0,
0,
0,
0
] | [] | [] | [
"compare",
"dictionary",
"google_app_engine",
"python"
] | stackoverflow_0003834571_compare_dictionary_google_app_engine_python.txt |
Q:
Tornado Web Framework Mysql connection handling
I have recently been exploring the Tornado web framework to serve a lot of consistent connections by lots of different clients.
I have a request handler that basically takes an RSA encrypted string and decrypts it. The decrypted text is an XML string that gets parse... | Tornado Web Framework Mysql connection handling | I have recently been exploring the Tornado web framework to serve a lot of consistent connections by lots of different clients.
I have a request handler that basically takes an RSA encrypted string and decrypts it. The decrypted text is an XML string that gets parsed by a SAX document handler that I have written. Eve... | [
"An SQL connection should not take 5 seconds. Try to not issue a query and see if that improves your performance - which it should.\nThe Mysqldb module has a threadsafety of \"1\", which means the module is thread safe, but connections cannot be shared amongst threads. You can implement a connection pool as an alte... | [
1,
1,
0
] | [] | [] | [
"mysql",
"persistent_connection",
"python",
"time",
"tornado"
] | stackoverflow_0001920012_mysql_persistent_connection_python_time_tornado.txt |
Q:
Can PHP be more like python?
Possible Duplicate:
Does PHP have an equivalent to Python's list comprehension syntax?
Does PHP have any equivalent of the simple and awesome list comprehension in python? Specifically, can I do a = [x for x in xrange(1,20)] in PHP w/o annoying loops?
A:
I think this will set you f... | Can PHP be more like python? |
Possible Duplicate:
Does PHP have an equivalent to Python's list comprehension syntax?
Does PHP have any equivalent of the simple and awesome list comprehension in python? Specifically, can I do a = [x for x in xrange(1,20)] in PHP w/o annoying loops?
| [
"I think this will set you free: http://code.google.com/p/php-lc/\n",
"Correct me if I'm wrong, but isn't the python 'x for x in xrange' a loop?\n",
"$a = range(1,19);\n\n"
] | [
2,
0,
0
] | [] | [] | [
"php",
"python"
] | stackoverflow_0003834281_php_python.txt |
Q:
How to use mod_passenger for Turbogears 2?
What do I put in passenger_wsgi.py for a Turbogears2 site?
Since it's possible for Django to use mod_passenger, I'm trying to use mod_passenger with Turbogears2. So far, I've found a passenger_wsgi.py for Turbogears1, but I don't know where to start to make a passenger_w... | How to use mod_passenger for Turbogears 2? | What do I put in passenger_wsgi.py for a Turbogears2 site?
Since it's possible for Django to use mod_passenger, I'm trying to use mod_passenger with Turbogears2. So far, I've found a passenger_wsgi.py for Turbogears1, but I don't know where to start to make a passenger_wsgi.py for a Turbogears2 site.
Here's the Turbog... | [
"I think the right question would be: how to write a WSGI file for Turbogears 2. If you have a WSGI file that works on other WSGI-compliant servers like mod_wsgi or Green Unicorn then it should work on Phusion Passenger as well.\n"
] | [
0
] | [] | [] | [
"passenger",
"python",
"turbogears",
"turbogears2"
] | stackoverflow_0003757740_passenger_python_turbogears_turbogears2.txt |
Q:
Python class-dependent template?
i want to create a widget depending on the class of the object, is there a simple way to do that in mako? for example
class A might have attributes A and B
while
class B might have attributes A, B and C
is there a pattern for this?
i want to make a super class that they but inheri... | Python class-dependent template? | i want to create a widget depending on the class of the object, is there a simple way to do that in mako? for example
class A might have attributes A and B
while
class B might have attributes A, B and C
is there a pattern for this?
i want to make a super class that they but inherit, but if I have a function print and ... | [
"Make a method which returns [a, b] in class A and [a, b, c] in class B.\nThen you can do: \n% for stuff in thing.return_list_of_stuff:\n <div>${stuff}</div>\n% endfor\n\n(I've never used mako, so the syntax might be incorect.)\n"
] | [
1
] | [] | [] | [
"mako",
"python",
"templates"
] | stackoverflow_0003835116_mako_python_templates.txt |
Q:
Python, using subprocess.Popen to make linux command line call? I'm getting "[Errno 2] No such file or directory"
I'm trying to follow the info I can find about subprocess.Popen as I want to make a linux command line call.. I am trying as below but am getting the error "[Errno 2] No such file or directory". I'm n... | Python, using subprocess.Popen to make linux command line call? I'm getting "[Errno 2] No such file or directory" | I'm trying to follow the info I can find about subprocess.Popen as I want to make a linux command line call.. I am trying as below but am getting the error "[Errno 2] No such file or directory". I'm not trying to open a file so I don't understand this error, and it works fine (although with other issues relating to wa... | [
"import subprocess \nproc=subprocess.Popen(['ls','-l']) # <-- Change the command here\nproc.communicate()\n\nPopen expects a list of strings. The first string is typically the program to be run, followed by its arguments. Sometimes when the command is complicated, it's convenient to use shlex.split to compose t... | [
17
] | [] | [] | [
"command_line",
"popen",
"python",
"subprocess"
] | stackoverflow_0003835400_command_line_popen_python_subprocess.txt |
Q:
Flatten a dictionary of dictionaries (2 levels deep) of lists
I'm trying to wrap my brain around this but it's not flexible enough.
In my Python script I have a dictionary of dictionaries of lists. (Actually it gets a little deeper but that level is not involved in this question.) I want to flatten all this into o... | Flatten a dictionary of dictionaries (2 levels deep) of lists | I'm trying to wrap my brain around this but it's not flexible enough.
In my Python script I have a dictionary of dictionaries of lists. (Actually it gets a little deeper but that level is not involved in this question.) I want to flatten all this into one long list, throwing away all the dictionary keys.
Thus I want to... | [
"I hope you realize that any order you see in a dict is accidental -- it's there only because, when shown on screen, some order has to be picked, but there's absolutely no guarantee.\nNet of ordering issues among the various sublists getting catenated,\n[x for d in thedict.itervalues()\n for alist in d.itervalues... | [
19,
6,
6
] | [] | [] | [
"data_structures",
"dictionary",
"mapreduce",
"python"
] | stackoverflow_0003835192_data_structures_dictionary_mapreduce_python.txt |
Q:
Python line remover
Hi I have a large file that I want to delete the lines that contain the text ALL and print the file without spaces with just the remaining lines. I started a program
sourcefile = open('C:\\scoresfinal.txt', 'r')
filename2 = open('C:\\nohet.txt', 'w')
offending = ["HET"]
def fixup( filename ):... | Python line remover | Hi I have a large file that I want to delete the lines that contain the text ALL and print the file without spaces with just the remaining lines. I started a program
sourcefile = open('C:\\scoresfinal.txt', 'r')
filename2 = open('C:\\nohet.txt', 'w')
offending = ["HET"]
def fixup( filename ):
fin = open( filenam... | [
"sourcefile = open('C:\\\\scoresfinal.txt', 'r')\n\ndefines sourcefile as a file object. So \nfixup(sourcefile)\n\nassigns sourcefile to be the value of the local variable filename in the fixup function.\nCalling open(filename) thus tries to open an already-open file object, when open expected a string naming a fil... | [
1,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0003834949_python.txt |
Q:
python kata problem: Color not working
When I try to run the python koans, I don't get the colors, instead I get the ANSI color codes. I want to get the colors. It seems to be using colorama under the hood. I try to run colorama sample code in the interpeter and get syntax errors and/or assert errors.
Second if c... | python kata problem: Color not working | When I try to run the python koans, I don't get the colors, instead I get the ANSI color codes. I want to get the colors. It seems to be using colorama under the hood. I try to run colorama sample code in the interpeter and get syntax errors and/or assert errors.
Second if can't fix first: How do I get to strip out th... | [
"Sorry about that!\nThe ansi colors are a very recent feature, and I haven't got around to adding a command line option to turn it off yet. Its coming very soon though!\nIn the meantime taking a slightly older version would get around the problem. Here's how you can do it through mercurial:\nhg clone https://gregma... | [
0
] | [] | [] | [
"ansi_colors",
"python"
] | stackoverflow_0003814714_ansi_colors_python.txt |
Q:
Wrong output in Python - as per my logic
Can someone tell me why my program is working weird. I am trying to sort list1 in ascending order. This code is part of my quick sort program I am trying to write. As per my logic which I am applying in this code, and I checked manually too, the output should be [1,2,3,4,5]... | Wrong output in Python - as per my logic | Can someone tell me why my program is working weird. I am trying to sort list1 in ascending order. This code is part of my quick sort program I am trying to write. As per my logic which I am applying in this code, and I checked manually too, the output should be [1,2,3,4,5]. However the output is coming out to be [1,2,... | [
"Since you do count = count + 1 right before the innermost for, you never get to reach the first position of list1 (list1[0]), which is the element \"3\". \n[Edit] Looking more carefully at your code, there seems to be a lot of confusion. For instance, on\n list1[position1]=list1[position2]\n list1[po... | [
4,
2,
0
] | [] | [] | [
"list",
"python",
"quicksort"
] | stackoverflow_0003834378_list_python_quicksort.txt |
Q:
Rewriting An URL With Regular Expression Substitution in Routes
In my Pylons app, some content is located at URLs that look like http://mysite/data/31415. Users can go to that URL directly, or search for "31415" via the search page. My constraints, however, mean that http://mysite/data/000031415 should go to the... | Rewriting An URL With Regular Expression Substitution in Routes | In my Pylons app, some content is located at URLs that look like http://mysite/data/31415. Users can go to that URL directly, or search for "31415" via the search page. My constraints, however, mean that http://mysite/data/000031415 should go to the same page as the above, as should searches for "0000000000031415." ... | [
"You can actually do that via conditional functions, since they let you modify the variables from the URL in place. \n",
"I know I am cheating by introducing a different routing library, since I haven't used Routes, but here's how this is done with Werkzeug's routing package. It lets you specify that a given fra... | [
1,
0
] | [] | [] | [
"pylons",
"python",
"routes"
] | stackoverflow_0002464844_pylons_python_routes.txt |
Q:
How do I specify a range of unicode characters
How do I specify a range of unicode characters from ' ' (space) to \u00D7FF?
I have a regular expression like r'[\u0020-\u00D7FF]' and it won't compile saying that it's a bad range. I am new to Unicode regular expressions so I haven't had this problem before.
Is ther... | How do I specify a range of unicode characters | How do I specify a range of unicode characters from ' ' (space) to \u00D7FF?
I have a regular expression like r'[\u0020-\u00D7FF]' and it won't compile saying that it's a bad range. I am new to Unicode regular expressions so I haven't had this problem before.
Is there a way to make this compile or a regular expression... | [
"The syntax of your unicode range will not do what you expect.\n\nThe raw r'' string prevents \\u escapes from being parsed, and the regex engine will not do this. The only range in this set is [0-\\]:\n>>> re.compile(r'[\\u0020-\\u00d7ff]', re.DEBUG)\nin\n literal 117\n literal 48\n literal 48\n literal 50\n ... | [
34,
5
] | [] | [] | [
"python",
"regex",
"unicode"
] | stackoverflow_0003835917_python_regex_unicode.txt |
Q:
Toplevel widgets in Tkinter
I have a Toplevel widget I'd like it so that it would never appear within the confines of the main Tk window. Basically so that when the Toplevel appears it doesn't cover up any of the main Tk window.
A:
You want to use wm_geometry and a tiny bit of math to calculate and set a suita... | Toplevel widgets in Tkinter | I have a Toplevel widget I'd like it so that it would never appear within the confines of the main Tk window. Basically so that when the Toplevel appears it doesn't cover up any of the main Tk window.
| [
"You want to use wm_geometry and a tiny bit of math to calculate and set a suitable starting position for the second toplevel.\n",
"You could just set up a separate toplevel, cf:\nself.newwindow = Toplevel(self)\nself.newwindow.title('New Window')\n\nand then embed the widget in the separate toplevel. \n"
] | [
1,
0
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0003836086_python_tkinter.txt |
Q:
Finding the character occupying a particular index in a string
I have a the string 'Hello', I need to find out what characters occupy which indexes.
Pseudo-code:
string = 'Hello'
a = string.index(0)
b = string.index(4)
print a , b
a would be 'H' and b would be 'o'.
A:
a = "Hello"
print a[0]
print a[4]
A:
Str... | Finding the character occupying a particular index in a string | I have a the string 'Hello', I need to find out what characters occupy which indexes.
Pseudo-code:
string = 'Hello'
a = string.index(0)
b = string.index(4)
print a , b
a would be 'H' and b would be 'o'.
| [
"a = \"Hello\"\nprint a[0]\nprint a[4]\n\n",
"String (str) in Python is a sequence type, and thus can be accessed with []:\nmy_string = 'Hello'\n\na = my_string[0]\nb = my_string[4]\n\nprint a, b # Prints H o\n\nThis means it also supports slicing, which is the standard way to get a substring in Python:\nprint my... | [
4,
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0003835861_python.txt |
Q:
Swapping token values in a string through regex
I have tokenized names (strings), with the tokens separated by underscores, which will always contain a "side" token by the value of M, L, or R.
The presence of that value is guaranteed to be unique (no repetitions or dangers that other tokens might get similar value... | Swapping token values in a string through regex | I have tokenized names (strings), with the tokens separated by underscores, which will always contain a "side" token by the value of M, L, or R.
The presence of that value is guaranteed to be unique (no repetitions or dangers that other tokens might get similar values).
In example:
foo_M_bar_type
foo_R_bar_type
foo_L_b... | [
"This answer [ab]uses the replacement function:\n>>> s = \"foo_M_bar_type foo_R_bar_type foo_L_bar_type\"\n>>> import re\n>>> re.sub(\"_[LR]_\", lambda m: {'_L_':'_R_','_R_':'_L_'}[m.group()], s)\n'foo_M_bar_type foo_L_bar_type foo_R_bar_type'\n>>>\n\n"
] | [
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0003836335_python_regex.txt |
Q:
Two Tkinter Questions
Is it possible to change the color of certain particular bits of text in the entry widget, or does it all have to be the same color?
Is it possible to change the Tk logo in the top right to a different image?
A:
1) No, you cannot change the color of just a part of the text in an entry wid... | Two Tkinter Questions | Is it possible to change the color of certain particular bits of text in the entry widget, or does it all have to be the same color?
Is it possible to change the Tk logo in the top right to a different image?
| [
"1) No, you cannot change the color of just a part of the text in an entry widget. If you need to do that you can use a Text widget. \nFrom effbot, the best tkinter reference on the web:\n\nWhen to use the Entry Widget\nThe entry widget is used to enter text strings. This widget allows the user to enter one line of... | [
3
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0003836625_python_tkinter.txt |
Q:
pyapns - hexlified_token_str
i try to test pyapns.
There is a mention of the hexlified_token_str in the documentation.
My token is stored in base64 format.
I try to do this
>>> notify('myapp', base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='), {'aps':{'alert': 'Hello!'}})
But I'm wrong.
Tracebac... | pyapns - hexlified_token_str | i try to test pyapns.
There is a mention of the hexlified_token_str in the documentation.
My token is stored in base64 format.
I try to do this
>>> notify('myapp', base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='), {'aps':{'alert': 'Hello!'}})
But I'm wrong.
Traceback (most recent call last):
File ... | [
"It was too late yesterday ...\nIt did the job :\nbinascii.hexlify(base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='))\n\nIt was just an obsolete token !\n"
] | [
1
] | [] | [] | [
"apple_push_notifications",
"python"
] | stackoverflow_0003833988_apple_push_notifications_python.txt |
Q:
unit testing a python function which invokes a vim subprocess
I've written a function which opens a vim editor with the given filename when called.. How can I do the unittest of these types of operations....
A:
To unit test something like this you must mock/stub out your dependencies. In this case lets say you ... | unit testing a python function which invokes a vim subprocess | I've written a function which opens a vim editor with the given filename when called.. How can I do the unittest of these types of operations....
| [
"To unit test something like this you must mock/stub out your dependencies. In this case lets say you are launching vim by calling os.system(\"vim\").\nIn your unit test you can stub out that function call doing something like:\ndef launchVim():\n os.system(\"vim\")\n\ndef testThatVimIsLaunched():\n try:\n ... | [
6,
5
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0003836411_python_unit_testing.txt |
Q:
django python: How to use the source instead of the egg?
I was having some issues with a Django app called "django-categories"
The developer told me to use the source instead of the egg.
How do I do that?
A:
On the github page you link to, there's a "download source" link. Use that to download a zip or tar arch... | django python: How to use the source instead of the egg? | I was having some issues with a Django app called "django-categories"
The developer told me to use the source instead of the egg.
How do I do that?
| [
"On the github page you link to, there's a \"download source\" link. Use that to download a zip or tar archive, then unzip it and make sure that the \"categories\" directory is in your PYTHONPATH.\n",
"Just copy the categories directory to your project directory(where all your other apps go) and add it to instal... | [
1,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003837008_django_python.txt |
Q:
Updating sitemap from django to google webmaster doesn't work
Our website gets updated almost everyday. We need to update the sitemap to the google webmasters every time there are new pages added.
We have tried using ping_google() along with the required set of arguments and google and it never seem to update the... | Updating sitemap from django to google webmaster doesn't work | Our website gets updated almost everyday. We need to update the sitemap to the google webmasters every time there are new pages added.
We have tried using ping_google() along with the required set of arguments and google and it never seem to update the sitemap on webmasters. To log the response, we re-wrote the functi... | [
"Can you post the link to your sitemaps file. \nIf you have set priority for most of the URL's in your sitemap high, google might think it's kind of spamming and will not bother to download sitemap. \nAlso check the change frequency in your sitemap.\nIf your sitemap is fine and content really changes everyday, goog... | [
0
] | [] | [] | [
"django",
"google_search_console",
"python",
"sitemap",
"urllib"
] | stackoverflow_0003836529_django_google_search_console_python_sitemap_urllib.txt |
Q:
Continous loop and exiting in python
I have a script that runs continuously when invoked and every 5 minutes checks my gmail inbox. To get it to run every 5 minutes I am using the time.sleep() function. However I would like user to end the script anytime my pressing q, which it seems cant be done when using time.s... | Continous loop and exiting in python | I have a script that runs continuously when invoked and every 5 minutes checks my gmail inbox. To get it to run every 5 minutes I am using the time.sleep() function. However I would like user to end the script anytime my pressing q, which it seems cant be done when using time.sleep(). Any suggestions on how i can do th... | [
"You can use select() on sys.stdin combined with a timeout. Roughly speaking, your main loop will look like this (untested):\nwhile True:\n r,w,e = select.select([sys.stdin], [], [], 600)\n if sys.stdin in r: # data available on sys.stdin\n if sys.stdin.read() == 'q':\n break\n # do gmail... | [
3,
1,
0
] | [] | [] | [
"continuous",
"python"
] | stackoverflow_0003836620_continuous_python.txt |
Q:
"SyntaxError: unexpected EOF while parsing" when using input()
I have 2 Python scripts which are main_menu.py and inputip.py.
The problem occurs when I press "enter" to be redirected to main_menu.py when my function finishes in inputip.py. The script does not allow me to redirect to main_menu.py instead it shows t... | "SyntaxError: unexpected EOF while parsing" when using input() | I have 2 Python scripts which are main_menu.py and inputip.py.
The problem occurs when I press "enter" to be redirected to main_menu.py when my function finishes in inputip.py. The script does not allow me to redirect to main_menu.py instead it shows this error on the Windows command prompt:
Traceback (most recent call... | [
"Unless you are using python 3.x (but your question is not tagged as such), don't use input. Use raw_input in stead. It will return strings, so convert them to int first, or do a string comparison. E.g.\nx = raw_input(\"Choice\")\nif x == '1': \n do_this()\n\n"
] | [
1
] | [] | [] | [
"input",
"python",
"python_2.x",
"syntax_error"
] | stackoverflow_0003837546_input_python_python_2.x_syntax_error.txt |
Q:
Is there a way to use the java browsing perspective of eclipse for python?
I'd like to use the browsing perspective ("column view") of eclipse for Python development. Is there a way to do this?
A:
please look http://www.pydev.org
| Is there a way to use the java browsing perspective of eclipse for python? | I'd like to use the browsing perspective ("column view") of eclipse for Python development. Is there a way to do this?
| [
"please look http://www.pydev.org\n"
] | [
2
] | [] | [] | [
"eclipse",
"perspective",
"python"
] | stackoverflow_0003837456_eclipse_perspective_python.txt |
Q:
PHP HTTP server? Ports 80, 443-444, 1000-3000, 8000-9000. (No-Apache)
I will upgrading to Linux Debian 6.0 "Squeeze" on the server soon and I want to know how I can use Python as a web-server on many ports dedicated for different things..
Ports Directory Description
80, 443 /var/www/s... | PHP HTTP server? Ports 80, 443-444, 1000-3000, 8000-9000. (No-Apache) | I will upgrading to Linux Debian 6.0 "Squeeze" on the server soon and I want to know how I can use Python as a web-server on many ports dedicated for different things..
Ports Directory Description
80, 443 /var/www/sitegen/ Take all domains and generate a site from the SQL DB
444, 1000-30... | [
"This isn't a PHP question as the PHP interpreter doesn't directly listen on ports. On Linux, it will (usually) run inside Apache. Apache can be configured to listen to multiple ports, and even on a per-virtual host basis.\nAlso, be aware that the nature of HTTPS makes it impossible for multiple virtual hosts to us... | [
2,
0
] | [] | [] | [
"apache",
"debian_based",
"php",
"ports",
"python"
] | stackoverflow_0003836631_apache_debian_based_php_ports_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.