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 listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
How can I tokenize this with a regex? | 1,389,062 | <p>Suppose I have strings like the following :</p>
<pre><code>OneTwo
ThreeFour
AnotherString
DVDPlayer
CDPlayer
</code></pre>
<p>I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the cases?</p... | 1 | 2009-09-07T12:02:18Z | 1,389,118 | <p>Try this regular expression:</p>
<pre><code>[A-Z](?:[a-z]+|[A-Z]*?(?=[A-Z][a-z]|\b))
</code></pre>
| 4 | 2009-09-07T12:14:21Z | [
"python",
"ruby",
"regex",
"tokenize",
"lexical-analysis"
] |
How can I tokenize this with a regex? | 1,389,062 | <p>Suppose I have strings like the following :</p>
<pre><code>OneTwo
ThreeFour
AnotherString
DVDPlayer
CDPlayer
</code></pre>
<p>I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the cases?</p... | 1 | 2009-09-07T12:02:18Z | 1,389,124 | <p>The regex</p>
<pre><code>([A-Z]+[a-z]*)([A-Z][a-z]*)
</code></pre>
<p>would do what you want assuming that all your strings are 2 words long and the second word is not like DVD.</p>
<p>I.e. it would work for your examples but maybe not for what you are actually trying to do.</p>
| 1 | 2009-09-07T12:15:36Z | [
"python",
"ruby",
"regex",
"tokenize",
"lexical-analysis"
] |
How can I tokenize this with a regex? | 1,389,062 | <p>Suppose I have strings like the following :</p>
<pre><code>OneTwo
ThreeFour
AnotherString
DVDPlayer
CDPlayer
</code></pre>
<p>I know how to tokenize the camel-case ones, except the "DVDPlayer" and "CDPlayer". I know I could tokenize them manually, but maybe you can show me a regex that can handle all the cases?</p... | 1 | 2009-09-07T12:02:18Z | 1,389,146 | <p>Here's my attempt: </p>
<pre><code>([A-Z][a-z]+)|([A-Z]+(?=[A-Z][a-z]+))
</code></pre>
| 1 | 2009-09-07T12:20:22Z | [
"python",
"ruby",
"regex",
"tokenize",
"lexical-analysis"
] |
how to create an excel file in google app engine (python)? | 1,389,076 | <p>I want to create an excel sheet using Google App Engine in python.</p>
<p>my application datastore contains the data of company details like </p>
<pre><code>name, business, website,..etc.,.
</code></pre>
<p>i want to put those details in an excel sheet, is it possible to generate excel file in Google App Engine u... | 4 | 2009-09-07T12:05:48Z | 1,389,129 | <p>You can use <a href="http://sourceforge.net/projects/pyexcelerator/" rel="nofollow">pyexcelerator</a> to generate excel files </p>
| 0 | 2009-09-07T12:16:47Z | [
"python",
"google-app-engine"
] |
how to create an excel file in google app engine (python)? | 1,389,076 | <p>I want to create an excel sheet using Google App Engine in python.</p>
<p>my application datastore contains the data of company details like </p>
<pre><code>name, business, website,..etc.,.
</code></pre>
<p>i want to put those details in an excel sheet, is it possible to generate excel file in Google App Engine u... | 4 | 2009-09-07T12:05:48Z | 1,391,790 | <p>You can't write to the filesystem in App Engine, so pyexcelerator's save function obviously won't work. </p>
<p>You'll want to take the data pyexcelerator's generating, and instead of writing it to a file either save it as a blob in the Datastore or return it directly to the user's browser.</p>
| 4 | 2009-09-08T03:20:03Z | [
"python",
"google-app-engine"
] |
how to create an excel file in google app engine (python)? | 1,389,076 | <p>I want to create an excel sheet using Google App Engine in python.</p>
<p>my application datastore contains the data of company details like </p>
<pre><code>name, business, website,..etc.,.
</code></pre>
<p>i want to put those details in an excel sheet, is it possible to generate excel file in Google App Engine u... | 4 | 2009-09-07T12:05:48Z | 1,394,024 | <p>You may like to consider <code>xlwt</code>, a fork of <code>pyExcelerator</code> with bug-fixes and on-going enhancements. See <code>http://pypi.python.org/pypi/xlwt</code> ... disclosure: I'm the maintainer of xlwt.</p>
| 4 | 2009-09-08T13:25:05Z | [
"python",
"google-app-engine"
] |
how to create an excel file in google app engine (python)? | 1,389,076 | <p>I want to create an excel sheet using Google App Engine in python.</p>
<p>my application datastore contains the data of company details like </p>
<pre><code>name, business, website,..etc.,.
</code></pre>
<p>i want to put those details in an excel sheet, is it possible to generate excel file in Google App Engine u... | 4 | 2009-09-07T12:05:48Z | 7,239,490 | <p>Another simple suggestion is to create tab seperated files (.tsv) or comma seperated files (.csv), which is very easy to do.
Just use "\t".join(row) and save as .xls/.tsv or ",".join(row) and save as .csv. Excel will know how to handle this. I suggest tab seperated files since tab is a rare character and using it pr... | 0 | 2011-08-30T06:32:34Z | [
"python",
"google-app-engine"
] |
how to add json library | 1,389,141 | <p>i am new to python, on my Mac, when i issue command</p>
<pre><code>User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
</code></pre>
<p>I get error on json. how to add this library? i'm using 2.5 (th... | 9 | 2009-09-07T12:19:02Z | 1,389,191 | <p>AFAIK the json module was added in version 2.6, see <a href="http://docs.python.org/library/json.html" rel="nofollow">here</a>. I'm guessing you can update your python installation to the latest stable 2.6 from <a href="http://www.python.org/download/" rel="nofollow">this page</a>.</p>
| 4 | 2009-09-07T12:31:54Z | [
"python",
"json",
"osx",
"python-2.5"
] |
how to add json library | 1,389,141 | <p>i am new to python, on my Mac, when i issue command</p>
<pre><code>User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
</code></pre>
<p>I get error on json. how to add this library? i'm using 2.5 (th... | 9 | 2009-09-07T12:19:02Z | 1,389,203 | <p>You can also install json-py from here <a href="http://sourceforge.net/projects/json-py/" rel="nofollow">http://sourceforge.net/projects/json-py/</a></p>
| 2 | 2009-09-07T12:34:40Z | [
"python",
"json",
"osx",
"python-2.5"
] |
how to add json library | 1,389,141 | <p>i am new to python, on my Mac, when i issue command</p>
<pre><code>User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
</code></pre>
<p>I get error on json. how to add this library? i'm using 2.5 (th... | 9 | 2009-09-07T12:19:02Z | 1,389,269 | <p>You can also install simplejson.</p>
<p>If you have pip (see <a href="https://pypi.python.org/pypi/pip" rel="nofollow">https://pypi.python.org/pypi/pip</a>) as your Python package manager you can install simplejson with:</p>
<pre><code> pip install simplejson
</code></pre>
<p>This is similar to the comment of ins... | 12 | 2009-09-07T12:47:24Z | [
"python",
"json",
"osx",
"python-2.5"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,389,202 | <p>You could do it easily with the keyword arguments, e.g. like this:</p>
<pre><code>>>> class D:
def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
>>> D(test='d').test
'd'
</code></pre>
<p>similar implementation for the positional arguments would be:</p>
... | 11 | 2009-09-07T12:34:37Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,389,216 | <p><strong>Edit: extended the solution to honor default arguments also</strong></p>
<p>Here is the complete solution:</p>
<pre><code>from functools import wraps
import inspect
def initializer(func):
"""
Automatically assigns the parameters.
>>> class process:
... @initializer
... ... | 56 | 2009-09-07T12:37:39Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,389,224 | <p>Quoting the <a href="http://www.python.org/dev/peps/pep-0020/">Zen of Python</a>,</p>
<blockquote>
<p>Explicit is better than implicit.</p>
</blockquote>
| 21 | 2009-09-07T12:38:59Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,389,232 | <p>If you're using Python 2.6 or higher, you can use <a href="http://docs.python.org/library/collections.html#collections.namedtuple">collections.namedtuple</a>:</p>
<pre><code>>>> from collections import namedtuple
>>> Process = namedtuple('Process', 'PID PPID cmd')
>>> proc = Process(1, 2,... | 25 | 2009-09-07T12:40:02Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,389,304 | <p>Another thing you can do:</p>
<pre><code>class X(object):
def __init__(self, a,b,c,d):
vars = locals() # dict of local names
self.__dict__.update(vars) # __dict__ holds and object's attributes
del self.__dict__["self"] # don't need `self`
</code></pre>
<p>But the only solution I would r... | 12 | 2009-09-07T12:54:44Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 1,837,379 | <p>Nadia's solution is better and more powerful, but I think this is also interesting:</p>
<pre><code>def constructor(*arg_names):
def __init__(self, *args):
for name, val in zip(arg_names, args):
self.__setattr__(name, val)
return __init__
class MyClass(object):
__init__ = constructor("var1", "var2"... | 5 | 2009-12-03T03:08:01Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 15,028,395 | <p><a href="https://github.com/nu11ptr" rel="nofollow">nu11ptr</a> has made a small module, <a href="https://github.com/nu11ptr/PyInstanceVars" rel="nofollow">PyInstanceVars</a>, which includes this functionality as a function decorator. In the module's README is states that the "<em>[...] performance is now only 30-40... | 0 | 2013-02-22T16:09:41Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 21,242,547 | <p>There may not be a need to initialize variables, as locals() already contains the values!</p>
<p>class Dummy(object):</p>
<pre><code>def __init__(self, a, b, default='Fred'):
self.params = {k:v for k,v in locals().items() if k != 'self'}
</code></pre>
<p>d = Dummy(2, 3)</p>
<p>d.params</p>
<p>{'a': 2, 'b': ... | 2 | 2014-01-20T19:31:47Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 32,073,190 | <p>Maybe this is a closed question, but I would like to propose my solution in order to know what you think about it. I have used a metaclass which applies a decorator to <strong>init</strong> method</p>
<pre><code>import inspect
class AutoInit(type):
def __new__(meta, classname, supers, classdict):
class... | 0 | 2015-08-18T13:00:55Z | [
"python",
"class",
"initialization-list"
] |
Python: Automatically initialize instance variables? | 1,389,180 | <p>I have a python class that looks like this:</p>
<pre><code>class Process:
def __init__(self, PID, PPID, cmd, FDs, reachable, user):
</code></pre>
<p>followed by:</p>
<pre><code> self.PID=PID
self.PPID=PPID
self.cmd=cmd
...
</code></pre>
<p>Is there any way to autoinitialize the... | 35 | 2009-09-07T12:28:28Z | 35,542,235 | <p>As soon as <code>getargspec</code> is deprecated since Python 3.5, here's solution using <code>inspect.signature</code>:</p>
<pre><code>from inspect import signature, Parameter
import functools
def auto_assign(func):
# Signature:
sig = signature(func)
for name, param in sig.parameters.items():
... | 2 | 2016-02-21T21:21:28Z | [
"python",
"class",
"initialization-list"
] |
what's wrong with my simple HTTP proxy script? (python socket based) | 1,389,278 | <p>i wrote a smple python script for a proxy functionality. It works. However, if the requested webpage has many other http requests, e.g. Google map, the page was rendered quite slow. </p>
<p>Could you guys give some hints, what would be the bottleneck in my code? how to improve?</p>
<p>Thanks in advance.</p>
<pre>... | 0 | 2009-09-07T12:48:40Z | 1,389,624 | <p>I'm not sure what your speed problems are, but here are some other nits I found to pick:</p>
<pre><code>result['protocal'] = vl[2]
</code></pre>
<p>should be</p>
<pre><code>result['protocol'] = vl[2]
</code></pre>
<p>This code is indented one level too deep:</p>
<pre><code>sk2.connect((host,int(port)))
</code><... | 0 | 2009-09-07T14:16:57Z | [
"python"
] |
what's wrong with my simple HTTP proxy script? (python socket based) | 1,389,278 | <p>i wrote a smple python script for a proxy functionality. It works. However, if the requested webpage has many other http requests, e.g. Google map, the page was rendered quite slow. </p>
<p>Could you guys give some hints, what would be the bottleneck in my code? how to improve?</p>
<p>Thanks in advance.</p>
<pre>... | 0 | 2009-09-07T12:48:40Z | 1,397,939 | <p>Er, well first of all you're assuming that all the subsequent requests on a connection are going to be for the same host...</p>
| 0 | 2009-09-09T06:54:19Z | [
"python"
] |
How to process UDP data in Appengine | 1,389,385 | <p>I have a service provider who is transmitting data thro' UDP. I want to establish a connection to them, receive & process data (will be with in the 30 sec limit/request)</p>
<p>Is it possible to get & process UDP data in appengine. I am looking for some simple example.</p>
| 1 | 2009-09-07T13:14:39Z | 1,389,493 | <p>Unfortunately I don't believe it's possible. The <a href="http://code.google.com/appengine/docs/python/runtime.html">docs</a> on the GAE python runtime say this:</p>
<blockquote>
<p>An App Engine application cannot:</p>
<ul>
<li>open a socket or access another host directly. An application can use the App ... | 6 | 2009-09-07T13:41:19Z | [
"python",
"google-app-engine",
"udp"
] |
How to process UDP data in Appengine | 1,389,385 | <p>I have a service provider who is transmitting data thro' UDP. I want to establish a connection to them, receive & process data (will be with in the 30 sec limit/request)</p>
<p>Is it possible to get & process UDP data in appengine. I am looking for some simple example.</p>
| 1 | 2009-09-07T13:14:39Z | 16,725,489 | <p><a href="http://googleappengine.blogspot.co.il/2013/04/app-engine-177-released.html" rel="nofollow">Update</a> for GAE 1.7.7:</p>
<blockquote>
<p><strong>Outbound sockets moved to Preview</strong></p>
<p>Outbound sockets is now in preview
in this release for <a href="https://developers.google.com/appengine... | 2 | 2013-05-23T23:24:03Z | [
"python",
"google-app-engine",
"udp"
] |
How to process UDP data in Appengine | 1,389,385 | <p>I have a service provider who is transmitting data thro' UDP. I want to establish a connection to them, receive & process data (will be with in the 30 sec limit/request)</p>
<p>Is it possible to get & process UDP data in appengine. I am looking for some simple example.</p>
| 1 | 2009-09-07T13:14:39Z | 17,618,253 | <p>You could run a separate agent on a cloud host like DigitalOcean or Amazon EC2 that proxies this protocol and makes itself available to Google App Engine via ordinary HTTP or web sockets.</p>
| 0 | 2013-07-12T15:14:59Z | [
"python",
"google-app-engine",
"udp"
] |
AN error about "User.add_to_class" to extend my user?I do not know why | 1,389,627 | <p>In my models.py, I user these code to extent two fields:</p>
<pre><code>User.add_to_class('bio', models.TextField(blank=True))
User.add_to_class('about', models.TextField(blank=True))
</code></pre>
<p>But when I creat a User :</p>
<pre><code>user = User.objects.create_user(username=self.cleaned_data['username'], ... | 1 | 2009-09-07T14:17:05Z | 1,389,778 | <p>This is <a href="http://groups.google.com/group/django-users/browse%5Fthread/thread/a35d94ce1a7893b0" rel="nofollow">not a good way to store additional user information</a>, for a number of reasons, as James Bennett points out in the linked thread. It's no surprise that you're getting weird SQL output and struggling... | 2 | 2009-09-07T14:57:08Z | [
"python",
"mysql",
"django"
] |
How to write a large amount of data in a tarfile in python without using temporary file | 1,389,681 | <p>I've wrote a small cryptographic module in python whose task is to cipher a file and put the result in a tarfile. The original file to encrypt can be quit large, but that's not a problem because my program only need to work with a small block of data at a time, that can be encrypted on the fly and stored.</p>
<p>I'... | 3 | 2009-09-07T14:33:56Z | 1,389,697 | <p>I guess you need to understand how the tar format works, and handle the tar writing yourself. Maybe this can be helpful?</p>
<p><a href="http://mail.python.org/pipermail/python-list/2001-August/100796.html" rel="nofollow">http://mail.python.org/pipermail/python-list/2001-August/100796.html</a></p>
| 0 | 2009-09-07T14:39:04Z | [
"python",
"tar"
] |
How to write a large amount of data in a tarfile in python without using temporary file | 1,389,681 | <p>I've wrote a small cryptographic module in python whose task is to cipher a file and put the result in a tarfile. The original file to encrypt can be quit large, but that's not a problem because my program only need to work with a small block of data at a time, that can be encrypted on the fly and stored.</p>
<p>I'... | 3 | 2009-09-07T14:33:56Z | 1,389,707 | <p>You can create an own file-like object and pass to TarFile.addfile. Your file-like object will generate the encrypted contents on the fly in the fileobj.read() method.</p>
| 4 | 2009-09-07T14:41:10Z | [
"python",
"tar"
] |
How to write a large amount of data in a tarfile in python without using temporary file | 1,389,681 | <p>I've wrote a small cryptographic module in python whose task is to cipher a file and put the result in a tarfile. The original file to encrypt can be quit large, but that's not a problem because my program only need to work with a small block of data at a time, that can be encrypted on the fly and stored.</p>
<p>I'... | 3 | 2009-09-07T14:33:56Z | 1,389,710 | <p>Huh? Can't you just use the <a href="http://docs.python.org/library/subprocess.html" rel="nofollow">subprocess</a> module to run a pipe through to tar? That way, no temporary file should be needed. Of course, this won't work if you can't generate your data in small enough chunks to fit in RAM, but if you have that p... | 2 | 2009-09-07T14:41:20Z | [
"python",
"tar"
] |
How to write a large amount of data in a tarfile in python without using temporary file | 1,389,681 | <p>I've wrote a small cryptographic module in python whose task is to cipher a file and put the result in a tarfile. The original file to encrypt can be quit large, but that's not a problem because my program only need to work with a small block of data at a time, that can be encrypted on the fly and stored.</p>
<p>I'... | 3 | 2009-09-07T14:33:56Z | 1,452,363 | <p>Basically using a file-like object and passing it to TarFile.addfile do the trick, but there is still some issues open.</p>
<ul>
<li>I need to known the full encrypted file size at the beginning</li>
<li>the way tarfile access to read method is such that the custom file-like object must always return full read buff... | 2 | 2009-09-20T23:53:26Z | [
"python",
"tar"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,389,757 | <p>You need to give us more context before we can answer: what type of data are you saving, how much is there, how do you want to access it?</p>
<p>As for pickles: they do not store code. When you pickle a function or class, it is the name that is stored, not the actual code itself.</p>
| 1 | 2009-09-07T14:53:33Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,389,790 | <p>You could do something like:</p>
<p>to write</p>
<ul>
<li>Pickle</li>
<li>Sign pickled file</li>
<li>Done</li>
</ul>
<p>to read</p>
<ul>
<li>Check pickled file's signature</li>
<li>Unpickle</li>
<li>Use</li>
</ul>
<p>I wonder though what makes you think that the data files are going to be tampered but your appl... | 3 | 2009-09-07T14:59:33Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,389,792 | <p>From your description JSON encoding is the secure and fast solution. There is a json module in python2.6, you can use it like this:</p>
<pre><code>import json
obj = {'key1': 'value1', 'key2': [1, 2, 3, 4], 'key3': 1322}
encoded = json.dumps(obj)
obj = json.loads(encoded)
</code></pre>
<p>JSON format is human reada... | 21 | 2009-09-07T15:00:30Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,389,803 | <p><strong><em></strong>In this answer, I'm only concerned about <strong>accidental</strong> corruption of the application's integrity.<strong></em></strong></p>
<p>Pickle is "secure". What might be insecure is accessing code you didn't write, for example in plugins; that is not relevant to pickles though.</p>
<p>Whe... | 1 | 2009-09-07T15:04:53Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,390,025 | <p>You should use a database of some kind. Storing in pickle format isn't a good idea (in most cases). You may consider:</p>
<ul>
<li><strong>SQLite</strong> - (included in Python 2.5+) fast and simple, but requires knowledge of SQL and DB-API</li>
<li><a href="http://buzhug.sourceforge.net/" rel="nofollow"><strong>bu... | 1 | 2009-09-07T16:09:03Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,391,437 | <p>Who -- specifically -- is the sociopath who's going through the effort to break a program by hacking the pickled file?</p>
<p>It's Python. The sociopath has your source. They don't need to fool around hacking your pickle file. They can just edit your source and do all the "damage" they want.</p>
<p>Don't worry ... | 1 | 2009-09-08T00:40:10Z | [
"python",
"data-structures",
"save"
] |
How to save data with Python? | 1,389,738 | <p>I am working on a program in Python and want users to be able to save data they are working on. I have looked into cPickle; it seems like it would be a fast and easy way to save data, it seems insecure. Since entire functions, classes, etc can be pickled, I am worried that a rogue save file could inject harmful co... | 12 | 2009-09-07T14:49:22Z | 1,512,645 | <p>You might enjoy working with the y_serial module over at
<a href="http://yserial.sourceforge.net" rel="nofollow">http://yserial.sourceforge.net</a> </p>
<p>which reads like a tutorial but operationally offers
working code for serialization and persistance.
The commentary discusses some of the pros and cons
rele... | 1 | 2009-10-03T02:45:42Z | [
"python",
"data-structures",
"save"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 1,390,399 | <p>It won't work in <code>shell</code>? I managed to get a django shell session going in emacs just now. </p>
<p>Hit <code>M-x shell</code> and then start your python shell inside that bash shell session, like so:</p>
<pre><code> M-x shell
</code></pre>
<p>the shell spawns</p>
<pre><code>prompt> cd path/to/my/dj... | 0 | 2009-09-07T17:57:53Z | [
"python",
"django",
"emacs",
"ipython"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 1,390,919 | <p>Using <a href="http://www.emacswiki.org/emacs/AnsiTerm" rel="nofollow"><code>ansi-term</code></a> will make ipython's tab-completion work, however note that this will remap all <code>C-x [...]</code> keybindings to <code>C-c [...]</code>.</p>
<p>If you like it, you can easily create a keybinding for it by putting t... | 1 | 2009-09-07T20:53:51Z | [
"python",
"django",
"emacs",
"ipython"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 1,392,730 | <p>OK, so I hacked this by myself today. A major part of it is copy-and-paste from <code>py-shell</code> from <code>python-mode.el</code>.</p>
<pre class="lang-lisp prettyprint-override"><code>(defun django-shell (&optional argprompt)
(interactive "P")
;; Set the default shell if not already set
(labels ((re... | 8 | 2009-09-08T08:33:27Z | [
"python",
"django",
"emacs",
"ipython"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 1,392,773 | <p>I did simply create a replacement ipython shell script.</p>
<p>I use python-mode.el and ipython.el; related .emacs.el fragment goes like this:</p>
<pre>
(setq ipython-command "/Users/japhy/bin/smart_ipython")
(require 'ipython)
;; fix completion for ipython 0.10
(setq ipython-completion-command-string
"prin... | 1 | 2009-09-08T08:47:13Z | [
"python",
"django",
"emacs",
"ipython"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 32,867,813 | <p>This is a pretty old question, but it's probably still useful for someone. I've found the easiest way of doing this is by adding the following to my .emacs</p>
<pre><code>(setq python-shell-interpreter "python"
python-shell-interpreter-args "-i /absolute/path/to/manage.py shell_plus")
</code></pre>
<p>You ca... | 1 | 2015-09-30T13:48:14Z | [
"python",
"django",
"emacs",
"ipython"
] |
How to run django shell from Emacs? | 1,389,835 | <p>I'd like to be able to run <code>./manage.py shell</code> in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.</p>
<p>Is this possible?</p>
| 9 | 2009-09-07T15:16:28Z | 38,608,305 | <p>After researching this question I think the best solution that will work for multiple django projects without changing your config each time you swap is <code>python-django.el</code> plus correct configuration of <em>directory-local variables</em>.</p>
<p>python-django is a great addition to python.el for django us... | 0 | 2016-07-27T08:57:31Z | [
"python",
"django",
"emacs",
"ipython"
] |
Mechanize and Google App Engine | 1,389,893 | <p>Has someone managed to use <a href="http://wwwsearch.sourceforge.net/mechanize/" rel="nofollow">mechanize</a> with Google App Engine application?</p>
| 4 | 2009-09-07T15:30:49Z | 1,398,104 | <p>I found that someone created this project: <a href="http://code.google.com/p/gaemechanize/" rel="nofollow">gaemechanize</a>. But no code at the time of writing.</p>
| 2 | 2009-09-09T07:34:35Z | [
"python",
"google-app-engine",
"mechanize"
] |
Mechanize and Google App Engine | 1,389,893 | <p>Has someone managed to use <a href="http://wwwsearch.sourceforge.net/mechanize/" rel="nofollow">mechanize</a> with Google App Engine application?</p>
| 4 | 2009-09-07T15:30:49Z | 2,056,566 | <p>I have solved this problem, please see:
<a href="http://stackoverflow.com/questions/1902079/python-mechanize-gaepython-code/2056543#2056543">http://stackoverflow.com/questions/1902079/python-mechanize-gaepython-code/2056543#2056543</a></p>
| 3 | 2010-01-13T12:27:41Z | [
"python",
"google-app-engine",
"mechanize"
] |
OpenGL in Python with Snow Leopard? | 1,389,928 | <p>I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of ex... | 4 | 2009-09-07T15:42:48Z | 1,390,205 | <p>You could try pygame. Pygame is a python wrapper around SDL. According to their website they have Max OS X binaries. Here is a <a href="http://www.willmcgugan.com/blog/tech/2007/6/4/opengl-sample-code-for-pygame/" rel="nofollow">simple example</a> of using pygame with OpenGL. Once you are able to create the window a... | 0 | 2009-09-07T17:01:35Z | [
"python",
"opengl",
"osx-snow-leopard"
] |
OpenGL in Python with Snow Leopard? | 1,389,928 | <p>I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of ex... | 4 | 2009-09-07T15:42:48Z | 1,390,246 | <p>There's probably no good reason to avoid 32-bit mode. Unless your Python programs need to larger address space, of course.</p>
| 2 | 2009-09-07T17:13:13Z | [
"python",
"opengl",
"osx-snow-leopard"
] |
OpenGL in Python with Snow Leopard? | 1,389,928 | <p>I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of ex... | 4 | 2009-09-07T15:42:48Z | 1,390,287 | <p>Also when programing with OpenGL in python remember that Python datastructures can be rather slow when it comes to requirements for 3D graphics. PyGL developers for example recommend using ctypes for operations that concern graphics, since that way you can get enough performance for some complicated geometry with ba... | 0 | 2009-09-07T17:24:21Z | [
"python",
"opengl",
"osx-snow-leopard"
] |
OpenGL in Python with Snow Leopard? | 1,389,928 | <p>I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++ and Objective-C, but I don't have much experience in Python. I'm wondering if there's a good tutorial that works in Snow Leopard. I'd prefer to stay in 64-bit mode if possible, since I've heard 32-bit programs require loading a lot of ex... | 4 | 2009-09-07T15:42:48Z | 1,390,361 | <p>I've used <a href="http://pyopengl.sourceforge.net/index.html" rel="nofollow">PyOpenGL</a> 3.0.0 quite successfully on Snow Leopard. It uses ctypes, so it should be making 64-bit calls if those libraries are available (and Snow Leopard's Python includes a 64-bit version). I haven't used the wxPython stuff with PyO... | 4 | 2009-09-07T17:47:23Z | [
"python",
"opengl",
"osx-snow-leopard"
] |
How do I use StandardAnalyzer with TermQuery? | 1,390,088 | <p>I'm trying to produce something similar to what QueryParser in lucene does, but without the parser, i.e. run a string through StandardAnalyzer, tokenize this and use TermQuery:s in a BooleanQuery to produce a query. My problem is that I only get Token:s from StandardAnalyzer, and not Term:s. I can convert a Token to... | 3 | 2009-09-07T16:26:23Z | 1,390,495 | <p>The established way to get the token text is with <code>token.termText()</code> - that API's been there forever.</p>
<p>And yes, you'll need to specify a field name to both the <code>Analyzer</code> and the <code>Term</code>; I think that's considered normal. 8-)</p>
| 2 | 2009-09-07T18:28:22Z | [
"python",
"lucene",
"pylucene"
] |
How do I use StandardAnalyzer with TermQuery? | 1,390,088 | <p>I'm trying to produce something similar to what QueryParser in lucene does, but without the parser, i.e. run a string through StandardAnalyzer, tokenize this and use TermQuery:s in a BooleanQuery to produce a query. My problem is that I only get Token:s from StandardAnalyzer, and not Term:s. I can convert a Token to... | 3 | 2009-09-07T16:26:23Z | 4,268,451 | <p>I've come across the same problem, and, using Lucene 2.9 API and Java, my code snippet looks like this:</p>
<pre><code>final TokenStream tokenStream = new StandardAnalyzer(Version.LUCENE_29)
.tokenStream( fieldName , new StringReader( value ) );
final List< String > result = new ArrayList< String >(... | 0 | 2010-11-24T15:26:27Z | [
"python",
"lucene",
"pylucene"
] |
What are the different options for processing uploaded PDF files in a Django application? | 1,390,371 | <p>Our Django application needs to do a few things with uploaded PDF files:</p>
<ol>
<li>Verify that the file is a PDF and isn't corrupted</li>
<li>Check that the file isn't encrypted</li>
<li>Count the number of pages</li>
</ol>
<p>We run into problems with one unfortunately popular application that's idea of an une... | 1 | 2009-09-07T17:49:43Z | 1,390,392 | <p><a href="http://pdflib.com" rel="nofollow">PDFlib</a> is excellent, but costs money. You didn't say it had to be free, though implicitly somehow I assume you want it to be! :)</p>
| 1 | 2009-09-07T17:55:45Z | [
"python",
"django",
"pdf"
] |
Removing redundant symbols from string | 1,390,657 | <p>Let's say I have a string like that: <code>'12,423,343.93'</code>. How to convert it to <code>float</code> in simple, effective and yet elegant way?</p>
<p>It seems I need to remove redundant commas from the string and then call <code>float()</code>, but I have no good solution for that.</p>
<p>Thanks</p>
| 2 | 2009-09-07T19:14:06Z | 1,390,666 | <pre><code>s = "12,423,343.93"
f = float(s.replace(",", ""))
</code></pre>
| 9 | 2009-09-07T19:17:02Z | [
"python",
"floating-point"
] |
Removing redundant symbols from string | 1,390,657 | <p>Let's say I have a string like that: <code>'12,423,343.93'</code>. How to convert it to <code>float</code> in simple, effective and yet elegant way?</p>
<p>It seems I need to remove redundant commas from the string and then call <code>float()</code>, but I have no good solution for that.</p>
<p>Thanks</p>
| 2 | 2009-09-07T19:14:06Z | 1,391,175 | <p>Note that the seperator symbols used vary from country to country. In some cultures, "." is used to seperate groups, and "," indicates a decimal point for instance. If you're parsing user-entered strings like this, it may be better to use the locale module instead. For example:</p>
<pre><code>>>> import... | 6 | 2009-09-07T22:26:04Z | [
"python",
"floating-point"
] |
Python: how do I implement 'pop' in this class? | 1,390,966 | <p>I'd like this class to act like a list. It's data resides in the attribute self.data.
If I have an instance, pp = population, does defining <code>__getitem__</code> mean I can refer to
pp instead of pp.data? Or is it the defining of <code>__repr__</code> that does that?
Would deriving this class from list instea... | 1 | 2009-09-07T21:09:20Z | 1,390,988 | <p>Why not just extend the list class? Then you have all of that functionality built in.</p>
<pre><code>class population(list):
# custom methods here
</code></pre>
<p>Just remember, instead of referencing <code>self.data</code> for the list, just reference <code>self</code>.</p>
| 7 | 2009-09-07T21:17:11Z | [
"python"
] |
Python: how do I implement 'pop' in this class? | 1,390,966 | <p>I'd like this class to act like a list. It's data resides in the attribute self.data.
If I have an instance, pp = population, does defining <code>__getitem__</code> mean I can refer to
pp instead of pp.data? Or is it the defining of <code>__repr__</code> that does that?
Would deriving this class from list instea... | 1 | 2009-09-07T21:09:20Z | 1,391,010 | <pre><code>def pop(self, index=-1) :
return self.data.pop(index)
</code></pre>
<p>This will implement the expected behavior :</p>
<ul>
<li>return the last item if no index is passed;</li>
<li>return the item at "index" if passed;</li>
<li>will use the type check of the underlying pop();</li>
<li>will raise the sa... | 2 | 2009-09-07T21:25:36Z | [
"python"
] |
Python: how do I implement 'pop' in this class? | 1,390,966 | <p>I'd like this class to act like a list. It's data resides in the attribute self.data.
If I have an instance, pp = population, does defining <code>__getitem__</code> mean I can refer to
pp instead of pp.data? Or is it the defining of <code>__repr__</code> that does that?
Would deriving this class from list instea... | 1 | 2009-09-07T21:09:20Z | 1,391,053 | <blockquote>
<p>If I have an instance, pp = population, does defining <code>__getitem__</code> mean I can refer to pp instead of pp.data?</p>
</blockquote>
<p>Essentially, yes. Adding a <code>__getitem__</code> method is equivalent to overloading the [] operator in some other languages. Thus the following two woul... | 1 | 2009-09-07T21:41:38Z | [
"python"
] |
Python: how do I implement 'pop' in this class? | 1,390,966 | <p>I'd like this class to act like a list. It's data resides in the attribute self.data.
If I have an instance, pp = population, does defining <code>__getitem__</code> mean I can refer to
pp instead of pp.data? Or is it the defining of <code>__repr__</code> that does that?
Would deriving this class from list instea... | 1 | 2009-09-07T21:09:20Z | 1,391,450 | <p>Is this really a <strong>list</strong> of things, or are you using a list to store a bunch of things? Before you inherit from list, why not just use a list?</p>
<p>I try to save inheritance for things that are true is-a relationships. A Form is-a Window, a Dialog is-a Form, etc. If you are just modeling is-imple... | 1 | 2009-09-08T00:43:07Z | [
"python"
] |
Google App Engine - Request class query_string | 1,391,026 | <p>In Python and GAE, I would like to ask how to get the parameters of a query string in the url.
As I know, the query_string part returns all the part after the "?" in the url. So what I have to do is to split the query string with "&", and use the variables.
Is there any other convinient way to manage the query... | 6 | 2009-09-07T21:31:07Z | 1,391,032 | <p>You don't need to complicate. You can retrieve all GET parameters with:</p>
<pre><code>self.request.get('var_name')
</code></pre>
<p>Or if you want to retrieve them all in one list you can use:</p>
<pre><code>self.request.get_all()
</code></pre>
<p>You can find more info on the Request class <a href="http://code... | 17 | 2009-09-07T21:34:38Z | [
"python",
"google-app-engine"
] |
Google App Engine - Request class query_string | 1,391,026 | <p>In Python and GAE, I would like to ask how to get the parameters of a query string in the url.
As I know, the query_string part returns all the part after the "?" in the url. So what I have to do is to split the query string with "&", and use the variables.
Is there any other convinient way to manage the query... | 6 | 2009-09-07T21:31:07Z | 28,768,234 | <p>If you want to iterate over all the parameters of your request, you should do something like this:</p>
<pre><code>for argument in self.request.arguments():
values = self.request.get_all(argument)
# do something with values (which is a list)
</code></pre>
<p>Or, you could build your own <code>dict</code> co... | 0 | 2015-02-27T15:10:26Z | [
"python",
"google-app-engine"
] |
function decorators in c# | 1,391,157 | <p>Is there a C# analog for Python's function decorators? It feels like it's doable with attributes and the reflection framework, but I don't see a way to replace functions at runtime.</p>
<p><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">Python decorators</a> generally work this way:</p>
<pre><co... | 21 | 2009-09-07T22:19:37Z | 1,391,176 | <p>You can do that using <a href="http://www.postsharp.org/">Post Sharp</a>. Check out the demo video for instructions.</p>
| 8 | 2009-09-07T22:26:29Z | [
"c#",
"python",
"reflection",
"decorator"
] |
function decorators in c# | 1,391,157 | <p>Is there a C# analog for Python's function decorators? It feels like it's doable with attributes and the reflection framework, but I don't see a way to replace functions at runtime.</p>
<p><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">Python decorators</a> generally work this way:</p>
<pre><co... | 21 | 2009-09-07T22:19:37Z | 1,391,202 | <p>The way I achieve this is through <a href="http://en.wikipedia.org/wiki/Aspect-oriented%5Fprogramming">AOP frameworks</a> like <a href="http://www.castleproject.org/dynamicproxy/index.html">Castle Dynamic Proxy</a>, <a href="http://www.springframework.net/doc/reference/html/aop-quickstart.html">Spring.NET</a> or eve... | 12 | 2009-09-07T22:37:40Z | [
"c#",
"python",
"reflection",
"decorator"
] |
function decorators in c# | 1,391,157 | <p>Is there a C# analog for Python's function decorators? It feels like it's doable with attributes and the reflection framework, but I don't see a way to replace functions at runtime.</p>
<p><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=240808">Python decorators</a> generally work this way:</p>
<pre><co... | 21 | 2009-09-07T22:19:37Z | 1,391,302 | <p>you can sort of achieve that by "ContextBoundObject" in the .NET framework.
but it's a bit convoluted because it basically uses .net remoting infrastructure to intercept method calls. (the runtime overhead is minimum if your calls are within the same app domain but just across different "context").
so the better app... | 4 | 2009-09-07T23:28:12Z | [
"c#",
"python",
"reflection",
"decorator"
] |
Pyqt GroupBox parenting | 1,391,174 | <p>In Python and Pyqt - I've got a simple class which instantiates a Label class and a GroupBox class. </p>
<p>According to docs, passing the Groupbox to the Label upon creation should make the Groupbox the parent of Label. However, I must be missing something simple here. When I create the GroupBox it's fine, when I ... | 1 | 2009-09-07T22:26:04Z | 1,403,724 | <p>The problem is that you are not using a layout. Because you are not using one, both widgets are being rendered one on top of the other one. It of course depends on what you are trying to do, but the following should be a good example:
<code></p>
<pre><code>class FileBrowser(QMainWindow):
def __init__(self):
... | 2 | 2009-09-10T06:54:57Z | [
"python",
"qt",
"oop",
"pyqt"
] |
Application Structure for GUI & Functions | 1,391,190 | <p>I'm starting a basic application using Python and PyQt and could use some experienced insight. Here's the structure I was thinking. This is understandably subjective, but is there a better way?</p>
<pre><code>myApp/GUI/__init__.py
mainWindow.py
subWindow1.py
subWindow2.py
myApp/Logic/... | 1 | 2009-09-07T22:31:51Z | 1,391,252 | <h2>MVC</h2>
<p>It looks like you have been reading about model-view-controller.</p>
<p>Separating the UI from the back end is a good idea. It will make runnings tests and debugging just the logic side easier, and the internal structure will be more modular.</p>
<p>I'm not certain it makes as much sense to split th... | 1 | 2009-09-07T22:58:53Z | [
"python",
"user-interface",
"structure"
] |
similar function to php's str_replace in python? | 1,391,429 | <p>is there a similar function in python that takes search(array) and replace(array) as a parameter? Then takes a value from each array and uses them to do search and replace on subject(string).</p>
<p>I know I can achieve this using for loops, but just looking more elegant way.</p>
| 2 | 2009-09-08T00:37:49Z | 1,391,466 | <p>I believe the answer is no.</p>
<p>I would specify your search/replace strings in a list, and the iterate over it:</p>
<pre><code>edits = [(search0, replace0), (search1, replace1), (search2, replace2)] # etc.
for search, replace in edits:
s = s.replace(search, replace)
</code></pre>
<p>Even if python did have... | 11 | 2009-09-08T00:48:01Z | [
"python"
] |
similar function to php's str_replace in python? | 1,391,429 | <p>is there a similar function in python that takes search(array) and replace(array) as a parameter? Then takes a value from each array and uses them to do search and replace on subject(string).</p>
<p>I know I can achieve this using for loops, but just looking more elegant way.</p>
| 2 | 2009-09-08T00:37:49Z | 1,391,574 | <p>Do it with regexps:</p>
<pre><code>import re
def replace_from_list(replacements, str):
def escape_string_to_regex(str):
return re.sub(r"([\\.^$*+?{}[\]|\(\)])", r"\\\1", str)
def get_replacement(match):
return replacements[match.group(0)]
replacements = dict(replacements)
replace_... | 1 | 2009-09-08T01:44:53Z | [
"python"
] |
similar function to php's str_replace in python? | 1,391,429 | <p>is there a similar function in python that takes search(array) and replace(array) as a parameter? Then takes a value from each array and uses them to do search and replace on subject(string).</p>
<p>I know I can achieve this using for loops, but just looking more elegant way.</p>
| 2 | 2009-09-08T00:37:49Z | 1,391,771 | <p>Heh - you could use the one-liner below whose elegance is second only to its convenience :-P</p>
<p>(Acts like PHP when search is longer than replace, too, if I read that correctly in the PHP docs.):</p>
<p><strong>** Edit: This new version works for all sized substrings to replace. **</strong></p>
<pre><code>>... | 2 | 2009-09-08T03:11:40Z | [
"python"
] |
easy way of installing python apps without using PYTHON path or muli symlink in site-package | 1,391,584 | <p>I didn't want to install python modules using easy install, symlinks in site-packages or PYTHONPATH.<br>
So, I am trying something that I do wants system wide, then any application installation is done locally. Note, the root password is required only once here.</p>
<p>First create a symblink of.../pythonX.Y/site-p... | 0 | 2009-09-08T01:50:32Z | 1,391,947 | <p>Have a look at <a href="http://pypi.python.org/pypi/virtualenv" rel="nofollow">virtualenv</a>.</p>
<p>It may do what you are after.</p>
| 4 | 2009-09-08T04:19:34Z | [
"python",
"django",
"module",
"pythonpath"
] |
Django: How to create a leaderboard | 1,391,601 | <p>Lets say I have around 1,000,000 users. I want to find out what position any given user is in, and which users are around him. A user can get a new achievement at any time, and if he could see his standing update, that would be wonderful.</p>
<p>Honestly, every way I think of doing this would be horrendously expens... | 8 | 2009-09-08T01:58:50Z | 1,391,622 | <p>I think Counterstrike solves this by requiring users to meet a minimum threshold to become ranked--you only need to accurately sort the top 10% or whatever.</p>
<p>If you want to sort everyone, consider that you don't need to sort them perfectly: sort them to 2 significant figures. With 1M users you could update t... | 4 | 2009-09-08T02:07:59Z | [
"python",
"sql",
"django",
"leaderboard"
] |
Django: How to create a leaderboard | 1,391,601 | <p>Lets say I have around 1,000,000 users. I want to find out what position any given user is in, and which users are around him. A user can get a new achievement at any time, and if he could see his standing update, that would be wonderful.</p>
<p>Honestly, every way I think of doing this would be horrendously expens... | 8 | 2009-09-08T01:58:50Z | 1,395,801 | <p>One million is not so much, I would try it the easy way first. If the points property is the thing you are sorting on that needs to be a database column. Then you can just do a count of points greater than the person in question to get the rank. To get other people near a person in question you do a query of people ... | 0 | 2009-09-08T19:14:35Z | [
"python",
"sql",
"django",
"leaderboard"
] |
Is it possible to deploy one GAE application from another GAE application? | 1,391,608 | <p>In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed... | 3 | 2009-09-08T02:02:11Z | 1,391,649 | <p>One limiting constraint could be the protocol that the python sdk uses to communicate with the GAE servers. If it only uses HTTP, you might be OK. but if it's anything else, you might be out of luck because you can't open a socket directly from within GAE.</p>
| 2 | 2009-09-08T02:21:14Z | [
"python",
"google-app-engine"
] |
Is it possible to deploy one GAE application from another GAE application? | 1,391,608 | <p>In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed... | 3 | 2009-09-08T02:02:11Z | 1,391,652 | <p>What problem did you have by trying to update behind a firewall?</p>
<p>I've got some, but finally I manage to work around them. </p>
<p>About your question, the constraint is that you cannot write files into a GAE app, so even though you could possibly pull from the VCS you can't write those pulled files. </p>
<... | 0 | 2009-09-08T02:22:18Z | [
"python",
"google-app-engine"
] |
Is it possible to deploy one GAE application from another GAE application? | 1,391,608 | <p>In order to redeploy a GAE application, I currently have to install the GAE deployment tools on the system that I am using for deployment. While this process is relatively straight forward, the deployment process is a manual process that does not work from behind a firewall and the deployment tools must be installed... | 3 | 2009-09-08T02:02:11Z | 1,392,766 | <p>Is it possible? Yes. The protocol appcfg uses to update apps is entirely HTTP-based, so there's absolutely no reason you couldn't write an app that's capable of deploying other apps (or redeploying itself - self-modifying code)! You may even be able to reuse large parts of appcfg.py to do it.</p>
<p>Is it easy? Pro... | 5 | 2009-09-08T08:44:38Z | [
"python",
"google-app-engine"
] |
Python web scraping involving HTML tags with attributes | 1,391,657 | <p>I'm trying to make a web scraper that will parse a web-page of publications and extract the authors. The skeletal structure of the web-page is the following:</p>
<pre><code><html>
<body>
<div id="container">
<div id="contents">
<table>
<tbody>
<tr>
<td class="author">... | 6 | 2009-09-08T02:23:25Z | 1,391,752 | <p>It's not clear to me from your question why you need to worry about the <code>div</code> tags -- what about doing just:</p>
<pre><code>soup = BeautifulSoup(html)
thetd = soup.find('td', attrs={'class': 'author'})
print thetd.string
</code></pre>
<p>On the HTML you give, running this emits exactly:</p>
<pre><code>... | 10 | 2009-09-08T03:01:06Z | [
"python",
"beautifulsoup",
"lxml",
"screen-scraping"
] |
Python web scraping involving HTML tags with attributes | 1,391,657 | <p>I'm trying to make a web scraper that will parse a web-page of publications and extract the authors. The skeletal structure of the web-page is the following:</p>
<pre><code><html>
<body>
<div id="container">
<div id="contents">
<table>
<tbody>
<tr>
<td class="author">... | 6 | 2009-09-08T02:23:25Z | 1,391,820 | <p>BeautifulSoup is certainly the canonical HTML parser/processor. But if you have just this kind of snippet you need to match, instead of building a whole hierarchical object representing the HTML, pyparsing makes it easy to define leading and trailing HTML tags as part of creating a larger search expression:</p>
<p... | 1 | 2009-09-08T03:31:52Z | [
"python",
"beautifulsoup",
"lxml",
"screen-scraping"
] |
Python web scraping involving HTML tags with attributes | 1,391,657 | <p>I'm trying to make a web scraper that will parse a web-page of publications and extract the authors. The skeletal structure of the web-page is the following:</p>
<pre><code><html>
<body>
<div id="container">
<div id="contents">
<table>
<tbody>
<tr>
<td class="author">... | 6 | 2009-09-08T02:23:25Z | 2,752,712 | <p>or you could be using pyquery, since BeautifulSoup is not actively maintained anymore, see <a href="http://www.crummy.com/software/BeautifulSoup/3.1-problems.html">http://www.crummy.com/software/BeautifulSoup/3.1-problems.html</a></p>
<p>first, install pyquery with </p>
<pre><code>easy_install pyquery
</code></pre... | 6 | 2010-05-02T07:01:44Z | [
"python",
"beautifulsoup",
"lxml",
"screen-scraping"
] |
Python web scraping involving HTML tags with attributes | 1,391,657 | <p>I'm trying to make a web scraper that will parse a web-page of publications and extract the authors. The skeletal structure of the web-page is the following:</p>
<pre><code><html>
<body>
<div id="container">
<div id="contents">
<table>
<tbody>
<tr>
<td class="author">... | 6 | 2009-09-08T02:23:25Z | 5,882,262 | <p>The lxml library is now the standard for parsing html in python. The interface can seem awkward at first, but it is very serviceable for what it does. </p>
<p>You should let the libary handle the xml specialism, such as those escaped &entities;</p>
<pre><code>import lxml.html
html = """<html><body>&... | 5 | 2011-05-04T10:51:34Z | [
"python",
"beautifulsoup",
"lxml",
"screen-scraping"
] |
How can I run gtk.main() asynchronsly in pygtk? | 1,391,680 | <p>The basic code that I have so far is below. How do I thread gtk.main() so that the code after Display is initialized runs asynchronously?</p>
<pre><code>import pygtk
pygtk.require("2.0")
import gtk
class Display():
def __init__(self):
self.fail = "This will fail to display"
window = gtk.Window... | 0 | 2009-09-08T02:33:36Z | 1,394,773 | <p>Just put the <code>gtk.main</code> call after everything else.
If you need to have the controller in a separate thread, make sure you do all gtk related function/methods by doing gobject.idle_add(<em>widget.method</em>).</p>
<pre><code>import pygtk
pygtk.require("2.0")
import gtk
class Display(object):
def __... | 0 | 2009-09-08T15:50:59Z | [
"python",
"multithreading",
"pygtk"
] |
How can I run gtk.main() asynchronsly in pygtk? | 1,391,680 | <p>The basic code that I have so far is below. How do I thread gtk.main() so that the code after Display is initialized runs asynchronously?</p>
<pre><code>import pygtk
pygtk.require("2.0")
import gtk
class Display():
def __init__(self):
self.fail = "This will fail to display"
window = gtk.Window... | 0 | 2009-09-08T02:33:36Z | 3,405,343 | <p>You could use Twisted with the gtk2reactor. </p>
<p><a href="http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html" rel="nofollow">http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html</a></p>
| 0 | 2010-08-04T12:12:23Z | [
"python",
"multithreading",
"pygtk"
] |
how to encode a key in mime format | 1,392,194 | <p>if the key is in ascii armored form ,taken by any pgp public key server and i want to convert it in mime encoded format.how to do ?is there any python api methods ?</p>
<p>thnks a lot</p>
| 0 | 2009-09-08T05:44:59Z | 1,392,395 | <p>What do you mean by MIME encoded? Please elaborate.</p>
<p>Did you ask the same question already? See my answer to other question about PEM,</p>
<p><a href="http://stackoverflow.com/questions/1387867/how-to-convert-base64-radix64-public-key-to-a-pem-format-in-python">http://stackoverflow.com/questions/1387867/how-... | 0 | 2009-09-08T07:00:08Z | [
"python",
"encoding"
] |
Advantages of UserDict class in Python | 1,392,396 | <p>What are advantages of using <strong>UserDict</strong> class?</p>
<p>I mean, what I really get if instead of</p>
<pre><code>class MyClass(object):
def __init__(self):
self.a = 0
self.b = 0
...
m = MyClass()
m.a = 5
m.b = 7
</code></pre>
<p>I will write the following:</p>
<pre><code>class MyCl... | 9 | 2009-09-08T07:00:17Z | 1,392,402 | <p>Subclassing the dict gives you all the features of a dict, like <code>if x in dict:</code>. You normally do this if you want to extend the features of the dict, creating an ordered dict for example.</p>
<p>BTW: In more recent Python versions you can subclass <code>dict</code> directly, you don't need <code>UserDict... | 6 | 2009-09-08T07:03:36Z | [
"python",
"oop"
] |
Advantages of UserDict class in Python | 1,392,396 | <p>What are advantages of using <strong>UserDict</strong> class?</p>
<p>I mean, what I really get if instead of</p>
<pre><code>class MyClass(object):
def __init__(self):
self.a = 0
self.b = 0
...
m = MyClass()
m.a = 5
m.b = 7
</code></pre>
<p>I will write the following:</p>
<pre><code>class MyCl... | 9 | 2009-09-08T07:00:17Z | 1,394,572 | <p><a href="http://docs.python.org/library/userdict.html?#UserDict.UserDict"><code>UserDict.UserDict</code> has no substantial added value since Python 2.2, since, as @gs mention, you can now subclass <code>dict</code> directly -- it exists only for backwards compatibility with Python 2.1 and earlier, when builtin type... | 25 | 2009-09-08T15:11:39Z | [
"python",
"oop"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 1,392,549 | <p>This grabs subdirectories:</p>
<pre><code>import os
def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
print get_siz... | 104 | 2009-09-08T07:48:15Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 1,776,987 | <p>monknut answer is good but it fails on broken symlink, so you also have to check if this path really exists</p>
<pre><code>if os.path.exists(fp):
total_size += os.stat(fp).st_size
</code></pre>
| 5 | 2009-11-21T22:24:26Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 1,777,225 | <p>for getting the size of one file, there is os.path.getsize()</p>
<pre><code>>>> import os
>>> os.path.getsize("/path/file")
35L
</code></pre>
<p>its reported in bytes.</p>
| 0 | 2009-11-21T23:57:12Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 4,368,431 | <p>Here is a recursive function (it recursively sums up the size of all subfolders and their respective files) which returns exactly the same bytes as when running "du -sb ." in linux (where the "." means "the current folder"):</p>
<pre><code>import os
def getFolderSize(folder):
total_size = os.path.getsize(folde... | 13 | 2010-12-06T16:12:22Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 12,984,676 | <p>The accepted answer doesn't take into account hard or soft links, and would count those files twice. You'd want to keep track of which inodes you've seen, and not add the size for those files.</p>
<pre><code>import os
def get_size(start_path='.'):
total_size = 0
seen = {}
for dirpath, dirnames, filenam... | 4 | 2012-10-20T02:18:48Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 13,475,351 | <p>You can do something like this : </p>
<pre><code>import commands
size = commands.getoutput('du -sh /path/').split()[0]
</code></pre>
<p>in this case I have not tested the result before returning it, if you want you can check it with commands.getstatusoutput.</p>
| 3 | 2012-11-20T14:30:24Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 17,936,789 | <p>Chris' answer is good but could be made more idiomatic by using a set to check for seen directories, which also avoids using an exception for control flow:</p>
<pre><code>def directory_size(path):
total_size = 0
seen = set()
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:... | 4 | 2013-07-30T01:09:50Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 18,763,675 | <p>a recursive one-liner:</p>
<pre><code>def getFolderSize(p):
from functools import partial
prepend = partial(os.path.join, p)
return sum([(os.path.getsize(f) if os.path.isfile(f) else getFolderSize(f)) for f in map(prepend, os.listdir(p))])
</code></pre>
| 2 | 2013-09-12T11:58:01Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 23,850,720 | <pre><code>import os
def get_size(path):
total_size = 0
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:
if os.path.exists(fp):
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size # in megabytes
</cod... | 0 | 2014-05-24T23:46:34Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 24,341,821 | <p>This script tells you which file is the biggest in the CWD and also tells you in which folder the file is.
This script works for me on win8 and python 3.3.3 shell</p>
<pre><code>import os
folder=os.cwd()
number=0
string=""
for root, dirs, files in os.walk(folder):
for file in files:
pathname=os.path.... | 0 | 2014-06-21T12:56:07Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 25,574,638 | <p>Some of the approaches suggested so far implement a recursion, others employ a shell or will not produce neatly formatted results. When your code is one-off for Linux platforms, you can get formatting as usual, recursion included, as a one-liner. Except for the <code>print</code> in the last line, it will work for c... | 13 | 2014-08-29T19:00:48Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 25,666,231 | <p>For the second part of the question</p>
<pre><code>def human(size):
B = "B"
KB = "KB"
MB = "MB"
GB = "GB"
TB = "TB"
UNITS = [B, KB, MB, GB, TB]
HUMANFMT = "%f %s"
HUMANRADIX = 1024.
for u in UNITS[:-1]:
if size < HUMANRADIX : return HUMANFMT % (size, u)
size... | 3 | 2014-09-04T13:01:07Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 29,611,830 | <p>One-liner you say...
Here is a one liner:</p>
<pre><code>sum([sum(map(lambda fname: os.path.getsize(os.path.join(directory, fname)), files)) for directory, folders, files in os.walk(path)])
</code></pre>
<p>Although I would probably split it out and it performs no checks.</p>
<p>To convert to kb see <a href="http... | 1 | 2015-04-13T17:53:19Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 34,580,785 | <p>The following script prints directory size of all sub-directories for the specified directory. It also tries to benefit (if possible) from caching the calls of a recursive functions. If an argument is omitted, the script will work in the current directory. The output is sorted by the directory size from biggest to s... | 1 | 2016-01-03T19:36:43Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 37,367,965 | <p>Python 3.5 recursive folder size using <code>os.scandir</code></p>
<pre><code>def folder_size(path='.'):
total = 0
for entry in os.scandir(path):
if entry.is_file():
total += entry.stat().st_size
elif entry.is_dir():
total += folder_size(entry.path)
return total
<... | 0 | 2016-05-21T21:01:22Z | [
"python",
"directory"
] |
Calculating a directory size using Python? | 1,392,413 | <p>Before i re-invent this particular wheel, has anybody got a nice routine for calculating the size of a directory using Python? It would be very nice if the routine would format the size nicely in Mb/Gb etc.</p>
| 78 | 2009-09-08T07:06:42Z | 39,615,417 | <p>A little late to the party but in one line provided that you have <a href="https://pypi.python.org/pypi/glob2" rel="nofollow">glob2</a> and <a href="https://pypi.python.org/pypi/humanize" rel="nofollow">humanize</a> installed. Note that in Python 3, the default <code>iglob</code> has a recursive mode. How to modify ... | 0 | 2016-09-21T11:32:50Z | [
"python",
"directory"
] |
Python: Why is ("hello" is "hello")? | 1,392,433 | <p>Why is <code>"hello" is "hello" == True</code> in Python?</p>
<p>I read the following <a href="http://zetcode.com/tutorials/pythontutorial/keywords/" rel="nofollow">here</a>:</p>
<blockquote>
<p>If two string literals are equal, they have been put to same
memory location. A string is an immutable entity. No h... | 48 | 2009-09-08T07:13:19Z | 1,392,437 | <p>Why is it strange. If the string is immutable it makes a lot of sense to only store it once. .NET has the same behavior. </p>
| 0 | 2009-09-08T07:14:42Z | [
"python",
"identity"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.