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
SQLite in Python 2.2.3
737,511
<p>I've written a web-app in python using SQLite and it runs fine on my server at home (with apache and python 2.5.2). I'm now trying to upload it to my web host and there servers use python 2.2.3 without SQLite.<br/> Anyone know of a way to use SQLite in python 2.2.3 e.g. a module that I can upload and import? I've tr...
1
2009-04-10T12:40:39Z
739,257
<p>If you have shell access to your web server, you can probably build you're own version of Python and SQLite. This will let you use the latest version. Download the source code, then when you configure it, do something like "./configure --prefix=$HOME/packages".</p> <p>Next, fiddle around with your .profile, or .bas...
0
2009-04-11T00:40:31Z
[ "python", "sql", "linux", "sqlite", "hosting" ]
SQLite in Python 2.2.3
737,511
<p>I've written a web-app in python using SQLite and it runs fine on my server at home (with apache and python 2.5.2). I'm now trying to upload it to my web host and there servers use python 2.2.3 without SQLite.<br/> Anyone know of a way to use SQLite in python 2.2.3 e.g. a module that I can upload and import? I've tr...
1
2009-04-10T12:40:39Z
4,066,757
<p>In case anyone comes across this question, the reason why neither pysqlite nor APSW are available for Python 2.2 is because Python 2.3 added the simplified GIL API. Prior to Python 2.3 it required a lot of code to keep track of the GIL. (The GIL is the lock used by Python to ensure correct behaviour while multi-th...
0
2010-11-01T05:06:17Z
[ "python", "sql", "linux", "sqlite", "hosting" ]
Returning default members when accessing to objects in python
737,512
<p>I'm writing an "envirorment" where each variable is composed by a value and a description:</p> <pre><code>class my_var: def __init__(self, value, description): self.value = value self.description = description </code></pre> <p>Variables are created and put inside a dictionary:</p> <pre><code>my_dic...
1
2009-04-10T12:41:35Z
737,549
<p>I think the fact that you have to do so much work to make a fancy shortcut is an indication that you're going against the grain. What you're doing violates LSP; it's counter-intuitive. </p> <pre><code>my_dict[k] = v; print my_dict[k] == v # should be True </code></pre> <p>Even two separate dicts would be preferabl...
1
2009-04-10T12:58:38Z
[ "python", "dynamic-data" ]
Returning default members when accessing to objects in python
737,512
<p>I'm writing an "envirorment" where each variable is composed by a value and a description:</p> <pre><code>class my_var: def __init__(self, value, description): self.value = value self.description = description </code></pre> <p>Variables are created and put inside a dictionary:</p> <pre><code>my_dic...
1
2009-04-10T12:41:35Z
737,551
<p>Two general notes.</p> <ol> <li><p>Please use Upper Case for Class Names.</p></li> <li><p>Please (unless using Python 3.0) subclass object. <code>class My_Var(object):</code>, for example.</p></li> </ol> <p>Now to your question.</p> <p>Let's say you do</p> <pre><code>x= My_Var(0.5, "A foo var") </code></pre> <...
3
2009-04-10T12:59:31Z
[ "python", "dynamic-data" ]
Returning default members when accessing to objects in python
737,512
<p>I'm writing an "envirorment" where each variable is composed by a value and a description:</p> <pre><code>class my_var: def __init__(self, value, description): self.value = value self.description = description </code></pre> <p>Variables are created and put inside a dictionary:</p> <pre><code>my_dic...
1
2009-04-10T12:41:35Z
737,559
<p>You could create an object that mostly acts like "value" but has an additional attribute "description, by implementing the operators in section "Emulating numeric types" of <a href="http://docs.python.org/reference/datamodel.html" rel="nofollow">http://docs.python.org/reference/datamodel.html</a></p> <pre><code>cla...
2
2009-04-10T13:03:45Z
[ "python", "dynamic-data" ]
Returning default members when accessing to objects in python
737,512
<p>I'm writing an "envirorment" where each variable is composed by a value and a description:</p> <pre><code>class my_var: def __init__(self, value, description): self.value = value self.description = description </code></pre> <p>Variables are created and put inside a dictionary:</p> <pre><code>my_dic...
1
2009-04-10T12:41:35Z
737,564
<p>I would personally just use two dictionaries, one for values and one for descriptions. Your desire for magic behavior is not very Pythonic.</p> <p>With that being said, you could implement your own dict class:</p> <pre><code>class DescDict(dict): def __init__(self, *args, **kwargs): self.descs = {} ...
2
2009-04-10T13:06:11Z
[ "python", "dynamic-data" ]
Followup: Multiprocessing or Multithreading for Python simulation software
737,826
<p>this is a follow up to <a href="http://stackoverflow.com/questions/731993/multiprocessing-or-multithreading">this</a>. (You don't have to read all the answers, just the question)</p> <p>People explained to me the difference between processes and threads. On the one hand, I wanted processes so I could fully exploit ...
0
2009-04-10T14:41:10Z
738,032
<blockquote> <p>The main process in my program is the GUI process. I will have it spawn a "rendering-manager" thread. The rendering-manager thread will be responsible for rendering the simulation, however, it will not render them by itself, but spawn other processes to do the work for it.</p> </blockquote> <p>I'm no...
0
2009-04-10T15:41:59Z
[ "python", "multithreading", "multicore", "simulation", "multiprocessing" ]
Followup: Multiprocessing or Multithreading for Python simulation software
737,826
<p>this is a follow up to <a href="http://stackoverflow.com/questions/731993/multiprocessing-or-multithreading">this</a>. (You don't have to read all the answers, just the question)</p> <p>People explained to me the difference between processes and threads. On the one hand, I wanted processes so I could fully exploit ...
0
2009-04-10T14:41:10Z
738,960
<p>Before using processes, make sure that:</p> <ul> <li>Your algorithm can be parallelized between all the processors.</li> <li>You need this parallelism.</li> </ul> <p>In my opinion a good rule of thumb is:</p> <ol> <li>Make it work.</li> <li>Make it right.</li> <li>Make it fast.</li> </ol> <p>So I'd suggest to â€...
2
2009-04-10T21:40:26Z
[ "python", "multithreading", "multicore", "simulation", "multiprocessing" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
737,963
<p>Scratch disks will benefit your application in the case that it works with very big files, </p> <p>Is that the case? </p> <p>If not, then i don't think you may find something that will benefit your application in scratch disks.</p>
1
2009-04-10T15:18:21Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
737,966
<p>Until you ACTUALLY run out of memory, thinking about this is a waste of time.</p> <p>When you finally do run out of memory, you'll need to use a temporary file to store objects that your process needs, but can't fit into memory.</p> <p>Use pickle or shelve (see <a href="http://docs.python.org/library/persistence.h...
4
2009-04-10T15:20:11Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
737,992
<p><a href="http://docs.python.org/library/mmap.html" rel="nofollow">Memory mapped files</a> might be what you are looking for. Python's implementation lets you use a file like a mutable string in memory.</p>
1
2009-04-10T15:31:20Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
738,001
<blockquote> <p>I understood that the reason for this is some limitation by Windows XP on how much total memory a process can take, regardless of HD space. I think it's around 3 GB.</p> </blockquote> <p>Just an FYI, this is more a limitation of a 32-bit OS rather than being a Windows XP problem. You'll have the sam...
2
2009-04-10T15:32:49Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
738,112
<p>The Win32 API provides this: <a href="http://msdn.microsoft.com/en-us/library/aa366527%28VS.85%29.aspx" rel="nofollow">link text</a>. You may be able to use these functions through PyWin32.</p>
1
2009-04-10T16:04:59Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
738,317
<p>You could combine S.Lott's answer about using pickle (you should use cPickle though for better performance) with SqlLite.</p> <p>sqlite is built into python 2.5 and up, so all you'll need to do is import :), then just store the pickled objects as strings in there and you'll have a nice fast method of accessing the ...
1
2009-04-10T17:40:44Z
[ "python", "windows", "memory-management" ]
Scratch disks in Python?
737,947
<p>I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason fo...
2
2009-04-10T15:11:33Z
4,207,006
<p>You are probably looking for something like ZODB. However, though ZODB tries hard to be transparent, no solution is going to be 100% free of artifacts. You have to write your code with an awareness that your objects primarily live in a database, but that there are multiple representations of your objects, there ar...
0
2010-11-17T16:59:51Z
[ "python", "windows", "memory-management" ]
How to Modify Choices of ModelMultipleChoiceField
738,301
<p>Let's say I have some contrived models:</p> <pre><code>class Author(Model): name = CharField() class Book(Model): title = CharField() author = ForeignKey(Author) </code></pre> <p>And let's say I want to use a ModelForm for Book:</p> <pre><code> class BookForm(ModelForm): class Meta: mod...
5
2009-04-10T17:34:26Z
738,463
<p>Form objects don't have their fields as attributes, you need to look in the "fields" attribute, which is a dictionary:</p> <pre><code>self.fields['author'].queryset = choices </code></pre> <p>If you want to fully understand what's going on here, you might be interested in <a href="http://stackoverflow.com/question...
8
2009-04-10T18:30:45Z
[ "python", "django", "django-forms" ]
How to Modify Choices of ModelMultipleChoiceField
738,301
<p>Let's say I have some contrived models:</p> <pre><code>class Author(Model): name = CharField() class Book(Model): title = CharField() author = ForeignKey(Author) </code></pre> <p>And let's say I want to use a ModelForm for Book:</p> <pre><code> class BookForm(ModelForm): class Meta: mod...
5
2009-04-10T17:34:26Z
738,483
<p>Although <a href="#738463">Carl</a> is correct about the fields, you're also missing a super class call. This is how I do it:</p> <pre><code>class BookForm(ModelForm): author = ModelMultipleChoiceField(queryset=Author.objects.all()) class Meta: model = Book def __init__(self, *args, **kwargs):...
6
2009-04-10T18:36:19Z
[ "python", "django", "django-forms" ]
Getting started with Django-Instant Django
738,433
<p>I've been trying to get Django running and when going through the intro to projects it seems that I keep having trouble when I get to the 'sync database' section. When using InstantDjango this doesn't seem to be as much of a problem. My question is, can one just do Django development with the InstantDjango program ...
0
2009-04-10T18:22:34Z
3,727,548
<p>InstantDjango uses sqlite by default. What database did you set your normal django to use? and you did you create that database before you ran the syncdb?</p> <p>InstantDjango uses different packaging for all the django required libraries (portable versions) which might be less stable but they should work for your ...
2
2010-09-16T14:16:27Z
[ "python", "django" ]
In Python, how do I reference a class generically in a static way, like PHP's "self" keyword?
738,467
<p>PHP classes can use the keyword "self" in a static context, like this:</p> <pre><code>&lt;?php class Test { public static $myvar = 'a'; public static function t() { echo self::$myvar; // Generically reference the current class. echo Test::$myvar; // Same thing, but not generic. } } ?&gt; </code></pr...
18
2009-04-10T18:31:50Z
738,480
<p>In all cases, <code>self.__class__</code> is an object's class.</p> <p><a href="http://docs.python.org/library/stdtypes.html#special-attributes">http://docs.python.org/library/stdtypes.html#special-attributes</a></p> <p>In the (very) rare case where you are trying to mess with static methods, you actually need <a ...
21
2009-04-10T18:35:45Z
[ "python", "class" ]
In Python, how do I reference a class generically in a static way, like PHP's "self" keyword?
738,467
<p>PHP classes can use the keyword "self" in a static context, like this:</p> <pre><code>&lt;?php class Test { public static $myvar = 'a'; public static function t() { echo self::$myvar; // Generically reference the current class. echo Test::$myvar; // Same thing, but not generic. } } ?&gt; </code></pr...
18
2009-04-10T18:31:50Z
738,552
<p>This should do the trick:</p> <pre><code>class C(object): my_var = 'a' @classmethod def t(cls): print cls.my_var C.t() </code></pre>
19
2009-04-10T19:04:47Z
[ "python", "class" ]
How do you automate the launching/debugging of large scale projects?
739,090
<p><strong>Scenario:</strong></p> <p>There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach <em>gdb</em> for debugging.</p> <p>The process launching script:</p> <ul> <li>ensures an environment variable is set.</li> <li>...
4
2009-04-10T22:43:55Z
739,347
<p>Instead of forwarding the signal to the debuggee from Python, you could try just ignoring it. The following worked for me:</p> <pre><code>import signal signal.signal(signal.SIGINT, signal.SIG_IGN) import subprocess cat = subprocess.Popen(['cat']) subprocess.call(['gdb', '--pid=%d' % cat.pid]) </code></pre> <p>Wi...
3
2009-04-11T01:41:29Z
[ "python", "debugging", "gdb", "subprocess", "selinux" ]
How do you automate the launching/debugging of large scale projects?
739,090
<p><strong>Scenario:</strong></p> <p>There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach <em>gdb</em> for debugging.</p> <p>The process launching script:</p> <ul> <li>ensures an environment variable is set.</li> <li>...
4
2009-04-10T22:43:55Z
750,128
<p>Your comment notes that you're sshing in with putty... do you have a controlling tty? With openssh you would want to add the -T option, I don't know how/if putty will do this the way you're using it.</p> <p>Also: you might try using cygwin's ssh instead of putty.</p>
0
2009-04-15T02:52:24Z
[ "python", "debugging", "gdb", "subprocess", "selinux" ]
How do you automate the launching/debugging of large scale projects?
739,090
<p><strong>Scenario:</strong></p> <p>There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach <em>gdb</em> for debugging.</p> <p>The process launching script:</p> <ul> <li>ensures an environment variable is set.</li> <li>...
4
2009-04-10T22:43:55Z
753,721
<p>if you already have a current script set up to do this, but are having problems automating part of it, maybe you can just grab expect and use it to provide the setup, then drop back into interactive mode in expect to launch the process. Then you can still have your ctrl-c available to interrupt.</p>
0
2009-04-15T21:05:18Z
[ "python", "debugging", "gdb", "subprocess", "selinux" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
739,262
<p>did you try the intro doc? <a href="http://docs.djangoproject.com/en/dev/intro/tutorial01" rel="nofollow">doc link</a></p> <p>If you follow this doc, you can at least say, "at step XXXX it got error YYY". Then someone with some experience (no me) should be able to find a good answer. This link is for the trunk, t...
0
2009-04-11T00:46:36Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
739,271
<p>duh, i'm not thinking. Just run</p> <pre><code>python manage.py syncdb </code></pre> <p>this will build you db so you can then run the server.</p>
0
2009-04-11T00:50:52Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
739,986
<p>Re-check your settings.py. In the second case, it looks like your DATABASE_ENGINE is set to the empty string, not 'sqlite3'.</p>
0
2009-04-11T12:31:40Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
749,985
<p>I found this <a href="http://groups.google.com/group/django-users/browse%5Fthread/thread/ea60854ad2e00b98" rel="nofollow">thread</a> on the Django Users group:</p> <p>They suggest that it has something to do with the way MacPorts installs Python. I wish I had more details to help you with, but as a workaround, I re...
1
2009-04-15T01:39:36Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
751,630
<p>This isn't an answer, exactly, but I would try removing the MacPorts install of Django and start over. Then try adding <a href="http://peak.telecommunity.com/DevCenter/EasyInstall" rel="nofollow">easy_install</a> and using that to install everything. To make things cleaner and easier to start over, you might also wa...
0
2009-04-15T13:12:08Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
756,828
<p>You can also try installing the py25-hashlib package if you don't have it already. I found this described on the <a href="http://code.djangoproject.com/ticket/8489" rel="nofollow">django bug tracking site</a>.</p> <p>Normally, this package is part of python, but it's either missing or wrong in the macports version,...
0
2009-04-16T16:01:10Z
[ "python", "database", "django", "sqlite" ]
"ImportError: No module named dummy" on fresh Django project
739,191
<p>I've got the following installed through MacPorts on MacOS X 10.5.6:</p> <pre><code>py25-sqlite3 @2.5.4_0 (active) python25 @2.5.4_1+darwin_9+macosx (active) sqlite3 @3.6.12_0 (active) </code></pre> <p><code>python25</code> is correctly set as my system's default Python.</p> <p>I downloaded a fresh copy of Django...
0
2009-04-10T23:53:37Z
757,829
<p>Try using the full path to python as well as checking the module path</p>
0
2009-04-16T20:04:13Z
[ "python", "database", "django", "sqlite" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
739,256
<p>Except for 1st, 2nd, and 3rd, I think they all just add th... 4th, 5th, 6th, 11th, 21st ... oh, oops ;-)</p> <p>I think this might work:</p> <pre><code>def ordinal(num): ldig = num % 10 l2dig = (num // 10) % 10 if l2dig == 1: suffix = 'th' elif ldig == 1: suffix = 'st' el...
1
2009-04-11T00:40:24Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
739,266
<p>Or shorten David's answer with:</p> <pre><code>if 4 &lt;= day &lt;= 20 or 24 &lt;= day &lt;= 30: suffix = "th" else: suffix = ["st", "nd", "rd"][day % 10 - 1] </code></pre>
29
2009-04-11T00:48:09Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
739,301
<p>Here's a more general solution:</p> <pre><code>def ordinal(n): if 10 &lt;= n % 100 &lt; 20: return str(n) + 'th' else: return str(n) + {1 : 'st', 2 : 'nd', 3 : 'rd'}.get(n % 10, "th") </code></pre>
26
2009-04-11T01:11:30Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
2,232,619
<p>Here it is using dictionaries as either a function or as a lambda...</p> <p>If you look at the dictionaries backwards you can read it as...</p> <p>Everything ends in 'th'</p> <p>...unless it ends in 1, 2, or 3 then it ends in 'st', 'nd', or 'rd'</p> <p>...unless it ends in 11, 12, or 13 then it ends in 'th, 'th'...
1
2010-02-09T21:20:51Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
2,276,874
<p>Here is an even shorter general solution:</p> <pre><code>def foo(n): return str(n) + {1: 'st', 2: 'nd', 3: 'rd'}.get(4 if 10 &lt;= n % 100 &lt; 20 else n % 10, "th") </code></pre> <p>Although the other solutions above are probably easier to understand at first glance, this works just as well while using a bit ...
0
2010-02-16T22:28:19Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
8,954,390
<p>Fixed for negative-inputs, based on eric.frederich's nice sol'n (just added <code>abs</code> when using <code>%</code>):</p> <pre><code>def ordinal(num): return '%d%s' % (num, { 11: 'th', 12: 'th', 13: 'th'}.get(abs(num) % 100, { 1: 'st',2: 'nd',3: 'rd',}.get(abs(num) % 10, 'th'))) </code></pre>
0
2012-01-21T16:00:04Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
14,257,232
<p>A more general and shorter solution (as a function):</p> <pre><code>def get_ordinal(num) ldig = num % 10 l2dig = (num // 10) % 10 if (l2dig == 1) or (ldig &gt; 3): return '%d%s' % (num, 'th') else: return '%d%s' % (num, {1: 'st', 2: 'nd', 3: 'rd'}.get(ldig)) </code></pre> <p>I just...
2
2013-01-10T11:47:26Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
16,671,215
<p>I had to convert a script over from javascript where I had a useful fn that replicated phps date obj. Very similar</p> <pre><code>def ord(n): return str(n)+("th" if 4&lt;=n%100&lt;=20 else {1:"st",2:"nd",3:"rd"}.get(n%10, "th")) </code></pre> <p>this tied in with my date styler:</p> <pre><code>def dtStylish(d...
0
2013-05-21T13:24:25Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
18,670,856
<p>I wanted to use ordinals for a project of mine and after a few prototypes I think this method although not small will work for any positive integer, yes any integer.</p> <p>It works by determiniting if the number is above or below 20, if the number is below 20 it will turn the int 1 into the string 1st , 2 , 2nd; 3...
0
2013-09-07T07:20:57Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
21,143,552
<pre><code>def ordinal(n): return ["th", "st", "nd", "rd"][n%10 if n%10&lt;4 and not (10&lt;n%100&lt;14) else 0] </code></pre>
1
2014-01-15T16:56:58Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
21,668,902
<p>Not sure if it existed 5 years ago when you asked this question, but the <a href="https://pypi.python.org/pypi/inflect">inflect</a> package has a function to do what you're looking for:</p> <pre><code>&gt;&gt;&gt; import inflect &gt;&gt;&gt; p = inflect.engine() &gt;&gt;&gt; for i in range(1,32): ... print p.or...
9
2014-02-10T04:04:22Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
29,554,088
<p>Here's a function I wrote as part of a calendar type of program I wrote (I'm not including the whole program). It adds on the correct ordinal for any number greater than 0. I included a loop to demo the output.</p> <pre><code>def ordinals(num): # st, nums ending in '1' except '11' if num[-1] == '1' and num[...
0
2015-04-10T05:34:12Z
[ "python" ]
Date Ordinal Output?
739,241
<p>I'm wondering if there is a quick and easy way to output ordinals given a number in python.</p> <p>For example, given the number <code>1</code>, I'd like to output <code>"1st"</code>, the number <code>2</code>, <code>"2nd"</code>, et cetera, et cetera.</p> <p>This is for working with dates in a breadcrumb trail</p...
18
2009-04-11T00:22:31Z
37,473,756
<p>These days I'd use Arrow <a href="http://arrow.readthedocs.io/en/latest/" rel="nofollow">http://arrow.readthedocs.io/en/latest/</a> (which definately wasn't around in '09)</p> <pre><code>&gt;&gt;&gt; import arrow &gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; arrow.get(datetime.utcnow()).format('Do') '27th...
0
2016-05-27T02:14:33Z
[ "python" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
739,286
<p>from the docs</p> <blockquote> <p>The blank choice will not be included if the model field has blank=False and an explicit default value (the default value will be initially selected instead).</p> </blockquote> <p>so set the default and you're ok</p>
30
2009-04-11T00:58:57Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
739,925
<p>If all else fails there's always JQuery*.</p> <p>It's dirty but it works.</p> <p>(*choose your JS poison)</p> <p>Edit - I'd like to see some justifications for the downvote - it's arguable that a JS solution is cleaner than the accepted answer and it's certainly quicker to implement. I'd say that this is a reason...
-2
2009-04-11T11:46:28Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
740,011
<p>Haven't tested this, but based on reading Django's code <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L680">here</a> and <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L710">here</a> I believe it should work:</p> <pre><code>class ThingForm(mod...
65
2009-04-11T12:40:43Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
741,297
<p>With Carl's answer as a guide and after rooting around the Django source for a couple hours I think this is the complete solution:</p> <ol> <li><p>To remove the empty option (extending Carl's example):</p> <pre><code>class ThingForm(models.ModelForm): class Meta: model = Thing def __init__(self, *args, *...
15
2009-04-12T05:13:30Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
1,363,109
<p>See <a href="http://code.djangoproject.com/ticket/4653" rel="nofollow">here</a> for the complete debate on and methods for resolution of this issue.</p>
4
2009-09-01T15:29:11Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
11,721,969
<p>As for the django 1.4 all you need is to set the "default" value and "blank=False" on the choices field</p> <pre><code>class MyModel(models.Model): CHOICES = ( (0, 'A'), (1, 'B'), ) choice_field = models.IntegerField(choices=CHOICES, blank=False, default=0) </code></pre>
8
2012-07-30T12:50:51Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
16,251,228
<p>you can do this in admin:</p> <pre><code>formfield_overrides = { models.ForeignKey: {'empty_label': None}, } </code></pre>
5
2013-04-27T10:52:25Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
21,071,876
<p>I was messing around with this today and just came up with a <s>coward hack</s> nifty solution:</p> <pre><code># Cowardly handle ModelChoiceField empty label # we all hate that '-----' thing class ModelChoiceField_init_hack(object): @property def empty_label(self): return self._empty_label @emp...
2
2014-01-12T06:13:41Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
21,785,041
<p>I find SOLUTION!!</p> <p>But not for ForeignKey :-)</p> <p>Maybe I can help you. I looked in Django source code and discovered that in django.forms.extras.widgets.SelecteDateWidget() is a property called none_value that equals (0, '-----') so I did in my code this</p> <pre><code>class StudentForm(ModelForm): ...
1
2014-02-14T16:52:00Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
24,868,776
<p>You can use this on your model:</p> <pre><code>class MyModel(models.Model): name = CharField('fieldname', max_length=10, default=None) </code></pre> <p><strong>default=None</strong> is the answer :D</p> <p>NOTE: I tried this on Django 1.7</p>
12
2014-07-21T15:22:22Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
29,303,202
<p>For the latest version of django the first answer should be like this</p> <pre><code>class ThingForm(models.ModelForm): class Meta: model = Thing def __init__(self, *args, **kwargs): self.base_fields['cargo'].empty_label = None super(ThingForm, self).__init__(*args, **kwargs)` </code></pre>
2
2015-03-27T14:33:39Z
[ "python", "django", "django-models", "django-forms" ]
Customize/remove Django select box blank option
739,260
<p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creates an option at the top of the list that has no ...
58
2009-04-11T00:43:58Z
30,421,758
<p><code>self.fields['xxx'].empty_value = None</code> would not work If you field type is <code>TypedChoiceField</code> which do not have <code>empty_label</code> property.</p> <p>What we should do is to remove first choice:</p> <p>1 . If you want to build a <code>BaseForm</code> auto detect <code>TypedChoiceField</c...
3
2015-05-24T09:03:09Z
[ "python", "django", "django-models", "django-forms" ]
QFileDialog passing directory to python script
739,288
<p>Im writing a little python program that goes through an XML file and does some replacement of tags. It takes three arguments, a path from whcih it creates a directory tree, the XML file its reading and the xml file its outputting to. It works fine from the command line just passing in arguments. As its not just for ...
1
2009-04-11T01:00:10Z
739,332
<p>Two potential solutions.</p> <p>Method 1:</p> <p>If you must use the displayText() method, I suggest you wrap the call to displayText() with an explicit string cast:</p> <pre><code>path = str(self.pathBox.displayText()) xmlFile = str(self.xmlFileBox.displayText()) outFileName = str(self.outfileNameBox.displayTe...
1
2009-04-11T01:30:27Z
[ "python", "qt", "parsing", "pyqt", "qfile" ]
Why is my send_mail() command not working in Django?
739,289
<p>I put the following in my settings.py file. The email address there is a test one. I found the email settings from <a href="https://help.webfaction.com/index.php?%5Fm=knowledgebase&amp;%5Fa=viewarticle&amp;kbarticleid=128&amp;nav=0,3" rel="nofollow">Webfaction</a>'s site: </p> <pre><code>EMAIL_HOST = 'smtp.webfac...
4
2009-04-11T01:00:40Z
739,291
<p>I have a Django project on Webfaction right now that is properly sending emails. The only difference between your settings and mine is that I did not specify <code>EMAIL_PORT</code> or <code>EMAIL_USE_TLS</code>. Try it out without those settings and let Django use the default it has and see if it works.</p> <p>For...
11
2009-04-11T01:04:03Z
[ "python", "django", "email" ]
Why is my send_mail() command not working in Django?
739,289
<p>I put the following in my settings.py file. The email address there is a test one. I found the email settings from <a href="https://help.webfaction.com/index.php?%5Fm=knowledgebase&amp;%5Fa=viewarticle&amp;kbarticleid=128&amp;nav=0,3" rel="nofollow">Webfaction</a>'s site: </p> <pre><code>EMAIL_HOST = 'smtp.webfac...
4
2009-04-11T01:00:40Z
4,707,876
<p>I had this problem with my hosted account at asmallorange.com. There, it was a firewall problem. I would suggest contacting support and ensuring port 465 can get through the firewall. </p>
1
2011-01-16T20:35:30Z
[ "python", "django", "email" ]
Why is my send_mail() command not working in Django?
739,289
<p>I put the following in my settings.py file. The email address there is a test one. I found the email settings from <a href="https://help.webfaction.com/index.php?%5Fm=knowledgebase&amp;%5Fa=viewarticle&amp;kbarticleid=128&amp;nav=0,3" rel="nofollow">Webfaction</a>'s site: </p> <pre><code>EMAIL_HOST = 'smtp.webfac...
4
2009-04-11T01:00:40Z
31,158,592
<p>I had this problem too. I deleted EMAIL_PORT and set EMAIL_USE_TLS = True. Now it is work.</p>
0
2015-07-01T10:18:57Z
[ "python", "django", "email" ]
Organizing a large Python project that must share an internal state?
739,311
<p>I'm currently in the middle of porting a fairly large Perl The problem is that it uses little Perl tricks to make its code available for <code>use</code>ing. I've done about the same with Python, making the codebase one big module for <code>import</code>ing. I've had a firm grasp of Python for a long time, but I hav...
1
2009-04-11T01:14:52Z
739,320
<p>It's really hard to tell without actually being able to see the code, but you should probably just consider importing the items that each module uses, in that module. It's not unusual to have a long list of imports - here's an example from my own website:</p> <pre><code># standard import inspect import linecache im...
1
2009-04-11T01:23:40Z
[ "python", "project-management", "code-organization" ]
Organizing a large Python project that must share an internal state?
739,311
<p>I'm currently in the middle of porting a fairly large Perl The problem is that it uses little Perl tricks to make its code available for <code>use</code>ing. I've done about the same with Python, making the codebase one big module for <code>import</code>ing. I've had a firm grasp of Python for a long time, but I hav...
1
2009-04-11T01:14:52Z
740,312
<blockquote> <p>what would be the best way to reorganize the project and refactor the code so that it retains its current ability to access everything else?</p> </blockquote> <p>I think you're actually quite close already, and probably better than many Python projects where they just assume that there is only one in...
1
2009-04-11T15:35:41Z
[ "python", "project-management", "code-organization" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
739,415
<p>It eludes me how you want to achieve a real translation without editing the .po files for each language? Magic?</p> <p>Edit (after comment) - how to automate the generation of the <strong>.po</strong> files:</p> <p>I don't use Gettext, but from the <a href="http://en.wikipedia.org/wiki/Gettext" rel="nofollow">wiki...
4
2009-04-11T02:49:57Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
739,522
<p>I'm using <a href="http://www.poedit.net/" rel="nofollow">poEdit</a> for translations.</p>
1
2009-04-11T04:28:23Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
740,425
<p>Use scripts. Assume your source code is in the directory $SRC, so create directory $SRC/po for i18n files (pot, po, mo etc). Then create file $SRC/po/POTFILES.in where specify path to source code files with gettext function calls. It may look like:</p> <pre><code>[encoding: UTF-8] ./main.cpp ./plugins/list.cpp </co...
3
2009-04-11T17:01:27Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
930,620
<p>You can try <a href="http://toolkit.translatehouse.org/" rel="nofollow">Translate Toolkit</a> for various po file conversions(po2csv for example). Child projects <a href="http://pootle.translatehouse.org/" rel="nofollow">Pootle</a> allows to manage translations over the web.</p>
3
2009-05-30T21:05:20Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
931,287
<p>My suggestion is <a href="http://code.google.com/p/django-rosetta/" rel="nofollow">django-rosetta</a>, which gives you a web based interface to editing your translations. Django doesn't need to be involved at all with your app, you're just using it for an online .PO edit facility.</p> <p>Another interesting new tr...
1
2009-05-31T04:43:41Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
1,079,473
<p>I've just done this for a project I'm working on, for us the process is like this:</p> <p>First, I have a POTFILES.in file which contains a list of source files needing translation. We actually have two files (e.g. admin.in and user.in), as the admin interface doesn't always need translating. So we can send trans...
20
2009-07-03T13:55:24Z
[ "python", "localization", "internationalization", "translation" ]
Easiest way to generate localization files
739,314
<p>I'm currently writing an app in Python and need to provide localization for it. </p> <p>I can use gettext and the utilities that come with it to generate .po and .mo files. But editing the .po files for each language, one-by-one, seems a bit tedious. Then, creating directories for each language and generating the ....
19
2009-04-11T01:16:14Z
9,442,227
<p>You can use <a href="https://www.transifex.net/">Transifex</a>, used by quite a few Python projects (Django, Mercurial). It has a web-based editor and command-line client for automation and also supports .NET, if that can be of help.</p> <p>Disclaimer: I'm the Transifex project lead.</p>
6
2012-02-25T07:34:13Z
[ "python", "localization", "internationalization", "translation" ]
Parsing specific elements out of a very large HTML file
739,325
<p>I have a very large HTML file (several megabytes). I know the data I want is under something like <code>&lt;div class=someName&gt;here&lt;/div&gt;</code></p> <p>What is a good library to parse through the HTML page so I can loop through elements and grab each <code>someName</code>? I want to do this in either C#, P...
1
2009-04-11T01:26:22Z
739,329
<p>Xerces is well documented, supported and tested. (C++)</p> <p><a href="http://xerces.apache.org/xerces-c/" rel="nofollow">http://xerces.apache.org/xerces-c/</a></p> <p>(yes, it's an XML parser but it should do the trick)</p>
1
2009-04-11T01:29:01Z
[ "c#", "c++", "python", "html", "parsing" ]
Parsing specific elements out of a very large HTML file
739,325
<p>I have a very large HTML file (several megabytes). I know the data I want is under something like <code>&lt;div class=someName&gt;here&lt;/div&gt;</code></p> <p>What is a good library to parse through the HTML page so I can loop through elements and grab each <code>someName</code>? I want to do this in either C#, P...
1
2009-04-11T01:26:22Z
739,330
<p>I would use Python and <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> for the job. It is very solid at handling this kind of stuff.</p> <p>For your case, you can use <a href="http://www.crummy.com/software/BeautifulSoup/documentation.html#Improving%20Performance%20by%20Pars...
13
2009-04-11T01:29:21Z
[ "c#", "c++", "python", "html", "parsing" ]
Parsing specific elements out of a very large HTML file
739,325
<p>I have a very large HTML file (several megabytes). I know the data I want is under something like <code>&lt;div class=someName&gt;here&lt;/div&gt;</code></p> <p>What is a good library to parse through the HTML page so I can loop through elements and grab each <code>someName</code>? I want to do this in either C#, P...
1
2009-04-11T01:26:22Z
739,340
<p>The <a href="http://www.codeplex.com/htmlagilitypack" rel="nofollow">Html Agility Pack</a> is a stellar option if you want to use C#</p>
3
2009-04-11T01:37:30Z
[ "c#", "c++", "python", "html", "parsing" ]
Parsing specific elements out of a very large HTML file
739,325
<p>I have a very large HTML file (several megabytes). I know the data I want is under something like <code>&lt;div class=someName&gt;here&lt;/div&gt;</code></p> <p>What is a good library to parse through the HTML page so I can loop through elements and grab each <code>someName</code>? I want to do this in either C#, P...
1
2009-04-11T01:26:22Z
739,851
<p>Sounds like a case for good old regular expressions.</p> <p>Input:</p> <pre><code>&lt;div class="test"&gt;Hello World&lt;/div&gt; &lt;div class="somename"&gt;Aloha World&lt;/div&gt; &lt;div&gt;Hey There&lt;/div&gt; </code></pre> <p>RegEx:</p> <pre><code>\&lt;div\sclass\=\"somename\"\&gt;(?&lt;Text&gt;.*?)\&lt;\/...
1
2009-04-11T10:42:33Z
[ "c#", "c++", "python", "html", "parsing" ]
Parsing specific elements out of a very large HTML file
739,325
<p>I have a very large HTML file (several megabytes). I know the data I want is under something like <code>&lt;div class=someName&gt;here&lt;/div&gt;</code></p> <p>What is a good library to parse through the HTML page so I can loop through elements and grab each <code>someName</code>? I want to do this in either C#, P...
1
2009-04-11T01:26:22Z
741,919
<p>Give <a href="http://www.grinninglizard.com/tinyxml/" rel="nofollow">TinyXML</a> a try. (C++ XML parser)</p>
0
2009-04-12T15:07:07Z
[ "c#", "c++", "python", "html", "parsing" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
739,501
<p>Here is a good link: One to Many Join using Google App Engine.</p> <p><a href="http://blog.arbingersys.com/2008/04/google-app-engine-one-to-many-join.html" rel="nofollow">http://blog.arbingersys.com/2008/04/google-app-engine-one-to-many-join.html</a></p> <p>Here is another good link: Many to Many Join using Google...
13
2009-04-11T04:08:26Z
[ "python", "sql", "google-app-engine", "gql" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
884,328
<p>I think this is the basics : Keys and Entity Groups look for it in appengine docs. (I'm new here so can't post a link)</p>
1
2009-05-19T18:27:09Z
[ "python", "sql", "google-app-engine", "gql" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
885,244
<p>Can I supplement the excellent answer further above with a link to a video:</p> <p><a href="http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine" rel="nofollow">http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine</a></p> <p>It's a great tal...
2
2009-05-19T21:59:07Z
[ "python", "sql", "google-app-engine", "gql" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
994,391
<p>I have worked on it but not a expert though Google app engine is very good thing and it is the future as it implements Platform as a Service and Software as a Service. Google app engine provides a non- relational database. So you cantreally write relationships here.</p> <p>Regards, Gaurav J</p>
0
2009-06-15T03:18:42Z
[ "python", "sql", "google-app-engine", "gql" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
1,508,916
<p>These links are great, but are predominantly python biased, I am using GWT, and therefore have to use the java flavour of GAE, does anyone have any examples of how to achieve these "join" equivalencies in the java version of GAE?</p> <p>Cheers, John</p>
0
2009-10-02T11:07:57Z
[ "python", "sql", "google-app-engine", "gql" ]
Google App Engine: Intro to their Data Store API for people with SQL Background?
739,490
<p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectively.</p> <p>For Example, if you have a self created Users Table and a Message Tabl...
7
2009-04-11T04:00:13Z
4,263,208
<p>The standalone GAE SDK is pretty difficult to use for putting data into and retrieving data from the Google App Engine data store.</p> <p>"Objectify" is a GAE extension that makes these operations much easier. The Objectify wiki and source code can be found here. I strongly recommend using Objectify in your GAE p...
0
2010-11-24T03:23:05Z
[ "python", "sql", "google-app-engine", "gql" ]
setattr with kwargs, pythonic or not?
739,625
<p>I'm using <code>__init__()</code> like this in some SQLAlchemy ORM classes that have many parameters (upto 20).</p> <pre><code>def __init__(self, **kwargs): for k, v in kwargs.iteritems(): setattr(self, k, v) </code></pre> <p>Is it "pythonic" to set attributes like this?</p>
15
2009-04-11T06:31:19Z
739,643
<p>To me it seems pretty pythonic if you only need this in one place in your code. </p> <p>The following link provides a more 'generic' approach to the same problem (e.g. with a decorator and some extra functionality), have a look at: <a href="http://code.activestate.com/recipes/551763/" rel="nofollow">http://code.act...
1
2009-04-11T06:49:43Z
[ "python", "initialization" ]
setattr with kwargs, pythonic or not?
739,625
<p>I'm using <code>__init__()</code> like this in some SQLAlchemy ORM classes that have many parameters (upto 20).</p> <pre><code>def __init__(self, **kwargs): for k, v in kwargs.iteritems(): setattr(self, k, v) </code></pre> <p>Is it "pythonic" to set attributes like this?</p>
15
2009-04-11T06:31:19Z
739,873
<p>Yes. Another way to do this is.</p> <pre><code>def __init__(self, **kwargs): self.__dict__.update( kwargs ) </code></pre>
18
2009-04-11T11:04:09Z
[ "python", "initialization" ]
setattr with kwargs, pythonic or not?
739,625
<p>I'm using <code>__init__()</code> like this in some SQLAlchemy ORM classes that have many parameters (upto 20).</p> <pre><code>def __init__(self, **kwargs): for k, v in kwargs.iteritems(): setattr(self, k, v) </code></pre> <p>Is it "pythonic" to set attributes like this?</p>
15
2009-04-11T06:31:19Z
744,161
<p>Yes, if there's not a "nicer" way of supplying the arguments.</p> <p>For example, using your ORM classes you mention, perhaps it would be more Python'y to allow..</p> <pre><code>col = Varchar() col.index = True col.length = 255 </code></pre> <p>..rather than..</p> <pre><code>col = Varchar(index = True, length = ...
4
2009-04-13T14:58:48Z
[ "python", "initialization" ]
Apply multiple negative regex to expression in Python
739,651
<p>This question is similar to <a href="http://stackoverflow.com/questions/597476/how-to-concisely-cascade-through-multiple-regex-statements-in-python">"How to concisely cascade through multiple regex statements in Python"</a> except instead of matching one regular expression and doing something I need to make sure I d...
1
2009-04-11T06:58:44Z
739,657
<p>"Squoosh" all the regexes into one line but put each in a named group using <a href="http://docs.python.org/library/re.html#regular-expression-syntax" rel="nofollow"><code>(?P&lt;name&gt;...)</code></a> then use <a href="http://docs.python.org/library/re.html#match-objects" rel="nofollow"><code>MatchOjbect.lastgroup...
2
2009-04-11T07:09:30Z
[ "python", "regex", "coding-style" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
739,665
<p>Check out <a href="http://docs.python.org/reference/compound_stmts.html#function">the documentation</a> to see how decorators work. Here is what you asked for:</p> <pre><code>def makebold(fn): def wrapped(): return "&lt;b&gt;" + fn() + "&lt;/b&gt;" return wrapped def makeitalic(fn): def wrapped...
2,338
2009-04-11T07:16:18Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
739,667
<p>Python decorators add extra functionality to another function</p> <p>An italics decorator could be like</p> <pre><code>def makeitalic(fn): def newFunc(): return "&lt;i&gt;" + fn() + "&lt;/i&gt;" return newFunc </code></pre> <p>Note that a function is defined inside a function. What it basically do...
48
2009-04-11T07:19:12Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
739,679
<p>Alternatively, you could write a factory function which return a decorator which wraps the return value of the decorated function in a tag passed to the factory function. For example:</p> <pre><code>from functools import wraps def wrap_in_tag(tag): def factory(func): @wraps(func) def decorator(...
110
2009-04-11T07:32:15Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
739,721
<p>It looks like the other people have already told you how to solve the problem. I hope this will help you understand what decorators are.</p> <p>Decorators are just syntactical sugar.</p> <p>This</p> <pre><code>@decorator def func(): ... </code></pre> <p>expands to </p> <pre><code>def func(): ... func...
72
2009-04-11T08:00:42Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
1,594,484
<p>If you are not into long explanations, see <a href="http://stackoverflow.com/questions/739654/understanding-python-decorators#answer-739665">Paolo Bergantino’s answer</a>.</p> <h1>Decorator Basics</h1> <h2>Python’s functions are objects</h2> <p>To understand decorators, you must first understand that function...
3,332
2009-10-20T13:05:46Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
4,012,213
<p>And of course you can return lambdas as well from a decorator function:</p> <pre><code>def makebold(f): return lambda: "&lt;b&gt;" + f() + "&lt;/b&gt;" def makeitalic(f): return lambda: "&lt;i&gt;" + f() + "&lt;/i&gt;" @makebold @makeitalic def say(): return "Hello" print say() </code></pre>
51
2010-10-25T06:18:12Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
8,633,375
<p>Another way of doing the same thing:</p> <pre><code>class bol(object): def __init__(self, f): self.f = f def __call__(self): return "&lt;b&gt;{}&lt;/b&gt;".format(self.f()) class ita(object): def __init__(self, f): self.f = f def __call__(self): return "&lt;i&gt;{}&lt;/i&gt;".format(self.f(...
14
2011-12-26T06:13:01Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
9,540,819
<p>Speaking of the counter example - as given above, the counter will be shared between all functions that use the decorator:</p> <pre><code>def counter(func): def wrapped(*args, **kws): print 'Called #%i' % wrapped.count wrapped.count += 1 return func(*args, **kws) wrapped.count = 0 ...
1
2012-03-02T21:47:17Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
11,673,539
<p>A decorator takes the function definition and creates a new function that executes this function and transforms the result.</p> <pre><code>@deco def do(): ... </code></pre> <p>is eqivarent to:</p> <pre><code>do = deco(do) </code></pre> <h2>Example:</h2> <pre><code>def deco(func): def inner(letter): ...
8
2012-07-26T16:11:42Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
15,840,821
<h1>Decorate functions with different number of arguments:</h1> <pre><code>def frame_tests(fn): def wrapper(*args): print "\nStart: %s" %(fn.__name__) fn(*args) print "End: %s\n" %(fn.__name__) return wrapper @frame_tests def test_fn1(): print "This is only a test!" @frame_tests d...
0
2013-04-05T18:18:08Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
17,140,530
<p>Here is a simple example of chaining decorators. Note the last line - it shows what is going on under the covers.</p> <pre><code>############################################################ # # decorators # ############################################################ def bold(fn): def decorate(): #...
2
2013-06-17T04:43:25Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
22,833,714
<pre><code>#decorator.py def makeHtmlTag(tag, *args, **kwds): def real_decorator(fn): css_class = " class='{0}'".format(kwds["css_class"]) \ if "css_class" in kwds else "" def wrapped(*args, **kwds): return "&lt;"+tag+css_class+"&gt;" + fn(*args, **kwds) ...
1
2014-04-03T09:43:12Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
29,163,633
<p>To explain decorator in a simpler way:</p> <p>With:</p> <pre><code>@decor1 @decor2 def func(*args, **kwargs): pass </code></pre> <p>When do:</p> <pre><code>func(*args, **kwargs) </code></pre> <p>You really do:</p> <pre><code>decor1(decor2(func))(*args, **kwargs) </code></pre>
3
2015-03-20T09:48:56Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
30,283,056
<p>You <em>could</em> make two separate decorators that do what you want as illustrated directly below. Note the use of <code>*args, **kwargs</code> in the declaration of the <code>wrapped()</code> function which supports the decorated function having multiple arguments (which isn't really necessary for the example <co...
8
2015-05-17T03:26:24Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
34,073,212
<blockquote> <h1>How can I make two decorators in Python that would do the following?</h1> </blockquote> <p>You want the following function, when called:</p> <blockquote> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> </blockquote> <p>To return:</p> <blockquote> <pre><code>&lt;b&gt;&...
5
2015-12-03T18:09:54Z
[ "python", "decorator", "python-decorators" ]
How to make a chain of function decorators in Python?
739,654
<p>How can I make two decorators in Python that would do the following?</p> <pre><code>@makebold @makeitalic def say(): return "Hello" </code></pre> <p>...which should return:</p> <pre><code>"&lt;b&gt;&lt;i&gt;Hello&lt;/i&gt;&lt;/b&gt;" </code></pre> <p>I'm not trying to make <code>HTML</code> this way in a real...
1,920
2009-04-11T07:05:31Z
40,047,951
<p>This question has been answered to buggery, granted. But I have an alternate solution for anyone interested in it.</p> <p>It allows you to use one decorator that will then go on to decorate your function/class with decorators that you give as arguments for the decorator.</p> <pre><code>class TupDec(object): # Give...
0
2016-10-14T16:29:30Z
[ "python", "decorator", "python-decorators" ]
Python: Locks from `threading` and `multiprocessing` interchangable?
739,687
<p>Are the locks from the <code>threading</code> module interchangeable with those from the <code>multiprocessing</code> module?</p>
5
2009-04-11T07:37:24Z
739,698
<p>I don't think so. Threading locks are within the same process, while the multiprocessing lock would likely be in shared memory.</p> <p>Last time I checked, multiprocessing doesn't allow you to share the lock in a Queue, which is a threading lock.</p>
1
2009-04-11T07:42:18Z
[ "python", "multithreading", "locking", "multiprocessing" ]