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 |
|---|---|---|---|---|---|---|---|---|---|
Programatically updating a spreadsheet hosted on google docs | 1,837,937 | <p>I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update.</p>
<p>I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas.</p>
<p>I'm using... | 8 | 2009-12-03T05:58:04Z | 4,079,371 | <ol>
<li>Clone your template worksheet using the instructions on <a href="http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#CopyingDocs">Copying Documents</a></li>
<li>Access the <a href="http://code.google.com/apis/spreadsheets/data/1.0/developers_guide_python.html#listWorksheets">list of w... | 6 | 2010-11-02T15:43:32Z | [
"python",
"google-docs"
] |
Programatically updating a spreadsheet hosted on google docs | 1,837,937 | <p>I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update.</p>
<p>I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas.</p>
<p>I'm using... | 8 | 2009-12-03T05:58:04Z | 8,706,754 | <p><strong>Whoa!!! Back the truck up. There's a much simpler approach</strong></p>
<p>I have been researching this a bit over the past few weeks because I'm planning to do the same thing for my monthly reports. I don't have the actual code fleshed out yet but I'll add it as I make progress.</p>
<p>In Google Docs ther... | 4 | 2012-01-03T00:33:12Z | [
"python",
"google-docs"
] |
How to get the URL Image which is displyed by script | 1,838,047 | <p>When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code.</p>
<p>I am using the selenium for testing. I want to download this image for verification/comparison.</p>
<p>How to get that image using python?</p>
| 0 | 2009-12-03T06:26:36Z | 1,838,239 | <p>You need to step through the Javascript on that page which might be calling some server-side code to generate that image (e.g. a Captcha image). Using the tools-> page info-> media in Firefox also gives you images on the page that the browser knows about. This post for example gives me <a href="http://stackoverflow.... | 0 | 2009-12-03T07:22:48Z | [
"python"
] |
How to get the URL Image which is displyed by script | 1,838,047 | <p>When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code.</p>
<p>I am using the selenium for testing. I want to download this image for verification/comparison.</p>
<p>How to get that image using python?</p>
| 0 | 2009-12-03T06:26:36Z | 1,838,243 | <p>If you aren't seeing an actual image tag in the HTML, your next step would seem to be figuring out how its being displayed. </p>
<p>The first place I'd suggest looking is in the .css files for this page. Images can actually be embedded using CSS, and this seems like the next likely option after being in the HTML co... | 0 | 2009-12-03T07:23:33Z | [
"python"
] |
How to get the URL Image which is displyed by script | 1,838,047 | <p>When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code.</p>
<p>I am using the selenium for testing. I want to download this image for verification/comparison.</p>
<p>How to get that image using python?</p>
| 0 | 2009-12-03T06:26:36Z | 1,870,291 | <p>if you just want to download the image, theres two strategies you can try:</p>
<ol>
<li><p>use a something like Firebug or Chrome developer tools. right click the element in question, click "inspect element", and look at the css properties of the element. if you look around, you should find something like backgro... | 0 | 2009-12-08T22:21:40Z | [
"python"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 1,838,211 | <p>It depends: see <a href="http://stackoverflow.com/questions/22149/unicode-vs-utf-8-confusion-in-python-django">here</a>. This is still true for Python 3 as far as internal representation goes.</p>
| 1 | 2009-12-03T07:12:22Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 1,838,228 | <p>I think, Its hard to judge difference between UTF-16, which is just a sequences of 16 bit words, to Python's string object.</p>
<p>And If python is compiled with Unicode=UCS4 option, it will be comparing between UTF-32 and Python string.</p>
<p>So, better consider, they are in different category, although you can ... | 0 | 2009-12-03T07:18:44Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 1,838,285 | <p>There has been NO CHANGE in Unicode internal representation between Python 2.X and 3.X.</p>
<p>It's definitely NOT UTF-16. <strong>UTF-anything is a byte-oriented EXTERNAL representation.</strong></p>
<p>Each code unit (character, surrogate, etc) has been assigned a number from range(0, 2 ** 21). This is called it... | 3 | 2009-12-03T07:37:52Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 1,838,733 | <p>Looking at the source code for CPython 3.1.5, in <a href="https://hg.python.org/cpython/file/v3.1.5/Include/unicodeobject.h#l436" rel="nofollow"><code>Include/unicodeobject.h</code></a>:
</p>
<pre><code>/* --- Unicode Type ------------------------------------------------------- */
typedef struct {
PyObject_HEA... | 4 | 2009-12-03T09:25:36Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 9,079,985 | <p>The internal representation will change in Python 3.3 which implements <a href="http://www.python.org/dev/peps/pep-0393/">PEP 393</a>. The new representation will pick one or several of ascii, latin-1, utf-8, utf-16, utf-32, generally trying to get a compact representation.</p>
<p>Implicit conversions into surrogat... | 15 | 2012-01-31T13:03:36Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
What is internal representation of string in Python 3.x | 1,838,170 | <p>In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16?</p>
<blockquote>
<p>The items of a string object are
Unicode code units. A Unicode code
unit is represented by a string obje... | 13 | 2009-12-03T06:57:36Z | 28,786,554 | <p>In Python 3.3 and above, the internal representation of the string will depend on the string, and can be any of ascii, latin-1, utf-8, utf-16, utf-32, as noted by Tobu and described in <a href="http://www.python.org/dev/peps/pep-0393/" rel="nofollow">PEP 393</a>.</p>
<p>For previous Pythons, the internal representa... | 2 | 2015-02-28T20:32:55Z | [
"python",
"string",
"unicode",
"python-3.x"
] |
Get new dict from old dict with condition? | 1,838,549 | <p>I am an dictionary (Dictionary of dictionary)</p>
<pre><code> old_dict = {
'1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0},
'2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1},
'3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0},
'4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'st... | 0 | 2009-12-03T08:43:58Z | 1,838,590 | <pre><code>dict([x for x in old_dict.iteritems() if x[1]['status']==0 and x[1]['check']==0])
</code></pre>
<p>old_dict.iteritems() returns you a list of pairs. Which you then filter and convert back to dictionary.</p>
| 3 | 2009-12-03T08:52:11Z | [
"python",
"dictionary"
] |
Get new dict from old dict with condition? | 1,838,549 | <p>I am an dictionary (Dictionary of dictionary)</p>
<pre><code> old_dict = {
'1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0},
'2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1},
'3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0},
'4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'st... | 0 | 2009-12-03T08:43:58Z | 1,838,591 | <pre><code>outputdata = dict([d for d in data.iteritems() if d[1][1] == ' 0' and d[1][6]==' 0'])
</code></pre>
| 1 | 2009-12-03T08:52:34Z | [
"python",
"dictionary"
] |
Get new dict from old dict with condition? | 1,838,549 | <p>I am an dictionary (Dictionary of dictionary)</p>
<pre><code> old_dict = {
'1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0},
'2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1},
'3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0},
'4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'st... | 0 | 2009-12-03T08:43:58Z | 1,838,605 | <p>Not very interesting, don't know why I answer it.</p>
<pre><code>In [17]: dict([(k, v) for k, v in old_dict.items() if v['check'] == 0 and v['status'] == 0])
</code></pre>
| 0 | 2009-12-03T08:55:21Z | [
"python",
"dictionary"
] |
Get new dict from old dict with condition? | 1,838,549 | <p>I am an dictionary (Dictionary of dictionary)</p>
<pre><code> old_dict = {
'1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0},
'2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1},
'3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0},
'4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'st... | 0 | 2009-12-03T08:43:58Z | 1,838,608 | <p>Dropping the [] from yu_sha's answer avoids constructing a dummy list:</p>
<pre><code>new_dict = dict( (k,v) for k,v in old_dict.iteritems()
if v["status"] != 0 and v["check"] != 0 )
</code></pre>
<p>or</p>
<pre><code>new_dict = dict(item for item in old_dict.iteritems()
... | 5 | 2009-12-03T08:56:04Z | [
"python",
"dictionary"
] |
Get new dict from old dict with condition? | 1,838,549 | <p>I am an dictionary (Dictionary of dictionary)</p>
<pre><code> old_dict = {
'1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0},
'2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1},
'3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0},
'4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'st... | 0 | 2009-12-03T08:43:58Z | 1,838,609 | <pre><code>new_dict = {}
for k, d in old_dict.iteritems():
if d['check'] == 0 and d['status'] == 0:
new_dict[k] = d
</code></pre>
| 5 | 2009-12-03T08:56:29Z | [
"python",
"dictionary"
] |
Html Agility Pack for python | 1,838,637 | <p>Is there any module for python similar to <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow">Html Agility Pack</a>?
If not, can anyone recommend me an alternative.</p>
<p>Thanks in advance!</p>
| 0 | 2009-12-03T09:06:15Z | 1,838,650 | <p>Try <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a>.</p>
| 3 | 2009-12-03T09:09:55Z | [
"python"
] |
Python Spliting a string | 1,838,674 | <p>I looking to split a string up with python, I have read the documentation but don't fully understand how to do it, I understand that I need to have some kind of identifier in the string so that the functions can find where the string(unless I can target the first space in the sentence?)</p>
<p>So for example how wo... | 5 | 2009-12-03T09:16:03Z | 1,838,686 | <p>Use <a href="http://docs.python.org/library/stdtypes.html#str.partition"><code>partition(' ')</code></a> which always returns three items in the tuple - the first bit up until the separator, the separator, and then the bits after. Slots in the tuple that have are not applicable are still there, just set to be empty... | 13 | 2009-12-03T09:18:29Z | [
"python",
"string"
] |
Python Spliting a string | 1,838,674 | <p>I looking to split a string up with python, I have read the documentation but don't fully understand how to do it, I understand that I need to have some kind of identifier in the string so that the functions can find where the string(unless I can target the first space in the sentence?)</p>
<p>So for example how wo... | 5 | 2009-12-03T09:16:03Z | 1,838,693 | <p>Use the <a href="http://docs.python.org/3.1/library/stdtypes.html#str.split"><code>split</code></a> method on strings:</p>
<pre><code>>>> "Sico87 is an awful python developer".split(' ', 1)
['Sico87', 'is an awful python developer']
</code></pre>
<p><strong>How it works:</strong></p>
<ol>
<li>Every strin... | 18 | 2009-12-03T09:19:14Z | [
"python",
"string"
] |
How to grab live text from a URL? | 1,839,120 | <p>Im trying to grab all data(text) coming from a URL which is constantly sending text, I tried using PHP but that would mean having the script running the whole time which it isnât really made for (I think). So I ended up using a BASH script.</p>
<p>At the moment I use wget (I couldnât get CURL to output the text... | 0 | 2009-12-03T10:42:30Z | 1,839,156 | <p>You could try this:
<br /></p>
<p>while true <br/>
do <br />
wget -q -O - <a href="http://example.com" rel="nofollow">http://example.com</a> >> filename # -O - outputs to the screen <br />
sleep 2 # sleep 2 sec <br />
done</p>
| 0 | 2009-12-03T10:48:25Z | [
"php",
"python",
"bash",
"wget",
"keep-alive"
] |
How to grab live text from a URL? | 1,839,120 | <p>Im trying to grab all data(text) coming from a URL which is constantly sending text, I tried using PHP but that would mean having the script running the whole time which it isnât really made for (I think). So I ended up using a BASH script.</p>
<p>At the moment I use wget (I couldnât get CURL to output the text... | 0 | 2009-12-03T10:42:30Z | 1,839,175 | <p>curl <a href="http://URL/" rel="nofollow">http://URL/</a> >> output.txt</p>
<p>the >> redirects the output from curl to output.txt, appending to any data already there. (If it was just > output.txt - that would overwrite the contents of output.txt each time you ran it).</p>
| 0 | 2009-12-03T10:51:55Z | [
"php",
"python",
"bash",
"wget",
"keep-alive"
] |
How to grab live text from a URL? | 1,839,120 | <p>Im trying to grab all data(text) coming from a URL which is constantly sending text, I tried using PHP but that would mean having the script running the whole time which it isnât really made for (I think). So I ended up using a BASH script.</p>
<p>At the moment I use wget (I couldnât get CURL to output the text... | 0 | 2009-12-03T10:42:30Z | 1,839,180 | <p>You can do <code>wget --tries=0 --retry-connrefused $URL -O - >> output.txt</code>.</p>
<p>Explanation: the parameters <code>-O</code> is short for <code>--output-document</code>, and a dash <code>-</code> means <em>standard output</em>. </p>
<p>The line <code>command > file</code> means write "write outp... | 4 | 2009-12-03T10:52:14Z | [
"php",
"python",
"bash",
"wget",
"keep-alive"
] |
How to grab live text from a URL? | 1,839,120 | <p>Im trying to grab all data(text) coming from a URL which is constantly sending text, I tried using PHP but that would mean having the script running the whole time which it isnât really made for (I think). So I ended up using a BASH script.</p>
<p>At the moment I use wget (I couldnât get CURL to output the text... | 0 | 2009-12-03T10:42:30Z | 1,839,689 | <p>Curl doesn't follow redirects by default and outputs nothing if there is a redirect. I always specify the <code>--location</code> option just in case. If you want to use <code>curl</code>, try:</p>
<pre><code>curl http://example.com --location --silent >> output.txt
</code></pre>
<p>The <code>--silent</code>... | 1 | 2009-12-03T12:51:03Z | [
"php",
"python",
"bash",
"wget",
"keep-alive"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 1,839,306 | <p>If <code>x</code> is called like this</p>
<pre><code>foo, bar = x(foo)
</code></pre>
<p>returning <code>None</code> would result in a</p>
<pre><code>TypeError: 'NoneType' object is not iterable
</code></pre>
<p>if <code>'bar'</code> is not in <code>foo</code>.</p>
<p><strong>Example</strong></p>
<pre><code>def... | 2 | 2009-12-03T11:20:12Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 1,839,350 | <p>Why should functions return values of a consistent type? To meet the following two rules.</p>
<p>Rule 1 -- a function has a "type" -- inputs mapped to outputs. It must return a consistent type of result, or it isn't a function. It's a mess.</p>
<p>Mathematically, we say some function, F, is a mapping from domai... | 14 | 2009-12-03T11:29:08Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 1,840,291 | <p>It's not so clear that a function must always return objects of a limited type, or that returning None is wrong. For instance, re.search can return a <code>_sre.SRE_Match</code> object or a <code>NoneType</code> object:</p>
<pre><code>import re
match=re.search('a','a')
type(match)
# <type '_sre.SRE_Match'>
... | 8 | 2009-12-03T14:42:41Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 1,840,696 | <p>Best practice in what a function should return varies greatly from language to language, and even between different Python projects.</p>
<p>For Python in general, I agree with the premise that returning None is bad if your function generally returns an iterable, because iterating without testing becomes impossible.... | 7 | 2009-12-03T15:35:46Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 1,840,730 | <p>I personally think it is perfectly fine for a function to return a tuple or None. However, a function should return at most 2 different types and the second one should be a None. A function should never return a string and list for example.</p>
| 5 | 2009-12-03T15:39:35Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 3,187,157 | <p>Premature optimization is the root of all evil. The minuscule efficiency gains might be important, but not until you've proven that you need them. </p>
<p>Whatever your language: a function is defined once, but tends to be used at any number of places. Having a consistent return type (not to mention documented pre-... | 1 | 2010-07-06T14:32:32Z | [
"python",
"function",
"return-type"
] |
Why should functions always return the same type? | 1,839,289 | <p>I read somewhere that functions should always return only one type
so the following code is considered as bad code:</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar')
return None
</code></pre>
<p>I guess the better solution would be</p>
<pre><code>def x(foo):
if 'bar' in foo:
return (foo, 'bar... | 14 | 2009-12-03T11:15:27Z | 32,674,034 | <p>Here are my thoughts on all that and I'll try to also explain why I think that the accepted answer is mostly incorrect.</p>
<p>First of all <code>programming functions != mathematical functions</code>. The closest you can get to mathematical functions is if you do functional programming but even then there are plen... | 1 | 2015-09-19T23:01:24Z | [
"python",
"function",
"return-type"
] |
python web app logging through pipe? (performance concerned) | 1,839,348 | <p>I'm writing a web app using python with web.py, and I want to implement my own logging system. I'd like to log detailed information about each request that come to python (static files are handled by web servers).</p>
<p>Currently I'm thinking about writing the logs to a pipe. On the other side, there should be cro... | 0 | 2009-12-03T11:28:39Z | 1,839,366 | <p>Pipes are one of the fastest I/O mechanisms available. It's just a shared buffer. Nothing more. If the receiving end of your pipe is totally overwhelmed, you may have an issue. But you have no evidence of that right now.</p>
<p>If you have 10's of processes started by FastCGI, each can have their own independe... | 1 | 2009-12-03T11:32:22Z | [
"python",
"logging",
"pipe"
] |
Calculating point of intersection based on angle and speed | 1,839,567 | <p>I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector that only consists of a point and a speed. No direction. We will call this one T.
Now, what I am trying to do is to find the shortest intersection point of these two vectors. Since T has no direction, this is p... | 3 | 2009-12-03T12:20:52Z | 1,839,760 | <p>My math could be a bit rusty, but try this:</p>
<p><em>p</em> and <em>q</em> are the position vectors, <em>d</em> and <em>e</em> are the direction vectors. After time <em>t</em>, you want them to be at the same place:</p>
<p><strong>(1)</strong> <em>p+t*d = q+t*e</em> </p>
<p>Since you want the direction vector <... | 1 | 2009-12-03T13:08:41Z | [
"python",
"math",
"vector",
"performance",
"intersection"
] |
Calculating point of intersection based on angle and speed | 1,839,567 | <p>I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector that only consists of a point and a speed. No direction. We will call this one T.
Now, what I am trying to do is to find the shortest intersection point of these two vectors. Since T has no direction, this is p... | 3 | 2009-12-03T12:20:52Z | 1,839,828 | <ol>
<li>Let's assume that the first point,
A, has zero speed. In this case, it
should be very simple to find the
direction which will give the
fastest intersection.</li>
<li>Now, A <strong>does</strong> have a speed. We can force it to have zero speed by deducting it's speed vector from the vector of B. Now we can sol... | 0 | 2009-12-03T13:21:03Z | [
"python",
"math",
"vector",
"performance",
"intersection"
] |
Calculating point of intersection based on angle and speed | 1,839,567 | <p>I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector that only consists of a point and a speed. No direction. We will call this one T.
Now, what I am trying to do is to find the shortest intersection point of these two vectors. Since T has no direction, this is p... | 3 | 2009-12-03T12:20:52Z | 1,839,845 | <p>OK, if I understand you right, you have</p>
<p>R = [ xy0, v, r ]
T = [ xy1, v ]</p>
<p>If you are concerned about the shortest intersection point, this will be achieved when your positions are identical, and in an Euclidean space this also forces the direction of the second "thing" being perpendicular to the fi... | -2 | 2009-12-03T13:23:40Z | [
"python",
"math",
"vector",
"performance",
"intersection"
] |
Calculating point of intersection based on angle and speed | 1,839,567 | <p>I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector that only consists of a point and a speed. No direction. We will call this one T.
Now, what I am trying to do is to find the shortest intersection point of these two vectors. Since T has no direction, this is p... | 3 | 2009-12-03T12:20:52Z | 1,840,184 | <p>In nature hunters use the constant bearing decreasing range algorithm to catch prey.
I like the explanation of how bats do this <a href="http://www.plosbiology.org/article/info%3Adoi%2F10.1371%2Fjournal.pbio.0040108" rel="nofollow" title="Echolocating Bats Use a Nearly Time-Optimal Strategy to Intercept Prey">link t... | 0 | 2009-12-03T14:27:04Z | [
"python",
"math",
"vector",
"performance",
"intersection"
] |
Python split value of a string | 1,840,165 | <p>I am working on a site in Python built on the back of Django(awesome framework, cant get my head around python), I looking to split a string that is returned from a database and I want it to be split when the first space occurs so I tried something like this,</p>
<pre><code>{{product.name.split(' ' ,1)}}
</code></... | 1 | 2009-12-03T14:24:23Z | 1,840,274 | <p>You can call methods using the <code>{{ }}</code> -- but the method can't require any attributes. </p>
<p>What I would do in this case is add a method on your model that performs the desired behavior. Example:</p>
<pre><code>class Product(models.Model):
...
def get_first_name(self):
if self.name:
... | 11 | 2009-12-03T14:39:44Z | [
"python",
"django",
"string"
] |
Is there any reason to choose __new__ over __init__ when defining a metaclass? | 1,840,421 | <p>I've always set up metaclasses something like this:</p>
<pre><code>class SomeMetaClass(type):
def __new__(cls, name, bases, dict):
#do stuff here
</code></pre>
<p>But I just came across a metaclass that was defined like this:</p>
<pre><code>class SomeMetaClass(type):
def __init__(self, name, bases... | 28 | 2009-12-03T15:00:54Z | 1,840,445 | <p>You can implement caching. <code>Person("Jack")</code> always returns a new object in the second example while you can lookup an existing instance in the first example with <code>__new__</code> (or not return anything if you want).</p>
| 1 | 2009-12-03T15:05:44Z | [
"python",
"constructor",
"new-operator",
"metaclass",
"init"
] |
Is there any reason to choose __new__ over __init__ when defining a metaclass? | 1,840,421 | <p>I've always set up metaclasses something like this:</p>
<pre><code>class SomeMetaClass(type):
def __new__(cls, name, bases, dict):
#do stuff here
</code></pre>
<p>But I just came across a metaclass that was defined like this:</p>
<pre><code>class SomeMetaClass(type):
def __init__(self, name, bases... | 28 | 2009-12-03T15:00:54Z | 1,840,466 | <p>If you want to alter the attributes dict before the class is created, or change the bases tuple, you have to use <code>__new__</code>. By the time <code>__init__</code> sees the arguments, the class object already exists. Also, you have to use <code>__new__</code> if you want to return something other than a newly... | 30 | 2009-12-03T15:08:54Z | [
"python",
"constructor",
"new-operator",
"metaclass",
"init"
] |
Is there any reason to choose __new__ over __init__ when defining a metaclass? | 1,840,421 | <p>I've always set up metaclasses something like this:</p>
<pre><code>class SomeMetaClass(type):
def __new__(cls, name, bases, dict):
#do stuff here
</code></pre>
<p>But I just came across a metaclass that was defined like this:</p>
<pre><code>class SomeMetaClass(type):
def __init__(self, name, bases... | 28 | 2009-12-03T15:00:54Z | 1,840,517 | <p>You can see the full writeup in <a href="http://docs.python.org/reference/datamodel.html#basic-customization" rel="nofollow">the official docs</a>, but basically, <code>__new__</code> is called <em>before</em> the new object is created (for the purpose of creating it) and <code>__init__</code> is called <em>after</e... | 2 | 2009-12-03T15:16:57Z | [
"python",
"constructor",
"new-operator",
"metaclass",
"init"
] |
Is there any reason to choose __new__ over __init__ when defining a metaclass? | 1,840,421 | <p>I've always set up metaclasses something like this:</p>
<pre><code>class SomeMetaClass(type):
def __new__(cls, name, bases, dict):
#do stuff here
</code></pre>
<p>But I just came across a metaclass that was defined like this:</p>
<pre><code>class SomeMetaClass(type):
def __init__(self, name, bases... | 28 | 2009-12-03T15:00:54Z | 5,278,551 | <p>As has been said, if you intend to alter something like the base classes or the attributes, youâll have to do it in <code>__new__</code>. The same is true for the <code>name</code> of the class but there seems to be a peculiarity with it. When you change <code>name</code>, it is not propagated to <code>__init__</c... | 0 | 2011-03-11T21:24:27Z | [
"python",
"constructor",
"new-operator",
"metaclass",
"init"
] |
How do I call a property setter from __init__ | 1,840,628 | <p>I have the following chunk of python code:</p>
<pre><code>import hashlib
class User:
def _set_password(self, value):
self._password = hashlib.sha1(value).hexdigest()
def _get_password(self):
return self._password
password = property(
fset = _set_password,
fget = _get_p... | 10 | 2009-12-03T15:27:04Z | 1,840,712 | <p>A property is a descriptor, and descriptors only work on new-style classes. Try:</p>
<pre><code>class User(object): ...
</code></pre>
<p>instead of:</p>
<pre><code>class User: ...
</code></pre>
<p>A good guide to descriptors can be found <a href="http://users.rcn.com/python/download/Descriptor.htm">here</a>.</p... | 14 | 2009-12-03T15:37:25Z | [
"python",
"setter",
"init",
"new-style-class"
] |
python X.509 asymmetric encryption | 1,840,720 | <p>Hello
I'm trying to understand how certificate and asymmetric encryption works. I'm looking for a python library where i can import public or private ca signed certificates and automatically encrypt or decrypt message in string format, i viewed the crypto library embedded in python source, but i don't know how to us... | 0 | 2009-12-03T15:38:19Z | 1,840,756 | <p><a href="http://chandlerproject.org/Projects/MeTooCrypto" rel="nofollow">MeTooCrypto</a>:</p>
<blockquote>
<p>M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extens... | 3 | 2009-12-03T15:42:58Z | [
"python",
"encryption",
"x509",
"encryption-asymmetric"
] |
Python3: ssl cert information | 1,840,725 | <p>I have been trying to get information regarding expired ssl certificates using python 3 but it would be nice to be able to get as verbose a workup as possible. any takers?
So far i have been trying to use urllib.request to get this info (to no avail), does this strike anyone as foolish?</p>
<p>I have seen some exa... | 1 | 2009-12-03T15:38:57Z | 1,840,957 | <p>The 3.1.1 documentation for SSL has an <a href="http://docs.python.org/3.1/library/ssl.html#client-side-operation" rel="nofollow">example</a>.</p>
| 1 | 2009-12-03T16:09:28Z | [
"python",
"ssl",
"certificate",
"urllib"
] |
How to verify sender of incoming email address in Google App Engine? | 1,840,858 | <p>I'm trying to write a heavily email-based application in the Python SDK of Google App Engine. I've noticed that Google <a href="http://code.google.com/appengine/docs/python/mail/receivingmail.html" rel="nofollow">allows you to receive email via its API</a>, and that it easily gives you access to the standard fields ... | 3 | 2009-12-03T15:56:58Z | 1,840,888 | <p>If this is part of a registration process or alike, then why don't you send back a "challenge" (e.g. URL to go for continuing registration or whatever, with a unique & time-bound key) to the (supposedly) originator? This way you can verify if the email address isn't forged.</p>
<p>The "big guys" (e.g. Google) u... | 0 | 2009-12-03T16:01:36Z | [
"python",
"google-app-engine",
"email",
"verification"
] |
How to verify sender of incoming email address in Google App Engine? | 1,840,858 | <p>I'm trying to write a heavily email-based application in the Python SDK of Google App Engine. I've noticed that Google <a href="http://code.google.com/appengine/docs/python/mail/receivingmail.html" rel="nofollow">allows you to receive email via its API</a>, and that it easily gives you access to the standard fields ... | 3 | 2009-12-03T15:56:58Z | 1,840,930 | <p>E-mail isn't generally a verifyable medium, unless you sign it with PGP or S/MIME. If you don't have headers, you haven't got anything to verify.</p>
<p>The only thing you can do is e-mail the address and ask the person to confirm that they really sent the message. That's a lot harder for the fraudulent e-mail send... | 1 | 2009-12-03T16:05:44Z | [
"python",
"google-app-engine",
"email",
"verification"
] |
How to verify sender of incoming email address in Google App Engine? | 1,840,858 | <p>I'm trying to write a heavily email-based application in the Python SDK of Google App Engine. I've noticed that Google <a href="http://code.google.com/appengine/docs/python/mail/receivingmail.html" rel="nofollow">allows you to receive email via its API</a>, and that it easily gives you access to the standard fields ... | 3 | 2009-12-03T15:56:58Z | 1,841,022 | <p>Actually, while not well documented, the sources <a href="http://www.google.com/codesearch/p?hl=en#Qx8E-7HUBTk/trunk/python/google/appengine/api/mail.py&q=InboundEmailMessage%20package%3Ahttp%3A//googleappengine%5C.googlecode%5C.com&sa=N&cd=1&ct=rc" rel="nofollow">here</a> suggest that the original m... | 2 | 2009-12-03T16:18:28Z | [
"python",
"google-app-engine",
"email",
"verification"
] |
How to verify sender of incoming email address in Google App Engine? | 1,840,858 | <p>I'm trying to write a heavily email-based application in the Python SDK of Google App Engine. I've noticed that Google <a href="http://code.google.com/appengine/docs/python/mail/receivingmail.html" rel="nofollow">allows you to receive email via its API</a>, and that it easily gives you access to the standard fields ... | 3 | 2009-12-03T15:56:58Z | 1,847,373 | <p>Alex is right about accessing the headers, but this doesn't allow you to verify the actual sender of the email: anyone can send an email with any 'from' address they wish, so don't rely on the from address as authoritative proof of who sent it.</p>
| 1 | 2009-12-04T14:42:23Z | [
"python",
"google-app-engine",
"email",
"verification"
] |
How to verify sender of incoming email address in Google App Engine? | 1,840,858 | <p>I'm trying to write a heavily email-based application in the Python SDK of Google App Engine. I've noticed that Google <a href="http://code.google.com/appengine/docs/python/mail/receivingmail.html" rel="nofollow">allows you to receive email via its API</a>, and that it easily gives you access to the standard fields ... | 3 | 2009-12-03T15:56:58Z | 12,015,126 | <p>You can verify the sender only using DKIM. GAE automatically signs the google accounts emails with DKIM but you need an external service(which should be accessed through http/https) to query the DNS and provide you the txt DNS fields.</p>
| 0 | 2012-08-18T01:40:18Z | [
"python",
"google-app-engine",
"email",
"verification"
] |
Can urllib2 make HTTP/1.1 requests? | 1,840,965 | <p>EDIT:</p>
<p>This question is invalid. Turns out a transparent proxy was making an onward HTTP 1.0 request even though urllib/httplib was indeed making a HTTP 1.1 request originally.</p>
<p>ORIGINAL QUESTION:</p>
<p>By default <code>urllib2.urlopen</code> always makes a HTTP 1.0 request. </p>
<p>Is there any way... | 2 | 2009-12-03T16:11:14Z | 1,841,055 | <p>Why do you think it's not already using http 1.1? Have you tried something like...:</p>
<pre><code>>>> import urllib2
>>> urllib2._opener.handlers[1].set_http_debuglevel(100)
>>> urllib2.urlopen('http://mit.edu').read()[:10]
connect: (mit.edu, 80)
send: 'GET / HTTP/1.1
</code></pre>
<p>... | 11 | 2009-12-03T16:22:56Z | [
"python",
"http",
"urllib2"
] |
Can urllib2 make HTTP/1.1 requests? | 1,840,965 | <p>EDIT:</p>
<p>This question is invalid. Turns out a transparent proxy was making an onward HTTP 1.0 request even though urllib/httplib was indeed making a HTTP 1.1 request originally.</p>
<p>ORIGINAL QUESTION:</p>
<p>By default <code>urllib2.urlopen</code> always makes a HTTP 1.0 request. </p>
<p>Is there any way... | 2 | 2009-12-03T16:11:14Z | 1,841,481 | <p>urllib2 uses httplib to make HTTP requests. My Python 2.6.4 definitely uses HTTP/1.1 in httplib, although it can handle responses from a 1.1, 1.0 or 0.9 server. As far back as 2.3, this appears to be the case (and possibly back to 1.5)</p>
<p>However, if it is required to tunnel through a proxy, it will send a requ... | 2 | 2009-12-03T17:20:18Z | [
"python",
"http",
"urllib2"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 1,841,329 | <p>Lambdas in python share the variable scope they're created in. In your first case, the scope of the lambda is makeFun's. In your second case, it's the global <code>i</code>, which is 9 because it's a leftover from the loop.</p>
<p>That's what I understand of it anyway...</p>
| 1 | 2009-12-03T17:00:43Z | [
"python",
"scope"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 1,841,330 | <p>Technically, the lambda expression is <em>closed</em> over the <code>i</code> that's visible in the global scope, which is last set to 9. It's the <em>same</em> <code>i</code> being referred to in all 10 lambdas. For example,</p>
<pre><code>i = 13
print b[3]()
</code></pre>
<p>In the <code>makeFun</code> function,... | 17 | 2009-12-03T17:00:54Z | [
"python",
"scope"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 1,841,333 | <p>Nice catch. The lambda in the list comprehension is seeing the same local <code>i</code> every time. </p>
<p>You can rewrite it as:</p>
<pre><code>a = []
for i in range(10):
a.append(makefun(i))
b = []
for i in range(10):
b.append(lambda: i)
</code></pre>
<p>with the same result.</p>
| 1 | 2009-12-03T17:01:11Z | [
"python",
"scope"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 1,841,367 | <p>One set of functions (a) operates on the argument passed and the other (b) operates on a global variable which is then set to 9. Check the disassembly:</p>
<pre><code>>>> import dis
>>> dis.dis(a[2])
1 0 LOAD_DEREF 0 (i)
3 RETURN_VALUE
>>> dis.dis(b... | 7 | 2009-12-03T17:04:54Z | [
"python",
"scope"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 1,841,368 | <p>As others have stated, scoping is the problem. Note that you can solve this by adding an extra argument to the lambda expression and assigning it a default value:</p>
<pre><code>>> def makeFun(i): return lambda: i
...
>>> a = [makeFun(i) for i in range(10)]
>>> b = [lambda: i for i in range... | 18 | 2009-12-03T17:05:09Z | [
"python",
"scope"
] |
Generating functions inside loop with lambda expression in python | 1,841,268 | <p>If I make two lists of functions:</p>
<pre><code>def makeFun(i):
return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>why are the lists <code>a</code> and <code>b</code> not equal?</p>
<p>For example:</p>
<pre><code>>>> a[2]()
2
>>> b[2](... | 23 | 2009-12-03T16:52:14Z | 13,736,820 | <p>To add some clarity (at least in my mind)</p>
<pre><code>def makeFun(i): return lambda: i
a = [makeFun(i) for i in range(10)]
b = [lambda: i for i in range(10)]
</code></pre>
<p>a uses makeFun(i) which is a function with an argument.</p>
<p>b uses lambda: i which is a function <strong>without</strong> arguments. ... | 3 | 2012-12-06T04:10:49Z | [
"python",
"scope"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 1,841,607 | <p>Pythonic way of iterating over a file and converting to int:</p>
<pre><code>for line in open(fname):
if line.strip(): # line contains eol character(s)
n = int(line) # assuming single integer on each line
</code></pre>
<p>What you're trying to do is slightly more complicated, but still ... | 28 | 2009-12-03T17:40:45Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 1,841,624 | <pre><code> readings = (infile.readline())
print readings
while readings != 0:
global count
readings = int(readings)
</code></pre>
<p>There's a problem with that code. <code>readings</code> is a new line read from the file - it's a string. Therefore you should not compare it to 0. Further, y... | 1 | 2009-12-03T17:43:40Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 1,841,673 | <blockquote>
<p>I am creating a program that reads a
file and if the first line of the file
is not blank, it reads the next four
lines. Calculations are performed on
those lines and then the next line is
read.</p>
</blockquote>
<p>Something like this should work:</p>
<pre><code>for line in infile:
nex... | 0 | 2009-12-03T17:49:47Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 1,841,713 | <p>You've got a problem with this line:</p>
<pre><code>while file_to_read != " ":
</code></pre>
<p>This does not find an empty string. It finds a string consisting of one space. Presumably this is not what you are looking for.</p>
<p>Listen to everyone else's advice. This is not very idiomatic python code, and wo... | 3 | 2009-12-03T17:56:59Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 8,948,303 | <p>Just for the record:</p>
<pre><code>>>> int('55063.000000')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '55063.000000'
</code></pre>
<p>Got me here...</p>
<pre><code>>>> float('55063.000000')
55063.0
</c... | 78 | 2012-01-20T21:49:34Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 15,370,574 | <p>I was getting similar errors, turns out that the dataset had blank values which python could not convert to integer.</p>
| 1 | 2013-03-12T19:38:06Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 24,059,374 | <p>Please test this function (<code>split()</code>) on a simple file. I was facing the same issue and found that it was because <code>split()</code> was not written properly (exception handling).</p>
| 2 | 2014-06-05T11:46:10Z | [
"python"
] |
ValueError: invalid literal for int() with base 10: '' | 1,841,565 | <p>I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error:</p>
<pre><code>ValueError: invalid literal fo... | 61 | 2009-12-03T17:34:19Z | 32,933,186 | <p>In my case I have to read data with comma for decimals values. </p>
<p>So to manage cases with data and cases without data in a dict: </p>
<pre><code>def total_estimated_time(issues_dict):
estimated = 0
for k in issues_dict:
if issues_dict[k].get('Estimated time', 0).replace(',', '.'):
... | 0 | 2015-10-04T11:56:30Z | [
"python"
] |
How can urllib2 / httplib talk HTTP 1.1 for HTTPS connections via a Squid proxy? | 1,841,730 | <p>When I use urllib2 to make a HTTP 1.1 connection via a squid proxy, squid makes a new ongoing connection in HTTP 1.0.</p>
<p>How can I persuade Squid to talk 1.1 to the destination server?</p>
| 2 | 2009-12-03T17:59:38Z | 1,841,740 | <p>After dealing with this problem for an entire afternoon, i found the solution. So please excuse me answering my own question, but it would be great if someone else finds this useful and it saves them the pain.</p>
<p>In order to get Squid to have a HTTP 1.1 conversation with the destination server, the original req... | 3 | 2009-12-03T18:00:48Z | [
"python",
"proxy",
"https",
"urllib"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,841,778 | <p>You might want to store the results in one file, like in</p>
<pre><code>find . -type f -exec md5sum {} \; > MD5SUMS
</code></pre>
<p>If you really want one file per hash:</p>
<pre><code>find . -type f | while read f; do g=`md5sum $f` > $f.md5; done
</code></pre>
<p>or even</p>
<pre><code>find . -type f | ... | 1 | 2009-12-03T18:08:59Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,841,779 | <p>using zsh:</p>
<pre><code>$ ls
a.txt
b.txt
c.txt
</code></pre>
<p>The magic:</p>
<pre><code>$ FILES=**/*(.)
$ # */ stupid syntax coloring thinks this is a comment
$ for f in $FILES; do hash=`md5sum $f | cut -f1 -d" "`; mv $f "$f:r.$hash.$f:e"; done
$ ls
a.60b725f10c9c85c70d97880dfe8191b3.txt
b.3b5d5c371295504221... | 0 | 2009-12-03T18:09:01Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,841,792 | <pre><code>find . -type f -print | while read file
do
hash=`$hashcommand "$file"`
filename=${file%.*}
extension=${file##*.}
mv $file "$filename.$hash.$extension"
done
</code></pre>
| 2 | 2009-12-03T18:11:50Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,841,848 | <p>In sh or bash, two versions. One limits itself to files with extensions...</p>
<pre><code>hash () {
#openssl md5 t.sh | sed -e 's/.* //'
whirlpool "$f"
}
find . -type f -a -name '*.*' | while read f; do
# remove the echo to run this for real
echo mv "$f" "${f%.*}.whirlpool-`hash "$f"`.${f##*.}"
done
</code... | 1 | 2009-12-03T18:20:34Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,841,980 | <pre><code>#!/bin/bash
find -type f -print0 | while read -d $'\0' file
do
md5sum=`md5sum "${file}" | sed -r 's/ .*//'`
filename=`echo "${file}" | sed -r 's/\.[^./]*$//'`
extension="${file:${#filename}}"
filename=`echo "${filename}" | sed -r 's/\.md5sum-[^.]+//'`
if [[ "${file}" != "${filename}.md5su... | 4 | 2009-12-03T18:40:20Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,842,134 | <p>Here's my take on it, in bash. Features: skips non-regular files; correctly deals with files with weird characters (i.e. spaces) in their names; deals with extensionless filenames; skips already-hashed files, so it can be run repeatedly (although if files are modified between runs, it adds the new hash rather than ... | 1 | 2009-12-03T19:01:18Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,842,682 | <p>The logic of the requirements is complex enough to justify the use of Python instead of bash. It should provide a more readable, extensible, and maintainable solution.</p>
<pre><code>#!/usr/bin/env python
import hashlib, os
def ishash(h, size):
"""Whether `h` looks like hash's hex digest."""
if len(h) == s... | 3 | 2009-12-03T20:27:54Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,842,746 | <p>whirlpool isn't a very common hash. You'll probably have to install a program to compute it. e.g. Debian/Ubuntu include a "whirlpool" package. The program prints the hash of one file by itself. apt-cache search whirlpool shows that some other packages support it, including the interesting md5deep.</p>
<p>Some ... | 1 | 2009-12-03T20:36:40Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,842,978 | <p>Ruby:</p>
<pre><code>#!/usr/bin/env ruby
require 'digest/md5'
Dir.glob('**/*') do |f|
next unless File.file? f
next if /\.md5sum-[0-9a-f]{32}/ =~ f
md5sum = Digest::MD5.file f
newname = "%s/%s.md5sum-%s%s" %
[File.dirname(f), File.basename(f,'.*'), md5sum, File.extname(f)]
File.rename f, newname
end
... | 0 | 2009-12-03T21:17:37Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,847,365 | <p>Hm, interesting problem.</p>
<p>Try the following (the mktest function is just for testing -- TDD for bash! :)</p>
<p>Edit:</p>
<ul>
<li>Added support for whirlpool hashes.</li>
<li>code cleanup</li>
<li>better quoting of filenames</li>
<li>changed array-syntax for test part-- should now work with most korn-like ... | 1 | 2009-12-04T14:41:28Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,854,674 | <p>I wasn't really happy with my first answer, since as I said there, this problem looks like it's best solved with perl. You already said in one edit of your question that you have perl on the OS X machine you want to run this on, so I gave it a shot.</p>
<p>It's hard to get it all right in bash, i.e. avoiding any q... | 3 | 2009-12-06T07:42:50Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,869,487 | <p>In response to your updated question:</p>
<blockquote>
<p>If anyone can comment on how I can avoid looking in hidden directories with my BASH Script, it would be much appreciated.</p>
</blockquote>
<p>You can avoid hidden directories with find by using</p>
<pre><code>find -name '.?*' -prune -o \( -type f -print... | 1 | 2009-12-08T20:05:59Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
Hashing Multiple Files | 1,841,737 | <blockquote>
<h2>Problem Specification:</h2>
<p>Given a directory, I want to iterate through the directory and its non-hidden sub-directories,<br>
 and add a whirlpool hash into the non-hidden
file's names.<br>
If the script is re-run it would would replace an old hash with a new one.</p>
<blockquote... | 2 | 2009-12-03T18:00:19Z | 1,880,234 | <p><strong>Updated to fix:<br></strong>
1. File names with '[' or ']' in their name (really, any character now. See comment)<br>
2. Handling of md5sum when hashing a file with a backslash or newline in its name<br>
3. Functionized hash-checking algo for modularity<br>
4. Refactored hash-checking logic to remove double-... | 5 | 2009-12-10T11:01:08Z | [
"python",
"perl",
"bash",
"hash",
"batch-processing"
] |
How can I organize each scraped item into a csv row? | 1,841,903 | <p>What is the best way to organize scraped data into a csv? More specifically each item is in this form</p>
<pre><code>url
"firstName middleInitial, lastName - level - word1 word2 word3, &amp; wordN practice officeCity."
JD, schoolName, date
</code></pre>
<p>Example:</p>
<pre><code>http://www.examplefirm.com/ja... | 1 | 2009-12-03T18:28:42Z | 1,842,041 | <p>There's really no short cut on this. Line 1 is easy. Just assign it to <code>url</code>. Line 3 can probably be split on <code>,</code> without any ill effects, but line 2 will have to be manually parsed. What do you know about word1-wordN? Are you sure "practice" will never be a "word". Are you sure the words... | 2 | 2009-12-03T18:49:33Z | [
"python",
"django",
"csv"
] |
python gtk module opens display on import | 1,841,949 | <p>I'm using the trick "python -c 'import myscript.py'" to perform a syntax check on a script which uses 'import gtk'.</p>
<p>I get the following error when performing the syntax check, which implies that the gtk module is executing a check for the X display, even though all that's being done at this point is to impor... | 1 | 2009-12-03T18:35:01Z | 1,842,150 | <p>What exactly do you mean by <code>'syntax checking'</code>?<br>
Can't you use a tool like <a href="http://www.logilab.org/857" rel="nofollow">pylint</a> to check for syntax errors?</p>
<p>Otherwise: a very ugly (but probably possible hack):</p>
<ol>
<li>In your python script detect whether X is present.</li>
<li>I... | 0 | 2009-12-03T19:03:06Z | [
"python",
"gtk"
] |
python gtk module opens display on import | 1,841,949 | <p>I'm using the trick "python -c 'import myscript.py'" to perform a syntax check on a script which uses 'import gtk'.</p>
<p>I get the following error when performing the syntax check, which implies that the gtk module is executing a check for the X display, even though all that's being done at this point is to impor... | 1 | 2009-12-03T18:35:01Z | 1,846,792 | <p>If the remote machine has vncserver installed, you can have a dummy server running and connect to that. Sample instructions:</p>
<pre><code>remotemachine $ vncserver -depth 16 -geometry 800x600 :7
New 'X' desktop is remotemachine:7
Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/... | 0 | 2009-12-04T12:55:18Z | [
"python",
"gtk"
] |
python gtk module opens display on import | 1,841,949 | <p>I'm using the trick "python -c 'import myscript.py'" to perform a syntax check on a script which uses 'import gtk'.</p>
<p>I get the following error when performing the syntax check, which implies that the gtk module is executing a check for the X display, even though all that's being done at this point is to impor... | 1 | 2009-12-03T18:35:01Z | 1,997,182 | <p>In your myscript.py, you could do like this</p>
<pre><code>if __name__=="__main__":
import gtk
</code></pre>
<p>That will not execute gtk's <code>__init__.py</code> when you do <code>"python -c 'import myscript.py'"</code></p>
| 0 | 2010-01-04T02:05:34Z | [
"python",
"gtk"
] |
python gtk module opens display on import | 1,841,949 | <p>I'm using the trick "python -c 'import myscript.py'" to perform a syntax check on a script which uses 'import gtk'.</p>
<p>I get the following error when performing the syntax check, which implies that the gtk module is executing a check for the X display, even though all that's being done at this point is to impor... | 1 | 2009-12-03T18:35:01Z | 2,014,247 | <p><em>Importing modules in Python executes their code!</em><br>
Well-behaved modules use the <code>if __name__ == '__main__'</code> trick to avoid side effects, but they can still fail - as happened to you.</p>
<p>[BTW, getting to ImportError means the whole file already has correct syntax.]</p>
<p>If you just want ... | 3 | 2010-01-06T16:04:33Z | [
"python",
"gtk"
] |
python gtk module opens display on import | 1,841,949 | <p>I'm using the trick "python -c 'import myscript.py'" to perform a syntax check on a script which uses 'import gtk'.</p>
<p>I get the following error when performing the syntax check, which implies that the gtk module is executing a check for the X display, even though all that's being done at this point is to impor... | 1 | 2009-12-03T18:35:01Z | 2,015,317 | <p>If you are editing with IDLE, <strong>Alt+X</strong> will check syntax of current file without running it.</p>
| 0 | 2010-01-06T18:43:08Z | [
"python",
"gtk"
] |
Python, unit test - Pass command line arguments to setUp of unittest.TestCase | 1,842,168 | <p>I have a script that acts as a wrapper for some unit tests written using the Python <code>unittest</code> module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using </p>
<pre><code>unittest.TestLoader().loadTestsFromTestCase()
</code></p... | 23 | 2009-12-03T19:05:40Z | 1,842,390 | <p>I would definitely advise against passing arguments to setUp like this; setUp is intended to be called implicitly when running a test, so you shouldn't be explicitly calling it like this.</p>
<p>One way you could tackle this would be to set the values you need to set either as environment variables or values in a g... | 5 | 2009-12-03T19:42:21Z | [
"python",
"unit-testing"
] |
Python, unit test - Pass command line arguments to setUp of unittest.TestCase | 1,842,168 | <p>I have a script that acts as a wrapper for some unit tests written using the Python <code>unittest</code> module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using </p>
<pre><code>unittest.TestLoader().loadTestsFromTestCase()
</code></p... | 23 | 2009-12-03T19:05:40Z | 2,081,750 | <p>Well, I want to do the same thing and was going to ask this question myself. I wanted to improve over the following code because it has duplication. It does let me send in arguments to test TestCase however:</p>
<pre><code>import unittest
import helpspot
class TestHelpSpot(unittest.TestCase):
"A few simple tes... | 41 | 2010-01-17T16:52:41Z | [
"python",
"unit-testing"
] |
Python, unit test - Pass command line arguments to setUp of unittest.TestCase | 1,842,168 | <p>I have a script that acts as a wrapper for some unit tests written using the Python <code>unittest</code> module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using </p>
<pre><code>unittest.TestLoader().loadTestsFromTestCase()
</code></p... | 23 | 2009-12-03T19:05:40Z | 21,613,948 | <p>If you define the attributes in the init method, then you can simply pass them all in the constructor like this..</p>
<pre><code>import unittest
import helpspot
class TestHelpSpot(unittest.TestCase):
"A few simple tests for HelpSpot"
def __init__(self, testname, path, user, pword):
super(TestHelpS... | 0 | 2014-02-06T21:00:29Z | [
"python",
"unit-testing"
] |
Python, unit test - Pass command line arguments to setUp of unittest.TestCase | 1,842,168 | <p>I have a script that acts as a wrapper for some unit tests written using the Python <code>unittest</code> module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using </p>
<pre><code>unittest.TestLoader().loadTestsFromTestCase()
</code></p... | 23 | 2009-12-03T19:05:40Z | 23,820,148 | <pre><code>if __name__ == '__main__':
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-z", "--zebra",
action="store_true", dest="zebra", default=False,
help="run like a zebra")
(options, args) = parser.parse_args()
if op... | 5 | 2014-05-23T02:40:43Z | [
"python",
"unit-testing"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,842,236 | <p>Python is better suited for practically anything that doesn't fall within PHP's specialty domain, which is building websites.</p>
<p>If you want a list of programming projects that you could work on, see this thread:
<a href="http://stackoverflow.com/questions/1022738/i-need-a-good-programming-project">http://stack... | 16 | 2009-12-03T19:16:41Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,842,248 | <p>A project you want to maintain over any length of time.</p>
<p>I've had to maintain PHP code and there is something about the fact that you can mix HTML and code that makes PHP stuff a nightmare.</p>
<p>Python has a much higher level of abstraction and makes more maintainable code much easier to write and much mor... | 3 | 2009-12-03T19:18:12Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,842,267 | <p>Anything that requires background processing or any significant amount of code that doesn't just show a user a page. Python is really good as a scripting language, and writing a command line Python script is commonplace; writing a PHP script to do command line work is rare.</p>
| 1 | 2009-12-03T19:21:31Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,843,126 | <p>I am going to answer based purely on ease of programming and encouragement of good design practices.</p>
<p>I learned to program using Perl and for many years wrote web applications using CGI, which was never pleasant in the first place. I always found that Perl was tedious to get right and way too easy to get wro... | 4 | 2009-12-03T21:43:56Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,843,790 | <p>PHP for websites. Python for pretty much anything else, such as commandline tools, long-running scripts, daemons, etcetera. If you're writing a PHP script and you're reaching for functions in the posix extenstion, shared memory or other low-level stuff then that's generally a sign that Python would be better suited.... | 5 | 2009-12-03T23:21:24Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,843,906 | <p>I only use php for the following reasons:</p>
<ol>
<li>The software I'm using that solves my problems is written in it (like <a href="http://wordpress.org" rel="nofollow">Wordpress</a>. Don't try to program everything, sometimes you have a lot of good stuff in php);</li>
<li>I need/want to run in a lot of different... | 2 | 2009-12-03T23:43:59Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,845,431 | <p>My company was contracted to build a web application last year, and the client specified that it should be done in Flex. Now, this application <em>should</em> have been a web application, but we had a unique opportunity to try something new.</p>
<p>We had absolutely no idea what we were doing at the time, but it wa... | 1 | 2009-12-04T07:36:58Z | [
"php",
"python",
"linux",
"theory"
] |
From a coder's perspective, what kind of project should I choose python over php for where both could do the job? | 1,842,208 | <p>I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.</p>
<p>Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform... | 3 | 2009-12-03T19:13:03Z | 1,847,687 | <p>If you're doing any multi threading development, pick Python over PHP.</p>
| 1 | 2009-12-04T15:27:04Z | [
"php",
"python",
"linux",
"theory"
] |
ReportLab LayoutError: too large on page | 1,842,266 | <p>I'm doing my first program using ReportLab where I don't know in advance where the page breaks will fall and I'm having trouble. To keep things simple I'm using the <code>SimpleDocTemplate</code>. My flowables look something like this:</p>
<pre><code>flowables = [Paragraph("Some title", style=headerParagraphStyle... | 9 | 2009-12-03T19:20:50Z | 1,902,304 | <p>Found a workaround myself. Based on some <a href="http://code.google.com/p/rst2pdf/source/diff?spec=svn675&r=675&format=side&path=/trunk/rst2pdf/createpdf.py" rel="nofollow">code changes made in rst2pdf</a>, I was able to get my code working reliably. The solution, although ugly, is to wrap all my <cod... | 1 | 2009-12-14T17:30:24Z | [
"python",
"pdf-generation",
"reportlab",
"platypus"
] |
ReportLab LayoutError: too large on page | 1,842,266 | <p>I'm doing my first program using ReportLab where I don't know in advance where the page breaks will fall and I'm having trouble. To keep things simple I'm using the <code>SimpleDocTemplate</code>. My flowables look something like this:</p>
<pre><code>flowables = [Paragraph("Some title", style=headerParagraphStyle... | 9 | 2009-12-03T19:20:50Z | 27,580,676 | <p>Looks like this is an old question but I experienced this same error very recently, and came here to find some advices. The fix I made was to make the spacer size a half of the old size. It was previously Spacer(1,0.2*inch) and I changed it to Spacer(1,0.1*inch). Then there are no more such errors.</p>
<p>FYI the e... | 0 | 2014-12-20T13:25:42Z | [
"python",
"pdf-generation",
"reportlab",
"platypus"
] |
Facebook login without opening another window/popup | 1,842,360 | <p>Is it possible for web application that is created by the same owner as facebook application to have access to facebook application without going through a explicit session opening exercise?
Most of the work is done on server side and I need to access facebook application directly from backend server. Each time the ... | 0 | 2009-12-03T19:36:58Z | 1,844,379 | <p>The opening of a window for facebook auth is the way facebook set up their authentication for facebook connect.</p>
<p>I don't think they offer another way of authenticating users, and I doubt you'd be able to work-around/circumvent this method without breaking their terms of use</p>
<p>Sorry I don't have better n... | 0 | 2009-12-04T01:43:30Z | [
"python",
"facebook"
] |
Reverse for '*' with arguments '()' and keyword arguments '{}' not found | 1,842,389 | <p>Caught an exception while rendering: </p>
<blockquote>
<p>Reverse for 'products.views.'filter_by_led' with arguments '()' and
keyword arguments '{}' not found.</p>
</blockquote>
<p>I was able to successfully import <code>products.views.filter_by_led</code> from the shell and it worked so the path should be co... | 44 | 2009-12-03T19:42:13Z | 1,842,548 | <p>There are 3 things I can think of off the top of my head:</p>
<ol>
<li>Just used <a href="http://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns">named urls</a>, it's more robust and maintainable anyway</li>
<li><p>Try using <code>django.core.urlresolvers.reverse</code> at the command line for a... | 45 | 2009-12-03T20:08:03Z | [
"python",
"django",
"django-templates"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.