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 |
|---|---|---|---|---|---|---|---|---|---|
draw points using matplotlib.pyplot [[x1,y1],[x2,y2]] | 2,282,727 | <p>I want to draw graph using a list of <code>(x,y)</code> pairs instead of using two lists, one of X's and one of Y's. Something like this:</p>
<pre><code>a = [[1,2],[3,3],[4,4],[5,2]]
plt.plot(a, 'ro')
</code></pre>
<p>Rather than:</p>
<pre><code>plt.plot([1,3,4,5], [2,3,4,2])
</code></pre>
<p>Suggestions?</p>
| 28 | 2010-02-17T17:05:29Z | 2,282,757 | <p>Write a helper function.</p>
<p>Here is a longish version, but I am sure there is a trick to compress it.</p>
<pre><code>>>> def helper(lst):
lst1, lst2 = [], []
for el in lst:
lst1.append(el[0])
lst2.append(el[1])
return lst1, lst2
>>>
>>> helper([[1,2],[3,... | 0 | 2010-02-17T17:08:40Z | [
"python",
"matplotlib"
] |
draw points using matplotlib.pyplot [[x1,y1],[x2,y2]] | 2,282,727 | <p>I want to draw graph using a list of <code>(x,y)</code> pairs instead of using two lists, one of X's and one of Y's. Something like this:</p>
<pre><code>a = [[1,2],[3,3],[4,4],[5,2]]
plt.plot(a, 'ro')
</code></pre>
<p>Rather than:</p>
<pre><code>plt.plot([1,3,4,5], [2,3,4,2])
</code></pre>
<p>Suggestions?</p>
| 28 | 2010-02-17T17:05:29Z | 2,315,858 | <p>You can do something like this:</p>
<pre><code>a=[[1,2],[3,3],[4,4],[5,2]]
plt.plot(*zip(*a))
</code></pre>
<p>Unfortunately, you can no longer pass 'ro'. You must pass marker and line style values as keyword parameters:</p>
<pre><code>a=[[1,2],[3,3],[4,4],[5,2]]
plt.plot(*zip(*a), marker='o', color='r', ls='')
<... | 44 | 2010-02-23T03:04:10Z | [
"python",
"matplotlib"
] |
draw points using matplotlib.pyplot [[x1,y1],[x2,y2]] | 2,282,727 | <p>I want to draw graph using a list of <code>(x,y)</code> pairs instead of using two lists, one of X's and one of Y's. Something like this:</p>
<pre><code>a = [[1,2],[3,3],[4,4],[5,2]]
plt.plot(a, 'ro')
</code></pre>
<p>Rather than:</p>
<pre><code>plt.plot([1,3,4,5], [2,3,4,2])
</code></pre>
<p>Suggestions?</p>
| 28 | 2010-02-17T17:05:29Z | 10,687,696 | <p>If you are using numpy array you could extract by axis:</p>
<pre><code>a = array([[1,2],[3,3],[4,4],[5,2]])
plot(a[:,0], a[:,1], 'ro')
</code></pre>
<p>For lists or lists you'll need some helper, like:</p>
<pre><code>a = [[1,2],[3,3],[4,4],[5,2]]
plot(*sum(a, []), marker='o', color='r')
</code></pre>
| 5 | 2012-05-21T14:58:02Z | [
"python",
"matplotlib"
] |
draw points using matplotlib.pyplot [[x1,y1],[x2,y2]] | 2,282,727 | <p>I want to draw graph using a list of <code>(x,y)</code> pairs instead of using two lists, one of X's and one of Y's. Something like this:</p>
<pre><code>a = [[1,2],[3,3],[4,4],[5,2]]
plt.plot(a, 'ro')
</code></pre>
<p>Rather than:</p>
<pre><code>plt.plot([1,3,4,5], [2,3,4,2])
</code></pre>
<p>Suggestions?</p>
| 28 | 2010-02-17T17:05:29Z | 23,716,233 | <p><strong>list comprehensions</strong></p>
<p>I highly suggest the liberal application of list comprehensions. Not only are they terse and powerful, they tend to make your code very readable.</p>
<p>Try something like this:</p>
<pre><code>list_of_lists = [[1,2],[3,3],[4,4],[5,2]]
x_list = [x for [x, y] in list_... | 7 | 2014-05-17T21:26:46Z | [
"python",
"matplotlib"
] |
How to see if code is backwards compatible for Python? | 2,282,882 | <p>I have some code that I am trying to make it play nicely with ESRI's geoprocessor. However, ESRI's geoprocessor runs on Python 2.2, 2.3, 2.4, 2.5. We need to make our tools work on any version. So I've spent a lot of time working and coding workarounds for different versions, such that the wrapper geoprocessor has i... | 13 | 2010-02-17T17:21:35Z | 2,283,054 | <p>Try pyqver: <a href="https://github.com/ghewgill/pyqver/" rel="nofollow">https://github.com/ghewgill/pyqver/</a></p>
<p>Gives you the minimum version for given python script analyzing the keywords and modules used.</p>
<p>Also, you can compile locally python 2.2 and use virtualenv to create a python 2.2 environmen... | 9 | 2010-02-17T17:46:00Z | [
"python",
"backwards-compatibility"
] |
How to see if code is backwards compatible for Python? | 2,282,882 | <p>I have some code that I am trying to make it play nicely with ESRI's geoprocessor. However, ESRI's geoprocessor runs on Python 2.2, 2.3, 2.4, 2.5. We need to make our tools work on any version. So I've spent a lot of time working and coding workarounds for different versions, such that the wrapper geoprocessor has i... | 13 | 2010-02-17T17:21:35Z | 2,283,061 | <p>If you are actively developing a commercial product, and you -really- want to support all these versions properly, I would suggest:</p>
<ol>
<li><p>Writing an automated test suite that can be run and tests functionality for your entire library/application/whatever.</p></li>
<li><p>Setting up a machine, or ideally v... | 10 | 2010-02-17T17:46:59Z | [
"python",
"backwards-compatibility"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 3,042,230 | <p>This may be the answer. </p>
<p>When calling OAuthGetRequestToken you sign the base_string with your consumer_secret followed by an & (ampersand)</p>
<p>When calling OAuthGetAccessToken you sign the base_string with your consumer_secret followed by an & (ampersand) followed by token_secret.</p>
<p>You wou... | 2 | 2010-06-15T02:50:04Z | [
"python",
"django",
"oauth",
"google-api"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 3,135,032 | <p>Have you tried the official gdata python api ?
It ships with an oauth client and hides the complexity of oauth calls.
<a href="http://code.google.com/p/gdata-python-client/" rel="nofollow">http://code.google.com/p/gdata-python-client/</a></p>
| 3 | 2010-06-28T18:18:36Z | [
"python",
"django",
"oauth",
"google-api"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 3,205,890 | <p>IIRC Google oauth is not quite following the standard, you <em>have</em> to specify what service you're requesting for (look at the examples provided in the google docs) in the request as an additional parameter, or it won't work.</p>
| 0 | 2010-07-08T16:32:48Z | [
"python",
"django",
"oauth",
"google-api"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 3,272,397 | <p>Tornado has working code for Google oauth. Check it out here. <a href="http://github.com/facebook/tornado/blob/master/tornado/auth.py#L588" rel="nofollow">google auth</a>. I 've used it and worked pretty well out of the box. All you need to do is pluck out the class and carefully put it into a django view. </p>
<p>... | 2 | 2010-07-17T16:52:30Z | [
"python",
"django",
"oauth",
"google-api"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 3,286,288 | <p>I have OAuth working in a python App Engine app:</p>
<p><a href="http://github.com/sje397/Chess">http://github.com/sje397/Chess</a></p>
<p>The app is running at:</p>
<p><a href="http://your-move.appspot.com">http://your-move.appspot.com</a></p>
| 6 | 2010-07-20T01:09:36Z | [
"python",
"django",
"oauth",
"google-api"
] |
Oauth for Google API example using Python / Django | 2,282,924 | <p>I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as <a href="http://github.com/leah/python-oauth/">oauth</a>, <a href="http://github.com/simplegeo/python-oauth2">oauth2</a> and <a href="http://code.welldev.org/django-oauth/wiki/Home">djanog-oauth</a> but ... | 33 | 2010-02-17T17:28:08Z | 9,254,557 | <p>This work for me.</p>
<pre><code>def login(request):
consumer_key = 'blabla'
consumer_secret = 'blabla'
callback = request.GET['callback']
request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken'
authorize_url = 'https://api.linkedin.com/uas/oauth/authorize'
acc... | 4 | 2012-02-13T01:32:07Z | [
"python",
"django",
"oauth",
"google-api"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,283,060 | <p>Download the book <a href="http://www.diveintopython.net/soap_web_services/index.html" rel="nofollow">from here</a>. Read it, breathe it and eat it.. :)</p>
<p>It's good for anyone.</p>
<p>And <a href="http://www.diveintopython3.net" rel="nofollow">updated for Python3</a>.</p>
| 2 | 2010-02-17T17:46:41Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,283,093 | <p>I wouldn't try to compare Perl and Python too much in order to learn Python, especially since you have working knowledge of other languages. If you are unfamiliar with OOP/Functional programming aspects and just looking to work procedurally like in Perl, start learning the Python language constructs / syntax and the... | -3 | 2010-02-17T17:51:48Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,283,160 | <p>Check out the <a href="http://docs.python.org/tut/" rel="nofollow">official tutorial</a>, which is actually pretty good. If you are interested in web development you should be ready at that point to jump right in to the documentation of the web framework you will be working with; Python has many to choose from, with... | 4 | 2010-02-17T18:02:29Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,283,224 | <p>If what you are looking at is succinct, concise reference to python then the book <a href="http://rads.stackoverflow.com/amzn/click/0672329786" rel="nofollow">Python Essential Reference</a>
might be helpful.</p>
| 2 | 2010-02-17T18:08:59Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,283,300 | <p>I've recently had to make a similar transition for work reasons, and it's been pretty painful. For better or worse, Python has a very different philosophy and way of working than Perl, and getting used to that can be frustrating. The things I've found most useful have been</p>
<ul>
<li>Spend a few hours going throu... | 56 | 2010-02-17T18:19:07Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,285,677 | <p><a href="http://wiki.python.org/moin/" rel="nofollow">This</a> is the site you should really go to. There's a section called <strong>Getting Started</strong> which you should take a look. There are also recommendations on books. On top of that, you might also be interested in <a href="http://wiki.python.org/moin/Per... | 3 | 2010-02-18T01:17:19Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,286,686 | <p>Being a hardcore Perl programmer, all I can say is <strong>DO NOT BUY</strong> O'Reilly's "Learning Python". It is nowhere NEAR as good as "Learning Perl", and there's no equivalent I know of to Larry Wall's "Programming Perl", which is simply unbeatable.</p>
<p>I've had the most success taking past Perl programs a... | 7 | 2010-02-18T06:16:46Z | [
"python",
"perl"
] |
Python for a Perl programmer | 2,283,034 | <p>I am an experienced Perl developer with some degree of experience and/or familiarity with other languages (working experience with C/C++, school experience with Java and Scheme, and passing familiarity with many others).</p>
<p>I might need to get some web work done in Python (most immediately, related to Google Ap... | 43 | 2010-02-17T17:43:42Z | 2,291,006 | <p>If you happen to be a fan of <a href="http://en.wikipedia.org/wiki/Perl_Cookbook">The Perl Cookbook</a>, you might be interested in checking out <a href="http://pleac.sourceforge.net">PLEAC, the Programming Language Examples Alike Cookbook</a>, specifically <a href="http://pleac.sourceforge.net/pleac_python">the sec... | 12 | 2010-02-18T18:12:42Z | [
"python",
"perl"
] |
App Engine, Python: how to filter query by ID? | 2,283,149 | <p>I try to get data from app engine datastore.</p>
<p>Filtering query by 'title' (or any other property) works:</p>
<pre><code>obj = db.Query(PageModel).filter('title',title)[0]
</code></pre>
<p>But the same thing with ID - doesn't:</p>
<pre><code>obj = db.Query(PageModel).filter('ID',page_id)[0]
</code></pre>
<p... | 6 | 2010-02-17T18:00:56Z | 2,283,381 | <p>Try</p>
<pre><code>obj = PageModel.get_by_id(page_id)
</code></pre>
<p>instead. This assumes that the ID you're working with is the numerical ID of a datastore key (ie, came from something like <code>obj.key().id()</code>) and not some arbitrary ID field you've added to your <code>PageModel</code>.</p>
| 13 | 2010-02-17T18:31:36Z | [
"python",
"google-app-engine"
] |
App Engine, Python: how to filter query by ID? | 2,283,149 | <p>I try to get data from app engine datastore.</p>
<p>Filtering query by 'title' (or any other property) works:</p>
<pre><code>obj = db.Query(PageModel).filter('title',title)[0]
</code></pre>
<p>But the same thing with ID - doesn't:</p>
<pre><code>obj = db.Query(PageModel).filter('ID',page_id)[0]
</code></pre>
<p... | 6 | 2010-02-17T18:00:56Z | 6,164,129 | <p>You can filter data by using key(s):</p>
<pre><code>from google.appengine.ext.db import Key
key = Key('bgakaWdyc3NlcnIPCxIJRmVlZEVudHJ5GAwM')
# Match many
PageModel.all().filter('__key__ IN ', [key])
# Match one
PageModel.all().filter('__key__ = ', key)
</code></pre>
<p>However, the method get_by_id(id) is prefe... | 2 | 2011-05-28T20:17:17Z | [
"python",
"google-app-engine"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,233 | <p>Easiest</p>
<pre><code>eval(myvar)(parameter1, parameter2)
</code></pre>
<p>You don't have a function "pointer". You have a function "name".</p>
<p>While this works well, you will have a large number of folks telling you it's "insecure" or a "security risk". </p>
| 4 | 2010-02-17T18:10:16Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,243 | <pre><code>funcdict = {
'mypackage.mymodule.myfunction': mypackage.mymodule.myfunction,
....
}
funcdict[myvar](parameter1, parameter2)
</code></pre>
| 62 | 2010-02-17T18:11:21Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,267 | <pre><code>def f(a,b):
return a+b
xx = 'f'
print eval('%s(%s,%s)'%(xx,2,3))
</code></pre>
<p><strong>OUTPUT</strong></p>
<pre><code> 5
</code></pre>
| 11 | 2010-02-17T18:15:22Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,297 | <pre><code>modname, funcname = myvar.rsplit('.', 1)
getattr(sys.modules[modname], funcname)(parameter1, parameter2)
</code></pre>
| 2 | 2010-02-17T18:18:42Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,518 | <p>Why not store the function itself? <code>myvar = mypackage.mymodule.myfunction</code> is much cleaner.</p>
| 3 | 2010-02-17T18:55:15Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 2,283,574 | <p>It's much nicer to be able to just store the function itself, since they're first-class objects in python.</p>
<pre><code>import mypackage
myfunc = mypackage.mymodule.myfunction
myfunc(parameter1, parameter2)
</code></pre>
<p>But, if you have to import the package dynamically, then you can achieve this through:</... | 25 | 2010-02-17T19:03:41Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 23,989,558 | <p><code>eval(compile(myvar,'<str>','eval'))(myargs)</code></p>
<p>compile(...,'eval') allows only a single statement, so that there can't be arbitrary commands after a call, or there will be a SyntaxError. Then a tiny bit of validation can at least constrain the expression to something in your power, like testi... | 0 | 2014-06-02T07:42:38Z | [
"python",
"function-pointers"
] |
Python function pointer | 2,283,210 | <p>I have a function name stored in a variable like this:</p>
<pre><code>myvar = 'mypackage.mymodule.myfunction'
</code></pre>
<p>and I now want to call myfunction like this</p>
<pre><code>myvar(parameter1, parameter2)
</code></pre>
<p>What's the easiest way to achieve this?</p>
| 41 | 2010-02-17T18:07:50Z | 38,236,885 | <p>I ran into a similar problem while creating a library to handle authentication. I want the app owner using my library to be able to register a callback with the library for checking authorization against LDAP groups the authenticated person is in. The configuration is getting passed in as a config.py file that gets ... | 0 | 2016-07-07T02:51:03Z | [
"python",
"function-pointers"
] |
Python+suds : xsd_base64Binary type? | 2,283,219 | <p>I'm trying to attach some files to a Jira using the Soap API.
I have python 2.6 and SOAPpy isn't working any more, so, I'm using suds. Everything is fine except for the attachements ... I don't know how to rewrite this piece of code : <a href="http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client?focu... | 1 | 2010-02-17T18:08:50Z | 2,872,793 | <p>dunno if this helps but when I was using python the handle wsdls I found a distinct lack of support in most packages for complex types. In the end I decided on zsi with its wsdl2py --complexType wsdl_url. This worked perfectly. I had many complex types in my wsdl with arrays of arrays of arrays defined in the wsdl. ... | 0 | 2010-05-20T10:17:21Z | [
"python",
"soap",
"jira",
"suds"
] |
Python+suds : xsd_base64Binary type? | 2,283,219 | <p>I'm trying to attach some files to a Jira using the Soap API.
I have python 2.6 and SOAPpy isn't working any more, so, I'm using suds. Everything is fine except for the attachements ... I don't know how to rewrite this piece of code : <a href="http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client?focu... | 1 | 2010-02-17T18:08:50Z | 4,949,828 | <p>You can attach a file to an issue using the Jira CLI (written in Python using suds). <a href="https://studio.plugins.atlassian.com/wiki/display/JCLIMD/JIRA+Command+Line+Interface+%28Python%29" rel="nofollow">The standalone code</a> is available under an LGPL license.</p>
<p>The command you would use is "attach".</... | 0 | 2011-02-09T20:02:10Z | [
"python",
"soap",
"jira",
"suds"
] |
Python+suds : xsd_base64Binary type? | 2,283,219 | <p>I'm trying to attach some files to a Jira using the Soap API.
I have python 2.6 and SOAPpy isn't working any more, so, I'm using suds. Everything is fine except for the attachements ... I don't know how to rewrite this piece of code : <a href="http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client?focu... | 1 | 2010-02-17T18:08:50Z | 5,328,676 | <p>If you do not want to use the Java CLI, below is how to add and attachment in Python.</p>
<pre><code>from suds.client import Client
client = Client(url_to_wsdl_file)
auth = client.service.login(username, password)
client.service.addBase64EncodedAttachmentsToIssue(auth, issue_key, [filename.encode("utf-8")], [open(... | 1 | 2011-03-16T16:47:09Z | [
"python",
"soap",
"jira",
"suds"
] |
Python trouble importing modules | 2,283,394 | <p>I am building a web app with this directory structure:</p>
<pre><code>app/
__init__.py
config/
__init__.py
db_config.py
models/
__init__.py
model.py
datasources/
__init__.py
database.py
...
...
</code></pre>
<p>Every __init__.py fi... | 1 | 2010-02-17T18:34:14Z | 2,283,423 | <p><code>import app.config.db_config</code> is the best way (avoid non-absolute imports and never ever use import *), and for this to work the <code>app</code> directory should be in <code>sys.path</code>. If it is not, add the directory to you <code>PYTHONPATH</code> or move the project to somewhere this is the case.<... | 2 | 2010-02-17T18:39:50Z | [
"python",
"filesystems",
"module"
] |
simple twisted server (twistd .tap)with a pexpect instance error | 2,283,408 | <p>I have been creating an async server socket that sends and recives xml using twisted.</p>
<p>The application works great! but because my main objective was to embed it in an init.d script and make it run in the background i decided to transform it in a "twisted application" in order to run it using twistd</p>
<pre... | 0 | 2010-02-17T18:36:27Z | 2,283,888 | <p>You're spawning a child process before daemonizing. After daemonizing that child is now a child of init, and not a child of your daemon.</p>
<p>You need to subclass <code>from twisted.application.service import Service</code> and spawn the child process in <code>startService</code>, which will be called after daemo... | 3 | 2010-02-17T19:46:59Z | [
"python",
"twisted",
"daemon",
"pexpect"
] |
app-engine-patch is dead. Now what is the best way to use Django on Google App Engine? | 2,283,414 | <p>The app-engine-patch authors have officially marked this wonderful project as dead <a href="http://code.google.com/p/app-engine-patch/" rel="nofollow"> on their website.</a> Over the last year a lot of people have asked what the best way to run Django on Google App Engine was, and time after time people have pointed... | 5 | 2010-02-17T18:38:13Z | 2,283,745 | <p>App engine patch is probably a safer bet for a given moment. Though not actively supported at the moment, it's still great, as it's been tested more thoroughly. If you're ready to take some risks - go and give the new djangoappengine+django-nonrel (native django support for non relational databases, primarily google... | 4 | 2010-02-17T19:25:22Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch"
] |
app-engine-patch is dead. Now what is the best way to use Django on Google App Engine? | 2,283,414 | <p>The app-engine-patch authors have officially marked this wonderful project as dead <a href="http://code.google.com/p/app-engine-patch/" rel="nofollow"> on their website.</a> Over the last year a lot of people have asked what the best way to run Django on Google App Engine was, and time after time people have pointed... | 5 | 2010-02-17T18:38:13Z | 2,304,845 | <p>It looks like you can just import it using use_library...</p>
<p><a href="http://code.google.com/appengine/docs/python/tools/libraries.html" rel="nofollow">http://code.google.com/appengine/docs/python/tools/libraries.html</a></p>
| 0 | 2010-02-21T05:06:55Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,283,637 | <p>The <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiprocessing</a> module is great and relieves from the limitations of the <a href="http://en.wikipedia.org/wiki/Global_Interpreter_Lock" rel="nofollow">GIL</a>.</p>
<p>Of course you can also have recourse to C based modules with thr... | 0 | 2010-02-17T19:12:37Z | [
"python",
"multithreading"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,283,694 | <p>I'd recommend <a href="http://herbsutter.wordpress.com/" rel="nofollow">http://herbsutter.wordpress.com/</a> (scroll down to the efficient concurrency columns) for a really great overview of what multiprocessing is all about. Yes, that guy talks about concurrency in a C++ context, but most of it is applicable for an... | 3 | 2010-02-17T19:19:22Z | [
"python",
"multithreading"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,283,750 | <p>Just to be sure, you mention multithreading and not multiprocessing. Information on <a href="http://docs.python.org/library/threading.html#module-threading" rel="nofollow" title="multithreading">Multithreading</a>
is available at that link. Multithreading is functionally different than multiprocessing. As mention... | 1 | 2010-02-17T19:26:09Z | [
"python",
"multithreading"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,283,821 | <p>here are 2 good python threading tutorials with code samples and some good background info:</p>
<p><a href="http://linuxgazette.net/107/pai.html" rel="nofollow">http://linuxgazette.net/107/pai.html</a><br>
<a href="http://www.ibm.com/developerworks/aix/library/au-threadingpython/" rel="nofollow">http://www.ibm.com/... | 0 | 2010-02-17T19:36:54Z | [
"python",
"multithreading"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,283,905 | <p>To multithread in python, you can use the python built-in <a href="http://docs.python.org/library/threading.html" rel="nofollow">threading</a> module. However, be aware that if your threads are compute-bound rather than IO bound, you are likely to have <em>worse</em> performance when multithreading. If your executio... | 0 | 2010-02-17T19:50:12Z | [
"python",
"multithreading"
] |
What resources/references are available for multithreaded programming in Python? | 2,283,610 | <p>I'm evaluating the use of Python for a new project and ran through some basic tutorials but am looking for some recommendations and resources for multithreaded development in Python? How does it compare to other languages?</p>
| 1 | 2010-02-17T19:07:54Z | 2,285,734 | <p>Although the comments about <code>multiprocessing</code> being a very useful new package that allows easily taking advantage of multi-core systems, your requirements for multithreaded behaviour may not require that, and may also be entirely unaffected by the "limitations of the GIL". </p>
<p>We've built many appli... | 0 | 2010-02-18T01:30:46Z | [
"python",
"multithreading"
] |
Opinion about Glashammer App engine Web framework | 2,283,616 | <p>I am having to look into some code and consider working in a Python framework called <a href="http://glashammer.org/" rel="nofollow">Glashammer</a>.</p>
<p>I know and love Django. I have some experience with Appengine native framework and Django on Appengine.</p>
<p>I'd like to know from you that have used one or ... | 2 | 2010-02-17T19:08:59Z | 2,296,467 | <p>After a bit of googling (and finding your question:) and half an hour of reading docs and code I can say that</p>
<p>Glashammmer is great because it:</p>
<ul>
<li>is well-documented;</li>
<li>is lightweight and very flexible;</li>
<li>provides almost everything to rapidly build a complex web app -- unlike Werkzeug... | 3 | 2010-02-19T13:13:16Z | [
"python",
"django",
"google-app-engine"
] |
Opinion about Glashammer App engine Web framework | 2,283,616 | <p>I am having to look into some code and consider working in a Python framework called <a href="http://glashammer.org/" rel="nofollow">Glashammer</a>.</p>
<p>I know and love Django. I have some experience with Appengine native framework and Django on Appengine.</p>
<p>I'd like to know from you that have used one or ... | 2 | 2010-02-17T19:08:59Z | 2,326,660 | <p>I am highly biased, because I am the Glashammer author. But the pros for me are:</p>
<ul>
<li>Werkzeug-based framework removes much of the boilerplate in creating Werkzeug based
applications</li>
<li>Easy pluggability and high flexibility: 2 levels of plugins, Appliances which are reusable components and Bundles wh... | 3 | 2010-02-24T14:27:41Z | [
"python",
"django",
"google-app-engine"
] |
psycopg2.InternalError no matter what I do | 2,283,704 | <p>I use Django and just dropped and re-created database in order to flush table data. Now when I'm trying to do any db-related task, I get: </p>
<pre><code>./manage.py sql portfolio
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/lib/pymod... | 1 | 2010-02-17T19:20:45Z | 2,283,983 | <p>That error means that something happened to your Postgres process that caused it to fail in the middle of a transaction but the transaction was never committed or rolled back, so it's stuck.</p>
<p>Basically you need to either issue a rollback command (this can be done from the Django shell, oftentimes), or kill th... | 3 | 2010-02-17T20:04:06Z | [
"python",
"django"
] |
psycopg2.InternalError no matter what I do | 2,283,704 | <p>I use Django and just dropped and re-created database in order to flush table data. Now when I'm trying to do any db-related task, I get: </p>
<pre><code>./manage.py sql portfolio
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/lib/pymod... | 1 | 2010-02-17T19:20:45Z | 17,786,838 | <p>Check postgres log file, to see the actual query responsible for database error. and try to find which portion of django makes this query.</p>
<p>Also check out <a href="https://github.com/django-debug-toolbar/django-debug-toolbar/issues/351" rel="nofollow">https://github.com/django-debug-toolbar/django-debug-toolb... | 0 | 2013-07-22T11:49:58Z | [
"python",
"django"
] |
Setting the cursor position in PyGTK (for a Gedit plugin) | 2,283,933 | <p>I'm developing a Gedit plugin which is built on PyGTK. I'm trying to figure out how to programatically tell the cursor where to go. For example, I'd like to have the cursor automatically go to right before the first "|" (pipe) in the current line.</p>
<p>Any ideas or starting points? I've been using the Gedit API u... | 0 | 2010-02-17T19:54:08Z | 2,284,334 | <p>Looking at the gedit plugin API, it looks like <code>gedit.Document</code> is a subclass of <code>GtkSourceBuffer</code> which itself subclasses <code>GtkTextBuffer</code>, the last of which has the cursor manipulation API you want. In particular, <code>get_insert()</code> and <code>place_cursor(where)</code> give t... | 1 | 2010-02-17T20:56:51Z | [
"python",
"plugins",
"pygtk",
"gedit"
] |
Django extends/include - bug? | 2,284,495 | <p>I'm trying to use both extends and include tags in one template, just like:</p>
<pre><code>{% extends "layout.html" %}
{% block content %}
<div id="content">
<nav class="mainMenu">
{% include "list.html" %}
</nav>
</div>
{% endblock %}
</code></pre>
<p>Unfortunately what is displa... | 1 | 2010-02-17T21:19:45Z | 2,284,512 | <p>You are most probably only rendering list.html in your view, check for that.</p>
| 2 | 2010-02-17T21:24:09Z | [
"python",
"django",
"templates"
] |
Google Books API - Getting Book Ratings? | 2,284,595 | <p>I cannot find a way to get a Book's <strong>Ratings</strong> through the <strong>Books API</strong> provided by Google.</p>
<p>All I figured out is how to obtain search listings, which do not include <strong>ratings and description</strong>.</p>
<hr>
<p>Help would be very much appreciated.</p>
| 2 | 2010-02-17T21:39:28Z | 2,348,193 | <p>I've never used Google Book API, but <a href="http://code.google.com/apis/books/docs/gdata/developers_guide_php.html#RetrievingAnnotations" rel="nofollow">its documentation</a> claims you can only retrieve an annotation (incl. review) for a specific user.</p>
<p>Another proof is some <a href="http://www.google.com/... | 1 | 2010-02-27T17:05:32Z | [
"python",
"ajax",
"google-books"
] |
Sum of Square Differences (SSD) in numpy/scipy | 2,284,611 | <p>I'm trying to use Python and Numpy/Scipy to implement an image processing algorithm. The profiler tells me a lot of time is being spent in the following function (called often), which tells me the sum of square differences between two images</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s +=... | 6 | 2010-02-17T21:43:37Z | 2,284,634 | <p>Just</p>
<pre><code>s = numpy.sum((A[:,:,0:3]-B[:,:,0:3])**2)
</code></pre>
<p>(which I expect is likely just <code>sum((A-B)**2)</code> if the shape is always (<em>,</em>,3))</p>
<p>You can also use the sum method: <code>((A-B)**2).sum()</code></p>
<p>Right?</p>
| 18 | 2010-02-17T21:47:11Z | [
"python",
"image-processing",
"numpy",
"scipy"
] |
Sum of Square Differences (SSD) in numpy/scipy | 2,284,611 | <p>I'm trying to use Python and Numpy/Scipy to implement an image processing algorithm. The profiler tells me a lot of time is being spent in the following function (called often), which tells me the sum of square differences between two images</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s +=... | 6 | 2010-02-17T21:43:37Z | 2,284,641 | <p>I do not know if the pow() function with power 2 will be fast. Try:</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s += sum((A[:,:,i] - B[:,:,i])*A[:,:,i] - B[:,:,i])
return s
</code></pre>
| 1 | 2010-02-17T21:47:52Z | [
"python",
"image-processing",
"numpy",
"scipy"
] |
Sum of Square Differences (SSD) in numpy/scipy | 2,284,611 | <p>I'm trying to use Python and Numpy/Scipy to implement an image processing algorithm. The profiler tells me a lot of time is being spent in the following function (called often), which tells me the sum of square differences between two images</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s +=... | 6 | 2010-02-17T21:43:37Z | 2,284,657 | <p>I am confused why you are taking <code>i in range(3)</code>. Is that supposed to be the whole array, or just part? </p>
<p>Overall, you can replace most of this with operations defined in numpy:</p>
<pre><code>def ssd(A,B):
squares = (A[:,:,:3] - B[:,:,:3]) ** 2
return numpy.sum(squares)
</code></pre>
<p>... | 1 | 2010-02-17T21:50:06Z | [
"python",
"image-processing",
"numpy",
"scipy"
] |
Sum of Square Differences (SSD) in numpy/scipy | 2,284,611 | <p>I'm trying to use Python and Numpy/Scipy to implement an image processing algorithm. The profiler tells me a lot of time is being spent in the following function (called often), which tells me the sum of square differences between two images</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s +=... | 6 | 2010-02-17T21:43:37Z | 2,319,405 | <p>Further to Ritsaert Hornstra's answer that got 2 negative marks (admittedly I didn't see it in it's original form...)</p>
<p>This is actually true.</p>
<p>For a large number of iterations it can often take twice as long to use the '**' operator or the pow(x,y) method as to just manually multiply the pairs together... | 1 | 2010-02-23T15:41:22Z | [
"python",
"image-processing",
"numpy",
"scipy"
] |
Sum of Square Differences (SSD) in numpy/scipy | 2,284,611 | <p>I'm trying to use Python and Numpy/Scipy to implement an image processing algorithm. The profiler tells me a lot of time is being spent in the following function (called often), which tells me the sum of square differences between two images</p>
<pre><code>def ssd(A,B):
s = 0
for i in range(3):
s +=... | 6 | 2010-02-17T21:43:37Z | 28,214,127 | <p>In Ruby language you can achieve this in this way</p>
<pre><code>def diff_btw_sum_of_squars_and_squar_of_sum(from=1,to=100) # use default values from 1..100.
((1..100).inject(:+)**2) -(1..100).map {|num| num ** 2}.inject(:+)
end
diff_btw_sum_of_squars_and_squar_of_sum #call for above method
</code></pre>
| -2 | 2015-01-29T11:54:14Z | [
"python",
"image-processing",
"numpy",
"scipy"
] |
Room for improvement on my Python code? | 2,284,809 | <p>I'm working on a Gedit plugin using Python (and PyGTK) and I really havent' worked with Python much so I have no idea if I'm writing Pythonic code.</p>
<p>All of my own code is contained in <code>__init__.py</code>. There are a few other files, but they're from an outside library that I'm hooking into. My <code>__i... | 2 | 2010-02-17T22:13:30Z | 2,284,853 | <p>Perhaps you want to move it into a file called <code>zen_plugin.py</code></p>
<p>Then make your <code>__init__.py</code></p>
<pre><code>from zen_plugin import ZenCodingPlugin
</code></pre>
| 2 | 2010-02-17T22:21:33Z | [
"python",
"pygtk",
"gedit"
] |
Room for improvement on my Python code? | 2,284,809 | <p>I'm working on a Gedit plugin using Python (and PyGTK) and I really havent' worked with Python much so I have no idea if I'm writing Pythonic code.</p>
<p>All of my own code is contained in <code>__init__.py</code>. There are a few other files, but they're from an outside library that I'm hooking into. My <code>__i... | 2 | 2010-02-17T22:13:30Z | 2,284,899 | <p>I've never done a GEdit plugin, so i can't comment on the _<em>init</em>_.py issue, but general notes:</p>
<ul>
<li><p>Isn't calling parent's _<em>init</em>_ with no new args redundant -- can't you just take out those 2 lines?</p></li>
<li><p>You create more local variables than I would have. I had to keep looking... | 3 | 2010-02-17T22:29:00Z | [
"python",
"pygtk",
"gedit"
] |
Room for improvement on my Python code? | 2,284,809 | <p>I'm working on a Gedit plugin using Python (and PyGTK) and I really havent' worked with Python much so I have no idea if I'm writing Pythonic code.</p>
<p>All of my own code is contained in <code>__init__.py</code>. There are a few other files, but they're from an outside library that I'm hooking into. My <code>__i... | 2 | 2010-02-17T22:13:30Z | 2,284,928 | <p>I would try to extract some functions from the long <code>expand_zencode()</code>. Like an <code>expand_tabs()</code>, for example. That's a matter of taste to some extent, but whenever I see a 'travelogue' with comments pointing out 'sights' along the way, it's a strong hint to refactor into functions each with a d... | 1 | 2010-02-17T22:33:27Z | [
"python",
"pygtk",
"gedit"
] |
Room for improvement on my Python code? | 2,284,809 | <p>I'm working on a Gedit plugin using Python (and PyGTK) and I really havent' worked with Python much so I have no idea if I'm writing Pythonic code.</p>
<p>All of my own code is contained in <code>__init__.py</code>. There are a few other files, but they're from an outside library that I'm hooking into. My <code>__i... | 2 | 2010-02-17T22:13:30Z | 2,285,051 | <p>It's gui code and is always verbose, my best advice is: does it work? good. Next Task !</p>
| -3 | 2010-02-17T22:51:27Z | [
"python",
"pygtk",
"gedit"
] |
Room for improvement on my Python code? | 2,284,809 | <p>I'm working on a Gedit plugin using Python (and PyGTK) and I really havent' worked with Python much so I have no idea if I'm writing Pythonic code.</p>
<p>All of my own code is contained in <code>__init__.py</code>. There are a few other files, but they're from an outside library that I'm hooking into. My <code>__i... | 2 | 2010-02-17T22:13:30Z | 2,285,181 | <p>If you only have the one file then your directory structure probably looks like</p>
<pre><code>pluginname
`- __init__.py
</code></pre>
<p>In this case you can just flatten your project to</p>
<pre><code>pluginname.py
</code></pre>
<p>If you later need other modules in your package you could go to</p>
<pre><code... | 1 | 2010-02-17T23:16:28Z | [
"python",
"pygtk",
"gedit"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,024 | <p>Python can handle circular imports to some extent. In cases where no sense can be made, the solution would probably still not make sense in another language. Most of the problems can be cleared up by using <code>import first</code> and later referring to <code>first.First</code> instead of <code>from first import Fi... | 11 | 2010-02-17T22:48:05Z | [
"python",
"ruby",
"dynamic-languages"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,026 | <p>Recursive definitions are not a problem restricted to dynamic languages. It's also often an issue in statically types languages. It might show up as a compile error because one of the types will be used before it is defined.</p>
<p>In some languages the solution is to use forward declarations. Other languages solve... | 3 | 2010-02-17T22:48:13Z | [
"python",
"ruby",
"dynamic-languages"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,034 | <p>This isn't a problem related to "dynamic" languages. It's an architectural issue. You need to take a better look at how you've structured things.</p>
| 0 | 2010-02-17T22:49:03Z | [
"python",
"ruby",
"dynamic-languages"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,054 | <p>Logically this is a paradox. It's the chicken and egg issue in code form. One of them has to come first. As suggested by the others, please go back to the drawing board and you'll be better off for it in the long run. Languages prevent you from doing this stuff for a reason!</p>
| 1 | 2010-02-17T22:52:05Z | [
"python",
"ruby",
"dynamic-languages"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,076 | <p>All other posters are correct that circular imports are a serious issue that you should fix, structurally.</p>
<p>However, specificly with Python/Django models, you can use string names to setup foreign keys to avoid these circular dependency issues --</p>
<pre><code>#appA/models.py
class A(models.Model):
b = mo... | 2 | 2010-02-17T22:57:00Z | [
"python",
"ruby",
"dynamic-languages"
] |
Do all dynamic languages have the circular import issue? | 2,284,968 | <p>For the following Python code:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
from second import Second
class First:
def __init__(self):
print 'Second'
</code></pre>
<p><strong>second.py</strong></p>
<pre><code># second.py
from first import First
class Second:
def __init__(self):
... | 2 | 2010-02-17T22:38:52Z | 2,285,687 | <p>Note that if you just move your imports to the end of your module, circular imports will work as expected. Like so:</p>
<p><strong>first.py</strong></p>
<pre><code># first.py
class First:
def __init__(self):
print 'Second'
from second import Second
</code></pre>
<p><strong>second.py</strong></p>
<pre><code... | 1 | 2010-02-18T01:18:53Z | [
"python",
"ruby",
"dynamic-languages"
] |
sqlalchemy 0.6 legacy database access? | 2,285,062 | <p>I feel like this should be simple, but i cant find a single example of it being done.</p>
<p>As an example I have the following existing tables:</p>
<pre><code>CREATE TABLE `source` (
`source_id` tinyint(3) unsigned NOT NULL auto_increment,
`name` varchar(40) default NULL,
PRIMARY KEY (`source_id`),
UNIQU... | 0 | 2010-02-17T22:53:25Z | 2,291,322 | <p>You can use a predefined/autoloaded table with declarative_base by assigning it to the __table__ attribute. The columns are picked up from the table, but you'll still have declare any relations you want to use.</p>
<pre><code>class Source(Base):
__table__ = source
class Event(Base):
__table__ = event
s... | 2 | 2010-02-18T18:56:21Z | [
"python",
"sqlalchemy",
"legacy-database"
] |
Python, mongo + spider monkey | 2,285,083 | <p>Ok, so this isn't exactly a question that I expect a full answer for but here goes...</p>
<p>I am currently using a python driver to fire data at a mongo instance and all it well in the world. Now I want to be able to pull data from mongo and evaluate each record in the collection. Now I need to pass in to this eva... | 0 | 2010-02-17T22:58:13Z | 2,289,628 | <p>Have you looked at <code>$where</code> clauses in MongoDB? Seems like those would pretty much give you exactly what you're looking for. In PyMongo it would look something like:</p>
<pre><code>db.foo.find().where("some javascript function that will get applied to each document matched by the find")
</code></pre>
| 3 | 2010-02-18T15:15:54Z | [
"python",
"mongodb",
"spidermonkey"
] |
How to install html5lib-0.90 library for Python on Windows? | 2,285,086 | <p>I'm using Windows, and trying to install html5lib-0.90 library on python </p>
<pre><code>C:\>python C:\Users\Junior\Downloads\Python\html5lib-0.90\setup.py install
Traceback (most recent call last):
File "C:\Users\Junior\Downloads\Python\html5lib-0.90\setup.py", line 36, in <module>
for name in os.listdir(... | 2 | 2010-02-17T22:58:26Z | 2,285,169 | <p>Try:</p>
<pre><code>C:\>cd \Users\Junior\Downloads\Python\html5lib-0.90\
C:\Users\Junior\Downloads\Python\html5lib-0.90>python setup.py install
</code></pre>
| 6 | 2010-02-17T23:14:32Z | [
"python",
"html5lib"
] |
Pylons: response renaming? Is there a better way? | 2,285,247 | <p>I've got a Pylons controller with an action called <strong>serialize</strong> returning <code>content_type=text/csv</code>. I'd like the response of the action to be named based on the input patameter, i.e. for the following route, produced csv file should be named <code>{id}.csv</code> : <code>/app/PROD/serialize</... | 0 | 2010-02-17T23:29:31Z | 2,285,335 | <p>You should be able to set the content-disposition header on a <a href="http://pylonshq.com/docs/en/0.9.7/thirdparty/webob/#webob.Response.content_disposition" rel="nofollow">response object</a>.</p>
<p>If you have already tried that, it may not have worked because the http standard says that the quotes should be do... | 2 | 2010-02-17T23:48:24Z | [
"python",
"pylons",
"response",
"wsgi",
"webob"
] |
Python basics: How to read N ints until '\n' is found in stdin | 2,285,284 | <p>How can I read N <code>int</code>s from the input, and stop reading when I find <code>\n</code>? Also, how can I add them to an array that I can work with?</p>
<p>I'm looking for something like this from C but in python</p>
<pre class="lang-c prettyprint-override"><code>while(scanf("%d%c",&somearray[i],&c)... | 3 | 2010-02-17T23:35:09Z | 2,285,295 | <p>In Python 2:</p>
<pre><code>lst = map(int, raw_input().split())
</code></pre>
<p><code>raw_input()</code> reads a whole line from the input (stopping at the <code>\n</code>) as a string.
<code>.split()</code> creates a list of strings by splitting the input into words.
<code>map(int, ...)</code> creates integers f... | 14 | 2010-02-17T23:37:15Z | [
"python",
"stdin"
] |
Python basics: How to read N ints until '\n' is found in stdin | 2,285,284 | <p>How can I read N <code>int</code>s from the input, and stop reading when I find <code>\n</code>? Also, how can I add them to an array that I can work with?</p>
<p>I'm looking for something like this from C but in python</p>
<pre class="lang-c prettyprint-override"><code>while(scanf("%d%c",&somearray[i],&c)... | 3 | 2010-02-17T23:35:09Z | 2,285,296 | <p>There is no direct equivalent of scanf in Python, but this should work</p>
<pre><code>somearray = map(int, raw_input().split())
</code></pre>
<p>In Python3 <code>raw_input</code> has been renamed to <code>input</code></p>
<pre><code>somearray = map(int, input().split())
</code></pre>
<p>Here is a breakdown/expla... | 12 | 2010-02-17T23:37:43Z | [
"python",
"stdin"
] |
Adding text to p tag in Beautiful Soup | 2,285,389 | <p>I was wondering if anyone knew how to add text to a tag (p, b -- any tag where you might want to include character data). The documentation mentions no where how you might do this. </p>
| 3 | 2010-02-18T00:05:41Z | 2,285,504 | <p>I'm not sure exactly if this is what you want, but maybe it's a start...</p>
<pre><code>from BeautifulSoup import BeautifulSoup, NavigableString
html = "<p></p>"
soup = BeautifulSoup(html)
ptag = soup.find('p')
ptag.insert(0, NavigableString("new"))
print ptag
</code></pre>
<p>Outputs</p>
<pre><code>... | 3 | 2010-02-18T00:33:33Z | [
"python",
"html",
"xml",
"beautifulsoup"
] |
Adding text to p tag in Beautiful Soup | 2,285,389 | <p>I was wondering if anyone knew how to add text to a tag (p, b -- any tag where you might want to include character data). The documentation mentions no where how you might do this. </p>
| 3 | 2010-02-18T00:05:41Z | 2,285,519 | <pre><code>>>> import BeautifulSoup
>>> b=BeautifulSoup.BeautifulSoup("<p></p><p></p>")
>>> for t,s in zip(b,[u'hello',u'world']):
... t.contents.append(BeautifulSoup.NavigableString(s))
...
>>> b
<p>hello</p><p>world</p>
</code></... | 1 | 2010-02-18T00:35:57Z | [
"python",
"html",
"xml",
"beautifulsoup"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 2,285,592 | <p>It seems to me that is perfectly suitable.</p>
<p>Be aware that <code>replace()</code> returns a copy of the original string and does not modify it in place. So since this replacement is only for display purposes it should work just fine.</p>
<p>Here is a little visual example:</p>
<pre><code>>>> s = ""... | 2 | 2010-02-18T00:55:11Z | [
"python",
"pylons",
"mako"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 2,285,613 | <p>Beware as line breaks in <code><textarea></code>s should get submitted as <code>\r\n</code> according to <a href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4" rel="nofollow">http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4</a></p>
<p>To be safe, try <code>s.replace('\r\n', '<... | 2 | 2010-02-18T01:01:10Z | [
"python",
"pylons",
"mako"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 7,381,635 | <p>This seems dangerous to me because it prints the whole string without escaping, which would allow arbitrary tags to be rendered. Make sure you cleanse the user's input with lxml or similar before printing. Beware that lxml will wrap in an HTML tag, it just can't handle things that aren't like that, so get ready to r... | 1 | 2011-09-11T22:13:45Z | [
"python",
"pylons",
"mako"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 12,622,747 | <p>The problem with your solution is that you bypass the string escaping, which can lead to security issues. Here is my solution :</p>
<pre><code><%! import markupsafe %>
${text.replace('\n', markupsafe.Markup('<br />'))}
</code></pre>
<p>or, if you want to use it more than once :</p>
<pre><code><%!
... | 4 | 2012-09-27T13:38:47Z | [
"python",
"pylons",
"mako"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 12,923,553 | <p>There is also a simply help function that can be called which will format and santize text correctly replacing \n for <br> tags (see <a href="http://sluggo.scrapping.cc/python/WebHelpers/modules/html/converters.html" rel="nofollow">http://sluggo.scrapping.cc/python/WebHelpers/modules/html/converters.html</a>).</p>
... | 0 | 2012-10-16T21:17:29Z | [
"python",
"pylons",
"mako"
] |
Converting \n to <br> in mako files | 2,285,507 | <p>I'm using python with pylons</p>
<p>I want to display the saved data from a textarea in a mako file with new lines formatted correctly for display</p>
<p>Is this the best way of doing it?</p>
<pre><code>> ${c.info['about_me'].replace("\n", "<br />") | n}
</code></pre>
| 4 | 2010-02-18T00:33:50Z | 21,016,502 | <p>try this it will work:-</p>
<pre><code>${c.info['about_me'] | n}
</code></pre>
| 1 | 2014-01-09T09:42:22Z | [
"python",
"pylons",
"mako"
] |
Python MySQL query not completing | 2,285,620 | <p>I am having problems with a Python script which is basically just analysing a CSV file line-by-line and then inserting each line into a MySQL table using a FOR loop:</p>
<pre><code>f = csv.reader(open(filePath, "r"))
i = 1
for line in f:
if (i > skipLines):
vals = nullify(line)
try:
... | 1 | 2010-02-18T01:04:36Z | 2,287,202 | <p>Have you tried <code>LOAD</code> MySQL function?</p>
<pre><code>query = "LOAD DATA INFILE '/path/to/file' INTO TABLE atable FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\\\'"
cursor.execute( query )
</code></pre>
<p>You can always pre-process the CSV file (at least that's what I do :)</p>
<p>Another thi... | 1 | 2010-02-18T08:30:15Z | [
"python",
"mysql"
] |
Python MySQL query not completing | 2,285,620 | <p>I am having problems with a Python script which is basically just analysing a CSV file line-by-line and then inserting each line into a MySQL table using a FOR loop:</p>
<pre><code>f = csv.reader(open(filePath, "r"))
i = 1
for line in f:
if (i > skipLines):
vals = nullify(line)
try:
... | 1 | 2010-02-18T01:04:36Z | 2,288,083 | <p>As S. Lott alluded to, aren't cursors used as handles into transactions?</p>
<p>So at any time the db is giving you the option of rolling back all those pending inserts.</p>
<p>You may simply have too many inserts for one transaction. Try committing the transaction every couple of thousand inserts.</p>
| 0 | 2010-02-18T11:09:57Z | [
"python",
"mysql"
] |
Hudson "Source code is unavailable." | 2,285,672 | <p>I'm using <strong>Hudson</strong> to continuously build a <strong>Python</strong> project. Unit tests and code coverage work great, but this message appears when drilling into the <strong>Cobertura Coverage Report</strong> for my files that are <em>not</em> unit tests: </p>
<pre><code>Source code is unavailable.Som... | 10 | 2010-02-18T01:16:25Z | 2,298,860 | <p>The Cobertura report file (which at this point is somewhere in <code>$HUDSON/jobs/foo/workspace</code>) needs to contain something like this at the beginning:</p>
<pre><code><sources>
<source>/path/to/source</source>
<source>/another/path</source>
</sources>
</code></pre>
<p... | 5 | 2010-02-19T19:05:57Z | [
"python",
"continuous-integration",
"hudson",
"code-coverage",
"cobertura"
] |
Hudson "Source code is unavailable." | 2,285,672 | <p>I'm using <strong>Hudson</strong> to continuously build a <strong>Python</strong> project. Unit tests and code coverage work great, but this message appears when drilling into the <strong>Cobertura Coverage Report</strong> for my files that are <em>not</em> unit tests: </p>
<pre><code>Source code is unavailable.Som... | 10 | 2010-02-18T01:16:25Z | 2,915,958 | <p>This is one hell of an ugly hack, but its the only thing that I could come up with to finally make it work... and after hours of Googling and hacking away trying to get results, this is the only thing I came up with.</p>
<pre><code>coverage run manage.py test
coverage xml
sed 's/filename="/filename="my\/path\//g' c... | 6 | 2010-05-26T19:09:14Z | [
"python",
"continuous-integration",
"hudson",
"code-coverage",
"cobertura"
] |
Hudson "Source code is unavailable." | 2,285,672 | <p>I'm using <strong>Hudson</strong> to continuously build a <strong>Python</strong> project. Unit tests and code coverage work great, but this message appears when drilling into the <strong>Cobertura Coverage Report</strong> for my files that are <em>not</em> unit tests: </p>
<pre><code>Source code is unavailable.Som... | 10 | 2010-02-18T01:16:25Z | 3,476,773 | <p>For me the other two solutions did not work stand-alone, but a combination of both of them did:</p>
<pre><code>...
coverage xml
sed 's/<!-- Generated by coverage.py: http:\/\/nedbatchelder.com\/code\/coverage -->/<sources><source>\/path\/to\/sourcefolder<\/source><\/sources>/g'
</code>... | 4 | 2010-08-13T12:29:47Z | [
"python",
"continuous-integration",
"hudson",
"code-coverage",
"cobertura"
] |
Hudson "Source code is unavailable." | 2,285,672 | <p>I'm using <strong>Hudson</strong> to continuously build a <strong>Python</strong> project. Unit tests and code coverage work great, but this message appears when drilling into the <strong>Cobertura Coverage Report</strong> for my files that are <em>not</em> unit tests: </p>
<pre><code>Source code is unavailable.Som... | 10 | 2010-02-18T01:16:25Z | 3,969,970 | <p>Our solution was to alter our use of the cobertura-report ant task to include the full path to the source directory rather than the relative path.</p>
<pre><code> <cobertura-report format="xml" destdir="${coverage.dir}" srcdir="${basedir}/${src.dir}"/>
</code></pre>
<p>Basically, the relative pathing include... | 1 | 2010-10-19T15:25:49Z | [
"python",
"continuous-integration",
"hudson",
"code-coverage",
"cobertura"
] |
Hudson "Source code is unavailable." | 2,285,672 | <p>I'm using <strong>Hudson</strong> to continuously build a <strong>Python</strong> project. Unit tests and code coverage work great, but this message appears when drilling into the <strong>Cobertura Coverage Report</strong> for my files that are <em>not</em> unit tests: </p>
<pre><code>Source code is unavailable.Som... | 10 | 2010-02-18T01:16:25Z | 9,084,693 | <p>The "correct" way to fix this is by putting your project on the PYTHONPATH and running the tests/coverage from outside your repo. Since it looks like you're using Django, django-admin.py test --settings=myproject.settings will let you do this.</p>
<p>-- Originally posted by <a href="http://stackoverflow.com/users/1... | -1 | 2012-01-31T18:11:18Z | [
"python",
"continuous-integration",
"hudson",
"code-coverage",
"cobertura"
] |
splitting one program into several smaller and their binding in python? | 2,285,746 | <p>i want to make from one big program 5 smaller programs:main and program1,program2,program3 and program4.programs1,2,3,4 should use variables from main program and return some new variables,and main program should use(or call) programs1,2,3,4...
can i bind these programs using functions,modules or something else and... | 1 | 2010-02-18T01:35:08Z | 2,285,785 | <p>You can simply use functions to do this:</p>
<pre><code>def function1(a):
print a
def function2(b):
print b
def function3(c):
print c
def function4():
return "hello!"
def main():
a, b, c = (1, 2, 3)
function1(a)
function2(b)
function3(c)
d = function4()
print d
if __name... | 5 | 2010-02-18T01:49:35Z | [
"python"
] |
Python dictionary that maps strings to a set of strings? | 2,285,874 | <p>I would like to be able to make a Python dictionary with strings as keys and sets of strings as the values. E.g.: <code>{ "crackers" : ["crunchy", "salty"] }</code> It must be a set, not a list.</p>
<p>However, when I try the following:</p>
<pre><code> word_dict = dict()
word_dict["foo"] = set()
word_dict["fo... | 11 | 2010-02-18T02:20:45Z | 2,285,881 | <pre><code>from collections import defaultdict
word_dict = defaultdict(set)
word_dict['banana'].add('yellow')
word_dict['banana'].add('brown')
word_dict['apple'].add('red')
word_dict['apple'].add('green')
for key,values in word_dict.iteritems():
print "%s: %s" % (key, values)
</code></pre>
| 20 | 2010-02-18T02:22:52Z | [
"python",
"dictionary",
"set"
] |
Python dictionary that maps strings to a set of strings? | 2,285,874 | <p>I would like to be able to make a Python dictionary with strings as keys and sets of strings as the values. E.g.: <code>{ "crackers" : ["crunchy", "salty"] }</code> It must be a set, not a list.</p>
<p>However, when I try the following:</p>
<pre><code> word_dict = dict()
word_dict["foo"] = set()
word_dict["fo... | 11 | 2010-02-18T02:20:45Z | 2,285,887 | <p><code>set.add()</code> does not return a new <code>set</code>, it modifies the <code>set</code> it is called on. Use it this way:</p>
<pre><code>word_dict = dict()
word_dict["foo"] = set()
word_dict["foo"].add("baz")
word_dict["foo"].add("bang")
</code></pre>
<p>Also, if you use... | 17 | 2010-02-18T02:24:11Z | [
"python",
"dictionary",
"set"
] |
Python dictionary that maps strings to a set of strings? | 2,285,874 | <p>I would like to be able to make a Python dictionary with strings as keys and sets of strings as the values. E.g.: <code>{ "crackers" : ["crunchy", "salty"] }</code> It must be a set, not a list.</p>
<p>However, when I try the following:</p>
<pre><code> word_dict = dict()
word_dict["foo"] = set()
word_dict["fo... | 11 | 2010-02-18T02:20:45Z | 2,285,891 | <p>Try:</p>
<pre><code>word_dict = dict()
myset = set()
myset.add("bar")
word_dict["foo"] = myset
myset.add("bang")
word_dict["foo"] = myset
for key in word_dict:
print key, word_dict[key]
</code></pre>
<p>It looks like standard dictionary iterator returns o... | 1 | 2010-02-18T02:25:07Z | [
"python",
"dictionary",
"set"
] |
Python dictionary that maps strings to a set of strings? | 2,285,874 | <p>I would like to be able to make a Python dictionary with strings as keys and sets of strings as the values. E.g.: <code>{ "crackers" : ["crunchy", "salty"] }</code> It must be a set, not a list.</p>
<p>However, when I try the following:</p>
<pre><code> word_dict = dict()
word_dict["foo"] = set()
word_dict["fo... | 11 | 2010-02-18T02:20:45Z | 2,285,895 | <p>When you say <code>word_dict["foo"].add("baz")</code>, you are adding 'baz' to the set word_dict["foo"].</p>
<p>The function returns <code>None</code> -- updating the set is a side-effect. So </p>
<pre><code>word_dict["foo"] = word_dict["foo"].add("baz")
</code></pre>
<p>ultimately sets <code>word_dict["foo"]</c... | 6 | 2010-02-18T02:26:43Z | [
"python",
"dictionary",
"set"
] |
Python dictionary that maps strings to a set of strings? | 2,285,874 | <p>I would like to be able to make a Python dictionary with strings as keys and sets of strings as the values. E.g.: <code>{ "crackers" : ["crunchy", "salty"] }</code> It must be a set, not a list.</p>
<p>However, when I try the following:</p>
<pre><code> word_dict = dict()
word_dict["foo"] = set()
word_dict["fo... | 11 | 2010-02-18T02:20:45Z | 2,285,899 | <p>The problem is this:</p>
<pre><code>word_dict["foo"] = word_dict["foo"].add("baz")
</code></pre>
<p>When you call <code>word_dict["foo"].add("baz")</code>, you're mutating the set that <code>word_dict["foo"]</code> refers to, and that operation returns <code>None</code>. So reading your statement right to left,... | 1 | 2010-02-18T02:27:55Z | [
"python",
"dictionary",
"set"
] |
detection of communication failure when "put" in queue | 2,285,922 | <p>I am using the <code>multiprocessing</code> python module with <code>Queue</code> for communication between processes. Some processes only send (i.e. <code>queue.put</code>) and I can't seem to find a way to detect when the receiving end gets terminated abruptly.</p>
<p>Is there a way to detect if the process at t... | 1 | 2010-02-18T02:37:24Z | 2,286,094 | <p>I don't believe <code>multiprocessing</code> sets up a "watch-dog" process for you to take care of crashes or kills of some of your processes. It may be worth your while to set one up (pretty hard to do cross-platform, but if, say, you're only worried about Linux, it's not that terrible).</p>
| 0 | 2010-02-18T03:26:01Z | [
"python",
"queue",
"multiprocessing"
] |
how does stackoverflow get the user-info when people login site use openid | 2,285,976 | <p>i want to get the userid and somethins other about user.</p>
<p>but i don't get this </p>
<p>i used pinax </p>
<p>what should i do ??</p>
<p>thanks</p>
<p>ex:facebook</p>
<pre><code>Javascript (from therunaround demo):
FB.Facebook.get_sessionState().waitUntilReady(function() {
var user = FB.Facebo... | 0 | 2010-02-18T02:51:12Z | 2,286,054 | <p>I don't think SO got my (google) userid when I logged on with OpenID based on Google -- if it did, somehow miraculously bypassing the OpenID safeguards (?), it certainly kept this fact very well hidden. What makes you think otherwise?</p>
| 0 | 2010-02-18T03:15:15Z | [
"python",
"django",
"openid"
] |
how does stackoverflow get the user-info when people login site use openid | 2,285,976 | <p>i want to get the userid and somethins other about user.</p>
<p>but i don't get this </p>
<p>i used pinax </p>
<p>what should i do ??</p>
<p>thanks</p>
<p>ex:facebook</p>
<pre><code>Javascript (from therunaround demo):
FB.Facebook.get_sessionState().waitUntilReady(function() {
var user = FB.Facebo... | 0 | 2010-02-18T02:51:12Z | 2,286,082 | <p>You can read about the open-id implementation details on their site, where: <a href="http://openid.net/add-openid/add-getting-started/" rel="nofollow">http://openid.net/add-openid/add-getting-started/</a>.</p>
<p>In a nutshell, you redirect the client to the openid provider who fills out the appropriate information... | 1 | 2010-02-18T03:22:02Z | [
"python",
"django",
"openid"
] |
Endless Recursion in Python | 2,286,019 | <p>Full disclosure, this is part of a homework assignment (though a small snippet, the project itself is a game playing AI).</p>
<p>I have this function built into a tree node class:</p>
<pre><code> def recursive_score_calc(self):
current_score = self.board
for c in self.children:
child... | 2 | 2010-02-18T03:03:56Z | 2,286,028 | <p>It looks like <code>self.children</code> contains <code>self</code>.</p>
<p><strong>EDIT</strong>:</p>
<p>The <code>children</code> property is being initialized to the same array instance for every instance of the <code>TreeNode</code> class.</p>
<p>You need to create a separate array instance for each <code>Tre... | 3 | 2010-02-18T03:06:30Z | [
"python",
"recursion"
] |
Endless Recursion in Python | 2,286,019 | <p>Full disclosure, this is part of a homework assignment (though a small snippet, the project itself is a game playing AI).</p>
<p>I have this function built into a tree node class:</p>
<pre><code> def recursive_score_calc(self):
current_score = self.board
for c in self.children:
child... | 2 | 2010-02-18T03:03:56Z | 2,286,080 | <p>This bit of your code:</p>
<pre><code>class TreeNode:
children = []
</code></pre>
<p>means that <em>every</em> instance of the class shares the same <code>children</code> list. So, in this bit:</p>
<pre><code>def add_child(self, child):
self.children.append(child)
</code></pre>
<p>you're appending to th... | 7 | 2010-02-18T03:21:44Z | [
"python",
"recursion"
] |
The origin of using # as a comment in Python? | 2,286,120 | <p>So I just had like this mental explosion dude! I was looking at my Python source code and was reading some comments and then I looked a the comments again. When I came across this:</p>
<pre><code>#!/usr/bin/env python
# A regular comment
</code></pre>
<p>Which made me wonder, was <code>#</code> chosen as the symbo... | 4 | 2010-02-18T03:32:41Z | 2,286,145 | <p>"All the rest of the line after character X" is clearly the handiest way to do comments if you have an X available (C++ had to use two characters, <code>//</code>, for the purpose, to offer an alternative to C's clunky PL/I-inspired '/<em>' ... '</em>/' "brackets").</p>
<p>Almost all printable Ascii characters can ... | 1 | 2010-02-18T03:39:09Z | [
"python",
"linux",
"shell"
] |
The origin of using # as a comment in Python? | 2,286,120 | <p>So I just had like this mental explosion dude! I was looking at my Python source code and was reading some comments and then I looked a the comments again. When I came across this:</p>
<pre><code>#!/usr/bin/env python
# A regular comment
</code></pre>
<p>Which made me wonder, was <code>#</code> chosen as the symbo... | 4 | 2010-02-18T03:32:41Z | 2,286,146 | <p>Yes.</p>
<p>Using # to start a comment is a convention followed by every major interpreted language designed to work on POSIX systems (i.e. not Windows).</p>
<p>It also dovetails nicely with the fact that the sequence "#!" at the beginning of a file is recognized by the OS to mean "run the command on this line" wh... | 13 | 2010-02-18T03:39:40Z | [
"python",
"linux",
"shell"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.