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
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
12,343,688
<p>Removing the 'rest' would work:</p> <pre><code>rounded = int(val) - int(val) % 5 </code></pre> <p>If the value is aready an integer:</p> <pre><code>rounded = val - val % 5 </code></pre> <p>As a function:</p> <pre><code>def roundint(value, base=5): return int(value) - int(value) % int(base) </code></pre>
6
2012-09-09T23:00:15Z
[ "python", "rounding" ]
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
18,666,678
<p>For rounding to non-integer values, such as 0.05:</p> <pre><code>def myround(x, prec=2, base=.05): return round(base * round(float(x)/base),prec) </code></pre> <p>I found this useful since I could just do a search and replace in my code to change "round(" to "myround(", without having to change the parameter val...
14
2013-09-06T21:13:23Z
[ "python", "rounding" ]
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
23,327,688
<p>You can “trick” <code>int()</code> into rounding off instead of rounding down by adding <code>0.5</code> to the number you pass to <code>int()</code>.</p>
-2
2014-04-27T19:04:48Z
[ "python", "rounding" ]
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
25,536,738
<p>Sorry, I wanted to comment on Alok Singhai's answer, but it won't let me due to a lack of reputation =/</p> <p>Anyway, we can generalize one more step and go:</p> <pre><code>def myround(x, base=5): return base * round(float(x) / base) </code></pre> <p>This allows us to use non-integer bases, like <code>.25</c...
3
2014-08-27T20:53:04Z
[ "python", "rounding" ]
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
31,614,085
<p>I realise I'm late to the party, but it seems that this solution has not been mentioned:</p> <pre><code>&gt;&gt;&gt; from __future__ import division # This is only needed on Python 2 &gt;&gt;&gt; def round_to_nearest(n, m): r = n % m return n + m - r if r + r &gt;= m else n - r ... </code></pre> ...
1
2015-07-24T15:12:49Z
[ "python", "rounding" ]
Round to 5 (or other number) in python
2,272,149
<p>Is there a built-in function that can round like this:</p> <pre><code>10 -&gt; 10 12 -&gt; 10 13 -&gt; 15 14 -&gt; 15 16 -&gt; 15 18 -&gt; 20 </code></pre>
75
2010-02-16T10:35:04Z
35,667,654
<pre><code>def round_to_next5(n): return n + (5 - n) % 5 </code></pre>
1
2016-02-27T08:47:44Z
[ "python", "rounding" ]
uncompressing tar.Z file with python?
2,272,199
<p>I need to write a python script that retrieves tar.Z files from an FTP server, and uncompress them on a windows machine. tar.Z, if I understood correctly is the result of a <em>compress</em> command in Unix.</p> <p>Python doesn't seem to know how to handle these, it's not gz, nor bz2 or zip. Does anyone know a libr...
1
2010-02-16T10:41:33Z
2,272,231
<p>Since you target a specific platform (Windows), the simplest solution may be to run gzip in a system call: <a href="http://www.gzip.org/#exe" rel="nofollow">http://www.gzip.org/#exe</a></p> <p>Are there other requirements in your project that the decompression needs to be done in Python?</p>
0
2010-02-16T10:46:39Z
[ "python", "tar", "compression" ]
uncompressing tar.Z file with python?
2,272,199
<p>I need to write a python script that retrieves tar.Z files from an FTP server, and uncompress them on a windows machine. tar.Z, if I understood correctly is the result of a <em>compress</em> command in Unix.</p> <p>Python doesn't seem to know how to handle these, it's not gz, nor bz2 or zip. Does anyone know a libr...
1
2010-02-16T10:41:33Z
2,272,410
<p>If GZIP -- the application -- can handle it, you have two choices.</p> <ol> <li><p>Try the Python <code>gzip</code> library. It may work.</p></li> <li><p>Use <code>subprocess Popen</code> to run <code>gzip</code> for you.</p></li> </ol> <p>It may be an InstallShield .Z file. You may want to use InstallShield to u...
1
2010-02-16T11:20:12Z
[ "python", "tar", "compression" ]
uncompressing tar.Z file with python?
2,272,199
<p>I need to write a python script that retrieves tar.Z files from an FTP server, and uncompress them on a windows machine. tar.Z, if I understood correctly is the result of a <em>compress</em> command in Unix.</p> <p>Python doesn't seem to know how to handle these, it's not gz, nor bz2 or zip. Does anyone know a libr...
1
2010-02-16T10:41:33Z
2,292,273
<p>A plain Python module that uncompresses is inexistant, AFAIK, but it's feasible to build one, given some knowledge:</p> <ul> <li>the .Z format header specification</li> <li>the .Z compression format</li> </ul> <p>Almost all necessary information can be found <a href="http://code.google.com/p/theunarchiver/wiki/Com...
0
2010-02-18T21:20:03Z
[ "python", "tar", "compression" ]
Class Inheritance through Multiple Classes
2,272,728
<p>I have 3 classes and I run the first class and declare a variable in the second class and want the 3rd class to be able to print out this variable. I have code below to explain this more clearly.</p> <pre><code>from class2 import Class2 class Class1(Class2): def __init__(self): self.value1 = 10 ...
1
2010-02-16T12:10:52Z
2,272,775
<p>It is kind of hard to understand what you are trying to do as your code does not even run. I think something like this is what you are trying to do:</p> <pre><code>class Class3(): def printValue(self): print self.string1 class Class2(Class3): def e(self): self.value4 = self.value3 - self....
1
2010-02-16T12:21:37Z
[ "python", "inheritance", "parameters", "class" ]
Class Inheritance through Multiple Classes
2,272,728
<p>I have 3 classes and I run the first class and declare a variable in the second class and want the 3rd class to be able to print out this variable. I have code below to explain this more clearly.</p> <pre><code>from class2 import Class2 class Class1(Class2): def __init__(self): self.value1 = 10 ...
1
2010-02-16T12:10:52Z
2,272,841
<p>I'd suggest:</p> <h2><strong>File1</strong></h2> <pre><code>class Class3: def __init__(self): #I'd really like to do self.string1 = "" or something concrete here. pass def printValue(self): #Add exception handling #self may not have a `string1` print self.string1 </...
0
2010-02-16T12:34:08Z
[ "python", "inheritance", "parameters", "class" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
2,272,859
<p>A more pythonic solution might be:</p> <pre><code># i,j = range to sort. a = a[:i] + sorted(a[i:j]) + a[j:] </code></pre> <p>This is not sorted 'in place', but that seems like an artificial requirement. Happy to hear why that could be a requirement, though. ;)</p>
-1
2010-02-16T12:37:01Z
[ "python", "sorting", "in-place" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
2,273,006
<p>Based on your requirements, I'd suggest creating your own sort function/ a wrapper class for the list with a sort function which staisfies your requirement. </p> <p>You might consider the DSU idiom or the schwartzian transform: See <a href="http://wiki.python.org/moin/HowTo/Sorting" rel="nofollow">http://wiki.pytho...
0
2010-02-16T13:03:47Z
[ "python", "sorting", "in-place" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
2,273,248
<p>I'd write it this way:</p> <pre><code>a[i:j] = sorted(a[i:j]) </code></pre> <p>It is not in-place sort either, but fast enough for relatively small segments.</p> <p>Please note, that Python copies only object references, so the speed penalty won't be that huge compared to a real in-place sort as one would expect....
29
2010-02-16T13:42:31Z
[ "python", "sorting", "in-place" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
2,275,504
<p>if <code>a</code> is a <code>numpy</code> array then to sort <code>[i, j)</code> range in-place, type:</p> <pre><code>a[i:j].sort() </code></pre> <p>Example:</p> <pre><code>&gt;&gt;&gt; import numpy as np &gt;&gt;&gt; a = np.array([4, 8, 1, 7, 3, 0, 5, 2, 6, 9]) &gt;&gt;&gt; a[1:4].sort() &gt;&gt;&gt; a array([4,...
9
2010-02-16T18:59:24Z
[ "python", "sorting", "in-place" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
28,106,518
<p>You can simply use the list method sort, e.g.</p> <pre><code>&gt;&gt;&gt; a = [2,3,1] &gt;&gt;&gt; a.sort() &gt;&gt;&gt; a [1, 2, 3] </code></pre>
-2
2015-01-23T09:17:58Z
[ "python", "sorting", "in-place" ]
Sort a part of a list in place
2,272,819
<p>Let's say we have a list:</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>Now, a.sort() will sort the list in place. What if we want to sort only <em>a part</em> of the list, still in place? In C++ we could write:</p> <pre><code>int array = { 4, 8, 1, 7, 3, 0, 5, 2, 6, 9 }; int * ptr = array; s...
21
2010-02-16T12:29:06Z
29,214,981
<p>There is another simple approach.let you have an array</p> <pre><code>a = [4, 8, 1, 7, 3, 0, 5, 2, 6, 9] </code></pre> <p>and you want to sort a part of this array,say from index 2 to index 7 in a zero based index, i.e from element 1 to 2.</p> <pre><code>b = a[2:7+1] b.sort() a[2:7+1] = b </code></pre>
0
2015-03-23T16:08:31Z
[ "python", "sorting", "in-place" ]
Python: select function
2,272,854
<p>With this code:</p> <pre><code>import scipy from scipy import * x = r_[1:15] print x a = select([x &gt; 7, x &gt;= 4],[x,x+10]) print a </code></pre> <p>I get this answer:</p> <pre><code>[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14] [ 0 0 0 14 15 16 17 8 9 10 11 12 13 14] </code></pre> <p>But why do I hav...
2
2010-02-16T12:36:00Z
2,272,921
<p>You seem to be using numpy.</p> <p>From the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.select.html" rel="nofollow">documentation for numpy.select()</a>:</p> <blockquote> <p><code>numpy.select(condlist, choicelist, default=0)</code></p> <p>...</p> <p><em>default</em>: The element...
5
2010-02-16T12:47:18Z
[ "python", "select", "numpy" ]
Is it possible to define a wx.Panel as a class in Python?
2,272,889
<p>I want to define several plugins. They all inherit from the superclass Plugin.</p> <p>Each plugin consists on a wx.Panel that have a more specific method called "draw".</p> <p>How can I define a class as a Panel and afterwards call that class in my frame?</p> <p>I've tried like this:</p> <pre><code>class Panel(w...
1
2010-02-16T12:41:37Z
2,273,154
<p>There is a class <code>wx.PyPanel</code> that is a version of Panel intended to be subclassed from Python and allows you to override C++ virtual methods.</p> <p>There are PyXxxx versions of a number of other wx classes as well.</p>
2
2010-02-16T13:26:00Z
[ "python", "class", "wxpython", "panel", "frame" ]
Is it possible to define a wx.Panel as a class in Python?
2,272,889
<p>I want to define several plugins. They all inherit from the superclass Plugin.</p> <p>Each plugin consists on a wx.Panel that have a more specific method called "draw".</p> <p>How can I define a class as a Panel and afterwards call that class in my frame?</p> <p>I've tried like this:</p> <pre><code>class Panel(w...
1
2010-02-16T12:41:37Z
2,273,220
<pre><code>class MyPanel(wx.Panel): def __init__(self, *args): wx.Panel.__init__(self, *args) def draw(self): # Your code here </code></pre>
4
2010-02-16T13:38:07Z
[ "python", "class", "wxpython", "panel", "frame" ]
Is it possible to define a wx.Panel as a class in Python?
2,272,889
<p>I want to define several plugins. They all inherit from the superclass Plugin.</p> <p>Each plugin consists on a wx.Panel that have a more specific method called "draw".</p> <p>How can I define a class as a Panel and afterwards call that class in my frame?</p> <p>I've tried like this:</p> <pre><code>class Panel(w...
1
2010-02-16T12:41:37Z
2,273,654
<blockquote> <p>How can I define a class as a Panel and afterwards call that class in my frame?</p> </blockquote> <p>What you tried is close, but you're not properly calling the super class <code>__init__</code>. When subclassing wxPython classes, however, it's generally best to use the following pattern so that yo...
0
2010-02-16T14:44:13Z
[ "python", "class", "wxpython", "panel", "frame" ]
SQLAlchemy and scalar values
2,272,917
<p>I have simple question regarding SQLAlchemy, is it possible to get the rows from the result as scalars instead of tuples? In other words I want an equivalent to:</p> <pre><code>[i[0] for i in self.archive.query(IRTerm.term).distinct()] </code></pre> <p>Thank you</p>
5
2010-02-16T12:46:47Z
2,273,007
<p>No built in way in SQLAlchemy, but with python it isn't too hard. The example you gave works fine. You can also do <code>map(itemgetter(0), query)</code> or <code>for value, in query:</code>.</p>
5
2010-02-16T13:03:47Z
[ "python", "sqlalchemy" ]
SQLAlchemy and scalar values
2,272,917
<p>I have simple question regarding SQLAlchemy, is it possible to get the rows from the result as scalars instead of tuples? In other words I want an equivalent to:</p> <pre><code>[i[0] for i in self.archive.query(IRTerm.term).distinct()] </code></pre> <p>Thank you</p>
5
2010-02-16T12:46:47Z
19,090,224
<p>Since 0.6.5 you can use <code>query.as_scalar</code> (<a href="http://docs.sqlalchemy.org/en/rel_0_7/orm/query.html#sqlalchemy.orm.query.Query.as_scalar" rel="nofollow">ref</a>).</p>
-1
2013-09-30T09:01:17Z
[ "python", "sqlalchemy" ]
CherryPy behind Nginx reverse-proxy POST requests corrupted/truncated
2,272,931
<p>I have put my application using Cherrypy 3.1.2 behind Nginx configured as a reverse-proxy. All is working right for GET requests, but all POST requests return HTTP 400 - Malformed header.</p> <p>I traced into CherryPy WSGI-Server source code to see the request-handling code and found out that if for GET requests th...
8
2010-02-16T12:48:36Z
3,017,904
<p>you could try the parameters:</p> <pre><code>ignore_invalid_headers on; sendfile on; </code></pre> <p>in the http block... also might try disabling keepalives and ensure you're logging access/errors to debug.</p>
1
2010-06-10T19:48:26Z
[ "python", "nginx", "cherrypy", "reverse-proxy" ]
DJANGO Python-ldap UNWILLING TO PERFORM {'info': '00002077: SvcErr: DSID-031907B4, problem 5003 (WILL_NOT_PERFORM), data 0\n', 'desc': 'Server is unwilling to perform'}
2,273,117
<p>My Django application using python-ldap library (ldap_groups django application) must add users against an Active Directory on a Windows 2003 Virtual Machine domain. My application running on a Ubuntu virtual Machine is not member of the Windows domain:</p> <p>Here is the code:</p> <p>settings.py</p> <pre><code>D...
1
2010-02-16T13:20:26Z
2,274,569
<p>I found the problem. In fact my objectclass was not compliant with Active Directory. Furthermore change information encoding by a python string.</p> <p>Here is the code to use:</p> <pre><code> attrs = {} attrs['objectclass'] = ['top','person','organizationalPerson','user'] attrs['cn'] = str(usernam...
1
2010-02-16T16:47:24Z
[ "python", "django", "ldap" ]
SQLAlchemy subquery - average of sums
2,273,127
<p>is there any way how to write the following SQL statement in SQLAlchemy ORM:</p> <pre><code>SELECT AVG(a1) FROM (SELECT sum(irterm.n) AS a1 FROM irterm GROUP BY irterm.item_id); </code></pre> <p>Thank you</p>
14
2010-02-16T13:21:39Z
2,273,149
<p>Please see SQLAlchemy's tutorial on <a href="http://www.sqlalchemy.org/docs/orm/tutorial.html#using-subqueries" rel="nofollow">subqueries</a>.</p>
1
2010-02-16T13:25:35Z
[ "python", "sqlalchemy" ]
SQLAlchemy subquery - average of sums
2,273,127
<p>is there any way how to write the following SQL statement in SQLAlchemy ORM:</p> <pre><code>SELECT AVG(a1) FROM (SELECT sum(irterm.n) AS a1 FROM irterm GROUP BY irterm.item_id); </code></pre> <p>Thank you</p>
14
2010-02-16T13:21:39Z
2,273,845
<pre><code>sums = session.query(func.sum(Irterm.n).label('a1')).group_by(Irterm.item_id) average = session.query(func.avg(sums.subquery().columns.a1)).scalar() </code></pre>
22
2010-02-16T15:14:28Z
[ "python", "sqlalchemy" ]
how to define generic variables in Python (syntax question)
2,273,211
<p>With Python it is easy to declare something like</p> <pre><code>self.x = "something" print self.x #outputs "something" </code></pre> <p>I want to have something like this:</p> <pre><code>param["key"] = "x" self.param["key"] = "something" #here I actually want to access this "self" parameter as below with its valu...
1
2010-02-16T13:35:51Z
2,273,230
<p>Use <a href="http://docs.python.org/library/functions.html#setattr" rel="nofollow"><code>setattr</code></a> -- <code>setattr(self, param['key'], 'something')</code>.</p>
4
2010-02-16T13:39:50Z
[ "python" ]
How about having a SingletonModel in Django?
2,273,258
<p>I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an <code>HTMLField</code>.</p> <p>The first way that came to mind was to make a model <code>Ticker</code> which will have only one instance. Then ...
15
2010-02-16T13:44:19Z
2,274,434
<p>rewrite your save method so that every time a Ticker object gets saved it overwrites the existing one (if one exists).</p>
1
2010-02-16T16:27:15Z
[ "python", "django", "orm", "singleton" ]
How about having a SingletonModel in Django?
2,273,258
<p>I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an <code>HTMLField</code>.</p> <p>The first way that came to mind was to make a model <code>Ticker</code> which will have only one instance. Then ...
15
2010-02-16T13:44:19Z
2,275,496
<p>I think having a "singleton" model is ugly; it's dumb use of the relational database and it's bad UI, because the admin UI is built around working with lists of objects.</p> <p>Instead I prefer to use a generic solution like <a href="http://github.com/clintecker/django-chunks" rel="nofollow">django-chunks</a> or <a...
1
2010-02-16T18:58:06Z
[ "python", "django", "orm", "singleton" ]
How about having a SingletonModel in Django?
2,273,258
<p>I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an <code>HTMLField</code>.</p> <p>The first way that came to mind was to make a model <code>Ticker</code> which will have only one instance. Then ...
15
2010-02-16T13:44:19Z
10,858,061
<p>You can use <a href="https://github.com/tttallis/django-singletons" rel="nofollow" title="django-singletons">django_singletons</a>. It has a built in admin support.</p>
3
2012-06-01T22:25:35Z
[ "python", "django", "orm", "singleton" ]
How about having a SingletonModel in Django?
2,273,258
<p>I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an <code>HTMLField</code>.</p> <p>The first way that came to mind was to make a model <code>Ticker</code> which will have only one instance. Then ...
15
2010-02-16T13:44:19Z
17,928,520
<p>A model with only one instance, a singleton, is sometime useful for things like global settings that you want to edit from the admin instead of having them in Django settings.py.</p> <p>There are several third party applications that helps implementing singleton models and improve the admin interface for instance, ...
1
2013-07-29T15:51:18Z
[ "python", "django", "orm", "singleton" ]
How about having a SingletonModel in Django?
2,273,258
<p>I'm making a very simple website in Django. On one of the pages there is a vertical ticker box. I need to give the client a way to edit the contents of the ticker box as an <code>HTMLField</code>.</p> <p>The first way that came to mind was to make a model <code>Ticker</code> which will have only one instance. Then ...
15
2010-02-16T13:44:19Z
20,813,571
<p>Try <a href="https://github.com/lazybird/django-solo">django-solo</a>, it works in django 1.5 + for sure, <a href="https://github.com/tttallis/django-singletons">django-singletons</a> doesn't work with 1.5 + because it uses a deprecated feature.</p>
6
2013-12-28T10:39:46Z
[ "python", "django", "orm", "singleton" ]
Should pre-commit tests use a big data set and fail if queries take too long, or use a small test database?
2,273,414
<p>I am developing some Python modules that use a mysql database to insert some data and produce various types of report. I'm doing test driven development and so far I run:</p> <ul> <li>some CREATE / UPDATE / DELETE tests against a temporary database that is thrown away at the end of each test case, and </li> <li>som...
1
2010-02-16T14:06:21Z
2,273,471
<p>I'd do both. Run against the small set first to make sure all the code works, then run against the large dataset for things which need to be tested for time, this would be selects, searches and reports especially. If you are doing inserts or deletes or updates on multiple row sets, I'd test those as well against the...
1
2010-02-16T14:16:03Z
[ "python", "sql", "mysql", "tdd", "automated-tests" ]
Should pre-commit tests use a big data set and fail if queries take too long, or use a small test database?
2,273,414
<p>I am developing some Python modules that use a mysql database to insert some data and produce various types of report. I'm doing test driven development and so far I run:</p> <ul> <li>some CREATE / UPDATE / DELETE tests against a temporary database that is thrown away at the end of each test case, and </li> <li>som...
1
2010-02-16T14:06:21Z
2,273,476
<p>The problem with testing against real data is that it contains lots of duplicate values, and not enough edge cases. It is also difficult to know what the expected values ought to be (especially if your live database is very big). Oh, and depending on what the live application does, it can be illegal to use the da...
1
2010-02-16T14:16:37Z
[ "python", "sql", "mysql", "tdd", "automated-tests" ]
Regex divide with upper-case
2,273,462
<p>I would like to replace strings like <code>'HDMWhoSomeThing'</code> to <code>'HDM Who Some Thing'</code> with regex.</p> <p>So I would like to extract words which starts with an upper-case letter or consist of upper-case letters only. Notice that in the string <code>'HDMWho'</code> the last upper-case letter is in ...
4
2010-02-16T14:14:06Z
2,273,478
<p>Try to split with this regular expression:</p> <pre><code>/(?=[A-Z][a-z])/ </code></pre> <p>And if your regular expression engine does not support splitting empty matches, try this regular expression to put spaces between the words:</p> <pre><code>/([A-Z])(?![A-Z])/ </code></pre> <p>Replace it with <code>" $1"</...
2
2010-02-16T14:17:00Z
[ "python", "regex", "string", "split", "uppercase" ]
Regex divide with upper-case
2,273,462
<p>I would like to replace strings like <code>'HDMWhoSomeThing'</code> to <code>'HDM Who Some Thing'</code> with regex.</p> <p>So I would like to extract words which starts with an upper-case letter or consist of upper-case letters only. Notice that in the string <code>'HDMWho'</code> the last upper-case letter is in ...
4
2010-02-16T14:14:06Z
2,273,482
<p>May be '[A-Z]*?[A-Z][a-z]+'?</p> <p><strong>Edit:</strong> This seems to work: [A-Z]{2,}(?![a-z])|[A-Z][a-z]+</p> <pre><code>import re def find_stuff(str): p = re.compile(r'[A-Z]{2,}(?![a-z])|[A-Z][a-z]+') m = p.findall(str) result = '' for x in m: result += x + ' ' print result find_stuff('HDMWhoS...
1
2010-02-16T14:17:39Z
[ "python", "regex", "string", "split", "uppercase" ]
Regex divide with upper-case
2,273,462
<p>I would like to replace strings like <code>'HDMWhoSomeThing'</code> to <code>'HDM Who Some Thing'</code> with regex.</p> <p>So I would like to extract words which starts with an upper-case letter or consist of upper-case letters only. Notice that in the string <code>'HDMWho'</code> the last upper-case letter is in ...
4
2010-02-16T14:14:06Z
2,273,756
<p>So 'words' in this case are:</p> <ol> <li>Any number of uppercase letters - unless the last uppercase letter is followed by a lowercase letter.</li> <li>One uppercase letter followed by any number of lowercase letters.</li> </ol> <p>so try:</p> <p><code>([A-Z]+(?![a-z])|[A-Z][a-z]*)</code></p> <p>The first alter...
1
2010-02-16T14:59:04Z
[ "python", "regex", "string", "split", "uppercase" ]
Regex divide with upper-case
2,273,462
<p>I would like to replace strings like <code>'HDMWhoSomeThing'</code> to <code>'HDM Who Some Thing'</code> with regex.</p> <p>So I would like to extract words which starts with an upper-case letter or consist of upper-case letters only. Notice that in the string <code>'HDMWho'</code> the last upper-case letter is in ...
4
2010-02-16T14:14:06Z
2,273,759
<p>one liner : </p> <p>' '.join(a or b for a,b in re.findall('([A-Z][a-z]+)|(?:([A-Z]*)(?=[A-Z]))',s))</p> <p>using regexp </p> <p>([A-Z][a-z]+)|(?:([A-Z]*)(?=[A-Z]))</p>
2
2010-02-16T14:59:17Z
[ "python", "regex", "string", "split", "uppercase" ]
Regex divide with upper-case
2,273,462
<p>I would like to replace strings like <code>'HDMWhoSomeThing'</code> to <code>'HDM Who Some Thing'</code> with regex.</p> <p>So I would like to extract words which starts with an upper-case letter or consist of upper-case letters only. Notice that in the string <code>'HDMWho'</code> the last upper-case letter is in ...
4
2010-02-16T14:14:06Z
2,273,807
<pre><code>#! /usr/bin/env python import re from collections import deque pattern = r'([A-Z]{2,}(?=[A-Z]|$)|[A-Z](?=[a-z]|$))' chunks = deque(re.split(pattern, 'HDMWhoSomeMONKEYThingXYZ')) result = [] while len(chunks): buf = chunks.popleft() if len(buf) == 0: continue if re.match(r'^[A-Z]$', buf) and len(...
2
2010-02-16T15:07:34Z
[ "python", "regex", "string", "split", "uppercase" ]
Overwrite auto_now for unittest
2,273,463
<p>I've defined some timestamps for events in the database as <code>auto_now_add</code>, as the information should be stored with it's timestamp the same time the event is stored.</p> <p>The description of the events is something like</p> <pre><code>class NewEvent(models.Model): ''' Individual event ''' ...
6
2010-02-16T14:14:32Z
2,273,968
<p>I've managed to create data overriding the default values using a fixture.</p> <p>I've created a <code>test_data.json</code> file with the data in the following format:</p> <pre><code>[ { "model": "stats_agg.newevent", "pk": 1, "fields": { "name": "event1", "quantity":0.0, "time...
3
2010-02-16T15:31:39Z
[ "python", "django", "unit-testing" ]
Overwrite auto_now for unittest
2,273,463
<p>I've defined some timestamps for events in the database as <code>auto_now_add</code>, as the information should be stored with it's timestamp the same time the event is stored.</p> <p>The description of the events is something like</p> <pre><code>class NewEvent(models.Model): ''' Individual event ''' ...
6
2010-02-16T14:14:32Z
16,908,692
<p>The problem with fixtures for me, is that I need to test that certain records that are older than 30 days are not returned, and ones that are not 30 days old are returned ... using static fixtures this cannot be done (in a lazy way). So what I chose to do is mock the timezone.now function which django uses to get th...
2
2013-06-04T02:02:44Z
[ "python", "django", "unit-testing" ]
Pythonic Way to reverse nested dictionaries
2,273,691
<p>I have a nested dictionary of people and item ratings, with people as the key. people may or may not share items. Example:</p> <pre><code>{ 'Bob' : {'item1':3, 'item2':8, 'item3':6}, 'Jim' : {'item1':6, 'item4':7}, 'Amy' : {'item1':6,'item2':5,'item3':9,'item4':2} } </code></pre> <p>I'm looking for the simplest...
7
2010-02-16T14:49:12Z
2,273,738
<p><a href="http://docs.python.org/library/collections.html#defaultdict-objects">collections.defaultdict</a> makes this pretty simple:</p> <pre><code>from collections import defaultdict import pprint data = { 'Bob' : {'item1':3, 'item2':8, 'item3':6}, 'Jim' : {'item1':6, 'item4':7}, 'Amy' : {'item1':6,'item2':5,'i...
16
2010-02-16T14:56:46Z
[ "python", "list-comprehension" ]
Pythonic Way to reverse nested dictionaries
2,273,691
<p>I have a nested dictionary of people and item ratings, with people as the key. people may or may not share items. Example:</p> <pre><code>{ 'Bob' : {'item1':3, 'item2':8, 'item3':6}, 'Jim' : {'item1':6, 'item4':7}, 'Amy' : {'item1':6,'item2':5,'item3':9,'item4':2} } </code></pre> <p>I'm looking for the simplest...
7
2010-02-16T14:49:12Z
2,275,062
<p>This is easy enough to do (as others have shown), but depending on your needs you should also consider that for data with several pieces of information where you want to extract by any criterion, a database might be the best tool. The built-in <code>sqlite3</code> module provides a low-overhead database that may, de...
1
2010-02-16T17:52:25Z
[ "python", "list-comprehension" ]
Pythonic Way to reverse nested dictionaries
2,273,691
<p>I have a nested dictionary of people and item ratings, with people as the key. people may or may not share items. Example:</p> <pre><code>{ 'Bob' : {'item1':3, 'item2':8, 'item3':6}, 'Jim' : {'item1':6, 'item4':7}, 'Amy' : {'item1':6,'item2':5,'item3':9,'item4':2} } </code></pre> <p>I'm looking for the simplest...
7
2010-02-16T14:49:12Z
2,276,028
<p>I totally agree that Ryan Ginstrom's answer is the preferred way of doing this (for all practical purposes). </p> <p>But since the question also explicitely asks:</p> <p><em><strong>Is it possible with a comprehension?</em></strong></p> <p>I thought I'd chime in with a quick example as for how to do this with a...
2
2010-02-16T20:19:30Z
[ "python", "list-comprehension" ]
Python: Visualisation of waves
2,273,699
<p>I want to programm an easy visualisation of wave propagation. I tried this with visual python (VPython) but the programm is very slow. I want to use a 2-D visualisation now. Which module could you recommend? Tkinter? Matplotlib?</p> <p>For the computation i use numpy/scipy because it is fast. Thanks in advance.</...
4
2010-02-16T14:50:04Z
2,273,803
<p>Try this library:<br> <a href="http://linux.wareseeker.com/Programming/summon-1.8.8.zip/2911b4d847" rel="nofollow">http://linux.wareseeker.com/Programming/summon-1.8.8.zip/2911b4d847</a></p> <p>Python Imaging Library is supposed to be good for 2D graphics:<br> <a href="http://www.pythonware.com/products/pil/" rel="...
1
2010-02-16T15:07:19Z
[ "python", "visualization", "physics", "wave" ]
pthread with callback to python VM
2,274,184
<p>Let's say I have a python script which loads a shared library (SL) through ctypes. </p> <ul> <li>The SL sets up a <code>pthread</code> T1</li> <li>The python script configures callbacks through the SL i.e. python script calls functions from the SL with references to python callables</li> </ul> <p><img src="http:/...
4
2010-02-16T15:59:56Z
2,274,345
<p>Polling the queue isn't normally necessary (you can devote another thread on the Python side to doing blocking <code>.get</code> calls on it), but that's not a big deal. Problem is, with such an arrangement, you might get caught by the <a href="http://en.wikipedia.org/wiki/Global_Interpreter_Lock" rel="nofollow">GI...
1
2010-02-16T16:18:12Z
[ "python", "linux", "multithreading", "ctypes", "pthreads" ]
pthread with callback to python VM
2,274,184
<p>Let's say I have a python script which loads a shared library (SL) through ctypes. </p> <ul> <li>The SL sets up a <code>pthread</code> T1</li> <li>The python script configures callbacks through the SL i.e. python script calls functions from the SL with references to python callables</li> </ul> <p><img src="http:/...
4
2010-02-16T15:59:56Z
31,642,053
<p>This can be easily implemented with Cython . I have written a sample at <a href="https://github.com/sachinpc/cython/tree/master/Demos/mt_callback" rel="nofollow">https://github.com/sachinpc/cython/tree/master/Demos/mt_callback</a></p> <p>The example shows how to wrap python callback in cython, when being called fr...
0
2015-07-26T21:16:06Z
[ "python", "linux", "multithreading", "ctypes", "pthreads" ]
problem with editing labels in wx list control
2,274,217
<p>hello <br> do you guys have any idea how to edit the the labels in the second column in a wx.ListCtrl here is the code that i used to create that list .. Note that the first column is the only editable one . how can i make the other one editable too?</p> <p><code> <br> self.lCUsers=wx.ListCtrl(self,style=wx.LC_EDI...
2
2010-02-16T16:03:19Z
2,413,105
<p>You can use the TextEditMixin</p> <pre><code>import wx from wx.lib.mixins.listctrl import TextEditMixin class EditableTextListCtrl(wx.ListCtrl, TextEditMixin): def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): wx.ListCtrl.__init__(self, parent, ID, po...
2
2010-03-09T22:33:16Z
[ "python", "wxpython", "wx" ]
Python: Can't use the command python
2,274,319
<p>I want to install summon-module on windows 7. I tried </p> <pre><code>python setup.py install </code></pre> <p>but cmd doesn't know the command "python".</p> <p>I also set the path correctly. What is the problem? Thanks in advance.</p>
0
2010-02-16T16:15:17Z
2,274,340
<p>on windows it is python.exe and you need the path to the executable added to your environment or to use the fully qualified path</p>
0
2010-02-16T16:17:36Z
[ "python", "windows", "installation" ]
Python: Can't use the command python
2,274,319
<p>I want to install summon-module on windows 7. I tried </p> <pre><code>python setup.py install </code></pre> <p>but cmd doesn't know the command "python".</p> <p>I also set the path correctly. What is the problem? Thanks in advance.</p>
0
2010-02-16T16:15:17Z
2,274,441
<p><code>PATH</code> needs to point to the directory your python.exe is in, or it needs to be in the current directory, or you need to specify the full path.</p> <p><code>PYTHONPATH</code> needs to point to the directory your setup.py is in, or it needs to be in the current directory, or you need to specify the full p...
4
2010-02-16T16:28:41Z
[ "python", "windows", "installation" ]
Python: Can't use the command python
2,274,319
<p>I want to install summon-module on windows 7. I tried </p> <pre><code>python setup.py install </code></pre> <p>but cmd doesn't know the command "python".</p> <p>I also set the path correctly. What is the problem? Thanks in advance.</p>
0
2010-02-16T16:15:17Z
2,274,734
<p>Add the directory with the python.exe to your path via Control Panel -> System -> Advanced -> Environment Variables. Then scroll through the System variables listed in the lower part of the screen, highlight "Path", and click edit. <strong>Add</strong> (don't replace!) the directory to that variable, probably at t...
3
2010-02-16T17:06:56Z
[ "python", "windows", "installation" ]
SocketServer.ThreadingTCPServer - Cannot bind to address after program restart
2,274,320
<p>As a follow-up to <a href="http://stackoverflow.com/questions/2270343/cannot-bind-to-address-after-socket-program-crashes">cannot-bind-to-address-after-socket-program-crashes</a>, I was receiving this error after my program was restarted:</p> <blockquote> <p>socket.error: [Errno 98] Address already in use</p> </b...
10
2010-02-16T16:15:23Z
2,274,334
<p>In this particular case, <code>.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)</code> may be called from the TCPServer class when the <code>allow_reuse_address</code> option is set. So I was able to solve it as follows:</p> <pre><code>httpd = SocketServer.ThreadingTCPServer(('localhost', port), CustomHandler, False) # Do ...
10
2010-02-16T16:17:02Z
[ "python", "linux", "sockets", "tcpserver" ]
SocketServer.ThreadingTCPServer - Cannot bind to address after program restart
2,274,320
<p>As a follow-up to <a href="http://stackoverflow.com/questions/2270343/cannot-bind-to-address-after-socket-program-crashes">cannot-bind-to-address-after-socket-program-crashes</a>, I was receiving this error after my program was restarted:</p> <blockquote> <p>socket.error: [Errno 98] Address already in use</p> </b...
10
2010-02-16T16:15:23Z
3,137,792
<p>The above solution didn't work for me but this one did:</p> <pre><code> SocketServer.ThreadingTCPServer.allow_reuse_address = True server = SocketServer.ThreadingTCPServer(("localhost", port), CustomHandler) server.serve_forever() </code></pre>
16
2010-06-29T04:09:00Z
[ "python", "linux", "sockets", "tcpserver" ]
Why User model inheritance doesn't work properly?
2,274,442
<p>I'm trying to use a <strong>User</strong> model inheritance in my django application. Model looks like this:</p> <pre><code>from django.contrib.auth.models import User, UserManager class MyUser(User): ICQ = models.CharField(max_length=9) objects = UserManager() </code></pre> <p>and authentication backend ...
0
2010-02-16T16:28:52Z
2,274,929
<p>Contrary to what the blog post you linked to says, storing this kind of data in a profile model is still the recommended way in Django. Subclassing <code>User</code> has all kinds of problems, one of which is the one you are hitting: Django has no idea you have subclassed <code>User</code> and happily creates and re...
4
2010-02-16T17:34:43Z
[ "python", "django", "inheritance", "django-models", "user" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
2,274,556
<p>Your iterator isn't reading 4 bytes at a time so I imagine it's rather confused. Like SilentGhost mentioned, it'd probably be best to use unpack_from().</p>
0
2010-02-16T16:45:45Z
[ "python" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
2,274,562
<p>I think "for rec in inh" is supposed to read 'lines', not bytes. What you want is:</p> <pre><code>while True: rec = inh.read(4) # Or inh.read(struct.calcsize('i')) if len(rec) != 4: break (pos,) = struct.unpack('i', rec) print pos </code></pre> <p>Or as others have mentioned:</p> <pre><cod...
4
2010-02-16T16:46:11Z
[ "python" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
2,274,575
<p><code>for rec in inh:</code> reads one <strong>line</strong> at a time -- not what you want for a <em>binary</em> file. Read 4 bytes at a time (with a <code>while</code> loop and <code>inh.read(4)</code>) instead (or read everything into memory with a single <code>.read()</code> call, then unpack successive 4-byte ...
7
2010-02-16T16:47:58Z
[ "python" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
2,274,605
<p>Check the size of the packed integers:</p> <pre><code>&gt;&gt;&gt; pos [7623, 3015, 3231, 3829] &gt;&gt;&gt; [struct.pack('i',e) for e in pos] ['\xc7\x1d\x00\x00', '\xc7\x0b\x00\x00', '\x9f\x0c\x00\x00', '\xf5\x0e\x00\x00'] </code></pre> <p>We see 4-byte strings, it means that reading should be 4 bytes at a time:<...
1
2010-02-16T16:51:03Z
[ "python" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
2,275,663
<p>You can probably use <code>array</code> as well if you want:</p> <pre><code>import array pos = array.array('i', [7623, 3015, 3231, 3829]) inh = open('test.bin', 'wb') pos.write(inh) inh.close() </code></pre> <p>Then use <code>array.array.fromfile</code> or <code>fromstring</code> to read it back.</p>
1
2010-02-16T19:23:44Z
[ "python" ]
Reading binary file in python
2,274,503
<p>I wrote a python script to create a binary file of integers. </p> <pre><code>import struct pos = [7623, 3015, 3231, 3829] inh = open('test.bin', 'wb') for e in pos: inh.write(struct.pack('i', e)) inh.close() </code></pre> <p>It worked well, then I tried to read the 'test.bin' file using the below cod...
2
2010-02-16T16:36:55Z
5,339,646
<p>This function reads all bytes from file</p> <pre><code>def read_binary_file(filename): try: f = open(filename, 'rb') n = os.path.getsize(filename) data = array.array('B') data.read(f, n) f.close() fsize = data.__len__() return (fsize, data) except IOError: return (-1, []) # somewhe...
1
2011-03-17T13:27:14Z
[ "python" ]
Where to put Python files to be redirected to by urls.py in Django?
2,275,016
<p>Where do I put python files to be redirected to by urls.py in Django? The tutorial showed something like this:</p> <blockquote> <p>urlpatterns = patterns('', (r'^polls/$', '<strong>mysite.polls.views.index</strong>'),</p> </blockquote> <p>Where do I set up pages to be easily linked as something.something.p...
2
2010-02-16T17:47:01Z
2,275,071
<p>You need to use views. You can create views (keep reading the official django documentation), then import them into your urls.py file and use them. Here's an example:</p> <h2>views.py</h2> <pre><code>from django.shortcuts import render_to_response def index(request): """ Main page. """ return render_t...
6
2010-02-16T17:53:45Z
[ "python", "django", "frameworks", "django-urls" ]
Why does django not do for the User model the same as it does for the userprofile model?
2,275,043
<p>Why doesn't django just have the model to use for User configured in the settings file?</p> <p>The requirements on the model specified would be that it contain a certain set of fields.</p> <p>Is there a reason why it couldn't be done this way?</p>
0
2010-02-16T17:50:30Z
2,275,208
<p><strong>"Why doesn't django just have the model to use for User configured in the settings file?"</strong></p> <p>I have a site that doesn't need users or a login or authentication. </p> <p>I don't want the model for User.</p> <p>In order to support everyone with applications like mine, User is optional.</p>
0
2010-02-16T18:14:50Z
[ "python", "django" ]
Why does django not do for the User model the same as it does for the userprofile model?
2,275,043
<p>Why doesn't django just have the model to use for User configured in the settings file?</p> <p>The requirements on the model specified would be that it contain a certain set of fields.</p> <p>Is there a reason why it couldn't be done this way?</p>
0
2010-02-16T17:50:30Z
2,275,652
<p>The User model has a lot of dependencies and must conform to a diverse set of API requirements in order to interoperate with the rest of the django framework. This is because of its relationship with authentication and authorization. Changing <code>User</code> means changing the expected behavior of <code>contrib....
2
2010-02-16T19:22:23Z
[ "python", "django" ]
python multi-processing queue: is putting independent from getting?
2,275,108
<p>Is <code>putting</code> an object in a <strong><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Queue" rel="nofollow">multi-processing queue</a></strong> independent from <code>getting</code> an object from it?</p> <p>In other words, will <code>putting</code> an object block the process ...
2
2010-02-16T18:01:27Z
2,275,221
<p>My reading of the source code is that <code>get</code> obtains a read lock, which is independent of of the lock (called <code>_notempty</code>) acquired by <code>put</code>. If I understand correctly, concurrent <code>get</code>s can block each other, and concurrent <code>put</code>s can block each other (modulo you...
1
2010-02-16T18:18:19Z
[ "python", "queue", "multiprocessing" ]
django-registration, fix for a glitch
2,275,155
<p>I am using django-registration version 0.8</p> <p>I use the default django-registration and Django auth system without any tweak. I did notice a small glitch, once I log in as a user, if I go to the /accounts/login/ , I still get the login entry form, how can I change that it redirect a logged in user to the main...
1
2010-02-16T18:08:02Z
2,277,295
<p>You can wrap Django's login view and do the check for already authenticated users there:</p> <pre><code>from django.contrib.auth.views import login from django.http import HttpResponseRedirect def mylogin(request, **kwargs): if request.user.is_authenticated(): return HttpResponseRedirect('/') else:...
1
2010-02-16T23:50:01Z
[ "python", "django" ]
Python: Animation with PIL
2,275,446
<p>I want an animated picture. But I need a refresh-function because plt.show() always opens a new window. Does anybody have a hint? Thanks!</p> <pre><code>import numpy as np import scipy from scipy import * import matplotlib.pyplot as plt #array aa = [] for x in range(44): aa.append([]) for z in range(44): ...
1
2010-02-16T18:51:21Z
2,275,546
<p>PIL is geared towards image editing, not animating or displaying. Instead, look to a GUI toolkit or a multimedia library like <a href="http://www.pyglet.org/" rel="nofollow">pyglet</a> or <a href="http://www.pygame.org/news.html" rel="nofollow">pygame</a></p>
4
2010-02-16T19:04:50Z
[ "python", "animation", "python-imaging-library" ]
Django generic relations practice
2,275,602
<p>i'm developing a authentication backend with object-based permissions for my django-app.I use generic relations between an object and a permission:</p> <pre><code>class GroupPermission(models.Model): content_t= models.ForeignKey(ContentType,related_name='g_content_t') object_id = models.PositiveIntegerField...
2
2010-02-16T19:13:24Z
2,276,112
<p>I'm guessing you're looking for something like:</p> <pre><code>perm = Permission.objects.get(pk=1) # pk #1 for brevity. group = Group.objects.get(pk=1) # Again, for brevity. group_perms = GroupPermission.objects.filter(permission=perm, group=group) objects = [x.content_object for x in group_perms] </code></pre>...
3
2010-02-16T20:32:09Z
[ "python", "django", "django-orm", "generic-relationship" ]
How to graphically edit the graph of a mathematical function (with python)?
2,275,845
<p>Is there already a python package allowing to graphically edit the graph of a function?</p>
2
2010-02-16T19:52:23Z
2,278,833
<p><a href="http://code.enthought.com/chaco/" rel="nofollow">Chaco</a> is designed to be very interactive, and is significantly more so than matplotlib. For example, the user can use the mouse to drag the legend to different places on a plot, or lasso data, or move a point around on one plot and change the results in ...
2
2010-02-17T06:48:17Z
[ "python", "user-interface", "math", "numpy" ]
Grouping related search keywords
2,275,901
<p>I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL.</p> <...
1
2010-02-16T20:01:23Z
2,275,962
<p>Not a concrete algorithm, but what you're looking for is basically an index created from words found in your text lines.</p> <p>So you'll need some sort of parser to recognize words, then you put them in an index structure and link each index entry to the line(s) where it is found. Then, by going over the index ent...
0
2010-02-16T20:09:43Z
[ "python", "algorithm", "postgresql", "data-structures" ]
Grouping related search keywords
2,275,901
<p>I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL.</p> <...
1
2010-02-16T20:01:23Z
2,275,981
<p>Well it seems that you just want to report every query that <em>contains</em> a given word. You can do this easily in plain SQL by using the wildcard matching feature, i.e.</p> <pre><code>SELECT * FROM QUERIES WHERE `querystring` LIKE '%dog%'. </code></pre> <p>The only problem with the query above is that it also ...
1
2010-02-16T20:13:18Z
[ "python", "algorithm", "postgresql", "data-structures" ]
Grouping related search keywords
2,275,901
<p>I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL.</p> <...
1
2010-02-16T20:01:23Z
2,276,100
<pre><code>f = open('data.txt', 'r') raw = f.readlines() #generate set of all possible groupings groups = set() for lines in raw: data = lines.strip().split() for items in data: groups.add(items) #parse input into groups for group in groups: print "Group \'%s\':" % group for line in raw: ...
2
2010-02-16T20:29:18Z
[ "python", "algorithm", "postgresql", "data-structures" ]
Grouping related search keywords
2,275,901
<p>I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL.</p> <...
1
2010-02-16T20:01:23Z
2,276,105
<p>Your algorithm needs the following parts (if done by yourself)</p> <ul> <li>a parser for the data, breaking up in lines, breaking up the lines in words.</li> <li>A datastructure to hold key value pairs (like a hashtable). The key is a word, the value is a dynamic array of lines (if you keep the lines you parsed in ...
0
2010-02-16T20:30:25Z
[ "python", "algorithm", "postgresql", "data-structures" ]
Grouping related search keywords
2,275,901
<p>I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL.</p> <...
1
2010-02-16T20:01:23Z
2,277,710
<p>Modified version of <a href="http://stackoverflow.com/questions/2275901/grouping-related-search-keywords/2276100#2276100">@swanson's answer</a> (not tested):</p> <pre><code>from collections import defaultdict from itertools import chain # generate set of all possible words lines = open('data.txt').readlines() wo...
0
2010-02-17T01:23:35Z
[ "python", "algorithm", "postgresql", "data-structures" ]
What's the advantage of queues over pipes when communicating between processes?
2,275,909
<p>What would be the advantage(s) (if any) of using 2 <strong><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Queue">Queues</a></strong> over a <strong><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Pipe">Pipe</a></strong> to communicate between processes?</p> ...
9
2010-02-16T20:03:18Z
2,275,936
<p>The big win is that queues are process- and thread- safe. Pipes are not: if two different processes try to read from or write to the same end of a pipe, bad things happen. Queues are also at a somewhat higher level of abstraction than pipes, which may or may not be an advantage in your specific case.</p>
11
2010-02-16T20:07:00Z
[ "python", "linux", "queue", "multiprocessing", "pipe" ]
What's the advantage of queues over pipes when communicating between processes?
2,275,909
<p>What would be the advantage(s) (if any) of using 2 <strong><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Queue">Queues</a></strong> over a <strong><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Pipe">Pipe</a></strong> to communicate between processes?</p> ...
9
2010-02-16T20:03:18Z
2,276,157
<p>Queues hold the messages and retains them until the next time the queue is active and pushes it through...regardless if the pipe or connection is broken...with a pipe/connection, its goodbye to the message with an error...</p> <p>Hope this helps, Best regards, Tom.</p>
4
2010-02-16T20:41:02Z
[ "python", "linux", "queue", "multiprocessing", "pipe" ]
POP3_SSL Not Found in poplib module
2,275,913
<p>What would cause this strange error when trying to use the poplib.POP3_SSL class.</p> <pre><code>Traceback (most recent call last): File "test.py", line 131, in &lt;module&gt; M = poplib.POP3_SSL('XXXXXXXX', 995) AttributeError: 'module' object has no attribute 'POP3_SSL' </code></pre> <p>My environment is P...
0
2010-02-16T20:04:25Z
2,275,928
<p>Your python might be compiled without ssl support.</p>
1
2010-02-16T20:05:50Z
[ "python", "ssl", "pop3" ]
How to change wx.Panel background color on MouseOver?
2,275,917
<p>this code:</p> <pre><code>import wx app = None class Plugin(wx.Panel): def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.SetBackgroundColour((11, 11, 11)) self.name = "plugin" self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver) ...
4
2010-02-16T20:04:55Z
2,275,975
<p>The method is named <code>SetBackgroundColour</code>, with a u.</p> <p>Also, you're binding events twice with two different methods. Just use the <code>self.Bind</code> style, and remove the other two lines.</p>
11
2010-02-16T20:12:22Z
[ "python", "wxpython", "panel", "wxwidgets" ]
How to get data in a histogram bin
2,275,924
<p>I want to get a list of the data contained in a histogram bin. I am using numpy, and Matplotlib. I know how to traverse the data and check the bin edges. However, I want to do this for a 2D histogram and the code to do this is rather ugly. Does numpy have any constructs to make this easier?</p> <p>For the 1D ca...
12
2010-02-16T20:05:45Z
2,276,726
<p>how about something like:</p> <pre><code>In [1]: data = numpy.array([0, 0.5, 1.5, 1.5, 1.5, 2.5, 2.5, 2.5, 3]) In [2]: hist, edges = numpy.histogram(data, bins=3) In [3]: for l, r in zip(edges[:-1], edges[1:]): print(data[(data &gt; l) &amp; (data &lt; r)]) ....: ....: [ 0.5] [ 1.5 1.5 1.5] [ ...
2
2010-02-16T22:08:35Z
[ "python", "numpy", "matplotlib", "histogram" ]
How to get data in a histogram bin
2,275,924
<p>I want to get a list of the data contained in a histogram bin. I am using numpy, and Matplotlib. I know how to traverse the data and check the bin edges. However, I want to do this for a 2D histogram and the code to do this is rather ugly. Does numpy have any constructs to make this easier?</p> <p>For the 1D ca...
12
2010-02-16T20:05:45Z
2,276,968
<p><a href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.hist" rel="nofollow">pyplot.hist</a> in matplotlib creates a histogram (but also draws it to the screen, which you might not want). For just the bins, you can use numpy.histogram, as outlined in another answer.</p> <p><a href="http://w...
0
2010-02-16T22:42:53Z
[ "python", "numpy", "matplotlib", "histogram" ]
How to get data in a histogram bin
2,275,924
<p>I want to get a list of the data contained in a histogram bin. I am using numpy, and Matplotlib. I know how to traverse the data and check the bin edges. However, I want to do this for a 2D histogram and the code to do this is rather ugly. Does numpy have any constructs to make this easier?</p> <p>For the 1D ca...
12
2010-02-16T20:05:45Z
2,277,669
<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.digitize.html#numpy.digitize" rel="nofollow"><code>digitize</code></a>, from core NumPy, will give you the <em>index</em> of the bin to which each value in your histogram belongs:</p> <pre><code>import numpy as NP A = NP.random.randint(0, 10, 100) ...
19
2010-02-17T01:12:32Z
[ "python", "numpy", "matplotlib", "histogram" ]
Using multilingual and localeurl in django
2,275,966
<p>Using django-multilingual and localeurl.</p> <p>Small sample of my main page view:</p> <pre><code>def main(request): #View for http://www.mysite.com/ name = Dog.objects.all()[0].full_name #this is a translated field return render_to_response("home.html", {"name" : name}) </code></pre> <p>Entering <a href=...
1
2010-02-16T20:10:45Z
2,322,292
<p>I have the same problem, after rotation with positions in MIDDLEWARE_CLASSES I've got the right order:</p> <pre><code>MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.sessions.middleware.SessionMidd...
3
2010-02-23T22:38:36Z
[ "python", "django", "django-multilingual" ]
Using multilingual and localeurl in django
2,275,966
<p>Using django-multilingual and localeurl.</p> <p>Small sample of my main page view:</p> <pre><code>def main(request): #View for http://www.mysite.com/ name = Dog.objects.all()[0].full_name #this is a translated field return render_to_response("home.html", {"name" : name}) </code></pre> <p>Entering <a href=...
1
2010-02-16T20:10:45Z
2,666,943
<p>after removing django.middleware.locale.LocaleMiddleware it worked for me also ...</p>
1
2010-04-19T11:26:18Z
[ "python", "django", "django-multilingual" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,018
<p><a href="http://www.wsgi.org/wsgi/">WSGI</a> is the Python standard for web server interfaces. If you want to create your own framework or operate without a framework, you should look into that. Specifically I have found <a href="http://pythonpaste.org/do-it-yourself-framework.html">Ian Bicking's DIY Framework</a>...
19
2010-02-16T20:17:54Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,026
<p>You will have to look into something like CGI or <a href="http://cleverdevil.org/computing/24/python-fastcgi-wsgi-and-lighttpd" rel="nofollow">FastCGI</a>, which provides an API to communicate to the webserver.</p> <p><a href="http://code.google.com/intl/nl-NL/appengine/" rel="nofollow">Google App Engine</a> enable...
2
2010-02-16T20:19:14Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,041
<p>One of the lightest-weight frameworks is <code>mod_wsgi</code>. Anything less is going to be a huge amount of work parsing HTTP requests to find headers and URI's and methods and parsing the GET or POST query/data association, handling file uploads, cookies, etc.</p> <p>As it is, mod_wsgi will only handle the basi...
3
2010-02-16T20:20:37Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,052
<p>For a PHP programmer, I think <a href="http://www.modpython.org/" rel="nofollow">mod_python</a> is a good way to get started without any framework. It can be used directly as Apache 2 module. You can have code tags (like <code>&lt;? ?&gt;</code> in PHP) and even conditional HTML output (HTML inside if statement):</p...
0
2010-02-16T20:22:10Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,065
<p>You should try web.py, it provides a bare minimum of features that does not get in your way.</p> <p><a href="http://webpy.org/" rel="nofollow">http://webpy.org/</a></p>
1
2010-02-16T20:23:56Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,276,845
<p>The answer is "don't". Using a framework makes your code more maintainable, scalable, readable, testable, and modular.</p>
-3
2010-02-16T22:24:22Z
[ "python" ]
Program web applications in python without a framework?
2,276,000
<p>I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework.</p>
14
2010-02-16T20:15:09Z
2,281,911
<p>People here love frameworks. One shortcoming I have noted is that Python lacks a handy-dandy module for Sessions as a library built-in, despite it being available in PHP and as CGI::Session in Perl.</p> <p>You will end up doing:</p> <pre><code>import cgi # if you want to work with forms and such import cgitb; cg...
1
2010-02-17T15:27:25Z
[ "python" ]
Python multiprocessing process vs. standalone Python VM
2,276,117
<p>Aside from the ease of use of the <code>multiprocessing</code> module when it comes to hooking up processes with communication resources, are there any other differences between spawning multiple processes using <code>multiprocessing</code> compared to using <code>subprocess</code> to launch separate Python VMs ?</p...
9
2010-02-16T20:33:23Z
2,276,333
<p>If you ignore any communication issues (i.e., if the separate Python VMs do not communicate among themselves, or communicate only through other mechanisms that are explicitly established), there are no other substantial differences. (I believe <code>multiprocessing</code>, under certain conditions -- Unix-like plat...
3
2010-02-16T21:05:41Z
[ "python", "multiprocessing", "virtual-machine" ]
Python multiprocessing process vs. standalone Python VM
2,276,117
<p>Aside from the ease of use of the <code>multiprocessing</code> module when it comes to hooking up processes with communication resources, are there any other differences between spawning multiple processes using <code>multiprocessing</code> compared to using <code>subprocess</code> to launch separate Python VMs ?</p...
9
2010-02-16T20:33:23Z
2,276,366
<p>On Posix platforms, <code>multiprocessing</code> primitives essentially wrap an <code>os.fork()</code>. What this means is that at point you spawn a process in multiprocessing, the code already imported/initialized remains so in the child process.</p> <p>This can be a boon if you have a lot of things to initialize ...
9
2010-02-16T21:10:28Z
[ "python", "multiprocessing", "virtual-machine" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
2,276,251
<p>Starting with <a href="http://en.wikipedia.org/wiki/PyDev" rel="nofollow">PyDev</a> 3.4.1, the default encoding is not being changed anymore. See <a href="https://sw-brainwy.rhcloud.com/tracker/PyDev/315" rel="nofollow">this ticket</a> for details.</p> <p>For earlier versions a solution is to make sure PyDev does ...
14
2010-02-16T20:52:49Z
[ "python", "encoding", "utf-8", "console" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
7,892,892
<p><strong>A) To control <code>sys.getdefaultencoding()</code> output:</strong></p> <pre><code>python -c 'import sys; print(sys.getdefaultencoding())' </code></pre> <p><code>ascii</code></p> <p>Then</p> <pre><code>echo "import sys; sys.setdefaultencoding('utf-16-be')" &gt; sitecustomize.py </code></pre> <p>and </p...
35
2011-10-25T16:55:23Z
[ "python", "encoding", "utf-8", "console" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
17,628,350
<p>Here is a simpler method (hack) that gives you back the <code>setdefaultencoding()</code> function that was deleted from <code>sys</code>:</p> <pre><code>import sys # sys.setdefaultencoding() does not exist, here! reload(sys) # Reload does the trick! sys.setdefaultencoding('UTF8') </code></pre> <p><strong>PS</str...
82
2013-07-13T08:18:16Z
[ "python", "encoding", "utf-8", "console" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
27,066,059
<p>If you get this error when you try to pipe/redirect output of your script</p> <p><code>UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)</code></p> <p>Just export PYTHONIOENCODING in console and then run your code.</p> <p><strong><code>export PYTHONIOENCODING=utf...
18
2014-11-21T16:33:51Z
[ "python", "encoding", "utf-8", "console" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
30,885,015
<p>There is an insightful blog post about it.</p> <p>See <a href="https://anonbadger.wordpress.com/2015/06/16/why-sys-setdefaultencoding-will-break-code/">https://anonbadger.wordpress.com/2015/06/16/why-sys-setdefaultencoding-will-break-code/</a>.</p> <p>I paraphrase its content below.</p> <p>In python 2 which was n...
5
2015-06-17T07:30:07Z
[ "python", "encoding", "utf-8", "console" ]
Changing default encoding of Python?
2,276,200
<p>I have many "can't encode" and "can't decode" problems with <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> when I run my applications from the console. But in the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse</a> <a href="http://en.wikipedia.org/wiki/PyDev...
77
2010-02-16T20:46:28Z
39,532,664
<p>Regarding python2 (and python2 only), some of the former answers rely on using the following hack:</p> <pre><code>import sys reload(sys) # Reload is a hack sys.setdefaultencoding('UTF8') </code></pre> <p>It is discouraged to use it (check <a href="https://anonbadger.wordpress.com/2015/06/16/why-sys-setdefaultenco...
1
2016-09-16T13:25:47Z
[ "python", "encoding", "utf-8", "console" ]
GIS: When and why to use ArcObjects over GDAL programming to work with ArcGIS rasters and vectors?
2,276,235
<p>Im just starting off with GDAL + python to support operations that cannot be done with ArcGIS python geoprocessing scripting. Mainly I am doing spatial modeling/analysis/editing of raster and vector data.</p> <p>I am a bit confused when ArcObject development is required versus when GDAL can be used? Is there functi...
3
2010-02-16T20:50:30Z
2,276,822
<p>GDAL is included in ArcGIS to work with some raster data formats. They do not use the GDAL utilities to do any geoprocessing. I would imagine ESRI have implemented most, if not all, of the functionality in GDAL with their own geoprocessing functions. In summary there is a big overlap in functionality between the two...
5
2010-02-16T22:21:45Z
[ "python", "gis", "arcgis", "gdal" ]
GIS: When and why to use ArcObjects over GDAL programming to work with ArcGIS rasters and vectors?
2,276,235
<p>Im just starting off with GDAL + python to support operations that cannot be done with ArcGIS python geoprocessing scripting. Mainly I am doing spatial modeling/analysis/editing of raster and vector data.</p> <p>I am a bit confused when ArcObject development is required versus when GDAL can be used? Is there functi...
3
2010-02-16T20:50:30Z
2,294,445
<p>ArcObjects and geoprocessing add a lot more functionality than GDAL and is mostly aimed at the desktop. Another option for looking at Python is also using QGIS which has a python API, is Free and Open Source, and an active developer community. </p> <p>There are also plenty of python libraries for doing spatial work...
1
2010-02-19T06:16:05Z
[ "python", "gis", "arcgis", "gdal" ]