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 |
|---|---|---|---|---|---|---|---|---|---|
Is there a python library that implements both sides of the AWS authentication protocol? | 701,789 | <p>I am writing a REST service in python and django and wanted to use Amazon's AWS authentication protocol. I was wondering if anyone knew of a python library that implemented formation of the header for sending and the validation of the header for recieving?</p>
| 3 | 2009-03-31T16:09:48Z | 1,679,235 | <p>I think this <a href="http://staff.science.uva.nl/~otsur/code/AWS%5FSignatureGenerator.py" rel="nofollow">code</a> does exactly what you want :)
I'll be happy to get comments for improvement if needed. </p>
| 0 | 2009-11-05T09:00:05Z | [
"python",
"amazon-web-services"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 701,807 | <p>Use <a href="http://docs.python.org/library/functions.html" rel="nofollow">eval</a>.</p>
| 2 | 2009-03-31T16:13:49Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 701,808 | <p>Check out <a href="http://docs.python.org/library/functions.html#eval" rel="nofollow">eval</a>:</p>
<pre><code>x = 1
print eval('x+1')
->2
</code></pre>
| 3 | 2009-03-31T16:14:05Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 701,810 | <p>In the example a string is executed as code using the exec function.</p>
<pre><code>import sys
import StringIO
# create file-like string to capture output
codeOut = StringIO.StringIO()
codeErr = StringIO.StringIO()
code = """
def f(x):
x = x + 1
return x
print 'This is my output.'
"""
# capture output a... | 37 | 2009-03-31T16:14:38Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 701,811 | <p>The most logical solution would be to use the built-in <a href="http://docs.python.org/library/functions.html#eval" rel="nofollow">eval()</a> function .Another solution is to write that string to a temporary python file and execute it. </p>
| 1 | 2009-03-31T16:15:10Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 701,813 | <p>For statements, use <a href="https://docs.python.org/library/functions.html#exec" rel="nofollow"><code>exec(string)</code></a> (Python 2/3) or <a href="https://docs.python.org/2/reference/simple_stmts.html#grammar-token-exec_stmt" rel="nofollow"><code>exec string</code></a> (Python 2):</p>
<pre><code>>>> m... | 169 | 2009-03-31T16:15:24Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 4,278,878 | <p><code>eval()</code> is just for expressions, while <code>eval('x+1')</code> works, <code>eval('x=1')</code> won't work for example. In that case, it's better to use <code>exec</code>, or even better: try to find a better solution :)</p>
| 11 | 2010-11-25T16:03:11Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 11,551,525 | <p>You accomplish executing code using exec, as with the following IDLE session:</p>
<pre><code>>>> kw = {}
>>> exec( "ret = 4" ) in kw
>>> kw['ret']
4
</code></pre>
| 7 | 2012-07-18T22:51:49Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 14,926,430 | <p><code>eval</code> and <code>exec</code> are the correct solution, and they can be used in a safe manner!</p>
<p>As discussed in <a href="http://docs.python.org/2/reference/simple_stmts.html#exec">Python's reference manual</a> and clearly explained in <a href="http://lybniz2.sourceforge.net/safeeval.html">this</a> t... | 8 | 2013-02-17T21:44:32Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 17,378,416 | <p>Remember that from version 3 <code>exec</code> is a function!<br>
so always use <code>exec(mystring)</code> instead of <code>exec mystring</code>.</p>
| 17 | 2013-06-29T08:49:04Z | [
"python",
"string",
"exec"
] |
How do I execute a string containing Python code in Python? | 701,802 | <p>How do I execute a string containing Python code in Python?</p>
| 156 | 2009-03-31T16:12:20Z | 35,707,442 | <h1>Avoid <code>exec</code> and <code>eval</code></h1>
<h2>Using <code>exec</code> and <code>eval</code> in Python is highly frowned upon.</h2>
<h3>There are better alternatives</h3>
<p>From the top answer (emphasis mine):</p>
<blockquote>
<p>For statements, use <code>exec</code>.</p>
<p>When you need the va... | 2 | 2016-02-29T19:01:54Z | [
"python",
"string",
"exec"
] |
Django Model.object.get pre_save Function Weirdness | 702,150 | <p>I have made a function that connects to a models 'pre_save' signal. Inside the function I am trying to check if the model instance's pk already exists in the table with:</p>
<pre><code>sender.objects.get(pk=instance._get_pk_val())
</code></pre>
<p>The first instance of the model raises an error. I catch the error ... | 2 | 2009-03-31T17:29:39Z | 702,630 | <p>S.Lott is correct... use <code>save()</code>, as you've already acknowledged that you have started doing.</p>
<p>As for the signal question, I can honestly see nothing wrong with your code. I've even run it locally myself with success. Are you sure that you're representing it properly in the question? Or that insta... | 1 | 2009-03-31T19:19:18Z | [
"python",
"django",
"django-models",
"error-handling",
"django-signals"
] |
Django Model.object.get pre_save Function Weirdness | 702,150 | <p>I have made a function that connects to a models 'pre_save' signal. Inside the function I am trying to check if the model instance's pk already exists in the table with:</p>
<pre><code>sender.objects.get(pk=instance._get_pk_val())
</code></pre>
<p>The first instance of the model raises an error. I catch the error ... | 2 | 2009-03-31T17:29:39Z | 784,437 | <p>Thanks for posting this. The top google results (at the time I'm posting this) are a little outdated and show the old way of connecting signals (which was recently rewritten, apparently). Your edits, with the corrected code snippets showed me how it's done.</p>
<p>I wish more posters edited their comments to place... | 0 | 2009-04-24T03:48:50Z | [
"python",
"django",
"django-models",
"error-handling",
"django-signals"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,215 | <p>Have you taken a look at CherryPy. It is minimalistic, yet efficient and simple. It is low level enough for not it to get in they way, but high enough to hide complexity. If I remember well, TurboGears was built on it.</p>
<p>With CherryPy, you have the choice of much everything. (Template framework, ORM if wanted,... | 7 | 2009-03-31T17:46:40Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,360 | <p>I'd say you're being a bit too pessimistic about "not learning anything" using Django or a similar full-stack framework, and underestimating the value of documentation and a large community. Even with Django there's still a considerable learning curve; and if it doesn't do everything you want, it's not like the fra... | 21 | 2009-03-31T18:11:31Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,366 | <p>Have you checked out web2py? After recently evaluating many Python web frameworks recently I've decided to adopt this one. Also check out Google App Engine if you haven't already.</p>
| 2 | 2009-03-31T18:12:33Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,576 | <p>Django is definitely worth learning, and sounds like it will fit your purposes. The admin interface it comes with is easy to get up and running, and it does use authentication.</p>
<p>As for "anything lower level", if you mean sql, it is entirely possible to shove sql into you queries with the extra keyword. Styl... | 1 | 2009-03-31T19:04:16Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,596 | <p>I'm a TurboGears fan, and this is exactly the reason why: a very nice trade-off between control and doing things right vs. easy.</p>
<p>You'll have to make up your own mind of course. Maybe you'd prefer to learn less, maybe more. Maybe the areas that I like knowledge/control (database for example), you couldn't c... | 0 | 2009-03-31T19:11:10Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 702,738 | <p>I would suggest for TurboGears 2. They have done a fantastic job of integrating best of Python world. </p>
<p><strong>WSGI:</strong> Assuming you are developing moderately complex projects/ business solutions in TG2 or some other framework say Grok. Even though these frameworks supports WSGI does that mean one who ... | 0 | 2009-03-31T19:46:54Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 703,232 | <p>I suggest taking another look at TG2. I think people have failed to notice some of the strides that have been made since the last version. Aside from the growing WSGI stack of utilities available there are quite a few TG2-specific items to consider. Here are a couple of highlights:</p>
<p><a href="http://turbogea... | 15 | 2009-03-31T21:54:24Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 703,271 | <p>Your question seems to be "is it worth learning WSGI and doing everything yourself," or using a "full stack framework that does everything for you." </p>
<p>I'd say that's a false dichotomy and there's an obvious third way. TurboGears 2 tries to provide a smooth path from a "do everything for you" style framework u... | 11 | 2009-03-31T22:07:15Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 703,326 | <blockquote>
<p>the religious debates between the Django and WSGI camps</p>
</blockquote>
<p>It would seem as though you're a tad bit confused about what WSGI is and what Django is. Saying that Django and WSGI are competing is a bit like saying that C and SQL are competing: you're comparing apples and oranges.</p>... | 52 | 2009-03-31T22:25:31Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 703,375 | <blockquote>
<p>Learn WSGI</p>
</blockquote>
<p>WSGI is absurdly simple.. It's basically a function that looks like..</p>
<pre><code>def application(environ, start_response) pass
</code></pre>
<p>The function is called when an HTTP request is received. <code>environ</code> contains various data (like the request U... | 4 | 2009-03-31T22:44:35Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 704,783 | <p>I'd say the correct answer depends on what you actually want and need, as what will be worthwhile in the long run depends on what you'll need in the long run. If your goal is to get applications deployed ASAP then the 'simpler' route, ie. Django, is surely the way to go. The value of a well-tested and well-documente... | 2 | 2009-04-01T09:36:46Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 926,169 | <p>Pylons seems a great tool for me:</p>
<ul>
<li>a real web framework (CherryPy is just a web server),</li>
<li>small code base - reuse of other projects,</li>
<li>written entirely with WSGI in mind, based on Paste,</li>
<li>allows you to code the app right away and touch the low level bits if it's necessary,</li>
</... | 1 | 2009-05-29T14:09:47Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
Django vs other Python web frameworks? | 702,179 | <p>I've pretty much tried every Python web framework that exists, and it took me a long time to realize there wasn't a silver bullet framework, each had its own advantages and disadvantages. I started out with <a href="http://snakelets.sf.net">Snakelets</a> and heartily enjoyed being able to control almost everything a... | 58 | 2009-03-31T17:39:02Z | 33,663,016 | <p>Web2py is the secret sauce here. Don't miss checking it out.</p>
| -1 | 2015-11-12T01:36:31Z | [
"python",
"django",
"wsgi",
"web-frameworks",
"turbogears"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 702,445 | <p>I'm afraid django's definition of slug means ascii, though the django docs don't explicitly state this. This is the source of the defaultfilters for the slugify... you can see that the values are being converted to ascii, with the 'ignore' option in case of errors:</p>
<pre><code>import unicodedata
value = unicoded... | 10 | 2009-03-31T18:30:52Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 4,019,144 | <p>Also, the Django version of slugify doesn't use the re.UNICODE flag, so it wouldn't even attempt to understand the meaning of <code>\w\s</code> as it pertains to non-ascii characters.</p>
<p>This custom version is working well for me:</p>
<pre><code>def u_slugify(txt):
"""A custom version of slugify that r... | 15 | 2010-10-25T21:45:40Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 4,036,665 | <p>There is a python package called <a href="http://pypi.python.org/pypi/Unidecode">unidecode</a> that I've adopted for the askbot Q&A forum, it works well for the latin-based alphabets and even looks reasonable for greek:</p>
<pre><code>>>> import unidecode
>>> from unidecode import unidecode
&g... | 76 | 2010-10-27T18:58:15Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 4,616,724 | <p>This is what I use:</p>
<p><a href="http://trac.django-fr.org/browser/site/trunk/djangofr/links/slughifi.py" rel="nofollow">http://trac.django-fr.org/browser/site/trunk/djangofr/links/slughifi.py</a></p>
<p>SlugHiFi is a wrapper for regular slugify, with a difference that it replaces national chars with their Engl... | 4 | 2011-01-06T15:47:21Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 6,191,847 | <p>You might want to look at:
<a href="https://github.com/un33k/django-uuslug">https://github.com/un33k/django-uuslug</a></p>
<p>It will take care of both "U"s for you. <strong>U</strong> in unique and <strong>U</strong> in Unicode.</p>
<p>It will do the job for you hassle free.</p>
| 7 | 2011-05-31T18:26:39Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 7,041,953 | <p>The Mozilla website team has been working on an implementation :
<a href="https://github.com/mozilla/unicode-slugify">https://github.com/mozilla/unicode-slugify</a>
sample code at
<a href="http://davedash.com/2011/03/24/how-we-slug-at-mozilla/">http://davedash.com/2011/03/24/how-we-slug-at-mozilla/</a></p>
| 19 | 2011-08-12T14:55:48Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to make Django slugify work properly with Unicode strings? | 702,337 | <p>What can I do to prevent <code>slugify</code> filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2)</p>
<p><a href="http://cnprog.com">cnprog.com</a> has Chinese characters in question URLs, so I looked in their code. They are not using <code>slugify</code> in templates, instead they... | 28 | 2009-03-31T18:07:54Z | 36,175,658 | <p>Django 1.9 introduced <code>allow_unicode</code> parameter to <a href="https://docs.djangoproject.com/en/stable/ref/utils/#module-django.utils.text" rel="nofollow"><code>django.utils.text.slugify</code></a>.</p>
<pre><code>>>> slugify("ä½ å¥½ World", allow_unicode=True)
"ä½ å¥½-world"
</code></pre>
<p>If ... | 4 | 2016-03-23T10:30:55Z | [
"python",
"django",
"unicode",
"django-templates",
"slug"
] |
How to get number of affected rows in sqlalchemy? | 702,342 | <p>I have one question concerning Python and the sqlalchemy module. What is the equivalent for <code>cursor.rowcount</code> in the sqlalchemy Python?</p>
| 17 | 2009-03-31T18:08:34Z | 702,398 | <p>Although it isn't really stated in the docs, a <code>ResultProxy</code> object does have a <code>rowcount</code> property as well.</p>
| 19 | 2009-03-31T18:21:52Z | [
"python",
"sqlalchemy"
] |
Python 3.0.1 Executable Creator | 702,395 | <p>Does anyone know if there's a windows Python executable creator program available now that supports Python 3.0.1? It seems that py2exe and pyInstaller, along with all the rest I've found, still aren't anywhere close to supporting 3.0 or 3.0.1.</p>
<p>Any help is greatly appreciated.</p>
<p>Edit: I guess I could do... | 6 | 2009-03-31T18:21:20Z | 703,280 | <p>Not answering the original question but this:</p>
<blockquote>
<p>I'm actually not sure how to get the directory my program will be installed into so subprocess can find the executable program I'm using.</p>
</blockquote>
<p>You can use something like</p>
<pre><code>if hasattr(sys, 'frozen'): # this means we're... | 5 | 2009-03-31T22:09:51Z | [
"python",
"executable",
"py2exe",
"pyinstaller"
] |
Python 3.0.1 Executable Creator | 702,395 | <p>Does anyone know if there's a windows Python executable creator program available now that supports Python 3.0.1? It seems that py2exe and pyInstaller, along with all the rest I've found, still aren't anywhere close to supporting 3.0 or 3.0.1.</p>
<p>Any help is greatly appreciated.</p>
<p>Edit: I guess I could do... | 6 | 2009-03-31T18:21:20Z | 1,136,269 | <p>After searching for many days I came to the conclusion that the isn't currently any method for making executables for python 3.0 scripts.</p>
<p>One workaround I came up with was to use portable python:
<a href="http://www.portablepython.com/releases/" rel="nofollow">http://www.portablepython.com/releases/</a></p>
... | 1 | 2009-07-16T08:51:46Z | [
"python",
"executable",
"py2exe",
"pyinstaller"
] |
Python 3.0.1 Executable Creator | 702,395 | <p>Does anyone know if there's a windows Python executable creator program available now that supports Python 3.0.1? It seems that py2exe and pyInstaller, along with all the rest I've found, still aren't anywhere close to supporting 3.0 or 3.0.1.</p>
<p>Any help is greatly appreciated.</p>
<p>Edit: I guess I could do... | 6 | 2009-03-31T18:21:20Z | 1,263,241 | <p>How about <a href="http://cx-freeze.sourceforge.net/">cx_Freeze</a>. Seems to support python 3.0 and 3.1?</p>
| 11 | 2009-08-11T22:07:12Z | [
"python",
"executable",
"py2exe",
"pyinstaller"
] |
Python 3.0.1 Executable Creator | 702,395 | <p>Does anyone know if there's a windows Python executable creator program available now that supports Python 3.0.1? It seems that py2exe and pyInstaller, along with all the rest I've found, still aren't anywhere close to supporting 3.0 or 3.0.1.</p>
<p>Any help is greatly appreciated.</p>
<p>Edit: I guess I could do... | 6 | 2009-03-31T18:21:20Z | 1,801,043 | <p>I got it working with <a href="http://cx-freeze.sourceforge.net/" rel="nofollow">cx_freeze</a>.</p>
<p>Was a bit of a hassle since you have to add a line of code to get around some errors but it turned out to go just fine with Python 3.1.1 and PyQt4.</p>
<p>Also see <a href="http://stackoverflow.com/questions/1737... | 0 | 2009-11-26T01:14:42Z | [
"python",
"executable",
"py2exe",
"pyinstaller"
] |
Python 3.0.1 Executable Creator | 702,395 | <p>Does anyone know if there's a windows Python executable creator program available now that supports Python 3.0.1? It seems that py2exe and pyInstaller, along with all the rest I've found, still aren't anywhere close to supporting 3.0 or 3.0.1.</p>
<p>Any help is greatly appreciated.</p>
<p>Edit: I guess I could do... | 6 | 2009-03-31T18:21:20Z | 19,952,222 | <p><s>
Python 3 is not supported by <code>py2exe</code>. The relevant bug to comment on is here:<br>
<a href="https://sourceforge.net/p/py2exe/feature-requests/20/">https://sourceforge.net/p/py2exe/feature-requests/20/</a>
</s></p>
<h1>py2exe for Python3 is out!</h1>
<p>Here is the original bug report:<br>
<a href="h... | 6 | 2013-11-13T11:13:08Z | [
"python",
"executable",
"py2exe",
"pyinstaller"
] |
How to limit I/O consumption of Python processes (possibly using ionice)? | 702,407 | <p>I would like a particular set of Python subprocesses to be as low-impact as possible. I'm already using <a href="http://www.manpagez.com/man/1/nice/">nice</a> to help limit CPU consumption. But ideally I/O would be limited as well. (If skeptical, please humor me and assume there is value in doing this; it doesn't... | 12 | 2009-03-31T18:23:07Z | 702,439 | <p>Why not have whatever <em>launches</em> the processes do the ionice on them (i.e., run them with ionice) rather than having them ionice themselves? It seems a whole lot cleaner.</p>
| 3 | 2009-03-31T18:29:21Z | [
"python",
"linux",
"performance",
"unix"
] |
How to limit I/O consumption of Python processes (possibly using ionice)? | 702,407 | <p>I would like a particular set of Python subprocesses to be as low-impact as possible. I'm already using <a href="http://www.manpagez.com/man/1/nice/">nice</a> to help limit CPU consumption. But ideally I/O would be limited as well. (If skeptical, please humor me and assume there is value in doing this; it doesn't... | 12 | 2009-03-31T18:23:07Z | 703,933 | <p>Hm.</p>
<p>As a start pointer, you should find what <code>syscall</code> number are the <code>ioprio_set</code> and <code>ioprio_get</code> system calls in your kernel. I'd suggest you check in <code>/usr/include/asm/unistd_32.h</code> or <code>/usr/include/asm/unistd_64.h</code>, depending on your kernel arch; if ... | 5 | 2009-04-01T03:19:38Z | [
"python",
"linux",
"performance",
"unix"
] |
How to limit I/O consumption of Python processes (possibly using ionice)? | 702,407 | <p>I would like a particular set of Python subprocesses to be as low-impact as possible. I'm already using <a href="http://www.manpagez.com/man/1/nice/">nice</a> to help limit CPU consumption. But ideally I/O would be limited as well. (If skeptical, please humor me and assume there is value in doing this; it doesn't... | 12 | 2009-03-31T18:23:07Z | 6,245,160 | <p><a href="http://code.google.com/p/psutil/" rel="nofollow">psutil</a> exposes this functionality (python 2.4 -> 3.2):</p>
<pre><code>import psutil, os
p = psutil.Process(os.getpid())
p.ionice(psutil.IOPRIO_CLASS_IDLE)
</code></pre>
<p>Also, starting from Python 3.3 this will be available in python stdlib as well:
<... | 13 | 2011-06-05T19:04:18Z | [
"python",
"linux",
"performance",
"unix"
] |
User editing own Active Directory data | 702,493 | <p>How can I build a web page that allows a logged on user of a Windows 2003 domain change details of his account (probably just First Name, Surname, and Phone number)?</p>
| 0 | 2009-03-31T18:42:43Z | 703,023 | <p>Check out <a href="http://code.google.com/p/python-ad/" rel="nofollow">Python-AD</a> (Python Active Directory) which offers the bindings you'll want for communicating with the AD server.</p>
<p>As for the very broad "how can I build a web page" portion of your request, SO has plenty of questions/answers on good web... | 0 | 2009-03-31T20:58:13Z | [
"asp.net",
"python",
"active-directory"
] |
User editing own Active Directory data | 702,493 | <p>How can I build a web page that allows a logged on user of a Windows 2003 domain change details of his account (probably just First Name, Surname, and Phone number)?</p>
| 0 | 2009-03-31T18:42:43Z | 703,042 | <p>Take a look at this <a href="http://www.novell.com/coolsolutions/feature/11204.html" rel="nofollow">http://www.novell.com/coolsolutions/feature/11204.html</a> </p>
| 0 | 2009-03-31T21:03:11Z | [
"asp.net",
"python",
"active-directory"
] |
Django admin - inline inlines (or, three model editing at once) | 702,637 | <p>I've got a set of models that look like this:</p>
<pre><code>class Page(models.Model):
title = models.CharField(max_length=255)
class LinkSection(models.Model):
page = models.ForeignKey(Page)
title = models.CharField(max_length=255)
class Link(models.Model):
linksection = models.ForeignKey(LinkSec... | 48 | 2009-03-31T19:20:51Z | 717,152 | <p>My recommendation would actually be to change your model. Why not have a <code>ForeignKey</code> in <code>Link</code> to <code>LinkSection</code>? Or, if it's not OneToMany, perhaps a <code>ManyToMany</code> field? The admin interface will generate that for free. Of course, I don't recommend this if links don't ... | 1 | 2009-04-04T14:05:51Z | [
"python",
"django",
"django-models",
"django-admin",
"inlines"
] |
Django admin - inline inlines (or, three model editing at once) | 702,637 | <p>I've got a set of models that look like this:</p>
<pre><code>class Page(models.Model):
title = models.CharField(max_length=255)
class LinkSection(models.Model):
page = models.ForeignKey(Page)
title = models.CharField(max_length=255)
class Link(models.Model):
linksection = models.ForeignKey(LinkSec... | 48 | 2009-03-31T19:20:51Z | 1,329,725 | <p>You can create a new class, similar to TabularInline or StackedInline, that is able to use inline fields itself.</p>
<p>Alternatively, you can create new admin templates, specifically for your model. But that of course overrules the nifty features of the admin interface.</p>
| 0 | 2009-08-25T17:29:16Z | [
"python",
"django",
"django-models",
"django-admin",
"inlines"
] |
Django admin - inline inlines (or, three model editing at once) | 702,637 | <p>I've got a set of models that look like this:</p>
<pre><code>class Page(models.Model):
title = models.CharField(max_length=255)
class LinkSection(models.Model):
page = models.ForeignKey(Page)
title = models.CharField(max_length=255)
class Link(models.Model):
linksection = models.ForeignKey(LinkSec... | 48 | 2009-03-31T19:20:51Z | 1,332,476 | <p>You need to create a custom <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form">form</a> and <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#template">template</a> for the <code>LinkSectionInline</code>.</p>
<p>Something like this should work for the form:</p>
<pre><code>LinkFor... | 19 | 2009-08-26T05:18:15Z | [
"python",
"django",
"django-models",
"django-admin",
"inlines"
] |
Django admin - inline inlines (or, three model editing at once) | 702,637 | <p>I've got a set of models that look like this:</p>
<pre><code>class Page(models.Model):
title = models.CharField(max_length=255)
class LinkSection(models.Model):
page = models.ForeignKey(Page)
title = models.CharField(max_length=255)
class Link(models.Model):
linksection = models.ForeignKey(LinkSec... | 48 | 2009-03-31T19:20:51Z | 26,087,864 | <p><a href="https://pypi.python.org/pypi/django-nested-inlines/0.1" rel="nofollow">Django-nested-inlines</a> is built for just this. Usage is simple.</p>
<pre><code>from django.contrib import admin
from nested_inlines.admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline
from models import A, B, C
c... | 3 | 2014-09-28T18:02:17Z | [
"python",
"django",
"django-models",
"django-admin",
"inlines"
] |
How do I generate multi-word terms recursively? | 702,760 | <p>Say I have a string of words: <code>'a b c d e f'</code>. I want to generate a list of multi-word terms from this string.</p>
<p>Word order matters. The term <code>'f e d'</code> shouldn't be generated from the above example.</p>
<p><strong>Edit:</strong> Also, words should not be skipped. <code>'a c'</code>, or... | 5 | 2009-03-31T19:54:20Z | 702,784 | <p>I would suggest that you should make your function a generator and then generate required number of terms. You would need to change <code>print</code> to <code>yield</code> (and make the whole block function, obviously).</p>
<p>You might have a look at <a href="http://docs.python.org/library/itertools.html?highligh... | 3 | 2009-03-31T20:00:08Z | [
"python",
"recursion"
] |
How do I generate multi-word terms recursively? | 702,760 | <p>Say I have a string of words: <code>'a b c d e f'</code>. I want to generate a list of multi-word terms from this string.</p>
<p>Word order matters. The term <code>'f e d'</code> shouldn't be generated from the above example.</p>
<p><strong>Edit:</strong> Also, words should not be skipped. <code>'a c'</code>, or... | 5 | 2009-03-31T19:54:20Z | 702,788 | <p>Why are you doing this? You can instead just use a for loop and <a href="http://docs.python.org/library/itertools.html#itertools.combinations" rel="nofollow"><code>itertools.combinations()</code></a>.</p>
| 3 | 2009-03-31T20:01:14Z | [
"python",
"recursion"
] |
How do I generate multi-word terms recursively? | 702,760 | <p>Say I have a string of words: <code>'a b c d e f'</code>. I want to generate a list of multi-word terms from this string.</p>
<p>Word order matters. The term <code>'f e d'</code> shouldn't be generated from the above example.</p>
<p><strong>Edit:</strong> Also, words should not be skipped. <code>'a c'</code>, or... | 5 | 2009-03-31T19:54:20Z | 702,807 | <p>This isn't recursive, but I think it does what you want. </p>
<pre><code>doc = 'a b c d e f'
words = doc.split(None)
max = 3
for index in xrange(len(words)):
for n in xrange(max):
if index + n < len(words):
print ' '.join(words[index:index+n+1])
</code></pre>
<... | 11 | 2009-03-31T20:07:02Z | [
"python",
"recursion"
] |
How do I generate multi-word terms recursively? | 702,760 | <p>Say I have a string of words: <code>'a b c d e f'</code>. I want to generate a list of multi-word terms from this string.</p>
<p>Word order matters. The term <code>'f e d'</code> shouldn't be generated from the above example.</p>
<p><strong>Edit:</strong> Also, words should not be skipped. <code>'a c'</code>, or... | 5 | 2009-03-31T19:54:20Z | 1,932,985 | <p>What you are looking for is N-gram algorithm. That will give you [a,ab,b,bc,c,cd,...].</p>
| 1 | 2009-12-19T13:59:57Z | [
"python",
"recursion"
] |
Is there a better trivial Python WebDAV server code snippet than this? | 702,780 | <p>Does anyone have a better code snippet for a trivial Python <a href="http://en.wikipedia.org/wiki/WebDAV" rel="nofollow">WebDAV</a> server? The code below (which is cobbled together from some Google search results) appears to work under Python 2.6, but I wonder if someone has something they have used before, a <em>... | 1 | 2009-03-31T19:58:46Z | 704,597 | <p>You can try akaDAV. It is a WebDAV module for Twisted that you can get at <a href="http://akadav.sourceforge.net/" rel="nofollow">http://akadav.sourceforge.net/</a>.</p>
<p>I think it is not maintained anymore but I've got it to work and it supports most operations (except locks).</p>
| 1 | 2009-04-01T08:32:31Z | [
"python",
"webdav"
] |
Is there a better trivial Python WebDAV server code snippet than this? | 702,780 | <p>Does anyone have a better code snippet for a trivial Python <a href="http://en.wikipedia.org/wiki/WebDAV" rel="nofollow">WebDAV</a> server? The code below (which is cobbled together from some Google search results) appears to work under Python 2.6, but I wonder if someone has something they have used before, a <em>... | 1 | 2009-03-31T19:58:46Z | 1,126,409 | <p>Or try PyFileServer, which I picked up for further develpment by the name WsgiDAV (<a href="http://code.google.com/p/wsgidav/" rel="nofollow">http://code.google.com/p/wsgidav/</a>)<br>
<strong>Edit:</strong> the project has moved to GitHub (<a href="https://github.com/mar10/wsgidav" rel="nofollow">https://github.com... | 3 | 2009-07-14T16:05:47Z | [
"python",
"webdav"
] |
Is there a better trivial Python WebDAV server code snippet than this? | 702,780 | <p>Does anyone have a better code snippet for a trivial Python <a href="http://en.wikipedia.org/wiki/WebDAV" rel="nofollow">WebDAV</a> server? The code below (which is cobbled together from some Google search results) appears to work under Python 2.6, but I wonder if someone has something they have used before, a <em>... | 1 | 2009-03-31T19:58:46Z | 3,554,256 | <p><a href="http://code.google.com/p/wsgidav/" rel="nofollow">WsgiDAV</a></p>
| 1 | 2010-08-24T07:22:30Z | [
"python",
"webdav"
] |
Executing Java programs through Python | 702,861 | <p>How do I do this?</p>
| 8 | 2009-03-31T20:20:32Z | 702,888 | <p>You can execute anything you want from Python with the <a href="http://docs.python.org/library/os.html#os.system"><code>os.system()</code></a> function.</p>
<blockquote>
<p><strong>os.system(command)</strong><br />
Execute the command
(a string) in a subshell. This is
implemented by calling the Standard C
... | 8 | 2009-03-31T20:25:59Z | [
"java",
"python"
] |
Executing Java programs through Python | 702,861 | <p>How do I do this?</p>
| 8 | 2009-03-31T20:20:32Z | 703,221 | <p>Of course, Jython allows you to use Java classes from within Python. It's an alternate way of looking at it that would allow much tighter integration of the Java code.</p>
| 5 | 2009-03-31T21:52:05Z | [
"java",
"python"
] |
URL encode a non-value pair in Python | 702,986 | <p>I'm trying to use Google's AJAX (JSON) Web Search API in Python. I'm stuck because Python's urllib.urlencode() only takes value pairs, not strings by themselves, to encode. In Google's API, the query string is the search term and it doesn't associate with a variable.</p>
<pre><code>query = "string that needs to be ... | 14 | 2009-03-31T20:48:16Z | 703,002 | <p>I think you're looking for <a href="http://docs.python.org/library/urllib.html#urllib.quote"><code>urllib.quote</code></a> instead.</p>
| 36 | 2009-03-31T20:52:33Z | [
"python",
"json",
"urlencode"
] |
Using email.HeaderParser with imaplib.fetch in python? | 703,185 | <p>Does anyone have a good example of using the HeaderParser class in Python for a message that you pull down with imaplib.fetch?</p>
<p>I have been able to find a lot of related things, but nothing that does just this.</p>
<p>Do I need to full down the fetch has an RFC822? I was hoping to simply pull down the subj... | 7 | 2009-03-31T21:40:57Z | 703,479 | <p>Good news: you're right... you don't need to pull down the RFC822. The <code>message_parts</code> parameter to <code>fetch()</code> lets you be quite fine-grained.</p>
<p>Here's a simple example of how to fetch just the header:</p>
<pre><code>import imaplib
from email.parser import HeaderParser
conn = imaplib.IMA... | 16 | 2009-03-31T23:27:07Z | [
"python",
"email"
] |
Most efficient way of loading formatted binary files in Python | 703,262 | <p>I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use?</p>
| 5 | 2009-03-31T22:03:36Z | 703,267 | <p>Use the <a href="http://docs.python.org/library/struct.html" rel="nofollow">struct</a> module, or possibly a custom module written in C if performance is critical.</p>
| 8 | 2009-03-31T22:05:12Z | [
"python",
"input",
"binaryfiles"
] |
Most efficient way of loading formatted binary files in Python | 703,262 | <p>I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use?</p>
| 5 | 2009-03-31T22:03:36Z | 703,588 | <p>I found that <code>array.fromfile</code> is the fastest methods for homogeneous data.</p>
| 0 | 2009-04-01T00:27:11Z | [
"python",
"input",
"binaryfiles"
] |
Most efficient way of loading formatted binary files in Python | 703,262 | <p>I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use?</p>
| 5 | 2009-03-31T22:03:36Z | 703,957 | <p><a href="http://docs.python.org/library/struct.html" rel="nofollow">struct</a> should work for the header section, while numpy's <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html#numpy.memmap" rel="nofollow">memmap</a> would be efficient for the data section if you are going to manipulat... | 4 | 2009-04-01T03:32:45Z | [
"python",
"input",
"binaryfiles"
] |
Most efficient way of loading formatted binary files in Python | 703,262 | <p>I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use?</p>
| 5 | 2009-03-31T22:03:36Z | 704,265 | <p><a href="http://www.hl.id.au/projects/bdec/" rel="nofollow">bdec</a> seems promising.</p>
| 1 | 2009-04-01T06:12:57Z | [
"python",
"input",
"binaryfiles"
] |
Python: an iteration over a non-empty list with no if-clause comes up empty. Why? | 703,520 | <p>How can an iterator over a non-empty sequence, with no filtering and no aggregation (<code>sum()</code>, etc.), yield nothing?</p>
<p>Consider a simple example:</p>
<pre><code>sequence = ['a', 'b', 'c']
list((el, ord(el)) for el in sequence)
</code></pre>
<p>This yields <code>[('a', 97), ('b', 98), ('c', 99)]</co... | 4 | 2009-03-31T23:53:51Z | 703,534 | <p><code>odd_integers_up_to_length(el).next()</code> will raise StopIteration, which isn't caught there, but is caught for the generator expression within it, stopping it without ever yielding anything.</p>
<p>look at the first iteration, when the value is 'a':</p>
<pre><code>>>> odd_integers_up_to_length('a... | 13 | 2009-03-31T23:59:40Z | [
"python",
"iterator",
"generator",
"leaky-abstraction"
] |
Python: an iteration over a non-empty list with no if-clause comes up empty. Why? | 703,520 | <p>How can an iterator over a non-empty sequence, with no filtering and no aggregation (<code>sum()</code>, etc.), yield nothing?</p>
<p>Consider a simple example:</p>
<pre><code>sequence = ['a', 'b', 'c']
list((el, ord(el)) for el in sequence)
</code></pre>
<p>This yields <code>[('a', 97), ('b', 98), ('c', 99)]</co... | 4 | 2009-03-31T23:53:51Z | 703,539 | <p>What happens is that the <code>next()</code> call raises a <code>StopIteration</code> exception, which bubbles up the stack to the outer generator expression and stops <em>that</em> iteration.</p>
<p>A <code>StopIteration</code> is the normal way for an iterator to signal that it's done. Generally we don't see it, ... | 4 | 2009-04-01T00:01:30Z | [
"python",
"iterator",
"generator",
"leaky-abstraction"
] |
Python: an iteration over a non-empty list with no if-clause comes up empty. Why? | 703,520 | <p>How can an iterator over a non-empty sequence, with no filtering and no aggregation (<code>sum()</code>, etc.), yield nothing?</p>
<p>Consider a simple example:</p>
<pre><code>sequence = ['a', 'b', 'c']
list((el, ord(el)) for el in sequence)
</code></pre>
<p>This yields <code>[('a', 97), ('b', 98), ('c', 99)]</co... | 4 | 2009-03-31T23:53:51Z | 703,543 | <p>str is a reserved keword, you should name your variable differently</p>
<p>I was also to advise about the next</p>
| 0 | 2009-04-01T00:03:10Z | [
"python",
"iterator",
"generator",
"leaky-abstraction"
] |
Python: an iteration over a non-empty list with no if-clause comes up empty. Why? | 703,520 | <p>How can an iterator over a non-empty sequence, with no filtering and no aggregation (<code>sum()</code>, etc.), yield nothing?</p>
<p>Consider a simple example:</p>
<pre><code>sequence = ['a', 'b', 'c']
list((el, ord(el)) for el in sequence)
</code></pre>
<p>This yields <code>[('a', 97), ('b', 98), ('c', 99)]</co... | 4 | 2009-03-31T23:53:51Z | 703,545 | <pre><code>>>> seq=['a','b','c']
>>> list((el,4) for el in seq)
[('a',4), ('b',4), ('c',4)]
</code></pre>
<p>So it's not <code>list</code> giving you trouble here...</p>
| 0 | 2009-04-01T00:04:53Z | [
"python",
"iterator",
"generator",
"leaky-abstraction"
] |
Anything like SciPy in Ruby? | 703,717 | <p>Looking further into the differences between Python and Ruby, is there a Ruby equivalent to SciPy, or what other scientific math gems are available for Ruby?</p>
| 14 | 2009-04-01T01:33:31Z | 703,731 | <p>There's nothing quite as mature or well done as SciPy, but check out <a href="http://sciruby.com/">SciRuby</a> and <a href="http://narray.rubyforge.org/">Numerical Ruby</a>.</p>
| 17 | 2009-04-01T01:39:34Z | [
"python",
"ruby",
"math",
"scipy"
] |
Anything like SciPy in Ruby? | 703,717 | <p>Looking further into the differences between Python and Ruby, is there a Ruby equivalent to SciPy, or what other scientific math gems are available for Ruby?</p>
| 14 | 2009-04-01T01:33:31Z | 703,736 | <p>rnum</p>
<blockquote>
<p>Ruby Numerical Library is a linear
algebra package using Blas and Lapack.</p>
</blockquote>
<p><a href="http://rnum.rubyforge.org/" rel="nofollow">http://rnum.rubyforge.org/</a></p>
<p>Site has some speed comparisons</p>
| 2 | 2009-04-01T01:42:19Z | [
"python",
"ruby",
"math",
"scipy"
] |
Anything like SciPy in Ruby? | 703,717 | <p>Looking further into the differences between Python and Ruby, is there a Ruby equivalent to SciPy, or what other scientific math gems are available for Ruby?</p>
| 14 | 2009-04-01T01:33:31Z | 8,365,878 | <p>linalg <a href="https://github.com/wedesoft" rel="nofollow">https://github.com/wedesoft</a>, installation instructions: <a href="http://www.quora.com/Installation-Instructions/How-do-I-install-Ruby-linalg-library-on-Mac" rel="nofollow">http://www.quora.com/Installation-Instructions/How-do-I-install-Ruby-linalg-libra... | 0 | 2011-12-03T05:55:15Z | [
"python",
"ruby",
"math",
"scipy"
] |
Anything like SciPy in Ruby? | 703,717 | <p>Looking further into the differences between Python and Ruby, is there a Ruby equivalent to SciPy, or what other scientific math gems are available for Ruby?</p>
| 14 | 2009-04-01T01:33:31Z | 10,339,519 | <p>Someone else mentioned NArray and Ara T. Howard's / @drawohara's SciRuby.</p>
<p>But there's also a new <a href="http://sciruby.com" rel="nofollow">SciRuby project</a> (proceeding with Ara's and Masahiro Tanaka's blessings) which includes a dense and sparse matrix gem, <a href="http://github.com/SciRuby/nmatrix" re... | 1 | 2012-04-26T18:46:07Z | [
"python",
"ruby",
"math",
"scipy"
] |
How would I compute exactly 30 days into the past with Python (down to the minute)? | 703,907 | <p>In Python, I'm attempting to retrieve the date/time that is exactly 30 days (30*24hrs) into the past. At present, I'm simply doing:</p>
<pre><code>>>> import datetime
>>> start_date = datetime.date.today() + datetime.timedelta(-30)
</code></pre>
<p>Which returns a datetime object, but with no tim... | 16 | 2009-04-01T02:59:46Z | 703,912 | <p>You want to use a <code>datetime</code> object instead of just a <code>date</code> object:</p>
<pre><code>start_date = datetime.datetime.now() + datetime.timedelta(-30)
</code></pre>
<p><code>date</code> just stores a date and <code>time</code> just a time. <code>datetime</code> is a date with a time.</p>
| 37 | 2009-04-01T03:01:48Z | [
"python",
"datetime",
"date",
"time"
] |
How would I compute exactly 30 days into the past with Python (down to the minute)? | 703,907 | <p>In Python, I'm attempting to retrieve the date/time that is exactly 30 days (30*24hrs) into the past. At present, I'm simply doing:</p>
<pre><code>>>> import datetime
>>> start_date = datetime.date.today() + datetime.timedelta(-30)
</code></pre>
<p>Which returns a datetime object, but with no tim... | 16 | 2009-04-01T02:59:46Z | 703,916 | <p>date <> datetime</p>
| -5 | 2009-04-01T03:05:31Z | [
"python",
"datetime",
"date",
"time"
] |
Using pydev with Eclipse on OSX | 703,925 | <p>I setup PyDev with this path for the python interpreter
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
since the one under /usr/bin were alias and Eclipse won't select it. I can run my python script now but cannot run the shell as an external tool. The message I get is</p>
<p>variable references em... | 11 | 2009-04-01T03:11:00Z | 704,037 | <p>I believe <code>${resource_loc}</code> or <code>${container_loc}</code> (without any argument) are based on the current selection in your workbench when you are launching your script.</p>
<p>So are you selecting the right resource when selecting that script through the "external tool" runner ?<br />
At least, click... | 0 | 2009-04-01T04:14:21Z | [
"python",
"eclipse"
] |
Using pydev with Eclipse on OSX | 703,925 | <p>I setup PyDev with this path for the python interpreter
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
since the one under /usr/bin were alias and Eclipse won't select it. I can run my python script now but cannot run the shell as an external tool. The message I get is</p>
<p>variable references em... | 11 | 2009-04-01T03:11:00Z | 884,296 | <p>Common practice seems to be to install an up-to-date Python 2.5 from python.org and use that instead of the system installation. I saw that recommended here and there when I got started on Mac OS X.</p>
<p>It installs under <code>/Library</code> (as opposed to <code>/System/Library</code>) so the system Python is i... | 3 | 2009-05-19T18:21:03Z | [
"python",
"eclipse"
] |
Using pydev with Eclipse on OSX | 703,925 | <p>I setup PyDev with this path for the python interpreter
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
since the one under /usr/bin were alias and Eclipse won't select it. I can run my python script now but cannot run the shell as an external tool. The message I get is</p>
<p>variable references em... | 11 | 2009-04-01T03:11:00Z | 2,785,302 | <p>I installed the Python.org version as well, this is a must.</p>
<p>I finally got PyDev working in Eclipse by pointing the interpreter to:</p>
<pre><code>/Library/Frameworks/Python.framework/Versions/2.6/bin/python
</code></pre>
<p>manually. If you don't do it manually (by using the Autoconfig) it seems to not fi... | 10 | 2010-05-06T23:53:40Z | [
"python",
"eclipse"
] |
Using pydev with Eclipse on OSX | 703,925 | <p>I setup PyDev with this path for the python interpreter
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
since the one under /usr/bin were alias and Eclipse won't select it. I can run my python script now but cannot run the shell as an external tool. The message I get is</p>
<p>variable references em... | 11 | 2009-04-01T03:11:00Z | 10,695,484 | <p>I know this is a ancient post... but, in case of some newbee like me to get the better answer.</p>
<p>I just using "Eclipse Marketplace" from the "Help" menu and search for keyword "python" or "PyDev" to get PyDev, and get it successfully installed.</p>
<p>AND, you should add PyDev to the top-right dock.</p>
<p>F... | 1 | 2012-05-22T03:48:38Z | [
"python",
"eclipse"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 704,139 | <p>Vim support for a number of scripting languages built in -- see <A HREF="http://www.vim.org/htmldoc/if_pyth.html" rel="nofollow">the Python interface</A> as an example.</p>
<p>Just modify <code>vim.current.buffer</code> appropriately and you're set.</p>
<p>To be a little more specific:</p>
<pre><code>function! Ro... | 10 | 2009-04-01T05:13:33Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 704,797 | <p>Here is a command in Vim language. So you don't have to compile Vim with +python support.</p>
<pre><code>function! s:transpose()
let maxcol = 0
let lines = getline(1, line('$'))
for line in lines
let len = len(line)
if len > maxcol
let maxcol = len
endif
endf... | 11 | 2009-04-01T09:42:24Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 704,857 | <p>If scripts don't do it for you, you could record the actions to a register (the carriage returns are added for readability):</p>
<pre><code>qa
1G0
xGo<Esc>p
1G0j
xGp
q
</code></pre>
<p>This will give you a macro that you could run against the example above, or any 2-line strings of the same length. You only ... | 5 | 2009-04-01T10:01:20Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 7,318,088 | <p><a href="http://stackoverflow.com/questions/704130/can-i-transpose-a-file-in-vim#704139">Charles Duffy's code</a> could be shortened/improved using <code>izip_longest</code> instead of <code>izip</code>:</p>
<pre><code>function! Rotate()
:py import vim, itertools
:py vim.current.buffer[:] = [''.join(c) for ... | 0 | 2011-09-06T09:58:16Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 7,320,629 | <p>The following function performs required editing operations to "transpose" the
contents of the current buffer.</p>
<pre><code>fu!T()
let[m,n,@s]=[0,line('$'),"lDG:pu\r``j@s"]
g/^/let m=max([m,col('$')])
exe'%norm!'.m."A \e".m.'|D'
sil1norm!@s
exe'%norm!'.n.'gJ'
endf
</code></pre>
<p>Below is its one-line version,<... | 1 | 2011-09-06T13:23:13Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
Can I transpose a file in Vim? | 704,130 | <p>I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. </p>
<p>The original file might be</p>
<pre><code>THE DAY WAS LONG... | 12 | 2009-04-01T05:09:10Z | 10,470,420 | <p>I've developed a vim plugin to do it. You can find it <a href="https://github.com/salsifis/vim-transpose" rel="nofollow">here</a>. Run <code>:Transpose</code> to transpose the whole file.</p>
| 0 | 2012-05-06T12:18:38Z | [
"python",
"vim",
"text-files",
"text-parsing"
] |
How can I convert a character to a integer in Python, and viceversa? | 704,152 | <p>I want to get, given a character, its <code>ASCII</code> value.</p>
<p>For example, for the character <code>a</code>, I want to get <code>97</code>, and vice versa.</p>
| 160 | 2009-04-01T05:19:15Z | 704,157 | <p>ord and chr</p>
| 4 | 2009-04-01T05:21:22Z | [
"python",
"integer",
"char",
"type-conversion"
] |
How can I convert a character to a integer in Python, and viceversa? | 704,152 | <p>I want to get, given a character, its <code>ASCII</code> value.</p>
<p>For example, for the character <code>a</code>, I want to get <code>97</code>, and vice versa.</p>
| 160 | 2009-04-01T05:19:15Z | 704,158 | <pre><code>>>> ord('a')
97
>>> chr(97)
'a'
</code></pre>
| 20 | 2009-04-01T05:21:39Z | [
"python",
"integer",
"char",
"type-conversion"
] |
How can I convert a character to a integer in Python, and viceversa? | 704,152 | <p>I want to get, given a character, its <code>ASCII</code> value.</p>
<p>For example, for the character <code>a</code>, I want to get <code>97</code>, and vice versa.</p>
| 160 | 2009-04-01T05:19:15Z | 704,160 | <p>Use <a href="http://docs.python.org/library/functions.html#chr"><code>chr()</code></a> and <a href="http://docs.python.org/library/functions.html#ord"><code>ord()</code></a>:</p>
<pre><code>>>> chr(97)
'a'
>>> ord('a')
97
</code></pre>
| 300 | 2009-04-01T05:22:00Z | [
"python",
"integer",
"char",
"type-conversion"
] |
How can I convert a character to a integer in Python, and viceversa? | 704,152 | <p>I want to get, given a character, its <code>ASCII</code> value.</p>
<p>For example, for the character <code>a</code>, I want to get <code>97</code>, and vice versa.</p>
| 160 | 2009-04-01T05:19:15Z | 704,183 | <p>The question has been answered but I think this reference is a good thing to keep note of. <a href="http://docs.python.org/library/functions.html">http://docs.python.org/library/functions.html</a></p>
| 7 | 2009-04-01T05:36:09Z | [
"python",
"integer",
"char",
"type-conversion"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,223 | <p>One idea: Save the process's PID (returned by <code>fork()</code> in your child process) to a file, then either schedule a <code>cron</code> job to kill it or kill it manually, reading the PID from the file.</p>
<p>Another option: Create a shell script wrapper that automatically kills and restarts the process. Same... | 0 | 2009-04-01T05:52:05Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,224 | <p>Take a look at the <a href="http://olympus.het.brown.edu/cgi-bin/man/man2html?start-stop-daemon" rel="nofollow">start-stop-daemon</a> utility. </p>
| 0 | 2009-04-01T05:52:52Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,226 | <p>You could always write a script to search for those processes and kill them if found.
Then add a cronjob to execute the script.</p>
<p><a href="http://www.faqs.org/faqs/unix-faq/faq/part3/section-10.html" rel="nofollow">Find process ID of a process with known name</a></p>
<p><a href="http://www.unix.com/unix-dummi... | 0 | 2009-04-01T05:53:16Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,229 | <p>This is in Perl, but you should be able to translate it to Python.</p>
<pre><code>#!/usr/bin/perl
use strict;
use warnings;
#set times to 0 for infinite times
my ($times, $wait, $program, @args) = @ARGV;
$times = -1 unless $times;
while ($times--) {
$times = -1 if $times < 0; #catch -2 and turn it back in... | 3 | 2009-04-01T05:55:10Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,273 | <p>With bash:</p>
<pre><code>while true ; do
run_proc &
PID=$!
sleep 3600
kill $PID
sleep 30
done
</code></pre>
<p>The <code>$!</code> bash variable expands to the PID of the most recently started background process. The <code>sleep</code> just waits an hour, then the <code>kill</code> shuts d... | 3 | 2009-04-01T06:16:21Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 704,889 | <p>In python:</p>
<pre><code>import subprocess
import time
while True:
p = subprocess.Popen(['/path/to/program', 'param1', 'param2'])
time.sleep(2 * 60 * 60) # wait time in seconds - 2 hours
p.kill()
</code></pre>
<p><code>p.kill()</code> is python >= 2.6.</p>
<p>On python <= 2.5 you can use this... | 2 | 2009-04-01T10:12:16Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
How do I schedule a process' termination? | 704,203 | <p>I need to run a process, wait a few hours, kill it, and start it again. Is there an easy way that I can accomplish this with Python or Bash? I can run it in the background but how do I identify it to use kill on it?</p>
| 0 | 2009-04-01T05:44:36Z | 713,898 | <p>Not an ideal method but if you know the name of the program and you know it's the only process of that name running on the system you can use this in cron:</p>
<pre><code>0 */2 * * * kill `ps -ax | grep programName | grep -v grep | awk '{ print $1 }'` && ./scriptToStartProcess
</code></pre>
<p>This will ru... | 0 | 2009-04-03T13:26:36Z | [
"python",
"bash",
"unix",
"process",
"kill"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,554 | <p>Here's one way of doing it, assuming your "alphabets" is integers, and that the list has at least two items:</p>
<pre><code>for i in xrange(1, len(a)):
if a[i] != a[i - 1] + 1:
print a[i - 1] + 1, "is missing"
</code></pre>
| 0 | 2009-04-01T08:20:13Z | [
"python"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,562 | <p>With sorted lists a binary search is usually the fastest alghorythm. Could you please provide an example list and an example "missing alphabet"?</p>
| 0 | 2009-04-01T08:21:18Z | [
"python"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,576 | <p>Some questions:</p>
<ul>
<li>Are all the letters upper or lower case? (a/A)</li>
<li>Is this the only alphabet you'll want to check?</li>
<li>Why are you doing this so often?</li>
</ul>
<p>Least lines of code:</p>
<pre><code># do this once, outside the loop
alphabet=set(string.ascii_lowercase)
# inside the loop, ... | 10 | 2009-04-01T08:25:40Z | [
"python"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,595 | <p>Using a list comprehension:</p>
<pre><code>>>> import string
>>> sourcelist = 'abcdefghijklmnopqrstuvwx'
>>> [letter for letter in string.ascii_lowercase if letter not in sourcelist]
['y', 'z']
>>>
</code></pre>
<p>The <a href="http://docs.python.org/library/string.html" rel="no... | 7 | 2009-04-01T08:32:13Z | [
"python"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,601 | <p>if you're talking about alphabet as letters:</p>
<pre><code>letterSet = set()
for word in wordList:
letterSet.update(set(word.lower()))
import string
alphabet = set(string.lowercase)
missingLetters = alphabet.difference(letterSet)
</code></pre>
| 0 | 2009-04-01T08:33:25Z | [
"python"
] |
python: finding a missing letter in the alphabet from a list - least lines of code | 704,526 | <p>I'm trying to find the missing letter in the alphabet from the list with the least lines of code.</p>
<p>If the list is sorted already (using list.sort()), what is the fastest or least lines of code to find the missing letter.</p>
<p>If I know there are only one missing letter.</p>
<p>(This is not any type of int... | 2 | 2009-04-01T08:08:19Z | 704,686 | <p>In the too clever for it's own good category, and assuming there is exactly one missing letter in a lowercase alphabet:</p>
<pre><code>print chr(2847 - sum(map(ord, theString)))
</code></pre>
<p><strong>[Edit]</strong>
I've run some timings on the various solutions to see which is faster.
Mine turned out to be fai... | 7 | 2009-04-01T09:06:28Z | [
"python"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.