title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
How to get a flat XML so that external entities are merged to the top level | 2,019,317 | <p>I know this is a borderline case whether it really belongs to stackoverflow or superuser, but as it seems there are quite a few 'editing code' questions over here, I am posting it on SO.</p>
<p>I have a pile of XML files that someone in their infinite wisdom have decided to explode to a multiple files using the ta... | 5 | 2010-01-07T09:30:23Z | 2,053,977 | <p>If you have libxml2 installed, then xmllint will probably do this for you. Depending on your setup, you might need more params, but for your example, </p>
<pre><code>xmllint --noent foobar.xml
</code></pre>
<p>will print your file to stdout with all entities resolved. Should be easy enough to wrap some bash script... | 4 | 2010-01-13T02:28:10Z | [
"python",
"xml",
"bash",
"editor",
"sed"
] |
saving data in Bulk using Django | 2,019,379 | <p>I have objects A witch has many to many relation ship to object b.
Is it possible to save objects A with it's B collection in a bulk ' I mean not to save B objects one by one then add them to A.</p>
<pre><code>for b in b_objects :
A.b_objs.add(b)
A.save()
</code></pre>
<p>Thanks</p>
| 0 | 2010-01-07T09:47:23Z | 2,019,393 | <p>You could dump your model to json (from <a href="http://www.djangosnippets.org/snippets/125/" rel="nofollow">http://www.djangosnippets.org/snippets/125/)</a>:</p>
<pre><code>import sys, os
sys.path.append('/Path/To/Django/Projects/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
from django.core.ser... | 0 | 2010-01-07T09:50:34Z | [
"python",
"django"
] |
saving data in Bulk using Django | 2,019,379 | <p>I have objects A witch has many to many relation ship to object b.
Is it possible to save objects A with it's B collection in a bulk ' I mean not to save B objects one by one then add them to A.</p>
<pre><code>for b in b_objects :
A.b_objs.add(b)
A.save()
</code></pre>
<p>Thanks</p>
| 0 | 2010-01-07T09:47:23Z | 2,025,716 | <p>I don't think so. The ManyToMany relationship is realized with an intermediate table than contains (id, a_id, b_id) tuples. Therefore <a href="http://www.djangoproject.com/documentation/models/many_to_many/" rel="nofollow">A must pre-exist</a> (See 'Sample API Usage') and each B must have an <code>id</code> before t... | 0 | 2010-01-08T05:27:08Z | [
"python",
"django"
] |
Python Instantiating SubClasses | 2,019,415 | <p>I wrote the following code trying to figure out how to instantiate the subclasses within the main class.. I came up with something that doesn't feel right.. at least for me. </p>
<p>Is there something wrong with this type of instancing? Is there a better way to call subclasses? </p>
<pre><code>class Family():
de... | 1 | 2010-01-07T09:54:08Z | 2,019,470 | <p>You are right, this code does not <em>feel</em> right. My questions would be ..</p>
<ul>
<li><p>What are you trying to achieve? There is not need to define <code>Father</code> and <code>Mother</code> inside <code>Family</code>, they could be defined outside <code>Family</code> and aggregated into it. (Is it the fac... | 1 | 2010-01-07T10:07:11Z | [
"python"
] |
Python Instantiating SubClasses | 2,019,415 | <p>I wrote the following code trying to figure out how to instantiate the subclasses within the main class.. I came up with something that doesn't feel right.. at least for me. </p>
<p>Is there something wrong with this type of instancing? Is there a better way to call subclasses? </p>
<pre><code>class Family():
de... | 1 | 2010-01-07T09:54:08Z | 2,019,483 | <p>Blergh.</p>
<p>Why are Father and Mother nested under Family? There's no reason to do this. Define them outside, then instantiate them inside.</p>
<p>I'm not sure exactly what you want to do. You may want to look into <a href="http://users.rcn.com/python/download/Descriptor.htm" rel="nofollow">Descriptors</a>, whi... | 1 | 2010-01-07T10:10:08Z | [
"python"
] |
Python Instantiating SubClasses | 2,019,415 | <p>I wrote the following code trying to figure out how to instantiate the subclasses within the main class.. I came up with something that doesn't feel right.. at least for me. </p>
<p>Is there something wrong with this type of instancing? Is there a better way to call subclasses? </p>
<pre><code>class Family():
de... | 1 | 2010-01-07T09:54:08Z | 2,019,527 | <p>What you've defined there are <em>not</em> (in Python terminology at least) subclasses - they're inner classes, or nested classes. I'm guessing that this isn't actually what you were trying to achieve, but I'm not sure what you did actually want - but here are my four best guesses:</p>
<ol>
<li><p><a href="http://d... | 6 | 2010-01-07T10:18:46Z | [
"python"
] |
https username and pwd + saving file with webbrowser | 2,019,482 | <p>Hi All
I would like to use python webbrowser to access a secure https page and save it into a file.</p>
<p>Am I right if I say that with webbrowser control is not possible to save an entire web page but only opening a URL? I didn't see any 'save' method.</p>
<p>Other than this, the page I want to use is a secure h... | 0 | 2010-01-07T10:09:53Z | 2,019,849 | <ol>
<li><p>Save means "Write a file to the disk". Of course there's no "save" method. The library opens the URL so your program can read it. Period. If your program wants to write it to disk, that's not part of reading a URL, so it's not part of browsing.</p></li>
<li><p>Use urllib2 for this. Not the webbrowser. ... | 0 | 2010-01-07T11:24:03Z | [
"python"
] |
how to use 'pickle' | 2,019,489 | <p>my code(i was unable to use 'pickle'):</p>
<pre><code>class A(object):
def __getstate__(self):
print 'www'
return 'sss'
def __setstate__(self,d):
print 'aaaa'
import pickle
a = A()
s = pickle.dumps(a)
e = pickle.loads(s)
print s,e
</code></pre>
<p>print :</p>
<pre><code>www
aaaa
c... | 2 | 2010-01-07T10:11:23Z | 2,019,514 | <p>In a nutshell, in your example, e equals a.</p>
<p>Don't have to care about these strang strings, you can dumps these strings to save to anywhere, just remember when you loads them, you got 'a' object again. </p>
| 0 | 2010-01-07T10:16:59Z | [
"python",
"pickle"
] |
how to use 'pickle' | 2,019,489 | <p>my code(i was unable to use 'pickle'):</p>
<pre><code>class A(object):
def __getstate__(self):
print 'www'
return 'sss'
def __setstate__(self,d):
print 'aaaa'
import pickle
a = A()
s = pickle.dumps(a)
e = pickle.loads(s)
print s,e
</code></pre>
<p>print :</p>
<pre><code>www
aaaa
c... | 2 | 2010-01-07T10:11:23Z | 2,019,530 | <p>You are able to <code>pickle</code> (meaning, this code works as it should). You just seem to get a result, you don't expect. If you expect the same 'output', try:</p>
<pre><code>import pickle
a = A()
s = pickle.dumps(a)
e = pickle.loads(s)
print s, pickle.dumps(e)
</code></pre>
<p>Your example isn't, well, a typi... | 3 | 2010-01-07T10:19:01Z | [
"python",
"pickle"
] |
how to use 'pickle' | 2,019,489 | <p>my code(i was unable to use 'pickle'):</p>
<pre><code>class A(object):
def __getstate__(self):
print 'www'
return 'sss'
def __setstate__(self,d):
print 'aaaa'
import pickle
a = A()
s = pickle.dumps(a)
e = pickle.loads(s)
print s,e
</code></pre>
<p>print :</p>
<pre><code>www
aaaa
c... | 2 | 2010-01-07T10:11:23Z | 2,019,571 | <p>What are you trying to do? It works for me:</p>
<pre><code>class A(object):
def __init__(self):
self.val = 100
def __str__(self):
"""What a looks like if your print it"""
return 'A:'+str(self.val)
import pickle
a = A()
a_pickled = pickle.dumps(a)
a.val = 200
a2 = pickle.loads(a_pic... | 4 | 2010-01-07T10:29:31Z | [
"python",
"pickle"
] |
How to import a variable from different file types | 2,019,552 | <p>I am trying to obtain a variable from a different file type and import it into a Python script. The file is version.mk, it has a variable called VARIABLE_ID. The import module does not work as normally, is there any way to call variables from other file types?</p>
<p>Thanks for any help</p>
<pre><code>import os
f... | 1 | 2010-01-07T10:24:45Z | 2,019,579 | <p>If you are sure about <code>version.mk</code> is valid python file, and does not have any harm codes, you can execute it.</p>
<pre><code>>>> exec(open("version.mk"))
>>> print VERSION_ID
1
</code></pre>
<hr>
<p><strong>UPDATE</strong>: because OP Added VERSION_ID is not a valid python number</p>... | 1 | 2010-01-07T10:31:43Z | [
"python"
] |
How to import a variable from different file types | 2,019,552 | <p>I am trying to obtain a variable from a different file type and import it into a Python script. The file is version.mk, it has a variable called VARIABLE_ID. The import module does not work as normally, is there any way to call variables from other file types?</p>
<p>Thanks for any help</p>
<pre><code>import os
f... | 1 | 2010-01-07T10:24:45Z | 2,019,635 | <p>If your file isn't Python code, you can't import it as if it were.</p>
<p>You need to open the file manually and parse for the setting. Especially if the line containing the number is something like</p>
<pre><code>VERSION_ID = 0.0.2
</code></pre>
<p>Since this can never be valid Python (there's no literal that lo... | 1 | 2010-01-07T10:44:47Z | [
"python"
] |
How to unzip python eggs? | 2,019,565 | <p>I'm trying to bundle some egg dependencies when using py2exe and as stated on the py2exe site, it doesn't work with those and I need to unzip them first. I've tried to first run <code>easy_install -m lxml</code> and then <code>easy_install --always-unzip lxml==2.2.2</code>, but it didn't work. Then I tried to set th... | 3 | 2010-01-07T10:28:24Z | 2,020,122 | <p>Quick hack/workaround: egg files are just zip files, so you can use the python zipfile module to unzip them. Maybe you could rename the easy_install file to "easy_install_pre.exe", and create a new .bat file named "easy_install.bat":</p>
<pre><code>easy_install_pre.exe %1
unzip_eggs.py %1
</code></pre>
| 2 | 2010-01-07T12:13:09Z | [
"python",
"py2exe",
"easy-install",
"egg"
] |
How to unzip python eggs? | 2,019,565 | <p>I'm trying to bundle some egg dependencies when using py2exe and as stated on the py2exe site, it doesn't work with those and I need to unzip them first. I've tried to first run <code>easy_install -m lxml</code> and then <code>easy_install --always-unzip lxml==2.2.2</code>, but it didn't work. Then I tried to set th... | 3 | 2010-01-07T10:28:24Z | 7,972,865 | <p>The zippped package file should be <strong>first removed before reinstalling</strong>. Then is is easy.</p>
<p>All methods of unzipped installation described in the question should work if the zipped package is removed first but does not work without it. Reinstallation of zipped package after unzipped installation ... | 0 | 2011-11-01T21:02:00Z | [
"python",
"py2exe",
"easy-install",
"egg"
] |
Python's CSV reader and iteration | 2,019,573 | <p>I have a CSV file that looks like this:</p>
<pre><code>"Company, Inc.",,,,,,,,,,,,10/30/09
A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01
All Clients,,,,,,,,,,,,USER
Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit
1000001111,CLIENT A,0,0,"3,711.32",0,... | 10 | 2010-01-07T10:29:46Z | 2,019,652 | <pre><code>import re
import StringIO
data=re.search("Client Account[^\r\n]+[\r\n]+(.*)(?=Grand Total)",open(filename).read(),re.DOTALL).group(1)
datafile=StringIO.StringIO(data)
inputFile = csv.reader(datafile, dialect='excel')
records = [line for line in inputFile if line and line[0].isdigit()]
</code></pre>
| 6 | 2010-01-07T10:46:42Z | [
"python",
"csv",
"iteration"
] |
Python's CSV reader and iteration | 2,019,573 | <p>I have a CSV file that looks like this:</p>
<pre><code>"Company, Inc.",,,,,,,,,,,,10/30/09
A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01
All Clients,,,,,,,,,,,,USER
Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit
1000001111,CLIENT A,0,0,"3,711.32",0,... | 10 | 2010-01-07T10:29:46Z | 2,019,690 | <p>you can do it like this, by setting flag</p>
<pre><code>import csv
file = "file"
f=0
reader = csv.reader(open(file),delimiter=',')
for row in reader:
if "Grand Total" in row: break
if "Client Account" in row: f=1;continue
if f:
if row[0].isdigit():
print row
</code></pre>
| 9 | 2010-01-07T10:55:15Z | [
"python",
"csv",
"iteration"
] |
Python's CSV reader and iteration | 2,019,573 | <p>I have a CSV file that looks like this:</p>
<pre><code>"Company, Inc.",,,,,,,,,,,,10/30/09
A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01
All Clients,,,,,,,,,,,,USER
Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit
1000001111,CLIENT A,0,0,"3,711.32",0,... | 10 | 2010-01-07T10:29:46Z | 2,019,760 | <p>Use a nice little generator for something like this. This one could be generalized a little more if your requirements change:</p>
<pre><code>def lines_between(source, first, second):
for line in source:
if line and line[0] == first:
break
for line in source:
if line: and line[0... | 3 | 2010-01-07T11:09:18Z | [
"python",
"csv",
"iteration"
] |
Python's CSV reader and iteration | 2,019,573 | <p>I have a CSV file that looks like this:</p>
<pre><code>"Company, Inc.",,,,,,,,,,,,10/30/09
A/R Summary Aged Analysis Report,,,,,,,,,,,,10:35:01
All Clients,,,,,,,,,,,,USER
Client Account,Customer Name,15-Jan,16 - 30,31 - 60,61 - 90,91 - 120,120 - Over,Total,Status,Credit Limit
1000001111,CLIENT A,0,0,"3,711.32",0,... | 10 | 2010-01-07T10:29:46Z | 2,019,990 | <p>Via generators. You can build all kinds of complexity from simple generator-filter functions. While considerably more complex than your filter, this is more extensible and can easily handle really complex spreadsheets. </p>
<pre><code>def skip_blank( rdr ):
for row in rdr:
if len(row) == 0: continue
... | 10 | 2010-01-07T11:47:15Z | [
"python",
"csv",
"iteration"
] |
Integer division compared to floored quotient: why this surprising result? | 2,019,588 | <p>The <code>//</code> "integer division" operator of Python surprised me, today:</p>
<pre><code>>>> math.floor(11/1.1)
10.0
>>> 11//1.1
9.0
</code></pre>
<p>The <a href="http://docs.python.org/library/stdtypes.html#index-593">documentation</a> reads "(floored) quotient of x and y". So, why is math... | 7 | 2010-01-07T10:33:25Z | 2,019,598 | <p>Because 1.1 can't be represented in binary form exactly; the approximation is a littler higher than 1.1 - therefore the division result is a bit too small. </p>
<p>Try the following:</p>
<p>Under Python 2, type at the console:</p>
<pre><code>>>> 1.1
1.1000000000000001
</code></pre>
<p>In Python 3.1, the... | 5 | 2010-01-07T10:36:04Z | [
"python",
"python-3.x",
"python-2.x",
"integer-division",
"floor"
] |
python vs java on web service development? | 2,019,621 | <p>i am currently using php as backend language in webdevelopment. but im wondering what you need to install to get running with python and java.</p>
<p>with php i need apache and mysql.</p>
<p>can i use those for java and python too?</p>
<p>i cant find good guides equivalent to LAMP/MAMP/WAMP so i understand the pa... | 4 | 2010-01-07T10:42:26Z | 2,019,676 | <p>You need to look into the <code>Web Application Framework</code> subject. Some SO pointers:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/776495/simple-webserver-or-web-testing-framework">simple-webserver-or-web-testing-framework</a></li>
<li><a href="http://stackoverflow.com/questions/1289941/web-applic... | 4 | 2010-01-07T10:52:06Z | [
"java",
"python"
] |
python vs java on web service development? | 2,019,621 | <p>i am currently using php as backend language in webdevelopment. but im wondering what you need to install to get running with python and java.</p>
<p>with php i need apache and mysql.</p>
<p>can i use those for java and python too?</p>
<p>i cant find good guides equivalent to LAMP/MAMP/WAMP so i understand the pa... | 4 | 2010-01-07T10:42:26Z | 2,019,826 | <p>I can only give suggestions for web development in python:</p>
<ul>
<li>Use <a href="http://www.tornadoweb.org/" rel="nofollow">Tornado</a> - A non blocking web server.</li>
<li>Use <a href="http://jinja.pocoo.org/2/" rel="nofollow">Jinja2</a> - A templating engine.</li>
<li>Use <a href="http://www.mongodb.org/" re... | 4 | 2010-01-07T11:19:20Z | [
"java",
"python"
] |
python vs java on web service development? | 2,019,621 | <p>i am currently using php as backend language in webdevelopment. but im wondering what you need to install to get running with python and java.</p>
<p>with php i need apache and mysql.</p>
<p>can i use those for java and python too?</p>
<p>i cant find good guides equivalent to LAMP/MAMP/WAMP so i understand the pa... | 4 | 2010-01-07T10:42:26Z | 2,019,939 | <p><a href="http://www.web2py.com/" rel="nofollow">web2py</a> is a python web framework that is completely self-contained, runs portably off a USB drive even. The manual is available on <a href="http://www.web2py.com/examples/default/docs" rel="nofollow">scribd</a>, and after an hour or two of tutorial you will have a ... | 2 | 2010-01-07T11:38:41Z | [
"java",
"python"
] |
sftp using ftplib | 2,019,780 | <p>Hi All
I need to download a file from a host using sFTP.</p>
<p>Do you know if is it possible to do that using python ftplib?
I saw <a href="http://stackoverflow.com/questions/432385/sftp-in-python-platform-independent">an example here</a>, but when I try to connect I receive <code>EOFError</code>.</p>
<p>I tried ... | 6 | 2010-01-07T11:12:02Z | 2,019,800 | <p>As <a href="http://stackoverflow.com/questions/432385/sftp-in-python-platform-independent">the question you linked to</a> states, ftplib doesn't support sftp (which is FTP over SSH and has nothing to do with FTPS, FTP over SSL). Use the <a href="http://stackoverflow.com/questions/432385/sftp-in-python-platform-indep... | 8 | 2010-01-07T11:15:52Z | [
"python",
"sftp",
"ftplib"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,019,803 | <p>The better syntax would be:</p>
<pre><code>[x for x in lst if x is None]
[x for x in lst if x is not None]
</code></pre>
| 4 | 2010-01-07T11:16:17Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,019,808 | <p>You don't need an <code>if</code>, you can just say</p>
<pre><code>[x for x in list]
</code></pre>
| 0 | 2010-01-07T11:17:01Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,019,810 | <p>What do you mean by</p>
<blockquote>
<p>I would like to have the same thing to match everything</p>
</blockquote>
<p>Just do</p>
<pre><code>[x for x in list]
</code></pre>
<p>and every item in <code>list</code> is matched.</p>
| 3 | 2010-01-07T11:17:16Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,019,822 | <blockquote>
<p>but I would like to have the same
thing to match everything</p>
</blockquote>
<p>To match everything, you don't need if statement</p>
<pre><code>[x for x in list1]
</code></pre>
<p>or If you really like to do</p>
<pre><code>[x for x in list1 if x in [x]]
</code></pre>
| 0 | 2010-01-07T11:19:00Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,021,002 | <p>Answering your revised question: the list that "matches" all possible values is effectively of infinite length. So you can't do what you want to do without an if test. I suggest that your arg should be either a list or one of two values representing the "all" and "none" cases:</p>
<pre><code>FILTER_NONE = object() ... | 0 | 2010-01-07T14:41:29Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,021,061 | <p>You could change your program to accept a filter object, instead of a list. </p>
<p>The abstract base filter would have a <code>matches</code> method, that returns true if x *matches".</p>
<p>Your general case filters would be constructed with a list argument, and would filter on membership of the list - the <code... | 3 | 2010-01-07T14:49:58Z | [
"python",
"filtering",
"list-comprehension"
] |
python list that matches everything | 2,019,791 | <p>I probably didn't ask correctly: I would like a list value that can match any list: the "inverse" of <code>(None,)</code>
but even with <code>(None,)</code> it will match item as None (which I don't want)</p>
<p>The point is I have a function working with: <code>[x for x in my_list if x[field] not in filter_list]</... | 1 | 2010-01-07T11:14:21Z | 2,021,187 | <p><code>__contains__</code> is the magic method that checks if something is in a sequence:</p>
<pre><code>class everything(object):
def __contains__(self, _):
return True
for x in (1,2,3):
print x in everything()
</code></pre>
| 5 | 2010-01-07T15:07:46Z | [
"python",
"filtering",
"list-comprehension"
] |
Error when install python mysql module on windows? | 2,019,827 | <p>When i try to install mysql on windows i get this error</p>
<pre><code>MySQL-python-0.9.2>python setup.py build
running build
running build_py
running build_ext
building '_mysql' extension
error: Unable to find vcvarsall.bat
</code></pre>
| 4 | 2010-01-07T11:19:31Z | 2,019,845 | <p>I guess, you don't have visual c++ compiler installed or compiler not in the PATH.</p>
<p>If you have mingw32, you can pass paramter <code>-c mingw32</code></p>
<p>And mysql-python is available as <a href="http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.win32-py2.5.exe/down... | 5 | 2010-01-07T11:23:26Z | [
"python",
"mysql",
"windows"
] |
Python basic maths | 2,019,850 | <p>My friend wrote up this script for me to calculate the quantity of construction materials needed for a theoretical site. </p>
<p>It basically takes 2 numbers and increases them independently until the large number reaches 50,000. It then prints a list like this:</p>
<pre><code>20000:6.40,21000:6.61,22000:6.82,2300... | 2 | 2010-01-07T11:24:07Z | 2,019,871 | <p>You can replace <code>string += str(getsmallint)</code> with <code>string += str(getsmallint*1.225)</code></p>
| 0 | 2010-01-07T11:28:07Z | [
"python",
"multiplication"
] |
Python basic maths | 2,019,850 | <p>My friend wrote up this script for me to calculate the quantity of construction materials needed for a theoretical site. </p>
<p>It basically takes 2 numbers and increases them independently until the large number reaches 50,000. It then prints a list like this:</p>
<pre><code>20000:6.40,21000:6.61,22000:6.82,2300... | 2 | 2010-01-07T11:24:07Z | 2,019,885 | <p>Replace the line:</p>
<pre><code>string += str(getbingint) + ":" + str("%.2f") % getsmallint + ","
</code></pre>
<p>with</p>
<pre><code>string += str(getbingint) + ":" + str("%.2f") % (getsmallint*1.225) + ","
</code></pre>
| 1 | 2010-01-07T11:30:13Z | [
"python",
"multiplication"
] |
Python basic maths | 2,019,850 | <p>My friend wrote up this script for me to calculate the quantity of construction materials needed for a theoretical site. </p>
<p>It basically takes 2 numbers and increases them independently until the large number reaches 50,000. It then prints a list like this:</p>
<pre><code>20000:6.40,21000:6.61,22000:6.82,2300... | 2 | 2010-01-07T11:24:07Z | 2,019,963 | <p>here's another version</p>
<pre><code>getbingint = input("Enter big start value: ")
getbiginc = input("Enter big increment value: ")
getsmallint = input("Enter small start value: ")
getsmalinc = input("Enter small increment value: ")
getbigend = input("Enter big end value: ")
for i in range(getbingint,getbigend,get... | 1 | 2010-01-07T11:43:13Z | [
"python",
"multiplication"
] |
cross module variable | 2,019,877 | <p>from <a href="http://stackoverflow.com/questions/142545/python-how-to-make-a-cross-module-variable">here</a> I got an idea about how using variables from other modules. this all works fine with</p>
<pre><code>import foo as bar
</code></pre>
<p>But I don't want to import my modules as "bar" I want to use it without... | 1 | 2010-01-07T11:28:33Z | 2,019,934 | <p>By using <code>import foo from bar</code> you don't import <code>bar</code> as a variable but as a constant.</p>
| 0 | 2010-01-07T11:37:36Z | [
"python",
"import",
"module"
] |
cross module variable | 2,019,877 | <p>from <a href="http://stackoverflow.com/questions/142545/python-how-to-make-a-cross-module-variable">here</a> I got an idea about how using variables from other modules. this all works fine with</p>
<pre><code>import foo as bar
</code></pre>
<p>But I don't want to import my modules as "bar" I want to use it without... | 1 | 2010-01-07T11:28:33Z | 2,019,950 | <p>As far as I know, there is no way to import a value <em>from</em> a module and have it readable and writable by the importing scope. When you just <code>import foo</code> in Python, it creates a module object named <code>foo</code>. Getting and setting attributes on a module object will change them in the module's s... | 2 | 2010-01-07T11:40:44Z | [
"python",
"import",
"module"
] |
cross module variable | 2,019,877 | <p>from <a href="http://stackoverflow.com/questions/142545/python-how-to-make-a-cross-module-variable">here</a> I got an idea about how using variables from other modules. this all works fine with</p>
<pre><code>import foo as bar
</code></pre>
<p>But I don't want to import my modules as "bar" I want to use it without... | 1 | 2010-01-07T11:28:33Z | 2,019,959 | <p><code>from foo import *</code> is frowned upon (by me, by <a href="http://code.google.com/p/soc/wiki/PythonStyleGuide#Module_and_package_imports" rel="nofollow">Google's style guide</a>, by the <a href="http://wiki.laptop.org/go/Python_Style_Guide#Imports" rel="nofollow">OLPC style guide</a> - which you should see, ... | 0 | 2010-01-07T11:42:26Z | [
"python",
"import",
"module"
] |
cross module variable | 2,019,877 | <p>from <a href="http://stackoverflow.com/questions/142545/python-how-to-make-a-cross-module-variable">here</a> I got an idea about how using variables from other modules. this all works fine with</p>
<pre><code>import foo as bar
</code></pre>
<p>But I don't want to import my modules as "bar" I want to use it without... | 1 | 2010-01-07T11:28:33Z | 2,020,160 | <p>Short answer: No, it's impossible, and you'll have to use a prefix. </p>
<p>It's important to understand that <code>from foo import x, y</code> is <em>copying</em> <code>x</code> to your namespace. It's equivallent to:</p>
<pre><code>import foo
# COPY TO YOUR NAMESPACE
x = foo.x
y = foo.y
# `from foo import` doe... | 3 | 2010-01-07T12:19:43Z | [
"python",
"import",
"module"
] |
Python inserting a short integer into a list of bytes | 2,019,929 | <p>I have a list of bytes as follows</p>
<pre><code>pkt_bytes = [ 0x02,0x07, 0xff,0xff ,0x00,0x03]
</code></pre>
<p>in the position <code>0xff,0xff</code> I want to put a 16bit short integer</p>
<p>How do I do it</p>
<p>Regards</p>
| 2 | 2010-01-07T11:36:57Z | 2,019,940 | <p>Try:</p>
<pre><code>>>> pkt_bytes.insert(3, 0xaa)
>>> help(pkt_bytes.insert)
Help on built-in function insert:
insert(...)
L.insert(index, object) -- insert object before index
</code></pre>
| 0 | 2010-01-07T11:39:06Z | [
"python",
"list"
] |
Python inserting a short integer into a list of bytes | 2,019,929 | <p>I have a list of bytes as follows</p>
<pre><code>pkt_bytes = [ 0x02,0x07, 0xff,0xff ,0x00,0x03]
</code></pre>
<p>in the position <code>0xff,0xff</code> I want to put a 16bit short integer</p>
<p>How do I do it</p>
<p>Regards</p>
| 2 | 2010-01-07T11:36:57Z | 2,019,957 | <p>You can use the <a href="http://docs.python.org/library/struct.html" rel="nofollow"><code>struct</code> module</a> to pack values into appropriate formats:</p>
<pre><code>>>> pkt_bytes = [0x02, 0x07, 0xff, 0xff, 0x00, 0x03]
>>> myint = 123
>>> pkt_bytes[3:5] = [ord(b) for b in struct.pack... | 5 | 2010-01-07T11:42:10Z | [
"python",
"list"
] |
Python inserting a short integer into a list of bytes | 2,019,929 | <p>I have a list of bytes as follows</p>
<pre><code>pkt_bytes = [ 0x02,0x07, 0xff,0xff ,0x00,0x03]
</code></pre>
<p>in the position <code>0xff,0xff</code> I want to put a 16bit short integer</p>
<p>How do I do it</p>
<p>Regards</p>
| 2 | 2010-01-07T11:36:57Z | 2,019,970 | <p>The code below will replace every occurrence of <code>0xff</code> with <code>0x04</code> until there are no more <code>0xff</code> left in the list.</p>
<pre><code>pkt_bytes = [0x02, 0x07, 0xff, 0xff ,0x00, 0x03]
while True:
try:
idx = pkt_bytes.index(0xff)
pkt_bytes[idx] = 0x04
except Value... | 0 | 2010-01-07T11:44:26Z | [
"python",
"list"
] |
Python inserting a short integer into a list of bytes | 2,019,929 | <p>I have a list of bytes as follows</p>
<pre><code>pkt_bytes = [ 0x02,0x07, 0xff,0xff ,0x00,0x03]
</code></pre>
<p>in the position <code>0xff,0xff</code> I want to put a 16bit short integer</p>
<p>How do I do it</p>
<p>Regards</p>
| 2 | 2010-01-07T11:36:57Z | 2,019,997 | <pre><code>>>> pkt_bytes = [ 0x02,0x07, 0xff,0xff ,0x00,0x03]
>>> pkt_bytes[2:4] = [pkt_bytes[2] << 8 | pkt_bytes[3]]
>>> pkt_bytes
[2, 7, 65535, 0, 3]
</code></pre>
| 0 | 2010-01-07T11:48:11Z | [
"python",
"list"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,019,955 | <p>You could adapt any of the popular sorting routines to do this. Just use foo(x) for comparison rather than x. </p>
| 0 | 2010-01-07T11:41:56Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,019,973 | <p>With a little bit of LINQ:</p>
<pre><code>var q = from el in li
orderby foo(el)
select el;
li = q.ToList();
</code></pre>
| 10 | 2010-01-07T11:44:47Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,019,975 | <p>This is the Python way: Just pass the function as the <code>key</code> argument to <code>sorted()</code> or <code>.sort()</code>:</p>
<pre><code>>>> mylist = [123, 765, 4, 13]
>>> def mod5(x):
... return x%5
...
>>> sorted(mylist, key = mod5)
[765, 123, 13, 4]
>>> sorted(myli... | 5 | 2010-01-07T11:44:55Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,020,129 | <p>The Haskell solution is particularly elegant with the <a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-Function.html#v%3Aon" rel="nofollow"><code>on</code></a> combinator from Data.Function.</p>
<pre><code>import Data.Function (on)
import Data.List (sortBy)
lists = [ [ 5, 6, 8 ]
... | 10 | 2010-01-07T12:14:50Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,020,264 | <p>Any other language? Ok, here's some F#:</p>
<p>Example: sort by sum:</p>
<pre><code>let foo = List.sum
let li = [[1;2];[42;1];[3;4]]
let result = li |> List.sortBy (fun el -> foo el)
</code></pre>
<p>Result (F# interactive):</p>
<pre><code>val result : int list list = [[1; 2]; [3; 4]; [42; 1]]
</code></pr... | 1 | 2010-01-07T12:36:17Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,021,093 | <p>in erlang:</p>
<pre><code>-module (codegolfs).
-export ([sortmain/0]).
sortmain() ->
sort(
fun (SubList) -> lists:sum(SubList) end,
[ [1,2,3],[1,3],[2,5,6] ]).
% output: [[2,5,6],[1,2,3],[1,3]]
sort(Fun,List) ->
lists:sort( fun(A,B) -> Fun(A) < Fun(B) end,List ).
</code></pre>
| 1 | 2010-01-07T14:54:37Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,021,122 | <p>Ruby:</p>
<pre><code>mylist = [[1,2,3],
[3,5,9],
[1,1,1],
[10,23,14]]
sortedlist = mylist.sort {|a,b| b.inject {|sum, n| sum + n } <=> a.inject {|sum,n| sum + n}}
</code></pre>
<p>I'm not sure the rules of Code Golf and I didn't write a foo method, but the sum could ea... | 2 | 2010-01-07T15:00:37Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,021,958 | <p>In Perl, this is often done with the well-known <a href="http://en.wikipedia.org/wiki/Schwartzian_transform" rel="nofollow">Schwartzian transform</a>.</p>
<pre><code>use List::Util qw(sum);
@li = map {$$_[0]} sort {$$a[1] <=> $$b[1]} map {[$_, sum(@$_)]} @li;
</code></pre>
<p>Reusing <a href="http://search.c... | 2 | 2010-01-07T16:45:22Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,022,799 | <p>Tcl: </p>
<pre><code>proc foo nums {tcl::mathop::+ {*}$nums}
set l {{1 2 3} {4 5 6} {3} {42 -40}}
lsort -command {apply {{a b} {expr {[foo $a] - [foo $b]}}}} $l
# => {42 -40} 3 {1 2 3} {4 5 6}
</code></pre>
| 0 | 2010-01-07T18:52:33Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,028,789 | <p>Ruby (shamelessly copying Beanish's input data):</p>
<pre><code>list = [
[1, 2, 3],
[3, 5, 9],
[1, 1, 1],
[10, 23, 14]
]
p list.sort_by { |a| -a.inject(&:+) }
# => [[10, 23, 14], [3, 5, 9], [1, 2, 3], [1, 1, 1]]
</code></pre>
| 1 | 2010-01-08T15:58:03Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
How do I sort this list? | 2,019,951 | <p>I have a list of lists.</p>
<pre><code>List<List<T>> li = {
{a1,a2,a3 ... aN},
{b1,b2,b3 ... bN},
...
};
double foo(List<T> list)
{
// do something
// e.g {1,2,3}
// it = 1 + 2 + 3
return it;
}
</code></pre>
<p>Now I want to sort <code>li</code> in such a way that hig... | 4 | 2010-01-07T11:40:52Z | 2,032,235 | <p>Clojure:</p>
<pre><code>(let [lst '((1 2 3) (3 5 9) (1 1 1) (10 23 14))]
(sort #(> (foo %1) (foo %2)) lst))
</code></pre>
| 1 | 2010-01-09T03:24:11Z | [
"c#",
"python",
"ruby",
"sorting",
"haskell"
] |
python json unicode - how do I eval using javascript | 2,019,966 | <p>Really spent a lot of time searching for this. Please need some help.</p>
<p>I am trying to add multilingual feature to my web app framework. For this I am unable to send non ascii characters as JSON. Here is what I am doing</p>
<ol>
<li><p>Here is what I get from the database</p>
<p>'\xe0\xa4\xa4\xe0\xa5\x87\xe0... | 3 | 2010-01-07T11:43:25Z | 2,019,992 | <p>Is this your desired output (see <code>ensure_ascii</code> argument for <a href="http://docs.python.org/library/json.html#json.dumps" rel="nofollow"><code>json.dumps</code></a>)?</p>
<pre><code>sys.stdout.write(json.dumps(response, ensure_ascii=False))
{"a": "तà¥à¤¸à¥à¤¤"}
</code></pre>
| 4 | 2010-01-07T11:47:57Z | [
"python",
"json",
"unicode",
"cgi"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 2,020,027 | <p><code>__module__</code> would do the trick.</p>
<p>Try:</p>
<pre><code>>>> import re
>>> print re.compile.__module__
re
</code></pre>
<p><a href="http://www.swaroopch.com/notes/Python_en:Modules" rel="nofollow">This site</a> suggests that <code>__package__</code> might work for Python 3.0; Howev... | 6 | 2010-01-07T11:52:54Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 2,020,061 | <p>Consider using the <code>inspect</code> module which has functions like <code>getmodule</code> which might be what are looking for:</p>
<pre><code>>>>import inspect
>>>import xml.etree.ElementTree
>>>et = xml.etree.ElementTree.ElementTree()
>>>inspect.getmodule(et)
<module 'xm... | 15 | 2010-01-07T11:58:56Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 2,020,083 | <p>With the following program</p>
<pre><code>#! /usr/bin/env python
import foo
def fullname(o):
return o.__module__ + "." + o.__class__.__name__
bar = foo.Bar()
print fullname(bar)
</code></pre>
<p>and <code>Bar</code> defined as</p>
<pre><code>class Bar(object):
def __init__(self, v=42):
self.val = v
</c... | 57 | 2010-01-07T12:03:02Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 2,564,344 | <p>Since the interest of this topic is to get fully qualified names, here is a pitfall that occurs when using relative imports along with the main module existing in the same package. E.g.:</p>
<pre><code>$ mkdir -p /tmp/fqname/foo
$ touch /tmp/fqname/foo/__init__.py
$ cat<<END > /tmp/fqname/foo/bar.py
> f... | 1 | 2010-04-01T23:50:14Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 13,653,312 | <p>Here's one based on Greg Bacon's excellent answer, but with a couple of extra checks:</p>
<p><code>__module__</code> can be <code>None</code> (according to the docs), and also for a type like <code>str</code> it can be <code>__builtin__</code> (which you might not want appearing in logs or whatever). The following... | 7 | 2012-11-30T21:17:43Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 16,763,814 | <p>The provided answers don't deal with nested classes. Though it's not available until Python 3.3 (<a href="http://www.python.org/dev/peps/pep-3155" rel="nofollow">PEP 3155</a>), you really want to use <code>__qualname__</code> of the class. Eventually (3.4? <a href="http://www.python.org/dev/peps/pep-0395" rel="nofol... | 12 | 2013-05-26T21:23:33Z | [
"python",
"python-datamodel"
] |
Get fully qualified class name of an object in Python | 2,020,014 | <p>For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I mean the class name including the package and module name.)</p>
<p>I know about <code>x.__class__.__name__</code>, but is there a simple method to get the package and module?</p>
| 59 | 2010-01-07T11:50:28Z | 19,388,184 | <p>This is a hack but I'm supporting 2.6 and just need something simple:</p>
<pre><code>>>> from logging.handlers import MemoryHandler as MH
>>> str(MH).split("'")[1]
'logging.handlers.MemoryHandler'
</code></pre>
| 2 | 2013-10-15T18:12:56Z | [
"python",
"python-datamodel"
] |
Increment a VERSION ID by one and write to .mk file | 2,020,180 | <p>I have code to read in the version number from a make file.</p>
<pre><code>VERSION_ID=map(int,re.match("VERSION_ID\s*=\s*(\S+)",open("version.mk").read()).group(1).split("."))
</code></pre>
<p>This code takes VERSION_ID=0.0.2 and stores it as [0, 0, 2].</p>
<p>Is there any way I can increment this number by one a... | 0 | 2010-01-07T12:23:08Z | 2,020,913 | <p>perhpas something like this (you should also check for errors and that)</p>
<pre><code>#! /usr/bin/python
import re
fn = "version.mk"
omk = open(fn).readlines()
nmk = open(fn, "w")
r = re.compile(r'(VERSION_ID\s*=\s*)(\S+)')
for l in omk:
m1 = r.match(l)
if m1:
VERSION_ID=map(int,m1.group(2).spli... | 2 | 2010-01-07T14:19:14Z | [
"python"
] |
SWIG Python bindings for OpenCV 2.0 with MacPorts | 2,020,228 | <p>Y'all,</p>
<p>I've been at to for 3 days trying to get OpenCV Python binds happening, and I have (the full epic struggle is <a href="http://www.tsd.net.au/blog/opencv-python-bindings-macports" rel="nofollow">documented here</a>) but despite turning the SWIG flag on in CMake after installing swig via macports, I'm n... | 1 | 2010-01-07T12:30:24Z | 2,027,767 | <p>Seems that the cmake flags didn't make much of a difference. I became systematic and reduced them to the minimum:</p>
<pre><code>cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_SWIG_PYTHON_SUPPORT=OFF -D BUILD_NEW_PYTHON_SUPPORT=ON -D PYTHON_INCLUDE_DIR=/opt/... | 0 | 2010-01-08T13:17:54Z | [
"python",
"opencv",
"cmake",
"swig",
"macports"
] |
SWIG Python bindings for OpenCV 2.0 with MacPorts | 2,020,228 | <p>Y'all,</p>
<p>I've been at to for 3 days trying to get OpenCV Python binds happening, and I have (the full epic struggle is <a href="http://www.tsd.net.au/blog/opencv-python-bindings-macports" rel="nofollow">documented here</a>) but despite turning the SWIG flag on in CMake after installing swig via macports, I'm n... | 1 | 2010-01-07T12:30:24Z | 4,444,786 | <p>If you're ok with the newer (non-SWIG) bindings, which imho are better anyway, you can just install directly via MacPorts:</p>
<pre><code>sudo port install opencv +python26
</code></pre>
<p>or</p>
<pre><code>sudo port install opencv +python27
</code></pre>
<p>as appropriate.</p>
<p>See also <a href="http://stac... | 0 | 2010-12-14T22:07:26Z | [
"python",
"opencv",
"cmake",
"swig",
"macports"
] |
Compilation warning in Python | 2,020,317 | <p>when a python file is compiled in linux machine the following warning is seen
but the same file compiled in Solaris machine, warning is not seen</p>
<pre><code>/opt/swe/tools/ext/gnu/python-2.3.5_p1/i686-linux2.4/lib/python2.3/config/libpython2.3.a(posixmodule.o)(.text+0x3e9a): In function `posix_tmpnam':
./Modules... | 1 | 2010-01-07T12:45:19Z | 2,020,338 | <p>Maybe update your python? Like, to 2.6.4</p>
| 0 | 2010-01-07T12:50:31Z | [
"python"
] |
Compilation warning in Python | 2,020,317 | <p>when a python file is compiled in linux machine the following warning is seen
but the same file compiled in Solaris machine, warning is not seen</p>
<pre><code>/opt/swe/tools/ext/gnu/python-2.3.5_p1/i686-linux2.4/lib/python2.3/config/libpython2.3.a(posixmodule.o)(.text+0x3e9a): In function `posix_tmpnam':
./Modules... | 1 | 2010-01-07T12:45:19Z | 2,020,498 | <p>You are using an older version of python. </p>
<p>Since then it became clear that the tmpnam function is not safe, and the libraries / headers shipping with linux have been updated to give you a warning. But it should compile, as backwards compatibility is pretty important.</p>
<p>Python 2.3 was developed in a tim... | 4 | 2010-01-07T13:16:40Z | [
"python"
] |
Compilation warning in Python | 2,020,317 | <p>when a python file is compiled in linux machine the following warning is seen
but the same file compiled in Solaris machine, warning is not seen</p>
<pre><code>/opt/swe/tools/ext/gnu/python-2.3.5_p1/i686-linux2.4/lib/python2.3/config/libpython2.3.a(posixmodule.o)(.text+0x3e9a): In function `posix_tmpnam':
./Modules... | 1 | 2010-01-07T12:45:19Z | 5,620,698 | <p>You get the same warning with libpython2.6.a so the suggestions to upgrade are unhelpful. Only upgrading to Python 3 gets rid of the warnings (see Python bug 1318) but that's not an option for some people.</p>
<p>One way to avoid the warning is to link to a library providing definitions of tmpnam_r and tempnam so ... | 1 | 2011-04-11T11:38:44Z | [
"python"
] |
how do i get the byte count of a variable in python just like wc -c gives in unix | 2,020,318 | <p>i am facing some problem with files with huge data.
i need to skip doing some execution on those files.
i get the data of the file into a variable.
now i need to get the byte of the variable and if it is greater than 102400 , then print a message.</p>
<p>update : i cannot open the files , since it is present in a t... | 1 | 2010-01-07T12:45:37Z | 2,020,334 | <p>This answer seems irrelevant, since I seem to have misunderstood the question, which has now been clarified. However, should someone find this question, while searching with pretty much the same terms, this answer may still be relevant:</p>
<p>Just open the file in binary mode</p>
<p>f = open(filename, 'rb')</p>
... | 0 | 2010-01-07T12:49:18Z | [
"python",
"tar"
] |
how do i get the byte count of a variable in python just like wc -c gives in unix | 2,020,318 | <p>i am facing some problem with files with huge data.
i need to skip doing some execution on those files.
i get the data of the file into a variable.
now i need to get the byte of the variable and if it is greater than 102400 , then print a message.</p>
<p>update : i cannot open the files , since it is present in a t... | 1 | 2010-01-07T12:45:37Z | 2,020,347 | <pre><code>import os
length_in_bytes = os.stat('file.txt').st_size
if length_in_bytes > 102400:
print 'Its a big file!'
</code></pre>
<p>Update to work on files in a tarfile</p>
<pre><code>import tarfile
tf = tarfile.TarFile('foo.tar')
for member in tarfile.getmembers():
if member.size > 102400:
... | 6 | 2010-01-07T12:51:01Z | [
"python",
"tar"
] |
how do i get the byte count of a variable in python just like wc -c gives in unix | 2,020,318 | <p>i am facing some problem with files with huge data.
i need to skip doing some execution on those files.
i get the data of the file into a variable.
now i need to get the byte of the variable and if it is greater than 102400 , then print a message.</p>
<p>update : i cannot open the files , since it is present in a t... | 1 | 2010-01-07T12:45:37Z | 2,020,364 | <p>If I'm understanding the question correctly, you want to skip certain input files if they're too large. For that, you can use <a href="http://docs.python.org/library/os.path.html" rel="nofollow"><code>os.path.getsize()</code></a>:</p>
<pre><code>import os.path
if os.path.getsize('f') <= 102400:
doit();
</code... | 2 | 2010-01-07T12:54:12Z | [
"python",
"tar"
] |
how do i get the byte count of a variable in python just like wc -c gives in unix | 2,020,318 | <p>i am facing some problem with files with huge data.
i need to skip doing some execution on those files.
i get the data of the file into a variable.
now i need to get the byte of the variable and if it is greater than 102400 , then print a message.</p>
<p>update : i cannot open the files , since it is present in a t... | 1 | 2010-01-07T12:45:37Z | 2,020,417 | <p>Just check the length of the string, then:</p>
<pre><code>if len(data) > 102400:
print "Skipping file which is too large, at %d bytes" % len(data)
else:
process(data) # The normal processing
</code></pre>
| 2 | 2010-01-07T13:02:45Z | [
"python",
"tar"
] |
how do i get the byte count of a variable in python just like wc -c gives in unix | 2,020,318 | <p>i am facing some problem with files with huge data.
i need to skip doing some execution on those files.
i get the data of the file into a variable.
now i need to get the byte of the variable and if it is greater than 102400 , then print a message.</p>
<p>update : i cannot open the files , since it is present in a t... | 1 | 2010-01-07T12:45:37Z | 2,020,425 | <p><code>len(data)</code> gives you the size in bytes if it's binary data. With strings the size depends on the encoding used.</p>
| 1 | 2010-01-07T13:04:30Z | [
"python",
"tar"
] |
How do I send a mail via mailx & subprcoess? | 2,020,476 | <p>I am EE, trying to write a script to simplify file checks using Python.
For some reason, our IT will not let me gain access to our smtp server, and will only allow sending mail via mailx.
So, I've thought of running mailx from Python and send it, in the same way that it works in my console. Alas, it gives an exeptio... | 3 | 2010-01-07T13:12:45Z | 2,020,553 | <p>you can use smtplib </p>
<pre><code>import smtplib
# email options
SERVER = "localhost"
FROM = "root@example.com"
TO = ["root"]
SUBJECT = "Alert!"
TEXT = "This message was sent with Python's smtplib."
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(... | 4 | 2010-01-07T13:25:40Z | [
"python",
"subprocess"
] |
How do I send a mail via mailx & subprcoess? | 2,020,476 | <p>I am EE, trying to write a script to simplify file checks using Python.
For some reason, our IT will not let me gain access to our smtp server, and will only allow sending mail via mailx.
So, I've thought of running mailx from Python and send it, in the same way that it works in my console. Alas, it gives an exeptio... | 3 | 2010-01-07T13:12:45Z | 2,020,581 | <p>You cas use <code>subprocess.call</code>. Like:</p>
<pre><code>subprocess.call(["mailx", "-s", "\"Test Python\"", "mymail@mycomopany.com"])
</code></pre>
<p>Details <a href="http://docs.python.org/library/subprocess.html#convenience-functions" rel="nofollow">here</a></p>
| 2 | 2010-01-07T13:29:26Z | [
"python",
"subprocess"
] |
In Python how should I test if a variable is None, True or False | 2,020,598 | <p>I have a function that can return one of three things:</p>
<ul>
<li>success (<code>True</code>)</li>
<li>failure (<code>False</code>)</li>
<li>error reading/parsing stream (<code>None</code>)</li>
</ul>
<p>My question is, if I'm not supposed to test against <code>True</code> or <code>False</code>, how should I see... | 57 | 2010-01-07T13:32:36Z | 2,020,606 | <pre><code>if result is None:
print "error parsing stream"
elif result:
print "result pass"
else:
print "result fail"
</code></pre>
<p>keep it simple and explicit. You can of course pre-define a dictionary.</p>
<pre><code>messages = {None: 'error', True: 'pass', False: 'fail'}
print messages[result]
</cod... | 63 | 2010-01-07T13:33:24Z | [
"python"
] |
In Python how should I test if a variable is None, True or False | 2,020,598 | <p>I have a function that can return one of three things:</p>
<ul>
<li>success (<code>True</code>)</li>
<li>failure (<code>False</code>)</li>
<li>error reading/parsing stream (<code>None</code>)</li>
</ul>
<p>My question is, if I'm not supposed to test against <code>True</code> or <code>False</code>, how should I see... | 57 | 2010-01-07T13:32:36Z | 2,020,642 | <p>I believe that throwing an exception is a better idea for your situation. An alternative will be the simulation method to return a tuple. The first item will be the status and the second one the result:</p>
<pre><code>result = simulate(open("myfile"))
if not result[0]:
print "error parsing stream"
else:
ret= re... | 1 | 2010-01-07T13:39:41Z | [
"python"
] |
In Python how should I test if a variable is None, True or False | 2,020,598 | <p>I have a function that can return one of three things:</p>
<ul>
<li>success (<code>True</code>)</li>
<li>failure (<code>False</code>)</li>
<li>error reading/parsing stream (<code>None</code>)</li>
</ul>
<p>My question is, if I'm not supposed to test against <code>True</code> or <code>False</code>, how should I see... | 57 | 2010-01-07T13:32:36Z | 2,020,704 | <p>Don't fear the Exception! Having your program just log and continue is as easy as:</p>
<pre><code>try:
result = simulate(open("myfile"))
except SimulationException as sim_exc:
print "error parsing stream", sim_exc
else:
if result:
print "result pass"
else:
print "result fail"
# exe... | 64 | 2010-01-07T13:46:51Z | [
"python"
] |
In Python how should I test if a variable is None, True or False | 2,020,598 | <p>I have a function that can return one of three things:</p>
<ul>
<li>success (<code>True</code>)</li>
<li>failure (<code>False</code>)</li>
<li>error reading/parsing stream (<code>None</code>)</li>
</ul>
<p>My question is, if I'm not supposed to test against <code>True</code> or <code>False</code>, how should I see... | 57 | 2010-01-07T13:32:36Z | 2,021,257 | <p>Never, never, never say</p>
<pre><code>if something == True:
</code></pre>
<p>Never. It's crazy, since you're redundantly repeating what is redundantly specified as the redundant condition rule for an if-statement.</p>
<p>Worse, still, never, never, never say</p>
<pre><code>if something == False:
</code></pre>
... | 13 | 2010-01-07T15:15:28Z | [
"python"
] |
In Python how should I test if a variable is None, True or False | 2,020,598 | <p>I have a function that can return one of three things:</p>
<ul>
<li>success (<code>True</code>)</li>
<li>failure (<code>False</code>)</li>
<li>error reading/parsing stream (<code>None</code>)</li>
</ul>
<p>My question is, if I'm not supposed to test against <code>True</code> or <code>False</code>, how should I see... | 57 | 2010-01-07T13:32:36Z | 37,413,702 | <p>I would like to stress that, even if there are situations where <code>if expr :</code> isn't sufficient because one wants to make sure <code>expr</code> is <code>True</code> and not just different from <code>0</code>/<code>None</code>/whatever, <code>is</code> is to be prefered from <code>==</code> <a href="http://s... | 1 | 2016-05-24T12:33:14Z | [
"python"
] |
How powerful is x3d for making animations? | 2,021,055 | <p>I want to make a rotating drillbit animation that shows the complete process of drilling.</p>
<p>I am not really sure that it can be done using <a href="http://en.wikipedia.org/wiki/X3D" rel="nofollow">x3d</a>. How good is x3d (along with python scripting, maybe) to make such animations?</p>
| 0 | 2010-01-07T14:48:41Z | 2,468,080 | <blockquote>
<p>I am not really sure that it can be
done using x3d. How good is x3d (along
with python scripting, maybe) to make
such animations?</p>
</blockquote>
<p>If you are running a modern - <a href="http://www.x3dom.org/?page_id=9" rel="nofollow">developer version browser</a>, then you can visit my home... | 0 | 2010-03-18T07:12:40Z | [
"python",
"animation",
"x3d"
] |
Python based web reporting tool? | 2,021,252 | <p>I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I c... | 4 | 2010-01-07T15:15:10Z | 2,021,281 | <p><a href="http://www.reportlab.org/">ReportLab</a></p>
<blockquote>
<p>Welcome to the ReportLab Open Source site. ReportLab is a library for programatically creating PDF documents. It's a fast, flexible, cross platform solution written in Python.</p>
</blockquote>
| 7 | 2010-01-07T15:17:43Z | [
"python",
"reporting"
] |
Python based web reporting tool? | 2,021,252 | <p>I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I c... | 4 | 2010-01-07T15:15:10Z | 2,021,396 | <p>Or go a little higher level than reportlab: <del><a href="http://www.xhtml2pdf.com/" rel="nofollow">xhtml2pdf</a></del> - now <a href="http://weasyprint.org/" rel="nofollow">WeasyPrint</a> (built on top of reportlab)</p>
<p>From the website:</p>
<ul>
<li>Translates HTML and CSS input into PDF files</li>
<li>Is wri... | 5 | 2010-01-07T15:31:40Z | [
"python",
"reporting"
] |
Python based web reporting tool? | 2,021,252 | <p>I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I c... | 4 | 2010-01-07T15:15:10Z | 2,022,186 | <p>Most reporting tools are stuck in the '80s: a time when you 'painted' a report intended to be printed that completely lacked integration with other reports.</p>
<p>Sometimes we still need that. If you need to print an invoice, you're pretty much stuck with that kind of functionality. But in general, most reportin... | 2 | 2010-01-07T17:20:12Z | [
"python",
"reporting"
] |
Python based web reporting tool? | 2,021,252 | <p>I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I c... | 4 | 2010-01-07T15:15:10Z | 2,044,362 | <p>Also have a look at <a href="http://mydbr.com" rel="nofollow">myDBR</a> a tool that allows you to define your reports in the database (using stored procedures) and then takes care of the layout and formatting of the data.</p>
<p>Even though myDBR is a PHP application, it does not require any PHP coding, just instal... | 1 | 2010-01-11T19:33:08Z | [
"python",
"reporting"
] |
Python based web reporting tool? | 2,021,252 | <p>I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I c... | 4 | 2010-01-07T15:15:10Z | 8,385,707 | <p>Try to have look at the <a href="http://databrewery.org/cubes.html" rel="nofollow">Cubes - Light-weight OLAP</a> framework for Python. It is just partial solution for your problem, but I think it might help.</p>
<ul>
<li><a href="https://github.com/Stiivi/cubes" rel="nofollow">Sources at github</a></li>
<li><a href... | 2 | 2011-12-05T13:00:04Z | [
"python",
"reporting"
] |
How do I execute (not import) a python script from a python prompt? | 2,021,345 | <p>I need to execute a Python script from an already started Python session, as if it were launched from the command line. I'm thinking of similar to doing <code>source</code> in bash or sh.</p>
| 6 | 2010-01-07T15:25:15Z | 2,021,400 | <p>In Python 2, the builtin function <a href="http://docs.python.org/library/functions.html#execfile" rel="nofollow"><code>execfile</code></a> does this.</p>
<pre><code>execfile(filename)
</code></pre>
| 11 | 2010-01-07T15:32:12Z | [
"python",
"bash",
"import",
"module"
] |
How do I execute (not import) a python script from a python prompt? | 2,021,345 | <p>I need to execute a Python script from an already started Python session, as if it were launched from the command line. I'm thinking of similar to doing <code>source</code> in bash or sh.</p>
| 6 | 2010-01-07T15:25:15Z | 2,021,747 | <p>If you're running <a href="http://ipython.scipy.org/" rel="nofollow">ipython</a> (which I highly recommend for interactive python sessions), you can type:</p>
<pre><code>%run filename
</code></pre>
<p>or</p>
<pre><code>%run filename.py
</code></pre>
<p>to execute the module (rather than importing it). You'll ge... | 3 | 2010-01-07T16:13:04Z | [
"python",
"bash",
"import",
"module"
] |
Download file using urllib in Python with the wget -c feature | 2,021,519 | <p>I am programming a software in Python to download HTTPÂ PDF from a database.
Sometimes the download stop with this message : </p>
<pre><code>retrieval incomplete: got only 3617232 out of 10689634 bytes
</code></pre>
<p>How can I ask the download to restart where it stops using the <code>206 Partial Content</code> ... | 7 | 2010-01-07T15:46:42Z | 2,021,586 | <p>You can request a partial download by sending a GET with the <code>Range</code> header:</p>
<pre><code>import urllib2
req = urllib2.Request('http://www.python.org/')
#
# Here we request that bytes 18000--19000 be downloaded.
# The range is inclusive, and starts at 0.
#
req.headers['Range'] = 'bytes=%s-%s' % (18000,... | 7 | 2010-01-07T15:53:27Z | [
"python",
"http",
"download",
"urllib2",
"urllib"
] |
How do I get Sphinx to test code embedded in documentation? | 2,021,671 | <p>If this code is a blockquote in my documentation, what do I need to do to make <a href="http://sphinx.pocoo.org/" rel="nofollow">Sphinx</a> run it when the documentation is generated? I tried adding</p>
<pre><code>.. testcode::
import datetime
def today():
return datetime.datetime.now().date()
... | 3 | 2010-01-07T16:04:49Z | 2,030,984 | <p>The <code>testcode</code> directive needs a matching <code>testoutput</code> directive.</p>
<p>Here's the example from the documentation.</p>
<pre><code>.. testcode::
print 'Output text.'
.. testoutput::
:hide:
:options: -ELLIPSIS, +NORMALIZE_WHITESPACE
Output text.
</code></pre>
| 3 | 2010-01-08T21:47:16Z | [
"python",
"python-sphinx"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,021,832 | <p>Largely distribution won't matter, as Python is present and largely self sufficient on virtually all Linux distributions.</p>
<p>If you're wanting to focus on development, I'd recommend Ubuntu. Ubuntu is arguably one of the most fully featured "ready for the user" distributions that makes system administration a s... | 11 | 2010-01-07T16:24:47Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,021,840 | <p>I use RHEL and have been very happy, so from that I would say Fedora would be fine. I use Debian at home, and it's great (headless though, so no web there).</p>
<p>That said, I think you should probably just pick one based on what your company uses, or any number of non-Python reasons. I don't think you are going... | 0 | 2010-01-07T16:25:53Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,021,851 | <p>You distribution should have Python 2.6. Otherwise it's a matter of choice.</p>
<p>One advice: Never ever install anything as root (eg. <code>python setup.py install</code>). Only install things with your distribution's package manager and use <a href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> as a use... | 6 | 2010-01-07T16:27:51Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,021,876 | <p>Most major distributions will include Python and Apache, so it's really just a matter of choice. If you're new to Linux, I'd suggest either Ubuntu or Fedora. Both are great for new users and have excellent community support.</p>
| 0 | 2010-01-07T16:31:10Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,022,173 | <p>As the other answers have mentioned so far, the Python 2.6 interpreter will be available on all recent Linux distribution releases. That shouldn't influence your choice.</p>
<p>However, your choice of IDE may eliminate some possibilities. You should make sure the distribution you select has a package for the latest... | 0 | 2010-01-07T17:17:47Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 2,975,353 | <p>I am working with Python on Cento 5.4 and Fedora 12 and I am very happy.</p>
<p>I also use Eclipse IDE for python and other languages without having any major issues.</p>
| 0 | 2010-06-04T15:05:19Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 5,528,749 | <p>Any desktop distribution like Ubuntu, OpenSUSE, Fedora, ... is OK, But if you want to always have the latest versions, I recommend ArchLinux.</p>
| 0 | 2011-04-03T09:35:24Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 9,386,203 | <p>Using a distribution with the latest stable versions of Python only lets you test your code with those versions. Today it's very easy for developers to test their code with multiple Python versions.</p>
<p>Gentoo probably gives you the most flexibility with multiple Python versions installed at once:</p>
<pre><cod... | 1 | 2012-02-21T22:21:13Z | [
"python",
"windows",
"linux",
"preferences"
] |
What linux distro is better suited for Python web development? | 2,021,803 | <p>Which linux distro is better suited for Python web development?</p>
<p><em>Background:</em></p>
<p>I currently develop on Windows and it's fine, but I am looking to move my core Python development to Linux. I'm sure most any distro will work fine, but does anyone have any reasons to believe one distro is better th... | 5 | 2010-01-07T16:21:36Z | 28,327,632 | <p>i think i remember a podcast with Guido Van Rossum and his core team python developers back in the days, and one of that core python developer is now employed by Canonical to take care of python integration for the ubuntu distro. So that explains why ubuntu is a much more pythonic distro compared to other distro. </... | 0 | 2015-02-04T17:27:28Z | [
"python",
"windows",
"linux",
"preferences"
] |
Cannot prettify scraped html in BeautifulSoup | 2,022,014 | <p>I have a small script that use <code>urllib2</code> to get contents of a site, find all the link tags, appends a small piece of HTML in on the top and bottom, and then I try to prettify it. It keeps returning TypeError: sequence item 1: expected string, Tag found. I have looked around,i can't really find the issue. ... | 2 | 2010-01-07T16:53:48Z | 2,022,048 | <pre><code>soup1 = BeautifulSoup(''.join(unicode(tag) for tag in tags))
</code></pre>
| 0 | 2010-01-07T16:59:04Z | [
"python",
"html",
"parsing",
"beautifulsoup"
] |
Cannot prettify scraped html in BeautifulSoup | 2,022,014 | <p>I have a small script that use <code>urllib2</code> to get contents of a site, find all the link tags, appends a small piece of HTML in on the top and bottom, and then I try to prettify it. It keeps returning TypeError: sequence item 1: expected string, Tag found. I have looked around,i can't really find the issue. ... | 2 | 2010-01-07T16:53:48Z | 2,024,587 | <p>This works for me:</p>
<pre><code>soup1 = BeautifulSoup(''.join(str(t) for t in tags))
</code></pre>
<p>This pyparsing solution gives some decent output, too:</p>
<pre><code>from pyparsing import makeHTMLTags, originalTextFor, SkipTo, Combine
# makeHTMLTags defines HTML tag patterns for given tag string
aTag,aE... | 2 | 2010-01-07T23:55:27Z | [
"python",
"html",
"parsing",
"beautifulsoup"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.