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
Need a Python package suitable for visualizing queue simulations
1,820,939
<p>I am working on a simulation in Queueing Theory, within a wxPython GUI. (<a href="http://garlicsim.org" rel="nofollow">Project link</a>.) What would be a good tool for visualizing the simulations? The visualization should consist of simple objects, such as clients, servers, a facility and a population. They should a...
3
2009-11-30T16:43:58Z
1,822,201
<p>You could try using one of the Python bindings for GraphViz. I could see something like this <a href="http://www.graphviz.org/Gallery/directed/cluster.html" rel="nofollow">http://www.graphviz.org/Gallery/directed/cluster.html</a> being used to illustrate a queue simulation.</p> <p>I use Pydot and its gret: <a href=...
0
2009-11-30T20:24:37Z
[ "python", "wxpython", "visualization", "simulation", "scientific-computing" ]
Need a Python package suitable for visualizing queue simulations
1,820,939
<p>I am working on a simulation in Queueing Theory, within a wxPython GUI. (<a href="http://garlicsim.org" rel="nofollow">Project link</a>.) What would be a good tool for visualizing the simulations? The visualization should consist of simple objects, such as clients, servers, a facility and a population. They should a...
3
2009-11-30T16:43:58Z
1,822,569
<p>I would consider using <a href="http://vpython.org/" rel="nofollow">VPython</a>. You could also create a dynamic graphic in Java using <a href="http://processing.org" rel="nofollow">Processing</a>, and have the simulation send update messages through your network protocol of choice.</p>
0
2009-11-30T21:36:15Z
[ "python", "wxpython", "visualization", "simulation", "scientific-computing" ]
Django: check whether an object already exists before adding
1,821,176
<p>This is a pretty simple Django question, but I can't find the answer in the Django docs, despite lots of hunting!</p> <p>How do I check whether an object already exists, and only add it if it does <em>not</em> already exist?</p> <p>Here's the code - I don't want to add the follow_role twice in the database if it a...
21
2009-11-30T17:26:39Z
1,821,247
<p>There's a helper function for this idiom called 'get_or_create' on your model manager:</p> <pre><code>role, created = UserToUserRole.objects.get_or_create( from_user=current_user, to_user=user, role='follow') </code></pre> <p>It returns a tuple of (model, bool) where 'model' is the object you're interested in ...
32
2009-11-30T17:39:15Z
[ "python", "django" ]
Django: check whether an object already exists before adding
1,821,176
<p>This is a pretty simple Django question, but I can't find the answer in the Django docs, despite lots of hunting!</p> <p>How do I check whether an object already exists, and only add it if it does <em>not</em> already exist?</p> <p>Here's the code - I don't want to add the follow_role twice in the database if it a...
21
2009-11-30T17:26:39Z
1,821,262
<p>If you're using a recent version of Django, you can use the <a href="http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together" rel="nofollow">unique_together</a> option to the UserToUserRole model, and then use the get_or_create() method Joe Holloway showed. This will guarantee that you can't get a d...
4
2009-11-30T17:42:02Z
[ "python", "django" ]
Django: check whether an object already exists before adding
1,821,176
<p>This is a pretty simple Django question, but I can't find the answer in the Django docs, despite lots of hunting!</p> <p>How do I check whether an object already exists, and only add it if it does <em>not</em> already exist?</p> <p>Here's the code - I don't want to add the follow_role twice in the database if it a...
21
2009-11-30T17:26:39Z
1,821,272
<p>If you want the check done every time before save you could use the pre save signal to check, <a href="http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre%5Fsave" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.pre%5Fsave</a></p> <p>Alternatively ...
0
2009-11-30T17:43:59Z
[ "python", "django" ]
How to get unicode month name in Python?
1,821,204
<p>I am trying to get a unicode version of <code>calendar.month_abbr[6]</code>. If I don't specify an encoding for the locale, I don't know how to convert the string to unicode. The example code below shows my problem:</p> <pre><code>&gt;&gt;&gt; import locale &gt;&gt;&gt; import calendar &gt;&gt;&gt; locale.setlocale...
3
2009-11-30T17:31:20Z
1,821,292
<p>Change the last line in your code:</p> <pre><code>&gt;&gt;&gt; print calendar.month_abbr[6].decode("utf8") Июн </code></pre> <p>Improperly used <a href="http://docs.python.org/library/functions.html#repr"><code>repr()</code></a> hides from you that you already get what you needed.</p> <p>Also <code>getlocale()...
12
2009-11-30T17:48:29Z
[ "python", "unicode" ]
How to get unicode month name in Python?
1,821,204
<p>I am trying to get a unicode version of <code>calendar.month_abbr[6]</code>. If I don't specify an encoding for the locale, I don't know how to convert the string to unicode. The example code below shows my problem:</p> <pre><code>&gt;&gt;&gt; import locale &gt;&gt;&gt; import calendar &gt;&gt;&gt; locale.setlocale...
3
2009-11-30T17:31:20Z
1,822,383
<p>What you need is:</p> <pre><code>… myencoding= locale.getpreferredencoding() print repr(calendar.month_abbr[6].decode(myencoding)) … </code></pre>
0
2009-11-30T21:03:47Z
[ "python", "unicode" ]
Unique UUIDs from multiple processes on same machine
1,821,399
<p>To tag the data we create, I'm considering using uuids. Security is not an issue, so I was going to use version 1 (date-and-mac-address-based). The only concern is that each user may be creating multiple data files at once from different processes with multiple threads. Assuming Python's uuid library is thread-sa...
3
2009-11-30T18:05:38Z
1,821,594
<p>Just use <a href="http://docs.python.org/library/uuid.html#uuid.uuid4" rel="nofollow">uuid4</a> for completely random UUIDs. There is no need to worry about collisions.</p> <p><strong>edit in response to comment</strong>: In my experience, redundant data leads to inconsistencies sooner or later. There is a reason t...
2
2009-11-30T18:39:27Z
[ "python", "uuid" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,499
<pre><code>import itertools for item in itertools.chain(("one","two"), ("bad","good")): print item </code></pre> <p>will produce the desired output with just one <code>for</code> loop.</p>
3
2009-11-30T18:26:08Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,504
<p>Not the best, but:</p> <pre><code>for i in a: some_function([x for x in i]) def some_function(args): for o in args: print o </code></pre>
0
2009-11-30T18:27:12Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,511
<p>List comprehensions and generators are only designed to be used as expressions, while printing is a statement. While you can effect what you're trying to do by doing</p> <pre><code>from __future__ import print_function for x in a: [print(each) for each in x] </code></pre> <p>doing so is amazingly unpythonic, ...
7
2009-11-30T18:27:53Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,524
<p>You'll need to define your own print method (or import <code>__future__.print_function</code>)</p> <pre><code>def pp(x): print x for i in a: _ = [pp(x) for x in i] </code></pre> <p>Note the <code>_</code> is used to indicate that the returned list is to be ignored.</p>
1
2009-11-30T18:29:24Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,532
<p>Given your example you could do something like this:</p> <pre><code>a = [("one","two"), ("bad","good")] for x in sum(map(list, a), []): print x </code></pre> <p>This can, however, become quite slow once the list gets big.</p> <p>The better way to do it would be like <a href="http://stackoverflow.com/users/20...
7
2009-11-30T18:30:21Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,617
<p>The print function really is superior, but here is a much more pythonic suggestion inspired by Benjamin Pollack's answer:</p> <pre><code>from __future__ import print_function for x in a: print(*x, sep="\n") </code></pre> <p>Simply use <code>*</code> to unpack the list x as arguments to the function, and use ne...
3
2009-11-30T18:43:23Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,821,618
<p>This code is straightforward and simpler than other solutions here:</p> <pre><code>for i in a: print '\n'.join([x for x in i]) </code></pre>
1
2009-11-30T18:43:34Z
[ "python", "loops", "nested" ]
Python: Nested Loop
1,821,471
<p>Consider this:</p> <pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; for i in a: ... for x in i: ... print x ... one two bad good </code></pre> <p>How can I write this code, but using a syntax like:</p> <pre><code>for i in a: print [x for x in i] </code></pre> <p>Obviousl...
2
2009-11-30T18:20:42Z
1,822,495
<pre><code>&gt;&gt;&gt; a = [("one","two"), ("bad","good")] &gt;&gt;&gt; print "\n".join(j for i in a for j in i) one two bad good &gt;&gt;&gt; for i in a: ... print "\n".join(i) ... one two bad good </code></pre>
4
2009-11-30T21:25:20Z
[ "python", "loops", "nested" ]
sqlalchemy does not create my foreign key
1,821,527
<p>SqlAlchemy newbie question:</p> <pre><code>Base = declarative_base() class A(Base): __tablename__ = 'as' id = Column(Integer, primary_key=True) class B(Base): __tablename__ = 'bs' id = Column(Integer, primary_key=True) a = relation(A) </code></pre> <p>When I create my database schema, I have ...
3
2009-11-30T18:29:39Z
1,821,609
<p><code>relation()</code> only tells the mapper how are the two tables related. You still need to add a column with the foreign key information. For example:</p> <pre><code>class B(Base): __tablename__ = 'bs' id = Column(Integer, primary_key=True) a_id = Column(Integer, ForeignKey('as.id'), name="a") ...
5
2009-11-30T18:42:11Z
[ "python", "mysql", "orm", "sqlalchemy" ]
Making Windows executables from Django applications
1,821,632
<p>I am trying to make a Django website be a simple Windows executable. I've been told that <code>py2exe</code> does not work correctly, both due to Django using <code>__import__</code>, and to its attempting to dispatch <code>manage.py</code> in some obscure way. Is that the case? If so, is there an alternative too...
4
2009-11-30T18:45:23Z
1,821,670
<p>You can try <a href="http://www.pyinstaller.org/wiki/DjangoApplication" rel="nofollow">Pyinstaller</a>.</p>
2
2009-11-30T18:52:18Z
[ "python", "django", "py2exe" ]
Making Windows executables from Django applications
1,821,632
<p>I am trying to make a Django website be a simple Windows executable. I've been told that <code>py2exe</code> does not work correctly, both due to Django using <code>__import__</code>, and to its attempting to dispatch <code>manage.py</code> in some obscure way. Is that the case? If so, is there an alternative too...
4
2009-11-30T18:45:23Z
1,918,185
<p>PyInstaller trunk has been succesfully used to build Django applications. It has builtin support for many Django magic, but requires a careful setup (have a look at the <a href="https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django" rel="nofollow">dedicated wiki page</a>).</p>
0
2009-12-16T22:15:13Z
[ "python", "django", "py2exe" ]
Using scons to perform validation
1,822,055
<p>My company is switching from make to scons. Part of our make process is to call xmllint on a number of xml files to validate them against a schema.</p> <p>I've got the following in my SConstruct:</p> <pre><code>import os; Env = DefaultEnvironment() pwd = Dir('.').path xmlValidator = Builder(action = 'xmllint --no...
1
2009-11-30T19:58:57Z
1,824,818
<p>You need to provide scons with an input file. You currently have the source file hard-coded into the builder "recipe". It is better to use the SOURCE placeholder in the action string and then specify the input file when you call the builder.</p> <pre><code>xmlValidator = Builder(action='xmllint --noout --schema '+ ...
2
2009-12-01T08:46:52Z
[ "python", "scons" ]
Asynchronously read stdout from subprocess.Popen
1,822,237
<p>I am running a sub-program using subprocess.popen. When I start my Python program from the command window (cmd.exe), the program writes some info and dates in the window as the program evolves.</p> <p>When I run my Python code <em>not</em> in a command window, it opens a new command window for this sub-program's o...
6
2009-11-30T20:34:26Z
2,310,428
<p>Use this:</p> <pre><code>cmd = subprocess.Popen(["c:/flow/flow.exe"], stdout=subprocess.PIPE) for line in cmd.stdout: print line.rstrip("\n") cmd.wait() # you may already be handling this in your current code </code></pre> <p>Note that you will still have to wait for the sub-program to flush its stdout buffer...
6
2010-02-22T11:08:14Z
[ "python", "windows", "subprocess" ]
Asynchronously read stdout from subprocess.Popen
1,822,237
<p>I am running a sub-program using subprocess.popen. When I start my Python program from the command window (cmd.exe), the program writes some info and dates in the window as the program evolves.</p> <p>When I run my Python code <em>not</em> in a command window, it opens a new command window for this sub-program's o...
6
2009-11-30T20:34:26Z
5,600,616
<p>It is an old post, but a common problem with a hard to find solution. Try this: <a href="http://code.activestate.com/recipes/440554-module-to-allow-asynchronous-subprocess-use-on-win/" rel="nofollow">http://code.activestate.com/recipes/440554-module-to-allow-asynchronous-subprocess-use-on-win/</a></p>
0
2011-04-08T20:46:38Z
[ "python", "windows", "subprocess" ]
Asynchronously read stdout from subprocess.Popen
1,822,237
<p>I am running a sub-program using subprocess.popen. When I start my Python program from the command window (cmd.exe), the program writes some info and dates in the window as the program evolves.</p> <p>When I run my Python code <em>not</em> in a command window, it opens a new command window for this sub-program's o...
6
2009-11-30T20:34:26Z
7,946,505
<p>Looking for a recipe to process Popen data asynchronously I stumbled upon <a href="http://code.activestate.com/recipes/576759-subprocess-with-async-io-pipes-class/" rel="nofollow">http://code.activestate.com/recipes/576759-subprocess-with-async-io-pipes-class/</a></p> <p>This looks quite promising, however I got th...
1
2011-10-30T17:18:58Z
[ "python", "windows", "subprocess" ]
Find and replace multiple strings in file then output to new filename python
1,822,307
<p>I am looking to create a python script that will read one source file then produce another file with a string for the name. </p> <p>for example </p> <p>macaddress.cnf.xml contains the source file </p> <p>I need to change '6000' to '6001' in multiple places of macaddress.cnf.xml, then I want to output to newmacadd...
-1
2009-11-30T20:50:45Z
1,822,456
<p>It is unclear from your question what all of your goals are, but I will try to address some of them. If you want to take input from one file, modify it, and then write to another file you could do following: </p> <pre><code>buffer = ""; with open("input_file") as in: buffer = in.read(); # do modifications ......
1
2009-11-30T21:17:39Z
[ "python", "full-text-search", "replace" ]
Find and replace multiple strings in file then output to new filename python
1,822,307
<p>I am looking to create a python script that will read one source file then produce another file with a string for the name. </p> <p>for example </p> <p>macaddress.cnf.xml contains the source file </p> <p>I need to change '6000' to '6001' in multiple places of macaddress.cnf.xml, then I want to output to newmacadd...
-1
2009-11-30T20:50:45Z
1,822,599
<pre><code>data=open("input_file").read() outfile=open("macaddressfromcsv.cnf.xml","w") for i in range(6001,6010): outfile.write(data.replace("6000",str(i)) outfile.write("\n") # you may not need this outfile.close() </code></pre> <p>Edit. I think you need to clarify the question. Is there only one output file...
0
2009-11-30T21:44:00Z
[ "python", "full-text-search", "replace" ]
Simple question about numpy matrix in python
1,822,417
<p>Let's suppose I have a numpy matrix variable called MATRIX with 3 coordinates: (x, y, z).</p> <p>Is acessing the matrix's value through the following code</p> <pre><code>myVar = MATRIX[0,0,0] </code></pre> <p>equal to</p> <pre><code>myVar = MATRIX[0,0][0] </code></pre> <p>or</p> <pre><code>myVar = MATRIX[0][0,...
0
2009-11-30T21:11:15Z
1,822,441
<p>It's not possible to index a tuple with another tuple, so none of that code is valid.</p>
1
2009-11-30T21:14:48Z
[ "python", "numpy" ]
Simple question about numpy matrix in python
1,822,417
<p>Let's suppose I have a numpy matrix variable called MATRIX with 3 coordinates: (x, y, z).</p> <p>Is acessing the matrix's value through the following code</p> <pre><code>myVar = MATRIX[0,0,0] </code></pre> <p>equal to</p> <pre><code>myVar = MATRIX[0,0][0] </code></pre> <p>or</p> <pre><code>myVar = MATRIX[0][0,...
0
2009-11-30T21:11:15Z
1,822,494
<p>I assume you have a <code>array</code> instance rather than a <code>matrix</code>, since the latter only can have two dimensions.</p> <p><code>m[0, 0, 0]</code> gets the element at position (0, 0, 0). <code>m[0, 0]</code> gets a whole subarray (a slice), which is itself a <code>array</code>. You can get the first e...
6
2009-11-30T21:25:06Z
[ "python", "numpy" ]
How do I send and receive real-time signals `sigqueue()` in Python?
1,822,449
<p>Python provides a <code>signals</code> module and <code>os.kill</code>; does it have a facility for <code>sigqueue()</code> (real-time signals with attached data)? What are the alternatives?</p>
2
2009-11-30T21:16:23Z
1,822,523
<p>One alternative, if no one has done it yet, would be to wrap the C library yourself - should be pretty quick and painless. <a href="http://www.python.org/doc/2.5.2/ext/intro.html" rel="nofollow">Look here</a> for more details.</p>
2
2009-11-30T21:29:49Z
[ "python", "unix", "ipc", "signals" ]
How do I send and receive real-time signals `sigqueue()` in Python?
1,822,449
<p>Python provides a <code>signals</code> module and <code>os.kill</code>; does it have a facility for <code>sigqueue()</code> (real-time signals with attached data)? What are the alternatives?</p>
2
2009-11-30T21:16:23Z
1,822,807
<p>You could do it with <a href="http://docs.python.org/library/ctypes.html" rel="nofollow">ctypes</a></p> <pre><code>&gt;&gt;&gt; from ctypes import * &gt;&gt;&gt; c = cdll.LoadLibrary("libc.so.6") &gt;&gt;&gt; c.sigqueue &lt;_FuncPtr object at 0xb7dbd77c&gt; &gt;&gt;&gt; c.sigqueue(100, 10, 0) -1 &gt;&gt;&gt; </code...
3
2009-11-30T22:20:09Z
[ "python", "unix", "ipc", "signals" ]
Is RLock a sensible default over Lock?
1,822,541
<p>the threading module in Python provides two kinds of locks: A common lock and a reentrant lock. It seems to me, that if I need a lock, I should always prefer the RLock over the Lock; mainly to prevent deadlock situations.</p> <p>Besides that, I see two points, when to prefer a Lock over a RLock:</p> <ul> <li>RLock...
11
2009-11-30T21:32:42Z
1,822,925
<p>Normally you should structure your code such that you never need to recursively lock in normal operation (basically it forces you to use locks tightly around the protected datastructures they are are protecting). Therefore you want to catch an anomalous recursive locking. </p>
3
2009-11-30T22:39:46Z
[ "python", "multithreading" ]
Is RLock a sensible default over Lock?
1,822,541
<p>the threading module in Python provides two kinds of locks: A common lock and a reentrant lock. It seems to me, that if I need a lock, I should always prefer the RLock over the Lock; mainly to prevent deadlock situations.</p> <p>Besides that, I see two points, when to prefer a Lock over a RLock:</p> <ul> <li>RLock...
11
2009-11-30T21:32:42Z
1,977,542
<p>Two points:</p> <ul> <li>In officially released Python versions (2.4, 2.5... up to 3.1), an RLock is much slower than a Lock, because Locks are implemented in C and RLocks in Python (this will change in 3.2)</li> <li>A Lock can be released from any thread (not necessarily the thread which acquire()d it), while an R...
10
2009-12-29T23:21:09Z
[ "python", "multithreading" ]
How to send status to the VIM status line after calling custom VIM (Python) function
1,822,619
<p>I've just created my first VIM script, I wrote it in Python. It's a simple script to switch color schemes from a directory (/vim/etc/colors). I would like to know how to send a notification after the color scheme changed with the name of the selected color scheme to the vim 'statusline'.</p> <p>rson gave an answer ...
2
2009-11-30T21:47:10Z
1,822,706
<p><code>vim.command('redraw | echo "%s"' % colorschemes[position])</code></p> <p>From <code>:help echo</code>:</p> <blockquote> <p>A later redraw may make the message disappear again. And since Vim mostly postpones redrawing until it's finished with a sequence of commands this happens quite often. To avoid ...
5
2009-11-30T22:03:12Z
[ "python", "vim", "scripting", "color-scheme" ]
How to send status to the VIM status line after calling custom VIM (Python) function
1,822,619
<p>I've just created my first VIM script, I wrote it in Python. It's a simple script to switch color schemes from a directory (/vim/etc/colors). I would like to know how to send a notification after the color scheme changed with the name of the selected color scheme to the vim 'statusline'.</p> <p>rson gave an answer ...
2
2009-11-30T21:47:10Z
1,824,827
<p>Since you are updating the script here,</p> <p>Instead of </p> <pre><code>if argument == 'next': position += 1 if position == len(colorschemes) - 1: position = 0 elif argument == 'prev': position -= 1 if position == -1: position = len(colorschemes) - 1 </code></pre> <p>Perhaps</p> ...
1
2009-12-01T08:49:08Z
[ "python", "vim", "scripting", "color-scheme" ]
Python integer to read-only buffer
1,822,709
<p>I am using cdb for a constant database in python. I would like to associate integer id's with some strings, and I would like to avoid storing each of these integer id's as strings, and instead store them as an integer. cdb though is looking for either a string or a read only buffer. Is there a way that I can stor...
2
2009-11-30T22:03:19Z
1,822,747
<p>According to the <a href="http://cr.yp.to/cdb/cdb.txt" rel="nofollow">cdb website</a> the database only takes strings as keys</p> <blockquote> <p>A cdb is an associative array: it maps strings (keys) to strings (data).</p> </blockquote> <p>So you will have to convert the integers to strings first. I suggest you...
4
2009-11-30T22:09:58Z
[ "python", "binary", "cdb" ]
Parsing dates from free-text input in Python
1,822,787
<p>I'm about to start working on a simple calendar app for a website I'm working on (using Django, but that fact's probably not relevant).</p> <p>I'd like users to be able to enter when an event is in a text box like this:</p> <ul> <li>Every Sunday evening at 7pm</li> <li>Next Friday</li> <li>Tuesday 1st Dec 2009</li...
1
2009-11-30T22:16:20Z
1,822,848
<p>There is <a href="http://code.google.com/p/parsedatetime/" rel="nofollow">http://code.google.com/p/parsedatetime/</a> </p>
4
2009-11-30T22:26:23Z
[ "python", "datetime" ]
Parsing dates from free-text input in Python
1,822,787
<p>I'm about to start working on a simple calendar app for a website I'm working on (using Django, but that fact's probably not relevant).</p> <p>I'd like users to be able to enter when an event is in a text box like this:</p> <ul> <li>Every Sunday evening at 7pm</li> <li>Next Friday</li> <li>Tuesday 1st Dec 2009</li...
1
2009-11-30T22:16:20Z
1,822,962
<p>I proposed a pyparsing solution to <a href="http://stackoverflow.com/questions/1258712/fuzzy-timestamp-parsing-with-python/1378134#1378134">this question</a>, which seems similar to yours.</p>
2
2009-11-30T22:47:29Z
[ "python", "datetime" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
1,823,089
<p>I'm sure there must be a standard library function for this, but it was fun to try to write it myself using recursion so here's what I came up with:</p> <pre><code>def intToStringWithCommas(x): if type(x) is not int and type(x) is not long: raise TypeError("Not an integer!") if x &lt; 0: ret...
11
2009-11-30T23:19:53Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
1,823,101
<p>I got this to work:</p> <pre><code>&gt;&gt;&gt; import locale &gt;&gt;&gt; locale.setlocale(locale.LC_ALL, 'en_US') 'en_US' &gt;&gt;&gt; locale.format("%d", 1255000, grouping=True) '1,255,000' </code></pre> <p>Sure, you don't <em>need</em> internationalization support, but it's clear, concise, and uses a built-in ...
198
2009-11-30T23:22:13Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
1,823,113
<p>Just subclass long (or float, or whatever). This is highly practical, because this way you can still use your numbers in math ops (and therefore existing code), but they will all print nicely in your terminal. </p> <pre><code>&gt;&gt;&gt; class number(long): def __init__(self, value): self = va...
0
2009-11-30T23:25:23Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
1,823,189
<p>Here is the locale grouping code after removing irrelevant parts and cleaning it up a little:</p> <p>(The following only works for integers)</p> <pre><code>def group(number): s = '%d' % number groups = [] while s and s[-1].isdigit(): groups.append(s[-3:]) s = s[:-3] return s + ','.j...
73
2009-11-30T23:42:26Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
4,113,289
<p>Here's one that works for floats too:</p> <pre><code>def float2comma(f): s = str(abs(f)) # Convert to a string decimalposition = s.find(".") # Look for decimal point if decimalposition == -1: decimalposition = len(s) # If no decimal, then just work from the end out = "" for i in range(d...
2
2010-11-06T13:33:49Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
4,205,875
<p>From the <a href="http://code.activestate.com/recipes/498181-add-thousands-separator-commas-to-formatted-number/#c3">comments</a> to activestate recipe <a href="http://code.activestate.com/recipes/498181-add-thousands-separator-commas-to-formatted-number/">498181</a> I reworked this:</p> <pre><code>import re def th...
8
2010-11-17T15:19:15Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
8,571,035
<p>For floats:</p> <pre><code>float(filter(lambda x: x!=',', '1,234.52')) # returns 1234.52 </code></pre> <p>For ints:</p> <pre><code>int(filter(lambda x: x!=',', '1,234')) # returns 1234 </code></pre>
-4
2011-12-20T05:03:21Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
8,932,161
<p>For inefficiency and unreadability it's hard to beat:</p> <pre><code>&gt;&gt;&gt; import itertools &gt;&gt;&gt; s = '-1234567' &gt;&gt;&gt; ','.join(["%s%s%s" % (x[0], x[1] or '', x[2] or '') for x in itertools.izip_longest(s[::-1][::3], s[::-1][1::3], s[::-1][2::3])])[::-1].replace('-,','-') </code></pre>
63
2012-01-19T19:35:28Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
9,505,119
<p>If you don't want to depend on any external libraries:</p> <pre><code> s = str(1234567) print ','.join([s[::-1][k:k+3][::-1] for k in xrange(len(s)-1, -1, -3)]) </code></pre> <p>This works only for non-negative integers.</p>
-6
2012-02-29T19:07:29Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
10,742,904
<p>I too, prefer the "simplest practical way". For >= 2.7:</p> <pre><code>"{:,}".format(value) </code></pre> <p><a href="http://docs.python.org/library/string.html#format-specification-mini-language">http://docs.python.org/library/string.html#format-specification-mini-language</a></p>
807
2012-05-24T18:02:17Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
11,149,343
<p>I'm using python 2.5 so I don't have access to the built-in formatting.</p> <p>I looked at the django code intcomma (intcomma_recurs in code below) and realized it's inefficient, because it's recursive and also compiling the regex on every run is not a good thing either. This is not necessary an 'issue' as django ...
1
2012-06-22T02:04:21Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
11,562,205
<p>Here's a one-line regex replacement:</p> <pre><code>re.sub("(\d)(?=(\d{3})+(?!\d))", r"\1,", "%d" % val) </code></pre> <p>Works only for inegral outputs:</p> <pre><code>import re val = 1234567890 re.sub("(\d)(?=(\d{3})+(?!\d))", r"\1,", "%d" % val) # Returns: '1,234,567,890' val = 1234567890.1234567890 # Returns...
26
2012-07-19T13:42:46Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
12,732,922
<p>Here is another variant using a generator function that works for integers:</p> <pre><code>def ncomma(num): def _helper(num): # assert isinstance(numstr, basestring) numstr = '%d' % num for ii, digit in enumerate(reversed(numstr)): if ii and ii % 3 == 0 and digit.isdigit(): ...
0
2012-10-04T17:53:00Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
16,924,278
<p>One liner for Python 2.5+ and Python 3 (positive int only):</p> <pre><code>''.join(reversed([x + (',' if i and not i % 3 else '') for i, x in enumerate(reversed(str(1234567)))])) </code></pre>
2
2013-06-04T17:48:26Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
20,458,213
<p>This does money along with the commas</p> <pre><code>def format_money(money, presym='$', postsym=''): fmt = '%0.2f' % money dot = string.find(fmt, '.') ret = [] if money &lt; 0 : ret.append('(') p0 = 1 else : p0 = 0 ret.append(presym) p1 = (dot-p0) % 3 + p0 wh...
1
2013-12-08T19:51:03Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
32,050,746
<p>You can also use <code>'{:n}'.format( value )</code> for a locale representation. I think this is the simpliest way for a locale solution.</p> <p>For more information, search for <code>thousands</code> in <a href="https://docs.python.org/3.5/library/string.html#format-specification-mini-language">Python DOC</a>.</p...
7
2015-08-17T12:43:14Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
36,262,731
<p>I am a Python beginner, but an experienced programmer. I have Python 3.5, so I can just use the comma, but this is nonetheless an interesting programming exercise. Consider the case of an unsigned integer. The most readable Python program for adding thousands separators appears to be:</p> <pre><code>def add_commas(...
0
2016-03-28T12:51:47Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
38,156,617
<p>from Python version 2.6 you can do this:</p> <pre><code>def format_builtin(n): return format(n, ',') </code></pre> <p>For Python versions &lt; 2.6 and just for your information, here are 2 manual solutions, they turn floats to ints but negative numbers work correctly:</p> <pre><code>def format_number_using_li...
3
2016-07-02T04:54:04Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
38,553,110
<p>This is what I do for floats. Although, honestly, I'm not sure which versions it works for - I'm using 2.7:</p> <pre><code>my_number = 4385893.382939491 my_string = str(format(int(my_number),",d")) + "." + str(my_number).rsplit('.')[1][:2] </code></pre> <p>Returns: 4,385,893.38</p> <p>The final [:2] can be chan...
-1
2016-07-24T14:26:44Z
[ "python", "python-2.x" ]
How to print number with commas as thousands separators?
1,823,058
<p>I am trying to print an integer in <em>Python 2.6.1</em> with commas as thousands separators. For example, I want to show the number <code>1234567</code> as <code>1,234,567</code>. How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest practical way.</p> <p>It does n...
290
2009-11-30T23:11:43Z
39,301,723
<p>I prefer the locale-based solution for real projects, but here is a simple and effective alternative:</p> <pre><code>def format_money(f, delimiter=',', frac_digits=2): neg = (f &lt; 0) if neg: f = -f s = '%.*f' % (frac_digits, f) if len(s) &lt; 5 + frac_digits: return ('-' if neg e...
-1
2016-09-02T23:08:37Z
[ "python", "python-2.x" ]
Can I find all of a certain base model in App Engine?
1,823,151
<p>Given a class-like relationship:</p> <pre><code>class A(db.Model): pass class B(A): pass </code></pre> <p>Can I get all of the base class? The query:</p> <pre><code>models.A.all().fetch(1) </code></pre> <p>returns an empty list.</p>
0
2009-11-30T23:34:09Z
1,823,755
<p>The datastore does not record inheritance, per se: it stores the <code>B</code> entities as being of kind <code>B</code>. You can get all (direct, proper) subclasses of <code>A</code> with <code>A.__subclasses__()</code> (if you want indirect subclasses as well you'll need to do the same with each of these, and so...
1
2009-12-01T03:10:31Z
[ "python", "google-app-engine" ]
Can I find all of a certain base model in App Engine?
1,823,151
<p>Given a class-like relationship:</p> <pre><code>class A(db.Model): pass class B(A): pass </code></pre> <p>Can I get all of the base class? The query:</p> <pre><code>models.A.all().fetch(1) </code></pre> <p>returns an empty list.</p>
0
2009-11-30T23:34:09Z
1,824,873
<p>The datastore doesn't natively support this sort of polymorphism - but you can use the <a href="http://code.google.com/appengine/docs/python/datastore/polymodelclass.html" rel="nofollow">polymodel class</a> to do this. Just inherit from PolyModel instead of Model and things will behave more or less as you expect the...
2
2009-12-01T08:58:09Z
[ "python", "google-app-engine" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,365
<p>If you can use SciPy, you can use <code>cosine</code> from <code>spatial.distance</code>:</p> <p><a href="http://docs.scipy.org/doc/scipy/reference/spatial.distance.html">http://docs.scipy.org/doc/scipy/reference/spatial.distance.html</a></p> <p>If you can't use SciPy, you could try to obtain a small speedup by re...
8
2009-12-01T00:45:10Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,396
<p>This is faster for arrays of around 1000+ elements. </p> <pre><code>from numpy import array def cosine_distance(a, b): a=array(a) b=array(b) numerator=(a*b).sum() denoma=(a*a).sum() denomb=(b*b).sum() result = 1 - numerator / sqrt(denoma*denomb) return result </code></pre>
1
2009-12-01T00:58:29Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,442
<p>(I originally thought) you're not going to speed it up a lot without breaking out to C (like numpy or scipy) or changing what you compute. But here's how I'd try that, anyway:</p> <pre><code>from itertools import imap from math import sqrt from operator import mul def cosine_distance(a, b): assert len(a) == le...
8
2009-12-01T01:13:06Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,470
<p>Similar to Darius Bacon's answer, I've been toying with operator and itertools to produce a faster answer. The following seems to be 1/3 faster on a 500-item array according to timeit:</p> <pre><code>from math import sqrt from itertools import imap from operator import mul def op_cosine(a, b): dot_prod = sum(i...
1
2009-12-01T01:21:32Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,490
<p>No need to take <code>abs()</code> of <code>a[i]</code> and <code>b[i]</code> if you're squaring it.</p> <p>Store <code>a[i]</code> and <code>b[i]</code> in temporary variables, to avoid doing the indexing more than once. Maybe the compiler can optimize this, but maybe not.</p> <p>Check into the <code>**2</code> o...
2
2009-12-01T01:26:52Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,823,735
<pre><code>def cd(a,b): if(len(a)!=len(b)): raise ValueError, "a and b must be the same length" rn = range(len(a)) adb = sum([a[k]*b[k] for k in rn]) nma = sqrt(sum([a[k]*a[k] for k in rn])) nmb = sqrt(sum([b[k]*b[k] for k in rn])) result = 1 - adb / (nma*nmb) return result </code><...
0
2009-12-01T03:05:16Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
1,824,248
<p>Using the C code inside of SciPy wins big for long input arrays. Using simple and direct Python wins for short input arrays; Darius Bacon's <code>izip()</code>-based code benchmarked out best. Thus, the ultimate solution is to decide which one to use at runtime, based on the length of the input arrays:</p> <pre><...
1
2009-12-01T05:56:22Z
[ "python", "arrays", "optimization", "distance" ]
Optimized method for calculating cosine distance in Python
1,823,293
<p>I wrote a method to calculate the cosine distance between two arrays:</p> <pre><code>def cosine_distance(a, b): if len(a) != len(b): return False numerator = 0 denoma = 0 denomb = 0 for i in range(len(a)): numerator += a[i]*b[i] denoma += abs(a[i])**2 denomb += abs(b[i])**2 ...
9
2009-12-01T00:15:59Z
4,651,712
<p>Your updated solution still has two square roots. You can reduce this to one by replacing the sqrt line with:</p> <blockquote> <p>result = 1 - numerator / (sqrt(denoma*denomb))</p> </blockquote> <p>A multiply is typically quite a bit quicker than a sqrt. It might not seem much as it is only called once in the ...
0
2011-01-10T21:30:56Z
[ "python", "arrays", "optimization", "distance" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,308
<p>It depends a lot on the format of your file.</p> <p>Does it make sense to split it anywhere? Or do you need to split it at a new line? Or do you need to make sure that you split it at the end of an object definition?</p> <p>Instead of splitting the file, you should use multiple readers on the same file, using <cod...
1
2009-12-01T00:28:31Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,309
<p>You dont mention how you are processing the lines; possibly the most important piece of info.</p> <p>Is each line independant? Is the calculation dependant on one line coming before the next? Must they be processed in blocks? How long does the processing for each line take? Is there a processing step that must i...
4
2009-12-01T00:28:40Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,319
<p>I know you specifically asked about Python, but I will encourage you to look at Hadoop (<a href="http://hadoop.apache.org/" rel="nofollow">http://hadoop.apache.org/</a>): it implements the Map and Reduce algorithm which was specifically designed to address this kind of problem. </p> <p>Good luck</p>
1
2009-12-01T00:31:40Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,437
<p>If the run time is long, instead of having each process read its next line through a <code>Queue</code>, have the processes read batches of lines. This way the overhead is amortized over several lines (e.g. thousands or more).</p>
0
2009-12-01T01:11:36Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,461
<p>One strategy is to assign each worker an offset so if you have eight worker processes you assign then numbers 0 to 7. Worker number 0 reads the first record processes it then skips 7 and goes on to process the 8th record etc., worker number 1 reads the second record then skips 7 and processes the 9th record............
6
2009-12-01T01:18:39Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,823,530
<p>One of the best architectures is already part of Linux OS's. No special libraries required.</p> <p>You want a "fan-out" design.</p> <ol> <li><p>A "main" program creates a number of subprocesses connected by pipes.</p></li> <li><p>The main program reads the file, writing lines to the pipes doing the minimum filter...
7
2009-12-01T01:45:05Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
What's the best way to divide large files in Python for multiprocessing?
1,823,300
<p>I run across a lot of "embarrassingly parallel" projects I'd like to parallelize with the <code>multiprocessing</code> module. However, they often involve reading in huge files (greater than 2gb), processing them line by line, running basic calculations, and then writing results. What's the best way to split a file ...
14
2009-12-01T00:23:25Z
1,825,467
<p>Fredrik Lundh's <a href="http://effbot.org/zone/wide-finder.htm" rel="nofollow">Some Notes on Tim Bray's Wide Finder Benchmark</a> is an interesting read, about a very similar use case, with a lot of good advice. Various other authors also implemented the same thing, some are linked from the article, but you might w...
1
2009-12-01T11:03:09Z
[ "python", "concurrency", "multiprocessing", "bioinformatics" ]
Set and use flags against a users profile model in Django
1,823,372
<p>I have a simple webapp in Django for an iPhone app. I want to prompt the user to review our product, but just once. I then don't want to show that prompt again.</p> <p>So would the best practise way of implementing this to be to add a new entry to the user profile model with a bolean field: "reviewed" - and then se...
0
2009-12-01T00:46:41Z
1,823,488
<p>There are a variety of ways to do this. I suggest the following:</p> <p>Django has a messaging framework, built by design to show messages to users only once when the software creates them. Whenever X is created/modified/deleted etc, you can add the message to the user via User.message_set.create(message='Whatever ...
0
2009-12-01T01:26:09Z
[ "python", "django", "django-models" ]
Set and use flags against a users profile model in Django
1,823,372
<p>I have a simple webapp in Django for an iPhone app. I want to prompt the user to review our product, but just once. I then don't want to show that prompt again.</p> <p>So would the best practise way of implementing this to be to add a new entry to the user profile model with a bolean field: "reviewed" - and then se...
0
2009-12-01T00:46:41Z
1,823,518
<p>If you are using MySQL or PostgreSQL, you can do some <code>ALTER TABLE</code> without loosing any data.</p> <p>In Django, it is quite easy to add a profile for the user. Make sure, to create the profile if it doesn't exist :</p> <pre><code>try: profile = request.user.get_profile() except UserProfile.DoesNot...
1
2009-12-01T01:39:02Z
[ "python", "django", "django-models" ]
Debugging Pyparsing Grammar
1,823,427
<p>I'm building a parser for an imaginary programming language called C-- (not the actual C-- language). I've gotten to the stage where I need to translate the language's grammar into something Pyparsing can accept. Unfortunatly when I come to parse my input string (which is correct and should not cause Pyparsing to er...
14
2009-12-01T01:08:14Z
1,823,558
<p>1) Change <code>Literal("if")</code> to <code>Keyword("if")</code> (and so on, down to <code>Literal("void")</code>), to prevent matching the leading "if" of a variable named <code>"ifactor"</code>.</p> <p>2) <code>nums</code>, <code>alphas</code>, and <code>alphanums</code> are not expressions, they are strings, t...
27
2009-12-01T01:55:18Z
[ "python", "pyparsing" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,434
<p>A bit subjective, but I'd vote for python because it has good libraries and abstracts a lot of the low level 'detail' that you'd have to consider when using c++...</p>
8
2009-12-01T01:10:10Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,440
<p>I did all my algorithms work in college in C++ because I knew it.</p> <p>If I'd had to learn a language at the same time, I would have picked Python most likely.</p>
6
2009-12-01T01:12:47Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,447
<p>I am under the impression that it really depends from what you mean by <em>faster</em>.</p> <p>Faster to develop: go python. Faster to run: go C++.</p> <p>However python can use a lot of external C libraries, so the difference in processing time might not be that relevant, depending on the type of implementation.<...
6
2009-12-01T01:14:39Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,457
<p>At my university the 500 students in the "Algorithms and Datastructures" class get to choose the language they want.</p> <p>Python is by far the most popular choice there, and personally I'm happy I also chose that, even though I already knew C++. </p>
5
2009-12-01T01:16:20Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,462
<p>Agree with your friend - use Python and put them within a unit test framework.</p> <p>I worked for a number of years with scientists who did a lot of their algorithmic work in Python.</p> <p>The example below shows typical tests (the import statement is for the stuff being tested), with a couple of niceties that ...
4
2009-12-01T01:18:43Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,473
<p>I would go for python. And if you really need the performance, then you can always write C/C++ extensions and use them in python.</p>
4
2009-12-01T01:22:01Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,475
<p>I think you're looking for Python, because you can:</p> <ul> <li>Focus on the algorithms themselves and not have to worry about other detail like memory management. </li> <li>Do more with less code</li> <li>The syntax is almost like working with pseudo code.</li> <li>There is great built in language support for li...
23
2009-12-01T01:22:37Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,479
<p>Algorithms are fine in Python (allthough you can only fly one OS scheduled python thread due to the global lock); however, when it comes to data structures + algorithms you need fixed complexity guarantees, and this case you mix Python with C.</p> <p>I suppose what I have said applies more to long running computati...
3
2009-12-01T01:23:31Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,545
<p>I also vote for python. When do algorithm, we tend to work on the algorithm itself rather than language, low level details. Basically, we works on abstraction level. And using python, we're less likely to be side-tracked. But if you're very familiar and comfortable with C++ and can use it freely to express your ide...
2
2009-12-01T01:51:29Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,577
<p>If using C++ means that STL is fair game, I'd say that it deserves serious consideration. STL is a fantastic library, combining structures, iterators, and algorithms. I love the Python recommendations, but if I could use STL I'd reconsider C++.</p>
1
2009-12-01T02:02:22Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,578
<p>Instead of focusing on the language, you should focus on the <em>libraries</em> available to you.</p> <p>You shouldn't write your own graph library when there are already plenty (read, "too many") available, both in <a href="http://www.google.com/search?q=c%2B%2B+graph+library" rel="nofollow">C++</a> and in <a href...
9
2009-12-01T02:03:06Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,580
<p>Remember that Python is compiled to bytecode and then interpreted in a VM. So, in performance isn't better (faster) than C++.</p>
0
2009-12-01T02:04:07Z
[ "c++", "python", "algorithm", "graph" ]
which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?
1,823,431
<p>I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much <strong>faster</strong> <em>to develop</em> and less time is spent in programming details which does not actually earn anything solution wise.</p> <p><strong>EDIT 2</s...
4
2009-12-01T01:08:54Z
1,823,589
<p>With C++, you'd sometimes be concentrating more on the language issues than the problem itself, so Python. I'd even be recommending you do it in a higher-level language like Matlab (although the language itself can be a bit ugly).</p>
2
2009-12-01T02:06:07Z
[ "c++", "python", "algorithm", "graph" ]
merge background audio file
1,823,480
<p>I have 2 audio files for primary and background music that I want to merge (not concatenate). The final audio file should be as long as the primary file, and if the background music is shorter then it should repeat.</p> <p>If there a Linux command or a Python library that can be used to do this? <a href="http://sox...
0
2009-12-01T01:23:37Z
1,824,425
<p>As a possible solution, why not detect if the length of the background file &lt; length of the foreground file and then construct a background file which is a loop, if necessary? Then you can pass that into sox.</p> <p>You should be able to get the length from <a href="http://docs.python.org/library/sndhdr.html" re...
1
2009-12-01T06:50:08Z
[ "python", "linux", "audio", "merge" ]
incorrect function being called on multiple fast calls to python's threading.Thread()
1,823,493
<p>I'm having some problems with launching threads from a list of functions. They are in a list because they are configuration-specific functions. I'm wrappering the functions so that I can store the results of the functions in 'self', but something is going wrong in a non-threadsafe way that I get the right number of ...
0
2009-12-01T01:27:11Z
1,823,532
<p>The problem is that <code>functionList[functionListIndex]</code> is evaluated only when the lambda it is in is run (within the thread). By then the value of functionListIndex can change.</p> <p>To fix this, you can pass a parameter to the lambda that will be evaluated at definition time:</p> <pre><code>newThread =...
1
2009-12-01T01:45:46Z
[ "python", "multithreading" ]
Python print buffering
1,823,528
<p>Let me rephrase my previous question. I just created a tool in ArcGIS using pythong as script language. The tool executes (runs) an outside program using the subprocess.popen. When I run the tool from ArcGSIS, a window appears that only shows the following.</p> <pre><code>Executing: RunFLOW C:\FLOW C:\FLOW\FLW.bat ...
1
2009-12-01T01:44:31Z
1,823,581
<p>I know nothing about ArcGIS, so I may be shooting in the dark here, but...if you want stdout, you usually don't want the <code>communicate()</code> method. You want something like this:</p> <pre><code>p=subprocess.Popen(Flow_bat,shell=True,stdout=subprocess.PIPE) stdout_value = p.stdout.read() </code></pre> <p>Th...
0
2009-12-01T02:04:08Z
[ "python", "printing", "executable" ]
Python print buffering
1,823,528
<p>Let me rephrase my previous question. I just created a tool in ArcGIS using pythong as script language. The tool executes (runs) an outside program using the subprocess.popen. When I run the tool from ArcGSIS, a window appears that only shows the following.</p> <pre><code>Executing: RunFLOW C:\FLOW C:\FLOW\FLW.bat ...
1
2009-12-01T01:44:31Z
1,876,602
<p>I'm not sure if you are aware of this or not but I use:</p> <pre><code>gp.AddMessage('blah blah') </code></pre> <p>to get messages to appear in the ArcGIS processing window. Its a method of the geoprocessor object, the library you import in Python to access the ArcGIS engine. You would already have imported this l...
0
2009-12-09T20:20:27Z
[ "python", "printing", "executable" ]
Django, updating a user profile with a ModelForm
1,823,588
<p>I'm trying to display a simple ModelForm for a user's profile and allow the user to update it. The problem here is that my logic is somehow flawed, and after a successful form.save() call, the old values show on the page. It isn't until a refresh that the appropriate value is shown. What is wrong here?</p> <pre><co...
7
2009-12-01T02:05:50Z
1,823,636
<p>Try this:</p> <pre><code>@login_required def user_profile(request): success = False user = User.objects.get(pk=request.user.id) if request.method == 'POST': upform = UserProfileForm(request.POST, instance=user.get_profile()) if upform.is_valid(): up = upform.save(commit=False...
8
2009-12-01T02:26:07Z
[ "python", "django" ]
Django, updating a user profile with a ModelForm
1,823,588
<p>I'm trying to display a simple ModelForm for a user's profile and allow the user to update it. The problem here is that my logic is somehow flawed, and after a successful form.save() call, the old values show on the page. It isn't until a refresh that the appropriate value is shown. What is wrong here?</p> <pre><co...
7
2009-12-01T02:05:50Z
1,826,233
<p>You could also use a <a href="https://docs.djangoproject.com/en/1.4/ref/generic-views/#django-views-generic-create-update-update-object" rel="nofollow">generic view</a>:</p> <pre><code>from django.views.generic.create_update import update_object @login_required def user_profile(request): return update_object(r...
3
2009-12-01T13:37:25Z
[ "python", "django" ]
Finding the joy of Javascript or searching for another UI-focused languages?
1,823,692
<p>I'm a GUI designer/interactive musician wanting to improve my programming chops. I already know the basics(variables, loops, arrays, if/else, some logic), but I'm looking to learn in a structured way. I've seen some great books/tuts on Python and Processing (and even Flash)that aim to teach the fundamentals of progr...
0
2009-12-01T02:51:01Z
1,823,703
<p>If you are really looking for the joy of GUI programming, then I suggest you C#. Get yourself VS 2008 or above. </p> <p>Just imagine, you have a great GUI designers that allow you to script you layout through drag and drop, and all you have to do, is to fill in the proper event and the program will just run like ma...
0
2009-12-01T02:53:48Z
[ "javascript", "python", "user-interface", "processing" ]
Finding the joy of Javascript or searching for another UI-focused languages?
1,823,692
<p>I'm a GUI designer/interactive musician wanting to improve my programming chops. I already know the basics(variables, loops, arrays, if/else, some logic), but I'm looking to learn in a structured way. I've seen some great books/tuts on Python and Processing (and even Flash)that aim to teach the fundamentals of progr...
0
2009-12-01T02:51:01Z
1,823,711
<p>Have you had a look at <a href="http://rads.stackoverflow.com/amzn/click/0596527748" rel="nofollow">Head-First Javascript</a>? It seems to me to be a programming tutorial that's not inferior to the best ones available for, say, Python -- sure, it deals with web programming too (while a Python-based book might not),...
2
2009-12-01T02:57:28Z
[ "javascript", "python", "user-interface", "processing" ]
Finding the joy of Javascript or searching for another UI-focused languages?
1,823,692
<p>I'm a GUI designer/interactive musician wanting to improve my programming chops. I already know the basics(variables, loops, arrays, if/else, some logic), but I'm looking to learn in a structured way. I've seen some great books/tuts on Python and Processing (and even Flash)that aim to teach the fundamentals of progr...
0
2009-12-01T02:51:01Z
1,823,712
<p>Any programming language popular enough to have books written about it that you've seen in stores will be professionally useful to you. I think you have a good approach in looking for something that excites you. If those Python books make your heart race, pick one up and dive in. If you find something else that you ...
0
2009-12-01T02:57:35Z
[ "javascript", "python", "user-interface", "processing" ]
Finding the joy of Javascript or searching for another UI-focused languages?
1,823,692
<p>I'm a GUI designer/interactive musician wanting to improve my programming chops. I already know the basics(variables, loops, arrays, if/else, some logic), but I'm looking to learn in a structured way. I've seen some great books/tuts on Python and Processing (and even Flash)that aim to teach the fundamentals of progr...
0
2009-12-01T02:51:01Z
1,823,713
<p>Javascript isn't so much a "joy" as it is a "necessary evil". jQuery just makes it less evil. Actually that's not entirely fair: part of the "evilness" of Javascript is just all the cross-browser difference, not the language itself (which is actually quite modern).</p> <p>But like learning anything, I don't think i...
1
2009-12-01T02:57:40Z
[ "javascript", "python", "user-interface", "processing" ]
Finding the joy of Javascript or searching for another UI-focused languages?
1,823,692
<p>I'm a GUI designer/interactive musician wanting to improve my programming chops. I already know the basics(variables, loops, arrays, if/else, some logic), but I'm looking to learn in a structured way. I've seen some great books/tuts on Python and Processing (and even Flash)that aim to teach the fundamentals of progr...
0
2009-12-01T02:51:01Z
1,823,714
<p>You might want to take a look at Tcl/Tk. Although the language is sort of arcane, and the library is at least in principle available in other languages, notably python and perl, the toolkit in its native language is really very clear and concise. </p>
0
2009-12-01T02:57:59Z
[ "javascript", "python", "user-interface", "processing" ]