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
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
78,483
<p>Try Qt instead of wx.</p> <p>QT is cross platform, and you can style things alot using CSS. It's extremely well documented and has excellent python bindings. In point of fact, I use the C++ documentation and not the PyQT documentation.</p>
1
2008-09-16T23:57:37Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
78,589
<p>Python + Qt + OpenGL - I surely believe any application can be written faster and better using python. QT4 is cross-platform, beautifull, implements everything you need from widgets (acessibility, etc...), and...it integrates with OpenGL. That means, you can simply have a widget that is a viewport to openGL stuff yo...
3
2008-09-17T00:14:41Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
85,490
<p>Both wx and QT do an excellent job of creating an application that matches the OS look and feel. It is also possible to implment all the widgets yourself directly in openg, this slashdot post lists some of the sets available </p> <p><a href="http://ask.slashdot.org/askslashdot/02/12/24/1813219.shtml?tid=156" rel="n...
1
2008-09-17T17:14:16Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
138,630
<p>In the latest releases of QT you can draw widgets <em>into</em> your OpenGL context, if you really would like to do something like that. Otherwise there is <a href="http://www.cegui.org.uk/wiki/index.php/Main_Page">CEGui</a> that is used in some game engines. </p> <p>Implementing GUI Widgets yourself unless you wan...
7
2008-09-26T10:21:40Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
7,697,287
<p>Blender is the only app I know of with a GUI written fully in OpenGL... the only problem is it's in C++.</p> <p>I'm a Python developer as well, but I'm just getting into using OGL</p> <p>I honestly don't think there are any toolkits to develop a GUI in OGL...</p> <p>the Blender developers are giving me runaround ...
1
2011-10-08T13:59:37Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
7,697,572
<p>my friend.<br> I believe I have found your answer ;)<br> <a href="http://glinter.sourceforge.net/" rel="nofollow">http://glinter.sourceforge.net/</a></p> <p>I havn't yet tried it, but it seems quite promising. (I'll edit this if it doesn't work)</p> <p>EDIT:<br> eh...<br> it uses Tk, PMW, and WX...<br> (not quite ...
-1
2011-10-08T14:50:03Z
[ "python", "user-interface", "opengl" ]
OPENGL User Interface Programming
78,238
<p>I'm developing a graphical application to present data (not a game but a real workhorse app). It needs to be cross platform, so I have chosen:</p> <ul> <li>python</li> <li>openGL (I need 3D, blending, textures etc)</li> <li>pyopengl</li> <li>wx/pywx - windowing, dialogs etc.</li> </ul> <p>The last component - WX -...
1
2008-09-16T23:11:31Z
26,485,404
<p>"<a href="http://cegui.org.uk" rel="nofollow">cegui</a>" is a good choise there is also a gui editor called "ceed" to generate the layout xml files. cegui also has python bindings and its well documented and used in many game engines</p>
0
2014-10-21T11:18:49Z
[ "python", "user-interface", "opengl" ]
Redirect command to input of another in Python
78,431
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
5
2008-09-16T23:46:47Z
78,459
<p>There is also the commands module:</p> <pre><code>import commands status, output = commands.getstatusoutput("gvimdiff &lt;(hg cat file.txt) file.txt") </code></pre> <p>There is also the popen set of functions, if you want to actually grok the data from a command as it is running.</p>
2
2008-09-16T23:53:40Z
[ "python", "bash", "redirect", "diff", "vimdiff" ]
Redirect command to input of another in Python
78,431
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
5
2008-09-16T23:46:47Z
78,481
<p>It just dawned on me that you are probably looking for one of the popen functions.</p> <p>from: <a href="http://docs.python.org/lib/module-popen2.html" rel="nofollow">http://docs.python.org/lib/module-popen2.html</a></p> <p>popen3(cmd[, bufsize[, mode]]) Executes cmd as a sub-process. Returns the file objects ...
-1
2008-09-16T23:57:24Z
[ "python", "bash", "redirect", "diff", "vimdiff" ]
Redirect command to input of another in Python
78,431
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
5
2008-09-16T23:46:47Z
78,482
<p>It can be done. As of Python 2.5, however, this mechanism is Linux-specific and not portable:</p> <pre><code>import subprocess import sys file = sys.argv[1] p1 = subprocess.Popen(['hg', 'cat', file], stdout=subprocess.PIPE) p2 = subprocess.Popen([ 'gvimdiff', '/proc/self/fd/%s' % p1.stdout.fileno(), fi...
8
2008-09-16T23:57:32Z
[ "python", "bash", "redirect", "diff", "vimdiff" ]
Redirect command to input of another in Python
78,431
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
5
2008-09-16T23:46:47Z
78,923
<p>This is actually an example in the <a href="https://docs.python.org/2.4/lib/node242.html" rel="nofollow">docs</a>:</p> <pre><code>p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) output = p2.communicate()[0] </code></pre> <p>which means for you:</p> <pre><code>import su...
2
2008-09-17T01:26:43Z
[ "python", "bash", "redirect", "diff", "vimdiff" ]
Python ReportLab use of splitfirst/splitlast
78,450
<p>I'm trying to use Python with ReportLab 2.2 to create a PDF report.<br /> According to the <a href="http://www.reportlab.com/docs/userguide.pdf">user guide</a>,</p> <blockquote> <p>Special TableStyle Indeces [sic]</p> <p>In any style command the first row index may be set to one of the special strings 'split...
6
2008-09-16T23:52:04Z
78,702
<blockquote> <p>[...] In any style command <strong>the first row index</strong> may be set to one of the special strings [...]</p> </blockquote> <p>In your first example you're setting the <em>second</em> row index to a special string as well.</p> <p>Not sure why the other two don't work... Are you sure this is w...
0
2008-09-17T00:40:54Z
[ "python", "reportlab" ]
Python ReportLab use of splitfirst/splitlast
78,450
<p>I'm trying to use Python with ReportLab 2.2 to create a PDF report.<br /> According to the <a href="http://www.reportlab.com/docs/userguide.pdf">user guide</a>,</p> <blockquote> <p>Special TableStyle Indeces [sic]</p> <p>In any style command the first row index may be set to one of the special strings 'split...
6
2008-09-16T23:52:04Z
94,869
<p>Well, it looks as if I will be answering my own question.</p> <p>First, the documentation flat out lies where it reads "In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split table, or t...
2
2008-09-18T17:46:36Z
[ "python", "reportlab" ]
Python ReportLab use of splitfirst/splitlast
78,450
<p>I'm trying to use Python with ReportLab 2.2 to create a PDF report.<br /> According to the <a href="http://www.reportlab.com/docs/userguide.pdf">user guide</a>,</p> <blockquote> <p>Special TableStyle Indeces [sic]</p> <p>In any style command the first row index may be set to one of the special strings 'split...
6
2008-09-16T23:52:04Z
2,623,783
<p>This seems to be a bug in the ReportLab Table class. Another fix for this in addition to <a href="http://stackoverflow.com/a/94869/669202">DLJessup's own answer</a> is to modify the ReportLab code that's causing the error, in <code>Table._drawBkgrnd()</code>, around line 1301. For 'splitlast', change:</p> <pre><c...
1
2010-04-12T16:52:07Z
[ "python", "reportlab" ]
Is there a benefit to defining a class inside another class in Python?
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
54
2008-09-17T01:02:31Z
78,855
<p>No, composition does not mean nesting. It would make sense to have a nested class if you want to hide it more in the namespace of the outer class.</p> <p>Anyway, I don't see any practical use for nesting in your case. It would make the code harder to read (understand) and it would also increase the indentation whic...
1
2008-09-17T01:11:41Z
[ "python", "oop" ]
Is there a benefit to defining a class inside another class in Python?
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
54
2008-09-17T01:02:31Z
78,858
<p>You might want to do this when the "inner" class is a one-off, which will never be used outside the <em>definition</em> of the outer class. For example to use a metaclass, it's sometimes handy to do</p> <pre><code>class Foo(object): class __metaclass__(type): .... </code></pre> <p>instead of defining a...
72
2008-09-17T01:12:59Z
[ "python", "oop" ]
Is there a benefit to defining a class inside another class in Python?
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
54
2008-09-17T01:02:31Z
78,868
<p>I don't know Python, but your question seems very general. Ignore me if it's specific to Python.</p> <p>Class nesting is all about scope. If you think that one class will only make sense in the context of another one, then the former is probably a good candidate to become a nested class.</p> <p>It is a common patt...
14
2008-09-17T01:14:33Z
[ "python", "oop" ]
Is there a benefit to defining a class inside another class in Python?
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
54
2008-09-17T01:02:31Z
78,968
<p>You could be using a class as class generator. Like (in some off the cuff code :)</p> <pre><code>class gen(object): class base_1(object): pass ... class base_n(object): pass def __init__(self, ...): ... def mk_cls(self, ..., type): '''makes a class based on the type passed in, t...
2
2008-09-17T01:34:41Z
[ "python", "oop" ]
Is there a benefit to defining a class inside another class in Python?
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
54
2008-09-17T01:02:31Z
79,094
<p>There is really no benefit to doing this, except if you are dealing with metaclasses.</p> <p>the class: suite really isn't what you think it is. It is a weird scope, and it does strange things. It really doesn't even make a class! It is just a way of collecting some variables - the name of the class, the bases, a l...
4
2008-09-17T01:52:55Z
[ "python", "oop" ]
How to check for memory leaks in Guile extension modules?
78,900
<p>I develop an extension module for Guile, written in C. This extension module embeds a Python interpreter.</p> <p>Since this extension module invokes the Python interpreter, I need to verify that it properly manages the memory occupied by Python objects. </p> <p>I found that the Python interpreter is well-behaved...
3
2008-09-17T01:22:56Z
78,990
<p>You've got a couple options. One is to write a supressions file for valgrind that turns off reporting of stuff that you're not working on. Python has such a file, for example: <a href="http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp" rel="nofollow">http://svn.python.org/projects/python/trunk/M...
4
2008-09-17T01:38:24Z
[ "python", "memory-leaks", "valgrind", "guile" ]
Testing GUI code: should I use a mocking library?
79,454
<p>Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to ...
5
2008-09-17T02:52:58Z
79,667
<p>Unit tests are really useful when you refactor your code (ie. completely rewrite or move a module). As long as you have unit tests before you do the big changes, you'll have confidence that you havent forgotten to move or include something when you finish.</p>
-2
2008-09-17T03:30:19Z
[ "python", "unit-testing", "user-interface", "tdd" ]
Testing GUI code: should I use a mocking library?
79,454
<p>Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to ...
5
2008-09-17T02:52:58Z
80,028
<p><strong>If you are writing your tests after you've written your code and making them pass, you are not doing TDD</strong> (nor are you getting any benefits of Test-First or Test-Driven development.. check out SO questions for definitive books on TDD)</p> <blockquote> <p>One of the things I've noticed with using...
7
2008-09-17T04:33:46Z
[ "python", "unit-testing", "user-interface", "tdd" ]
Testing GUI code: should I use a mocking library?
79,454
<p>Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to ...
5
2008-09-17T02:52:58Z
82,049
<p><strong>Please remember that TDD is not a panaceum.</strong> It's hard, it's supposed to be hard, and it's especially hard to write mocking tests "in advance".</p> <p>So I would say - do what works for you. Even it's not "certified TDD". I do basically the same thing.</p> <p>You may want to provide your own API fo...
-3
2008-09-17T11:08:17Z
[ "python", "unit-testing", "user-interface", "tdd" ]
How do I get started processing email related to website activity?
79,602
<p>I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for aut...
1
2008-09-17T03:19:29Z
79,670
<p>There are some pretty serious concerns here for how to send email automatically, and here are a few:</p> <p>Use an email library. Python includes one called 'email'. This is your friend, it will stop you from doing anything tragically wrong. Read an example from <a href="http://docs.python.org/lib/node161.html" rel...
3
2008-09-17T03:31:07Z
[ "python", "email" ]
How do I get started processing email related to website activity?
79,602
<p>I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for aut...
1
2008-09-17T03:19:29Z
79,743
<p>Some general information with regards to automated mail processing...</p> <p>First, the mail server "brand" itself isn't that important for broadcasting or receiving emails. All of them support the standard smtp / pop3 communications protocol. Most even have IMAP support and have some level of spam filtering. Tha...
2
2008-09-17T03:44:00Z
[ "python", "email" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
79,826
<p>Don't try to run <code>unittest.main()</code> from IDLE. It's trying to access <code>sys.argv</code>, and it's getting the args that IDLE was started with. Either run your tests in a different way from IDLE, or call <code>unittest.main()</code> in its own Python process.</p>
10
2008-09-17T03:58:24Z
[ "python", "unit-testing" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
79,833
<p>Your example is exiting on my install too. I can make it execute the tests and stay within Python by changing</p> <pre><code>unittest.main() </code></pre> <p>to</p> <pre><code>unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromTestCase(Test)) </code></pre> <p>More information is available <a href=...
10
2008-09-17T03:59:27Z
[ "python", "unit-testing" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
79,932
<p>Pop open the source code to <code>unittest.py</code>. <code>unittest.main()</code> is hard-coded to call <code>sys.exit()</code> after running all tests. Use <code>TextTestRunner</code> to run test suites from the prompt.</p>
5
2008-09-17T04:19:45Z
[ "python", "unit-testing" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
407,950
<pre><code>try: sys.exit() except SystemExit: print('Simple as that, but you should really use a TestRunner instead') </code></pre>
1
2009-01-02T20:34:33Z
[ "python", "unit-testing" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
3,215,505
<p>In new Python 2.7 release, <a href="http://docs.python.org/library/unittest.html#unittest.main" rel="nofollow">unittest.main()</a> has a new argument.</p> <p>If 'exit' is set to <code>False</code>, <code>sys.exit()</code> is not called during the execution of <code>unittest.main()</code>.</p>
17
2010-07-09T18:30:28Z
[ "python", "unit-testing" ]
Unittest causing sys.exit()
79,754
<p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p> <pre><code>IDLE 1.2.2 ==== No Subprocess ==== &gt;&gt;&gt; import unittest &gt;&gt;&gt; &gt;&gt;&gt; class Test(unittest.TestCase): def testA(self): ...
11
2008-09-17T03:46:55Z
21,262,077
<p>It's nice to be able to demonstrate that your tests work when first trying out the unittest module, and to know that you won't exit your Python shell. However, these solutions are version dependent.</p> <h2>Python 2.6</h2> <p>I'm using Python 2.6 at work, <code>import</code>ing <code>unittest2 as unittest</code> (...
3
2014-01-21T15:18:13Z
[ "python", "unit-testing" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
79,808
<pre><code>def local_to_utc(t): secs = time.mktime(t) return time.gmtime(secs) def utc_to_local(t): secs = calendar.timegm(t) return time.localtime(secs) </code></pre> <p>Source: <a href="http://feihonghsu.blogspot.com/2008/02/converting-from-local-time-to-utc.html">http://feihonghsu.blogspot.com/2008...
20
2008-09-17T03:54:39Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
79,877
<p>First, parse the string into a naive datetime object. This is an instance of <code>datetime.datetime</code> with no attached timezone information. See documentation for <code>datetime.strptime</code> for information on parsing the date string.</p> <p>Use the <a href="http://pytz.sourceforge.net/"><code>pytz</code><...
137
2008-09-17T04:07:28Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
79,913
<p>Thanks @rofly, the full conversion from string to string is as follows:</p> <pre><code>time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.mktime(time.strptime("2008-09-17 14:04:00", "%Y-%m-%d %H:%M:%S")))) </code></pre> <p>My summary of the <code...
51
2008-09-17T04:15:39Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
1,464,261
<p>How about - </p> <pre><code>time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(seconds)) </code></pre> <p>if seconds is <code>None</code> then it converts the local time to UTC time else converts the passed in time to UTC.</p>
2
2009-09-23T06:28:23Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
2,175,170
<p>The datetime module's <a href="http://docs.python.org/library/datetime.html#datetime.datetime.utcnow" rel="nofollow">utcnow()</a> function can be used to obtain the current UTC time.</p> <pre><code>&gt;&gt;&gt; import datetime &gt;&gt;&gt; utc_datetime = datetime.datetime.utcnow() &gt;&gt;&gt; utc_datetime.strftime...
60
2010-02-01T07:00:27Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
2,347,991
<p>if you prefer datetime.datetime:</p> <pre><code>dt = datetime.strptime("2008-09-17 14:04:00","%Y-%m-%d %H:%M:%S") utc_struct_time = time.gmtime(time.mktime(dt.timetuple())) utc_dt = datetime.fromtimestamp(time.mktime(utc_struct_time)) print dt.strftime("%Y-%m-%d %H:%M:%S") </code></pre>
4
2010-02-27T16:12:25Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
4,113,872
<p>in this case ... pytz is best lib</p> <pre><code>import pytz utc = pytz.utc yourdate = datetime.datetime.now() yourdateutc = yourdate.astimezone(utc).replace(tzinfo=None) </code></pre>
-1
2010-11-06T16:02:06Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
4,894,920
<pre><code>import time import datetime def Local2UTC(LocalTime): EpochSecond = time.mktime(LocalTime.timetuple()) utcTime = datetime.datetime.utcfromtimestamp(EpochSecond) return utcTime &gt;&gt;&gt; LocalTime = datetime.datetime.now() &gt;&gt;&gt; UTCTime = Local2UTC(LocalTime) &gt;&gt;&gt; LocalTim...
4
2011-02-04T05:38:34Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
8,068,619
<p>For getting around day-light saving, etc.</p> <p>None of the above answers particularly helped me. The code below works for GMT.</p> <pre><code>def get_utc_from_local(date_time, local_tz=None): assert date_time.__class__.__name__ == 'datetime' if local_tz is None: local_tz = pytz.timezone(settings....
2
2011-11-09T16:59:57Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
8,563,126
<p>I'm having good luck with <a href="http://labix.org/python-dateutil">dateutil</a> (which is widely recommended on SO for other related questions):</p> <pre><code>from datetime import * from dateutil import * from dateutil.tz import * # METHOD 1: Hardcode zones: utc_zone = tz.gettz('UTC') local_zone = tz.gettz('Ame...
11
2011-12-19T14:58:01Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
10,040,725
<p>One more example with pytz, but includes localize(), which saved my day.</p> <pre><code>import pytz, datetime utc = pytz.utc fmt = '%Y-%m-%d %H:%M:%S' amsterdam = pytz.timezone('Europe/Amsterdam') dt = datetime.datetime.strptime("2012-04-06 10:00:00", fmt) am_dt = amsterdam.localize(dt) print am_dt.astimezone(utc)...
14
2012-04-06T07:54:41Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
12,059,267
<p>You can do it with:</p> <pre><code>&gt;&gt;&gt; from time import strftime, gmtime, localtime &gt;&gt;&gt; strftime('%H:%M:%S', gmtime()) #UTC time &gt;&gt;&gt; strftime('%H:%M:%S', localtime()) # localtime </code></pre>
2
2012-08-21T16:30:50Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
12,186,921
<p>I've had the most success with <a href="https://dateutil.readthedocs.org/en/latest/relativedelta.html" rel="nofollow">python-dateutil</a>:</p> <pre><code>from dateutil import tz def datetime_to_utc(date): """Returns date in UTC w/o tzinfo""" return date.astimezone(tz.gettz('UTC')).replace(tzinfo=None) if d...
5
2012-08-29T21:40:03Z
[ "python", "datetime", "utc" ]
How do I convert local time to UTC in Python?
79,797
<p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p> <p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p> <p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo...
147
2008-09-17T03:52:42Z
13,084,428
<p>Here's a summary of common Python time conversions</p> <ul> <li>struct_time (UTC) → POSIX:<br><code>calendar.timegm(struct_time)</code></li> <li>Naïve datetime (local) → POSIX:<br><code>calendar.timegm(stz.localize(dt, is_dst=None).utctimetuple())</code></li> <li>Naïve datetime (UTC) → POSIX:<br><code>calen...
9
2012-10-26T09:38:42Z
[ "python", "datetime", "utc" ]
How do you design data models for Bigtable/Datastore (GAE)?
79,850
<p>Since the Google App Engine Datastore is based on <a href="http://research.google.com/archive/bigtable.html">Bigtable</a> and we know that's not a relational database, how do you design a <strong><em>database schema</em>/*data model*</strong> for applications that use this type of database system?</p>
17
2008-09-17T04:02:53Z
80,420
<p>As GAE builds on how data is managed in Django there is a lot of info on how to address similar questions in the Django documentation (for example see <a href="http://www.djangobook.com/en/1.0/chapter05/" rel="nofollow">here</a>, scroll down to 'Your first model').</p> <p>In short you design you db model as a regul...
-2
2008-09-17T06:01:53Z
[ "python", "database", "google-app-engine", "bigtable" ]
How do you design data models for Bigtable/Datastore (GAE)?
79,850
<p>Since the Google App Engine Datastore is based on <a href="http://research.google.com/archive/bigtable.html">Bigtable</a> and we know that's not a relational database, how do you design a <strong><em>database schema</em>/*data model*</strong> for applications that use this type of database system?</p>
17
2008-09-17T04:02:53Z
80,425
<p>Designing a bigtable schema is an open process, and basically requires you to think about:</p> <ul> <li>The access patterns you will be using and how often each will be used</li> <li>The relationships between your types</li> <li>What indices you are going to need</li> <li>The write patterns you will be using (in or...
18
2008-09-17T06:02:38Z
[ "python", "database", "google-app-engine", "bigtable" ]
How do you design data models for Bigtable/Datastore (GAE)?
79,850
<p>Since the Google App Engine Datastore is based on <a href="http://research.google.com/archive/bigtable.html">Bigtable</a> and we know that's not a relational database, how do you design a <strong><em>database schema</em>/*data model*</strong> for applications that use this type of database system?</p>
17
2008-09-17T04:02:53Z
196,660
<p>You can use www.web2py.com. You build the model and the application once and it works on GAE but also witl SQLite, MySQL, Posgres, Oracle, MSSQL, FireBird</p>
1
2008-10-13T03:49:29Z
[ "python", "database", "google-app-engine", "bigtable" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
79,985
<p>You want split, from the <a href="https://docs.python.org/2/library/shlex.html">shlex</a> module.</p> <pre><code>&gt;&gt;&gt; import shlex &gt;&gt;&gt; shlex.split('this is "a test"') ['this', 'is', 'a test'] </code></pre> <p>This should do exactly what you want.</p>
253
2008-09-17T04:27:32Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
79,989
<p>Have a look at the <code>shlex</code> module, particularly <code>shlex.split</code>.</p> <blockquote> <p><code>&gt;&gt;&gt; import shlex</code></p> <p><code>&gt;&gt;&gt; shlex.split('This is "a test"')</code></p> <p><code>['This', 'is', 'a test']</code></p> </blockquote>
45
2008-09-17T04:27:59Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
80,015
<p>Try this:</p> <pre><code> def adamsplit(s): result = [] inquotes = False for substring in s.split('"'): if not inquotes: result.extend(substring.split()) else: result.append(substring) inquotes = not inquotes return result </code></pre> <p>Some test strings:</p> ...
-2
2008-09-17T04:31:38Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
80,361
<p>If you don't care about sub strings than a simple</p> <pre><code>&gt;&gt;&gt; 'a short sized string with spaces '.split() </code></pre> <p>Performance:</p> <pre><code>&gt;&gt;&gt; s = " ('a short sized string with spaces '*100).split() " &gt;&gt;&gt; t = timeit.Timer(stmt=s) &gt;&gt;&gt; print "%.2f usec/pass" % ...
-1
2008-09-17T05:46:57Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
80,449
<p>Since this question is tagged with regex, I decided to try a regex approach. I first replace all the spaces in the quotes parts with \x00, then split by spaces, then replace the \x00 back to spaces in each part.</p> <p>Both versions do the same thing, but splitter is a bit more readable then splitter2.</p> <pre><c...
8
2008-09-17T06:08:38Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
524,796
<p>I see regex approaches here that look complex and/or wrong. This surprises me, because regex syntax can easily describe "whitespace or thing-surrounded-by-quotes", and most regex engines (including Python's) can split on a regex. So if you're going to use regexes, why not just say exactly what you mean?:</p> <pre...
26
2009-02-07T23:17:26Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
525,011
<p>Depending on your use case, you may also want to check out the csv module:</p> <pre><code>import csv lines = ['this is "a string"', 'and more "stuff"'] for row in csv.reader(lines, delimiter=" "): print row </code></pre> <p>Output: </p> <pre><code>['this', 'is', 'a string'] ['and', 'more', 'stuff'] </code></p...
17
2009-02-08T02:18:46Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
2,159,337
<p>Hmm, can't seem to find the "Reply" button... anyway, this answer is based on the approach by Kate, but correctly splits strings with substrings containing escaped quotes and also removes the start and end quotes of the substrings:</p> <pre><code> [i.strip('"').strip("'") for i in re.split(r'(\s+|(?&lt;!\\)".*?(?&...
1
2010-01-29T01:36:23Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
11,194,593
<p>To get around the unicode issues in some Python 2 versions, I suggest:</p> <pre><code>from shlex import split as _split split = lambda a: [b.decode('utf-8') for b in _split(a.encode('utf-8'))] </code></pre>
2
2012-06-25T17:51:17Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
11,644,046
<p>The unicode issues with shlex discussed above (top answer) appear to be resolved (indirectly) in 2.7.2+ as per <a href="http://bugs.python.org/issue6988#msg146200" rel="nofollow">http://bugs.python.org/issue6988#msg146200</a></p> <p>(separate answer because I can't comment)</p>
1
2012-07-25T06:42:53Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
23,155,180
<p>I use shlex.split to process 70,000,000 lines of squid log, it's so slow. So I switched to re.</p> <p>Please try this, if you have performance problem with shlex.</p> <pre><code>import re def line_split(line): return re.findall(r'[^"\s]\S*|".+?"', line) </code></pre>
3
2014-04-18T13:29:10Z
[ "python", "regex" ]
Split a string by spaces -- preserving quoted substrings -- in Python
79,968
<p>I have a string which is like this:</p> <pre><code>this is "a test" </code></pre> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p> <pre><code>['this','is','a test'] </code></pre> <p>PS. I know you are going to ask "what hap...
163
2008-09-17T04:25:15Z
32,480,710
<p>I suggest:</p> <p>test string:</p> <pre><code>s = 'abc "ad" \'fg\' "kk\'rdt\'" zzz"34"zzz "" \'\'' </code></pre> <p>to capture also "" and '':</p> <pre><code>import re re.findall(r'"[^"]*"|\'[^\']*\'|[^"\'\s]+',s) </code></pre> <p>result:</p> <pre><code>['abc', '"ad"', "'fg'", '"kk\'rdt\'"', 'zzz', '"34"', 'zz...
0
2015-09-09T13:19:59Z
[ "python", "regex" ]
Btrieve without Pervasive?
80,215
<p>Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.</p>
2
2008-09-17T05:15:02Z
80,596
<p>As far as I know that is not possible. It is not an open source database, so writing drivers for it is really hard.</p>
1
2008-09-17T06:45:50Z
[ "c#", "python", "btrieve" ]
Btrieve without Pervasive?
80,215
<p>Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.</p>
2
2008-09-17T05:15:02Z
275,524
<p>If you download one of the trial versions, you can get/install the odbc client and connect that way.</p> <p>In our version of pervasive (older version) on the server where the database is installed, you can also find this client install.</p>
2
2008-11-09T02:28:52Z
[ "c#", "python", "btrieve" ]
Btrieve without Pervasive?
80,215
<p>Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.</p>
2
2008-09-17T05:15:02Z
718,654
<p>This depends a lot on the version of Btrieve. I've been working with btrieve for a long time and have found that the best API for the old 6.15 version was in pascal. That having been said there was definately a C api around as well.</p> <p>Pervasive have recently released a 6.15 ultimate patch. Using this and the C...
0
2009-04-05T09:39:25Z
[ "c#", "python", "btrieve" ]
PubSub lib for c#
80,347
<p>Is there a c# library which provides similar functionality to the <a href="http://wiki.wxpython.org/PubSub" rel="nofollow">Python PubSub</a> library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events.</p>
1
2008-09-17T05:44:30Z
80,362
<p>These may be a bit heavy for you depending on your needs but: <a href="http://www.nservicebus.com/" rel="nofollow">http://www.nservicebus.com/</a> <a href="http://blog.phatboyg.com/masstransit/" rel="nofollow">http://blog.phatboyg.com/masstransit/</a></p>
3
2008-09-17T05:47:09Z
[ "c#", "python", "design-patterns" ]
PubSub lib for c#
80,347
<p>Is there a c# library which provides similar functionality to the <a href="http://wiki.wxpython.org/PubSub" rel="nofollow">Python PubSub</a> library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events.</p>
1
2008-09-17T05:44:30Z
80,864
<p>Again, my be overkill, but the <a href="http://ose.sf.net" rel="nofollow">OSE</a> library allows thins kind of thing.</p>
0
2008-09-17T07:42:21Z
[ "c#", "python", "design-patterns" ]
PubSub lib for c#
80,347
<p>Is there a c# library which provides similar functionality to the <a href="http://wiki.wxpython.org/PubSub" rel="nofollow">Python PubSub</a> library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events.</p>
1
2008-09-17T05:44:30Z
467,248
<p>Note, if you have events for message notification, there are many options for dependancy injection / inversion of control. See <a href="http://www.springframework.net/" rel="nofollow">Spring.Net</a> and <a href="http://www.castleproject.org/container/" rel="nofollow">Castle Windsor</a> as two popular frameworks.</p...
1
2009-01-21T22:15:14Z
[ "c#", "python", "design-patterns" ]
PubSub lib for c#
80,347
<p>Is there a c# library which provides similar functionality to the <a href="http://wiki.wxpython.org/PubSub" rel="nofollow">Python PubSub</a> library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events.</p>
1
2008-09-17T05:44:30Z
29,311,041
<p>Looks like there are several offerings on NuGet: <a href="https://www.nuget.org/packages?q=pubsub" rel="nofollow">https://www.nuget.org/packages?q=pubsub</a></p>
0
2015-03-27T22:13:05Z
[ "c#", "python", "design-patterns" ]
Asychronous Programming in Python Twisted
80,617
<p>I'm having trouble developing a reverse proxy in Twisted. It works, but it seems overly complex and convoluted. So much of it feels like voodoo...</p> <p>Are there any <em>simple, solid</em> examples of asynchronous program structure on the web or in books? A sort of best practices guide? When I complete my program...
29
2008-09-17T06:51:35Z
81,106
<p>If you aren't looking to use twisted there was a great guide I used a while back. Here is the <a href="http://www.nightmare.com/pythonwin/async_sockets.html" rel="nofollow">link to it</a>.</p>
0
2008-09-17T08:25:06Z
[ "python", "asynchronous", "twisted" ]
Asychronous Programming in Python Twisted
80,617
<p>I'm having trouble developing a reverse proxy in Twisted. It works, but it seems overly complex and convoluted. So much of it feels like voodoo...</p> <p>Are there any <em>simple, solid</em> examples of asynchronous program structure on the web or in books? A sort of best practices guide? When I complete my program...
29
2008-09-17T06:51:35Z
81,456
<p>Twisted contains a <a href="http://twistedmatrix.com/projects/core/documentation/howto/index.html">large number of examples</a>. One in particular, the <a href="http://twistedmatrix.com/projects/core/documentation/howto/tutorial/intro.html">"evolution of Finger" tutorial</a>, contains a thorough explanation of how ...
63
2008-09-17T09:29:45Z
[ "python", "asynchronous", "twisted" ]
How to skip sys.exitfunc when unhandled exceptions occur
80,993
<p>As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?</p> <pre><code>import atexit def helloworld(): print("Hello World!") atexit.register(helloworld) raise Exception("Good bye cruel world!") </code></pre> <p>...
4
2008-09-17T08:05:18Z
81,051
<p>If you call</p> <pre><code>import os os._exit(0) </code></pre> <p>the exit handlers will not be called, yours or those registered by other modules in the application.</p>
0
2008-09-17T08:15:58Z
[ "python", "exception", "atexit" ]
How to skip sys.exitfunc when unhandled exceptions occur
80,993
<p>As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?</p> <pre><code>import atexit def helloworld(): print("Hello World!") atexit.register(helloworld) raise Exception("Good bye cruel world!") </code></pre> <p>...
4
2008-09-17T08:05:18Z
81,087
<p>I don't really know why you want to do that, but you can install an excepthook that will be called by Python whenever an uncatched exception is raised, and in it clear the array of registered function in the <code>atexit</code> module.</p> <p>Something like that :</p> <pre><code>import sys import atexit def clear...
5
2008-09-17T08:21:20Z
[ "python", "exception", "atexit" ]
How to skip sys.exitfunc when unhandled exceptions occur
80,993
<p>As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?</p> <pre><code>import atexit def helloworld(): print("Hello World!") atexit.register(helloworld) raise Exception("Good bye cruel world!") </code></pre> <p>...
4
2008-09-17T08:05:18Z
81,107
<p>In addition to calling os._exit() to avoid the registered exit handler you also need to catch the unhandled exception:</p> <pre><code>import atexit import os def helloworld(): print "Hello World!" atexit.register(helloworld) try: raise Exception("Good bye cruel world!") except Exception, e: prin...
0
2008-09-17T08:25:14Z
[ "python", "exception", "atexit" ]
PythonWin's python interactive shell calling constructors twice?
81,191
<p>While answering <a href="http://stackoverflow.com/questions/68645/python-static-variable#81002">http://stackoverflow.com/questions/68645/python-static-variable#81002</a> </p> <p>I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?</p> <pre><code>PythonWin 2.5 (r25:51908, Mar 9 2007, 1...
2
2008-09-17T08:42:07Z
81,274
<p>My guess is as follows. The PythonWin editor offers autocomplete for an object, i.e. when you type <code>myobject.</code> it offers a little popup of all the availble method names. So I think when you type <code>X().</code> it's creating an instance of <code>X</code> in the background and doing a <code>dir</code> ...
3
2008-09-17T08:57:41Z
[ "python", "activestate" ]
PythonWin's python interactive shell calling constructors twice?
81,191
<p>While answering <a href="http://stackoverflow.com/questions/68645/python-static-variable#81002">http://stackoverflow.com/questions/68645/python-static-variable#81002</a> </p> <p>I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?</p> <pre><code>PythonWin 2.5 (r25:51908, Mar 9 2007, 1...
2
2008-09-17T08:42:07Z
81,751
<p>Two small additional points.</p> <p>First, <code>self.__class__.l.append(1)</code> isn't really sensible.</p> <p>Just say <code>self.l.append(1)</code>. Python searches the instance before it searches the class for the reference.</p> <p>More importantly, class-level variables are rarely useful. Class-level cons...
1
2008-09-17T10:18:30Z
[ "python", "activestate" ]
PythonWin's python interactive shell calling constructors twice?
81,191
<p>While answering <a href="http://stackoverflow.com/questions/68645/python-static-variable#81002">http://stackoverflow.com/questions/68645/python-static-variable#81002</a> </p> <p>I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice?</p> <pre><code>PythonWin 2.5 (r25:51908, Mar 9 2007, 1...
2
2008-09-17T08:42:07Z
84,248
<p>Dave Webb is correct, and you can see this by adding a print statement:</p> <pre><code>&gt;&gt;&gt; class X: ... l = [] ... def __init__(self): ... print 'inited' ... self.__class__.l.append(1) ... </code></pre> <p>Then as soon as you type the period in <code>X().</code> it prints <...
2
2008-09-17T15:08:22Z
[ "python", "activestate" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
81,479
<p>You can not store files as there is not a traditional file system. You can only store them in their own DataStore (in a field defined as a <a href="http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html" rel="nofollow">BlobProperty</a>)</p> <p>There is an example in the previous link:</p> <p...
1
2008-09-17T09:32:32Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
81,489
<p>There's no flat file storing in Google App Engine. Everything has to go in to the <a href="http://code.google.com/appengine/docs/datastore/" rel="nofollow">Datastore</a> which is a bit like a relational database but not quite.</p> <p>You could store the files as <a href="http://code.google.com/appengine/docs/datas...
0
2008-09-17T09:33:52Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
143,798
<p>There is a thread in Google Groups about it:</p> <p><a href="http://groups.google.com/group/google-appengine/browse_thread/thread/f9d0f22d8de8c025/bba32165e308dd13?lnk=gst&amp;q=uploading+files#bba32165e308dd13">Uploading Files</a></p> <p>With a lot of useful code, that discussion helped me very much in uploading ...
10
2008-09-27T15:20:58Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
173,918
<p>In fact, this question is answered in the App Egnine documentation. See an example on <a href="http://code.google.com/appengine/docs/images/usingimages.html#Uploading">Uploading User Images</a>.</p> <p>HTML code, inside &lt;form&gt;&lt;/form&gt;:</p> <pre>&lt;input type="file" name="img"/&gt;</pre> <p>Python code...
48
2008-10-06T11:15:22Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
534,354
<p>If your still having a problem, check you are using enctype in the form tag</p> <p>No:</p> <pre><code>&lt;form encoding="multipart/form-data" action="/upload"&gt; </code></pre> <p>Yes:</p> <pre><code>&lt;form enctype="multipart/form-data" action="/upload"&gt; </code></pre>
3
2009-02-10T21:47:22Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
1,240,820
<p>Personally I found the tutorial described <a href="http://shogi-software.blogspot.com/2009/04/google-app-engine-and-file-upload.html" rel="nofollow">here</a> useful when using the Java run time with GAE. For some reason, when I tried to upload a file using</p> <pre><code>&lt;form action="/testservelet" method="get"...
1
2009-08-06T19:19:13Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
1,987,486
<p>Google has released a service for storing large files. Have a look at <a href="http://code.google.com/appengine/docs/python/blobstore/" rel="nofollow">blobstore API documentation</a>. If your files are > 1MB, you should use it.</p>
6
2009-12-31T23:33:53Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
3,050,807
<p>I try it today, It works as following:</p> <p>my sdk version is 1.3.x</p> <p>html page:</p> <pre><code>&lt;form enctype="multipart/form-data" action="/upload" method="post" &gt; &lt;input type="file" name="myfile" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; </code></pre> <p>Server Code:</p> <pre><code...
6
2010-06-16T04:55:55Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
3,545,032
<p>I have observed some strange behavior when uploading files on App Engine. When you submit the following form:</p> <pre><code>&lt;form method="post" action="/upload" enctype="multipart/form-data"&gt; &lt;input type="file" name="img" /&gt; ... &lt;/form&gt; </code></pre> <p>And then you extract the <code>img...
0
2010-08-23T05:53:11Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
4,787,543
<p>Here is a complete, working file. I pulled the original from the Google site and modified it to make it slightly more real world.</p> <p>A few things to notice:</p> <ol> <li>This code uses the <a href="http://code.google.com/appengine/docs/python/blobstore/">BlobStore API</a></li> <li><p>The purpose of this line ...
39
2011-01-24T21:46:46Z
[ "python", "google-app-engine" ]
Upload files in Google App Engine
81,451
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p> <p>I'll be glad anyone can provide cod...
73
2008-09-17T09:28:53Z
11,814,685
<p>There is a way of using <strong>flat file system</strong>( Atleast in usage perspective)</p> <p>There is this <a href="http://code.google.com/p/gaevfs/" rel="nofollow"><strong>Google App Engine Virtual FileSystem project</strong></a>. that is implemented with the help of datastore and memcache APIs to emulate an or...
0
2012-08-05T07:27:45Z
[ "python", "google-app-engine" ]
PyQt and PyCairo
82,180
<p>I know it's possible to place a PyCairo surface inside a Gtk Drawing Area. But I think Qt is a lot better to work with, so I've been wondering if there's anyway to place a PyCairo surface inside some Qt component?</p>
2
2008-09-17T11:28:23Z
82,258
<p>Qt's own OpenGL based surfaces (using QPainter) are known to be much faster than Cairo. Might you explain why you want specifically Cairo in Qt?</p> <p>For the basics of using QPainter see <a href="http://www.informit.com/articles/article.aspx?p=1174421" rel="nofollow">this excerpt</a> from the book "C++ GUI Progra...
3
2008-09-17T11:44:49Z
[ "python", "qt", "gtk", "pyqt" ]
PyQt and PyCairo
82,180
<p>I know it's possible to place a PyCairo surface inside a Gtk Drawing Area. But I think Qt is a lot better to work with, so I've been wondering if there's anyway to place a PyCairo surface inside some Qt component?</p>
2
2008-09-17T11:28:23Z
453,179
<p>For plotting with you should also consider matplotlib, which provides a higher level API and integrates well with PyQT.</p>
0
2009-01-17T11:38:54Z
[ "python", "qt", "gtk", "pyqt" ]
Python + DNS : Cannot get RRSIG records: No Answer
82,607
<p>I get DNS records from a Python program, using <a href="http://www.dnspython.org/" rel="nofollow">DNS Python</a></p> <p>I can get various DNSSEC-related records:</p> <pre><code>&gt;&gt;&gt; import dns.resolver &gt;&gt;&gt; myresolver = dns.resolver.Resolver() &gt;&gt;&gt; myresolver.use_edns(1, 0, 1400) &gt;&gt;&g...
1
2008-09-17T12:32:01Z
82,868
<p>If you try this, what happens?</p> <blockquote> <blockquote> <blockquote> <p>print myresolver.query('sources.org', 'ANY', 'RRSIG')</p> </blockquote> </blockquote> </blockquote>
0
2008-09-17T12:59:30Z
[ "python", "dns", "dnspython" ]
Python + DNS : Cannot get RRSIG records: No Answer
82,607
<p>I get DNS records from a Python program, using <a href="http://www.dnspython.org/" rel="nofollow">DNS Python</a></p> <p>I can get various DNSSEC-related records:</p> <pre><code>&gt;&gt;&gt; import dns.resolver &gt;&gt;&gt; myresolver = dns.resolver.Resolver() &gt;&gt;&gt; myresolver.use_edns(1, 0, 1400) &gt;&gt;&g...
1
2008-09-17T12:32:01Z
84,448
<p>You probably mean RRSIG ANY (otherwise, the order is wrong, the class needs to be after the type)</p> <pre><code>&gt;&gt;&gt; print myresolver.query('sources.org', 'RRSIG', 'ANY') Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python2.5/site-packages/dns/resolv...
1
2008-09-17T15:25:29Z
[ "python", "dns", "dnspython" ]
Python + DNS : Cannot get RRSIG records: No Answer
82,607
<p>I get DNS records from a Python program, using <a href="http://www.dnspython.org/" rel="nofollow">DNS Python</a></p> <p>I can get various DNSSEC-related records:</p> <pre><code>&gt;&gt;&gt; import dns.resolver &gt;&gt;&gt; myresolver = dns.resolver.Resolver() &gt;&gt;&gt; myresolver.use_edns(1, 0, 1400) &gt;&gt;&g...
1
2008-09-17T12:32:01Z
114,923
<p>This looks like a probable bug in the Python DNS library, although I don't read Python well enough to find it.</p> <p>Note that in any case your EDNS0 buffer size parameter is not large enough to handle the RRSIG records for sources.org, so your client and server would have to fail over to TCP/IP.</p>
0
2008-09-22T13:42:59Z
[ "python", "dns", "dnspython" ]
Python + DNS : Cannot get RRSIG records: No Answer
82,607
<p>I get DNS records from a Python program, using <a href="http://www.dnspython.org/" rel="nofollow">DNS Python</a></p> <p>I can get various DNSSEC-related records:</p> <pre><code>&gt;&gt;&gt; import dns.resolver &gt;&gt;&gt; myresolver = dns.resolver.Resolver() &gt;&gt;&gt; myresolver.use_edns(1, 0, 1400) &gt;&gt;&g...
1
2008-09-17T12:32:01Z
37,234,210
<p>You may want to use <code>raise_on_no_answer=False</code> and you will get the correct response:</p> <pre><code>resolver.query(hostname, dnsrecord, raise_on_no_answer=False) </code></pre>
0
2016-05-15T03:23:10Z
[ "python", "dns", "dnspython" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
82,690
<p><b>Byteflow</b> is a blog engine, written on Python, using Django</p>
3
2008-09-17T12:40:53Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
82,717
<p>James Bennett has an <a href="http://www.b-list.org/weblog/2007/nov/29/django-blog" rel="nofollow">interesting take</a> on this question:</p> <blockquote> <p>“where can I find a good Django-powered blogging application” is probably at the top of the frequently-asked questions list both on django-users and in ...
4
2008-09-17T12:43:37Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
82,739
<p>EDIT: Original link went dead so here's an updated link with extracts of the list sorted with the most recently updated source at the top.</p> <p><a href="http://blog.montylounge.com/2010/02/10/eleven-django-blog-engines-you-should-know/">Eleven Django blog engines you should know</a></p> <p>by Monty Lounge Indust...
20
2008-09-17T12:45:14Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
82,753
<p>Django's powerful admin interface and easy ORM makes it a 30 minute job to build a blog that propably fits your needs; Why look for a 3rd party product when you can make it yourself very quickly?</p>
3
2008-09-17T12:46:38Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
141,214
<p>Nathan Borror has a great package of 'basic apps' that has a blog. These are well written, well documented apps that you should try out, get ideas from, etc.</p> <p><a href="http://code.google.com/p/django-basic-apps/" rel="nofollow">http://code.google.com/p/django-basic-apps/</a></p>
1
2008-09-26T18:46:29Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
2,001,335
<p>The book <a href="http://rads.stackoverflow.com/amzn/click/1430219386" rel="nofollow">Practical Django Projects</a> provides a tutorial on how to create a Django blogging app.</p>
3
2010-01-04T18:41:48Z
[ "python", "django" ]
Is there any list of blog engines, written in Django?
82,653
<p>Is there any list of blog engines, written in Django?</p>
17
2008-09-17T12:37:48Z
21,028,758
<p>You should check <code>django-blogango</code>. <a href="http://agiliq.com/blog" rel="nofollow">http://agiliq.com/blog</a> is run using this blogging engine.</p> <p><a href="https://github.com/agiliq/django-blogango" rel="nofollow">https://github.com/agiliq/django-blogango</a></p>
1
2014-01-09T18:55:06Z
[ "python", "django" ]
How do I check whether a file exists using Python?
82,831
<p>How do I check whether a file exists, without using the <a href="https://docs.python.org/3.6/reference/compound_stmts.html#try"><code>try</code></a> statement?</p>
2,729
2008-09-17T12:55:00Z
82,836
<pre><code>import os.path if os.path.isfile(filename): </code></pre>
211
2008-09-17T12:55:48Z
[ "python", "file", "filesystems" ]