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 |
|---|---|---|---|---|---|---|---|---|---|
Drag-and-drop to canvas in wxPython | 2,328,008 | <p>Do you know if there is an easy way to drag-and-drop elements (icons or buttons) into a canvas and create different drawings on it as a result?</p>
<p>The idea is to have a set of objects and let the user drag them into a drawing space.</p>
<p>In the worst case the user could just click on the icon/button, and the... | 3 | 2010-02-24T17:23:25Z | 3,971,484 | <p>I assume you are building a browser app? If so, the jQuery UI Droppable plugin provides most of the standard functionality, and is pretty easy to modify to fit custom needs. Here's the link: <a href="http://jqueryui.com/demos/droppable/" rel="nofollow">http://jqueryui.com/demos/droppable/</a></p>
| 2 | 2010-10-19T18:31:42Z | [
"python",
"drag-and-drop",
"wxpython",
"canvas"
] |
Python OOP - Class relationships | 2,328,094 | <p>Assuming I have a system of three Classes.
The <code>GameClass</code> creates instances of both other classes upon initialization.</p>
<pre><code>class FieldClass:
def __init__( self ):
return
def AnswerAQuestion( self ):
return 42
class PlayerClass:
def __init__( self ):
re... | 4 | 2010-02-24T17:35:30Z | 2,328,146 | <p>I would go with <a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow">Dependency Injection</a>: instantiate a <code>GameClass</code> with the required <code>FieldClass</code> and <code>PlayerClass</code> in the constructor call etc. (i.e. instead of creating the dependent objects from within <c... | 4 | 2010-02-24T17:41:42Z | [
"python",
"oop"
] |
Python OOP - Class relationships | 2,328,094 | <p>Assuming I have a system of three Classes.
The <code>GameClass</code> creates instances of both other classes upon initialization.</p>
<pre><code>class FieldClass:
def __init__( self ):
return
def AnswerAQuestion( self ):
return 42
class PlayerClass:
def __init__( self ):
re... | 4 | 2010-02-24T17:35:30Z | 2,328,180 | <p>To better understand your class relationships you have to tell us more about your project and what you are trying to accomplish. </p>
<p>One way to reference the <em>instance</em> of <code>FieldClass</code> from <code>PlayerClass</code> in your example is to pass the <code>GameClass</code> instance to the <code>Pla... | 4 | 2010-02-24T17:44:54Z | [
"python",
"oop"
] |
Python OOP - Class relationships | 2,328,094 | <p>Assuming I have a system of three Classes.
The <code>GameClass</code> creates instances of both other classes upon initialization.</p>
<pre><code>class FieldClass:
def __init__( self ):
return
def AnswerAQuestion( self ):
return 42
class PlayerClass:
def __init__( self ):
re... | 4 | 2010-02-24T17:35:30Z | 2,328,188 | <p>I would do something like the following, where you pass Game in as a back-reference, allowing you access to the other associated classes. In this way, you could optionally give that player instance a direct relationship to the field.</p>
<pre><code>class FieldClass(object):
def __init__(self, game):
se... | 0 | 2010-02-24T17:46:11Z | [
"python",
"oop"
] |
Python OOP - Class relationships | 2,328,094 | <p>Assuming I have a system of three Classes.
The <code>GameClass</code> creates instances of both other classes upon initialization.</p>
<pre><code>class FieldClass:
def __init__( self ):
return
def AnswerAQuestion( self ):
return 42
class PlayerClass:
def __init__( self ):
re... | 4 | 2010-02-24T17:35:30Z | 2,328,199 | <p>You could provide the context to the child objects, i.e.:</p>
<pre><code>class FieldClass:
def __init__(self,game):
self.game = game
class PlayerClass:
def __init__(self,game):
self.game = game
def DoMagicHere(self):
self.game.Field.AnswerAQuestion()
class GameClass:
def __init__(self):
sel... | 1 | 2010-02-24T17:47:42Z | [
"python",
"oop"
] |
Avoiding unnecessary slice copying in Python | 2,328,171 | <p>Is there a common idiom for avoiding pointless slice copying for cases like this:</p>
<pre><code>>>> a = bytearray(b'hello')
>>> b = bytearray(b'goodbye, cruel world.')
>>> a.extend(b[14:20])
>>> a
bytearray(b'hello world')
</code></pre>
<p>It seems to me that there is an unnece... | 5 | 2010-02-24T17:44:16Z | 2,328,175 | <p>Creating a <code>buffer</code> object avoids copying the slice, but for short slices it's more efficient to just make the copy:</p>
<pre><code>>>> a.extend(buffer(b, 14, 6))
>>> a
bytearray(b'hello world')
</code></pre>
<p>Here there's only one copy made of the memory, but the cost of creating th... | 5 | 2010-02-24T17:44:35Z | [
"python",
"optimization",
"idioms"
] |
Avoiding unnecessary slice copying in Python | 2,328,171 | <p>Is there a common idiom for avoiding pointless slice copying for cases like this:</p>
<pre><code>>>> a = bytearray(b'hello')
>>> b = bytearray(b'goodbye, cruel world.')
>>> a.extend(b[14:20])
>>> a
bytearray(b'hello world')
</code></pre>
<p>It seems to me that there is an unnece... | 5 | 2010-02-24T17:44:16Z | 2,329,402 | <p><code>itertools</code> has <code>islice</code>. islice doesn't have a count method so it is useful in other cases where you wish to avoid copying the slice. As you pointed out - count has a mechanism for that anyway</p>
<pre><code>>>> from itertools import islice
>>> a = bytearray(1000000)
>>... | 2 | 2010-02-24T20:49:08Z | [
"python",
"optimization",
"idioms"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 2,373,353 | <p>A possible cause is <a href="http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#lazy-translation" rel="nofollow">Lazy Translation</a>.</p>
<p>In example, in views.py you should use <strong>ugettext</strong>:</p>
<pre><code>from django.utils.translation import ugettext as _
</code></pre>
<p>But... | 3 | 2010-03-03T17:11:10Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 2,381,694 | <p>Maybe the translated strings are marked as <code>fuzzy</code>?</p>
| 12 | 2010-03-04T18:23:50Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 4,087,770 | <p>Hi just attach some fixes I had to do in the past:</p>
<ul>
<li>Restart the webserver!</li>
</ul>
<p>In the setting file
- <code>USE_I18N = True</code> is needed</p>
<ul>
<li><p>django.middleware.locale.LocaleMiddleware among middleware modules (but this is not your case for sure as long as Django will not care a... | 3 | 2010-11-03T13:59:41Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 17,742,639 | <p>Another cause can be a wrong directory structure.</p>
<p>Read well the manage command's error message about which directory to create before running the <code>makemassages</code> command for the <em>app</em> translation. (It must be <code>locale</code> for an app, <em>not</em> <code>conf/locale</code>.) Note that t... | 0 | 2013-07-19T09:29:40Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 18,593,863 | <p>I noticed that when I had <code>%</code> in my text, the translated text was not being used. There may be other characters that can cause this problem. I fixed the problem by escaping the <code>%</code> as <code>%%</code>.</p>
| 0 | 2013-09-03T13:40:53Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 19,865,528 | <p>Just got hit by one. I had the <code>locale/</code> directory in the root of my project, but by default <a href="https://docs.djangoproject.com/en/1.6/topics/i18n/translation/#how-django-discovers-translations" rel="nofollow">Django looks for translations</a> in the <code>INSTALLED_APPS</code> directories, and in t... | 7 | 2013-11-08T17:56:18Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
Django i18n: Common causes for translations not appearing | 2,328,185 | <p>I am making a multilingual Django website. I created a messages file, populated and compiled it. I checked the site (the admin in this case,) in my wanted language (Hebrew) and most phrases appear in Hebrew like they should, but some don't. I checked the source and these still appear as <code>_('Whatever')</code> li... | 11 | 2010-02-24T17:45:12Z | 31,889,066 | <p>I was having this problem with my project right now. I had the variable LANGUAGES on settings.py set this way:</p>
<pre><code>LANGUAGES = (
('en', _('English')),
('pt-br', _('Brazilian Portuguese')),
)
</code></pre>
<p>And a folder structure with a locale folder, and a subfolder pt-br inside. Turns out that my tra... | 1 | 2015-08-08T02:35:35Z | [
"python",
"django",
"translation",
"gettext",
"django-multilingual"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,250 | <p>My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application. So, if Java would take you two weeks, then Python may take about 6. </p>
| 5 | 2010-02-24T17:57:54Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,275 | <p>Python is like baby java, you'll pick it up in a breeze.</p>
| 3 | 2010-02-24T18:00:15Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,292 | <p>It always take longer than you think. </p>
<p>Try writing a small program doing just a bit of what you need. If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.</p>
| 4 | 2010-02-24T18:03:23Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,316 | <p>Are you just programming or are you designing/architecting? <br></p>
<p>If you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project.</p>
<p>If you are designing/architecting this your... | 0 | 2010-02-24T18:05:53Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,330 | <p>Well I would say how fast you pick up Python also depends on what other languages you know(or comfortable) apart from Java. If the only language you know is Java then I don't think the switch from Java to Python would be intuitive or smooth. To start with Java is statically typed and Python is dynamically typed, and... | 2 | 2010-02-24T18:07:47Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,346 | <p>I think it depends on the area of the project. While GUI is not hard in Python, any kind of GUI-framework will have a somewhat steep learning curve.
If it is a webapp, I'd say go for Python. The added time for learning is quickly gained back by easy of use of the many Python webframeworks.</p>
<p>The big risk is th... | 8 | 2010-02-24T18:10:08Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,364 | <p>You have roughly 5 weeks to complete the project. If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up. I say go for it. Python is relatively easy to pick up. I think three weeks of work is enough to time to know whether yo... | 7 | 2010-02-24T18:13:01Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,426 | <p>If you Google for "Pythonic", you'll find a lot of discussion about how to do things in ways that fit well in Python, will be easy to understand by other Python users, and so on. It always takes a while to progress from code that simply works in a language to using that language well -- and in the case of Python, th... | 2 | 2010-02-24T18:24:26Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,430 | <p>I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Onc... | 1 | 2010-02-24T18:24:46Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,518 | <p>Generally, if I'm not familiar with a language, I allow at least a month to get somewhat comfortable with it. Two or three months if it's outside my "comfort zone" of C-like languages. Having said that, I think Java and Python are similar enough that you might trim that a bit.</p>
<p>Also, based on your own histo... | 1 | 2010-02-24T18:35:54Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 2,328,658 | <p>Charlie, being a new hire and all, you shouldn't really decide on which technology to code the project. This is a management decision. </p>
<p>In fact, even though team skill can be used to determine the technology of choice for one or other project, there are many other, more important, things to take into account... | 0 | 2010-02-24T18:54:50Z | [
"java",
"python"
] |
How much leeway do I have to leave myself to learn a new language? | 2,328,230 | <p>I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? </p>
<p>Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, ... | 13 | 2010-02-24T17:53:26Z | 3,258,221 | <p>My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects. So if it was me, I'd do the project in Java, and do a few little Python projects at home.</p>
<p>But of course, you learn a lot more a lot faster when you are using a new language "fo... | 0 | 2010-07-15T17:29:35Z | [
"java",
"python"
] |
Python:Extend the 'dict' class | 2,328,235 | <p>I have to solve this exercise:</p>
<blockquote>
<p>Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the order must be preserved also when new elements... | 17 | 2010-02-24T17:55:17Z | 2,328,259 | <p>The implementation of dict will not help you with the task. What you want is a class that has the same interface as <code>dict</code>, but a different implementation. <a href="http://docs.python.org/reference/datamodel.html#emulating-container-types">That will require to implement methods like <code>__getitem__</cod... | 9 | 2010-02-24T17:58:48Z | [
"python",
"extend",
"dictionary"
] |
Python:Extend the 'dict' class | 2,328,235 | <p>I have to solve this exercise:</p>
<blockquote>
<p>Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the order must be preserved also when new elements... | 17 | 2010-02-24T17:55:17Z | 2,328,266 | <p>If you use python 2.7+, then see <a href="http://docs.python.org/dev/library/collections.html#collections.OrderedDict" rel="nofollow">collections.OrderedDict</a>.<br>
Otherwise, backport (copy the source) or see <a href="http://code.activestate.com/recipes/576693/" rel="nofollow">Recipe 576693: Ordered Dictionary fo... | 5 | 2010-02-24T17:59:19Z | [
"python",
"extend",
"dictionary"
] |
Python:Extend the 'dict' class | 2,328,235 | <p>I have to solve this exercise:</p>
<blockquote>
<p>Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the order must be preserved also when new elements... | 17 | 2010-02-24T17:55:17Z | 2,328,500 | <p>Good news: the problem is not difficult at all.</p>
<p>In order to poke around and see the entrails of a <code>class</code> you can use </p>
<pre><code>>>> dir(dict)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__g... | 4 | 2010-02-24T18:34:00Z | [
"python",
"extend",
"dictionary"
] |
Python:Extend the 'dict' class | 2,328,235 | <p>I have to solve this exercise:</p>
<blockquote>
<p>Python's dictionaries do not preserve the order of inserted data nor store the data sorted by the key. Write an extension for the dict class whose instances will keep the data sorted by their key value. Note that the order must be preserved also when new elements... | 17 | 2010-02-24T17:55:17Z | 2,329,727 | <p>You can either subclass <code>dict</code> or <code>UserDict</code>, since van already talked about UserDict, lets look at <code>dict</code>.</p>
<p>Type <code>help(dict)</code> into an interpreter and you see a big list of methods. You will need to override all the methods that modify the dict as well as the method... | 17 | 2010-02-24T21:34:46Z | [
"python",
"extend",
"dictionary"
] |
Turn SSLchecking off in M2Crypto in Python | 2,328,265 | <p>Is there a way to turn off SSL checking so that WrongHost Exceptions are not generated when using SOAPpy in python.</p>
| 1 | 2010-02-24T17:59:13Z | 2,328,444 | <p>You can disable all peer certificate checks in M2Crypto like that:</p>
<pre><code>from M2Crypto import SSL, httpslib
context = SSL.Context("sslv3")
# Disable certificate checking
context.set_verify(0, depth = 0)
connection = httpslib.HTTPSConnection("somehostname", 443, ssl_context=context)
# Hack (!!!) for dis... | 5 | 2010-02-24T18:26:12Z | [
"python",
"ssl",
"soappy"
] |
Turn SSLchecking off in M2Crypto in Python | 2,328,265 | <p>Is there a way to turn off SSL checking so that WrongHost Exceptions are not generated when using SOAPpy in python.</p>
| 1 | 2010-02-24T17:59:13Z | 6,474,009 | <p>Expanding on AndiDog's answer, you can set postConnectionCheck on a instance-by-instance basis and in version 0.21.1 (at least) of M2Crypto, there is the <code>Connect.set_post_connection_check_callback()</code> method to do so:</p>
<pre><code>sslsock = M2Crypto.SSL.Connection(sslcontext)
# Disable checking of serv... | 0 | 2011-06-24T21:35:48Z | [
"python",
"ssl",
"soappy"
] |
unladen-swallow with numpy/scipy | 2,328,267 | <p>has anyone used unladen-swallow with numpy/scipy for numeric/scientific applications? Is it significantly faster in your experience? Any opinions would be great.</p>
| 7 | 2010-02-24T17:59:19Z | 2,330,249 | <p>It should be faster. I have not tested it myself, but i just got back from pycon and they had a talk about unladen-swallow in which they mentioned the performance increase with numpy and other packages. You can watch the talk <a href="http://pycon.blip.tv/file/3261170/#" rel="nofollow">here</a>.</p>
| 1 | 2010-02-24T22:47:17Z | [
"python",
"optimization",
"numpy",
"scipy",
"unladen-swallow"
] |
unladen-swallow with numpy/scipy | 2,328,267 | <p>has anyone used unladen-swallow with numpy/scipy for numeric/scientific applications? Is it significantly faster in your experience? Any opinions would be great.</p>
| 7 | 2010-02-24T17:59:19Z | 2,338,033 | <p>Nobody has extensive experience with Unladen Swallow yet (except the developers), so it's going to be difficult to find many people who can discuss it. Also, with the talk of merging Unladen Swallow (which is built using <a href="http://llvm.org/">LLVM</a>) with the CPython runtime, things are going to be something... | 5 | 2010-02-25T22:07:19Z | [
"python",
"optimization",
"numpy",
"scipy",
"unladen-swallow"
] |
unladen-swallow with numpy/scipy | 2,328,267 | <p>has anyone used unladen-swallow with numpy/scipy for numeric/scientific applications? Is it significantly faster in your experience? Any opinions would be great.</p>
| 7 | 2010-02-24T17:59:19Z | 2,341,312 | <p>On the question, not an answer: </p>
<pre><code>Total runtime = python + numpy + interface,
cpython/unladenswallow + mostlyC + interface.
</code></pre>
<p>Without real data on how these 3 split -- 20 70 10, 40 40 20 ? and that for > 1 benchmark,<br>
there's no way of telling which way is up.</p>... | 1 | 2010-02-26T11:47:49Z | [
"python",
"optimization",
"numpy",
"scipy",
"unladen-swallow"
] |
Change the type of a global variable in a function initializing it | 2,328,464 | <p>I have a <code>__main__</code> function where I initialize a lot of variables that are to be used in my program, later on. I have a problem where a variable that I temporarely declare as None in the outer scope, is assigned an object of SomeClass, but due to scoping rules I cannot access it's content in the outer sc... | 0 | 2010-02-24T18:28:56Z | 2,328,630 | <p>Assuming that <code>setup()</code> is meant to be <code>initialize()</code>, the problem is that the variable <code>myObject</code> in <code>initialize()</code> is a local variable that hides the global <code>myObject</code>, and when <code>initialize()</code> returns, the local name will go out of scope.</p>
<p>To... | 2 | 2010-02-24T18:51:11Z | [
"python",
"class",
"scope",
"global-variables"
] |
Change the type of a global variable in a function initializing it | 2,328,464 | <p>I have a <code>__main__</code> function where I initialize a lot of variables that are to be used in my program, later on. I have a problem where a variable that I temporarely declare as None in the outer scope, is assigned an object of SomeClass, but due to scoping rules I cannot access it's content in the outer sc... | 0 | 2010-02-24T18:28:56Z | 2,328,656 | <p>If your <code>SomeClass</code> requires an argument from the execution of the script, it would probably be easiest to just pass in whatever information you need to construct an instance of it as an argument. It might look something like:</p>
<pre><code>def initialize(args):
... lots of initialization ...
m... | 0 | 2010-02-24T18:54:43Z | [
"python",
"class",
"scope",
"global-variables"
] |
Change the type of a global variable in a function initializing it | 2,328,464 | <p>I have a <code>__main__</code> function where I initialize a lot of variables that are to be used in my program, later on. I have a problem where a variable that I temporarely declare as None in the outer scope, is assigned an object of SomeClass, but due to scoping rules I cannot access it's content in the outer sc... | 0 | 2010-02-24T18:28:56Z | 2,329,076 | <p>You don't have to do it that - using globals is considered bad practice for most uses. You can always return the data you want:</p>
<pre><code>def initialize():
... lots of initialization ...
return foo.bar.SomeClass(init_variable)
if __name__ == "__main__":
myObject = initialize()
myObject.member1... | 2 | 2010-02-24T20:04:13Z | [
"python",
"class",
"scope",
"global-variables"
] |
Perform a SQL JOIN on Django models that are not related? | 2,328,493 | <p>I have 2 Models, User (django.contrib.auth.models.User) and a model named Log. Both contain an "email" field. Log does not have a ForeignKey pointing to the User model. I'm trying to figure out how I can perform a JOIN on these two tables using the email field as the commonality.</p>
<p>There are basically 2 que... | 2 | 2010-02-24T18:32:58Z | 2,328,707 | <p>why not use <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none" rel="nofollow">extra()</a>?</p>
<p>example (untested):</p>
<pre><code>User.objects.extra(
select={
'log_count': 'SELECT COUNT(*) FROM my... | 2 | 2010-02-24T19:05:41Z | [
"python",
"django",
"orm"
] |
Perform a SQL JOIN on Django models that are not related? | 2,328,493 | <p>I have 2 Models, User (django.contrib.auth.models.User) and a model named Log. Both contain an "email" field. Log does not have a ForeignKey pointing to the User model. I'm trying to figure out how I can perform a JOIN on these two tables using the email field as the commonality.</p>
<p>There are basically 2 que... | 2 | 2010-02-24T18:32:58Z | 2,329,146 | <p>Do the Log.email values always correspond to a User? If so, how about just adding a ForeignKey(User) to the Log object?</p>
<pre><code>class Log(models.Model):
# ...
user = models.ForeignKey(User)
</code></pre>
<p>With the FK to User, it becomes fairly straight forward to find what you want:</p>
<pre><co... | 0 | 2010-02-24T20:15:00Z | [
"python",
"django",
"orm"
] |
Perform a SQL JOIN on Django models that are not related? | 2,328,493 | <p>I have 2 Models, User (django.contrib.auth.models.User) and a model named Log. Both contain an "email" field. Log does not have a ForeignKey pointing to the User model. I'm trying to figure out how I can perform a JOIN on these two tables using the email field as the commonality.</p>
<p>There are basically 2 que... | 2 | 2010-02-24T18:32:58Z | 2,332,902 | <p>You can add an extra method onto the User class, using MonkeyPatching/DuckPunching:</p>
<pre><code>def logs(user):
return Log.objects.filter(email=user.email)
from django.contrib.auth.models import User
User.logs = property(logs)
</code></pre>
<p>Now, you can query a User, and ask for the logs attached (for i... | 2 | 2010-02-25T09:25:44Z | [
"python",
"django",
"orm"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,328,590 | <p>Since <code>quickCheck</code> is being called close to 25,000,000 times, you might want to use memoization to cache the answers.</p>
<p>You can do memoization in C as well as Python. Things will be much faster in C, also.</p>
<p>You're computing <code>1/6</code> in each iteration of quickCheck. I'm not sure if t... | 16 | 2010-02-24T18:45:23Z | [
"python",
"optimization",
"math",
"performance"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,328,609 | <p>The other respondents have already mentioned several optimizations that will help. However, ultimately, you're not going to be able to match the performance of C in Python. Python is a nice tool, but since it's interpreted, it isn't really suited for heavy number crunching or other apps where performance is key.</p>... | 2 | 2010-02-24T18:47:54Z | [
"python",
"optimization",
"math",
"performance"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,328,663 | <p>20x difference between Python and C for a number crunching task seems quite good to me.</p>
<p>Check the usual <a href="http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python&lang2=gcc" rel="nofollow">performance differences</a> for some CPU intensive tasks (keep in mind that the scale is... | 1 | 2010-02-24T18:56:37Z | [
"python",
"optimization",
"math",
"performance"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,328,766 | <p>There are some python compilers that might actually do a good bit for you. Have a look at <a href="http://psyco.sourceforge.net/doc.html" rel="nofollow">Psyco</a>.</p>
<p>Another way of dealing with math intensive programs is to rewrite the majority of the work into a math kernel, such as <a href="http://numpy.sci... | 4 | 2010-02-24T19:15:43Z | [
"python",
"optimization",
"math",
"performance"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,328,859 | <p>I made it go from ~7 seconds to ~3 seconds on my machine:</p>
<ul>
<li>Precomputed <code>i * (3 * i - 1 ) / 2</code> for each value, in yours it was computed twice quite a lot</li>
<li>Cached calls to quickCheck</li>
<li>Removed <code>if i == g</code> by adding +1 to the range</li>
<li>Removed <code>if p_i > p_g... | 9 | 2010-02-24T19:29:50Z | [
"python",
"optimization",
"math",
"performance"
] |
Python code optimization (20x slower than C) | 2,328,495 | <p>I've written this very badly optimized C code that does a simple math calculation:</p>
<pre><code>#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(... | 4 | 2010-02-24T18:33:02Z | 2,337,084 | <p>Because the function p() monotonically increasing you can avoid comparing the values as <em>g > i</em> implies <em>p(g) > p(i)</em>. Also, the inner loop can be broken early because <em>p(g) - p(i) >= diff</em> implies <em>p(g+1) - p(i) >= diff</em>.</p>
<p>Also for correctness, I changed the equality comparison in... | 5 | 2010-02-25T19:45:30Z | [
"python",
"optimization",
"math",
"performance"
] |
Any potential gotchas or things to be aware of for a newcomer to Django? | 2,328,767 | <p>In other words, what did you not know when you started with Django that you wish someone had told you?</p>
<p>I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go.</p>
| 2 | 2010-02-24T19:15:49Z | 2,328,793 | <p>You can't process data in templates. There are a fair number of questions in SO from people trying to do "real" processing in the templates. The Django template language is -- intentionally -- not JSP or ASP or PHP. It just does presentation and retrieval of values computed in view functions.</p>
<p>If you can't... | 4 | 2010-02-24T19:21:34Z | [
"python",
"django"
] |
Any potential gotchas or things to be aware of for a newcomer to Django? | 2,328,767 | <p>In other words, what did you not know when you started with Django that you wish someone had told you?</p>
<p>I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go.</p>
| 2 | 2010-02-24T19:15:49Z | 2,328,803 | <p>Use forms for <em>all</em> data validation. Bulk loading, batch processing, web services, everything. </p>
<p>At first, it seems odd to read a CSV file, populate a Form, and then have the Form validate the data and build the database object. But that's the way it's supposed to work. Use the Forms for all valida... | 4 | 2010-02-24T19:23:24Z | [
"python",
"django"
] |
Any potential gotchas or things to be aware of for a newcomer to Django? | 2,328,767 | <p>In other words, what did you not know when you started with Django that you wish someone had told you?</p>
<p>I've dabbled some in Django but nothing really serious. However, I'm hoping to change that, and I'm wondering if there's any gotchas/shortcomings/whatever that I need to be aware of as I go.</p>
| 2 | 2010-02-24T19:15:49Z | 2,328,812 | <p>Be aware of specifying absolute paths in your <code>settings.py</code> file. Django doesn't come with an out-of-the-box solution for making everything relative, and you have to employ Python's utilities. The usual solution is something like:</p>
<pre><code>import os
def abspath(file):
return os.path.join(os.pat... | 6 | 2010-02-24T19:24:21Z | [
"python",
"django"
] |
Transforming nested Python loops into list comprehensions | 2,329,165 | <p>I've started working on some Project Euler problems, and have solved <a href="http://projecteuler.net/index.php?section=problems&id=4" rel="nofollow">number 4</a> with a simple brute force solution:</p>
<pre><code>def mprods(a,b):
c = range(a,b)
f = []
for d in c:
for e in c:
f.append(d*e)
return f
ma... | 3 | 2010-02-24T20:17:30Z | 2,329,193 | <pre><code>c = range(a, b)
print [d * e for d in c for e in c]
</code></pre>
| 7 | 2010-02-24T20:21:17Z | [
"python",
"list-comprehension"
] |
Transforming nested Python loops into list comprehensions | 2,329,165 | <p>I've started working on some Project Euler problems, and have solved <a href="http://projecteuler.net/index.php?section=problems&id=4" rel="nofollow">number 4</a> with a simple brute force solution:</p>
<pre><code>def mprods(a,b):
c = range(a,b)
f = []
for d in c:
for e in c:
f.append(d*e)
return f
ma... | 3 | 2010-02-24T20:17:30Z | 2,329,245 | <p>I think you'll like this one-liner (formatted for readability):</p>
<pre><code>max(z for z in (d*e
for d in xrange(100, 1000)
for e in xrange(100, 1000))
if str(z) == str(z)[::-1])
</code></pre>
<p>Or slightly changed:</p>
<pre><code>c = range(100, 1000)
max(z for z in ... | 2 | 2010-02-24T20:28:54Z | [
"python",
"list-comprehension"
] |
Transforming nested Python loops into list comprehensions | 2,329,165 | <p>I've started working on some Project Euler problems, and have solved <a href="http://projecteuler.net/index.php?section=problems&id=4" rel="nofollow">number 4</a> with a simple brute force solution:</p>
<pre><code>def mprods(a,b):
c = range(a,b)
f = []
for d in c:
for e in c:
f.append(d*e)
return f
ma... | 3 | 2010-02-24T20:17:30Z | 2,334,372 | <pre><code>from itertools import product
def palindrome(i):
return str(i) == str(i)[::-1]
x = xrange(900,1000)
max(a*b for (a,b) in (product(x,x)) if palindrome(a*b))
</code></pre>
<ul>
<li><p><code>xrange(900,1000)</code> is like <code>range(900,1000)</code> but instead of returning a list it returns an object t... | 3 | 2010-02-25T13:51:02Z | [
"python",
"list-comprehension"
] |
Referenced Model Loading in Google App Engine | 2,329,387 | <p>In Python, say I've got a model of class <code>A</code> that has a ReferenceProperty <code>b</code> to model class <code>B</code>, which has a ReferenceProperty <code>c</code> to model class <code>C</code>.</p>
<p>Assuming an instance of <code>A</code> already exists in the datastore, I can get it by saying:</p>
<... | 1 | 2010-02-24T20:47:56Z | 2,329,439 | <p>ReferenceProperties are lazily-loaded. <strong>b</strong> will not be looked up from the datastore until you actually use it for something.</p>
| 1 | 2010-02-24T20:55:06Z | [
"python",
"google-app-engine",
"model",
"memcached",
"loading"
] |
Referenced Model Loading in Google App Engine | 2,329,387 | <p>In Python, say I've got a model of class <code>A</code> that has a ReferenceProperty <code>b</code> to model class <code>B</code>, which has a ReferenceProperty <code>c</code> to model class <code>C</code>.</p>
<p>Assuming an instance of <code>A</code> already exists in the datastore, I can get it by saying:</p>
<... | 1 | 2010-02-24T20:47:56Z | 2,329,447 | <p>The models will be dereferenced when you first access them. So calling a.b will get b, and calling a.b.c will get c.</p>
<p>Have a look at Nick Johnson's blog for some tips about memcahing models:
<a href="http://blog.notdot.net/2009/9/Efficient-model-memcaching" rel="nofollow">http://blog.notdot.net/2009/9/Effici... | 2 | 2010-02-24T20:56:25Z | [
"python",
"google-app-engine",
"model",
"memcached",
"loading"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,329,459 | <p>As far as I know, you can't just open a txt file with python and remove a line. You have to make a new file and move everything but that line to it. If you know the specific line, then you would do something like this:</p>
<pre><code>f = open('in.txt')
fo = open('out.txt','w')
ind = 1
for line in f:
if ind != ... | 1 | 2010-02-24T20:58:15Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,329,515 | <p>If the lines are variable length then I don't believe that there is a better algorithm than reading the file line by line and writing out all lines, except for the one(s) that you do not want.</p>
<p>You can identify these lines by checking some criteria, or by keeping a running tally of lines read and suppressing ... | 1 | 2010-02-24T21:05:47Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,329,604 | <p>Update: solution using sed as requested by poster in comment.</p>
<p>To delete for example the second line of file:</p>
<pre><code>sed '2d' input.txt
</code></pre>
<p>Use the <code>-i</code> switch to edit in place. Warning: this is a destructive operation. Read the help for this command for information on how to... | 1 | 2010-02-24T21:17:03Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,329,972 | <p>You can have two file objects for the same file at the same time (one for reading, one for writing):</p>
<pre><code>def removeLine(filename, lineno):
fro = open(filename, "rb")
current_line = 0
while current_line < lineno:
fro.readline()
current_line += 1
seekpoint = fro.tell()
... | 10 | 2010-02-24T22:05:34Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,330,081 | <p>Modify the file <strong>in place</strong>, offending line is replaced with spaces so the remainder of the file does not need to be shuffled around on disk. You can also "<em>fix</em>" the line in place if the fix is not longer than the line you are replacing</p>
<pre><code>import os
from mmap import mmap
def remove... | 7 | 2010-02-24T22:22:11Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,330,179 | <pre><code>def removeLine(filename, lineno):
in = open(filename)
out = open(filename + ".new", "w")
for i, l in enumerate(in, 1):
if i != lineno:
out.write(l)
in.close()
out.close()
os.rename(filename + ".new", filename)
</code></pre>
| 0 | 2010-02-24T22:36:46Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,330,250 | <p>I think there was a somewhat similar if not exactly the same type of question asked here. Reading (and writing) line by line is slow, but you can read a bigger chunk into memory at once, go through that line by line skipping lines you don't want, then writing this as a single chunk to a new file. Repeat until done. ... | 0 | 2010-02-24T22:47:29Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 2,330,888 | <p>@OP, if you can use awk, eg assuming line number is 10</p>
<pre><code>$ awk 'NR!=10' file > newfile
</code></pre>
| 0 | 2010-02-25T01:09:30Z | [
"python",
"optimization"
] |
Fastest Way to Delete a Line from Large File in Python | 2,329,417 | <p>I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...</p>
<p>Eventually once I'm comfortable with the process, I'll automate... | 20 | 2010-02-24T20:51:01Z | 20,372,792 | <p>I will provide two alternatives based on the look-up factor (line number or a search string):</p>
<h3>Line number</h3>
<pre><code>def removeLine2(filename, lineNumber):
with open(filename, 'r+') as outputFile:
with open(filename, 'r') as inputFile:
currentLineNumber = 0
while ... | 0 | 2013-12-04T10:27:21Z | [
"python",
"optimization"
] |
how do you specify which python executable to use in Django 1.1.1? | 2,329,541 | <p>I have a RH system running RHEL 5.3, which comes with python2.4 that can't be removed for numerous reasons. </p>
<p>I have been able to build 64-bit RPMS for python 2.6 as an altinstall. It's called with "python26".</p>
<p>How can I tell Django to use this command to get to the proper python version, instead of ... | 0 | 2010-02-24T21:09:32Z | 2,329,700 | <p>Look at <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow">virtualenv</a>, you can setup your own environment for django (well, anything) with different lib versions, symlinks etc.</p>
| 2 | 2010-02-24T21:30:16Z | [
"python",
"django"
] |
how do you specify which python executable to use in Django 1.1.1? | 2,329,541 | <p>I have a RH system running RHEL 5.3, which comes with python2.4 that can't be removed for numerous reasons. </p>
<p>I have been able to build 64-bit RPMS for python 2.6 as an altinstall. It's called with "python26".</p>
<p>How can I tell Django to use this command to get to the proper python version, instead of ... | 0 | 2010-02-24T21:09:32Z | 2,329,713 | <p>That depends on the deploying method you use. E.g., if you use the <a href="http://docs.djangoproject.com/en/1.1/howto/deployment/modwsgi/" rel="nofollow">django-recommended</a> <a href="http://code.google.com/p/modwsgi/" rel="nofollow">mod_wsgi</a> deployment, then you must <a href="http://code.google.com/p/modwsgi... | 2 | 2010-02-24T21:31:52Z | [
"python",
"django"
] |
Client polling (reverse AJAX) for chat requests in Django? | 2,329,627 | <p>I want to make it that one user on the site can chat request another user on my Django site. I want the requestee to get a realtime box that say: "Do you want to chat?"</p>
<p>How does the following client polling approach sound:</p>
<p>user1 clicks on users2 nickname, generating a POST request to some /message/re... | 0 | 2010-02-24T21:20:03Z | 2,329,704 | <p>A database table for this would put a load on your server, as you said, but might be useful if you want to keep a record of these requests for whatever reason.</p>
<p>Using something like memcached or an AMQP server might give you better performance. If you like you could even use a higher-performance key-value-sto... | 2 | 2010-02-24T21:30:44Z | [
"python",
"ajax",
"django",
"session",
"reverse-ajax"
] |
Client polling (reverse AJAX) for chat requests in Django? | 2,329,627 | <p>I want to make it that one user on the site can chat request another user on my Django site. I want the requestee to get a realtime box that say: "Do you want to chat?"</p>
<p>How does the following client polling approach sound:</p>
<p>user1 clicks on users2 nickname, generating a POST request to some /message/re... | 0 | 2010-02-24T21:20:03Z | 6,986,436 | <p>I suggest you look for a "COMET like" communication instead of "AJAX like" if you worry about server performance and bandwidth usage.</p>
<p>By the way, <a href="http://redis.io/" rel="nofollow">REDIS</a> looks very well suited for handling that kind of in-memory data structures.</p>
| 0 | 2011-08-08T18:01:46Z | [
"python",
"ajax",
"django",
"session",
"reverse-ajax"
] |
Dealing with BACKSLASH character in non-string literals in Python | 2,329,719 | <p>I have the following string read from an XML elememnt, and it is assigned to a variable called filename. <em>I don't know how to make this any clearer as saying filename = the following string, without leading someone to think that I have a string literal then.</em></p>
<pre><code>\\server\data\uploads\0224.1307.Va... | 0 | 2010-02-24T21:32:54Z | 2,329,753 | <p>We need more information. What exactly is in the variable filename? To answer, use <code>print repr(filename)</code> and add the results to your question above.</p>
<hr>
<p><strong>Wild guess</strong></p>
<p>DISCLAIMER: This is a guess - try:</p>
<pre><code>import ntpath
print ntpath.basename(filename)
</code></... | 2 | 2010-02-24T21:39:02Z | [
"python",
"string",
"encoding",
"escaping"
] |
Dealing with BACKSLASH character in non-string literals in Python | 2,329,719 | <p>I have the following string read from an XML elememnt, and it is assigned to a variable called filename. <em>I don't know how to make this any clearer as saying filename = the following string, without leading someone to think that I have a string literal then.</em></p>
<pre><code>\\server\data\uploads\0224.1307.Va... | 0 | 2010-02-24T21:32:54Z | 2,329,826 | <p>All the downvoting in the world won't change the fact that <strong>you're doing it wrong</strong>. <code>os.path</code> is for native paths. <code>\\foo\bar\baz</code> is not a OS X path, it's a Windows UNC. <code>posixpath</code> is not equipped to handle UNCs; <code>ntpath</code> is.</p>
| 1 | 2010-02-24T21:47:45Z | [
"python",
"string",
"encoding",
"escaping"
] |
libxml2 install error: command 'gcc' failed with exit status 1? What are the dependencies of libxml2? | 2,330,062 | <p>I am trying to install libxml2 on unbuntu 9.10 and getting errors:</p>
<p>$ sudo python setup.py develop
Its a very lengthy error message but the last error is</p>
<p><strong>Setup script exited with error: Command 'gcc' failed with exit status 1.</strong></p>
<p>Can anybody tell me why i am getting this error?</... | 0 | 2010-02-24T22:19:58Z | 2,330,104 | <p>What is wrong with</p>
<pre><code>$ sudo apt-get install libxml2-dev
</code></pre>
<p>or the graphical equivalents?</p>
| 1 | 2010-02-24T22:25:44Z | [
"python",
"ubuntu"
] |
libxml2 install error: command 'gcc' failed with exit status 1? What are the dependencies of libxml2? | 2,330,062 | <p>I am trying to install libxml2 on unbuntu 9.10 and getting errors:</p>
<p>$ sudo python setup.py develop
Its a very lengthy error message but the last error is</p>
<p><strong>Setup script exited with error: Command 'gcc' failed with exit status 1.</strong></p>
<p>Can anybody tell me why i am getting this error?</... | 0 | 2010-02-24T22:19:58Z | 2,330,167 | <p>As Dirk says, you can install the libxml2 package with apt.</p>
<p>If you are building from source for some reason a good starting point is this command</p>
<pre><code>$ sudo apt-get build-dep libxml2
</code></pre>
| 0 | 2010-02-24T22:34:41Z | [
"python",
"ubuntu"
] |
libxml2 install error: command 'gcc' failed with exit status 1? What are the dependencies of libxml2? | 2,330,062 | <p>I am trying to install libxml2 on unbuntu 9.10 and getting errors:</p>
<p>$ sudo python setup.py develop
Its a very lengthy error message but the last error is</p>
<p><strong>Setup script exited with error: Command 'gcc' failed with exit status 1.</strong></p>
<p>Can anybody tell me why i am getting this error?</... | 0 | 2010-02-24T22:19:58Z | 2,372,931 | <p>This is the entire error:</p>
<p>amed â_extensionsâ
src/lxml/lxml.etree.c:134800: error: âstruct <strong>pyx_obj_4lxml_5etree__BaseContextâ has no member named â_namespacesâ
src/lxml/lxml.etree.c:134800: error: âstruct __pyx_obj_4lxml_5etree__BaseContextâ has no member named â_namespacesâ
src/lx... | -1 | 2010-03-03T16:17:45Z | [
"python",
"ubuntu"
] |
libxml2 install error: command 'gcc' failed with exit status 1? What are the dependencies of libxml2? | 2,330,062 | <p>I am trying to install libxml2 on unbuntu 9.10 and getting errors:</p>
<p>$ sudo python setup.py develop
Its a very lengthy error message but the last error is</p>
<p><strong>Setup script exited with error: Command 'gcc' failed with exit status 1.</strong></p>
<p>Can anybody tell me why i am getting this error?</... | 0 | 2010-02-24T22:19:58Z | 2,782,458 | <p>I encountered the same problem today on Centos 5.4. If you experience such an error on this system (and on RHEL and probably Fedora) you have to install libxml2-devel and/or libxslt-devel.</p>
<p>P.S. I know it's not an answer for this question in general however it maybe helpful for someone so I decided to write d... | 3 | 2010-05-06T15:52:57Z | [
"python",
"ubuntu"
] |
Keeping ORM with stored procedures | 2,330,278 | <p>I am developing a Python web app using sqlalchemy to communicate with mysql database. So far I have mostly been using sqlalchemy's ORM layer to speak with the database. The greatest benefit to me of ORM has been the speed of development, not having to write all these sql queries and then map them to models.</p>
<p>... | 4 | 2010-02-24T22:51:04Z | 2,338,360 | <p>SQLAlchemy doesn't have any good way to convert inserts, updates and deletes to stored procedure calls. It probably wouldn't be that hard to add the capability to have instead_{update,insert,delete} extensions on mappers, but no one has bothered yet. I consider the requirement to have simple DML statements go throug... | 2 | 2010-02-25T23:11:35Z | [
"python",
"mysql",
"database",
"stored-procedures",
"sqlalchemy"
] |
In Python with sqlite is it necessary to close a cursor? | 2,330,344 | <p>Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor?</p>
<p>Additiona... | 21 | 2010-02-24T23:02:16Z | 2,330,380 | <p>You're not obliged to call <code>close()</code> on the cursor; it can be garbage collected like any other object.</p>
<p>But even if waiting for garbage collection sounds OK, I think it would be good style still to ensure that a resource such as a database cursor gets closed whether or not there is an exception. </... | 4 | 2010-02-24T23:08:43Z | [
"python",
"sqlite"
] |
In Python with sqlite is it necessary to close a cursor? | 2,330,344 | <p>Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor?</p>
<p>Additiona... | 21 | 2010-02-24T23:02:16Z | 2,330,419 | <p>It's probably a good idea (although it might not matter much with sqlite, don't know there, but it'll make your code more portable). Further, with recent Python (2.5+), it's easy:</p>
<pre><code>from __future__ import with_statement
from contextlib import closing
with closing(db.cursor()) as cursor:
# do some... | 12 | 2010-02-24T23:15:31Z | [
"python",
"sqlite"
] |
In Python with sqlite is it necessary to close a cursor? | 2,330,344 | <p>Here is the scenario. In your function you're executing statements using a cursor, but one of them fails and an exception is thrown. Your program exits out of the function before closing the cursor it was working with. Will the cursor float around taking up space? Do I have to close the cursor?</p>
<p>Additiona... | 21 | 2010-02-24T23:02:16Z | 2,416,354 | <p>I haven't seen any effect for the <code>sqlite3.Cursor.close()</code> operation yet. </p>
<p>After closing, you can still call <code>fetch(all|one|many)</code> which will return the remaining results from the previous execute statement. Even running <code>Cursor.execute()</code> still works ...</p>
| 5 | 2010-03-10T11:15:56Z | [
"python",
"sqlite"
] |
Python LinkedIn API problem (OAuth) | 2,330,376 | <p>has anyone used the pylinkedin library ?
After redirection from LinkedIn when I try to get the accessToken LinkedIn returns oauth_problem=permission_unknown
Any clues </p>
| 1 | 2010-02-24T23:07:57Z | 6,124,152 | <p>I think our fork of the Linkedin-Client-Library is much more complete (yet a bit heavy)</p>
<p><a href="https://github.com/PhilGo20/LinkedIn-Client-Library" rel="nofollow">https://github.com/PhilGo20/LinkedIn-Client-Library</a></p>
| 0 | 2011-05-25T12:02:43Z | [
"python",
"oauth",
"linkedin"
] |
How to set the program title in python | 2,330,393 | <p>I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the the apple menu. Currently this only shows the word "Python", but I would of co... | 9 | 2010-02-24T23:11:43Z | 2,330,448 | <p>Since your program is interpreted by Python, then what actually is run is Python itself - the <strong>interpreter</strong> program. You would have to have your Python script merged with Python into a single executable and that would be able to have a separate name. For windows there is py2exe, that does that, but I ... | 3 | 2010-02-24T23:20:46Z | [
"python",
"osx",
"title",
"menubar"
] |
How to set the program title in python | 2,330,393 | <p>I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the the apple menu. Currently this only shows the word "Python", but I would of co... | 9 | 2010-02-24T23:11:43Z | 2,330,596 | <p>It depends on what type of application you have. If it's a graphical application, most graphical toolkits allow you to change the title of a window (tk, which comes with python, allows you to do this by calling the <code>title()</code> method of your window object, as does gtk, for which you can use the <code>set_ti... | 9 | 2010-02-24T23:55:10Z | [
"python",
"osx",
"title",
"menubar"
] |
Why am I getting this error in Django (I'm trying to do a 304 not modified) | 2,330,435 | <pre><code>def list_ajax(reqest):
#q = request.GET.get('q',None)
#get all where var = q.
return ...
list_ajax = condition(etag_func=list_ajax)(list_ajax)
</code></pre>
<p>As you can see, I'm trying to return a 304 to the client if the result is the same. But, I am getting this Django error, why?:</p>
<pre... | 0 | 2010-02-24T23:18:49Z | 2,330,878 | <p>The correct <code>etag_func</code> would return some serializable data. In your case, the best choice is something like this:</p>
<pre><code>@etag(_get_list)
def list_ajax(request):
objects = _get_list(request)
return render_to_response("list.html", {"objects": objects})
def _get_list(request):
q = re... | 0 | 2010-02-25T01:06:29Z | [
"python",
"django",
"http",
"header",
"http-status-code-304"
] |
Why am I getting this error in Django (I'm trying to do a 304 not modified) | 2,330,435 | <pre><code>def list_ajax(reqest):
#q = request.GET.get('q',None)
#get all where var = q.
return ...
list_ajax = condition(etag_func=list_ajax)(list_ajax)
</code></pre>
<p>As you can see, I'm trying to return a 304 to the client if the result is the same. But, I am getting this Django error, why?:</p>
<pre... | 0 | 2010-02-24T23:18:49Z | 2,332,524 | <p>Fixed.</p>
<p>Passed the request in.</p>
<pre><code>def list_ajax_etag(request):
return str(request.GET.get('l',''))+str(request.GET.get('a',''))
</code></pre>
| 0 | 2010-02-25T08:12:32Z | [
"python",
"django",
"http",
"header",
"http-status-code-304"
] |
Echo Program in between Arduino and Python | 2,330,531 | <p>I want to send some data to an Arduino through pyserial in Python. All I want to the Arduino to do is read the variable length string data from the serial port, and write it back so that Python can read it. Since I've been unable to do that, the code below only has Python sending on character. Here's the Python code... | 4 | 2010-02-24T23:40:39Z | 2,330,856 | <p>Try increasing or removing the timeout, and set read's size to 1. You may also want to increase the sleep delay, or even implement a simple read loop.</p>
<p>Something like:</p>
<pre><code>try:
while True:
data = ser.read(1).__repr__()
if data:
print "Received: %s." % data
... | 3 | 2010-02-25T01:00:50Z | [
"python",
"embedded",
"arduino",
"pyserial"
] |
Echo Program in between Arduino and Python | 2,330,531 | <p>I want to send some data to an Arduino through pyserial in Python. All I want to the Arduino to do is read the variable length string data from the serial port, and write it back so that Python can read it. Since I've been unable to do that, the code below only has Python sending on character. Here's the Python code... | 4 | 2010-02-24T23:40:39Z | 2,331,661 | <p>I would recommend verifying the two parts independently, using a separate serial port and serial comms software on the PC.</p>
<p>E.g. if your PC has two serial ports, then use a null-modem (loopback) cable to connect them. Or use <a href="http://com0com.sourceforge.net/" rel="nofollow">com0com</a> to make a pair o... | 3 | 2010-02-25T04:33:40Z | [
"python",
"embedded",
"arduino",
"pyserial"
] |
Echo Program in between Arduino and Python | 2,330,531 | <p>I want to send some data to an Arduino through pyserial in Python. All I want to the Arduino to do is read the variable length string data from the serial port, and write it back so that Python can read it. Since I've been unable to do that, the code below only has Python sending on character. Here's the Python code... | 4 | 2010-02-24T23:40:39Z | 2,336,801 | <p>Do you need to flush the sent character out of any held serial buffer? </p>
<p>It may be that your character is not actually leaving the COM port and arriving at the Arduino. When you test this with the Arduino Terminal (I assume you mean the UI terminal in the development environment) you are actually sending your... | 0 | 2010-02-25T19:05:52Z | [
"python",
"embedded",
"arduino",
"pyserial"
] |
Echo Program in between Arduino and Python | 2,330,531 | <p>I want to send some data to an Arduino through pyserial in Python. All I want to the Arduino to do is read the variable length string data from the serial port, and write it back so that Python can read it. Since I've been unable to do that, the code below only has Python sending on character. Here's the Python code... | 4 | 2010-02-24T23:40:39Z | 10,549,980 | <p>The reason you may have to send twice is that, if you're connecting via the USB, the first serial connection will reset the Arduino.</p>
| 0 | 2012-05-11T10:52:43Z | [
"python",
"embedded",
"arduino",
"pyserial"
] |
Is there such a thing as "too many yield statements" in python? | 2,330,546 | <p>If doing a directory listing and reading the files within, at what point does the performance of yield start to deteriorate, compared to returning a list of all the files in the directory?</p>
<p>Here I'm assuming one has enough RAM to return the (potentially huge) list.</p>
<p>PS I'm having problems inlining code... | 4 | 2010-02-24T23:45:11Z | 2,330,581 | <p>It depends on how you're doing the directory listing. Most mechanisms in Python pull the entire directory listing into a list; if doing it that way then even a single yield is a waste. If using <code>opendir(3)</code> then it's probably a random number, according to XKCD's definition of "random".</p>
| 2 | 2010-02-24T23:51:58Z | [
"python",
"yield"
] |
Is there such a thing as "too many yield statements" in python? | 2,330,546 | <p>If doing a directory listing and reading the files within, at what point does the performance of yield start to deteriorate, compared to returning a list of all the files in the directory?</p>
<p>Here I'm assuming one has enough RAM to return the (potentially huge) list.</p>
<p>PS I'm having problems inlining code... | 4 | 2010-02-24T23:45:11Z | 2,330,602 | <p>There is no point at which further use of <code>yield</code> results in decreased performance. In fact, as compared to assembling things in a list, <code>yield</code> actually improves by comparison the more elements there are.</p>
| 5 | 2010-02-24T23:56:03Z | [
"python",
"yield"
] |
Is there such a thing as "too many yield statements" in python? | 2,330,546 | <p>If doing a directory listing and reading the files within, at what point does the performance of yield start to deteriorate, compared to returning a list of all the files in the directory?</p>
<p>Here I'm assuming one has enough RAM to return the (potentially huge) list.</p>
<p>PS I'm having problems inlining code... | 4 | 2010-02-24T23:45:11Z | 2,330,887 | <p>using yield is functionally similar to writing a functor class, even from an implementation or performance perspective, except that it can probably actually call the generator a little bit quicker than the <code>__call__</code> method on a self-made class, because that is built in to the generator's C implementation... | 1 | 2010-02-25T01:09:18Z | [
"python",
"yield"
] |
Is there such a thing as "too many yield statements" in python? | 2,330,546 | <p>If doing a directory listing and reading the files within, at what point does the performance of yield start to deteriorate, compared to returning a list of all the files in the directory?</p>
<p>Here I'm assuming one has enough RAM to return the (potentially huge) list.</p>
<p>PS I'm having problems inlining code... | 4 | 2010-02-24T23:45:11Z | 6,089,492 | <p>In Python 2.7, the definition of <code>glob</code> is</p>
<p><code>def glob(pathname): return list(iglob(pathname))</code></p>
<p>So at least for this version, <code>glob</code> can never be faster than <code>iglob</code>.</p>
| 0 | 2011-05-22T17:14:15Z | [
"python",
"yield"
] |
How to convert ctypes' c_long to Python's int? | 2,330,587 | <p><code>int(c_long(1))</code> doesn't work.</p>
| 11 | 2010-02-24T23:53:17Z | 2,330,610 | <pre><code>>>> ctypes.c_long(1).value
1
</code></pre>
| 20 | 2010-02-24T23:57:12Z | [
"python",
"ctypes"
] |
How to convert ctypes' c_long to Python's int? | 2,330,587 | <p><code>int(c_long(1))</code> doesn't work.</p>
| 11 | 2010-02-24T23:53:17Z | 2,330,613 | <pre><code>>>> type(ctypes.c_long(1).value)
<type 'int'>
</code></pre>
| 2 | 2010-02-24T23:57:49Z | [
"python",
"ctypes"
] |
How to convert ctypes' c_long to Python's int? | 2,330,587 | <p><code>int(c_long(1))</code> doesn't work.</p>
| 11 | 2010-02-24T23:53:17Z | 2,330,623 | <p>Use the 'value' attribute of c_long object.<br></p>
<pre>
<code>
c_long(1).value
</code>
</pre>
<p>or</p>
<pre>
<code>
i = c_long(1)
print i.value
</code>
</pre>
| 5 | 2010-02-25T00:00:27Z | [
"python",
"ctypes"
] |
Colorize PyLint Output? | 2,330,608 | <p>Anyone have any tricks/techniques for colorizing PyLint output?</p>
| 3 | 2010-02-24T23:56:51Z | 2,330,635 | <p>If you feel up to <a href="http://pygments.org/docs/lexerdevelopment/" rel="nofollow">writing a Pygments lexer</a> then you could use <a href="http://pygments.org/docs/cmdline/" rel="nofollow"><code>pygmentize</code></a>.</p>
| 3 | 2010-02-25T00:02:51Z | [
"python",
"pylint",
"colorize"
] |
Colorize PyLint Output? | 2,330,608 | <p>Anyone have any tricks/techniques for colorizing PyLint output?</p>
| 3 | 2010-02-24T23:56:51Z | 2,333,150 | <p><code>$ pylint --output-format=colorized</code></p>
<p>Try <code>$ pylint --help | less</code> for more useful tricks. </p>
| 8 | 2010-02-25T10:07:01Z | [
"python",
"pylint",
"colorize"
] |
Getting fast translation of string data transmitted via a socket into objects in Python | 2,330,834 | <p>I currently have a Python application where newline-terminated ASCII strings are being transmitted to me via a TCP/IP socket. I have a high data rate of these strings and I need to parse them as quickly as possible. Currently, the strings are being transmitted as CSV and if the data rate is high enough, my Python ... | 2 | 2010-02-25T00:52:08Z | 2,330,861 | <p>You can't make Python faster. But you can make your Python application faster.</p>
<p>Principle 1: Do Less.</p>
<p>You can't do less input parsing <em>over all</em> but you can do less input parsing in the process that's also reading the socket and doing everything else with the data.</p>
<p>Generally, do this.<... | 3 | 2010-02-25T01:01:48Z | [
"python",
"performance",
"string",
"parsing",
"sockets"
] |
Getting fast translation of string data transmitted via a socket into objects in Python | 2,330,834 | <p>I currently have a Python application where newline-terminated ASCII strings are being transmitted to me via a TCP/IP socket. I have a high data rate of these strings and I need to parse them as quickly as possible. Currently, the strings are being transmitted as CSV and if the data rate is high enough, my Python ... | 2 | 2010-02-25T00:52:08Z | 2,330,905 | <p>You need to profile your code to find out where the time is being spent.</p>
<p>That doesn't necessarily mean using python's profiler</p>
<p>For example you can just try parsing the same csv string 1000000 times with different methods. Choose the fastest method - divide by 1000000 now you know how much CPU time it... | 0 | 2010-02-25T01:15:39Z | [
"python",
"performance",
"string",
"parsing",
"sockets"
] |
which is the best way to get the value of 'session_key','uid','expires' | 2,330,857 | <p>i have a string </p>
<p>'''
{"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":164
23386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66
64a1679bbeed4282154b35"}
'''</p>
<p>how to get the value .</p>
<p>thanks</p>
| 1 | 2010-02-25T01:00:55Z | 2,330,879 | <pre><code>>>> import json
>>> s=''' {"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":16423386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66 64a1679bbeed4282154b35"} '''
>>> d=json.loads(s)
>>> d['session_key']
u'3.KbRiifBOxY_0ouPag6__.36... | 3 | 2010-02-25T01:06:47Z | [
"python"
] |
which is the best way to get the value of 'session_key','uid','expires' | 2,330,857 | <p>i have a string </p>
<p>'''
{"session_key":"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986","uid":164
23386,"expires":12673200,"secret":"sm7WM_rRtjzXeOT_jDoQ__","sig":"6a6aeb66
64a1679bbeed4282154b35"}
'''</p>
<p>how to get the value .</p>
<p>thanks</p>
| 1 | 2010-02-25T01:00:55Z | 2,330,880 | <p>The string appears to be JSON. </p>
<pre><code>import json
obj= json.loads( aString )
obj['session_key']
</code></pre>
<p>Or it could be a Python dict. Try </p>
<pre><code>obj= eval(myString)
obj['session_key']
</code></pre>
| 2 | 2010-02-25T01:07:39Z | [
"python"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.