content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
how to password protect a website hosted on gunicorn
Is there a way to password protect an application which is hosted in gunicorn,
I did this with .htaccess in apache, but can we do this in gurnicorn?
A:
You tagged django and it has some useful things built right into it...
You should be able to do a @login_r... | how to password protect a website hosted on gunicorn | Is there a way to password protect an application which is hosted in gunicorn,
I did this with .htaccess in apache, but can we do this in gurnicorn?
| [
"You tagged django and it has some useful things built right into it... \nYou should be able to do a @login_required right before your specific view funciton.\nThis will force the current 'anonymous' user to a login screen if they aren't logged in.\n",
"You can also use middleware and for example kill every sess... | [
1,
1
] | [] | [] | [
"django",
"gunicorn",
"python"
] | stackoverflow_0008341797_django_gunicorn_python.txt |
Q:
Facing issue while writing data into a file in python script
I have to write 7231 bytes into a file using python script. In a client-server program, my python script act like client and it received 7231 bytes from server. If I check in TCP-Dump, its shows complete data. But when I try to write into a file; I am mi... | Facing issue while writing data into a file in python script | I have to write 7231 bytes into a file using python script. In a client-server program, my python script act like client and it received 7231 bytes from server. If I check in TCP-Dump, its shows complete data. But when I try to write into a file; I am missing the content.
My script:
def SendOnce(self, req='/gpsData=... | [
"First of all, 7231 bytes is not exactly huge...\nWith the limited info you gave, I would guess that you might have forgotten to take the OS's write buffer into account. You probably try to read the file before all the content was written to it.\nPython generally uses the system's standard buffer (you can change th... | [
3,
0
] | [] | [] | [
"python",
"string"
] | stackoverflow_0008341358_python_string.txt |
Q:
Python ast to dot graph
I'm analyzing the AST generated by python code for "fun and profit", and I would like to have something more graphical than "ast.dump" to actually see the AST generated.
In theory is already a tree, so it shouldn't be too hard to create a graph, but I don't understand how I could do it.
ast... | Python ast to dot graph | I'm analyzing the AST generated by python code for "fun and profit", and I would like to have something more graphical than "ast.dump" to actually see the AST generated.
In theory is already a tree, so it shouldn't be too hard to create a graph, but I don't understand how I could do it.
ast.walk seems to walk with a BF... | [
"Fantastic, it works and it's really simple\nclass AstGraphGenerator(object):\n\n def __init__(self):\n self.graph = defaultdict(lambda: [])\n\n def __str__(self):\n return str(self.graph)\n\n def visit(self, node):\n \"\"\"Visit a node.\"\"\"\n method = 'visit_' + node.__class_... | [
8,
6
] | [] | [] | [
"abstract_syntax_tree",
"grammar",
"python"
] | stackoverflow_0008340567_abstract_syntax_tree_grammar_python.txt |
Q:
Need to find the relative frequencies
Cannot find out why this is not working?:
def frequencies(counts):
total = sum(counts)
frequencies = []
for count in counts:
frequencies.append(float(count/total))
return frequencies
It should take a list of intergers as argument and return... | Need to find the relative frequencies | Cannot find out why this is not working?:
def frequencies(counts):
total = sum(counts)
frequencies = []
for count in counts:
frequencies.append(float(count/total))
return frequencies
It should take a list of intergers as argument and return a list of relative frequencies.
| [
"That is because sum() returns an integer and hence you are doing integer division.\nUse \ntotal = float(sum(counts))\n\ninstead or \nfrequencies.append(count/float(total))\n\n",
"If I correctly understand the task, the code should count the frequencies of the numbers met in the list.\nI'd suggest this solution:\... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0008342207_python.txt |
Q:
Error in paster setup-app development.ini?
I am trying to install MediaCore on my machine running CentOS as soon as I fire this coomand
on command prompt it gives me an error
[root@localhost mediacore-mediacore-e6e7419]# paster setup-app development.ini Traceback (most recent call last):
File "/usr/bin/paster"... | Error in paster setup-app development.ini? | I am trying to install MediaCore on my machine running CentOS as soon as I fire this coomand
on command prompt it gives me an error
[root@localhost mediacore-mediacore-e6e7419]# paster setup-app development.ini Traceback (most recent call last):
File "/usr/bin/paster", line 7, in ?
sys.exit( File "/usr/lib/pyth... | [
"The with statement only appeared in python2.5, and you're using python2.4. It looks that Beaker is not really compatible with python2.4.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0008342397_python.txt |
Q:
Xpath vs DOM vs BeautifulSoup vs lxml vs other Which is the fastest approach to parse a webpage?
I know how to parse a page using Python. My question is which is the fastest method of all parsing techniques, how fast is it from others?
The parsing techniques I know are Xpath, DOM, BeautifulSoup, and using the find... | Xpath vs DOM vs BeautifulSoup vs lxml vs other Which is the fastest approach to parse a webpage? | I know how to parse a page using Python. My question is which is the fastest method of all parsing techniques, how fast is it from others?
The parsing techniques I know are Xpath, DOM, BeautifulSoup, and using the find method of Python.
| [
"http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/\n\n",
"lxml was written on C. And if you use x86 it is best chose.\nIf we speak about techniques there is no big difference between Xpath and DOM - it's very quickly methods. But if you will use find or findAll in BeautifulSoup it will be slow... | [
10,
1
] | [] | [] | [
"dom",
"html_parsing",
"lxml",
"python",
"xpath"
] | stackoverflow_0008342335_dom_html_parsing_lxml_python_xpath.txt |
Q:
ml-py svm converges but classifying wrongly
I am trying to do some classification task with python and SVM.
From collected data I extracted the feature vectors for each class and created a training set. The feature vectors have n-dimensions(39 or more). So, say for 2 classes I have a set of 39-d feature vectors a... | ml-py svm converges but classifying wrongly | I am trying to do some classification task with python and SVM.
From collected data I extracted the feature vectors for each class and created a training set. The feature vectors have n-dimensions(39 or more). So, say for 2 classes I have a set of 39-d feature vectors and a single array of class labels corresponding t... | [
"I don't use mlpy, but np.ones((1,len(featurevector1)) should perhaps be just np.ones(len(featurevector1)) --\nprint .shape of each to see the difference.\n(If you have a link to public data anything like yours, could you post it please ?)\n"
] | [
0
] | [] | [] | [
"classification",
"libsvm",
"machine_learning",
"python",
"svm"
] | stackoverflow_0008284890_classification_libsvm_machine_learning_python_svm.txt |
Q:
Python Tkinter scrollbox
I have the following code and keep getting the error:
AttributeError: 'NoneType' object has no attribute 'curselection'
I tried changing items to simple text messages instead of items from an array, but that didn't work. So I don't know how to fix this. I think that there's some kind of... | Python Tkinter scrollbox | I have the following code and keep getting the error:
AttributeError: 'NoneType' object has no attribute 'curselection'
I tried changing items to simple text messages instead of items from an array, but that didn't work. So I don't know how to fix this. I think that there's some kind of issue with using grid(), beca... | [
"self.box = Pmw.ScrolledListBox(...).grid(row=12, column=0, ipadx=30, ipady=30)\n\nThe grid method returns None, so self.box gets set to None. Therefore you get said error when trying to call self.box.curselection. You can fix this by moving the grid call like this:\nself.box = Pmw.ScrolledListBox(...)\nself.box.gr... | [
4
] | [] | [] | [
"grid",
"python",
"tkinter"
] | stackoverflow_0008342507_grid_python_tkinter.txt |
Q:
How do I change the format/amount of digits that appear?
I'm very new to Python and have a question. Currently I'm using this to calculate the times between a message goes out and the message comes in. The resulting starting time, time delta, and the Unique ID are then presented in file. As well, I'm using Python ... | How do I change the format/amount of digits that appear? | I'm very new to Python and have a question. Currently I'm using this to calculate the times between a message goes out and the message comes in. The resulting starting time, time delta, and the Unique ID are then presented in file. As well, I'm using Python 2.7.2
Currently it is subtracting the two times and the result... | [
"If float(out_ts) are hours, then '{0:.3f}'.format(float(out_ts) * 3600.) will give you the text representation of seconds with three digits after decimal point.\n",
"\nHow can I force it to always display the exact number.\n\nThis is sometimes not possible, because of floating point inaccuracies\nWhat you can do... | [
2,
1
] | [] | [] | [
"digit",
"python"
] | stackoverflow_0008342891_digit_python.txt |
Q:
compare values in a file python
Here is my data sample in a txt file:
1322484979.322313000 85.24.168.19 QQlb-j7itDQ
1322484981.070116000 83.233.56.133 Ne8Bb1d5oyc
1322484981.128791000 83.233.56.133 Ne8Bb1d5oyc
1322484981.431075000 83.233.56.133 Ne8Bb1d5oyc
1322484985.210652000 83.233.57.136... | compare values in a file python | Here is my data sample in a txt file:
1322484979.322313000 85.24.168.19 QQlb-j7itDQ
1322484981.070116000 83.233.56.133 Ne8Bb1d5oyc
1322484981.128791000 83.233.56.133 Ne8Bb1d5oyc
1322484981.431075000 83.233.56.133 Ne8Bb1d5oyc
1322484985.210652000 83.233.57.136 QWUiCAE4E7U
The first column is t... | [
"In a basic way, it could looks like this : \ndata = open(\"data.txt\", \"r\")\n\nlast_time = 0.0\nlast_ip = None\nlast_hash = None\n\nfor line in data:\n timestamp, ip, hash_value = line.split()\n if ip==last_ip and hash_value==last_hash and float(timestamp) - float(last_time) < 5.0:\n ... | [
3
] | [] | [] | [
"python"
] | stackoverflow_0008342864_python.txt |
Q:
Is there a way to add/modify attributes of generators that were created with yield?
So I wanted to make an arff reader (similar to csv file format).
And I wanted to use yield to make an iterator but also to add attributes to this iterator.
eg:
data = arff.reader(my_fname)
print data.relation
for row in data:
p... | Is there a way to add/modify attributes of generators that were created with yield? | So I wanted to make an arff reader (similar to csv file format).
And I wanted to use yield to make an iterator but also to add attributes to this iterator.
eg:
data = arff.reader(my_fname)
print data.relation
for row in data:
print row
but in the reader definition:
def reader(fname):
reader.relation = fname # ... | [
"You can make it a class.\nclass Reader(object): # Assuming Python <= 2.7\n def __init__(self, fname):\n self.fname = fname\n\n def __iter__(self):\n yield 1\n yield 2\n\nr = Reader(\"some file\")\nprint r.fname ## 'some file'\nfor line in r:\n print line ## 1 then 2\n\n"
] | [
5
] | [] | [] | [
"generator",
"python",
"yield"
] | stackoverflow_0008343304_generator_python_yield.txt |
Q:
Python web template engine
I am looking for a python web templating engine that works like this:
<table>
<%
for item in items:
%>
<tr>
<th>Name</th>
<td><%= item.name %></td>
</tr>
<%
%>
</table>
I have worked with PHP before so this seems nice to me. I have looked here http://w... | Python web template engine | I am looking for a python web templating engine that works like this:
<table>
<%
for item in items:
%>
<tr>
<th>Name</th>
<td><%= item.name %></td>
</tr>
<%
%>
</table>
I have worked with PHP before so this seems nice to me. I have looked here http://wiki.python.org/moin/Templating b... | [
"Jinja2 — inspired by Django templates, but much improved, text-based. And speaking of Django, you probably want to pick a framework before you pick a template engine.\n",
"I would try Mako\n",
"It's a lot more than just a template engine... But I'm a huge Django fan\nhttps://djangoproject.com/\nhttps://docs.d... | [
4,
2,
2,
0
] | [] | [] | [
"frameworks",
"python",
"templates",
"web"
] | stackoverflow_0008343437_frameworks_python_templates_web.txt |
Q:
How can I get hours from a Python datetime?
I have a Python datetime, d, and I want to get the number of hours since midnight as a floating point number. The best I've come up with is:
h = ((((d.hour * 60) + d.minute) * 60) + d.second) / (60.0 * 60)
Which gives 4.5 for 4:30am, 18.75 for 6:45pm, etc. Is there a ... | How can I get hours from a Python datetime? | I have a Python datetime, d, and I want to get the number of hours since midnight as a floating point number. The best I've come up with is:
h = ((((d.hour * 60) + d.minute) * 60) + d.second) / (60.0 * 60)
Which gives 4.5 for 4:30am, 18.75 for 6:45pm, etc. Is there a better way?
| [
"h = d.hour + d.minute / 60. + d.second / 3600.\n\nhas less brackets…\n",
"h = (d - d.replace(hour=0,minute=0,second=0)).seconds / 3600.\n\n... has less division and/or multiplication\n"
] | [
42,
5
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0008343385_datetime_python.txt |
Q:
Python call constructor in a member function
Let's take for example this class, which is extending MySQLDB's connection object.
class DBHandler(mysql.connections.Connection):
def __init__(self,cursor=None):
if cursor == None:
cursor = 'DictCursor'
super(DBHandler,self).__init__... | Python call constructor in a member function | Let's take for example this class, which is extending MySQLDB's connection object.
class DBHandler(mysql.connections.Connection):
def __init__(self,cursor=None):
if cursor == None:
cursor = 'DictCursor'
super(DBHandler,self).__init__(host = db_host,
user = db_user,
... | [
"Yes, you can, since it would be preferable to extract your initialization code in another method (a def init(self):).\nThis is because __init__ is not really the constructor of the object, it is more the \"initializer\" of your instance, the real constructor is the __new__ method, that is responsible of the instan... | [
5
] | [] | [] | [
"constructor",
"oop",
"python"
] | stackoverflow_0008343576_constructor_oop_python.txt |
Q:
Django AttributeError: 'Manager' object has no attribute 'select_for_update'
I have a simple model define in Django. I want to select an Object using django select_for_update method to ensure data persistence as multiple threads needs to update single row but different columns. But it is giving following error:
Ob... | Django AttributeError: 'Manager' object has no attribute 'select_for_update' | I have a simple model define in Django. I want to select an Object using django select_for_update method to ensure data persistence as multiple threads needs to update single row but different columns. But it is giving following error:
Obj = my_model.objects.select_for_update().filter(pk=1)
AttributeError: 'Manager' o... | [
"check it out the documentation :\nhttps://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update\nso if you`ll have to upgrade your django version to the development version! \n"
] | [
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0008342221_django_django_models_python.txt |
Q:
What's a good framework for managing flashdata in google app engine?
I'm looking for a framework to manage flashdata on google app engine. Flashdata is data that only lives from one page to another, so for example, a user fills out a form, this form gets processed in the post method of a handler, and is redirected... | What's a good framework for managing flashdata in google app engine? | I'm looking for a framework to manage flashdata on google app engine. Flashdata is data that only lives from one page to another, so for example, a user fills out a form, this form gets processed in the post method of a handler, and is redirected to a get handler, as specified with the post redirect get pattern. On the... | [
"You didn't specify a runtime, so I'm going to assume Python.\nwebapp2 features session support, including support for flash messages.\n"
] | [
1
] | [] | [] | [
"frameworks",
"google_app_engine",
"python"
] | stackoverflow_0008341602_frameworks_google_app_engine_python.txt |
Q:
Django: Saving multiple ManyToMany fields within a transaction
this is the representation of my models:
class B(models.Model):
"""I'm a dummy model, so doesn't pay atention of what I do"""
name = models.CharField(max_length=250)
class A(models.Model):
name = models.CharField(max_length=250)
many_b = m... | Django: Saving multiple ManyToMany fields within a transaction | this is the representation of my models:
class B(models.Model):
"""I'm a dummy model, so doesn't pay atention of what I do"""
name = models.CharField(max_length=250)
class A(models.Model):
name = models.CharField(max_length=250)
many_b = models.ManyToManyField(B)
Now, suppose I have a list of B objects. A... | [
"From the docs:\n>>> john = Author.objects.create(name=\"John\")\n>>> paul = Author.objects.create(name=\"Paul\")\n>>> george = Author.objects.create(name=\"George\")\n>>> ringo = Author.objects.create(name=\"Ringo\")\n>>> entry.authors.add(john, paul, george, ringo)\n\nSo if you have a list, use argument expansion... | [
5,
1
] | [] | [] | [
"django",
"manytomanyfield",
"model",
"python"
] | stackoverflow_0008343620_django_manytomanyfield_model_python.txt |
Q:
What is the optimal naming convention for test files in Python?
I am looking for an optimal naming convention for python test files that ease the usage of different test frameworks (unittest, note, pyunit, ...) and also that is friendly with test auto-discovery for these tools.
I just want a clear set of recomanda... | What is the optimal naming convention for test files in Python? | I am looking for an optimal naming convention for python test files that ease the usage of different test frameworks (unittest, note, pyunit, ...) and also that is friendly with test auto-discovery for these tools.
I just want a clear set of recomandation that would require minimal configuration for tools.
Tests direc... | [
"Don't call the directory test or it will conflict with the built-in test package.\nThe naming conventions are defined in PEP 8. See the 'Naming Conventions' section. Underscores are better than hyphens!\nThe layout of your package is a bit more flexible. I tend to do the following:\npackage\n|-- package\n| |-- __... | [
23,
2
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0008343711_python_unit_testing.txt |
Q:
Facing XML Parsing Error while creating XULRunner application
I tried creating an XULRunner app as given in the tutorial - http://pyxpcomext.mozdev.org/no_wrap/tutorials/pyxulrunner/python_xulrunner_about.html
But when I tried running the app it gave me the following error -
XML Parsing Error:
Location: chrome:/... | Facing XML Parsing Error while creating XULRunner application | I tried creating an XULRunner app as given in the tutorial - http://pyxpcomext.mozdev.org/no_wrap/tutorials/pyxulrunner/python_xulrunner_about.html
But when I tried running the app it gave me the following error -
XML Parsing Error:
Location: chrome://pyxpcom_gui_app/content/pyxpcom_gui_app.xul
Line Number 19, Colum... | [
"Given that your code doesn't seem to have any syntax errors, the most likely issue is the &pyxpcom_gui_app.title; entity reference (note that the XML parser used by Firefox always points to the end of a tag regardless of the line where it finds an unknown entity). Either you forgot to include the DTD file defining... | [
1,
1,
0
] | [] | [] | [
"python",
"xml_parsing",
"xulrunner"
] | stackoverflow_0007613440_python_xml_parsing_xulrunner.txt |
Q:
How do you apply a list of lambda functions to a single element using an iterator?
I want to apply a list of lambda functions to a single element using an iterable that has to be created with yield.
The list of lambda functions would have something like:
[<function <lambda> at 0x1d310c8>, <function <lambda> at 0x... | How do you apply a list of lambda functions to a single element using an iterator? | I want to apply a list of lambda functions to a single element using an iterable that has to be created with yield.
The list of lambda functions would have something like:
[<function <lambda> at 0x1d310c8>, <function <lambda> at 0x1d355f0>]
And I want to apply every function, from left to right , to a single element ... | [
"def apply_all(functions, item):\n for f in functions:\n yield f(item)\n\nExample usage:\nfunctions = [type, id, hex]\nfor result in apply_all(functions, 55):\n print result\n\ngives\n<type 'int'>\n20326112\n0x37\n\n",
"Give this a shot:\ndef lambda_apply(unnamed_funcs, element):\n for unnamed in ... | [
7,
3,
2,
1,
0
] | [] | [] | [
"iterator",
"lambda",
"list",
"python",
"yield"
] | stackoverflow_0008344058_iterator_lambda_list_python_yield.txt |
Q:
Getting the filename from a path in Python?
I have a string containing a filename and optionally can be a full path or a relative one.
os.path module seems to miss such function. What is the easiest solution?
A:
I think you want os.path.basename.
A:
If you just want the filename without the path, then use base... | Getting the filename from a path in Python? | I have a string containing a filename and optionally can be a full path or a relative one.
os.path module seems to miss such function. What is the easiest solution?
| [
"I think you want os.path.basename.\n",
"If you just want the filename without the path, then use basename\nfrom os.path import basename\n\n# now you can call it directly with basename\nprint basename(\"/a/b/c.txt\")\n\nThis will give c.txt as output. \n",
"Method 1 : ( way to Go )\nfrom os.path import basename... | [
5,
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0008344648_python.txt |
Q:
Is this a hash function? python
im trying to implement a hash function in python. Would you consider the following a real hash function? I've 10 buckets and values from 1 to 7. It will also count amount of collisions :)
import random
A=[1,2,3,4,5,6,7]
hashed=[]
def func():
i=0
count=0
while len(A)... | Is this a hash function? python | im trying to implement a hash function in python. Would you consider the following a real hash function? I've 10 buckets and values from 1 to 7. It will also count amount of collisions :)
import random
A=[1,2,3,4,5,6,7]
hashed=[]
def func():
i=0
count=0
while len(A)>i:
m=random.randint(1,10) ... | [
"No. A hash function has to be deterministic. It cannot rely on randomness.\n\nA hash procedure must be deterministic—meaning that for a given input value it must always generate the same hash value. In other words, it must be a function of the hashed data, in the mathematical sense of the term. This requirement ex... | [
4,
1,
0,
0,
0
] | [] | [] | [
"function",
"hash",
"python"
] | stackoverflow_0008344719_function_hash_python.txt |
Q:
Python cannot open file
#!/usr/bin/python
data = open("/home/mia/Desktop/results/all-nodup.txt", "r")
fd = open("/home/mia/Desktop/results/all-filter.txt", "w")
last_time = 0.0
last_ip = None
last_hash = None
row = data.read()
for line in row:
timestamp, ip, hash_value = line.split()
if ip==last_ip... | Python cannot open file | #!/usr/bin/python
data = open("/home/mia/Desktop/results/all-nodup.txt", "r")
fd = open("/home/mia/Desktop/results/all-filter.txt", "w")
last_time = 0.0
last_ip = None
last_hash = None
row = data.read()
for line in row:
timestamp, ip, hash_value = line.split()
if ip==last_ip and hash_value==last_hash: ... | [
"python can't even find your filter.py script file, so changing your code is useless. To fix that you'll either need to:\n\nput filter.py inside results/ directory\nuse absolute path, e.g. python /path/to/script/filter.py\nfigure out the correct relative path, e.g. python ../../blah/filter.py\nput the path where fi... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0008344870_python.txt |
Q:
Calling nonexistent functions of None
If I name an exception as a variable, what properties are held by that variable? For example,
try:
None.nonexistent_function()
#return an AttributeError.
except Exception as ex:
self.assertEqual(__, ex.__class__.__name__)
In this instance, what is necessary to mak... | Calling nonexistent functions of None | If I name an exception as a variable, what properties are held by that variable? For example,
try:
None.nonexistent_function()
#return an AttributeError.
except Exception as ex:
self.assertEqual(__, ex.__class__.__name__)
In this instance, what is necessary to make the assertion True? How can the Name and ... | [
"Try it at the REPL:\n>>> try: None.foo()\n... except Exception as ex: pass\n...\n>>> # ex is still in scope, so we can play around with it and find out for ourselves:\n... ex.__class__.__name__\n'AttributeError'\n>>>\n\n",
"Hmmm... using Python's command line, I get:\n>>> try:\n... None.nonexistent_function(... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0008344869_python.txt |
Q:
Pythons fastest way of randomising case of a string
I want to randomise the case of a string, heres what I have:
word="This is a MixeD cAse stRing"
word_cap=''
for x in word:
if random.randint(0,1):
word_cap += x.upper()
else:
word_cap += x.lower()
word = wor... | Pythons fastest way of randomising case of a string | I want to randomise the case of a string, heres what I have:
word="This is a MixeD cAse stRing"
word_cap=''
for x in word:
if random.randint(0,1):
word_cap += x.upper()
else:
word_cap += x.lower()
word = word_cap
print word
Im wondering if you could use list com... | [
"import random\ns = 'this is a lower case string'\n\n''.join(random.choice((str.upper,str.lower))(x) for x in s)\n\nrandom.choice randomly selects one from two functions str.upper, str.lower.\nThen this function is applied to x for each letter in the input string s.\nIf initial string has all the letters in lowerca... | [
9,
4
] | [] | [] | [
"python",
"random",
"string",
"variables"
] | stackoverflow_0008344905_python_random_string_variables.txt |
Q:
Asynchronous Bidirectional RPC
I am looking for a RPC library in Java or Python (Python is preferred) that uses TCP. It should support:
Asynchronous
Bidirectional
RPC
Some sort of event loop (with callbacks or similar)
Any recommendations? I have looked a things like bjsonrpc which seemed to be the right sort o... | Asynchronous Bidirectional RPC | I am looking for a RPC library in Java or Python (Python is preferred) that uses TCP. It should support:
Asynchronous
Bidirectional
RPC
Some sort of event loop (with callbacks or similar)
Any recommendations? I have looked a things like bjsonrpc which seemed to be the right sort of thing however it didn't seem possi... | [
"You should definitely check out Twisted. It's an event-based Python networking framework that has an implementation of an event loop (called the \"reactor\") supporting select, poll, epoll, kqueue and I/O completion ports, and mediates asynchronous calls with objects called Deferreds\nAs for your RPC requirement, ... | [
6,
2,
1,
1
] | [] | [] | [
"python",
"rpc"
] | stackoverflow_0007293011_python_rpc.txt |
Q:
How to handle parallel calls to a Python API?
I wrote an API which which does some database operations with values requested by the API caller. How does this whole API system work when more than on person calls a function at the same time?
Do different instances of my API code start when a number of API calls are... | How to handle parallel calls to a Python API? | I wrote an API which which does some database operations with values requested by the API caller. How does this whole API system work when more than on person calls a function at the same time?
Do different instances of my API code start when a number of API calls are made?
If I need to handle like 2500 parallel API c... | [
"Do you plan to call your python API from some other python code? If so then how is the parallelism achieved? Do you plan to spawn many threads, use your api in every thread? \nAnyway it's worthwhile to take a look at multiprocessing module that allows one to create separate python processes. There are lots of thre... | [
0
] | [] | [] | [
"api",
"parallel_processing",
"python"
] | stackoverflow_0008344728_api_parallel_processing_python.txt |
Q:
modify a dictionary
I need to modify a dictionary. I have a dictionary with integer values and want to replace each value with the fraction of the total of all values, eg.:
census={a:4, b:1, c:3}; turnIntoFractions(census), should then print {a:0.5, b:0,125 ,c:0,375 }
I was thinking something like:
def turnIntoFra... | modify a dictionary | I need to modify a dictionary. I have a dictionary with integer values and want to replace each value with the fraction of the total of all values, eg.:
census={a:4, b:1, c:3}; turnIntoFractions(census), should then print {a:0.5, b:0,125 ,c:0,375 }
I was thinking something like:
def turnIntoFractions:
L=d.keys()
... | [
"You can use dictionary comprehension.\ndef turnIntoFractions(d):\n total = float(sum(d.values()))\n return {key:(value/total) for key,value in d.items()}\n\n",
"Your first problem is that you are doing the sum of the keys, not the values:\ntotal = sum(d.values())\n\nNow, you can just modify the dictionary in... | [
3,
1,
0,
0,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0008344917_dictionary_python.txt |
Q:
Namerror when trying to use def
I keep getting "NameError: name 'get_length' is not defined". What's wrong with my code?
def get_length_get_width_get_depth(ask_for_length,ask_for_width,ask_for_depth):
"Ask the user for the object's length,width, and depth"
length = raw_input(ask_for_length)
width = r... | Namerror when trying to use def | I keep getting "NameError: name 'get_length' is not defined". What's wrong with my code?
def get_length_get_width_get_depth(ask_for_length,ask_for_width,ask_for_depth):
"Ask the user for the object's length,width, and depth"
length = raw_input(ask_for_length)
width = raw_input(ask_for_width)
depth = r... | [
"you have no defined get_length method, just get_length_get_width_get_depth\ntry \nlength,width,depth = get_length_get_width_get_depth(\"What is the length of the object?\",\"What is the depth?\", \"What is the width?\")\n\nAlso to fix typos and unnecessary code in your question, take a look at this complete sample... | [
3,
1
] | [] | [] | [
"function",
"python"
] | stackoverflow_0008345203_function_python.txt |
Q:
Assertion Error in Pypdf package in Python
I am using Python 2.4 and PyPdf 1.13 on a Windows platform.
I am trying to merge PDF files from a list into one using the following code:
import os
from pyPdf import PdfFileWriter, PdfFileReader
attached=["C:\\test\\T_tech.pdf","C:\\test\\00647165-Backup.pdf"]
output=Pd... | Assertion Error in Pypdf package in Python | I am using Python 2.4 and PyPdf 1.13 on a Windows platform.
I am trying to merge PDF files from a list into one using the following code:
import os
from pyPdf import PdfFileWriter, PdfFileReader
attached=["C:\\test\\T_tech.pdf","C:\\test\\00647165-Backup.pdf"]
output=PdfFileWriter()
maxpage=0
os.chdir("C:\\test")
na... | [
"From the source:\n # bad xref character at startxref. Let's see if we can find\n # the xref table nearby, as we've observed this error with an\n # off-by-one before.\n stream.seek(-11, 1)\n tmp = stream.read(20)\n xref_loc = tmp.find(\"xref\")\n ... | [
1
] | [] | [] | [
"pypdf",
"python"
] | stackoverflow_0008345476_pypdf_python.txt |
Q:
OpenCV python: cv2.split() vs slicing while getting channel in BGR-image
I want to get only the first channel (Blue) in BGR-image and then save it to disk.
When I use cv2.split() everything is ok
>>> import cv2
>>> a = cv2.imread("/home/s18/theVIDEO/1_resized.jpg")
>>> b = cv2.split(a)[0]
>>> type(b)
<type 'numpy.... | OpenCV python: cv2.split() vs slicing while getting channel in BGR-image | I want to get only the first channel (Blue) in BGR-image and then save it to disk.
When I use cv2.split() everything is ok
>>> import cv2
>>> a = cv2.imread("/home/s18/theVIDEO/1_resized.jpg")
>>> b = cv2.split(a)[0]
>>> type(b)
<type 'numpy.ndarray'> ... | [
"It turns out OK if you didn't slice directly but copying the contents instead\n...\n>>> c = zeros((a.shape[0],a.shape[1]), dtype=a.dtype)\n>>> c[:,:] = a[:,:,0]\n>>> cv2.imwrite('out.jpg', c)\nTrue\n\n"
] | [
2
] | [] | [] | [
"channel",
"opencv",
"python",
"slice",
"split"
] | stackoverflow_0008344722_channel_opencv_python_slice_split.txt |
Q:
python pull Queue
I am using a back end handler to collect URL's from site maps. I am using a pull queue to perform this task and task constructor did not allow to add a url to it 's constructor. How to add a URL to a Pull queue so once the task is complete i can use REST to retrieve it's status. can any one give... | python pull Queue | I am using a back end handler to collect URL's from site maps. I am using a pull queue to perform this task and task constructor did not allow to add a url to it 's constructor. How to add a URL to a Pull queue so once the task is complete i can use REST to retrieve it's status. can any one give me a working example? ... | [
"Here's the documentation on the task queue REST API: http://code.google.com/appengine/docs/python/taskqueue/rest.html\nSpecifically, you can use\nGET\nhttps://www.googleapis.com/taskqueue/v1beta1/projects/{PROJECT_NAME}/taskqueues/{TASKQUEUE_NAME}/tasks/{TASK_NAME}\n\nIf the object is returned, it will have info o... | [
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0008326295_google_app_engine_python.txt |
Q:
regex - how to recognise a pattern until a second one is found
I have a file, named a particular way. Let's say it's:
tv_show.s01e01.episode_name.avi
it's the standard way a video file of a tv show's episode is named on the net. The pattern is quite the same all over the web, so I want to extract some information... | regex - how to recognise a pattern until a second one is found | I have a file, named a particular way. Let's say it's:
tv_show.s01e01.episode_name.avi
it's the standard way a video file of a tv show's episode is named on the net. The pattern is quite the same all over the web, so I want to extract some information from a file named this way. Basically I want to get:
the show's ti... | [
"try this\nshow_p=re.compile(\"(.*)\\.s(\\d*)e(\\d*)\")\nshow_p.match(x).groups()\n\nwhere x is your string\nEdit** (I forgot to include the extension, here is the revision)\nshow_p=re.compile(\"^(.*)\\.s(\\d*)e(\\d*).*?([^\\.]*)$\")\nshow_p.match(x).groups()\n\n\nAnd Here is the test result\n>>> show_p=re.compile(... | [
2,
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0008345190_python_regex.txt |
Q:
How to follow link with scrappy
How to follow links in this example : http://snippets.scrapy.org/snippets/7/ ?
The script stop after visiting the link of the first page.
class MySpider(BaseSpider):
"""Our ad-hoc spider"""
name = "myspider"
start_urls = ["http://stackoverflow.com/"]
question_list_xpath = '//div[@... | How to follow link with scrappy | How to follow links in this example : http://snippets.scrapy.org/snippets/7/ ?
The script stop after visiting the link of the first page.
class MySpider(BaseSpider):
"""Our ad-hoc spider"""
name = "myspider"
start_urls = ["http://stackoverflow.com/"]
question_list_xpath = '//div[@id="content"]//div[contains(@class, "... | [
"Yes, you need to subclass CrawlSpider, and rename parse function to something like parse_page, because CrawlSpider uses parse to start scraping.\nThis was already answered\n"
] | [
1
] | [] | [] | [
"python",
"scrapy"
] | stackoverflow_0008344383_python_scrapy.txt |
Q:
Commands from Tkinter.Button
I have a fairly simple Python problem which I really struggle to solve.
I have a LabelFrame widget within a Tk widget parent. The LabelFrame contains a number of widgets, including labels, entry widgets and buttons. Upon pressing a button, I want to execute a def, however want to send ... | Commands from Tkinter.Button | I have a fairly simple Python problem which I really struggle to solve.
I have a LabelFrame widget within a Tk widget parent. The LabelFrame contains a number of widgets, including labels, entry widgets and buttons. Upon pressing a button, I want to execute a def, however want to send the user inputs in the entry widge... | [
"That is how it was supposd to be - whenever you add parentheses after teh name of a function you are calling it. Using only its name, you are referencing the function object.\nTKinter per se does not allow one to add parameters to a callback.\nThe usual thing to do is to create a \"throw away function\", using the... | [
1
] | [] | [] | [
"button",
"python",
"widget"
] | stackoverflow_0008345371_button_python_widget.txt |
Q:
Need to use matplotlib scatter markers outside the chart, in labels for a bar graph
I have a scatter plot that uses six different symbols to plot points. For example, the code below plots a point with the downward-pointing triangle symbol:
my_axis.scatter([x], [y], marker='v')
Each symbol represents a different c... | Need to use matplotlib scatter markers outside the chart, in labels for a bar graph | I have a scatter plot that uses six different symbols to plot points. For example, the code below plots a point with the downward-pointing triangle symbol:
my_axis.scatter([x], [y], marker='v')
Each symbol represents a different class of object. I need to make reference to the symbols used in the scatter plot in a dif... | [
"Using Latex is a rather easy solution. For example:\nfrom matplotlib import rc\nrc('text', usetex=True)\nplt.xticks(ind+width/2., (\"$\\lozenge$\", \"$\\square$\", \"$\\plus$\", \"o\", \"$\\bigtriangledown$\") )\n\nAnd if you need help figuring out the names for the symbols, this is a great little website that al... | [
3,
0
] | [] | [] | [
"charts",
"matplotlib",
"python"
] | stackoverflow_0008337786_charts_matplotlib_python.txt |
Q:
Why doesn't this cause an array out of bounds error in Python?
I do not know much about python, but I am surprised the following code works:
import sys
prev = [sys.maxint]*(5)
j = 0
print prev[j]
print prev[j-1]
In general I thought second print statement should give me an error. Why does this work?
I need to co... | Why doesn't this cause an array out of bounds error in Python? | I do not know much about python, but I am surprised the following code works:
import sys
prev = [sys.maxint]*(5)
j = 0
print prev[j]
print prev[j-1]
In general I thought second print statement should give me an error. Why does this work?
I need to convert some python code into C++, and in C++ this will not work.
| [
"mylist[-1] returns the last item of mylist, mylist[-2] the second-to-last item etc.\nThis is by design. Read the tutorial.\n",
"That's because j - 1 evaluates to -1, which when used as index of python list, means last element.\n",
"The index of an array l can be an integer in the range [-len(l), len(l)-1] (not... | [
5,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0008346109_python.txt |
Q:
execution python application from browser
I have written a python console based program. It takes few arguments (like file name ) for execution.
I want to run it from the browser...
How can I parse this arguments and execute that python code
Any clues..approaches.
Thanks
A:
Maybe you should clarify your problem.... | execution python application from browser | I have written a python console based program. It takes few arguments (like file name ) for execution.
I want to run it from the browser...
How can I parse this arguments and execute that python code
Any clues..approaches.
Thanks
| [
"Maybe you should clarify your problem. At least i don't fully understand why you want to run a terminal program in the browser?\nBut if you want to reuse some code you have already written you could use a micro framework like Flask. \nCheck this example from flask's docs:\nfrom flask import Flask\napp = Flask(__na... | [
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0008346028_django_python.txt |
Q:
TypeError: 'function' object is unsubscriptable in Python?
I have an array of string objects, with color codes for plotting graphs, which looks like this: colors = ["ob-", "or-", "oy-", "og-", "om-", "op-"]
When i try to access it with a for loop (where its index is less than the array length) i get the following ... | TypeError: 'function' object is unsubscriptable in Python? | I have an array of string objects, with color codes for plotting graphs, which looks like this: colors = ["ob-", "or-", "oy-", "og-", "om-", "op-"]
When i try to access it with a for loop (where its index is less than the array length) i get the following error message: TypeError: 'function' object is unsubscriptable
T... | [
"There's nothing in the code you've provided that would produce the error you're receiving. If you're certain that's the line that's throwing the exception my bet is that in your actual source file you've typed str[i] instead of str(i). Otherwise, you're going to have to provide more information / code.\n"
] | [
0
] | [] | [] | [
"arrayaccess",
"arrays",
"python",
"typeerror"
] | stackoverflow_0008345962_arrayaccess_arrays_python_typeerror.txt |
Q:
convert UNIX timestamp to non-local time in Python
I am new to Python. I figured out how to UNIX time to local time, but I can't figure how to convert to a different time zone (Central time with daylight saving). Can somebody help?
A:
You could use time.tzset. The documentation provides some good examples settin... | convert UNIX timestamp to non-local time in Python | I am new to Python. I figured out how to UNIX time to local time, but I can't figure how to convert to a different time zone (Central time with daylight saving). Can somebody help?
| [
"You could use time.tzset. The documentation provides some good examples setting also the TZ environment variable.\n",
"I can recommend pytz, a timezone definition package for Python. After you installed and imported timezon from pytz, you need to make your local datetime object timezone aware (e.g. for UTC): \... | [
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0008346164_python.txt |
Q:
Selecting a random list element in python
I'm trying to create a function that takes two lists and selects an element at random from each of them. Is there any way to do this using the random.seed function?
A:
You can use random.choice to pick a random element from a sequence (like a list).
If your two lists are... | Selecting a random list element in python | I'm trying to create a function that takes two lists and selects an element at random from each of them. Is there any way to do this using the random.seed function?
| [
"You can use random.choice to pick a random element from a sequence (like a list).\nIf your two lists are list1 and list2, that would be:\na = random.choice(list1)\nb = random.choice(list2)\n\nAre you sure you want to use random.seed? This will initialize the random number generator in a consistent way each time, ... | [
21,
1
] | [
"I totally redid my previous answer. Here is a class which wraps a random-number generator (with optional seed) with the list. This is a minor improvement over F.J.'s, because it gives deterministic behavior for testing. Calling choice() on the first list should not affect the second list, and vice versa:\nclass rl... | [
-1
] | [
"list",
"python"
] | stackoverflow_0008346067_list_python.txt |
Q:
Logic game: maximising (or minimising) the chances for two agents to meet
Note: this question is tagged both language-agnostic and python as my primary concern is finding out the algorithm to implement the solution to the problem, but information on how to implement it efficiently (=executing fast!) in python are ... | Logic game: maximising (or minimising) the chances for two agents to meet |
Note: this question is tagged both language-agnostic and python as my primary concern is finding out the algorithm to implement the solution to the problem, but information on how to implement it efficiently (=executing fast!) in python are a plus.
Rules of the game:
Imagine two teams one of A agents (An) and one of... | [
"The members of the two teams and the slots define a tripartite graph A-S-B, with edges given by the possible moves. The bipartite subgraphs consisting of the slots and members of just one team are of interest; call these A-S for the graph with team A members and S-B for team B members. You can use the S-B graph to... | [
5,
3,
1
] | [
"This is not really a question of programming as much as it is a game theory question. What follows is a sketch of a game-theoretic analysis of the problem.\nWe have a game of two players (A and B). A two-player game is always a zero-sum game, i.e. the gain of one player is loss for the other. Even if game payoffs ... | [
-3
] | [
"algorithm",
"language_agnostic",
"logic",
"optimization",
"python"
] | stackoverflow_0008340372_algorithm_language_agnostic_logic_optimization_python.txt |
Q:
GTK+ RadioButton Defaults - How to Work Around Ugly Hack?
I have a group of GTK+(3) RadioButtons. I don't think the version of GTK matters here, though.
When a RadioButton is toggled in my app, an action is taken and the GUI is updated with relevant information. This is all handled in a connected callback for the ... | GTK+ RadioButton Defaults - How to Work Around Ugly Hack? | I have a group of GTK+(3) RadioButtons. I don't think the version of GTK matters here, though.
When a RadioButton is toggled in my app, an action is taken and the GUI is updated with relevant information. This is all handled in a connected callback for the "toggled" signal. No problems.
Only non-toggled RadioButtons wi... | [
"The following will force the button to emit a toggled signal:\nbutton.toggled()\n\nThis works because toggled method is already defined. However, if it wasn't you could still use the emit method to force any widget to emit any of their signals:\nbutton.emit('toggled')\n\n",
"I am not sure if that fits your need,... | [
2,
1
] | [] | [] | [
"gtk",
"python"
] | stackoverflow_0008345817_gtk_python.txt |
Q:
How to handle multibyte string in Python
There are multibyte string functions in PHP to handle multibyte string (e.g:CJK script). For example, I want to count how many letters in a multi bytes string by using len function in python, but it return an inaccurate result (i.e number of bytes in this string)
japanese =... | How to handle multibyte string in Python | There are multibyte string functions in PHP to handle multibyte string (e.g:CJK script). For example, I want to count how many letters in a multi bytes string by using len function in python, but it return an inaccurate result (i.e number of bytes in this string)
japanese = "桜の花びらたち"
print japanese
print len(japanese)#... | [
"Use Unicode strings:\n# Encoding: UTF-8\n\njapanese = u\"桜の花びらたち\"\nprint japanese\nprint len(japanese)\n\nNote the u in front of the string.\nTo convert a bytestring into Unicode, use decode: \"桜の花びらたち\".decode('utf-8')\n",
"Try converting it to unicode first:\nprint len(japanese.decode(\"utf-8\"))\n\ngives 7. ... | [
9,
3
] | [] | [] | [
"multibyte",
"multibyte_functions",
"python",
"string"
] | stackoverflow_0008346608_multibyte_multibyte_functions_python_string.txt |
Q:
Putting unittest classes in the related script itself vs making a separate file
So I'm creating unit tests for all of my scripts, many of which arent oo, and have main-loop code. I was wondering what the standard is for the location of creating unittest classes in relation to the affected script. Should the unit t... | Putting unittest classes in the related script itself vs making a separate file | So I'm creating unit tests for all of my scripts, many of which arent oo, and have main-loop code. I was wondering what the standard is for the location of creating unittest classes in relation to the affected script. Should the unit test be in a separate file which imports the script, and then function-alize the mainl... | [
"You should separate your tests into a file of their own, and extract functions from your main so that they can be tested.\n(After you've extracted the functions, you might notice that a lot of data is being shared between them, hinting that you should be creating a class.)\nYou'll have a file like this:\ndef func_... | [
1,
0,
0
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0008346580_python_unit_testing.txt |
Q:
three argument filtering
Lets assume I have defined function:
def threeArgs(x,y,z):
return ... # Returns True or False
I also have a list of elements:
a = [elem1, elem2, ..., elemN]
I would like to construct another list b containing first and last element form list a and those elements Xn in between for which... | three argument filtering | Lets assume I have defined function:
def threeArgs(x,y,z):
return ... # Returns True or False
I also have a list of elements:
a = [elem1, elem2, ..., elemN]
I would like to construct another list b containing first and last element form list a and those elements Xn in between for which threeArgs(Xn-1,Xn, Xn+1) retu... | [
"Use slicing to create three shifted lists, then zip them together:\n[a[0]] + [y for x, y, z in zip(a, a[1:], a[2:]) if threeArgs(x, y, z)] + [a[-1]]\n\n",
"If you have the window function defined, you can do this:\na[0] + [a[i+3] for i,v in enumerate(imap(threeArgs, window(a, 3))) if v] + a[-1]\n\nwhich might us... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0008346647_python.txt |
Q:
Using range and dictionary in Python's Bellman-Ford implementation
The Bellman-Ford algorithm looks like this
initialize-single-source(G,s)
for i = 1 to |G.V| - 1
for each edge (u,v) in G.E
call Relax(u,v,w)
and so on
This psuedocode index begins with 1, not zero.
Here is how I called the edge. I use di... | Using range and dictionary in Python's Bellman-Ford implementation | The Bellman-Ford algorithm looks like this
initialize-single-source(G,s)
for i = 1 to |G.V| - 1
for each edge (u,v) in G.E
call Relax(u,v,w)
and so on
This psuedocode index begins with 1, not zero.
Here is how I called the edge. I use dictionary for edge and vertex.
for i in range((len(self.V.keys()))-1)... | [
"Did you already give this super website a try? Sometimes answers can be found there...\n",
"\nQ1: We should begin with index zero, right?\n\nNot necessarily; you could also iterate over xrange(1, len(self.V)). Starting from zero is idiomatic, though.\n\nQ2: Should we still minus 1 from the length of G.V?\n\nIf y... | [
3,
3
] | [] | [] | [
"graph",
"python"
] | stackoverflow_0008346880_graph_python.txt |
Q:
remote objects returning another remote objects in python's RPC world
I am basically familiar with RPC solutions available in Python: XML-RPC and Pyro. I can make an remote object by binding it on the server-side and then I can get proxy object on the client side on which I can operate. When I call some method on ... | remote objects returning another remote objects in python's RPC world | I am basically familiar with RPC solutions available in Python: XML-RPC and Pyro. I can make an remote object by binding it on the server-side and then I can get proxy object on the client side on which I can operate. When I call some method on remote object e.g. proxy.get_file() then the rpc mechanism tries to seriali... | [
"I have found a library that does exactly what I need: RPyC. From intro:\n\nsimple, immutable python objects (like strings, integers, tuples, etc.) are passed by value, meaning the value itself is passed to the other side.\nall other objects are passed by reference, meaning a \"reference\" to the object is passed t... | [
2,
1,
0
] | [] | [] | [
"python",
"rpc"
] | stackoverflow_0004631561_python_rpc.txt |
Q:
Adding whitespace to the ends of textwrapping?
I'm looking to wrap a paragraph with a limit of 80 characters, however if there is a necessary break (break long words set to false) and the line total is now 71 for example, how do I add 9 characters worth of white space to fill it out to 80 characters, for each line... | Adding whitespace to the ends of textwrapping? | I'm looking to wrap a paragraph with a limit of 80 characters, however if there is a necessary break (break long words set to false) and the line total is now 71 for example, how do I add 9 characters worth of white space to fill it out to 80 characters, for each line that this occurs.
I'm looking to use either the fil... | [
"Just postprocess the result:\nfor line in textwrap.wrap(some_text, 80, break_long_words=False):\n yield \"%-80s\" % (line)\n\nObviously if you have a lot of this to do you might want to create your own TextWrapper instance, but I suspect you already are familiar with the textwrap documentation.\n"
] | [
2
] | [] | [] | [
"python",
"whitespace",
"word_wrap"
] | stackoverflow_0008347064_python_whitespace_word_wrap.txt |
Q:
socket.send working only once in python code for an echo client
I have the following code for an echo client that sends data to an echo server using socket connection:
echo_client.py
import socket
host = '192.168.2.2'
port = 50000
size = 1024
def get_command():
#..Code for this here
s = socket.socket(socket... | socket.send working only once in python code for an echo client | I have the following code for an echo client that sends data to an echo server using socket connection:
echo_client.py
import socket
host = '192.168.2.2'
port = 50000
size = 1024
def get_command():
#..Code for this here
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
while 1:
msg... | [
"Your server code only calls recv once. You should call accept once if you only want to receive one connection, but then you need to loop calling recv and send.\n",
"Your problem is that you are blocking on the accept inside the server's loop.\nThis is expecting the server to accept connections from more than one... | [
5,
2
] | [] | [] | [
"network_programming",
"python",
"sockets"
] | stackoverflow_0008347107_network_programming_python_sockets.txt |
Q:
Multiplayer game on Google App Engine
I would like to make a multiplayer game on the app engine. And the channel api gives me another reason to choose the app engine over a lot of other services. Has anyone tried this?
I understand how about go about a turn based game but I am stuck on how to go about something t... | Multiplayer game on Google App Engine | I would like to make a multiplayer game on the app engine. And the channel api gives me another reason to choose the app engine over a lot of other services. Has anyone tried this?
I understand how about go about a turn based game but I am stuck on how to go about something that has multiple users each contributing to... | [
"Interesting read over here at the appengine blog about a real time game on appengine...\nhttp://googleappengine.blogspot.com/2010/04/games-on-app-engine-interview-with-jay.html\n",
"I have a prototype implementation details of multiuser chat room (or a game room) on my blog post at http://blog.myblive.com/2010/1... | [
4,
2,
2
] | [] | [] | [
"api",
"google_app_engine",
"python"
] | stackoverflow_0005100152_api_google_app_engine_python.txt |
Q:
What is MATLAB good for? Why is it so used by universities? When is it better than Python?
I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can b... | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | [
"Adam is only partially right. Many, if not most, mathematicians will never touch it. If there is a computer tool used at all, it's going to be something like Mathematica or Maple. Engineering departments, on the other hand, often rely on it and there are definitely useful things for some applied mathematicians... | [
77,
38,
34,
15,
13,
12,
10,
7,
6,
6,
6,
6,
5,
4,
4,
4,
4,
3,
3,
2,
2
] | [] | [] | [
"matlab",
"python"
] | stackoverflow_0000179904_matlab_python.txt |
Q:
Cleaning Python modules an have fresh start Mac OS X
I am not a total newbie but I am trying to install modules for quite a long time and at this point i would like to have a fresh start and install python and all the modules I need so i really understand them. My problem is that some of them import, but most of t... | Cleaning Python modules an have fresh start Mac OS X | I am not a total newbie but I am trying to install modules for quite a long time and at this point i would like to have a fresh start and install python and all the modules I need so i really understand them. My problem is that some of them import, but most of them install either to the wrong site-packages or dont impo... | [
"Buildout and virtualenv should be what you are looking for.\nBuildout helps you configure a python installation and virtualenv allows you to isolate multiple different configurations from each other.\nHere's a nice blog post explaining how to use them together.\nAlso, see this other question: Buildout and Virtuale... | [
5,
3,
-3
] | [] | [] | [
"module",
"python"
] | stackoverflow_0008346731_module_python.txt |
Q:
sqrt() takes exactly 2 arguments (1 given)
def sqrt (n, one):
floating_point_precision = 10*16
n_float = float(( n * floating_point_precision) // one) / floating_point_precision
x = (int(floating_point_precision * math.sqrt(n_float)) * one) // floating_point_precision
n_one = n ... | sqrt() takes exactly 2 arguments (1 given) | def sqrt (n, one):
floating_point_precision = 10*16
n_float = float(( n * floating_point_precision) // one) / floating_point_precision
x = (int(floating_point_precision * math.sqrt(n_float)) * one) // floating_point_precision
n_one = n * one
while 1:
x_old = x
... | [
"Your sqrt function has two parameters, but you only provided one argument. It seems that the second argument should be the value \"1\".\nprint \"The newton estimate of\", mynum, \"is\", sqrt(mynum, 1.0)\n\n",
"You've defined sqrt as a function which takes two arguments. Later, your code references your function:... | [
3,
2,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0008347435_python.txt |
Q:
"Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
I am using mysqldb (the python MySQL) module..
But everytime I try to run. it gives me this error.
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL s... | "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") | I am using mysqldb (the python MySQL) module..
But everytime I try to run. it gives me this error.
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
I think the issue is multiple m... | [
"Aaghh a stupid overlooking of facts on my part.. \nIn the question I did said that I am stopping the default mysql.. before starting the xampp mysql..\nbut forgot to restart it.. \nand unfortunately \n/etc/init.d/mysql start\n\nwont work\nyou have to do\n/etc/init.d/mysql restart\n\n",
"Apparently XAMPP has it's... | [
3,
2
] | [] | [] | [
"mysql",
"mysql_python",
"python",
"ubuntu"
] | stackoverflow_0008346996_mysql_mysql_python_python_ubuntu.txt |
Q:
Create path and filename from string in Python
Given the following strings:
dir/dir2/dir3/dir3/file.txt
dir/dir2/dir3/file.txt
example/directory/path/file.txt
I am looking to create the correct directories and blank files within those directories.
I imported the os module and I saw that there is a mkdir function... | Create path and filename from string in Python | Given the following strings:
dir/dir2/dir3/dir3/file.txt
dir/dir2/dir3/file.txt
example/directory/path/file.txt
I am looking to create the correct directories and blank files within those directories.
I imported the os module and I saw that there is a mkdir function, but I am not sure what to do to create the whole p... | [
"Here is the answer on all your questions (directory creation and blank file creation)\nimport os\n\nfileList = [\"dir/dir2/dir3/dir3/file.txt\",\n \"dir/dir2/dir3/file.txt\",\n \"example/directory/path/file.txt\"]\n\nfor file in fileList:\n dir = os.path.dirname(file)\n # create directory if it does no... | [
4,
1
] | [] | [] | [
"python"
] | stackoverflow_0008344315_python.txt |
Q:
How can I grab all terms beginning with '#'?
I have a string like so: "sometext #Syrup #nshit #thebluntislit"
and i want to get a list of all terms starting with '#'
I used the following code:
import re
line = "blahblahblah #Syrup #nshit #thebluntislit"
ht = re.search(r'#\w*', line)
ht = ht.group(0)
print ht
and ... | How can I grab all terms beginning with '#'? | I have a string like so: "sometext #Syrup #nshit #thebluntislit"
and i want to get a list of all terms starting with '#'
I used the following code:
import re
line = "blahblahblah #Syrup #nshit #thebluntislit"
ht = re.search(r'#\w*', line)
ht = ht.group(0)
print ht
and i get the following:
#Syrup
I was wondering if th... | [
"Regular expression is not needed with good programming languages like Python:\n hashed = [ word for word in line.split() if word.startswith(\"#\") ]\n\n",
"You can use \ncompiled = re.compile(r'#\\w*')\ncompiled.findall(line)\n\nOutput:\n['#Syrup', '#nshit', '#thebluntislit']\n\nBut there is a problem. If you s... | [
21,
4,
1
] | [] | [] | [
"hashtag",
"python",
"regex"
] | stackoverflow_0008347567_hashtag_python_regex.txt |
Q:
Authenticate users across Django projects - where to begin?
I'm in the process of building several Django based web applications for the same client. What I would like to do is set up an authentication server so that user credentials can be shared among django projects e.g. Jan Doe creates account for App-A and ... | Authenticate users across Django projects - where to begin? | I'm in the process of building several Django based web applications for the same client. What I would like to do is set up an authentication server so that user credentials can be shared among django projects e.g. Jan Doe creates account for App-A and can use the same un and pw to log in to App-B.
Django packages is... | [
"No, you don't need a separate package. Just use Django's built-in multi-database handling. Check out: https://docs.djangoproject.com/en/dev/topics/db/multi-db/.\nEssentially, you designate one of your databases as the one that's going to store the user data and make sure that database is added to each of your othe... | [
5
] | [] | [] | [
"django",
"python"
] | stackoverflow_0008347615_django_python.txt |
Q:
Drop in Single Breakpoint in Ruby Code
I am trying to find ruby code that has commensurate functionality to these lines in python:
import code
code.interact(local=locals())
These lines essentially insert a single breakpoint into my code and open up a console where I can interact with any variables.
Any thoughts o... | Drop in Single Breakpoint in Ruby Code | I am trying to find ruby code that has commensurate functionality to these lines in python:
import code
code.interact(local=locals())
These lines essentially insert a single breakpoint into my code and open up a console where I can interact with any variables.
Any thoughts on how to do this in Ruby?
| [
"You want the Pry library:\nrequire 'pry' # gem install pry\nbinding.pry # Drop into the pry console\n\nRead more here:\nhttp://banisterfiend.wordpress.com/2011/01/27/turning-irb-on-its-head-with-pry/\nSee also:\nHow to use Pry with Sinatra?\n",
"There is Kernel#local_variables in Ruby that returns the names of... | [
16,
1
] | [] | [] | [
"breakpoints",
"debugging",
"python",
"ruby",
"ruby_on_rails"
] | stackoverflow_0008347636_breakpoints_debugging_python_ruby_ruby_on_rails.txt |
Q:
Replacing multiple lines by one in websites files: bash ? python?
I am looking for a command line solution to replace a potentially dangerous string in php files by a safer one, on a Linux server. I'd like to conduct the replace in all hosted sites, and then have it run as a daily cronjob to be on the safer side.
... | Replacing multiple lines by one in websites files: bash ? python? | I am looking for a command line solution to replace a potentially dangerous string in php files by a safer one, on a Linux server. I'd like to conduct the replace in all hosted sites, and then have it run as a daily cronjob to be on the safer side.
Bash or PHP would be perfect I guess, but I'm ok with Python if that's ... | [
"i use command line perl for bulk search and replace\nperl -pi -e 's/FIND IT/REPLACE IT' /home/name/public_html/html/*.html \n\n",
"How about this awk one-liner. You can use it with find or for loop to do mass substitution. \nawk '/\\$authsites/{sub(/\\(.*\\)/,\"( )\");print;next}1' INPUTFILE\n\nTest:\n[jaypal:~/... | [
0,
0
] | [] | [] | [
"bash",
"php",
"python",
"sed"
] | stackoverflow_0008347630_bash_php_python_sed.txt |
Q:
Python or Bash commands to determine time since a cron job string would have triggered
I'm writing a Django app (although parts can be Bash) that stores the cron job strings of many other machines. It needs to calculate the amount of time since that cron job would have triggered on that machine. Is there a pytho... | Python or Bash commands to determine time since a cron job string would have triggered | I'm writing a Django app (although parts can be Bash) that stores the cron job strings of many other machines. It needs to calculate the amount of time since that cron job would have triggered on that machine. Is there a python library useful for converting cron style strings to another Python friendly scheduler form... | [
"Celery is the package that's usually used with Django for job scheduling. It has a module for parsing cron specs. It might be of use.\n"
] | [
2
] | [] | [] | [
"bash",
"cron",
"django",
"linux",
"python"
] | stackoverflow_0008348148_bash_cron_django_linux_python.txt |
Q:
How do I setup a python, telnet proxy for a device on a different network over SSH?
Overview:
I have a device sitting on a local network to a computer that is sitting on an outside network. I would like to create a software program that allows me to seamlessly connect to the device from a computer on a different ... | How do I setup a python, telnet proxy for a device on a different network over SSH? | Overview:
I have a device sitting on a local network to a computer that is sitting on an outside network. I would like to create a software program that allows me to seamlessly connect to the device from a computer on a different network. For purposes of this question, I've created a picture to help describe the netw... | [
"I have to admit that I didn't quite follow all of your description, especially the \"dial home\" client/server part. However, your diagram seems sufficient for understanding.\n\nSet up port forwarding on \"router2\" that forwards the incoming SSH port to your Windows server.\nWrite a Python program (you will proba... | [
0
] | [] | [] | [
"proxy",
"python",
"ssh",
"telnet"
] | stackoverflow_0008348073_proxy_python_ssh_telnet.txt |
Q:
How to create a list of n dictionaries
I'm learning Python and for practicing purposes I'm writing a script that reads a file (containing a graph in Trivial Graph Format) and runs a couple of graph algorithms on the graph.
I thought about storing the graph in a list of n dictionaries, where n is the number of vert... | How to create a list of n dictionaries | I'm learning Python and for practicing purposes I'm writing a script that reads a file (containing a graph in Trivial Graph Format) and runs a couple of graph algorithms on the graph.
I thought about storing the graph in a list of n dictionaries, where n is the number of vertexes and all the edges of a vertex would be ... | [
"It looks like vertex1 is probably greater than num_vertexes. Given that python indexes from 0 and the example on the wiki of the format goes from 1, the last line's vertex number is probably 1 higher than the length of the index (I'd need to see the file to know for sure, of course). So in the python case lst[0]... | [
4,
2
] | [] | [] | [
"python"
] | stackoverflow_0008348473_python.txt |
Q:
find primes function
I have a function:
def containsNoDivisor(n, ps):
'''n is an integer and ps is a list of integers. Returns True if
and only if there is no integer in ps that divides n. '''
for p in ps:
if n % p == 0:
return False
print True
Then I need to create another ... | find primes function | I have a function:
def containsNoDivisor(n, ps):
'''n is an integer and ps is a list of integers. Returns True if
and only if there is no integer in ps that divides n. '''
for p in ps:
if n % p == 0:
return False
print True
Then I need to create another function, that computes a ... | [
"It looks like you're printing True instead of returning it in your containsNoDivisor function. It should look like this:\ndef containsNoDivisor(n, ps):\n '''n is an integer and ps is a list of integers. Returns True if\n and only if there is no integer in ps that divides n. '''\n for p in ps:\n ... | [
4,
1,
0
] | [] | [] | [
"primes",
"python"
] | stackoverflow_0008342657_primes_python.txt |
Q:
How to know if python script was run using interpreter's -m option?
I couldn't find answer after having read all the following:
PEP 338 Executing modules as scripts
documentation of runpy standard module
description of Python interpreter's -m option
Rationale:
When a test script which uses relative imports is ... | How to know if python script was run using interpreter's -m option? | I couldn't find answer after having read all the following:
PEP 338 Executing modules as scripts
documentation of runpy standard module
description of Python interpreter's -m option
Rationale:
When a test script which uses relative imports is being run without -m option I could print a warning message instead of le... | [
"Disclaimer: this is just an observation, I have not seen it in the docs so it is probably implementation dependent and might not be consistent across different Python versions.\nI have noticed that when calling a script using a -m option a variable called __loader__ is added to the namespace, so at the top of your... | [
3,
2
] | [] | [] | [
"command_line",
"python"
] | stackoverflow_0008348726_command_line_python.txt |
Q:
AES 256 Encryption with PyCrypto using CBC mode - any weaknesses?
I have the following python script to encrypt/decrypt data using AES 256, could you please tell me if there's anything in the code that may make the encryption weak or if there's anything that I've not taken account of for AES 256 encryption using C... | AES 256 Encryption with PyCrypto using CBC mode - any weaknesses? | I have the following python script to encrypt/decrypt data using AES 256, could you please tell me if there's anything in the code that may make the encryption weak or if there's anything that I've not taken account of for AES 256 encryption using CBC mode? I've tested the script and it works fine, it is encrypting and... | [
"I've seen the code posted on the internet. There are - in principle - not too many things wrong with it, but there is no need to invent your own padding. Furthermore, I don't see why the first padding character is called INTERRUPT. I presume that INTERRUPT and PAD is handled as a single byte (I'm not a Python expe... | [
2
] | [] | [] | [
"encryption",
"encryption_symmetric",
"pycrypto",
"python"
] | stackoverflow_0007954661_encryption_encryption_symmetric_pycrypto_python.txt |
Q:
strange behaviour of filehandle.tell() function
I don't get why the tell() function doesn't work in this case. Let's create a file with the string "1\n2\n3\n4\n" inside:
f=open('test.tmp','w')
f.write('1\n2\n3\n4\n')
f.close()
Now, let's open it and run the following code:
fTellResults=[]
f=open('test.tmp','r+')
... | strange behaviour of filehandle.tell() function | I don't get why the tell() function doesn't work in this case. Let's create a file with the string "1\n2\n3\n4\n" inside:
f=open('test.tmp','w')
f.write('1\n2\n3\n4\n')
f.close()
Now, let's open it and run the following code:
fTellResults=[]
f=open('test.tmp','r+')
for line in f:
fTellResults.append(f.tell())
f.cl... | [
"\nfile.next()\nA file object is its own iterator, for example iter(f) returns f (unless f is closed). When a file is used as an iterator, typically in a for loop (for example, for line in f: print line), the next() method is called repeatedly. This method returns the next input line, or raises StopIteration when E... | [
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0008348798_python.txt |
Q:
Architecture: I have to make available object properties that that is updated every couple seconds
My app maintains the state of a bunch of objects with variables.
I'm using Twisted to accept socket requests and return the properties of an object.
I want to make sure the app can scale for a lot of requests so I'm ... | Architecture: I have to make available object properties that that is updated every couple seconds | My app maintains the state of a bunch of objects with variables.
I'm using Twisted to accept socket requests and return the properties of an object.
I want to make sure the app can scale for a lot of requests so I'm wondering if I should deliver the object properties directly from the objects, or if I should store thos... | [
"I don't think you have any performance penalty because of having many reading operations from the same object (only one thread is executed at a time after all).\n",
"I think either you create an selfCreatedObject or using a memcached once, it will be an instance of python objects, like list or dict or anything e... | [
0,
0
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0008348687_python_twisted.txt |
Q:
Connecting iPhone app to a secure RESTful API?
I am building a RESTful API in Python with the Pylons framework, serving it with Apache2 and mod_wsgi, and would like to connect it to an iPhone app. I have very little experience with HTTPS, SSL, and certificate authorities, and I am wondering how I would go about se... | Connecting iPhone app to a secure RESTful API? | I am building a RESTful API in Python with the Pylons framework, serving it with Apache2 and mod_wsgi, and would like to connect it to an iPhone app. I have very little experience with HTTPS, SSL, and certificate authorities, and I am wondering how I would go about securing my API.
How do I make sure that the API is b... | [
"This really depends on what you mean by \"securing\" your API.\nDo you mean that you want to A) secure it so that unauthorized people are unable to access the API or B) do you mean that you want some level of encryption on the data passed back and forth between the client and server?\nIf the answer is B or both, t... | [
1,
1
] | [] | [] | [
"apache",
"api",
"iphone",
"python",
"ssl"
] | stackoverflow_0008348456_apache_api_iphone_python_ssl.txt |
Q:
Something more beautiful than <__main__.MyClass instance at 0x1624710>
This is my class (as simple as it can be):
class MyClass():
def __init__(self, id):
self.id = id
def __str__(self):
return "MyClass #%d" % self.id
When I print an object of MyClass, I get this beautiful string: MyClass... | Something more beautiful than <__main__.MyClass instance at 0x1624710> | This is my class (as simple as it can be):
class MyClass():
def __init__(self, id):
self.id = id
def __str__(self):
return "MyClass #%d" % self.id
When I print an object of MyClass, I get this beautiful string: MyClass #id. But when I just "show it" in the interpreter, I still get this nasty <... | [
"def __repr__(self):\n return 'MyClass #%d' % (self.id,)\n\n",
">>> class MyClass():\n... def __init__(self, id):\n... self.id = id\n... def __repr__(self):\n... return \"MyClass #%d\" % self.id\n... \n>>> c = MyClass(5)\n>>> c\nMyClass #5\n\n"
] | [
10,
1
] | [] | [] | [
"class",
"python"
] | stackoverflow_0008349054_class_python.txt |
Q:
Python Gearman get data from background task
I'm try use gearman with backgroud tasks and get data progress from worker.
In documentation I'm see methods: send_job_data and send_job_status, but with background first method not work (I'm not see data in job.data_updates), but status changes in job.status.
I'm use t... | Python Gearman get data from background task | I'm try use gearman with backgroud tasks and get data progress from worker.
In documentation I'm see methods: send_job_data and send_job_status, but with background first method not work (I'm not see data in job.data_updates), but status changes in job.status.
I'm use this code for test workers:
from gearman import... | [
"background tasks are called such because they allow the client that submitted them to un-block and work disconnected. They do not keep a channel of communication open to the client, so you won't get any of those status updates. They essentially go into the bit-bucket. If you want a background task to communicate i... | [
2
] | [] | [] | [
"gearman",
"python",
"python_gearman"
] | stackoverflow_0008344561_gearman_python_python_gearman.txt |
Q:
Generating combinations of a string (not permutations)
I've tried to implement the algorithm in "Programming Interviews Exposed" in Python, as below, but it doesn't seem to work (page 99 on the 2nd Edition):
The idea is to generate all combinations (not permutations) of a string, such that if you input "wxyz" you ... | Generating combinations of a string (not permutations) | I've tried to implement the algorithm in "Programming Interviews Exposed" in Python, as below, but it doesn't seem to work (page 99 on the 2nd Edition):
The idea is to generate all combinations (not permutations) of a string, such that if you input "wxyz" you would get "w, wx, wxy, wxyz, wxz, wy, wyz, wz.... " etc. if... | [
"In your current code, try changing the line out = out[:-1] to del out[-1]. Both of those result in out having the last item removed, but in your current code out is reassigned instead of using the same list. This results in characters never being removed from the original list, which will obviously mess with the... | [
3,
2,
1,
0
] | [] | [] | [
"algorithm",
"combinations",
"python"
] | stackoverflow_0008347815_algorithm_combinations_python.txt |
Q:
Python ncurses, CDK, urwid difference
What's the difference between these 3? As far as I understand it they both provide binding to curses which is the C library for terminal text-based UI.
I currently have no knowledge of any of the 3 and I've never used curses. Which one would you recommend? I've heard of ncurse... | Python ncurses, CDK, urwid difference | What's the difference between these 3? As far as I understand it they both provide binding to curses which is the C library for terminal text-based UI.
I currently have no knowledge of any of the 3 and I've never used curses. Which one would you recommend? I've heard of ncurses many times but only once or twice about C... | [
"What I get after looking at some references is:\n\nncurses: It's a free software version of curses, so you have to deal with all kind low-level details.\npyCDK: It's a higher level library that provides some widgets. I haven't used this one, but according to the sourceforge project page it's been unmaintained for ... | [
36,
3
] | [] | [] | [
"curses",
"ncurses",
"python",
"urwid"
] | stackoverflow_0008349085_curses_ncurses_python_urwid.txt |
Q:
Visual Studio 2010 Attaching to Python Process
I'm using VS 2010 to attach to a Python script that is calling a DLL via ctypes.
I can attach to the process and under the "Modules" view I can see the DLL and it's associated PDB. The paths lead right to the solutions output folder which happens to be ".../Debug/bin"... | Visual Studio 2010 Attaching to Python Process | I'm using VS 2010 to attach to a Python script that is calling a DLL via ctypes.
I can attach to the process and under the "Modules" view I can see the DLL and it's associated PDB. The paths lead right to the solutions output folder which happens to be ".../Debug/bin". I'm running the script from this same folder.
When... | [
"As you are using VS 2010, install the Python Tools for Visual Studio extension that was released a few months ago. It is awesome. \n\nSupports CPython and IronPython\nPython editor with advanced member and signature intellisense\nCode navigation, goto definition, and object browser \nLocal and remote debugging\n\n... | [
2
] | [] | [] | [
"dll",
"python",
"symbols",
"visual_studio"
] | stackoverflow_0008348983_dll_python_symbols_visual_studio.txt |
Q:
XPath for selecting multiple HTML `a` elements
I'm pretty new to XPath and couldn't figure it out looking at other solutions.
What I'm trying to do is select all the a elements inside a given td (td[2] in example) and running a for statement to output the text contained within the a elements.
Source code:
multiple... | XPath for selecting multiple HTML `a` elements | I'm pretty new to XPath and couldn't figure it out looking at other solutions.
What I'm trying to do is select all the a elements inside a given td (td[2] in example) and running a for statement to output the text contained within the a elements.
Source code:
multiple = HTML.ElementFromURL(url).xpath('//table[contains(... | [
"The XPath you need is pretty close:\n//table[contains(@class, \"mg-b20\")]/tr[3]/td[2]//a\n\nI don't know what library you're using, but I suspect it is the Plex Parsekit API. If so, parsekit uses lxml.etree as its underlying library, so you can simplify your code even further:\nelement = HTML.ElementFromURL(url)\... | [
3
] | [] | [] | [
"lxml",
"python",
"xpath"
] | stackoverflow_0008349610_lxml_python_xpath.txt |
Q:
Importing a shared library and the global namespace
I am trying to import a shared library which contains a number of Python wrappers for a visualisation program (VisIt to be specific). This library is implemented in such a way that one first imports the library, which makes a few functions available, and then you... | Importing a shared library and the global namespace | I am trying to import a shared library which contains a number of Python wrappers for a visualisation program (VisIt to be specific). This library is implemented in such a way that one first imports the library, which makes a few functions available, and then you call a function which launches the visualisaion viewer a... | [
"It seems that Visit uses a dynamic import which brings everything to local scope. Basically, they're assuming that you'll never call visit.Launch() outside of the global scope. The launch function is all written in C++, so I'm not sure exactly how it's importing.\nOne workaround is to reassign the names from the l... | [
2,
0
] | [] | [] | [
"python",
"shared_libraries"
] | stackoverflow_0008348921_python_shared_libraries.txt |
Q:
Troubleshooting Fibonacci series with python
I am reading a textbook and I have no idea why is this code compiling differently on my compiler than what it says in the book.
def fibs(number):
result = [0, 1]
for i in range(number-2):
result.append(result[-2] + result[-1])
return resu... | Troubleshooting Fibonacci series with python | I am reading a textbook and I have no idea why is this code compiling differently on my compiler than what it says in the book.
def fibs(number):
result = [0, 1]
for i in range(number-2):
result.append(result[-2] + result[-1])
return result
So this:
fibs(10) should give me [0, 1, 1, 2, ... | [
"The code in your post isn't valid Python. Since your code was able to run, it's probably actually like this:\ndef fibs(number):\n result = [0, 1]\n for i in range(number-2):\n result.append(result[-2] + result[-1])\n return result\n\nYour return result is indented such that it's inside the for ... | [
13,
2,
1
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0008350223_algorithm_python.txt |
Q:
Creating a new results/logging file using paramiko and sftp
I am using python and paramiko to read some files using sftp. The get is working fine. When I am done processing the file, I would like to put a file summarizing the results. I would rather not have to save the file locally first in order to do this; I... | Creating a new results/logging file using paramiko and sftp | I am using python and paramiko to read some files using sftp. The get is working fine. When I am done processing the file, I would like to put a file summarizing the results. I would rather not have to save the file locally first in order to do this; I have a dict of the results, I just want to create a file on the ... | [
"Did something similar a while ago, but i used disk files, maybe you find something useful:\nhttp://code.activestate.com/recipes/576810-copy-files-over-ssh-using-paramiko/\nAnd if you need to only create files in memory you could try\n StringIO: \nhttp://docs.python.org/library/stringio.html\n"
] | [
1
] | [] | [] | [
"paramiko",
"python"
] | stackoverflow_0008349234_paramiko_python.txt |
Q:
PyQt4 QComboBox Signals and Slots
is there a way to create a signal that asserts when a combo box is opened and user uses the up - down arrows on the keyboard to select an item. So far the Qt4 reference lists signals that activate only after a mouse click or return key hit. I tried highlighted(int) and that only... | PyQt4 QComboBox Signals and Slots | is there a way to create a signal that asserts when a combo box is opened and user uses the up - down arrows on the keyboard to select an item. So far the Qt4 reference lists signals that activate only after a mouse click or return key hit. I tried highlighted(int) and that only worked with another mouse click but w... | [
"The highlighted signal does appear to be the one you want.\nYou just need to make use of the passed value:\nclass CmdRef(Qg.QMainWindow):\n def __init__(self, parent = None):\n ...\n self.ui.cb_dspBenchCmds.highlighted['QString'].connect(self.chooseCmd)\n ...\n\n def chooseCmd(self, whic... | [
2
] | [] | [] | [
"pyqt",
"python",
"qcombobox",
"signals_slots"
] | stackoverflow_0008349301_pyqt_python_qcombobox_signals_slots.txt |
Q:
How can I run a program hundreds of times using Python?
I have a program which I need to call more than 100 times with different values.
I want to do it simultaneously that is not wait for one call to complete and then to start again.
How can I achieve it ?
Is multithreading the solution to it.
I am using python f... | How can I run a program hundreds of times using Python? | I have a program which I need to call more than 100 times with different values.
I want to do it simultaneously that is not wait for one call to complete and then to start again.
How can I achieve it ?
Is multithreading the solution to it.
I am using python for it.
| [
"You can do this with the subprocess module. Here is an example that runs the sleep command a hundred times, with a sleep value between 0 and 10 seconds. It runs them all in parallel and then exits when they all finish.\nimport subprocess\nimport time\n\nbin_path = 'sleep'\ninvocation_args = [[str(x*0.1)] for x in ... | [
3,
0,
0,
0
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0008348978_multithreading_python.txt |
Q:
Can we pass a function and the mocker to another function for mocking?
I want to pass the function form along with the mocker to another function in the testing class, and expect the function will be mocked after returning. However, it seemed not working, and thanks for any suggestions!
class Cls():
def submthd... | Can we pass a function and the mocker to another function for mocking? | I want to pass the function form along with the mocker to another function in the testing class, and expect the function will be mocked after returning. However, it seemed not working, and thanks for any suggestions!
class Cls():
def submthd(self):
return 0
def mthd(self):
a=self.submthd()
retur... | [
"I might be mistaken, but it seems to me that what you're trying to do is called \"Patching\" in Python Mocker parlance. You want to change the behaviour of the submthd() call on the existing instance of Cls().\nFirstly, you need to use new style classes (e.g. subclasses of object). So let's redefine Cls():\nclass ... | [
0
] | [] | [] | [
"python"
] | stackoverflow_0008349754_python.txt |
Q:
how to send the content in a list from server in twisted python?
I have a list related to multiclient chat server problem. This is the list ['talk', client_n, message]. How can I send 'message' to 'client_n' from the server in twisted python using transport.write()?
I wrote the code in two ways. But both are not... | how to send the content in a list from server in twisted python? | I have a list related to multiclient chat server problem. This is the list ['talk', client_n, message]. How can I send 'message' to 'client_n' from the server in twisted python using transport.write()?
I wrote the code in two ways. But both are not working.
1st way:
data = data.strip()
dat1 = data.split()
dat2 ... | [
"What is self.factory.clients? Is it perhaps a dictionary? Do you really want to do something like:\nclient = self.factory.clients.get(client_n)\nif client:\n client.transport.write(message)\n\n",
"I am not an expert, but maybe you should consider to serialize and deserialize your list through JSON ?\n"
] | [
6,
0
] | [] | [] | [
"chat",
"list",
"python",
"transport",
"twisted"
] | stackoverflow_0008326066_chat_list_python_transport_twisted.txt |
Q:
Google AppEngine Python: Class Not Defined
In my Python-coded AppEngine application, I'm getting the following error code:
NameError: global name 'PandaHugs' is not defined
I can't figure out why, as I define 'PandaHugs' above the place where it is called. Here's the code:
#!C:\Python25\python.exe -u
import wsg... | Google AppEngine Python: Class Not Defined | In my Python-coded AppEngine application, I'm getting the following error code:
NameError: global name 'PandaHugs' is not defined
I can't figure out why, as I define 'PandaHugs' above the place where it is called. Here's the code:
#!C:\Python25\python.exe -u
import wsgiref.handlers
from google.appengine.ext import d... | [
"You define the class PandasHugs early in your code, but later you have:\nHugForAPanda = PandaHugs(message=TheMessage)\n\nNotice the singular form of Panda? What you want is\nHugForAPanda = PandasHugs(message=TheMessage)\n\nEdit: You also have for PandasHugs in ListOfHugs: in the get() method of your MainPage class... | [
3
] | [] | [] | [
"class",
"google_app_engine",
"python"
] | stackoverflow_0008350558_class_google_app_engine_python.txt |
Q:
Input user into a list
I am trying to receive user input and then put it into a list. I have a working version, however, I feel as though it is redundant(the first block seems redundant, though if I take it away, it doesn't work). Any way this can be improved?
Thanks
def pastChoice():
choice = raw_input("> ")... | Input user into a list | I am trying to receive user input and then put it into a list. I have a working version, however, I feel as though it is redundant(the first block seems redundant, though if I take it away, it doesn't work). Any way this can be improved?
Thanks
def pastChoice():
choice = raw_input("> ")
prevMove = []
pre... | [
"you could do it this way? I don't know the real reason you are trying to do this, but to accept user input and add to a list this will do fine.\ndef main():\n prevMove = []\n choice = ''\n\n def getHistory():\n print prevMove\n\n while True:\n choice = raw_input(\"> \")\n ... | [
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0008350560_python.txt |
Q:
Python copy list issue
I don't know what's wrong here, I'm sure someone here can help though. I have a list mylst (list of lists) that's being copied and passed into the method foo. foo iterates through the list and replaces the first element in the row with a passed in var and returns the altered list. I print... | Python copy list issue | I don't know what's wrong here, I'm sure someone here can help though. I have a list mylst (list of lists) that's being copied and passed into the method foo. foo iterates through the list and replaces the first element in the row with a passed in var and returns the altered list. I print the list and I see it gives... | [
"The lst[:] trick makes a copy of one level of list. You've got nested lists, so you may want to have a look at the services offered by the copy standard module.\nIn particular:\nfirst = foo(copy.deepcopy(mylst), \"first\")\n\n",
"You aren't making another copy of mylist. Both times you call foo, you are passing... | [
7,
0
] | [] | [] | [
"python"
] | stackoverflow_0008350750_python.txt |
Q:
Python uses three unicode characters to represent an asian fullstop? This is weird?
The python file:
# -*- coding: utf-8 -*-
print u"。"
print [u"。".encode('utf8')]
Produces:
。
['\xe3\x80\x82']
Why does python use 3 characters to store my 1 fullstop? This is really strange, if you print each one out individuall... | Python uses three unicode characters to represent an asian fullstop? This is weird? | The python file:
# -*- coding: utf-8 -*-
print u"。"
print [u"。".encode('utf8')]
Produces:
。
['\xe3\x80\x82']
Why does python use 3 characters to store my 1 fullstop? This is really strange, if you print each one out individually, they are all different as well. Any ideas?
| [
"In UTF-8, three bytes (not really characters) are used to represent code points between U+07FF and U+FFFF, such as this character, IDEOGRAPHIC FULL STOP (U+3002).\nTry dumping the script file with od -x. You should find the same three bytes used to represent the character there. \n",
"UTF-8 is a multibyte charac... | [
7,
1,
0,
0
] | [] | [] | [
"python",
"unicode",
"utf_8"
] | stackoverflow_0008350347_python_unicode_utf_8.txt |
Q:
euler challenge 12, why does this python code fail?
The Following code keeps telling me a wrong number and I can't see why, know it's brute force but it should still work... also the number it returns has indeed over 500 divisors, 512 to be exact, help would be much appreciated
Number = 1
Count = 2
Found = False... | euler challenge 12, why does this python code fail? | The Following code keeps telling me a wrong number and I can't see why, know it's brute force but it should still work... also the number it returns has indeed over 500 divisors, 512 to be exact, help would be much appreciated
Number = 1
Count = 2
Found = False
while Found == False:
Divisors = 0
if (Number % ... | [
"The number of divisors of an integer is just the product of (1 + exponent) for each pure power in the factor decomposition of an integer.\nAs an example: 28 = 2^2 * 7\nThe powers are 2 and 1, so the number of divisors is (2+1)*(1+1) = 3*2 = 6. Easy one\nBigger one: 2047 * 2048 / 2 = 2^10 * 23 * 89\nThe powers are ... | [
3,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0008348255_python.txt |
Q:
how to add/subtract 2 days in the target day in python?
I have a problem in adding or subtracting 2 days to the target day...
here is my code :
import datetime
target_date = datetime.date(2011,2,7)
thanks
A:
Use datetime.timedelta:
import datetime
target_date = datetime.date(2011,2,7)
delta = datetime.timedel... | how to add/subtract 2 days in the target day in python? | I have a problem in adding or subtracting 2 days to the target day...
here is my code :
import datetime
target_date = datetime.date(2011,2,7)
thanks
| [
"Use datetime.timedelta:\nimport datetime\ntarget_date = datetime.date(2011,2,7)\n\ndelta = datetime.timedelta(days=2)\nnew_date = target_date - delta\n\nprint new_date # 2011-02-05\n\n"
] | [
6
] | [] | [] | [
"date",
"python"
] | stackoverflow_0008351150_date_python.txt |
Q:
Why does the numpy angle function return values also for the masked array values
If you try the following code segment
import numpy as np
import numpy.ma as ma
a = np.random.random(100) + 1j*np.random.random(100)
mask = np.ones_like(a, dtype='bool')
mask[0:9] = False
a = ma.masked_array(a, mask)
phase = np.angle(... | Why does the numpy angle function return values also for the masked array values | If you try the following code segment
import numpy as np
import numpy.ma as ma
a = np.random.random(100) + 1j*np.random.random(100)
mask = np.ones_like(a, dtype='bool')
mask[0:9] = False
a = ma.masked_array(a, mask)
phase = np.angle(a)
The phase array will not be masked. The angle function will return values for the ... | [
"Had a quick look at the numpy source, and it might be a bug/not implemented yet.\nIt's listed as a \"missing feature (work in progress)\" on the numpy.ma page, issue #1: http://projects.scipy.org/numpy/wiki/MaskedArray.\nThe problem is that a number of unary functions such as np.angle, np.quantile call [np.]asarra... | [
3
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0008346457_numpy_python.txt |
Q:
How do I catch/except registration errors with Django?
I want to be able to return a message to the user when they try to register but their registration fails.
I have tried all of the following methods:
try:
user = User.objects.create_user(username, email, password)
except User.DoesNotExist
print "aaa... | How do I catch/except registration errors with Django? | I want to be able to return a message to the user when they try to register but their registration fails.
I have tried all of the following methods:
try:
user = User.objects.create_user(username, email, password)
except User.DoesNotExist
print "aaaa"
try:
user = User.objects.create_user(username, ema... | [
"I'd suggest using the The Messages Framework.\nAlso, I can't imagine creating a user throwing DoesNotExist. The whole idea is that the user doesn't exist, so if that's thrown, there are some serious problems going on.\nBe aware also that the default backend for the messages framework is to store messages against a... | [
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0008351168_django_python.txt |
Q:
issue with gdata analytics client in python
I was able to successfully retrieve an OAuth access token for Google Analytics using Google's gdata python library.
However, my attempt to use the token to access Google Analytics data is failing. Here is the relevant code snippet:
client = gdata.analytics.client.Analyti... | issue with gdata analytics client in python | I was able to successfully retrieve an OAuth access token for Google Analytics using Google's gdata python library.
However, my attempt to use the token to access Google Analytics data is failing. Here is the relevant code snippet:
client = gdata.analytics.client.AnalyticsClient(source='myapp')
client.auth_token = acc... | [
"The problem is in gauth.py (part of the gdata client library) at about line 587 in version 2.0.15.\nThe value for the \"max-results\" parameter being passed to urllib.quote is 10000, an integer, not a string, so it doesn't have an iterator.\nMy quick hacky fix is:\n for key in sorted_keys:\n safe_str_param = u... | [
2,
0
] | [] | [] | [
"gdata",
"google_analytics",
"python"
] | stackoverflow_0005576210_gdata_google_analytics_python.txt |
Q:
Python - Spawn/Run a New Process Using Shell's stdin and stdout
I want to execute a non-python program from within python. The non-python program prompts the user for a password so I want stdin to be routed to that subprocess. Similarly, the subprocess has some stdout which I want to be printed to the console. Whe... | Python - Spawn/Run a New Process Using Shell's stdin and stdout | I want to execute a non-python program from within python. The non-python program prompts the user for a password so I want stdin to be routed to that subprocess. Similarly, the subprocess has some stdout which I want to be printed to the console. When the subprocess terminates, I would like the parent python program t... | [
"subprocess.call(whatever, stdin=sys.stdout, stdout=sys.stdin)\n\nHowever, are you sure that the password comes in through stdin? Command-line passwords generally use a different facility.\n"
] | [
3
] | [] | [] | [
"python"
] | stackoverflow_0008351582_python.txt |
Q:
Fiddler does not capture my script's requests
my code:
proxy = urllib2.ProxyHandler({'http': '127.0.0.1:8888'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://www.google.com')
print f.read()
this request does not show in Fiddler's capture, does anyone know how to ... | Fiddler does not capture my script's requests | my code:
proxy = urllib2.ProxyHandler({'http': '127.0.0.1:8888'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://www.google.com')
print f.read()
this request does not show in Fiddler's capture, does anyone know how to configure Fiddler so that the request is captured?
... | [
"I got the exactly the same issue, when fiddler2 opens, even I change \nproxy = urllib2.ProxyHandler({'http': 'http://asdfl.com:13212/'}) (such none existing proxy server), it still can get the page content, I guess maybe when proxy server has been setup by fiddler2, urllib2 totally ignore the ProxyHandler for some... | [
8
] | [] | [] | [
"fiddler",
"python"
] | stackoverflow_0007681305_fiddler_python.txt |
Q:
run an Excel Macro from Python (but an Excel process stays in memory)
with the following python method, I make a call to an Excel macro. I was happy when I got that to work, however I was wondering everytime I was executing this I could see a Windows temporary/lock file of the same name as the .XLA I was using the... | run an Excel Macro from Python (but an Excel process stays in memory) | with the following python method, I make a call to an Excel macro. I was happy when I got that to work, however I was wondering everytime I was executing this I could see a Windows temporary/lock file of the same name as the .XLA I was using the Macro from.
class XlaMakeUnmake:
__configFile = 'xla_svn.cfg'
__v... | [
"I don't know Python, but you need to use:\nxl.Quit\n\n"
] | [
2
] | [] | [] | [
"excel",
"python",
"win32com"
] | stackoverflow_0008346473_excel_python_win32com.txt |
Q:
Python 2.7 argparse
I have a function:
def x(a,b,c)
How can I collect variable values from the command line that fit this pattern?
python test.py --x_center a --y_center b c (c has, for example, 3, 4 or more values )
A:
You can do something like that like this:
import argparse
def x(x_center, y_center, values)... | Python 2.7 argparse | I have a function:
def x(a,b,c)
How can I collect variable values from the command line that fit this pattern?
python test.py --x_center a --y_center b c (c has, for example, 3, 4 or more values )
| [
"You can do something like that like this:\nimport argparse\n\ndef x(x_center, y_center, values):\n print \"X center:\", x_center\n print \"Y center:\", y_center\n print \"Values:\", values\n\ndef main():\n parser = argparse.ArgumentParser(description=\"Do something.\")\n parser.add_argument('-x', '-... | [
41
] | [] | [] | [
"argparse",
"python"
] | stackoverflow_0008351732_argparse_python.txt |
Q:
Google App Engine Datastore Query to JSON with Python
How can I get a JSON Object in python from getting data via Google App Engine Datastore?
I've got model in datastore with following field:
id
key_name
object
userid
created
Now I want to get all objects for one user:
query = Model.all().filter('userid', user.... | Google App Engine Datastore Query to JSON with Python | How can I get a JSON Object in python from getting data via Google App Engine Datastore?
I've got model in datastore with following field:
id
key_name
object
userid
created
Now I want to get all objects for one user:
query = Model.all().filter('userid', user.user_id())
How can I create a JSON object from the query s... | [
"Not sure if you got the answer you were looking for, but did you mean how to parse the model (entry) data in the Query object directly into a JSON object? (At least that's what I've been searching for).\nI wrote this to parse the entries from Query object into a list of JSON objects:\ndef gql_json_parser(query_obj... | [
8,
1,
0
] | [] | [] | [
"google_cloud_datastore",
"json",
"python"
] | stackoverflow_0005381660_google_cloud_datastore_json_python.txt |
Q:
Run Time Error (exit status 1) when submitting puzzle in Python
I have python 2.7 installed on my windows computer. I'm trying to email a puzzle answer to Spotify, which is running Python 2.6.6. When I submit my *.py source code, I'm getting the following error:
Run Time Error
Exited, exit status: 1
I only have ... | Run Time Error (exit status 1) when submitting puzzle in Python | I have python 2.7 installed on my windows computer. I'm trying to email a puzzle answer to Spotify, which is running Python 2.6.6. When I submit my *.py source code, I'm getting the following error:
Run Time Error
Exited, exit status: 1
I only have "import sys". I've run tons of stress tests - possible inputs are 1 ... | [
"I got the same error. As I see it's not python output but just an answer from spotify bot that your program threw an exception in some tests. Maybe the real output isn't shown to prevent debugging using the bot.\nWhen you print dummy data fist test fails and you get 'Wrong Answer'.\nWhen you print real output firs... | [
1
] | [] | [] | [
"exitstatus",
"python",
"runtime"
] | stackoverflow_0007512180_exitstatus_python_runtime.txt |
Q:
I need help figuring out some Python Regex
I have tried to properly wrap my head around the below but I still have big hole in my reasoning. What is ?::, and could someone explain it properly for me
rule_syntax = re.compile('(\\\\*)'\
'(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)'\
'|(?:<([a-zA-Z_][a-... | I need help figuring out some Python Regex | I have tried to properly wrap my head around the below but I still have big hole in my reasoning. What is ?::, and could someone explain it properly for me
rule_syntax = re.compile('(\\\\*)'\
'(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)'\
'|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)'\
'(?::((?:... | [
"There are two tools that you may wish to look into to help with your understanding\n\nRegexper creates a visual representation of regex, here's yours:\n\nRegexpal is a tool that allows you to input a regex and various strings and see what matches, here's yours with some example matches\n\n",
"(?:expr) is just li... | [
4,
3
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0008352020_python_regex.txt |
Q:
how to merge object/string array in django-python?
I have a code in my django that it look like this:
firstname = ['Mark', 'Kate']
lastname = ['Brown', 'White']
and the out-put should be like this
person = [['Mark', 'Brown']
['Kate', 'White']]
can anyone can give me some hint or sample code on how to ... | how to merge object/string array in django-python? | I have a code in my django that it look like this:
firstname = ['Mark', 'Kate']
lastname = ['Brown', 'White']
and the out-put should be like this
person = [['Mark', 'Brown']
['Kate', 'White']]
can anyone can give me some hint or sample code on how to get the output?
i try to use this method:
person = first... | [
"You can use:\n zip(firstname, lastmane)\n"
] | [
2
] | [] | [] | [
"arrays",
"django",
"python"
] | stackoverflow_0008352525_arrays_django_python.txt |
Q:
Python 3.x WSGI Testing framework
Given that webtest doesn't seem to have a 3.x version (or any plans to develop one), are there any solutions for automated system testing of a WSGI application? I know unittest for unit testing - I'm more interested in the moment in whole systems tests.
I'm not looking for tools t... | Python 3.x WSGI Testing framework | Given that webtest doesn't seem to have a 3.x version (or any plans to develop one), are there any solutions for automated system testing of a WSGI application? I know unittest for unit testing - I'm more interested in the moment in whole systems tests.
I'm not looking for tools to help develop an application - just te... | [
"In case anyone else comes upon this, I ended up writing a solution myself. Here's a very simple class I use - I just inherit from WSGIBaseTest instead of TestCase, and get a method self.request() that I can pass requests into. It stores cookies, and will automatically send them into the application on later reques... | [
4
] | [] | [] | [
"integration_testing",
"python",
"python_3.x",
"testing",
"wsgi"
] | stackoverflow_0007266809_integration_testing_python_python_3.x_testing_wsgi.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.