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 |
|---|---|---|---|---|---|---|---|---|---|
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 62,527 | <p>For a file <code>module.py</code>, the unit test should normally be called <code>test_module.py</code>, following Pythonic naming conventions.</p>
<p>There are several commonly accepted places to put <code>test_module.py</code>:</p>
<ol>
<li>In the same directory as <code>module.py</code>.</li>
<li>In <code>../tes... | 102 | 2008-09-15T12:52:00Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 63,645 | <p>When writing a package called "foo", I will put unit tests into a separate package "foo_test". Modules and subpackages will then have the same name as the SUT package module. E.g. tests for a module foo.x.y are found in foo_test.x.y. The __init__.py files of each testing package then contain an AllTests suite that i... | 0 | 2008-09-15T14:56:35Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 77,145 | <p>If the tests are simple, simply put them in the docstring -- most of the test frameworks for Python will be able to use that:</p>
<pre><code>>>> import module
>>> module.method('test')
'testresult'
</code></pre>
<p>For other more involved tests, I'd put them either in <code>../tests/test_module.p... | 0 | 2008-09-16T21:10:12Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 103,610 | <p>I also tend to put my unit tests in the file itself, as Jeremy Cantrell above notes, although I tend to not put the test function in the main body, but rather put everything in an</p>
<pre><code>if __name__ == '__main__':
do tests...
</code></pre>
<p>block. This ends up adding documentation to the file as 'exa... | 18 | 2008-09-19T16:46:53Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 128,616 | <p>We use </p>
<p>app/src/code.py</p>
<p>app/testing/code_test.py </p>
<p>app/docs/..</p>
<p>In each test file we insert "../src/" in sys.path. It's not the nicest solution but works. I think it would be great if someone came up w/ something like maven in java that gives you standard conventions that just work, no ... | 1 | 2008-09-24T17:44:16Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 382,596 | <p>I prefer toplevel tests directory. This does mean imports become a little more difficult. For that I have two solutions:</p>
<ol>
<li>Use setuptools. Then you can pass <code>test_suite='tests.runalltests.suite'</code> into <code>setup()</code>, and can run the tests simply: <code>python setup.py test</code></li>
<l... | 2 | 2008-12-19T23:48:07Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 815,212 | <p>We had the very same question when writing Pythoscope (<a href="http://pythoscope.org">http://pythoscope.org</a>), which generates unit tests for Python programs. We polled people on the testing in python list before we chose a directory, there were many different opinions. In the end we chose to put a "tests" dir... | 23 | 2009-05-02T17:08:05Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 2,363,162 | <p>How I do it...</p>
<p>Folder structure:</p>
<pre><code>project/
src/
code.py
tests/
setup.py
</code></pre>
<p>Setup.py points to src/ as the location containing my projects modules, then i run:</p>
<pre><code>setup.py develop
</code></pre>
<p>Which adds my project into site-packages, pointin... | 4 | 2010-03-02T12:50:51Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 22,704,148 | <p>From my experience in developing Testing frameworks in Python, I would suggest to put python unit tests in a separate directory. Maintain a symmetric directory structure. This would be helpful in packaging just the core libraries and not package the unit tests. Below is implemented through a schematic diagram. </p>
... | 4 | 2014-03-28T04:22:38Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 23,386,287 | <h2>Only 1 test file</h2>
<p>If doesn't have many test file, put in top-level directory is nice (I think this is python recommended way):</p>
<pre><code>module/
lib/
__init__.py
module.py
test.py
</code></pre>
<h2>Many test file</h2>
<p>If has many test file, put in a <code>tests</code> folder:</p>
<pr... | 18 | 2014-04-30T10:58:51Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 37,122,327 | <p>I recommend you check some main Python projects on GitHub and get some ideas.</p>
<p>When your code gets larger and you add more libraries it's better to create a test folder in the same directory you have setup.py and mirror your project directory structure for each test type (unittest, integration, ...)</p>
<p>F... | 2 | 2016-05-09T17:54:13Z | [
"python",
"unit-testing",
"code-organization"
] |
Where do the Python unit tests go? | 61,151 | <p>If you're writing a library, or an app, where do the unit test files go? </p>
<p>It's nice to separate the test files from the main app code, but it's awkward to put them into a "tests" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. </p>
<p... | 286 | 2008-09-14T05:41:11Z | 39,740,835 | <p>Every once in a while I find myself checking out topic of test placement, and every time majority of recommends a separate folder structure beside the library code, but I find that every time arguments are the same and are not that convincing. I end up putting my test modules somewhere beside the core modules. </p>
... | 0 | 2016-09-28T07:31:38Z | [
"python",
"unit-testing",
"code-organization"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 61,522 | <p>The <code>dir</code> builtin will give you all the object's attributes, including special methods like <code>__str__</code>, <code>__dict__</code> and a whole bunch of others which you probably don't want. But you can do something like:</p>
<pre><code>>>> class Foo(object):
... bar = 'hello'
... ba... | 45 | 2008-09-14T18:07:55Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 61,551 | <p>I've settled with a combination of both answers:</p>
<pre><code>dict((key, value) for key, value in f.__dict__.iteritems()
if not callable(value) and not key.startswith('__'))
</code></pre>
| 19 | 2008-09-14T18:50:52Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 62,680 | <p>Note that best practice in current versions of Python is to use <i>new-style</i> classes, i.e.</p>
<pre><code>class Foo(object):
...
</code></pre>
<p>Also, there's a difference between an 'object' and a 'class'. To build a dictionary from an arbitrary <i>object</i>, it's sufficient to use <code>__dict__</code>. Us... | 227 | 2008-09-15T13:08:56Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 63,635 | <blockquote>
<p>To build a dictionary from an arbitrary <i>object</i>, it's sufficient to use <code>__dict__</code>.</p>
</blockquote>
<p>This misses attributes that the object inherits from its class. For example,</p>
<pre><code>class c(object):
x = 3
a = c()
</code></pre>
<p>hasattr(a, 'x') is true, but 'x' ... | 10 | 2008-09-15T14:56:01Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 17,470,565 | <p>Late answer but provided for completeness and the benefit of googlers:</p>
<pre><code>def props(x):
return dict((key, getattr(x, key)) for key in dir(x) if key not in dir(x.__class__))
</code></pre>
<p>This will not show methods defined in the class, but it will still show fields including those assigned to la... | 5 | 2013-07-04T12:40:05Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 23,937,693 | <p>I think the easiest way is to create a <strong>getitem</strong> attribute for the class. If you need to write to the object, you can create a custom <strong>setattr</strong> . Here is an example for <strong>getitem</strong>:</p>
<pre><code>>>> class A(object):
... def __init__(self):
... self.b... | 1 | 2014-05-29T16:02:23Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 29,333,136 | <p>I thought I'd take some time to show you how you can translate an object to dict via <code>dict(obj)</code>.</p>
<pre class="lang-py prettyprint-override"><code>class A(object):
d = '4'
e = '5'
f = '6'
def __init__(self):
self.a = '1'
self.b = '2'
self.c = '3'
def __ite... | 2 | 2015-03-29T18:32:42Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 31,770,231 | <p>Instead of <code>x.__dict__</code>, it's actually more pythonic to use <code>vars(x)</code>.</p>
| 14 | 2015-08-02T08:57:29Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Python dictionary from an object's fields | 61,517 | <p>Do you know if there is a built-in function to build a dictionary from an arbitrary object? I'd like to do something like this:</p>
<pre><code>>>> class Foo:
... bar = 'hello'
... baz = 'world'
...
>>> f = Foo()
>>> props(f)
{ 'bar' : 'hello', 'baz' : 'world' }
</code></pre>
<p><... | 174 | 2008-09-14T18:00:43Z | 34,662,287 | <p>If you want to list part of your attributes, override <code>__dict__</code>:</p>
<pre><code>def __dict__(self):
d = {
'attr_1' : self.attr_1,
...
}
return d
# Call __dict__
d = instance.__dict__()
</code></pre>
<p>This helps a lot if your <code>instance</code> get some large block data and you... | 3 | 2016-01-07T18:14:45Z | [
"python",
"dictionary",
"attributes",
"object",
"metaprogramming"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 61,629 | <p>Firstly, note that Python allows for the following (no need for the parenthesis):</p>
<pre><code>q, r = divide(22, 7)
</code></pre>
<p>Regarding your question, there's no hard and fast rule either way. For simple (and usually contrived) examples, it may seem that it's always possible for a given function to have a... | 24 | 2008-09-14T20:42:01Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 61,636 | <p>Absolutely (for the example you provided).</p>
<h3>Tuples are first class citizens in Python</h3>
<p>There is a builtin function <a href="http://docs.python.org/lib/built-in-funcs.html"><code>divmod()</code></a> that does exactly that.</p>
<pre><code>q, r = divmod(x, y) # ((x - x%y)/y, x%y) Invariant: div*y + mod... | 84 | 2008-09-14T20:54:14Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 61,637 | <p>The example you give is actually a python builtin function, called <code>divmod</code>. So someone, at some point in time, thought that it was pythonic enough to include in the core functionality.</p>
<p>To me, if it makes the code cleaner, it is pythonic. Compare these two code blocks:</p>
<pre><code>seconds = 12... | 12 | 2008-09-14T20:55:28Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 63,528 | <p>It's fine to return multiple values using a tuple for simple functions such as <code>divmod</code>. If it makes the code readable, it's Pythonic.</p>
<p>If the return value starts to become confusing, check whether the function is doing too much and split it if it is. If a big tuple is being used like an object, ma... | 0 | 2008-09-15T14:43:01Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 63,549 | <p>It's definitely pythonic. The fact that you can return multiple values from a function the boilerplate you would have in a language like C where you need to define a struct for every combination of types you return somewhere.</p>
<p>However, if you reach the point where you are returning something crazy like 10 val... | 1 | 2008-09-15T14:46:06Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 63,809 | <p>Returning a tuple is cool. Also note the new namedtuple
which was added in python 2.6 which may make this more palatable for you:
<a href="http://docs.python.org/dev/library/collections.html#collections.namedtuple" rel="nofollow">http://docs.python.org/dev/library/collections.html#collections.namedtuple</a></p>
| 1 | 2008-09-15T15:14:04Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 64,110 | <p>Yes, returning multiple values (i.e., a tuple) is definitely pythonic. As others have pointed out, there are plenty of examples in the Python standard library, as well as in well-respected Python projects. Two additional comments:</p>
<ol>
<li>Returning multiple values is sometimes very, very useful. Take, for e... | 3 | 2008-09-15T15:47:23Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 66,967 | <p>I'm fairly new to Python, but the tuple technique seems very pythonic to me. However, I've had another idea that may enhance readability. Using a dictionary allows access to the different values by name rather than position. For example:</p>
<pre><code>def divide(x, y):
return {'quotient': x/y, 'remainder':x... | 1 | 2008-09-15T21:05:57Z | [
"python",
"function",
"return-value"
] |
Is it pythonic for a function to return multiple values? | 61,605 | <p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..functio... | 66 | 2008-09-14T20:15:19Z | 640,632 | <p>OT: RSRE's Algol68 has the curious "/:=" operator. eg.</p>
<pre><code>INT quotient:=355, remainder;
remainder := (quotient /:= 113);
</code></pre>
<p>Giving a quotient of 3, and a remainder of 16. </p>
<p>Note: typically the value of "(x/:=y)" is discarded as quotient "x" is assigned by reference, but in RSRE's c... | 1 | 2009-03-12T21:48:42Z | [
"python",
"function",
"return-value"
] |
python cgi on IIS | 61,781 | <p>How do you set up IIS so that you can call python scripts from asp pages?</p>
<p>Ok, so I found the answer to that question here: <a href="http://support.microsoft.com/kb/276494" rel="nofollow">http://support.microsoft.com/kb/276494</a></p>
<p>So on to my next question: How do you call a cgi script from within cla... | 0 | 2008-09-15T01:41:31Z | 61,842 | <p>You could also do it <a href="http://www.4guysfromrolla.com/webtech/082201-1.shtml" rel="nofollow">this way</a>.</p>
| 2 | 2008-09-15T03:58:29Z | [
"python",
"iis",
"asp-classic",
"vbscript",
"cgi"
] |
python cgi on IIS | 61,781 | <p>How do you set up IIS so that you can call python scripts from asp pages?</p>
<p>Ok, so I found the answer to that question here: <a href="http://support.microsoft.com/kb/276494" rel="nofollow">http://support.microsoft.com/kb/276494</a></p>
<p>So on to my next question: How do you call a cgi script from within cla... | 0 | 2008-09-15T01:41:31Z | 66,440 | <p>I don't believe that VBScript as hosted by IIS has any way of executing an external process. If you are using python as an AXscripting engine then you could just use the sys module. If the script you're calling is actually meant to be a cgi script you'll have to mimic all the environment variables that the cgi use... | 1 | 2008-09-15T20:09:09Z | [
"python",
"iis",
"asp-classic",
"vbscript",
"cgi"
] |
What's a good way to find relative paths in Google App Engine? | 61,894 | <p>So I've done the trivial "warmup" apps with GAE. Now I'd like to build something with a more complex directory structure. Something along the lines of:</p>
<pre><code>siteroot/
models/
controllers/
controller1/
controller2/
...
templates/
template1/
template2/
...
</code></pre>
<p>..etc. The cont... | 3 | 2008-09-15T05:21:47Z | 62,121 | <p>The <code>dirname</code> function returns an absolute path, use relative paths. See what is the current directory when your controllers are executed with <code>os.path.abspath(os.path.curdir)</code> and build a path to the templates relative to that location (without the <code>os.path.abspath</code> part of course).... | 1 | 2008-09-15T10:37:02Z | [
"python",
"google-app-engine"
] |
What's a good way to find relative paths in Google App Engine? | 61,894 | <p>So I've done the trivial "warmup" apps with GAE. Now I'd like to build something with a more complex directory structure. Something along the lines of:</p>
<pre><code>siteroot/
models/
controllers/
controller1/
controller2/
...
templates/
template1/
template2/
...
</code></pre>
<p>..etc. The cont... | 3 | 2008-09-15T05:21:47Z | 102,572 | <p>You can't use relative paths, as Toni suggests, because you have no guarantee that the path from your working directory to your app's directory will remain the same.</p>
<p>The correct solution is to either use os.path.split, as you are, or to use something like:</p>
<pre><code>path = os.path.join(os.path.dirname(... | 4 | 2008-09-19T15:02:56Z | [
"python",
"google-app-engine"
] |
Comparing runtimes | 62,079 | <p>I am trying to get some accurate runtime comparisons of PHP vs Python (and potentially any other language that I have to include). Timing within a script is not my problem but timing within a script does not account for everything from the moment the request is made to run the script to output.</p>
<blockquote>
<... | 2 | 2008-09-15T10:06:19Z | 62,094 | <p>If your idea is to compare the languages, I'd say anything outside them is not relevant for comparison purposes. </p>
<p>Nonetheless you can use the time command to measure everything and can compare it with the timing within a script.</p>
<p>Like this:</p>
<pre><code>$ time script.php
HI!
real 0m3.218s
user ... | 4 | 2008-09-15T10:18:05Z | [
"php",
"python",
"benchmarking"
] |
Comparing runtimes | 62,079 | <p>I am trying to get some accurate runtime comparisons of PHP vs Python (and potentially any other language that I have to include). Timing within a script is not my problem but timing within a script does not account for everything from the moment the request is made to run the script to output.</p>
<blockquote>
<... | 2 | 2008-09-15T10:06:19Z | 62,097 | <ol>
<li><p>It's worth taking speed into account if you're optimizing code. You should generally know why you're optimizing code (as in: a specific task in your existing codebase is taking too long, not "I heard PHP is slower than Python"). It's <em>not</em> worth taking speed into account if you don't actually plan on... | 1 | 2008-09-15T10:20:04Z | [
"php",
"python",
"benchmarking"
] |
Comparing runtimes | 62,079 | <p>I am trying to get some accurate runtime comparisons of PHP vs Python (and potentially any other language that I have to include). Timing within a script is not my problem but timing within a script does not account for everything from the moment the request is made to run the script to output.</p>
<blockquote>
<... | 2 | 2008-09-15T10:06:19Z | 62,099 | <p>Well, you can use the "time" command to help:</p>
<pre><code>you@yourmachine:~$ time echo "hello world"
hello world
real 0m0.000s
user 0m0.000s
sys 0m0.000s
you@yourmachine:~$
</code></pre>
<p>And this will get around timing outside of the environment.</p>
<p>As for whether you need to actually time that e... | 1 | 2008-09-15T10:23:55Z | [
"php",
"python",
"benchmarking"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,093 | <p>No. How would Python parse your script if there was a way to disable this?</p>
| 0 | 2008-09-15T13:56:32Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,094 | <p>No. Indentation-as-grammar is an integral part of the Python language, for better and worse.</p>
| 33 | 2008-09-15T13:56:47Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,095 | <p>I do not believe so, as Python is a whitespace-delimited language. Perhaps a text editor or IDE with auto-indentation would be of help. What are you currently using?</p>
| 2 | 2008-09-15T13:56:55Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,111 | <p>No, there isn't. Indentation is syntax for Python. You can:</p>
<ol>
<li>Use tabnanny.py to check your code</li>
<li>Use a syntax-aware editor that highlights such mistakes (vi does that, emacs I bet it does, and then, most IDEs do too)</li>
<li>(far-fetched) write a preprocessor of your own to convert braces (or w... | 3 | 2008-09-15T13:59:18Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,119 | <p>All of the whitespace issues I had when I was starting Python were the result mixing tabs and spaces. Once I configured everything to just use one or the other, I stopped having problems.</p>
<p>In my case I configured UltraEdit & vim to use spaces in place of tabs.</p>
| 5 | 2008-09-15T13:59:45Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,122 | <p>You should disable tab characters in your editor when you're working with Python (always, actually, IMHO, but especially when you're working with Python). Look for an option like "Use spaces for tabs": any decent editor should have one.</p>
| 2 | 2008-09-15T14:00:05Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,124 | <p>Not really. There are a few ways to modify whitespace rules for a given line of code, but you will still need indent levels to determine scope.</p>
<p>You can terminate statements with <code>;</code> and then begin a new statement on the same line. (Which people often do when <a href="http://codegolf.com/" rel="no... | 1 | 2008-09-15T14:00:23Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,196 | <p>It's possible to write a pre-processor which takes randomly-indented code with pseudo-python keywords like "endif" and "endwhile" and properly indents things. I had to do this when using python as an "ASP-like" language, because the whole notion of "indentation" gets a bit fuzzy in such an environment.</p>
<p>Of co... | 2 | 2008-09-15T14:06:46Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,216 | <p>I agree with justin and others -- pick a good editor and use spaces rather than tabs for indentation and the whitespace thing becomes a non-issue. I only recently started using Python, and while I thought the whitespace issue would be a real annoyance it turns out to not be the case. For the record I'm using emacs ... | 2 | 2008-09-15T14:09:10Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,289 | <p>Getting your indentation to work correctly is going to be important in any language you use. </p>
<p>Even though it won't affect the execution of the program in most other languages, incorrect indentation can be very confusing for anyone trying to read your program, so you need to invest the time in figuring out ho... | 1 | 2008-09-15T14:16:37Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,357 | <blockquote>
<p>I'm currently using NotePad++. Is
there maybe an IDE that would take
care of the tabs and indenting?</p>
</blockquote>
<p>I liked <a href="http://pydev.sourceforge.net/" rel="nofollow">pydev</a> extensions of eclipse for that.</p>
| 4 | 2008-09-15T14:22:30Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,403 | <p>Tabs and spaces confusion can be fixed by setting your editor to use spaces instead of tabs. </p>
<p>To make whitespace completely intuitive, you can use a stronger code editor or an IDE (though you don't need a full-blown IDE if all you need is proper automatic code indenting). </p>
<p>A list of editors can be fo... | 2 | 2008-09-15T14:28:27Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,450 | <p>I was a bit reluctant to learn Python because of tabbing. However, I almost didn't notice it when I used Vim.</p>
| 0 | 2008-09-15T14:34:34Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,819 | <p>I find it hard to understand when people flag this as a problem with Python. I took to it immediately and actually find it's one of my favourite 'features' of the language :)</p>
<p>In other languages I have two jobs:
1. Fix the braces so the computer can parse my code
2. Fix the indentation so I can parse my code.... | 2 | 2008-09-15T15:15:07Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 63,956 | <p>If you're looking for a recommendation for a Python IDE, after extensive research, I've been most happy with Wing Software's WingIDE:</p>
<p><a href="http://www.wingware.com/products" rel="nofollow">http://www.wingware.com/products</a></p>
<p>There is a free trial version, so you have nothing to lose. It supports... | 1 | 2008-09-15T15:29:29Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 64,186 | <p>Many Python IDEs and generally-capable text/source editors can handle the whitespace for you.</p>
<p>However, it is best to just "let go" and enjoy the whitespace rules of Python. With some practice, they won't get into your way at all, and you will find they have many merits, the most important of which are:</p>
... | 0 | 2008-09-15T15:57:56Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 64,356 | <p><a href="http://timhatch.com/projects/pybraces/" rel="nofollow">pybraces</a></p>
<p>It's unsupported.</p>
| 3 | 2008-09-15T16:18:30Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 64,899 | <p>In Python, indentation is a semantic element as well as providing visual grouping for readability.</p>
<p>Both space and tab can indicate indentation. This is unfortunate, because:</p>
<ul>
<li><p>The interpretation(s) of a tab varies
among editors and IDEs and is often
configurable (and often configured).</p></li... | 0 | 2008-09-15T17:25:34Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 65,771 | <p>The real answer to your question is that if you are going to use the language you need to learn its syntax. Just as an error in indenting python can generate a compiler error, an error using braces in various other languages can also generate a compiler error.</p>
<p>Even worse it can be silently misinterpreted by... | 0 | 2008-09-15T19:07:07Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 68,052 | <p>If you don't want to use an IDE/text editor with automatic indenting, you can use the pindent.py script that comes in the Tools\Scripts directory. It's a preprocessor that can convert code like:</p>
<pre><code>def foobar(a, b):
if a == b:
a = a+1
elif a < b:
b = b-1
if b > a: a = a-1
end if
else:
print 'oops!... | 1 | 2008-09-15T23:53:40Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 68,061 | <p>Emacs! Seriously, its use of "tab is a <em>command</em>, not a <em>character</em>", is absolutely perfect for python development.</p>
| 9 | 2008-09-15T23:56:17Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 68,702 | <pre><code>from __future__ import braces
</code></pre>
| 36 | 2008-09-16T01:55:09Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 69,064 | <p>Check the options of your editor or find an editor/IDE that allows you to convert TABs to spaces. I usually set the options of my editor to substitute the TAB character with 4 spaces, and I never run into any problems.</p>
| 0 | 2008-09-16T03:03:31Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 73,325 | <p>Strange - No one mentioned GEdit (Gnome) or OpenKomodo (Windows, Mac, GNU/Linux...). Both of them are great!</p>
<p>OpenKomodo especially deals with tabs and spaces very well. And - it's free. Whee! When I need a lighter weight thingy, I just use GEdit.</p>
<p>Download OpenKomodo here -
<a href="http://www.openko... | 0 | 2008-09-16T15:03:47Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 118,216 | <p>Nope, there's no way around it, and it's by design:</p>
<pre><code>>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
</code></pre>
<p>Most Python programmers simply don't use tabs, but use spaces to indent instead, that way there's no editor-to-editor inconsistency... | 0 | 2008-09-22T23:27:06Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 1,515,244 | <p>Yes, there is a way. I hate these "no way" answers, there is no way until you discover one.</p>
<p>And in that case, whatever it is worth, there is one.</p>
<p>I read once about a guy who designed a way to code so that a simple script could re-indent the code properly. I didn't managed to find any links today, tho... | -1 | 2009-10-04T00:20:23Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 1,538,995 | <p>I'm surprised no one has mentioned IDLE as a good default python editor. Nice syntax colors, handles indents, has intellisense, easy to adjust fonts, and it comes with the default download of python. Heck, I write mostly IronPython, but it's so nice & easy to edit in IDLE and run ipy from a command prompt.</p>... | 1 | 2009-10-08T16:35:33Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 1,780,742 | <p>Just use Ruby, it's much better than Python.</p>
<p><a href="http://www.ruby-lang.org" rel="nofollow">http://www.ruby-lang.org</a></p>
| -3 | 2009-11-23T01:52:25Z | [
"python"
] |
Is there a way around coding in Python without the tab, indent & whitespace criteria? | 63,086 | <p>I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?</p>
<p>I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?</p>
| 6 | 2008-09-15T13:55:14Z | 2,695,213 | <p>Any decent programming editor will reduce this annoyance to nil. I see Notepad++ has syntax highlighting, it's likely you just need to set your preferences appropriately for auto-indenting and such.</p>
| 0 | 2010-04-22T23:24:42Z | [
"python"
] |
Which is the most useful Mercurial hook for programming in a loosely connected team? | 63,488 | <p>I recently discovered the notify extension in Mercurial which allows me quickly send out emails whenever I push changes, but I'm pretty sure I'm still missing out on a lot of functionality which could make my life a lot easier. </p>
<ul>
<li>notify-extension: <a href="http://www.selenic.com/mercurial/wiki/index.cgi... | 0 | 2008-09-15T14:38:58Z | 63,606 | <p>Take a look at the hgweb stuff. You can set up RSS feeds and see all the revisions, et cetera.</p>
| 1 | 2008-09-15T14:52:58Z | [
"python",
"mercurial",
"hook"
] |
Which is the most useful Mercurial hook for programming in a loosely connected team? | 63,488 | <p>I recently discovered the notify extension in Mercurial which allows me quickly send out emails whenever I push changes, but I'm pretty sure I'm still missing out on a lot of functionality which could make my life a lot easier. </p>
<ul>
<li>notify-extension: <a href="http://www.selenic.com/mercurial/wiki/index.cgi... | 0 | 2008-09-15T14:38:58Z | 63,636 | <p>I really enjoy what I did with my custom hook. I have it post a message to my campfire account (campfire is a group based app). It worked out really well. Because I had my clients in there and it could show him my progress.</p>
| 2 | 2008-09-15T14:56:06Z | [
"python",
"mercurial",
"hook"
] |
Which is the most useful Mercurial hook for programming in a loosely connected team? | 63,488 | <p>I recently discovered the notify extension in Mercurial which allows me quickly send out emails whenever I push changes, but I'm pretty sure I'm still missing out on a lot of functionality which could make my life a lot easier. </p>
<ul>
<li>notify-extension: <a href="http://www.selenic.com/mercurial/wiki/index.cgi... | 0 | 2008-09-15T14:38:58Z | 330,548 | <p>I've written a small set of minor hooks which might be interesting: <a href="http://fellowiki.org/hg/support/quecksilber/file/" rel="nofollow">http://fellowiki.org/hg/support/quecksilber/file/</a></p>
<p>Anyway, these are the hooks most useful to me ;-)</p>
| 1 | 2008-12-01T11:13:07Z | [
"python",
"mercurial",
"hook"
] |
How create threads under Python for Delphi | 63,681 | <p>I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.</p>
<p>Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed tha... | 1 | 2008-09-15T15:00:45Z | 63,767 | <p>Threads by definition are part of the same process. If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends.</p>
<p>You'll probably want the new process to end (via exit() or the like) immediately after spawning the script.</p>
| 0 | 2008-09-15T15:10:03Z | [
"python",
"delphi"
] |
How create threads under Python for Delphi | 63,681 | <p>I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.</p>
<p>Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed tha... | 1 | 2008-09-15T15:00:45Z | 63,794 | <p>If a process dies all it's threads die with it, so a solution might be a separate process.</p>
<p>See if creating a xmlrpc server might help you, that is a simple solution for interprocess communication.</p>
| 0 | 2008-09-15T15:12:27Z | [
"python",
"delphi"
] |
How create threads under Python for Delphi | 63,681 | <p>I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.</p>
<p>Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed tha... | 1 | 2008-09-15T15:00:45Z | 65,757 | <p>Python has its own threading module that comes standard, if it helps. You can create thread objects using the threading module.</p>
<p><a href="http://docs.python.org/lib/module-threading.html" rel="nofollow">threading Documentation</a></p>
<p><a href="http://docs.python.org/lib/module-thread.html" rel="nofollow">... | 2 | 2008-09-15T19:05:12Z | [
"python",
"delphi"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 64,163 | <p>A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with different numbers, like so.</p>
<pre><code>class dog(object):
def __init__(self, height, width, lenght):
self.height = height
self.width = width
self.length = length
def revert(self):
sel... | 5 | 2008-09-15T15:54:52Z | [
"python",
"class"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 64,195 | <p>Classes don't have values. Objects do. Is what you want basically a class that can reset an instance (object) to a set of default values? </p>
<p>How about just providing a reset method, that resets the properties of your object to whatever is the default?</p>
<p>I think you should simplify your question, or tell ... | 1 | 2008-09-15T15:59:11Z | [
"python",
"class"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 64,206 | <p>I think you are confused. You should re-check the meaning of "class" and "instance".</p>
<p>I think you are trying to first declare a Instance of a certain Class, and then declare a instance of other Class, use the data from the first one, and then find a way to convert the data in the second instance and use it on... | 1 | 2008-09-15T16:00:31Z | [
"python",
"class"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 64,216 | <pre><code>class ABC(self):
numbers = [0,1,2,3]
class DEF(ABC):
def __init__(self):
self.new_numbers = super(ABC,self).numbers
def setnums(self, numbers):
self.new_numbers = numbers
def getnums(self):
return self.new_numbers
def reset(self):
__init__()
</code></pre>
| 1 | 2008-09-15T16:01:20Z | [
"python",
"class"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 64,399 | <p>Just FYI, here's an alternate implementation... Probably violates about 15 million pythonic rules, but I publish it per information/observation:</p>
<pre><code>class Resettable(object):
base_dict = {}
def reset(self):
self.__dict__ = self.__class__.base_dict
def __init__(self):
... | 1 | 2008-09-15T16:24:30Z | [
"python",
"class"
] |
Classes in Python | 64,141 | <p>In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class? </p>
<p>So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names ... | 1 | 2008-09-15T15:51:02Z | 82,969 | <p>Here's another answer kind of like pobk's; it uses the instance's dict to do the work of saving/resetting variables, but doesn't require you to specify the names of them in your code. You can call save() at any time to save the state of the instance and reset() to reset to that state.</p>
<pre><code>class MyReset:... | 1 | 2008-09-17T13:09:44Z | [
"python",
"class"
] |
Nice Python wrapper for Yahoo's Geoplanet web service? | 64,185 | <p>Has anybody created a nice wrapper around Yahoo's geo webservice "GeoPlanet" yet?</p>
| 2 | 2008-09-15T15:57:48Z | 66,924 | <p>After a brief amount of Googling, I found nothing that looks like a wrapper for this API, but I'm not quite sure if a wrapper is what is necessary for GeoPlanet. </p>
<p>According to Yahoo's <a href="http://developer.yahoo.com/geo/guide/api_docs.html#api_overview" rel="nofollow">documentation</a> for GeoPlanet, re... | 2 | 2008-09-15T21:01:02Z | [
"python",
"gis",
"yahoo"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 64,308 | <p>I tend to create new applications for each logically separate set of models. e.g.:</p>
<ul>
<li>User Profiles</li>
<li>Forum Posts</li>
<li>Blog posts</li>
</ul>
| 7 | 2008-09-15T16:12:39Z | [
"python",
"django"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 64,464 | <p>I prefer to think of Django applications as reusable modules or components than as "applications". </p>
<p>This helps me encapsulate and decouple certain features from one another, improving re-usability should I decide to share a particular "app" with the community at large, and maintainability.</p>
<p>My general... | 11 | 2008-09-15T16:32:07Z | [
"python",
"django"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 64,492 | <p>James Bennett has a wonderful <a href="http://www.b-list.org/weblog/2008/mar/15/slides/" rel="nofollow">set of slides</a> on how to organize reusable apps in Django.</p>
| 25 | 2008-09-15T16:35:16Z | [
"python",
"django"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 67,769 | <p>An 'app' could be many different things, it all really comes down to taste. For example, let's say you are building a blog. Your app could be the entire blog, or you could have an 'admin' app, a 'site' app for all of the public views, an 'rss' app, a 'services' app so developers can interface with the blog in their ... | 0 | 2008-09-15T22:56:37Z | [
"python",
"django"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 68,086 | <p>The rule I follow is it should be a new app if I want to reuse the functionality in a different project.</p>
<p>If it needs deep understanding of the models in your project, it's probably more cohesive to stick it with the models.</p>
| 1 | 2008-09-16T00:01:11Z | [
"python",
"django"
] |
When to create a new app (with startapp) in Django? | 64,237 | <p>I've googled around for this, but I still have trouble relating to what Django defines as "apps". </p>
<p>Should I create a new app for each piece of functionality in a site, even though it uses models from the main project? </p>
<p>Do you guys have good rule of thumb of when to split off a new app, and when to ke... | 48 | 2008-09-15T16:03:22Z | 8,034,555 | <p>Here is the updated presentation on 6 September 2008.</p>
<p><a href="http://www.youtube.com/watch?v=A-S0tqpPga4">http://www.youtube.com/watch?v=A-S0tqpPga4</a></p>
<p><a href="http://media.b-list.org/presentations/2008/djangocon/reusable_apps.pdf">http://media.b-list.org/presentations/2008/djangocon/reusable_apps... | 7 | 2011-11-07T09:15:00Z | [
"python",
"django"
] |
How can I access App Engine through a Corporate proxy? | 64,362 | <p>I have corporate proxy that supports https but not HTTP CONNECT (even after authentication). It just gives 403 Forbidden in response anything but HTTP or HTTPS URLS. It uses HTTP authenication, not NTLM. It is well documented the urllib2 does not work with https thru a proxy. App Engine trys to connect to a https UR... | 1 | 2008-09-15T16:18:59Z | 84,465 | <p>Do you mean it uses http basic-auth before allowing proxying, and does it then allow 'connect'.</p>
<p>Then you should be able to tunnel over it using http-tunnel or proxytunnel</p>
| 1 | 2008-09-17T15:26:22Z | [
"python",
"google-app-engine"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 64,471 | <p><a href="http://pyro.sf.net">Pyro</a> (Python Remote Objects) is fairly clever if all your server/clients are going to be in Python. I use <a href="http://www.xmpp.org">XMPP</a> alot though since I'm communicating with hosts that are not always Python. XMPP lends itself to being extended fairly easily too.</p>
<p>T... | 5 | 2008-09-15T16:33:05Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 64,487 | <p>I'd use http and start with understanding what the Python <a href="http://docs.python.org/lib/asyncore-example.html" rel="nofollow">library</a> offers. </p>
<p>Then I'd move onto the more industrial strength <a href="http://wiki.python.org/moin/Twisted-Examples" rel="nofollow">Twisted</a> library.</p>
| 1 | 2008-09-15T16:34:45Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 64,489 | <p><a href="http://www.ietf.org/rfc/rfc2616.txt" rel="nofollow">HTTP</a> seems to suit your requirements and is very well supported in Python. </p>
<p><a href="http://twistedmatrix.com/" rel="nofollow">Twisted</a> is good for serious asynchronous network programming in Python, but it has a steep learning curve, so it ... | 3 | 2008-09-15T16:34:53Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 64,572 | <p>In the RPC field, Json-RPC will bring a big performance improvement over xml-rpc:
<a href="http://json-rpc.org/wiki/python-json-rpc" rel="nofollow">http://json-rpc.org/wiki/python-json-rpc</a></p>
| -1 | 2008-09-15T16:45:13Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 64,690 | <p>XMLRPC is very simple to get started with, and at my previous job, we used it extensively for intra-node communication in a distributed system. As long as you keep track of the fact that the None value can't be easily transferred, it's dead easy to work with, and included in Python's standard library. </p>
<p>Run i... | 0 | 2008-09-15T16:58:29Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 76,560 | <p>If you are looking to do file transfers, XMLRPC is likely a bad choice. It will require that you encode all of your data as XML (and load it into memory).</p>
<p>"Data requests" and "file transfers" sounds a lot like plain old HTTP to me, but your statement of the problem doesn't make your requirements clear. Wha... | 9 | 2008-09-16T20:23:37Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 256,826 | <p>I suggest you look at 1. XMLRPC 2. JSONRPC 3. SOAP 4. REST/ATOM
XMLRPC is a valid choice. Don't worry it is too old. That is not a problem. It is so simple that little needed changing since original specification. The pro is that in every programming langauge I know there is a library for a client to be written in. ... | 4 | 2008-11-02T12:10:07Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 256,833 | <p>There is no need to use HTTP (indeed, HTTP is not good for RPC in general in some respects), and no need to use a standards-based protocol if you're talking about a python client talking to a python server.</p>
<p>Use a Python-specific RPC library such as Pyro, or what Twisted provides (Twisted.spread).</p>
| 1 | 2008-11-02T12:17:54Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 257,415 | <p>SSH can be a good choice for file transfer and remote control, especially if you are concerned with secure login. Most Linux and Solaris servers will already run an SSH service for administration, so if your Python program use ssh then you don't need to open up any additional ports or services on remote machines. </... | 1 | 2008-11-02T21:34:54Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 280,853 | <p><a href="http://incubator.apache.org/thrift/" rel="nofollow">Facebook's thrift</a> project may be a good answer. It uses a light-weight protocol to pass object around and allows you to use any language you wish. It may fall-down on security though as I believe there is none.</p>
| 0 | 2008-11-11T13:21:44Z | [
"python",
"client"
] |
Best Python supported server/client protocol? | 64,426 | <p>I'm looking for a good server/client protocol supported in Python for making data requests/file transfers between one server and many clients. Security is also an issue - so secure login would be a plus. I've been looking into XML-RPC, but it looks to be a pretty old (and possibly unused these days?) protocol.</p>... | 9 | 2008-09-15T16:27:47Z | 292,659 | <p><a href="http://code.google.com/p/protobuf/">ProtocolBuffers</a> was released by Google as a way of serializing data in a very compact efficient way. They have support for C++, Java and Python. I haven't used it yet, but looking at the source, there seem to be RPC clients and servers for each language. </p>
<p>I... | 7 | 2008-11-15T15:16:25Z | [
"python",
"client"
] |
Sending mail from Python using SMTP | 64,505 | <p>I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ?</p>
<pre><code>from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN... | 70 | 2008-09-15T16:36:35Z | 64,554 | <p>The main gotcha I see is that you're not handling any errors: .login() and .sendmail() both have documented exceptions that they can throw, and it seems like .connect() must have some way to indicate that it was unable to connect - probably an exception thrown by the underlying socket code.</p>
| 6 | 2008-09-15T16:43:36Z | [
"python",
"smtp"
] |
Sending mail from Python using SMTP | 64,505 | <p>I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ?</p>
<pre><code>from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN... | 70 | 2008-09-15T16:36:35Z | 64,580 | <p>You should make sure you format the date in the correct format - <a href="http://www.faqs.org/rfcs/rfc2822.html" rel="nofollow">RFC2822</a>.</p>
| 3 | 2008-09-15T16:46:00Z | [
"python",
"smtp"
] |
Sending mail from Python using SMTP | 64,505 | <p>I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ?</p>
<pre><code>from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN... | 70 | 2008-09-15T16:36:35Z | 64,673 | <p>Make sure you don't have any firewalls blocking SMTP. The first time I tried to send an email, it was blocked both by Windows Firewall and McAfee - took forever to find them both.</p>
| 5 | 2008-09-15T16:55:57Z | [
"python",
"smtp"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.