title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Python recursive folder read
2,212,643
<p>I have a C++/Obj-C background and I am just discovering Python (been writing it for about an hour). I am writing a script to recursively read the contents of text files in a folder structure.</p> <p>The problem I have is the code I have written will only work for one folder deep. I can see why in the code (see <cod...
80
2010-02-06T09:24:39Z
7,161,703
<p><code>os.walk</code> does recursive walk by default. For each dir, starting from root it yields a 3-tuple (dirpath, dirnames, filenames)</p> <pre class="lang-py prettyprint-override"><code>from os import walk from os.path import splitext, join def select_files(root, files): """ simple logic here to filter ...
-1
2011-08-23T13:24:12Z
[ "python", "scripting", "file-io" ]
Python recursive folder read
2,212,643
<p>I have a C++/Obj-C background and I am just discovering Python (been writing it for about an hour). I am writing a script to recursively read the contents of text files in a folder structure.</p> <p>The problem I have is the code I have written will only work for one folder deep. I can see why in the code (see <cod...
80
2010-02-06T09:24:39Z
32,897,154
<p>Simple and fast solution:</p> <pre><code>import os import sys walk_dir = "/var/www/html/mrskin/Britney Spears" for root, subdirs, files in os.walk(walk_dir): print root </code></pre>
2
2015-10-01T21:27:04Z
[ "python", "scripting", "file-io" ]
virtualbox and python API
2,212,706
<p>0 vote down</p> <p>I have installed virtualbox . but i cant import the module xpcom. but the synaptic package shows that it is installed. what could be wrong?</p> <p>-ASK</p>
1
2010-02-06T09:50:56Z
2,212,712
<p>To be able to import xpcom, you would need to install <a href="https://developer.mozilla.org/en/PyXPCOM" rel="nofollow">pyxpcom</a> extension, and build instructions are <a href="https://developer.mozilla.org/en/Building_PyXPCOM" rel="nofollow">here</a>.</p> <p>In Synaptic Package Manager, it would be <a href="http...
1
2010-02-06T09:53:19Z
[ "python", "xpcom" ]
Python: Why is IDLE so slow?
2,212,722
<p><a href="http://en.wikipedia.org/wiki/IDLE_%28Python%29">IDLE</a> is my favorite Python editor. It offers very nice and intuitive Python shell which is extremely useful for unit-testing and debugging, and a neat debugger.</p> <p><strong>However, code executed under IDLE is insanely slow. By insanely I mean <em>3 or...
16
2010-02-06T09:58:20Z
2,212,812
<p>The problem is the text output not the debugger.</p> <p>I just tried it on my Q6600 (3GHz overclocked) System and my numbers are even worse. But its easy to see that they are going down the more output text is added.</p> <p>I tried to run it with </p> <p>1000 iterations => 7,8 sec 2000 iterations => 28,5 sec 3000...
27
2010-02-06T10:33:07Z
[ "python", "performance", "python-idle" ]
Python: Why is IDLE so slow?
2,212,722
<p><a href="http://en.wikipedia.org/wiki/IDLE_%28Python%29">IDLE</a> is my favorite Python editor. It offers very nice and intuitive Python shell which is extremely useful for unit-testing and debugging, and a neat debugger.</p> <p><strong>However, code executed under IDLE is insanely slow. By insanely I mean <em>3 or...
16
2010-02-06T09:58:20Z
2,213,321
<p>The problem is in the Tkinter Text widget, and its inefficient management of very long lines, and you create one. You'll notice that, while any part of a very long line is visible, all scrolling is devilishly slow.</p>
8
2010-02-06T13:59:13Z
[ "python", "performance", "python-idle" ]
Python IRC Client
2,212,727
<p>When I run the script:</p> <pre><code>import socket from time import strftime time = strftime("%H:%M:%S") irc = 'irc.tormented-box.net' port = 6667 channel = '#tormented' sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((irc, port)) print sck.recv(4096) sck.send('NICK supaBOT\r\n') sck.send('US...
0
2010-02-06T09:59:45Z
2,212,743
<p>This means that <code>message</code> has no spaces in it, so when it's split by a space, you get a list containing a single element - you are trying to access the second element of this list. You should insert a check for this case.</p> <p><strong>EDIT:</strong> In reply to your comment: how you add the check depen...
3
2010-02-06T10:04:22Z
[ "python" ]
Python IRC Client
2,212,727
<p>When I run the script:</p> <pre><code>import socket from time import strftime time = strftime("%H:%M:%S") irc = 'irc.tormented-box.net' port = 6667 channel = '#tormented' sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sck.connect((irc, port)) print sck.recv(4096) sck.send('NICK supaBOT\r\n') sck.send('US...
0
2010-02-06T09:59:45Z
2,212,794
<p>Try </p> <pre><code>get = message.split(" ",1)[-1] </code></pre> <p>Example</p> <pre><code>&gt;&gt;&gt; "abcd".split(" ",1)[-1] 'abcd' &gt;&gt;&gt; "abcd efgh".split(" ",1)[-1] 'efgh' </code></pre>
0
2010-02-06T10:24:47Z
[ "python" ]
pyparsing question
2,212,860
<p>This code works:</p> <pre><code>from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234", "! sfs" ] for t in tests: try: results = query.parseString( t ) pri...
0
2010-02-06T10:59:07Z
2,212,906
<p>You could use zipcode and foo separately, so that you know which one the string matches.</p> <pre><code>zipresults = zipcode.parseString( t ) fooresults = foo.parseString( t ) </code></pre>
3
2010-02-06T11:20:05Z
[ "python", "parsing", "text-parsing", "pyparsing" ]
pyparsing question
2,212,860
<p>This code works:</p> <pre><code>from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234", "! sfs" ] for t in tests: try: results = query.parseString( t ) pri...
0
2010-02-06T10:59:07Z
2,212,979
<p>I do not have the <code>pyparsing</code> module, but <code>Regex</code> must be a class, not a function.</p> <p>What you can do is subclass from it and override methods as required to customize behaviour, then use your subclasses instead.</p>
2
2010-02-06T11:51:31Z
[ "python", "parsing", "text-parsing", "pyparsing" ]
pyparsing question
2,212,860
<p>This code works:</p> <pre><code>from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234", "! sfs" ] for t in tests: try: results = query.parseString( t ) pri...
0
2010-02-06T10:59:07Z
2,213,805
<p>Your second question is easy, so I'll answer that first. Change query to assign results names to the different expressions:</p> <pre><code>query = ( zipcode("zip") | foo("foo") ) </code></pre> <p>Now you can call getName() on the returned result:</p> <pre><code>print t,"-&gt;", results, results.getName() </code...
2
2010-02-06T16:41:10Z
[ "python", "parsing", "text-parsing", "pyparsing" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,212,947
<p>Python has a standard library module to read csv files:</p> <pre><code>import csv reader = csv.reader(open('file.csv')) for line in reader: print line </code></pre> <p>For your example input this prints</p> <pre><code>['data1', ' data2 ', "data3'''", ' \'data4""\'', '', '', 'data5', ''] </code></pre> <p>ED...
4
2010-02-06T11:42:31Z
[ "python", "regex", "csv" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,213,008
<p>While the <code>csv</code> module is the right answer here, a regex that could do this is quite doable:</p> <pre><code>import re r = re.compile(r''' \s* # Any whitespace. ( # Start capturing here. [^,"']+? # Either a series of non-comma non-quote characters. ...
6
2010-02-06T12:04:22Z
[ "python", "regex", "csv" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,213,285
<p>Although it would likely be possible with some combination of pre-processing, use of <code>csv</code> module, post-processing, and use of regular expressions, your stated requirements do not fit well with the design of the <code>csv</code> module, nor possibly with regular expressions (depending on the complexity of...
5
2010-02-06T13:44:41Z
[ "python", "regex", "csv" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,213,989
<p>This probably sounds too simple, but really from the looks of things you are looking for a string that contains either [a-zA-Z0-9]["']+[a-zA-Z0-9], I mean without in depth testing against the data really what you're looking for is a quote or double quote (or any combination) in between letters (you could also add nu...
0
2010-02-06T17:40:28Z
[ "python", "regex", "csv" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,216,335
<p><strong>It is not possible to give you an answer, because you have not completely specified the protocol that is being used by the writer.</strong></p> <p>It evidently contains rules like:</p> <p>If a field contains any commas or single quotes, quote it with double quotes.<br> Else if the field contains any double...
2
2010-02-07T07:54:06Z
[ "python", "regex", "csv" ]
Python regex for reading CSV-like rows
2,212,933
<p>I want to parse incoming CSV-like rows of data. Values are separated with commas (and there could be leading and trailing whitespaces around commas), and can be quoted either with ' or with ". For example - this is a valid row:</p> <pre><code> data1, data2 ,"data3'''", 'data4""',,,data5, </code></pre> <p>but ...
9
2010-02-06T11:34:43Z
2,217,424
<p>If your goal is to convert the data to XML (or JSON, or YAML), look at <a href="http://github.com/knipknap/Gelatin/tree/master/syntax/csv/syntax.gel" rel="nofollow">this example</a> for a <a href="http://wiki.github.com/knipknap/Gelatin/" rel="nofollow">Gelatin</a> syntax that produces the following output:</p> <pr...
0
2010-02-07T16:52:38Z
[ "python", "regex", "csv" ]
How to create a scrollable screen in text mode with Python
2,213,060
<p>I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this?</p> <p>For example:</p> <pre><code>&gt;&gt;&gt; def jhelp(object): &gt;&gt;&gt; text = # get text for object &gt;&gt;&...
4
2010-02-06T12:29:10Z
2,213,117
<p>look at <code>pydoc</code> module in the standard library</p>
0
2010-02-06T12:45:45Z
[ "python", "text" ]
How to create a scrollable screen in text mode with Python
2,213,060
<p>I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this?</p> <p>For example:</p> <pre><code>&gt;&gt;&gt; def jhelp(object): &gt;&gt;&gt; text = # get text for object &gt;&gt;&...
4
2010-02-06T12:29:10Z
2,213,183
<pre><code>from pydoc import ttypager def jhelp(object): text = # get text for object ttypager(text) # display a scrollable screen. </code></pre>
2
2010-02-06T13:09:29Z
[ "python", "text" ]
How to create a scrollable screen in text mode with Python
2,213,060
<p>I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this?</p> <p>For example:</p> <pre><code>&gt;&gt;&gt; def jhelp(object): &gt;&gt;&gt; text = # get text for object &gt;&gt;&...
4
2010-02-06T12:29:10Z
29,500,999
<p>I think what you really want is <code>from pydoc import pager</code>. <code>ttypager</code> is a very reduced pager, but <code>pager</code> will automatically use a better pager (basically <code>less</code>) if it is available. </p>
0
2015-04-07T20:45:50Z
[ "python", "text" ]
What is a nicer alternative to a namedtuples _replace?
2,213,102
<p>Take this code:</p> <pre><code>&gt;&gt;&gt; import urlparse &gt;&gt;&gt; parts = urlparse.urlparse('http://docs.python.org/library/') &gt;&gt;&gt; parts = parts._replace(path='/3.0'+parts.path) </code></pre> <p><code>parts._replace works</code> but as it is an underscored method, it's supposed to be internal, and ...
5
2010-02-06T12:40:47Z
2,213,108
<p>The reason methods of <code>namedtuple</code> start with an initial underscore is only to prevent name collisions. They <a href="http://docs.python.org/library/collections.html#collections.namedtuple">should not be considered to be for internal use only</a>:</p> <blockquote> <p>To prevent conflicts with field nam...
16
2010-02-06T12:43:21Z
[ "python", "namedtuple" ]
Reading request parameters in Python
2,213,191
<p>I am very new to python and having to get into this stuff for a simple program to integrate with an ASP.NET application that I am building. The pseudo code is as follows.</p> <ol> <li>Get two parameters from request. (A ASP.NET will be calling this url by POST and sending two parameters)</li> <li>Internally execute...
2
2010-02-06T13:14:00Z
2,213,254
<p><a href="http://onlamp.com/pub/a/python/2004/02/26/python_server_pages.html">Here</a> is a good beginner's tutorial for mod_python.</p> <p>As far as I understand your question you have a mod_python-based script and you want to read a POST parameter. Therefore you only have to use the <code>form</code> object which ...
5
2010-02-06T13:35:18Z
[ "python", "parameters", "request", "mod-python" ]
Reading request parameters in Python
2,213,191
<p>I am very new to python and having to get into this stuff for a simple program to integrate with an ASP.NET application that I am building. The pseudo code is as follows.</p> <ol> <li>Get two parameters from request. (A ASP.NET will be calling this url by POST and sending two parameters)</li> <li>Internally execute...
2
2010-02-06T13:14:00Z
2,213,679
<p>"I know it should be very simple and know how to do it in Java/.NET/PHP and RoR but not in Python"</p> <p>Well, it's not simple in Python -- the language.</p> <p>It is simple in many Python web frameworks.</p> <p>Don't make the mistake of comparing Python (the language) with PHP (the web framework) or RoR (the w...
0
2010-02-06T15:55:54Z
[ "python", "parameters", "request", "mod-python" ]
Access a subset of functions of a Python class
2,213,289
<p>Using a class that has an xmlrpc proxy as one of it's object's properties</p> <pre><code>def __init__(self): self.proxy = ServerProxy(...) # ... </code></pre> <p>I'm trying to ease the use of some of the proxy's functions. Only a subset of the proxy functions are supposed to be used and I thus thought of c...
3
2010-02-06T13:46:36Z
2,213,501
<p>I'm not 100% sure if this is what you want, but it works:</p> <pre><code>def proxy_wrapper(name, docstring): def wrapper(self, *args, **kwargs): return self.proxy.__getattribute__(name)(*args, **kwargs) wrapper.__doc__ = docstring wrapper._is_wrapper = True return wrapper class Something(ob...
3
2010-02-06T14:56:44Z
[ "python", "xml-rpc" ]
Access a subset of functions of a Python class
2,213,289
<p>Using a class that has an xmlrpc proxy as one of it's object's properties</p> <pre><code>def __init__(self): self.proxy = ServerProxy(...) # ... </code></pre> <p>I'm trying to ease the use of some of the proxy's functions. Only a subset of the proxy functions are supposed to be used and I thus thought of c...
3
2010-02-06T13:46:36Z
2,213,525
<p>Use xml-rpc introspection to get the server list and intersect it with your object's properties. Something like:</p> <pre><code>loc = dir(self) rem = proxy.listMethods() # However introspection gets a method list wrapped = [x for x in rem if x in loc] </code></pre>
2
2010-02-06T15:06:26Z
[ "python", "xml-rpc" ]
Why can't I do a hyphen in Django template view?
2,213,308
<pre><code>{{profile.first-name.value}} </code></pre> <p>My variable is hypeh only...I wish I could do <strong>first_name</strong>, but many variables are hyphens. However, due to this problem, I can't display my variables in the template. Why?</p>
3
2010-02-06T13:53:22Z
2,213,330
<p>The hyphen is an operator in Python. It would work better if you swapped all hyphens for underscores.</p>
7
2010-02-06T14:03:19Z
[ "python", "django", "templates" ]
Django model class methods for predefined values
2,213,309
<p>I'm working on some Django-code that has a model like this: </p> <pre><code>class Status(models.Model): code = models.IntegerField() text = models.CharField(maxlength=255) </code></pre> <p>There are about 10 pre-defined code/text-pairs that are stored in the database. Scattered around the codebase I see c...
12
2010-02-06T13:53:34Z
2,213,341
<p>You should perhaps implement this by defining a custom manager for your class, and adding two manager methods on that manager (which I believe is the preferred way for adding table-level functionality for any model). However, another way of doing it is by throwing in two <a href="http://docs.python.org/library/funct...
26
2010-02-06T14:09:12Z
[ "python", "django", "django-models" ]
Hooking str.__getitem__ in Python
2,213,325
<p>Is there a way of hooking str.__getitem__?</p> <p>Example:</p> <p>I'd like to be capable of do:</p> <pre><code>&gt;&gt;&gt; "this is a string"[[1,3,4]] 'hs ' </code></pre> <p>passing a list to [] and get the items in that list.</p> <p><strong>A more realistic example:</strong></p> <pre><code>class STR(str): ...
2
2010-02-06T14:01:01Z
2,213,338
<p>Why hook an often-used internal function when you can </p> <pre><code>def get_characters (s, l): return "".join(s[i] for i in l) &gt;&gt;&gt; get_characters("this is a string", [1,3,4]) "hs " </code></pre>
3
2010-02-06T14:06:11Z
[ "python" ]
Hooking str.__getitem__ in Python
2,213,325
<p>Is there a way of hooking str.__getitem__?</p> <p>Example:</p> <p>I'd like to be capable of do:</p> <pre><code>&gt;&gt;&gt; "this is a string"[[1,3,4]] 'hs ' </code></pre> <p>passing a list to [] and get the items in that list.</p> <p><strong>A more realistic example:</strong></p> <pre><code>class STR(str): ...
2
2010-02-06T14:01:01Z
2,213,344
<p>Methods on objects defined in C cannot be monkeypatched. The best you can do is to use an external function to complete the task.</p>
2
2010-02-06T14:09:52Z
[ "python" ]
Why str has no __radd__ method in Python?
2,213,329
<p>str has other methods like __rmod__, __rsub__ or __rmul__</p> <p>int did have a __radd__ method</p> <p>Weird, and I'd like to know why.</p> <p>Example radd beeing called when first term HAS add method:</p> <pre><code>&gt;&gt;&gt; class STR(str): ... def __radd__(self, other): ... print "jeje" ......
3
2010-02-06T14:02:40Z
2,213,422
<p><code>__radd__</code> is used when the first term of the addition does not implement <code>__add__</code>. In the case of <code>int</code>, addition is well defined by its mathematical definition, and so int tries to coerce the other term into a number. </p> <p>with <code>str</code>, there is no such well defined...
5
2010-02-06T14:34:56Z
[ "python", "implementation" ]
Why str has no __radd__ method in Python?
2,213,329
<p>str has other methods like __rmod__, __rsub__ or __rmul__</p> <p>int did have a __radd__ method</p> <p>Weird, and I'd like to know why.</p> <p>Example radd beeing called when first term HAS add method:</p> <pre><code>&gt;&gt;&gt; class STR(str): ... def __radd__(self, other): ... print "jeje" ......
3
2010-02-06T14:02:40Z
2,213,439
<p>Types only define methods that they use. Since the only objects that can be added to strings are other strings or unicode objects, there is no need for a general <code>__radd__</code> method. <code>__rmul__</code> allows you to duplicate strings:</p> <pre><code>&gt;&gt;&gt; 4 * 'abc' 'abcabcabcabc' </code></pre>...
1
2010-02-06T14:39:56Z
[ "python", "implementation" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,349
<p>Keys cannot be changed. You will need to add a new key with the modified value then remove the old one, or create a new dict with a dict comprehension or the like.</p>
28
2010-02-06T14:11:13Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,368
<p>For example like this:</p> <pre><code>def appendabc(somedict): return dict(map(lambda (key, value): (str(key)+"abc", value), somedict.items())) def transform(multilevelDict): new = appendabc(multilevelDict) for key, value in new.items(): if isinstance(value, dict): new[key] = trans...
12
2010-02-06T14:17:38Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,378
<pre><code>&gt;&gt;&gt; mydict={'fruit':'orange','colors':{'dark':4,'light':5}} &gt;&gt;&gt; def f(mydict): ... return dict((k+"abc",f(v) if hasattr(v,'keys') else v) for k,v in mydict.items()) ... &gt;&gt;&gt; f(mydict) {'fruitabc': 'orange', 'colorsabc': {'darkabc': 4, 'lightabc': 5}} </code></pre>
7
2010-02-06T14:19:43Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,388
<pre><code>#! /usr/bin/env python d = {'fruit':'orange', 'colors':{'dark':4,'light':5}} def add_abc(d): newd = dict() for k,v in d.iteritems(): if isinstance(v, dict): v = add_abc(v) newd[k + "abc"] = v return newd d = add_abc(d) print d </code></pre>
2
2010-02-06T14:22:13Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,389
<p>You could do this with recursion:</p> <pre><code>import collections in_dict={'fruit':'orange','colors':{'dark':4,'light':5}} def transform_dict(d): out_dict={} for k,v in d.iteritems(): k=k+'abc' if isinstance(v,collections.MutableMapping): v=transform_dict(v) ...
0
2010-02-06T14:22:28Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,213,394
<p>Something like that</p> <pre><code>def applytoallkeys( dic, func ): def yielder(): for k,v in dic.iteritems(): if isinstance( v, dict): yield func(k), applytoallkeys( v, func ) else: yield func(k), v return dict(yielder()) def appendword( s ):...
1
2010-02-06T14:25:12Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
2,215,887
<p>My understanding is that you can't change the keys, and that you would need to make a new set of keys and assign their values to the ones the original keys were pointing to.</p> <p>I'd do something like:</p> <pre><code>def change_keys(d): if type(d) is dict: return dict([(k+'abc', change_keys(v)) for k, v in...
6
2010-02-07T04:11:08Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
7,666,742
<p>you should also consider that there is the possibility of nested dicts in nested lists, which will not be covered by the above solutions. This function ads a prefix and/or a postfix to every key within the dict.</p> <pre><code>def transformDict(multilevelDict, prefix="", postfix=""): """adds a prefix and/or postfix...
0
2011-10-05T19:38:16Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
8,284,946
<p>I use the following utility function that I wrote that takes a target dict and another dict containing the translation and switches all the keys according to it:</p> <pre><code>def rename_keys(d, keys): return dict([(keys.get(k), v) for k, v in d.items()]) </code></pre> <p>So with the initial data:</p> <pre><...
3
2011-11-27T10:33:53Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
17,887,576
<pre><code>for k in theDict: theDict[k+'abc']=theDict.pop(k) </code></pre>
0
2013-07-26T17:36:16Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
19,386,325
<p>I use this for converting docopt POSIX-compliant command-line keys to PEP8 keys</p> <p>(e.g. "--option" --> "option", "" --> "option2", "FILENAME" --> "filename")</p> <hr> <pre><code>arguments = docopt.docopt(__doc__) # dictionary for key in arguments.keys(): if re.match('.*[-&lt;&gt;].*', key) or key != key...
0
2013-10-15T16:29:55Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
24,235,612
<p>here's a tight little function:</p> <pre><code>def keys_swap(orig_key, new_key, d): d[new_key] = d.pop(orig_key) </code></pre> <p>for your particular problem:</p> <pre><code>def append_to_dict_keys(appendage, d): #note that you need to iterate through the fixed list of keys, because #otherwise we will...
1
2014-06-16T01:28:26Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
28,996,187
<p>Hi I'm a new user but finding an answer for same question, I can't get anything fully functional to my problem, I make this little piece of cake with a full nested replace of keys, you can send list with dict or dict. Finally your dicts can have list with dict or more dict nested and it is all replaced with your new...
0
2015-03-11T19:58:43Z
[ "python", "dictionary" ]
In Python, I have a dictionary. How do I change the keys of this dictionary?
2,213,334
<p>Let's say I have a pretty complex dictionary.</p> <pre><code>{'fruit':'orange','colors':{'dark':4,'light':5}} </code></pre> <p>Anyway, my objective is to <strong>scan every key</strong> in this complex multi-level dictionary. Then, append "abc" to the end of each key. </p> <p>So that it will be:</p> <pre><code>{...
19
2010-02-06T14:04:55Z
35,463,446
<p>A functional (and flexible) solution. This allows an arbitrary transform to be applied to keys (recursively for embedded dicts): </p> <pre><code>def remap_dict(d, keymap_f): """returns a new dict by recursively remapping all of d's keys using keymap_f""" return dict([(keymap_f(k), remap_dict(v, keymap_f) if is...
0
2016-02-17T17:19:12Z
[ "python", "dictionary" ]
How to store python classes into a database with Django?
2,213,402
<p>I have two files:</p> <p><em><strong>choices.py</em></strong></p> <pre><code>class SomeChoice: name = u"lorem" class AnotherChoice: name = u"ipsum" # etc... </code></pre> <p><em><strong>models.py</em></strong></p> <pre><code>from django.db import models import choices class SomeModel(models.Model): ...
2
2010-02-06T14:29:12Z
2,213,498
<p>You could use pickle to store instances of the classes, but then it would be uglier, and you don't <em>need</em> to store the classes in the database in this case, so don't (you want to avoid hitting the database as much as possible).</p> <p>To avoid repeating the IDs in two places, you could change the code to som...
2
2010-02-06T14:56:04Z
[ "python", "database", "django", "django-models", "storing-information" ]
How to store python classes into a database with Django?
2,213,402
<p>I have two files:</p> <p><em><strong>choices.py</em></strong></p> <pre><code>class SomeChoice: name = u"lorem" class AnotherChoice: name = u"ipsum" # etc... </code></pre> <p><em><strong>models.py</em></strong></p> <pre><code>from django.db import models import choices class SomeModel(models.Model): ...
2
2010-02-06T14:29:12Z
2,213,512
<p>What's the value of the SomeChoice and AnotherChoice classes? Why not just store the keys and values in a dictionary (kind of link CHOICES in your SomeModel) and have one new class that just represents a choice, </p> <pre><code>class UserChoice: def __init__(self, id, name): self.id = id self.na...
0
2010-02-06T15:01:32Z
[ "python", "database", "django", "django-models", "storing-information" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,535
<p>In python it helps to think of declaring variables as binding values to names.</p> <p>Try not to misspell them, or you will have new ones (assuming you are talking about assignment statements - referencing them will cause an exception).</p> <p>If you are talking about instance variables, you won't be able to use t...
9
2010-02-06T15:10:49Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,543
<p>Python never forces you to create a variable only when you use it. You can always bind <code>None</code> to a name and then use the name elsewhere later.</p>
5
2010-02-06T15:12:36Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,560
<p>If you do any serious development you'll use a (integrated) development environment. <a href="http://www.logilab.org/857" rel="nofollow">Pylint</a> will be part of it and tell you all your misspellings. No need to make such a feature part of the langauge.</p>
3
2010-02-06T15:16:29Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,567
<p>To avoid a situation with misspelling variable names, I use a text-editor with an autocompletion function and binded </p> <pre><code> python -c "import py_compile; py_compile.compile('{filename}')" </code></pre> <p>to a function to be called when I save a file.</p>
4
2010-02-06T15:18:59Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,655
<p>Test.</p> <p>Example, with file <code>variable.py</code>:</p> <pre><code>#! /usr/bin/python somevar = 5 </code></pre> <p>Then, make file <code>variable.txt</code> (to hold the tests):</p> <pre><code>&gt;&gt;&gt; import variables &gt;&gt;&gt; variables.somevar == 4 True </code></pre> <p>Then do:</p> <pre><code...
3
2010-02-06T15:45:27Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,663
<p>It's a silly artifact of Python's inspiration by "teaching languages", and it serves to make the language more accessible by removing the stumbling block of "declaration" entirely. For whatever reason (probably represented as "simplicity"), Python never gained an optional stricture like VB's "Option Explicit" to int...
15
2010-02-06T15:48:42Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,213,963
<p>If you want a class with "locked-down" instance attributes, it's not hard to make one, e.g.:</p> <pre><code>class LockedDown(object): __locked = False def __setattr__(self, name, value): if self.__locked: if name[:2] != '__' and name not in self.__dict__: raise ValueError("Can't set attribute ...
12
2010-02-06T17:31:22Z
[ "python" ]
What's the pythonic way of declaring variables?
2,213,531
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> ...
10
2010-02-06T15:09:32Z
2,214,528
<p>Variable declaration does not prevent bugs. Any more than lack of variable declaration causes bugs.</p> <p>Variable declarations prevent one specific type of bug, but it creates other types bugs.</p> <p><strong>Prevent</strong>. Writing code where there's an attempt to set (or change) a variable with the wrong t...
-1
2010-02-06T20:00:52Z
[ "python" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
2,214,018
<p>An attempt to <code>easy_install</code> indicates a problem with their <a href="http://pypi.python.org/pypi/scipy/0.7.0">listing</a> in the <a href="http://pypi.python.org/pypi">Python Package Index</a>, which pip searches.</p> <pre><code>easy_install scipy Searching for scipy Reading http://pypi.python.org/simple/...
83
2010-02-06T17:48:20Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
3,625,365
<p>If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using <a href="http://en.wikipedia.org/wiki/Arch_Linux" rel="nofollow">Arch Linux</a>), I can get SciPy installed with:</p> <pre><code>pip install scipy </code></pre>
11
2010-09-02T08:29:46Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
3,865,521
<p>In Ubuntu 10.04 (Lucid), I could successfully <code>pip install scipy</code> (within a virtualenv) after installing some of its dependencies, in particular:</p> <pre><code>$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatl...
31
2010-10-05T16:05:34Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
7,668,453
<p>Addon for Ubuntu (Ubuntu&nbsp;10.04 LTS (Lucid Lynx)):</p> <p>The repository moved, but a</p> <pre><code>pip install -e git+http://github.com/scipy/scipy/#egg=scipy </code></pre> <p>failed for me... With the following steps, it finally worked out (as root in a virtual environment, where <code>python3</code> is a ...
3
2011-10-05T22:22:41Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
15,355,787
<p><em>Prerequisite:</em></p> <pre><code>sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev sudo pip install --upgrade pip </code></pre> <p><em>Actual packages:</em></p> <pre><code>sudo pip install numpy sudo pip install scipy </code></pre> <p><em>Optional packages:</em></p> <pre...
174
2013-03-12T07:45:21Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
22,493,784
<p>I tried all the above and nothing worked for me. This solved all my problems:</p> <pre><code>pip install -U numpy pip install -U scipy </code></pre> <p>Note that the <code>-U</code> option to <code>pip install</code> requests that the package be <em>upgraded</em>. Without it, if the package is already installed <...
11
2014-03-19T00:17:56Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
22,633,734
<p>For the Arch Linux users:</p> <p><code>pip install --user scipy</code> prerequisites the following Arch packages to be installed:</p> <ul> <li><code>gcc-fortran</code></li> <li><code>blas</code></li> <li><code>lapack</code></li> </ul>
7
2014-03-25T11:50:57Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
28,116,352
<p>On Fedora, this works:</p> <pre><code>sudo yum install -y python-pip sudo yum install -y lapack lapack-devel blas blas-devel sudo yum install -y blas-static lapack-static sudo pip install numpy sudo pip install scipy </code></pre> <p>If you get any <code>public key</code> errors while downloading, add <code>--nog...
12
2015-01-23T18:26:22Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
32,395,290
<p>In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran</p> <pre><code> sudo apt-get install libatlas-base-dev gfortran </code></pre> <p>Then run pip install scipy</p>
2
2015-09-04T10:02:29Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
34,220,168
<p>To install scipy on windows follow these instructions:-</p> <p>Step-1 : Press this link <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy">http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy</a> to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).</p> <p>Step-2: Go to the directory whe...
7
2015-12-11T09:32:22Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
36,588,996
<p>For gentoo, it's in the main repository: <code>emerge --ask scipy</code></p>
0
2016-04-13T05:02:30Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
37,884,499
<ol> <li>install python-3.4.4</li> <li>scipy-0.15.1-win32-superpack-python3.4</li> <li>apply the following commend doc</li> </ol> <pre class="lang-py prettyprint-override"><code>py -m pip install --upgrade pip py -m pip install numpy py -m pip install matplotlib py -m pip install scipy py -m pip install scikit-learn <...
1
2016-06-17T14:46:32Z
[ "python", "install", "scipy", "pip" ]
Installing SciPy with pip
2,213,551
<p>It is possible to install <a href="http://en.wikipedia.org/wiki/NumPy">NumPy</a> with <a href="https://en.wikipedia.org/wiki/Pip_%28package_manager%29">pip</a> using <code>pip install numpy</code>. </p> <p>Is there a similar possibility with <a href="http://en.wikipedia.org/wiki/SciPy">SciPy</a>? (Doing <code>pip i...
142
2010-02-06T15:13:55Z
39,718,011
<p>Besides all of these answers, If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine. <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a> In the above URL you can download the packages and ...
0
2016-09-27T06:57:48Z
[ "python", "install", "scipy", "pip" ]
how do people normally deal with class variables in django?
2,213,595
<p>I can't see any provision for this in the django docs, so how do people go about doing this.</p> <p>My specific case is this.</p> <p>I have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart insta...
2
2010-02-06T15:27:43Z
2,213,602
<p>The default primary key will already be a unique monotonic integer (even in SQLite if you don't delete any records), so you can just use that for it.</p>
1
2010-02-06T15:29:54Z
[ "python", "django-models" ]
how do people normally deal with class variables in django?
2,213,595
<p>I can't see any provision for this in the django docs, so how do people go about doing this.</p> <p>My specific case is this.</p> <p>I have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart insta...
2
2010-02-06T15:27:43Z
2,213,631
<p>You can create a field in a model and state it as primary key or use your current primary key if you are migrating a legacy database <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.primary_key" rel="nofollow">primary_key=True</a>.</p> <p>Django ORM has no support for complex ...
0
2010-02-06T15:38:38Z
[ "python", "django-models" ]
how do people normally deal with class variables in django?
2,213,595
<p>I can't see any provision for this in the django docs, so how do people go about doing this.</p> <p>My specific case is this.</p> <p>I have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart insta...
2
2010-02-06T15:27:43Z
2,213,782
<p>Have your invoice field in your model:</p> <pre><code>class Cart(models.Model): ..... invoice_id = models.PositiveIntegerField(null=True,unique=True) </code></pre> <p>Only set the value when appropriate.</p> <p>To find the next ID:</p> <pre><code>try: nextID = Cart.objects.exclude(invoice_id=None).order_by('...
0
2010-02-06T16:31:44Z
[ "python", "django-models" ]
Changing the hour with datetime.replace() in python
2,213,682
<p>Given that foo is a valid datetime object in python, </p> <p>One can change the hour represented in a datestamp (foo) by doing something something like: </p> <pre><code>foo2 = foo.replace( hour=5 ) </code></pre> <p>Rather then replacing the hour with a particular value ( as is done above )..is it possible to inc...
14
2010-02-06T15:57:11Z
2,213,710
<p>That's what <code>timedelta</code> is for:</p> <pre><code>&gt;&gt;&gt; import datetime &gt;&gt;&gt; d = datetime.datetime(2010, 12, 25, 18, 25) &gt;&gt;&gt; d + datetime.timedelta(hours = 8) datetime.datetime(2010, 12, 26, 2, 25) </code></pre>
23
2010-02-06T16:08:46Z
[ "python", "osx", "datetime" ]
How can _meta.local_fields not match the table schema in the database?
2,213,716
<p>I'm completely confused about why _meta.local_fields returns more fields than the database table contains. The User model inherits from contrib.auth.models.User.</p> <pre><code>$ mysql -u user -p database Enter password: Reading table information for completion of table and column names You can turn off this...
0
2010-02-06T16:09:49Z
2,214,000
<p>It would have been helpful if you showed the <em>Django model</em> that is related to this problem. From the field names in your SQL this model appears to inherit from contrib.auth.models.User, is that true? If so, did you happen to duplicate a field name defined in the User model?</p> <p><strong>Update:</strong> T...
0
2010-02-06T17:44:33Z
[ "python", "django", "django-models" ]
Python: removing duplicates from a list of lists
2,213,923
<p>I have a list of lists in Python:</p> <pre><code>k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] </code></pre> <p>And I want to remove duplicate elements from it. Was if it a normal list not of lists I could used <code>set</code>. But unfortunate that list is not hashable and can't make set of lists. Only of tuples...
59
2010-02-06T17:17:46Z
2,213,935
<pre><code>&gt;&gt;&gt; k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] &gt;&gt;&gt; k = sorted(k) &gt;&gt;&gt; k [[1, 2], [1, 2], [3], [4], [4], [5, 6, 2]] &gt;&gt;&gt; dedup = [k[i] for i in range(len(k)) if i == 0 or k[i] != k[i-1]] &gt;&gt;&gt; dedup [[1, 2], [3], [4], [5, 6, 2]] </code></pre> <p>I don't know if it...
12
2010-02-06T17:21:34Z
[ "python" ]
Python: removing duplicates from a list of lists
2,213,923
<p>I have a list of lists in Python:</p> <pre><code>k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] </code></pre> <p>And I want to remove duplicate elements from it. Was if it a normal list not of lists I could used <code>set</code>. But unfortunate that list is not hashable and can't make set of lists. Only of tuples...
59
2010-02-06T17:17:46Z
2,213,971
<p>Doing it manually, creating a new <code>k</code> list and adding entries not found so far:</p> <pre><code>k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] new_k = [] for elem in k: if elem not in new_k: new_k.append(elem) k = new_k print k # prints [[1, 2], [4], [5, 6, 2], [3]] </code></pre> <p>Simple to...
6
2010-02-06T17:33:05Z
[ "python" ]
Python: removing duplicates from a list of lists
2,213,923
<p>I have a list of lists in Python:</p> <pre><code>k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] </code></pre> <p>And I want to remove duplicate elements from it. Was if it a normal list not of lists I could used <code>set</code>. But unfortunate that list is not hashable and can't make set of lists. Only of tuples...
59
2010-02-06T17:17:46Z
2,213,973
<pre><code>&gt;&gt;&gt; k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] &gt;&gt;&gt; import itertools &gt;&gt;&gt; k.sort() &gt;&gt;&gt; list(k for k,_ in itertools.groupby(k)) [[1, 2], [3], [4], [5, 6, 2]] </code></pre> <p><a href="http://docs.python.org/library/itertools.html?highlight=itertools#module-itertools"><co...
85
2010-02-06T17:33:57Z
[ "python" ]
Python: removing duplicates from a list of lists
2,213,923
<p>I have a list of lists in Python:</p> <pre><code>k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] </code></pre> <p>And I want to remove duplicate elements from it. Was if it a normal list not of lists I could used <code>set</code>. But unfortunate that list is not hashable and can't make set of lists. Only of tuples...
59
2010-02-06T17:17:46Z
2,214,211
<p>Even your "long" list is pretty short. Also, did you choose them to match the actual data? Performance will vary with what these data actually look like. For example, you have a short list repeated over and over to make a longer list. This means that the quadratic solution is linear in your benchmarks, but not in re...
3
2010-02-06T18:36:00Z
[ "python" ]
Is everything greater than None?
2,214,194
<p>Is there a Python built-in datatype, <strong>besides <code>None</code></strong>, for which:</p> <pre><code>&gt;&gt;&gt; not foo &gt; None True </code></pre> <p>where <code>foo</code> is a value of that type? How about Python 3?</p>
50
2010-02-06T18:32:17Z
2,214,223
<p><code>None</code> is always less than any datatype in Python 2 (see <a href="http://hg.python.org/cpython/file/ab05e7dd2788/Objects/object.c#l778"><code>object.c</code></a>).</p> <p>In Python 3, this was changed; now doing comparisons on things without a sensible natural ordering results in a <code>TypeError</code>...
59
2010-02-06T18:38:29Z
[ "python", "python-3.x", "python-datamodel" ]
Is everything greater than None?
2,214,194
<p>Is there a Python built-in datatype, <strong>besides <code>None</code></strong>, for which:</p> <pre><code>&gt;&gt;&gt; not foo &gt; None True </code></pre> <p>where <code>foo</code> is a value of that type? How about Python 3?</p>
50
2010-02-06T18:32:17Z
2,214,230
<p>From the Python <strong>2.7.5</strong> source (<a href="http://hg.python.org/cpython/file/ab05e7dd2788/Objects/object.c#l778"><code>object.c</code></a>):</p> <pre><code>static int default_3way_compare(PyObject *v, PyObject *w) { ... /* None is smaller than anything */ if (v == Py_None) retur...
23
2010-02-06T18:40:12Z
[ "python", "python-3.x", "python-datamodel" ]
cache.fetch in Django?
2,214,330
<p>Does Django caching have a method similar to Rails' cache.fetch? (http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#M001023) The rails cache fetch works like:</p> <pre> cache.fetch("my_key") { // return what I want to put in my_key if it is empty "some_value" } </pre> <p>It's useful because it ...
2
2010-02-06T19:03:14Z
2,214,337
<p>Well to get a default value if the key does not exits you can provide a second parameter:</p> <pre><code>cache.get('key', 'default') </code></pre> <blockquote> <p><a href="http://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cache-api" rel="nofollow"><code>cache.get()</code></a> can take a default ar...
0
2010-02-06T19:06:39Z
[ "python", "ruby-on-rails", "django", "caching", "fetch" ]
cache.fetch in Django?
2,214,330
<p>Does Django caching have a method similar to Rails' cache.fetch? (http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#M001023) The rails cache fetch works like:</p> <pre> cache.fetch("my_key") { // return what I want to put in my_key if it is empty "some_value" } </pre> <p>It's useful because it ...
2
2010-02-06T19:03:14Z
2,216,326
<p>I think the code you would have to write would be like this: (EDIT)</p> <pre><code>def get_value(param1,param2): return "value %s - %s " % (str(param1),str(param2)) def fetch(key,val_function,**kwargs) val = cache.get(key) if not val: val = val_function(**kwargs) cache.set(key,val) ...
4
2010-02-07T07:47:55Z
[ "python", "ruby-on-rails", "django", "caching", "fetch" ]
cache.fetch in Django?
2,214,330
<p>Does Django caching have a method similar to Rails' cache.fetch? (http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html#M001023) The rails cache fetch works like:</p> <pre> cache.fetch("my_key") { // return what I want to put in my_key if it is empty "some_value" } </pre> <p>It's useful because it ...
2
2010-02-06T19:03:14Z
2,560,915
<p>Julian's code is quite good but doesn't take positional args (when you want to use sorted() for example). Here's my fix:</p> <pre><code>def get_value(param1,param2): return "value %s - %s " % (str(param1),str(param2)) def fetch(key,val_function, *args, **kwargs) val = cache.get(key) if not val: ...
2
2010-04-01T14:05:45Z
[ "python", "ruby-on-rails", "django", "caching", "fetch" ]
(django initial setup) Django installation is redirecting all traffic to django page, fix?
2,214,645
<p>I'm a complete newbie to Django. I've been trying to get it working on my Ubuntu server.</p> <p>everytime someone my server, it redirects to the "Congratulations on your first Django-powered page." It completely ignores the index.html file in the www directory. Why is that? Is there a away to make it so that it onl...
0
2010-02-06T20:44:51Z
2,214,664
<blockquote> <p>"It completely ignores the index.html file in the www directory. Why is that?"</p> </blockquote> <p>Because you installed django and django takes over from that point. You should probably change the <code>&lt;Location&gt;</code> path to "testproject" instead of "/" as obviously the latter means r...
1
2010-02-06T20:50:02Z
[ "python", "django", "apache", "mod-python", "apache-config" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,675
<p>Try this:</p> <pre><code>x = [0] * 100000000 </code></pre> <p>It takes just a few seconds to execute on my machine, and access is close to instant.</p>
6
2010-02-06T20:52:39Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,678
<p>It's unlikely you'll find anything faster than <code>numpy</code>'s <code>array</code>. The implementation of the array itself is as efficient as it would be in, say, C (and basically the same as <code>array.array</code>, just with more usefulness.)</p> <p>If you want to speed up your code, you'll have to do it by ...
3
2010-02-06T20:53:51Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,710
<p>In addition to the other excellent solutions, another way is to use a dict instead of an array (elements which exist are non-zero, otherwise they're zero). Lookup time is O(1).</p> <p>You might also check if your application is resident in RAM, rather than swapping out. It's only 381 MB, but the system may not be g...
1
2010-02-06T21:00:05Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,752
<p><a href="http://en.wikipedia.org/wiki/NumPy" rel="nofollow">NumPy</a> is the appropriate tool for a large, fixed-size, homogeneous array. Accessing individual elements of anything in Python isn't going to be all that fast, though whole-array operations can often be conducted at speeds similar to C or Fortran. If you...
0
2010-02-06T21:12:42Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,771
<p>I have done some profiling, and the results are completely counterintuitive. For simple array access operations, <strong>numpy and array.array are 10x slower than native Python arrays</strong>.</p> <p>Note that for array access, I am doing operations of the form:</p> <pre><code>a[i] += 1 </code></pre> <p>Profiles...
25
2010-02-06T21:17:34Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,938
<p>For fast creation, use the array module.</p> <p>Using the array module is ~5 times faster for creation, but about twice as slow for accessing elements compared to a normal list:</p> <pre><code># Create array python -m timeit -s "from array import array" "a = array('I', '\x00' * 100000000)" 10 loops, best of 3: 20...
3
2010-02-06T22:09:04Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,214,986
<p>Just a reminder how Python's integers work: if you allocate a list by saying</p> <pre><code>a = [0] * K </code></pre> <p>you need the memory for the list (<code>sizeof(PyListObject) + K * sizeof(PyObject*)</code>) and the memory for the single integer object <code>0</code>. As long as the numbers in the list stay ...
10
2010-02-06T22:26:07Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,215,000
<p>I would simply create your own data type that doesn't initialize ANY values.</p> <p>If you want to read an index position that has NOT been initialized, you return zeroes. Still, do not initialize any storage.</p> <p>If you want to read an index position that HAS been initialized, simply return the value.</p> <p>...
0
2010-02-06T22:32:24Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
2,215,022
<p>If you are are not able to vectorize your calculuations, Python/Numpy will be slow. Numpy is fast because vectorized calculations occur at a lower level than Python. The core numpy functions are all written in C or Fortran. Hence <code>sum(a)</code> is not a python loop with many accesses, it's a single low level...
5
2010-02-06T22:41:25Z
[ "python", "arrays", "performance" ]
Efficient Python array with 100 million zeros?
2,214,651
<p>What is an efficient way to initialize and access elements of a large array in Python?</p> <p>I want to create an array in Python with 100 million entries, unsigned 4-byte integers, initialized to zero. I want fast array access, preferably with contiguous memory.</p> <p>Strangely, <a href="http://en.wikipedia.org/...
18
2010-02-06T20:46:40Z
37,362,629
<p>If</p> <ul> <li>access speed of array.array is acceptable for your application</li> <li>compact storage is most important</li> <li>you want to use standard modules (no NumPy dependency)</li> <li>you are on platforms that have /dev/zero</li> </ul> <p>the following may be of interest to you. It initialises array.arr...
0
2016-05-21T11:58:18Z
[ "python", "arrays", "performance" ]
wxpython GUI having static Japanese text and chinese static text
2,214,694
<p>We want to support localization of the static text (labels, button labels, etc) to Japanese and Chinese in wxpython. We want only static text within the GUI elements to be changed, hard coding of Japanese or Chinese characters in the label(static text fields) would do the work for us. Any help on how to pursue this ...
0
2010-02-06T20:56:38Z
2,216,777
<p>see: wx.GetTranslation</p> <p><a href="http://wiki.wxpython.org/Internationalization" rel="nofollow">http://wiki.wxpython.org/Internationalization</a></p> <p>What I do, is use _ = wx.GetTranslation at the top of my scripts, and enclose any strings in _("My String")</p> <p>I use this batch script: <a href="http:/...
0
2010-02-07T12:47:06Z
[ "python", "unicode", "wxpython" ]
Django: Making ForeignKey not create a back-reference
2,214,705
<p>I know that I can use <code>ForeignKey</code>'s <code>related_name</code> argument to control what the back-reference's name will be. But is it possible to avoid creating a back-reference completely?</p> <p>(e.g., I have in Car a field ForeignKey(Person), and I don't want Person to have an attribute that leads back...
1
2010-02-06T20:59:07Z
2,214,882
<p>Why would you want to do this? You don't have to use it if you don't want to.</p> <p>In any case, the back-reference is only a code shortcut - it's exactly equivalent to <code>Car.objects.filter(person_id=person.id)</code>.</p>
1
2010-02-06T21:51:53Z
[ "python", "django" ]
Django: Making ForeignKey not create a back-reference
2,214,705
<p>I know that I can use <code>ForeignKey</code>'s <code>related_name</code> argument to control what the back-reference's name will be. But is it possible to avoid creating a back-reference completely?</p> <p>(e.g., I have in Car a field ForeignKey(Person), and I don't want Person to have an attribute that leads back...
1
2010-02-06T20:59:07Z
13,872,056
<p>For those coming from Google: use a '+' in the related_name field to prevent creating a back reference field.</p> <p><a href="https://docs.djangoproject.com/en/1.4/ref/models/fields/#django.db.models.ForeignKey.related_name" rel="nofollow">https://docs.djangoproject.com/en/1.4/ref/models/fields/#django.db.models.Fo...
4
2012-12-14T03:04:09Z
[ "python", "django" ]
Django: Can the value of ForeignKey be None?
2,214,909
<p>I have a model called <code>SimplePage</code> in which I have this line:</p> <pre><code>category = models.ForeignKey('Category', related_name='items', blank=True, null=True) </code></pre> <p>I assumed this will allow me to have SimplePage instances that do not have a Category.</p> <p>...
4
2010-02-06T21:59:58Z
2,215,003
<p>Could it possibly be that you added the <code>null=True</code> attribute after doing the <code>syncdb</code> for that model? Django won't change database tables, only create them. Check in your database if <code>NULL</code> is allowed for that column and change it manually.</p> <p><strong>Edit</strong>: starting wi...
9
2010-02-06T22:35:43Z
[ "python", "database", "django", "foreign-keys" ]
Are there any free alternatives to the Ranorex library (Python, Windows)?
2,215,154
<p>I am interested in the Python one. I wish to automate some GUI under Windows. What is the best open source library for that with no strings attached? Thanks.</p>
3
2010-02-06T23:26:10Z
2,215,189
<p>Try <a href="http://pywinauto.openqa.org/" rel="nofollow">pyWinAuto</a>.</p>
2
2010-02-06T23:35:50Z
[ "python", "windows", "user-interface", "automation" ]
Are there any free alternatives to the Ranorex library (Python, Windows)?
2,215,154
<p>I am interested in the Python one. I wish to automate some GUI under Windows. What is the best open source library for that with no strings attached? Thanks.</p>
3
2010-02-06T23:26:10Z
2,216,167
<p>There's <a href="http://www.tizmoi.net/watsup/intro.html" rel="nofollow">WATSUP</a>, but I've not tried it yet myself.</p> <p>I've also heard of pyWinAuto, although the link I have is to <a href="http://sourceforge.net/projects/pywinauto/" rel="nofollow">pyWinAuto on SourceForge</a>.</p>
1
2010-02-07T06:24:33Z
[ "python", "windows", "user-interface", "automation" ]
How to get rid of pygame surfaces?
2,215,227
<p>In the following code, there is not just <strong>one</strong> circle on the screen at any given point in time. I want to fix this to make it so that it looks like there is only one circle, instead of leaving a smudge trail where ever the mouse cursor has been.</p> <pre><code>import pygame,sys from pygame.locals imp...
3
2010-02-06T23:46:53Z
2,215,258
<p>You need to specifically erase the circle before you blit it again. Depending on how complicated your scene is, you may have to try different methods. Generally what I do is have a "background" surface that a blit to the screen every frame and then blit the sprites/other surfaces in their new positions (blits in Pyg...
6
2010-02-06T23:57:32Z
[ "python", "pygame", "geometry-surface" ]
Actionscript flex sockets and telnet
2,215,308
<p>I am trying to make a flex application where it gets data from a telnet connection and I am running into a weird problem.</p> <p>To give a brief introduction, i want to read data from a process that exposes it through a socket. So if in the shell i type <code>telnet localhost 8651</code>i receive the xml and then t...
1
2010-02-07T00:13:09Z
2,215,404
<p>What security sandbox are you running this in? if you are running this as a flash application embedded in a web page then this is most likely a security violation.</p> <blockquote> <p>The XMLSocket.connect() method can connect only to computers in the same domain where the SWF file resides. This restriction...
0
2010-02-07T00:46:23Z
[ "python", "flex", "actionscript-3", "sockets", "telnet" ]