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
python regular expression to split paragraphs
116,494
<p>How would one write a regular expression to use in python to split paragraphs?</p> <p>A paragraph is defined by 2 linebreaks (\n). But one can have any ammount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.</p> <p>I am using python so the solution can use python's <...
3
2008-09-22T18:10:41Z
116,557
<p>Almost the same, but using non-greedy quantifiers and taking advantage of the whitespace sequence.</p> <pre><code>\s*?\n\s*?\n\s*? </code></pre>
0
2008-09-22T18:18:09Z
[ "python", "regex", "parsing", "text", "split" ]
python regular expression to split paragraphs
116,494
<p>How would one write a regular expression to use in python to split paragraphs?</p> <p>A paragraph is defined by 2 linebreaks (\n). But one can have any ammount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.</p> <p>I am using python so the solution can use python's <...
3
2008-09-22T18:10:41Z
116,621
<p>Are you trying to deduce the structure of a document in plain test? Are you doing what <a href="http://docutils.sourceforge.net/" rel="nofollow">docutils</a> does?</p> <p>You might be able to simply use the <a href="http://docutils.sourceforge.net/docs/dev/hacking.html#parsing-the-document" rel="nofollow">Docutil...
2
2008-09-22T18:28:28Z
[ "python", "regex", "parsing", "text", "split" ]
python regular expression to split paragraphs
116,494
<p>How would one write a regular expression to use in python to split paragraphs?</p> <p>A paragraph is defined by 2 linebreaks (\n). But one can have any ammount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.</p> <p>I am using python so the solution can use python's <...
3
2008-09-22T18:10:41Z
116,622
<p>Unfortunately there's no nice way to write "space but not a newline".</p> <p>I think the best you can do is add some space with the <code>x</code> modifier and try to factor out the ugliness a bit, but that's questionable: <code>(?x) (?: [ \t\r\f\v]*? \n ){2} [ \t\r\f\v]*?</code></p> <p>You could also try creati...
3
2008-09-22T18:28:47Z
[ "python", "regex", "parsing", "text", "split" ]
python regular expression to split paragraphs
116,494
<p>How would one write a regular expression to use in python to split paragraphs?</p> <p>A paragraph is defined by 2 linebreaks (\n). But one can have any ammount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph.</p> <p>I am using python so the solution can use python's <...
3
2008-09-22T18:10:41Z
123,806
<p>Not a regexp but really elegant:</p> <pre><code>from itertools import groupby def paragraph(lines) : for group_separator, line_iteration in groupby(lines.splitlines(True), key = str.isspace) : if not group_separator : yield ''.join(line_iteration) for p in paragraph('p1\n\t\np2\t\n\tstill ...
1
2008-09-23T20:54:44Z
[ "python", "regex", "parsing", "text", "split" ]
How do you create an osx application/dmg from a python package?
116,657
<p>I want to create a mac osx application from python package and then put it in a disk image. </p> <p>Because I load some resources out of the package, the package should <strong>not</strong> reside in a zip file.</p> <p>The resulting disk image should display the background picture to "drag here -> applications" fo...
23
2008-09-22T18:35:28Z
116,901
<p>I don't know the correct way to do it, but this manual method is the approach I've used for simple scripts which seems to have preformed suitably.</p> <p>I'll assume that whatever directory I'm in, the Python files for my program are in the relative <code>src/</code> directory, and that the file I want to execute (...
7
2008-09-22T19:19:30Z
[ "python", "osx", "packaging" ]
Best practices for manipulating database result sets in Python?
116,894
<p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v...
3
2008-09-22T19:18:21Z
116,974
<p>Have you considered using an ORM? <a href="http://www.sqlalchemy.org/features.html" rel="nofollow" title="SQL Alchemy features">SQLAlchemy</a> is pretty good, and <a href="http://elixir.ematia.de/trac/wiki" rel="nofollow" title="Elixir Wiki">Elixir</a> makes it beautiful. It can really reduce the ammount of boilerpl...
1
2008-09-22T19:30:31Z
[ "python", "database" ]
Best practices for manipulating database result sets in Python?
116,894
<p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v...
3
2008-09-22T19:18:21Z
117,012
<p>Using a ORM for an iPhone app might be a bad idea because of performance issues, you want your code to be as fast as possible. So you can't avoid boilerplate code. If you are considering a ORM, besides SQLAlchemy I'd recommend Storm.</p>
-2
2008-09-22T19:35:55Z
[ "python", "database" ]
Best practices for manipulating database result sets in Python?
116,894
<p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v...
3
2008-09-22T19:18:21Z
117,769
<p>Depending on how much you want to do with the data you may not need to populate an intermediate object. The cursor's header data structure will let you get the column names - a bit of introspection will let you make a dictionary with col-name:value pairs for the row. You can pass the dictionary to the % operator. ...
0
2008-09-22T21:30:03Z
[ "python", "database" ]
Best practices for manipulating database result sets in Python?
116,894
<p>I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I'v...
3
2008-09-22T19:18:21Z
117,994
<p>The empty Record class and the free-floating function that (generally) applies to an individual Record is a hint that you haven't designed your class properly.</p> <pre><code>class Record( object ): """Assuming rtda and pnl must exist.""" def __init__( self ): self.da= 0 self.rt= 0 s...
1
2008-09-22T22:23:44Z
[ "python", "database" ]
How to Retrieve name of current Windows User (AD or local) using Python?
117,014
<p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
18
2008-09-22T19:36:32Z
117,047
<p>Try this:</p> <pre><code>import os; print os.environ.get( "USERNAME" ) </code></pre> <p>That should do the job.</p>
26
2008-09-22T19:42:41Z
[ "python", "active-directory" ]
How to Retrieve name of current Windows User (AD or local) using Python?
117,014
<p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
18
2008-09-22T19:36:32Z
117,092
<p>I don't know Python, but for windows the underlying api is <a href="http://msdn.microsoft.com/en-us/library/ms724435(VS.85).aspx" rel="nofollow">GetUserNameEx</a>, I assume you can call that in Python if os.environ.get( "USERNAME" ) doesn't tell you everything you need to know.</p>
1
2008-09-22T19:48:00Z
[ "python", "active-directory" ]
How to Retrieve name of current Windows User (AD or local) using Python?
117,014
<p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
18
2008-09-22T19:36:32Z
1,992,923
<pre><code>win32api.GetUserName() win32api.GetUserNameEx(...) </code></pre> <p>See: <a href="http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html" rel="nofollow">http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html</a></p>
2
2010-01-02T21:31:16Z
[ "python", "active-directory" ]
How to Retrieve name of current Windows User (AD or local) using Python?
117,014
<p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
18
2008-09-22T19:36:32Z
23,963,670
<p>Pretty old question but to refresh the answer to the original question "How can I retrieve the name of the currently logged in user, using a python script?" use:</p> <pre><code>import os print (os.getlogin()) </code></pre> <p>Per Python documentation: getlogin - Return the name of the user logged in on the control...
0
2014-05-30T21:29:28Z
[ "python", "active-directory" ]
How to Retrieve name of current Windows User (AD or local) using Python?
117,014
<p>How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user.</p>
18
2008-09-22T19:36:32Z
24,649,918
<p>as in <a href="http://stackoverflow.com/a/842096/611007">http://stackoverflow.com/a/842096/611007</a> by <a href="http://stackoverflow.com/users/102243/konstantin-tenzin">Konstantin Tenzin</a></p> <blockquote> <p>Look at <a href="http://docs.python.org/library/getpass.html" rel="nofollow">getpass</a> module</p> ...
4
2014-07-09T09:25:26Z
[ "python", "active-directory" ]
What is the scope for imported classes in python?
117,127
<p>Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags!</p> <p><strong>The Problem</strong></p> <p>I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the...
2
2008-09-22T19:52:44Z
117,174
<p>Functions are always executed in the scope they are defined in, as are methods and class bodies. They are never executed in another scope. Because importing is just another assignment statement, and everything in Python is a reference, the functions, classes and modules don't even know where they are imported to.</p...
1
2008-09-22T19:58:10Z
[ "python", "import", "scope", "eval" ]
What is the scope for imported classes in python?
117,127
<p>Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags!</p> <p><strong>The Problem</strong></p> <p>I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the...
2
2008-09-22T19:52:44Z
117,433
<p>In this example, you can simply hand over functions as objects to the methods in <code>C1</code>:</p> <pre><code>&gt;&gt;&gt; class C1(object): &gt;&gt;&gt; def eval(self, x): &gt;&gt;&gt; x() &gt;&gt;&gt; &gt;&gt;&gt; def f2(): print "go f2" &gt;&gt;&gt; c = C1() &gt;&gt;&gt; c.eval(f2) go f2 </code></pr...
1
2008-09-22T20:32:17Z
[ "python", "import", "scope", "eval" ]
Python and POST data
117,167
<p>In PHP I simply write:</p> <pre><code>$bob = $_POST['bob']; </code></pre> <p>How do I do the same in Python?</p> <p>And yes, I do normally check that it exists etc, I'm just stripping it down specifically to the functionality I am after.</p> <p><hr> Edit: I am not using a framework</p>
4
2008-09-22T19:57:37Z
117,201
<p>The simplest method is the 'cgi' module:</p> <pre><code>import cgi data = cgi.FieldStorage() data['bob'] </code></pre> <p>But the context you are executing in (frameworks you're using, WSGI or even (heaven forbid) mod_python) may have different, more efficient or more direct methods of access.</p>
10
2008-09-22T20:01:12Z
[ "python", "http", "post" ]
How to update a Tix.ComboBox's text?
117,211
<p>I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?</p> <p>Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text fi...
2
2008-09-22T20:02:38Z
117,384
<p>woo! solved it on my own.</p> <p>Use </p> <pre><code>self.combo['selection'] </code></pre> <p>instead of</p> <pre><code>self.combo['value'] </code></pre>
5
2008-09-22T20:24:50Z
[ "python", "combobox", "tkinter", "tix" ]
How to update a Tix.ComboBox's text?
117,211
<p>I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?</p> <p>Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text fi...
2
2008-09-22T20:02:38Z
207,117
<p><i>NOTE: copy of Moe's answer that can be selected as chosen answer</i></p> <p>woo! solved it on my own.</p> <p>Use </p> <pre><code>self.combo['selection'] </code></pre> <p>instead of</p> <pre><code>self.combo['value'] </code></pre>
1
2008-10-16T01:22:20Z
[ "python", "combobox", "tkinter", "tix" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,256
<p>Try 4.0/100</p>
1
2008-09-22T20:07:20Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,257
<p>A simple route 4 / 100.0 </p> <p>or</p> <p>4.0 / 100</p>
1
2008-09-22T20:07:27Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,258
<p>You need to tell Python to use floating point values, not integers. You can do that simply by using a decimal point yourself in the inputs:</p> <pre><code>&gt;&gt;&gt; 4/100.0 0.040000000000000001 </code></pre>
3
2008-09-22T20:07:38Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,264
<p>There are three options:</p> <pre><code>&gt;&gt;&gt; 4 / float(100) 0.04 &gt;&gt;&gt; 4 / 100.0 0.04 </code></pre> <p>which is the same behavior as the C, C++, Java etc, or </p> <pre><code>&gt;&gt;&gt; from __future__ import division &gt;&gt;&gt; 4 / 100 0.04 </code></pre> <p>You can also activate this behavior ...
79
2008-09-22T20:08:15Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,270
<p>Make one or both of the terms a floating point number, like so:</p> <pre><code>4.0/100.0 </code></pre> <p>Alternatively, turn on the feature that will be default in Python 3.0, 'true division', that does what you want. At the top of your module or script, do:</p> <pre><code>from __future__ import division </code>...
7
2008-09-22T20:08:45Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,285
<p>You cant get a decimal value by dividing one integer with another, you'll allways get an integer that way (result truncated to integer). You need at least one value to be a decimal number.</p>
0
2008-09-22T20:11:02Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,682
<p>Other answers suggest how to get a floating-point value. While this wlil be close to what you want, it won't be exact:</p> <pre><code>&gt;&gt;&gt; 0.4/100. 0.0040000000000000001 </code></pre> <p>If you actually want a <em>decimal</em> value, do this:</p> <pre><code>&gt;&gt;&gt; import decimal &gt;&gt;&gt; decima...
21
2008-09-22T21:12:07Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
117,806
<p>You might want to look at Python's <a href="http://docs.python.org/lib/module-decimal.html" rel="nofollow">decimal</a> package, also. This will provide nice decimal results.</p> <pre><code>&gt;&gt;&gt; decimal.Decimal('4')/100 Decimal("0.04") </code></pre>
2
2008-09-22T21:38:16Z
[ "python", "math", "syntax", "operators" ]
How do I get a decimal value when using the division operator in Python?
117,250
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
31
2008-09-22T20:06:16Z
30,474,510
<p>Please consider following example</p> <pre><code>float tot=(float)31/7; </code></pre>
-1
2015-05-27T06:16:16Z
[ "python", "math", "syntax", "operators" ]
What's the Name of the Python Module that Formats arbitrary Text to nicely looking HTML?
117,477
<p>A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only.</p> <p>Unfortunately I lost the name of the library and was unable to Google it....
10
2008-09-22T20:39:11Z
117,543
<p><a href="http://sphinx.pocoo.org/" rel="nofollow">Sphinx</a> is a documentation generator using reStructuredText. It's quite nice, although I haven't used it personally.</p> <p>The website <a href="http://sphinx.pocoo.org/" rel="nofollow">Hazel Tree</a>, which compiles python text uses Sphinx, and so does the new ...
0
2008-09-22T20:48:51Z
[ "python", "formatting", "markup" ]
What's the Name of the Python Module that Formats arbitrary Text to nicely looking HTML?
117,477
<p>A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only.</p> <p>Unfortunately I lost the name of the library and was unable to Google it....
10
2008-09-22T20:39:11Z
117,819
<p><p><a href="http://www.freewisdom.org/projects/python-markdown/" rel="nofollow">Markdown in python</a> is a python implementation of the <a href="http://daringfireball.net/projects/markdown/" rel="nofollow">perl based markdown</a> utility.</p> <p><p>Markown converts various forms of structured text to valid html, a...
1
2008-09-22T21:40:15Z
[ "python", "formatting", "markup" ]
What's the Name of the Python Module that Formats arbitrary Text to nicely looking HTML?
117,477
<p>A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only.</p> <p>Unfortunately I lost the name of the library and was unable to Google it....
10
2008-09-22T20:39:11Z
117,824
<p>Okay. I found it now. It's called <a href="http://glyphobet.net/pottymouth/">PottyMouth</a>.</p>
14
2008-09-22T21:41:26Z
[ "python", "formatting", "markup" ]
How do I use timezones with a datetime object in python?
117,514
<p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p> <pre><code>import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone"...
37
2008-09-22T20:44:39Z
117,523
<p>The Python standard library doesn't contain timezone information, because unfortunately timezone data changes a lot faster than Python. You need a third-party module for this; the usual choice is <a href="http://pytz.sourceforge.net">pytz</a></p>
9
2008-09-22T20:46:08Z
[ "python", "datetime", "timezone" ]
How do I use timezones with a datetime object in python?
117,514
<p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p> <pre><code>import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone"...
37
2008-09-22T20:44:39Z
117,615
<p>I recommend <code>babel</code> and <code>pytz</code> when working with timezones. Keep your internal datetime objects naive and in UTC and convert to your timezone for formatting only. The reason why you probably want naive objects (objects without timezone information) is that many libraries and database adapters...
36
2008-09-22T20:59:40Z
[ "python", "datetime", "timezone" ]
How do I use timezones with a datetime object in python?
117,514
<p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p> <pre><code>import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone"...
37
2008-09-22T20:44:39Z
1,893,437
<p>For the current local timezone, you can you use:</p> <pre><code>&gt;&gt;&gt; import time &gt;&gt;&gt; offset = time.timezone if (time.localtime().tm_isdst == 0) else time.altzone &gt;&gt;&gt; offset / 60 / 60 * -1 -9 </code></pre> <p>The value returned is in seconds West of UTC (with areas East of UTC getting a ne...
7
2009-12-12T13:35:12Z
[ "python", "datetime", "timezone" ]
How do I use timezones with a datetime object in python?
117,514
<p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p> <pre><code>import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone"...
37
2008-09-22T20:44:39Z
10,484,336
<p>We are familiar to timezone cut off from GMT (now UTC), but Python takes timezone cut off from Western. That's why there are negative timezone cutoff's in Python, I believe.</p>
-1
2012-05-07T15:00:07Z
[ "python", "datetime", "timezone" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
117,794
<p>Look closely at <a href="http://www.sqlalchemy.org/" rel="nofollow">SQLAlchemy</a>. This can probably do much of what you want. It gives you Python syntax for plain-old SQL that runs on the server.</p>
5
2008-09-22T21:35:01Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
117,818
<p>LINQ is a language feature of C# and VB.NET. It is a special syntax recognized by the compiler and treated specially. It is also dependent on another language feature called expression trees.</p> <p>Expression trees are a <strong>little</strong> different in that they are not special syntax. They are written jus...
5
2008-09-22T21:40:10Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
118,350
<p>I believe that when IronPython 2.0 is complete, it will have LINQ support (see <a href="http://groups.google.com/group/ironpy/browse_thread/thread/eb6b9eb2241cc68e" rel="nofollow">this thread</a> for some example discussion). Right now you should be able to write something like:</p> <pre><code>Queryable.Select(Que...
4
2008-09-23T00:11:39Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
118,496
<p><a href="http://www.sqlalchemy.org/trac/wiki/SqlSoup" rel="nofollow">sqlsoup</a> in sqlalchemy gives you the quickest solution in python I think if you want a clear(ish) one liner . Look at the page to see.</p> <p>It should be something like...</p> <pre><code>result = [n.Number for n in db.Numbers.filter(db.Number...
6
2008-09-23T00:52:48Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
235,727
<p>A key factor for LINQ is the ability of the compiler to generate expression trees. I am using a macro in Nemerle that converts a given Nemerle expression into an Expression tree object. I can then pass this to the Where/Select/etc extension methods on IQueryables. It's not quite the syntax of C# and VB, but it's clo...
1
2008-10-25T01:12:45Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Can you do LINQ-like queries in a language like Python or Boo?
117,732
<p>Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number:</p> <p>var result = from n in db.Numbers where n.Number &lt; 5 select n.Number;</p> <p>This will run very efficiently in C#, because it generates an SQL query something like "select Number fr...
4
2008-09-22T21:24:00Z
254,524
<p>Boo supports list generator expressions using the same syntax as python. For more information on that, check out the Boo documentation on <a href="http://boo.codehaus.org/Generator+Expressions" rel="nofollow">Generator expressions</a> and <a href="http://boo.codehaus.org/List+Generators" rel="nofollow">List compreh...
1
2008-10-31T18:55:58Z
[ "python", "linq", "linq-to-sql", "ironpython", "boo" ]
Debug/Monitor middleware for python wsgi applications
117,986
<p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p> <p>Something like firefox live headers, but for the server side.</p>
1
2008-09-22T22:22:18Z
118,037
<p>That shouldn't be too hard to write yourself as long as you only need the headers. Try that:</p> <pre><code>import sys def log_headers(app, stream=None): if stream is None: stream = sys.stdout def proxy(environ, start_response): for key, value in environ.iteritems(): if key.sta...
2
2008-09-22T22:35:22Z
[ "python", "debugging", "wsgi", "middleware" ]
Debug/Monitor middleware for python wsgi applications
117,986
<p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p> <p>Something like firefox live headers, but for the server side.</p>
1
2008-09-22T22:22:18Z
118,142
<p>The middleware</p> <pre><code>from wsgiref.util import request_uri import sys def logging_middleware(application, stream=sys.stdout): def _logger(environ, start_response): stream.write('REQUEST\n') stream.write('%s %s\n' %( environ['REQUEST_METHOD'], request_uri(environ)...
2
2008-09-22T23:05:34Z
[ "python", "debugging", "wsgi", "middleware" ]
Debug/Monitor middleware for python wsgi applications
117,986
<p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p> <p>Something like firefox live headers, but for the server side.</p>
1
2008-09-22T22:22:18Z
307,547
<p>If you want Apache-style logs, try <a href="http://svn.pythonpaste.org/Paste/trunk/paste/translogger.py" rel="nofollow">paste.translogger</a></p> <p>But for something more complete, though not in a very handy or stable location (maybe copy it into your source) is <a href="http://svn.pythonpaste.org/Paste/WSGIFilter...
2
2008-11-21T01:35:12Z
[ "python", "debugging", "wsgi", "middleware" ]
Debug/Monitor middleware for python wsgi applications
117,986
<p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p> <p>Something like firefox live headers, but for the server side.</p>
1
2008-09-22T22:22:18Z
1,041,821
<p>The mod_wsgi documentation provides various tips on debugging which are applicable to any WSGI hosting mechanism and not just mod_wsgi. See:</p> <p><a href="http://code.google.com/p/modwsgi/wiki/DebuggingTechniques" rel="nofollow">http://code.google.com/p/modwsgi/wiki/DebuggingTechniques</a></p> <p>This includes a...
1
2009-06-25T01:53:10Z
[ "python", "debugging", "wsgi", "middleware" ]
Debug/Monitor middleware for python wsgi applications
117,986
<p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p> <p>Something like firefox live headers, but for the server side.</p>
1
2008-09-22T22:22:18Z
2,384,940
<p>My WebCore project has a bit of middleware that logs the entire WSGI environment (thus Beaker sessions, headers, etc.) for the incoming request, headers for outbound responses, as well as performance information to a MongoDB database. Average overhead is around 4ms.</p> <p>The module has been removed from the core...
1
2010-03-05T06:23:26Z
[ "python", "debugging", "wsgi", "middleware" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
118,110
<p>You may also want to consider the <a href="http://docs.python.org/lib/module-csv.html" rel="nofollow">csv</a> module. I haven't tried it, but it looks like your input data is closer to CSV than to shell syntax (which is what shlex parses).</p>
5
2008-09-22T22:56:56Z
[ "python", "split", "escaping", "quotes" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
118,132
<p>You could do something like this:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; pattern = re.compile(r'\s*("[^"]*"|.*?)\s*,') &gt;&gt;&gt; def split(line): ... return [x[1:-1] if x[:1] == x[-1:] == '"' else x ... for x in pattern.findall(line.rstrip(',') + ',')] ... &gt;&gt;&gt; split("foo, bar, baz...
1
2008-09-22T23:02:31Z
[ "python", "split", "escaping", "quotes" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
118,161
<p>If it doesn't need to be pretty, this might get you on your way:</p> <pre><code>def f(s, splitifeven): if splitifeven &amp; 1: return [s] return [x.strip() for x in s.split(",") if x.strip() != ''] ss = 'foo, bar, "one, two", three four' print sum([f(s, sie) for sie, s in enumerate(ss.split('"'))]...
-2
2008-09-22T23:09:25Z
[ "python", "split", "escaping", "quotes" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
118,162
<p>It depends how complicated you want to get... do you want to allow more than one type of quoting. How about escaped quotes?</p> <p>Your syntax looks very much like the common CSV file format, which is supported by the Python standard library:</p> <pre><code>import csv reader = csv.reader(['''foo, bar, "one, two",...
39
2008-09-22T23:09:45Z
[ "python", "split", "escaping", "quotes" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
118,187
<p>The shlex module solution allows escaped quotes, one quote escape another, and all fancy stuff shell supports.</p> <pre><code>&gt;&gt;&gt; import shlex &gt;&gt;&gt; my_splitter = shlex.shlex('''foo, bar, "one, two", three four''', posix=True) &gt;&gt;&gt; my_splitter.whitespace += ',' &gt;&gt;&gt; my_splitter.white...
21
2008-09-22T23:15:45Z
[ "python", "split", "escaping", "quotes" ]
How can i parse a comma delimited string into a list (caveat)?
118,096
<p>I need to be able to take a string like:</p> <pre><code>'''foo, bar, "one, two", three four''' </code></pre> <p>into:</p> <pre><code>['foo', 'bar', 'one, two', 'three four'] </code></pre> <p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
19
2008-09-22T22:54:10Z
157,771
<p>I'd say a regular expression would be what you're looking for here, though I'm not terribly familiar with Python's Regex engine.</p> <p>Assuming you use lazy matches, you can get a set of matches on a string which you can put into your array.</p>
0
2008-10-01T14:08:53Z
[ "python", "split", "escaping", "quotes" ]
How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?
118,138
<p>I have read that it is possible to <a href="http://developer.imendio.com/projects/gtk-macosx/build-instructions" rel="nofollow">build GTK+ on MacOS X</a>. I know that it's possible to create a <a href="http://developer.imendio.com/projects/gtk-macosx/creating-app-bundles" rel="nofollow">bundle of a GTK+ application...
7
2008-09-22T23:04:07Z
121,180
<p>I'm not sure if I'm grokking all the details of your question, but looking at your problem in general (how do I deploy a python app on mac), I'm inclined to say that the answer is <a href="http://undefined.org/python/py2app.html" rel="nofollow">py2app</a>. Basically this will bundle a python interpreter and all rele...
1
2008-09-23T14:03:07Z
[ "python", "osx", "gtk", "pygtk" ]
How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?
118,138
<p>I have read that it is possible to <a href="http://developer.imendio.com/projects/gtk-macosx/build-instructions" rel="nofollow">build GTK+ on MacOS X</a>. I know that it's possible to create a <a href="http://developer.imendio.com/projects/gtk-macosx/creating-app-bundles" rel="nofollow">bundle of a GTK+ application...
7
2008-09-22T23:04:07Z
126,313
<p>While it's not a guide <em>solely</em> targetted at python/GTK+/OS X, <a href="http://groups.google.com/group/reinteract/msg/4846099674d2153a" rel="nofollow">this post</a> is a good, detailed description of someone else's attempt to do most of what you describe. Obviously, the app-specific stuff is going to vary.</p...
1
2008-09-24T10:03:37Z
[ "python", "osx", "gtk", "pygtk" ]
How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?
118,138
<p>I have read that it is possible to <a href="http://developer.imendio.com/projects/gtk-macosx/build-instructions" rel="nofollow">build GTK+ on MacOS X</a>. I know that it's possible to create a <a href="http://developer.imendio.com/projects/gtk-macosx/creating-app-bundles" rel="nofollow">bundle of a GTK+ application...
7
2008-09-22T23:04:07Z
126,346
<p>Native looking widgets is quite complicated. There's a beginning of quartz engine (for theming) found here <a href="http://git.gnome.org/browse/gtk+/tree/gdk/quartz" rel="nofollow">http://git.gnome.org/browse/gtk+/tree/gdk/quartz</a> For self-contained applications check out the newly released bundle on <a href="htt...
3
2008-09-24T10:12:16Z
[ "python", "osx", "gtk", "pygtk" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
118,163
<p>It works for me. You must be doing something wrong.</p> <pre><code>&gt;&gt;&gt; re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)', '127.255.0.0').groups() ('127', '255', '0', '0') </code></pre> ...
7
2008-09-22T23:10:13Z
[ "php", "python", "regex" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
118,165
<p>That regular expression matches here, no idea what you are doing wrong:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; x = re.compile(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|' ... r'2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]' ... r'[0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)')...
1
2008-09-22T23:10:35Z
[ "php", "python", "regex" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
118,180
<p><a href="http://www.regular-expressions.info/php.html" rel="nofollow">PHP</a> uses 3 different flavors of regex, while python uses only one. I don't code in python, so I make no expert claims on how it uses REGEX. <a href="http://oreilly.com/catalog/9781565922570/" rel="nofollow">O'Reilly Mastering Regular Expressio...
1
2008-09-22T23:14:25Z
[ "php", "python", "regex" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
118,181
<p>I would suggest that using a regex for decimal range validation is not necessarily the correct answer for this problem. This is far more readable:</p> <pre><code>def valid_ip(s): m = re.match(r"(\d+)\.(\d+)\.(\d+)\.(\d+)$", s) if m is None: return False parts = [int(m.group(1+x)) for x in range(...
4
2008-09-22T23:14:34Z
[ "php", "python", "regex" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
118,182
<p>Without further details, I'd guess it's quote escaping of some kind. Both PHP and python's RegEX objects take strings as arguments. These strings will be escaped by the languge before being passed on to the RegEx engine.</p> <p>I always using Python's "raw" string format when working with regular expressions. It...
2
2008-09-22T23:14:43Z
[ "php", "python", "regex" ]
Python Regex vs PHP Regex
118,143
<p>No not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p> <pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) </code></pre> <p>That's my Regex an...
3
2008-09-22T23:06:02Z
198,882
<p>Just because you <em>can</em> do it with regex, doesn't mean you should. It would be much better to write instructions like: split the string on the period, make sure each group is numeric and within a certain range of numbers.</p> <p>If you want to use a regex, just verify that it kind of "looks like" an IP addre...
3
2008-10-13T20:16:59Z
[ "php", "python", "regex" ]
What's the best dispatcher/callback library in Python?
118,221
<p>I need to allow other Python applications to register callback functions for events in my application. These need to have priorities associated with them (so a callback with a priority of 10 runs before a callback with a priority of 1) and callback functions need to be able to signal errors to the dispatcher.</p> ...
2
2008-09-22T23:28:37Z
118,227
<p>Are these other applications running in another address space? If so, you'll need to use an interprocess communication library like <a href="http://www.freedesktop.org/wiki/Software/dbus" rel="nofollow">D-BUS</a>.</p> <p>If you're just sending signals in the same process, try <a href="http://pypi.python.org/pypi/Py...
1
2008-09-22T23:30:39Z
[ "python" ]
What's the best dispatcher/callback library in Python?
118,221
<p>I need to allow other Python applications to register callback functions for events in my application. These need to have priorities associated with them (so a callback with a priority of 10 runs before a callback with a priority of 1) and callback functions need to be able to signal errors to the dispatcher.</p> ...
2
2008-09-22T23:28:37Z
118,228
<p>What platform are you running under? GObject is the basis of the GTK GUI that's widely-used under Linux, and it supports event loops with prioritizable events like this.</p>
0
2008-09-22T23:30:44Z
[ "python" ]
What's the best dispatcher/callback library in Python?
118,221
<p>I need to allow other Python applications to register callback functions for events in my application. These need to have priorities associated with them (so a callback with a priority of 10 runs before a callback with a priority of 1) and callback functions need to be able to signal errors to the dispatcher.</p> ...
2
2008-09-22T23:28:37Z
1,140,282
<p>Try Twisted for anything network-related. Its perspective broker is quite nice to use. </p>
0
2009-07-16T21:01:38Z
[ "python" ]
What's the best dispatcher/callback library in Python?
118,221
<p>I need to allow other Python applications to register callback functions for events in my application. These need to have priorities associated with them (so a callback with a priority of 10 runs before a callback with a priority of 1) and callback functions need to be able to signal errors to the dispatcher.</p> ...
2
2008-09-22T23:28:37Z
3,491,737
<p>Try python-callbacks - <a href="http://code.google.com/p/python-callbacks/" rel="nofollow">http://code.google.com/p/python-callbacks/</a>.</p>
0
2010-08-16T08:52:15Z
[ "python" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
118,275
<p>There's a file called idle.py in your Python installation directory in Lib\idlelib\idle.py</p> <p>If you run that file with Python, then IDLE should start.</p> <blockquote> <p>c:\Python25\pythonw.exe c:\Python25\Lib\idlelib\idle.py</p> </blockquote>
53
2008-09-22T23:49:11Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
118,308
<p>Here's another path you can use. I'm not sure if this is part of the standard distribution or if the file is automatically created on first use of the IDLE.</p> <pre><code>C:\Python25\Lib\idlelib\idle.pyw </code></pre>
8
2008-09-22T23:56:03Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
1,537,046
<p>You can also assign hotkeys to Windows shortcuts directly (at least in Windows 95 you could, I haven't checked again since then, but I think the option should be still there ^_^).</p>
1
2009-10-08T10:51:18Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
7,394,470
<p>In Python 3.2.2, I found <code>\Python32\Lib\idlelib\idle.bat</code> which was useful because it would let me open python files supplied as args in IDLE.</p>
10
2011-09-12T21:48:51Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
8,237,399
<p>If you just have a Python shell running, type:</p> <pre><code>import idlelib.PyShell idlelib.PyShell.main() </code></pre>
8
2011-11-23T04:35:54Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
18,023,426
<p>Python installation folder > Lib > idlelib > idle.pyw</p> <p>Double click on it and you're good to go.</p>
3
2013-08-02T18:05:55Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
33,572,951
<p>The idle shortcut is an "Advertised Shortcut" which breaks certain features like the "find target" button. Google for more info.</p> <p>You can view the link with a hex editor or download <a href="https://code.google.com/p/lnk-parser/" rel="nofollow">LNK Parser</a> to see where it points to.</p> <p>In my case it r...
1
2015-11-06T18:06:16Z
[ "python", "python-idle", "komodo", "pywin" ]
How to start IDLE (Python editor) without using the shortcut on Windows Vista?
118,260
<p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving t...
43
2008-09-22T23:44:21Z
35,535,565
<p>there is a .bat script to start it (python 2.7).</p> <pre><code>c:\Python27\Lib\idlelib\idle.bat </code></pre>
1
2016-02-21T11:33:34Z
[ "python", "python-idle", "komodo", "pywin" ]
How do you use the ellipsis slicing syntax in Python?
118,370
<p>This came up in <a href="http://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a>, but I can't see good documentation or examples that explain how the feature works.</p>
114
2008-09-23T00:17:09Z
118,395
<p>You'd use it in your own class, since no builtin class makes use of it.</p> <p>Numpy uses it, as stated in the <a href="http://wiki.scipy.org/Numpy_Example_List_With_Doc#head-490d781b49b68b300eedaef32369fae7d58627fb">documentation</a>. Some examples <a href="http://wiki.scipy.org/Tentative_NumPy_Tutorial#head-86486...
70
2008-09-23T00:24:21Z
[ "python", "numpy", "subclass", "slice", "ellipsis" ]
How do you use the ellipsis slicing syntax in Python?
118,370
<p>This came up in <a href="http://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a>, but I can't see good documentation or examples that explain how the feature works.</p>
114
2008-09-23T00:17:09Z
118,508
<p>The ellipsis is used to slice higher-dimensional data structures. </p> <p>It's designed to mean <em>at this point, insert as many full slices (<code>:</code>) to extend the multi-dimensional slice to all dimensions</em>.</p> <p><strong>Example</strong>:</p> <pre><code>&gt;&gt;&gt; from numpy import arange &gt;&gt...
159
2008-09-23T00:55:09Z
[ "python", "numpy", "subclass", "slice", "ellipsis" ]
How do you use the ellipsis slicing syntax in Python?
118,370
<p>This came up in <a href="http://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a>, but I can't see good documentation or examples that explain how the feature works.</p>
114
2008-09-23T00:17:09Z
120,055
<p>This is another use for Ellipsis, which has nothing to do with slices: I often use it in intra-thread communication with queues, as a mark that signals "Done"; it's there, it's an object, it's a singleton, and its name means "lack of", and it's not the overused None (which could be put in a queue as part of normal d...
66
2008-09-23T09:34:48Z
[ "python", "numpy", "subclass", "slice", "ellipsis" ]
How do you use the ellipsis slicing syntax in Python?
118,370
<p>This came up in <a href="http://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a>, but I can't see good documentation or examples that explain how the feature works.</p>
114
2008-09-23T00:17:09Z
17,763,926
<p>Python documentation aren't very clear about this but there is another use of ellipsis. It is used as a representation of infinite data structures in case of Python. <a href="http://stackoverflow.com/questions/17160162/what-is-in-python-2-7">This question</a> discusses how and some actual applications.</p>
0
2013-07-20T15:47:51Z
[ "python", "numpy", "subclass", "slice", "ellipsis" ]
How can I join a list into a string (caveat)?
118,458
<p>Along the lines of my previous <a href="http://stackoverflow.com/questions/118096/how-can-i-parse-a-comma-delimited-string-into-a-list-caveat">question</a>, how can i join a list of strings into a string such that values get quoted cleanly. Something like:</p> <pre><code>['a', 'one "two" three', 'foo, bar', """both...
6
2008-09-23T00:41:25Z
118,462
<p>Using the <code>csv</code> module you can do that way:</p> <pre><code>import csv writer = csv.writer(open("some.csv", "wb")) writer.writerow(the_list) </code></pre> <p>If you need a string just use <code>StringIO</code> instance as a file:</p> <pre><code>f = StringIO.StringIO() writer = csv.writer(f) writer.write...
7
2008-09-23T00:43:42Z
[ "python", "string", "list", "csv" ]
How can I join a list into a string (caveat)?
118,458
<p>Along the lines of my previous <a href="http://stackoverflow.com/questions/118096/how-can-i-parse-a-comma-delimited-string-into-a-list-caveat">question</a>, how can i join a list of strings into a string such that values get quoted cleanly. Something like:</p> <pre><code>['a', 'one "two" three', 'foo, bar', """both...
6
2008-09-23T00:41:25Z
118,625
<p>Here's a slightly simpler alternative.</p> <pre><code>def quote(s): if "'" in s or '"' in s or "," in str(s): return repr(s) return s </code></pre> <p>We only need to quote a value that might have commas or quotes.</p> <pre><code>&gt;&gt;&gt; x= ['a', 'one "two" three', 'foo, bar', 'both"\''] &gt;...
1
2008-09-23T01:26:34Z
[ "python", "string", "list", "csv" ]
How can I join a list into a string (caveat)?
118,458
<p>Along the lines of my previous <a href="http://stackoverflow.com/questions/118096/how-can-i-parse-a-comma-delimited-string-into-a-list-caveat">question</a>, how can i join a list of strings into a string such that values get quoted cleanly. Something like:</p> <pre><code>['a', 'one "two" three', 'foo, bar', """both...
6
2008-09-23T00:41:25Z
121,745
<p>On a related note, Python's <a href="http://docs.python.org/lib/standard-encodings.html" rel="nofollow">builtin encoders</a> can also do string escaping:</p> <pre><code>&gt;&gt;&gt; print "that's interesting".encode('string_escape') that\'s interesting </code></pre>
2
2008-09-23T15:29:04Z
[ "python", "string", "list", "csv" ]
How do I create a non-standard type with SOAPpy?
118,467
<p>I am calling <a href="http://www.pingdom.com/services/api-documentation/" rel="nofollow">a WSDL web service</a> from Python using <a href="http://pywebsvcs.sourceforge.net/" rel="nofollow">SOAPpy</a>. The call I need to make is to the method <a href="http://www.pingdom.com/services/api-documentation/operation_login"...
2
2008-09-23T00:46:14Z
118,507
<p>The better method is to use the ZSI soap module which allows you to take a WDSL file and turn it into classes and methods that you can then use to call it. The online documentation is <a href="http://pywebsvcs.sourceforge.net/zsi.html#SECTION0012300000000000000000" rel="nofollow"> on their website</a> but the latest...
0
2008-09-23T00:54:58Z
[ "python", "web-services", "soap" ]
How do I read an Excel file into Python using xlrd? Can it read newer Office formats?
118,516
<p>My issue is below but would be interested comments from anyone with experience with xlrd.</p> <p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current component...
10
2008-09-23T00:58:09Z
118,586
<p>Well here is some code that I did: (look down the bottom): <a href="http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-decisiontables/src/main/resources/python-dt/pydt.py" rel="nofollow">here</a></p> <p>Not sure about the newer formats - if xlrd can't read it, xlrd needs to have a new version released !</p>...
0
2008-09-23T01:14:51Z
[ "python", "xlrd", "import-from-excel" ]
How do I read an Excel file into Python using xlrd? Can it read newer Office formats?
118,516
<p>My issue is below but would be interested comments from anyone with experience with xlrd.</p> <p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current component...
10
2008-09-23T00:58:09Z
118,803
<p>Do you have to use xlrd? I just downloaded 'UPDATED - Dow Jones Industrial Average Movers - 2008' from that website and had no trouble reading it with <a href="http://sourceforge.net/projects/pyexcelerator" rel="nofollow">pyExcelerator</a>.</p> <pre><code>import pyExcelerator book = pyExcelerator.parse_xls('DJIAMo...
-1
2008-09-23T02:33:40Z
[ "python", "xlrd", "import-from-excel" ]
How do I read an Excel file into Python using xlrd? Can it read newer Office formats?
118,516
<p>My issue is below but would be interested comments from anyone with experience with xlrd.</p> <p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current component...
10
2008-09-23T00:58:09Z
125,001
<p>More info on pyExcelerator: To read a file, do this:</p> <pre><code>import pyExcelerator book = pyExcelerator.parse_xls(filename) </code></pre> <p>where filename is a string that is the filename to read (not a file-like object). This will give you a data structure representing the workbook: a list of pairs, where...
1
2008-09-24T02:05:29Z
[ "python", "xlrd", "import-from-excel" ]
How do I read an Excel file into Python using xlrd? Can it read newer Office formats?
118,516
<p>My issue is below but would be interested comments from anyone with experience with xlrd.</p> <p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current component...
10
2008-09-23T00:58:09Z
272,170
<p>xlrd support for Office 2007/2008 (OpenXML) format is in alpha test - see the following post in the python-excel newsgroup: <a href="http://groups.google.com/group/python-excel/msg/0c5f15ad122bf24b?hl=en" rel="nofollow">http://groups.google.com/group/python-excel/msg/0c5f15ad122bf24b?hl=en</a> </p>
3
2008-11-07T14:14:03Z
[ "python", "xlrd", "import-from-excel" ]
How do I read an Excel file into Python using xlrd? Can it read newer Office formats?
118,516
<p>My issue is below but would be interested comments from anyone with experience with xlrd.</p> <p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current component...
10
2008-09-23T00:58:09Z
694,688
<p>FWIW, I'm the author of xlrd, and the maintainer of xlwt (a fork of pyExcelerator). A few points:</p> <ol> <li><p>The file ComponentReport-DJI.xls is misnamed; it is not an XLS file, it is a tab-separated-values file. Open it with a text editor (e.g. Notepad) and you'll see what I mean. You can also look at the not...
25
2009-03-29T14:21:13Z
[ "python", "xlrd", "import-from-excel" ]
What is wrong with my snap to grid code?
118,540
<p>First of all, I'm fairly sure snapping to grid is fairly easy, however I've run into some odd trouble in this situation and my maths are too weak to work out specifically what is wrong.</p> <p>Here's the situation</p> <p>I have an abstract concept of a grid, with Y steps exactly Y_STEP apart (the x steps are worki...
0
2008-09-23T01:04:10Z
118,645
<p>Do you have a typo in positionChanged() ?</p> <pre><code>def positionChanged(self, newPos): self.snappedPos = snapToGrid(newPos, Y_OFFSET, Y_STEP) </code></pre> <p>I guess you are off by one pixel because of the accuracy problems during float division. Try changing your snapToGrid() to this:</p> <pre><code>de...
0
2008-09-23T01:33:59Z
[ "python", "graphics", "grid", "snap-framework" ]
What is wrong with my snap to grid code?
118,540
<p>First of all, I'm fairly sure snapping to grid is fairly easy, however I've run into some odd trouble in this situation and my maths are too weak to work out specifically what is wrong.</p> <p>Here's the situation</p> <p>I have an abstract concept of a grid, with Y steps exactly Y_STEP apart (the x steps are worki...
0
2008-09-23T01:04:10Z
118,847
<p>Thanks for the answer, there may be a typo, but I can't see it...</p> <p>Unfortunately the change to snapToGrid didn't make a difference, so I don't think that's the issue.</p> <p>It's not off by one pixel, but rather it's off by Y_STEP. Playing around with it some more I've found that I can't get it to be exact ...
0
2008-09-23T02:54:08Z
[ "python", "graphics", "grid", "snap-framework" ]
What is wrong with my snap to grid code?
118,540
<p>First of all, I'm fairly sure snapping to grid is fairly easy, however I've run into some odd trouble in this situation and my maths are too weak to work out specifically what is wrong.</p> <p>Here's the situation</p> <p>I have an abstract concept of a grid, with Y steps exactly Y_STEP apart (the x steps are worki...
0
2008-09-23T01:04:10Z
119,022
<p>Ok, I'm answering my own question here, as alexk mentioned, using int to truncate was my mistake. </p> <p>The behaviour I'm after is best modeled by math.floor().</p> <p>Apologies, the original question does not contain enough information to really work out what the problem is. I didn't have the extra bit of inf...
1
2008-09-23T03:56:48Z
[ "python", "graphics", "grid", "snap-framework" ]
How to express this Bash command in pure Python
118,591
<p>I have this line in a useful Bash script that I haven't managed to translate into Python, where 'a' is a user-input number of days' worth of files to archive:</p> <pre><code>find ~/podcasts/current -mindepth 2 -mtime '+`a`+' -exec mv {} ~/podcasts/old \; </code></pre> <p>I am familiar with the os.name and getpass....
1
2008-09-23T01:15:54Z
118,647
<p>That's not a Bash command, it's a <code>find</code> command. If you really want to port it to Python it's possible, but you'll never be able to write a Python version that's as concise. <code>find</code> has been optimized over 20 years to be excellent at manipulating filesystems, while Python is a general-purpose p...
2
2008-09-23T01:34:37Z
[ "python", "shell", "language-comparisons" ]
How to express this Bash command in pure Python
118,591
<p>I have this line in a useful Bash script that I haven't managed to translate into Python, where 'a' is a user-input number of days' worth of files to archive:</p> <pre><code>find ~/podcasts/current -mindepth 2 -mtime '+`a`+' -exec mv {} ~/podcasts/old \; </code></pre> <p>I am familiar with the os.name and getpass....
1
2008-09-23T01:15:54Z
118,658
<pre><code>import os, stat os.stat("test")[stat.ST_MTIME] </code></pre> <p>Will give you the mtime. I suggest fixing those in <code>walk_results[2]</code>, and then recursing, calling the function for each dir in <code>walk_results[1]</code>.</p>
0
2008-09-23T01:38:31Z
[ "python", "shell", "language-comparisons" ]
How to express this Bash command in pure Python
118,591
<p>I have this line in a useful Bash script that I haven't managed to translate into Python, where 'a' is a user-input number of days' worth of files to archive:</p> <pre><code>find ~/podcasts/current -mindepth 2 -mtime '+`a`+' -exec mv {} ~/podcasts/old \; </code></pre> <p>I am familiar with the os.name and getpass....
1
2008-09-23T01:15:54Z
118,817
<pre><code>import os import shutil from os import path from os.path import join, getmtime from time import time archive = "bak" current = "cur" def archive_old_versions(days = 3): for root, dirs, files in os.walk(current): for name in files: fullname = join(root, name) if (getmtime...
5
2008-09-23T02:39:18Z
[ "python", "shell", "language-comparisons" ]
How to express this Bash command in pure Python
118,591
<p>I have this line in a useful Bash script that I haven't managed to translate into Python, where 'a' is a user-input number of days' worth of files to archive:</p> <pre><code>find ~/podcasts/current -mindepth 2 -mtime '+`a`+' -exec mv {} ~/podcasts/old \; </code></pre> <p>I am familiar with the os.name and getpass....
1
2008-09-23T01:15:54Z
118,879
<pre><code>import subprocess subprocess.call(['find', '~/podcasts/current', '-mindepth', '2', '-mtime', '+5', '-exec', 'mv', '{}', '~/podcasts/old', ';'], shell=True) </code></pre> <p>That is not a joke. This python script will do exactly what the bash one does.</p> <p><strong>EDIT</strong>: Dropped ...
3
2008-09-23T03:05:37Z
[ "python", "shell", "language-comparisons" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,651
<p>I personally doubt that there currently is at the moment, as a lot of the Python afficionados love the fact that Python is this way, whitespace delimited.</p> <p>I've never actually thought about that as an accessibility issue however. Maybe it's something to put forward as a bug report to Python?</p> <p>I'd assum...
10
2008-09-23T01:35:23Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,656
<p>You should be able to configure your editor to speak the tabs and spaces -- I know it's possible to <em>display</em> whitespace in most editors, so there must be an accessibility option somewhere to speak them.</p> <p>Failing that, there is <a href="http://timhatch.com/projects/pybraces/" rel="nofollow">pybraces</a...
6
2008-09-23T01:38:10Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,676
<p>I appreciate your problem, but think you are specifying the implementation instead of the problem you need solved. Instead of converting to braces, how about working on a way for your screen reader to tell you the indentation level? <p> For example, <a href="http://viming.blogspot.com/2007/02/indent-level-highlight...
4
2008-09-23T01:43:21Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,706
<p>Although I am not blind, I have heard good things about <a href="http://emacspeak.sourceforge.net/">Emacspeak</a>. They've had a Python mode since their <a href="http://emacspeak.sourceforge.net/releases/release-8.0.html">8.0 release</a> in 1998 (they seem to be up to release 28.0!). Definitely worth checking out.</...
9
2008-09-23T01:51:53Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,738
<p>Python supports braces for defining code blocks, and it also supports using 'begin' and 'end' tags.</p> <p>Please see these code examples:</p> <pre><code>class MyClass(object): #{ def myfunction(self, arg1, arg2): #{ for i in range(arg1): #{ print i #} #} #} </code></pre> <p>A...
24
2008-09-23T02:02:25Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
118,744
<p>There's a solution to your problem that is distributed with python itself. <code>pindent.py</code>, it's located in the Tools\Scripts directory in a windows install (my path to it is C:\Python25\Tools\Scripts), it looks like you'd have grab it from svn.python.org if you are running on Linux or OSX. </p> <p>It adds ...
52
2008-09-23T02:04:01Z
[ "python", "accessibility", "blind", "blindness" ]
Is there a way to convert indentation in Python code to braces?
118,643
<p>I am a totally blind programmer who would like to learn Python. Unfortunately the fact that code blocks are represented with different levels of indentation is a major stumbling block. I was wondering if there were any tools available that would allow me to write code using braces or some other code block delimiter ...
73
2008-09-23T01:33:13Z
236,957
<p>I use eclipse with the pydev extensions since it's an IDE I have a lot of experience with. I also appreciate the smart indentation it offers for coding if statements, loops, etc. I have configured the pindent.py script as an external tool that I can run on the currently focused python module which makes my life easi...
3
2008-10-25T20:06:08Z
[ "python", "accessibility", "blind", "blindness" ]