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 |
|---|---|---|---|---|---|---|---|---|---|
Comunicating to server with queries through stream. What is the right way? | 2,128,545 | <p>I'm writing my first network application. It manipulates jabber client and comunicates with some service with IQ-stanzas. But details are not important.</p>
<p>This interaction works through twisted xmlstream (python language). Typical situations are described here: <a href="http://juick.com/help/api/xmpp/" rel="no... | 1 | 2010-01-24T19:59:22Z | 2,128,624 | <p>To pair a response with a reply, you use the iq.id attribute. You can store a few deferreds in a cache indexed by id and run them when they get a reply. Since XMPP is TCP-based, you will mostly get replies in the right order anyway. You can cap the cache and run the deferred's errback if the deferred has been in the... | 0 | 2010-01-24T20:20:00Z | [
"python",
"networking",
"twisted"
] |
SQLAlchemy printing raw SQL from create() | 2,128,717 | <p>I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?</p>
| 20 | 2010-01-24T20:40:52Z | 2,131,733 | <p>SQLAlchemy is designed in such a way that doesn't allow echoing generated DDL statements without actually executing them. AFAIK, <a href="http://packages.python.org/sqlalchemy-migrate/" rel="nofollow">SQLAlchemy Migrate</a> use mock engine to catch statements without executing when --preview_sql option is used, so u... | -2 | 2010-01-25T10:56:47Z | [
"python",
"sqlalchemy",
"pylons"
] |
SQLAlchemy printing raw SQL from create() | 2,128,717 | <p>I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?</p>
| 20 | 2010-01-24T20:40:52Z | 2,134,301 | <p>Something like this? (from the SQLA FAQ)</p>
<p><a href="http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html" rel="nofollow">http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html</a></p>
| 8 | 2010-01-25T17:44:10Z | [
"python",
"sqlalchemy",
"pylons"
] |
SQLAlchemy printing raw SQL from create() | 2,128,717 | <p>I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?</p>
| 20 | 2010-01-24T20:40:52Z | 3,150,687 | <pre><code>from sqlalchemy.schema import CreateTable
print CreateTable(table)
</code></pre>
<p>If you are using declarative syntax:</p>
<pre><code>print CreateTable(Model.__table__)
</code></pre>
<p><strong>Update:</strong></p>
<p>Since I have the accepted answer and there is important information in <a href="http... | 40 | 2010-06-30T15:22:21Z | [
"python",
"sqlalchemy",
"pylons"
] |
SQLAlchemy printing raw SQL from create() | 2,128,717 | <p>I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?</p>
| 20 | 2010-01-24T20:40:52Z | 5,418,919 | <p>May be you mean <code>echo</code> parameter of sqlalchemy.create_engine?</p>
<p>/tmp$ cat test_s.py </p>
<pre><code>import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Department(Base):
__tablename__ = "departments"
department_id = sa.Column(sa... | 0 | 2011-03-24T12:14:54Z | [
"python",
"sqlalchemy",
"pylons"
] |
SQLAlchemy printing raw SQL from create() | 2,128,717 | <p>I am giving Pylons a try with SQLAlchemy, and I love it, there is just one thing, is it possible to print out the raw SQL CREATE TABLE data generated from Table().create() before it's executed?</p>
| 20 | 2010-01-24T20:40:52Z | 10,216,304 | <p>I needed to get the raw table sql in order to setup tests for some existing models. Here's a successful unit test that I created for SQLAlchemy 0.7.4 based on <a href="http://stackoverflow.com/a/3150687/1093087">Antoine's answer</a> as proof of concept:</p>
<pre><code>from sqlalchemy import create_engine
from sqlal... | 9 | 2012-04-18T19:13:02Z | [
"python",
"sqlalchemy",
"pylons"
] |
Running django on IronPython | 2,128,740 | <p>There have been some questions and answers here on stackoverflow, but no one asked if it's a good solution to run django on IIS.<br>
Any experience is welcome, both good and bad.</p>
| 2 | 2010-01-24T20:45:49Z | 2,128,919 | <p>One thing I know is that Django has no official support for IronPython - just CPython and Jython. In addition, PIL - which provides Django's support for image fields - does not natively support IronPython, though the <a href="http://code.google.com/p/ironclad/" rel="nofollow">ironclad</a> project could help with tha... | 2 | 2010-01-24T21:24:43Z | [
".net",
"python",
"django",
"iis",
"ironpython"
] |
Python to C# Code Explanation | 2,128,784 | <p>My ultimate aim is to convert the below code in python to C#, but I'd like to do it my self by learning the python syntax. I understand that the code is recursive.</p>
<p>The code produces polynomials of degree n with k variables. More specifically the list of exponents for each variable.</p>
<pre><code>def multi... | 5 | 2010-01-24T20:53:15Z | 2,128,811 | <p><code>[0] * n</code> returns a list with n <code>0</code>s. <code>[]</code> is an empty list. <code>[[k]]</code> is a list that contains a list that contains <code>k</code>.</p>
<p>The last part uses list comprehensions. The basic forms of a list comprehension are:</p>
<pre><code>[<new value> for <name>... | 1 | 2010-01-24T20:58:48Z | [
"c#",
"python"
] |
Python to C# Code Explanation | 2,128,784 | <p>My ultimate aim is to convert the below code in python to C#, but I'd like to do it my self by learning the python syntax. I understand that the code is recursive.</p>
<p>The code produces polynomials of degree n with k variables. More specifically the list of exponents for each variable.</p>
<pre><code>def multi... | 5 | 2010-01-24T20:53:15Z | 2,128,827 | <p>I would use <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx" rel="nofollow">LINQ</a> in C# to translate the code:</p>
<ul>
<li><p><code>[]</code> is the empty list.</p>
<pre><code>Enumerable.Empty<T>()
</code></pre></li>
<li><p><code>[x]</code> is the list containing a single ite... | 3 | 2010-01-24T21:03:12Z | [
"c#",
"python"
] |
Python to C# Code Explanation | 2,128,784 | <p>My ultimate aim is to convert the below code in python to C#, but I'd like to do it my self by learning the python syntax. I understand that the code is recursive.</p>
<p>The code produces polynomials of degree n with k variables. More specifically the list of exponents for each variable.</p>
<pre><code>def multi... | 5 | 2010-01-24T20:53:15Z | 2,128,985 | <p>Some comments:</p>
<p>Pythons <code>return "Error"</code> is not throwing an exception. It returns the string value "Error".</p>
<p>Pythons <code>if not k:</code> is not equivalent to <code>if (k == 0)</code> there are more things that are "not", like empty lists, the None value, etc (that may not make a differenc... | 1 | 2010-01-24T21:39:46Z | [
"c#",
"python"
] |
Python to C# Code Explanation | 2,128,784 | <p>My ultimate aim is to convert the below code in python to C#, but I'd like to do it my self by learning the python syntax. I understand that the code is recursive.</p>
<p>The code produces polynomials of degree n with k variables. More specifically the list of exponents for each variable.</p>
<pre><code>def multi... | 5 | 2010-01-24T20:53:15Z | 2,129,527 | <p>I found this one intriguing and after some help with understanding the Python code I took a stab at it. C# 3.0 and .NET Framework 3.5 needed.</p>
<pre><code>public static IEnumerable<IEnumerable<int>> MultiChoose(int n, int k)
{
if (k < 0 || n < 0) throw new Exception();
if (k == 0) return... | 1 | 2010-01-25T00:22:15Z | [
"c#",
"python"
] |
Python - Rpy2 - Can't import a bunch of packages | 2,128,806 | <p>I've just started using rpy2 with Python. I've installed it and am able to do basic things, like call R's plot function from inside Python. For everything I've done, I've used import calls like:</p>
<pre><code>import rpy2
import rpy2.robjects
</code></pre>
<p>From robjects I can do most things I want to do. How... | 2 | 2010-01-24T20:57:20Z | 2,128,836 | <p><code>packages</code> is new in 2.1. You're probably still using 2.0.x.</p>
| 3 | 2010-01-24T21:05:13Z | [
"python"
] |
Python - Rpy2 - Can't import a bunch of packages | 2,128,806 | <p>I've just started using rpy2 with Python. I've installed it and am able to do basic things, like call R's plot function from inside Python. For everything I've done, I've used import calls like:</p>
<pre><code>import rpy2
import rpy2.robjects
</code></pre>
<p>From robjects I can do most things I want to do. How... | 2 | 2010-01-24T20:57:20Z | 2,128,911 | <p>You can use the normal <code>library()</code> command from robjects.r to load a library in rpy2 2.0.x:</p>
<pre><code>from rpy2.robjects import r
r.library("lattice")
r.library("ggplot2")
</code></pre>
<p>Or you can upgrade to the 2.1 alpha and see if the new way works for you.</p>
| 2 | 2010-01-24T21:22:30Z | [
"python"
] |
Is it possible to narrow down the generated query in SQLAlchemy if it was created via query_property? | 2,128,809 | <p>I have another quick question about SQLAlchemy.</p>
<p>If I have added a <code>query_property</code> [1] field in my SQLAlchemy Table class, is it possible to narrow down the SELECTed fields?</p>
<p>Here is what I mean. </p>
<p>Suppose my class <code>Comments</code> has this:</p>
<pre><code>class Comments:
q... | 2 | 2010-01-24T20:57:33Z | 2,130,431 | <p>Try using <code>query.values(Comment.comment)</code>. Note that it returns generator, not modified query, so this method should called last after applying all filters.</p>
| 1 | 2010-01-25T05:44:35Z | [
"python",
"sql",
"sqlalchemy"
] |
Python, len, and size of ints | 2,128,989 | <p>So, cPython (2.4) has some interesting behaviour when the length of something gets near to 1<<32 (the size of an int). </p>
<pre><code>r = xrange(1<<30)
assert len(r) == 1<<30
</code></pre>
<p>is fine, but:</p>
<pre><code>r = xrange(1<<32)
assert len(r) == 1<<32
ValueError: xrange o... | 5 | 2010-01-24T21:40:33Z | 2,129,012 | <p><code>1<<32</code>, when treated as a signed integer, is negative.</p>
| 1 | 2010-01-24T21:45:13Z | [
"python",
"int"
] |
Python, len, and size of ints | 2,128,989 | <p>So, cPython (2.4) has some interesting behaviour when the length of something gets near to 1<<32 (the size of an int). </p>
<pre><code>r = xrange(1<<30)
assert len(r) == 1<<30
</code></pre>
<p>is fine, but:</p>
<pre><code>r = xrange(1<<32)
assert len(r) == 1<<32
ValueError: xrange o... | 5 | 2010-01-24T21:40:33Z | 2,129,017 | <p>cPython assumes that lists fit in memory. This extends to objects that behave like lists, such as xrange. essentially, the <code>len</code> function expects the <code>__len__</code> method to return something that is convertable to <code>size_t</code>, which won't happen if the number of logical elements is too la... | 11 | 2010-01-24T21:45:59Z | [
"python",
"int"
] |
Python, len, and size of ints | 2,128,989 | <p>So, cPython (2.4) has some interesting behaviour when the length of something gets near to 1<<32 (the size of an int). </p>
<pre><code>r = xrange(1<<30)
assert len(r) == 1<<30
</code></pre>
<p>is fine, but:</p>
<pre><code>r = xrange(1<<32)
assert len(r) == 1<<32
ValueError: xrange o... | 5 | 2010-01-24T21:40:33Z | 2,129,036 | <p>You'll find that</p>
<pre><code>xrange(1 << 31 - 1)
</code></pre>
<p>is the last one that behaves as you want. This is because the maximum signed (32-bit) integer is 2^31 - 1.</p>
<p><code>1 << 32</code> is not a positive signed 32-bit integer (Python's <code>int</code> datatype), so that's why you're... | 5 | 2010-01-24T21:49:36Z | [
"python",
"int"
] |
Pylons: free module-level variables? | 2,129,164 | <p>Not even sure if module-level is correct here, but...</p>
<p>I have a Pylons project and within the model component I have a global variable, doc, in <code>__init__.py</code> that I want to use from different Query objects. (doc is a Document handle on an XML file that I am using as a fake DB.) My question is, when... | 1 | 2010-01-24T22:29:45Z | 2,129,178 | <p>Objects only stop existing when 1) no references to them exist, or 2) the interpreter ends. A module/package keeps a reference to all module-level names in its private dict; deleting all references to the module in all other modules as well as in sys.modules, <em>and</em> all references to any objects within it will... | 0 | 2010-01-24T22:33:01Z | [
"python",
"singleton",
"scope",
"free",
"pylons"
] |
Pylons: free module-level variables? | 2,129,164 | <p>Not even sure if module-level is correct here, but...</p>
<p>I have a Pylons project and within the model component I have a global variable, doc, in <code>__init__.py</code> that I want to use from different Query objects. (doc is a Document handle on an XML file that I am using as a fake DB.) My question is, when... | 1 | 2010-01-24T22:29:45Z | 2,287,497 | <p>Have you considered putting the <strong>doc</strong> object in <code>globals</code>? Since it's an immutable object it shall be the perfect place to store it. Than you can reference <code>globals</code> from any controller and pass it to a <code>Query</code> object (during <code>__init__</code> or explicitly when ca... | 0 | 2010-02-18T09:26:34Z | [
"python",
"singleton",
"scope",
"free",
"pylons"
] |
Code translation, from Python to Ruby | 2,129,227 | <p>I would like to convert a few Python lines on Ruby, from this excellent article signed by Thomas Guest at: <a href="http://wordaligned.org/articles/drawing-chess-positions" rel="nofollow">http://wordaligned.org/articles/drawing-chess-positions</a></p>
<p>(note: I'm a really bigger Python noob)</p>
<p>Here is a cop... | 2 | 2010-01-24T22:44:36Z | 2,129,378 | <p>Looking at each method in turn, starting with <code>outer_join</code>.</p>
<p>In Python, <code>join</code> is a method on strings that takes a sequence and joins the elements delimited by the string. e.g. <code>'|'.join(['p, 'p', 'p'])</code></p>
<p>In Ruby, <code>join</code> is a method on arrays that takes the d... | 2 | 2010-01-24T23:30:21Z | [
"python",
"ruby"
] |
Code translation, from Python to Ruby | 2,129,227 | <p>I would like to convert a few Python lines on Ruby, from this excellent article signed by Thomas Guest at: <a href="http://wordaligned.org/articles/drawing-chess-positions" rel="nofollow">http://wordaligned.org/articles/drawing-chess-positions</a></p>
<p>(note: I'm a really bigger Python noob)</p>
<p>Here is a cop... | 2 | 2010-01-24T22:44:36Z | 2,129,393 | <p>This will do what you want:</p>
<pre><code>def expand(match)
' ' * match.to_i
end
def expand_blanks(fen)
fen.gsub(/\d/) {|d| expand d}
end
def outer_join(sep, ss)
sep + ss.join(sep) + sep
end
def ascii_draw_chess_position(fen)
pieces = expand_blanks(fen).gsub('/', '')
divider = "+-+-+-+-+-+-+-+-+\n"
... | 1 | 2010-01-24T23:33:52Z | [
"python",
"ruby"
] |
Python: xml.dom.minidom empty nodeValue nonempty toxml() value | 2,129,252 | <p>I have a line that gets the nodeValue of a Node:</p>
<pre><code>parent.getElementsByTagName("Url")[0].nodeValue
</code></pre>
<p>that returns nothing:</p>
<pre><code><br/>
</code></pre>
<p>When I do:</p>
<pre><code>parent.getElementsByTagName("Url")[0].toxml()
</code></pre>
<p>it returns:</p>
<pre><code... | 4 | 2010-01-24T22:51:31Z | 2,129,288 | <p>The <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247" rel="nofollow">DOM Level 2 documentation</a> states that <code>nodeName</code> for an element node is the tag name, the <code>nodeValue</code> is always <code>null</code> and <code>attributes</code> is a <code>NamedNodeMap</code>, so this co... | 0 | 2010-01-24T23:01:13Z | [
"python",
"xml",
"minidom"
] |
Python: xml.dom.minidom empty nodeValue nonempty toxml() value | 2,129,252 | <p>I have a line that gets the nodeValue of a Node:</p>
<pre><code>parent.getElementsByTagName("Url")[0].nodeValue
</code></pre>
<p>that returns nothing:</p>
<pre><code><br/>
</code></pre>
<p>When I do:</p>
<pre><code>parent.getElementsByTagName("Url")[0].toxml()
</code></pre>
<p>it returns:</p>
<pre><code... | 4 | 2010-01-24T22:51:31Z | 2,129,298 | <p>Try this:</p>
<pre><code>parent.getElementsByTagName('Url')[0].childNodes[0].nodeValue
</code></pre>
| 5 | 2010-01-24T23:03:02Z | [
"python",
"xml",
"minidom"
] |
Clojure Jython interop | 2,129,253 | <p>I was wondering if anyone has tried somehow calling Jython functions
from within Clojure, and how you went about doing this if so. I have
not used Jython, but I would imagine the Jython interpreter can be
invoked in the same way as any other java code, and Python programs
can be run within it. However I wonder if ... | 12 | 2010-01-24T22:51:46Z | 2,130,855 | <p><strong>A note:</strong> I just realised that the question is specifically about calling Jython functions from Clojure and <em>not</em> about building a full-fledged Jython-Clojure interop solution... But! I've already produced a smallish write-up on my initial thoughts on the latter and I guess that's the logical n... | 12 | 2010-01-25T07:42:30Z | [
"python",
"interop",
"lisp",
"clojure",
"jython"
] |
gtk.Builder() and multiple glade files breaks | 2,129,369 | <p>I have a glade gui, and I want to insert another object using a glade file as well. </p>
<p>When I do it as bellow (this is essentially what I am doing) the whole app hangs and the self.show() and maxes out the CPU at 100%. If I replace the first line of one's <strong>init</strong>() with self.builder = gtk.Build... | 1 | 2010-01-24T23:26:34Z | 2,134,108 | <p>Is there a good reason for using the same <code>gtk.Builder</code> object in two classes?<br>
This might be the cause of your problem. In your <code>one</code> class, you load a glade file but you never do anything with its widgets. Something like this should work:</p>
<pre><code>class one(gtk.VBox):
def __init_... | 2 | 2010-01-25T17:17:41Z | [
"python",
"gtk",
"pygtk"
] |
IP address of client in Python SimpleXMLRPCServer? | 2,129,374 | <p>I have a <a href="http://docs.python.org/library/simplexmlrpcserver.html#SimpleXMLRPCServer.SimpleXMLRPCServer" rel="nofollow">SimpleXMLRPCServer</a> server (Python). </p>
<p>How can I get the IP address of the client in the request handler?</p>
<p>This information appears in the log. However, I am not sure how to... | 3 | 2010-01-24T23:27:18Z | 2,129,402 | <p>The request handler itself should have a property <code>client_address</code> (inherited from <code>BaseHTTPRequestHandler</code>). From <a href="http://docs.python.org/library/basehttpserver.html#BaseHTTPServer.BaseHTTPRequestHandler" rel="nofollow">BaseHTTPRequestHandler</a>:</p>
<blockquote>
<p>Contains a tupl... | 2 | 2010-01-24T23:35:45Z | [
"python",
"ip-address",
"xml-rpc",
"simplexmlrpcserver"
] |
IP address of client in Python SimpleXMLRPCServer? | 2,129,374 | <p>I have a <a href="http://docs.python.org/library/simplexmlrpcserver.html#SimpleXMLRPCServer.SimpleXMLRPCServer" rel="nofollow">SimpleXMLRPCServer</a> server (Python). </p>
<p>How can I get the IP address of the client in the request handler?</p>
<p>This information appears in the log. However, I am not sure how to... | 3 | 2010-01-24T23:27:18Z | 3,000,079 | <p>As Michael noted, you can get <code>client_address</code> from within the request handler. For instance, you can override the <code>__init__</code> function which is inherited indirectly from <code>BaseRequestHandler</code>.</p>
<pre><code>class RequestHandler(SimpleXMLRPCRequestHandler):
def __init__(self, req... | 2 | 2010-06-08T18:17:55Z | [
"python",
"ip-address",
"xml-rpc",
"simplexmlrpcserver"
] |
IP address of client in Python SimpleXMLRPCServer? | 2,129,374 | <p>I have a <a href="http://docs.python.org/library/simplexmlrpcserver.html#SimpleXMLRPCServer.SimpleXMLRPCServer" rel="nofollow">SimpleXMLRPCServer</a> server (Python). </p>
<p>How can I get the IP address of the client in the request handler?</p>
<p>This information appears in the log. However, I am not sure how to... | 3 | 2010-01-24T23:27:18Z | 7,405,024 | <p>One way to pass the ip address to the request method is to override RequestHandler.decode_request_content.</p>
<p>decode_request_content returns a XML string.
Example:</p>
<pre><code><?xml version='1.0'?>
<methodCall>
<methodName>get_workunit</methodName>
<params>
<... | 1 | 2011-09-13T16:08:38Z | [
"python",
"ip-address",
"xml-rpc",
"simplexmlrpcserver"
] |
Dynamically assign special methods to objects but not classes in Python | 2,129,643 | <p>I would like to do the following:</p>
<pre><code>class A(object): pass
a = A()
a.__int__ = lambda self: 3
i = int(a)
</code></pre>
<p>Unfortunately, this throws:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string or a nu... | 4 | 2010-01-25T01:06:43Z | 2,129,652 | <p>Python always looks up special methods on the class, not the instance (except in the old, aka "legacy", kind of classes -- they're deprecated and have gone away in Python 3, because of the quirky semantics that mostly comes from looking up special methods on the instance, so you really <strong>don't</strong> want to... | 8 | 2010-01-25T01:12:09Z | [
"python",
"dynamic",
"methods"
] |
Dynamically assign special methods to objects but not classes in Python | 2,129,643 | <p>I would like to do the following:</p>
<pre><code>class A(object): pass
a = A()
a.__int__ = lambda self: 3
i = int(a)
</code></pre>
<p>Unfortunately, this throws:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string or a nu... | 4 | 2010-01-25T01:06:43Z | 2,129,656 | <p>The only recourse that works for new-style classes is to have a method on the class that calls the attribute on the instance (if it exists):</p>
<pre><code>class A(object):
def __int__(self):
if '__int__' in self.__dict__:
return self.__int__()
raise ValueError
a = A()
a.__int__ = l... | 2 | 2010-01-25T01:12:48Z | [
"python",
"dynamic",
"methods"
] |
Dynamically assign special methods to objects but not classes in Python | 2,129,643 | <p>I would like to do the following:</p>
<pre><code>class A(object): pass
a = A()
a.__int__ = lambda self: 3
i = int(a)
</code></pre>
<p>Unfortunately, this throws:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string or a nu... | 4 | 2010-01-25T01:06:43Z | 2,130,575 | <p>I have nothing to add about the specifics of overriding <code>__int__</code>. But I noticed one thing about your sample that bears discussing.</p>
<p>When you manually assign new methods to an object, "self" is <em>not</em> automatically passed in. I've modified your sample code to make my point clearer:</p>
<pr... | 0 | 2010-01-25T06:21:27Z | [
"python",
"dynamic",
"methods"
] |
How can I set up Celery to call a custom initialization function before running my tasks? | 2,129,820 | <p>I have a Django project and I'm trying to use Celery to submit tasks for background processing ( <a href="http://ask.github.com/celery/introduction.html">http://ask.github.com/celery/introduction.html</a> ). Celery integrates well with Django and I've been able to submit my custom tasks and get back results.</p>
<p... | 15 | 2010-01-25T02:07:42Z | 2,145,587 | <p>You can either write a custom loader, or use the signals.</p>
<p>Loaders have the <code>on_task_init</code> method, which is called when a task is about to be executed,
and <code>on_worker_init</code> which is called by the celery+celerybeat main process.</p>
<p>Using signals is probably the easiest, the signals a... | 13 | 2010-01-27T09:07:57Z | [
"python",
"django",
"daemon",
"amqp",
"celery"
] |
Classes, methods, and polymorphism in Python | 2,129,891 | <p>I made a module prototype with the aim of building complex timer schedules in python. The class prototypes emulate Timer objects, each with their waiting times, Repeat objects that group Timer and other Repeat objects, and a Schedule class, just for holding a whole construction or Timers and Repeat instances. The co... | 3 | 2010-01-25T02:29:22Z | 2,129,921 | <p>This is called <a href="http://en.wikipedia.org/wiki/Duck_typing" rel="nofollow">duck typing</a> and it's used in Python <em>all the time</em>.</p>
| 3 | 2010-01-25T02:41:40Z | [
"python",
"oop",
"timer",
"polymorphism"
] |
Classes, methods, and polymorphism in Python | 2,129,891 | <p>I made a module prototype with the aim of building complex timer schedules in python. The class prototypes emulate Timer objects, each with their waiting times, Repeat objects that group Timer and other Repeat objects, and a Schedule class, just for holding a whole construction or Timers and Repeat instances. The co... | 3 | 2010-01-25T02:29:22Z | 2,130,019 | <p>It is indeed used all the time and is perfectly fine. If you want to be really careful, you can use <code>hasattr</code> to make sure the object you expect to have a <code>run</code> method actually has one fairly early on. That helps makes sure exceptions get thrown as close to the point of error as possible.</p>... | 2 | 2010-01-25T03:20:47Z | [
"python",
"oop",
"timer",
"polymorphism"
] |
Classes, methods, and polymorphism in Python | 2,129,891 | <p>I made a module prototype with the aim of building complex timer schedules in python. The class prototypes emulate Timer objects, each with their waiting times, Repeat objects that group Timer and other Repeat objects, and a Schedule class, just for holding a whole construction or Timers and Repeat instances. The co... | 3 | 2010-01-25T02:29:22Z | 2,131,162 | <p>The duck-typing-based approach is fine. If you want to be able to check if a given class is supposed to run in your framework, you can use <a href="http://docs.python.org/library/abc.html">Abstract Base Classes</a> (needs Python 2.6). PEP 3119 states:</p>
<blockquote>
<p>[...] there are many different ways to tes... | 5 | 2010-01-25T09:02:58Z | [
"python",
"oop",
"timer",
"polymorphism"
] |
copying functions located in instances | 2,129,930 | <p>Here's some (simplified) code for what I'm trying to do:</p>
<pre><code>class a:
pass
class b:
def printSelf(self):
print self
instOfA = a()
instOfB = b()
instOfA.printSelf = instOfB.printSelf
instOfA.printSelf()
<__main__.b instance at 0x0295D238>
</code></pre>
<p>When I call instOfA.pr... | 2 | 2010-01-25T02:44:16Z | 2,129,973 | <p>You can use the descriptor of the method to get a bound method:</p>
<pre><code>instOfA.printSelf = b.printSelf.__get__(instOfA)
</code></pre>
<p>Of course, you can use <code>__class__</code> if you don't know the type of instOfB:</p>
<pre><code>instOfA.printSelf = instOfB.__class__.printSelf.__get__(instOfA)
</co... | 2 | 2010-01-25T03:01:30Z | [
"python",
"function",
"self",
"multiple-instances"
] |
copying functions located in instances | 2,129,930 | <p>Here's some (simplified) code for what I'm trying to do:</p>
<pre><code>class a:
pass
class b:
def printSelf(self):
print self
instOfA = a()
instOfB = b()
instOfA.printSelf = instOfB.printSelf
instOfA.printSelf()
<__main__.b instance at 0x0295D238>
</code></pre>
<p>When I call instOfA.pr... | 2 | 2010-01-25T02:44:16Z | 2,130,165 | <p>The issue is that <code>instOfB.printSelf</code> is a <em>bound method</em> - the <code>self</code> variable is set to be instOfB when you create the object. What I would do, frankly, is just to set up the function slightly differently:</p>
<pre><code>class b:
def printSelf(self, other):
print other
</c... | 0 | 2010-01-25T04:18:35Z | [
"python",
"function",
"self",
"multiple-instances"
] |
pyinstaller exe's not dying after sys.exit() | 2,129,935 | <p>I have a cherrypy app compiled with pyinstaller. One function does the following:</p>
<pre><code>cherrypy.engine.stop()
sys.exit()
</code></pre>
<p>the cherrypy engine stops without problem, but the process doesn't actually die and I can't figure out why. </p>
| 4 | 2010-01-25T02:46:12Z | 2,129,985 | <p>One thing to keep in mind: sys.exit() doesn't actually kill the process: it raises SystemExit, which usually results in the process ending, but doesn't have to.</p>
| 0 | 2010-01-25T03:07:15Z | [
"python",
"pyinstaller"
] |
pyinstaller exe's not dying after sys.exit() | 2,129,935 | <p>I have a cherrypy app compiled with pyinstaller. One function does the following:</p>
<pre><code>cherrypy.engine.stop()
sys.exit()
</code></pre>
<p>the cherrypy engine stops without problem, but the process doesn't actually die and I can't figure out why. </p>
| 4 | 2010-01-25T02:46:12Z | 2,136,632 | <p>Try with os._exit(), which is a real system exit. I can't see why PyInstaller should change a thing when it comes to process quitting, though.</p>
| 1 | 2010-01-25T23:57:23Z | [
"python",
"pyinstaller"
] |
django error in my code ,what does i do | 2,129,992 | <pre><code>from django.core.management import setup_environ
from register2 import settings
setup_environ(settings)
from django import forms
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import ugettext_lazy as _
class AuthenticationRememberMeForm ( AuthenticationForm ):
... | 0 | 2010-01-25T03:09:16Z | 2,130,738 | <p>The django <code>forms</code> module uses a metaclass to facilitate declarative syntax for form fields. As a consequence, you should consider <code>remember_me</code> to be a <em>field</em> of your form <em>instance</em>, not a class attribute. So accessing the field as so makes sense:</p>
<pre><code>form = Authent... | 1 | 2010-01-25T07:05:19Z | [
"python",
"django"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,130,027 | <p>Uses <a href="http://docs.python.org/library/itertools.html#recipes" rel="nofollow"><code>grouper()</code></a>:</p>
<pre><code>def chunks(seq, num):
return grouper(int(math.ceil(len(seq) / float(num))), seq)
</code></pre>
| 3 | 2010-01-25T03:23:26Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,130,035 | <p>Here's one that could work:</p>
<pre><code>def chunkIt(seq, num):
avg = len(seq) / float(num)
out = []
last = 0.0
while last < len(seq):
out.append(seq[int(last):int(last + avg)])
last += avg
return out
</code></pre>
<p>Testing:</p>
<pre><code>>>> chunkIt(range(10), 3)
[[0, 1, 2], ... | 29 | 2010-01-25T03:27:31Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,130,042 | <p>Changing the code to yield <code>n</code> chunks rather than chunks of <code>n</code>:</p>
<pre><code>def chunks(l, n):
""" Yield n successive chunks from l.
"""
newn = int(len(l) / n)
for i in xrange(0, n-1):
yield l[i*newn:i*newn+newn]
yield l[n*newn-newn:]
l = range(56)
three_chunks ... | 14 | 2010-01-25T03:30:11Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,130,055 | <p>Here is one that adds <code>None</code> to make the lists equal length</p>
<pre><code>>>> from itertools import izip_longest
>>> def chunks(l, n):
""" Yield n successive chunks from l. Pads extra spaces with None
"""
return list(zip(*izip_longest(*[iter(l)]*n)))
>>> l=range(5... | 3 | 2010-01-25T03:34:22Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,135,920 | <p>You can write it fairly simply as a list generator:</p>
<pre><code>def split(a, n):
k, m = len(a) / n, len(a) % n
return (a[i * k + min(i, m):(i + 1) * k + min(i + 1, m)] for i in xrange(n))
</code></pre>
<p>Example:</p>
<pre><code>>>> list(split(range(11), 3))
[[0, 1, 2, 3], [4, 5, 6, 7], [8, 9,... | 26 | 2010-01-25T21:48:42Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,136,090 | <p>As long as you don't want anything silly like continuous chunks:</p>
<pre><code>>>> def chunkify(lst,n):
... return [ lst[i::n] for i in xrange(n) ]
...
>>> chunkify( range(13), 3)
[[0, 3, 6, 9, 12], [1, 4, 7, 10], [2, 5, 8, 11]]
</code></pre>
| 37 | 2010-01-25T22:18:16Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 2,235,614 | <p>Have a look at <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html" rel="nofollow">numpy.split</a>:</p>
<pre><code>>>> a = numpy.array([1,2,3,4])
>>> numpy.split(a, 2)
[array([1, 2]), array([3, 4])]
</code></pre>
| 2 | 2010-02-10T09:19:37Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 9,798,464 | <p>Another way would be something like this, the idea here is to use grouper, but get rid of <code>None</code>. In this case we'll have all 'small_parts' formed from elements at the first part of the list, and 'larger_parts' from the later part of the list. Length of 'larger parts' is len(small_parts) + 1. We need to c... | 0 | 2012-03-21T04:05:55Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 18,946,327 | <p>Here's another variant that spreads the "remaining" elements evenly among all the chunks, one at a time until there are none left. In this implementation, the larger chunks occur at the beginning the process.</p>
<pre><code>def chunks(l, k):
""" Yield k successive chunks from l."""
if k < 1:
yield []
... | 0 | 2013-09-22T16:54:11Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 24,207,927 | <p>The same as <a href="http://stackoverflow.com/a/2136090/3712360">job's</a> answer, but takes into account lists with size smaller than the number of chuncks.</p>
<pre><code>def chunkify(lst,n):
[ lst[i::n] for i in xrange(n if n < len(lst) else len(lst)) ]
</code></pre>
<p>if n (number of chunks) is 7 and l... | 1 | 2014-06-13T14:37:56Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 26,021,382 | <p>Here is my solution:</p>
<pre><code> def chunks(l, amount):
if amount < 1:
raise ValueError('amount must be positive integer')
chunk_len = len(l) // amount
leap_parts = len(l) % amount
remainder = amount // 2 # make it symmetrical
i = 0
while i <... | 1 | 2014-09-24T15:55:54Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 28,582,968 | <p>split=lambda x,n: x if not x else [x[:n]]+[split([] if not -(len(x)-n) else x[-(len(x)-n):],n)][0]</p>
<p>split([1,2,3,4,5,6,7,8,9],2)</p>
<p>[[1, 2], [3, 4], [5, 6], [7, 8], [9]]</p>
| 1 | 2015-02-18T11:51:38Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 29,763,631 | <p>Implementation using numpy.linspace method. </p>
<p>Just specify the number of parts you want the array to be divided in to.The divisions will be of nearly equal size.</p>
<p>Example :
</p>
<pre><code>import numpy as np
a=np.arange(10)
print "Input array:",a
parts=3
i=np.linspace(np.min(a),np.max(a)+1,par... | 0 | 2015-04-21T05:25:40Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 33,709,777 | <p>Using list comprehension:</p>
<pre><code>def divide_list_to_chunks(list_, n):
return [list_[start::n] for start in range(n)]
</code></pre>
| -1 | 2015-11-14T15:06:48Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 37,414,115 | <p>If you divide <code>n</code> elements into roughly <code>k</code> chunks you can make <code>n % k</code> chunks 1 element bigger than the other chunks to distribute the extra elements. </p>
<p>The following code will give you the length for the chunks:</p>
<pre><code>[(n // k) + (1 if i < (n % k) else 0) for i ... | 0 | 2016-05-24T12:48:57Z | [
"python",
"list",
"chunks"
] |
splitting a list of arbitrary size into only roughly N-equal parts | 2,130,016 | <p>what is the best way to divide a list into <em>roughly</em> equal parts? for example, if I have a list with 54 elements and i want to split it into 3 roughly equal parts? I'd like the parts to be as even as possible, hopefully assigning the elements that do not fit in a way that gives the most equal parts. to give ... | 46 | 2010-01-25T03:19:28Z | 38,482,118 | <p>Rounding the linspace and using it as an index is an easier solution than what amit12690 proposes.</p>
<pre><code>function chunks=chunkit(array,num)
index = round(linspace(0,size(array,2),num+1));
chunks = cell(1,num);
for x = 1:num
chunks{x} = array(:,index(x)+1:index(x+1));
end
end
</code></pre>
| 0 | 2016-07-20T13:04:20Z | [
"python",
"list",
"chunks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,130,252 | <p>A stock <code>s</code> belong in a group <code>G</code> if for each stock <code>t</code> in <code>G</code>, <code>s</code> * 1.05 >= <code>t</code> and <code>s</code> / 1.05 <= <code>t</code>, right?</p>
<p>How do we add the stocks to each group? If we have the stocks 95, 100, 101, and 105, and we start a group ... | 2 | 2010-01-25T04:47:48Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,130,314 | <p>You need to specify your problem in more detail. Just what does "put the stockprices into groups when they are within 0.5% of each other" mean?</p>
<p>Possibilities:</p>
<p>(1) each member of the group is within 0.5% of every other member of the group</p>
<p>(2) sort the list and split it where the gap is more th... | 2 | 2010-01-25T05:09:09Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,130,344 | <p>For a given set of stock prices, there is probably more than one way to group stocks that are within 0.5% of each other. Without some additional rules for grouping the prices, there's no way to be sure an answer will do what you really want.</p>
| 0 | 2010-01-25T05:20:20Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,130,388 | <p>You won't be able to classify them into hard "groups". If you have prices (1.0,1.05, 1.1) then the first and second should be in the same group, and the second and third should be in the same group, but not the first and third.</p>
<p>A quick, dirty way to do something that you might find useful:</p>
<pre><code>de... | 1 | 2010-01-25T05:35:06Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,130,405 | <p>I suggest a repeated use of <a href="http://en.wikipedia.org/wiki/K-means_clustering" rel="nofollow">k-means clustering</a> -- let's call it KMC for short. KMC is a simple and powerful clustering algorithm... but it needs to "be told" how many clusters, <code>k</code>, you're aiming for. You don't know that in adva... | 3 | 2010-01-25T05:38:57Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,132,487 | <p>apart from the proper way to pick which values fit together, this is a problem where a little Object Orientation dropped in can make it a lot easier to deal with.</p>
<p>I made two classes here, with a minimum of desirable behaviors, but which can make the classification a lot easier -- you get a single point to pl... | 0 | 2010-01-25T13:19:34Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
put stockprices into groups when they are within 0.5% of each other | 2,130,202 | <p>Thanks for the answers, I have not used StackOverflow before so I was suprised by the number of answers and the speed of them - its fantastic.</p>
<p>I have not been through the answers properly yet, but thought I should add some information to the problem specification. See the image below.</p>
<p>I can't post an... | 0 | 2010-01-25T04:32:29Z | 2,133,884 | <p>For the grouping element, could you use itertools.groupby()? As the data is sorted, a lot of the work of grouping it is already done, and then you could test if the current value in the iteration was different to the last by <0.5%, and have itertools.groupby() break into a new group every time your function retur... | 0 | 2010-01-25T16:45:44Z | [
"python",
"list",
"cluster-analysis",
"grouping",
"stocks"
] |
python Qt: main widget scroll bar | 2,130,446 | <p>We are trying to put scrollbar on the main widget, so if the user resizes the main window, the scrollbar appears, and let he move up and down to see child widgets that is outside the smaller window widget, allowing it to move right and left.</p>
<p>Here is the code for the main widget with the scroll-bar..</p>
<pr... | 1 | 2010-01-25T05:49:48Z | 2,131,371 | <p>You use <code>centralWidget</code> (which is a <code>QWidget</code>) as the central widget of the main window, the scroll area is never added to the window. Having it contain the central widget is not enough.</p>
<p>The following code has been generated by <code>pyuic</code>:</p>
<pre><code>def setupUi(self, MainW... | 1 | 2010-01-25T09:48:17Z | [
"python",
"qt",
"scrollbar",
"widget"
] |
python Qt: main widget scroll bar | 2,130,446 | <p>We are trying to put scrollbar on the main widget, so if the user resizes the main window, the scrollbar appears, and let he move up and down to see child widgets that is outside the smaller window widget, allowing it to move right and left.</p>
<p>Here is the code for the main widget with the scroll-bar..</p>
<pr... | 1 | 2010-01-25T05:49:48Z | 2,137,058 | <p>I added some of the suggestions you send me. thanks.</p>
<p>To use self.scrollArea.setWidget(self.scrollAreaWidgetContents), scrollAreaWidgetContents must be declared first. Here is the code updated -- doing everything nicely:</p>
<pre><code>def centralWDG(self,MainWindow):
self.centralwidget = QtGui.QWidget(M... | 0 | 2010-01-26T01:41:04Z | [
"python",
"qt",
"scrollbar",
"widget"
] |
Adding a string in front of a string for each item in a list in python | 2,130,552 | <p>I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. </p>
<p>n is my list of websites
h is "http"</p>
<pre><code>for p in n:
if p[0]!="h":
p= h+ p
else:
continue
return n
</co... | 8 | 2010-01-25T06:17:17Z | 2,130,567 | <p>You need to reassign the list item -- strings are immutable, so <code>+=</code> is making a new string, not mutating the old one. I.e.:</p>
<pre><code>for i, p in enumerate(n):
if not p.startswith('h'):
n[i] = 'http' + p
</code></pre>
| 4 | 2010-01-25T06:20:04Z | [
"python",
"string",
"loops",
"for-loop"
] |
Adding a string in front of a string for each item in a list in python | 2,130,552 | <p>I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. </p>
<p>n is my list of websites
h is "http"</p>
<pre><code>for p in n:
if p[0]!="h":
p= h+ p
else:
continue
return n
</co... | 8 | 2010-01-25T06:17:17Z | 2,130,577 | <p>This could also be done using list comprehension:</p>
<pre><code>n = [i if i.startswith('h') else 'http' + i for i in n]
</code></pre>
| 14 | 2010-01-25T06:22:03Z | [
"python",
"string",
"loops",
"for-loop"
] |
Adding a string in front of a string for each item in a list in python | 2,130,552 | <p>I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. </p>
<p>n is my list of websites
h is "http"</p>
<pre><code>for p in n:
if p[0]!="h":
p= h+ p
else:
continue
return n
</co... | 8 | 2010-01-25T06:17:17Z | 2,130,580 | <pre><code>n = [{True: '', False: 'http'}[p.startswith('h')] + p for p in n]
</code></pre>
<p>Don't really do this. Although it <em>does</em> work.</p>
| 0 | 2010-01-25T06:22:34Z | [
"python",
"string",
"loops",
"for-loop"
] |
Adding a string in front of a string for each item in a list in python | 2,130,552 | <p>I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. </p>
<p>n is my list of websites
h is "http"</p>
<pre><code>for p in n:
if p[0]!="h":
p= h+ p
else:
continue
return n
</co... | 8 | 2010-01-25T06:17:17Z | 2,130,618 | <pre><code>>>> n=["abcd","http","xyz"]
>>> n=[x[:1]=='h' and x or 'http'+x for x in n]
>>> n
['httpabcd', 'http', 'httpxyz']
</code></pre>
| 0 | 2010-01-25T06:31:22Z | [
"python",
"string",
"loops",
"for-loop"
] |
How to get IUnknown from WDM driver CreateInstance | 2,130,559 | <p>In documentation (C++ example)</p>
<pre><code>LUnknown* pIUnknown = CreateInstance(slot);
</code></pre>
<p>I try this </p>
<pre><code>>> import ctypes
>> print type(ctypes.cdll.lcomp.CreateInstance(0))
<type 'int'>
</code></pre>
<p>How to get IUNKNOWN and QueryInterface? </p>
| 1 | 2010-01-25T06:18:13Z | 2,130,965 | <p>I guess that accessing COM object with ctypes might be a bit difficult. I would recommend to have a look to win32com included in the windows extensions by Mark Hammond.</p>
<p>You can start with this tutorial : <a href="http://www.boddie.org.uk/python/COM.html" rel="nofollow">http://www.boddie.org.uk/python/COM.htm... | 0 | 2010-01-25T08:12:07Z | [
"python",
"com",
"ctypes",
"iunknown"
] |
How to build standalone python installation | 2,130,608 | <p>How can I build python interpreter which can be installed by just extracting the archive?</p>
<p>e.g. I want to python-2.6.tar.gz. User will extract it in any directory, and start using it.</p>
| 3 | 2010-01-25T06:30:02Z | 2,130,674 | <p>Maybe <a href="http://www.portablepython.com/wiki/Download" rel="nofollow"><code>portablepython</code></a> (currently Windows only) will help. You can try using it directly, or follow the install process to learn how to create such an environment.</p>
<blockquote>
<p>Portable Python is a Python® programming lan... | 4 | 2010-01-25T06:43:39Z | [
"python"
] |
How to build standalone python installation | 2,130,608 | <p>How can I build python interpreter which can be installed by just extracting the archive?</p>
<p>e.g. I want to python-2.6.tar.gz. User will extract it in any directory, and start using it.</p>
| 3 | 2010-01-25T06:30:02Z | 2,140,082 | <p>I went another way, on debian, and wrote a script to automate the install of python. </p>
<p>This is python-specific, but uses fabric and paramiko to deploy python on remote machines. see:</p>
<p><a href="http://bitbucket.org/chris.mahan/debian-stable-python-2.6.4-deployer/" rel="nofollow">http://bitbucket.org/chr... | 1 | 2010-01-26T14:45:07Z | [
"python"
] |
sqlite python insert | 2,130,641 | <p>I have asked similar question before , here is detailed explanation of what i'm trying to achieve </p>
<p>I have two sqlite tables<br>
table1 - is standard table - has fields like server,id,status
table2 - has fields like server,id,status,number,logfile</p>
<p>Table2 is empty and Table1 has values. I'm trying to ... | 2 | 2010-01-25T06:37:23Z | 2,130,723 | <p>This statement is broken:</p>
<pre><code>self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",(record[0],)(record[1],),(record[2],));
</code></pre>
<p>it should read:</p>
<pre><code>self.cursor.execute("insert into server_table2(server,status,id) values (?,?,?)",record[0:2])
</code></p... | 3 | 2010-01-25T07:01:49Z | [
"python",
"sqlite"
] |
Python Qt: embedded html bug? | 2,130,705 | <p>Here is a strange thing that is happening... I have used embedded html with Qt Python to display a form inside the GUI/Widget. The problem is, if the cell has more content, it shows a black shadow like a box on the right side of that cell/table.</p>
<p>Here is an example of the code working fine:</p>
<pre><code> ... | 1 | 2010-01-25T06:55:18Z | 4,237,952 | <p>If this is an exact snippet from you code then problem may be connected with the fact that you don't have closing <code></b></code> tag. If that doesn't help try removing <code><div></code> and adding <code>align='center'</code> to <code><td></code></p>
| 0 | 2010-11-21T13:01:48Z | [
"python",
"html",
"qt",
"table",
"bug-tracking"
] |
Qt: Python tcp client sends data over socket. How to read these bytes with Qt? | 2,130,757 | <p>Situation:
I have tcp client made with Python and tcp server made with Qt. I try to send bytes with my client but I can't get Qt server to read these bytes.</p>
<p>Using Python made client and server, everything works fine. Also I can get my Python client work with C# server with no problems.</p>
<p>Code for Pyth... | 1 | 2010-01-25T07:10:15Z | 2,132,441 | <p>The server code you attached works this way: Every 'packet' (logical one) is consisted of a <code>size</code> field, and following that <code>size</code> worth of data.</p>
<p>Basically it goes like this:</p>
<ol>
<li>Read a <code>quint16</code>, if there aren't
enough bytes to be read, wait for
more.</li>
<li><co... | 0 | 2010-01-25T13:10:27Z | [
"python",
"debugging",
"qt",
"sockets",
"tcp"
] |
Qt: Python tcp client sends data over socket. How to read these bytes with Qt? | 2,130,757 | <p>Situation:
I have tcp client made with Python and tcp server made with Qt. I try to send bytes with my client but I can't get Qt server to read these bytes.</p>
<p>Using Python made client and server, everything works fine. Also I can get my Python client work with C# server with no problems.</p>
<p>Code for Pyth... | 1 | 2010-01-25T07:10:15Z | 2,147,624 | <p>You need to arrange for your code to read when there is data available. From your description, there is not data available yet when startRead() runs.</p>
<p>I assume you called <code>QTcpServer::nextPendingConnection</code> to get your <code>tcpSocket</code> in <code>startRead()</code>? If not, you need to do so.</... | 1 | 2010-01-27T14:34:19Z | [
"python",
"debugging",
"qt",
"sockets",
"tcp"
] |
Persisting hashlib state | 2,130,892 | <p>I'd like to create a <code>hashlib</code> instance, <code>update()</code> it, then persist its state in some way. Later, I'd like to recreate the object using this state data, and continue to <code>update()</code> it. Finally, I'd like to get the <code>hexdigest()</code> of the total cumulative run of data. State pe... | 3 | 2010-01-25T07:54:24Z | 2,130,920 | <p>hashlib.sha1 is a wrapper around a C library so you won't be able to pickle it.</p>
<p>It would need to implement the <code>__getstate__</code> and <code>__setstate__</code> methods for Python to access its internal state</p>
<p>You could use a <a href="http://tamale.net/sha1/sha1-0.2/sha1.py" rel="nofollow">pure ... | 1 | 2010-01-25T08:03:13Z | [
"python",
"persistence",
"hash",
"pickle",
"hashlib"
] |
Persisting hashlib state | 2,130,892 | <p>I'd like to create a <code>hashlib</code> instance, <code>update()</code> it, then persist its state in some way. Later, I'd like to recreate the object using this state data, and continue to <code>update()</code> it. Finally, I'd like to get the <code>hexdigest()</code> of the total cumulative run of data. State pe... | 3 | 2010-01-25T07:54:24Z | 2,132,188 | <p>You can easily build a wrapper object around the hash object which can transparently persist the data.</p>
<p>The obvious drawback is that it needs to retain the hashed data in full in order to restore the state - so depending on the data size you are dealing with, this may not suit your needs. But it should work ... | 0 | 2010-01-25T12:30:01Z | [
"python",
"persistence",
"hash",
"pickle",
"hashlib"
] |
Persisting hashlib state | 2,130,892 | <p>I'd like to create a <code>hashlib</code> instance, <code>update()</code> it, then persist its state in some way. Later, I'd like to recreate the object using this state data, and continue to <code>update()</code> it. Finally, I'd like to get the <code>hexdigest()</code> of the total cumulative run of data. State pe... | 3 | 2010-01-25T07:54:24Z | 5,880,091 | <p><a href="http://stackoverflow.com/questions/5865824/hash-algorithm-for-dynamic-growing-streaming-data">Hash algorithm for dynamic growing/streaming data?</a></p>
| 0 | 2011-05-04T07:35:42Z | [
"python",
"persistence",
"hash",
"pickle",
"hashlib"
] |
Python Qt: Qprinter not defined | 2,130,895 | <p>I am trying to put the printer to run the output from an html document.</p>
<p>Here is a small function to do that:</p>
<pre><code>def callPrinterHtml(self,document):
self.printer = QPrinter()
self.printer.setPageSize(QPrinter.Letter)
dialog = QPrintDialog(self.printer, self)
if dialog.exec_():
... | 0 | 2010-01-25T07:55:25Z | 2,130,910 | <ol>
<li><p>Did you import the module that contains QPrinter? using an import directive?</p></li>
<li><p>Is the module containing QPrinter in your python path?</p></li>
</ol>
| 2 | 2010-01-25T08:00:05Z | [
"python",
"html",
"qt",
"document",
"printing"
] |
Google App Engine (python) authorization web services /third party client | 2,130,899 | <p>I have a google app engine project and i want to make my REST API available to third parties. Like twitter API.</p>
<p>Twitter requests the user and password to be sent so thet they can be authorized - can i do this with google user accounts? </p>
<p>I have read somewhere on this site this is not a prefered method... | 2 | 2010-01-25T07:57:58Z | 2,131,226 | <p><a href="http://oauth.net/" rel="nofollow">OAuth</a> was created with this situation in mind. It's a specification for the sort of auth-token scheme you just described, and it's <a href="http://wiki.oauth.net/ServiceProviders" rel="nofollow">reasonably widespread</a> these days.</p>
<p>For balance, see <a href="ht... | 1 | 2010-01-25T09:19:04Z | [
"python",
"google-app-engine",
"rest",
"authorization"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 2,130,963 | <p>Any errors show up? This might an issue of not having set the backend. You can set it from the Python interpreter or from a config file (<code>.matplotlib/matplotlibrc</code>) in you home directory.</p>
<p>To set the backend in code you can do</p>
<pre><code>import matplotlib
matplotlib.use('Agg')
</code></pre>
<... | 8 | 2010-01-25T08:11:54Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 2,130,968 | <p>You can type</p>
<pre><code>import pylab
pylab.show()
</code></pre>
<p>or better, use <code>ipython -pylab</code>.</p>
| 77 | 2010-01-25T08:12:35Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 2,131,021 | <p><code>pylab.show()</code> works but blocks (you need to close the window).</p>
<p>A much more convenient solution is to do <code>pylab.ion()</code> (interactive mode on) when you start: all (the pylab equivalents of) <code>pyplot.*</code> commands display their plot immediately. <a href="http://matplotlib.sourcefor... | 28 | 2010-01-25T08:27:41Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 4,839,002 | <p>Try this:</p>
<pre><code>import matplotlib
matplotlib.use('TkAgg')
</code></pre>
<p>BEFORE import pylab</p>
| 9 | 2011-01-29T19:38:33Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 6,587,966 | <p>If you encounter an issue in which <code>pylab.show()</code> freezes the ipython window (this may be Mac OS X specific; not sure), you can cmd-c in the ipython window, switch to the plot window, and it will break out. Apparently future calls to <code>pylab.show()</code> will not freeze the ipython window, only the ... | 0 | 2011-07-05T19:41:13Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 12,188,535 | <p>the code snippet below works on both Eclipse and Python Shell:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
import pylab
# Come up with x and y
x = np.arange(0, 5, 0.1)
y = np.sin(x)
# Just print x and y for fun
print x
print y
# plot the x and y and you are supposed to see a sine curve
plt.... | 5 | 2012-08-30T01:03:11Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 18,148,678 | <p>Another possibility when using easy_install is that you need to require the most recent version of matplotlib.
Try:</p>
<pre><code>import pkg_resources
pkg_resources.require("matplotlib")
</code></pre>
<p>before you import matplotlib or any of its modules.</p>
| -5 | 2013-08-09T14:10:27Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 28,300,947 | <p>If you are starting ipython with the <code>--pylab</code> option, you shouldn't need to call <code>show()</code> or <code>draw()</code>.Try this:</p>
<pre><code>ipython --pylab=inline
</code></pre>
| 0 | 2015-02-03T14:10:11Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 34,340,979 | <p><code>--pylab</code> no longer works for Jupyter, but fortunately we can add tweak <code>ipython_config.py</code> file to get both <code>pylab</code> as well as <code>autoreload</code> functionalities.</p>
<pre><code>c.InteractiveShellApp.extensions = ['autoreload', 'pylab']
c.InteractiveShellApp.exec_lines = ['%... | 0 | 2015-12-17T17:43:04Z | [
"python",
"ubuntu",
"matplotlib"
] |
No plot window in matplotlib | 2,130,913 | <p>I just installed matplotlib in Ubuntu 9.10 using the synaptic package system.
However, when I try the following simple example</p>
<pre><code>>>> from pylab import plot;
>>> plot([1,2,3],[1,2,3])
[<matplotlib.lines.Line2D object at 0x9aa78ec>]
</code></pre>
<p>I get no plot window. Any ide... | 50 | 2010-01-25T08:01:58Z | 39,996,985 | <p>Modern ipython uses the "--matplotlib" argument with an optional backend parameter. It defaults to "auto", which is usually good enough on Mac and Windows. I haven't tested it on Ubuntu or any other Linux distro, but I would expect it to work.</p>
<pre><code>ipython --matplotlib
</code></pre>
| 0 | 2016-10-12T11:02:48Z | [
"python",
"ubuntu",
"matplotlib"
] |
How can I convert a digraph to an undirected graph in networkx? | 2,131,005 | <p>I am using the networkx package. Is there a function in networkx which can do the task for me?</p>
| 5 | 2010-01-25T08:21:56Z | 2,131,042 | <p>I found the function
<a href="http://networkx.lanl.gov/reference/generated/networkx.DiGraph.to_undirected.html?highlight=digraph">http://networkx.lanl.gov/reference/generated/networkx.DiGraph.to_undirected.html?highlight=digraph</a></p>
| 5 | 2010-01-25T08:31:59Z | [
"python",
"networkx"
] |
Preprocess SHPAML in Django's template loader? | 2,131,029 | <p>Is there any way to make Django's template loader run all templates it loads (i.e. directly or via extend/include) through SHPAML if it figures the HTML is out of date?</p>
<p>I know how to invoke SHPAML recursively over an entire directory, but I would prefer to be able to run it on demand so I don't have to remem... | 3 | 2010-01-25T08:29:57Z | 2,131,679 | <p>I suspect you can achieve what you want by inheriting from <a href="http://code.djangoproject.com/browser/django/trunk/django/template/loaders/app_directories.py#L31" rel="nofollow"><code>django.template.loaders.app_directories.Loader</code></a> (or whatever loader you use) and overwriting the <code>load_template_so... | 3 | 2010-01-25T10:44:54Z | [
"python",
"django",
"templates",
"preprocessor",
"shpaml"
] |
Preprocess SHPAML in Django's template loader? | 2,131,029 | <p>Is there any way to make Django's template loader run all templates it loads (i.e. directly or via extend/include) through SHPAML if it figures the HTML is out of date?</p>
<p>I know how to invoke SHPAML recursively over an entire directory, but I would prefer to be able to run it on demand so I don't have to remem... | 3 | 2010-01-25T08:29:57Z | 2,875,840 | <p>Just created a project based on the snippet in piquadrat's answer. It's a little more feature complete and supports django 1.1 and 1.2 (probably 1.0 as well)</p>
<ul>
<li><a href="http://bitbucket.org/jiaaro/django-shpaml-template-loader/src" rel="nofollow">django-shpaml-template-loader on bitbucket</a></li>
</ul>
... | 1 | 2010-05-20T16:31:31Z | [
"python",
"django",
"templates",
"preprocessor",
"shpaml"
] |
Moving from PHP to Python | 2,131,117 | <p>Currently I do all of my web-based programming in PHP, and each day I get more and more anxious to try Python.</p>
<p>Not that I haven't played with it in an interpreter, but I mean really, write a web-based project in Python, and possibly move pretty much exclusively over to Python.</p>
<p>But, I know that Python... | 8 | 2010-01-25T08:52:03Z | 2,131,122 | <p>Have a look at <a href="http://www.djangoproject.com/" rel="nofollow">django</a> web framework.</p>
| 2 | 2010-01-25T08:53:13Z | [
"php",
"python"
] |
Moving from PHP to Python | 2,131,117 | <p>Currently I do all of my web-based programming in PHP, and each day I get more and more anxious to try Python.</p>
<p>Not that I haven't played with it in an interpreter, but I mean really, write a web-based project in Python, and possibly move pretty much exclusively over to Python.</p>
<p>But, I know that Python... | 8 | 2010-01-25T08:52:03Z | 2,131,133 | <p>Python is unlike PHP executed by a CGI like interface. This interface has an API to such variables.</p>
<p>Frameworks like <a href="http://www.djangoproject.com/" rel="nofollow">Django</a> incorporate that API. It's recommended to use such a framework which makes a lot of things easier.</p>
| 3 | 2010-01-25T08:55:02Z | [
"php",
"python"
] |
Moving from PHP to Python | 2,131,117 | <p>Currently I do all of my web-based programming in PHP, and each day I get more and more anxious to try Python.</p>
<p>Not that I haven't played with it in an interpreter, but I mean really, write a web-based project in Python, and possibly move pretty much exclusively over to Python.</p>
<p>But, I know that Python... | 8 | 2010-01-25T08:52:03Z | 2,131,136 | <p>Here are some <a href="http://wiki.python.org/moin/WebFrameworks" rel="nofollow">other web frameworks</a> for your reference.</p>
| 4 | 2010-01-25T08:55:33Z | [
"php",
"python"
] |
Moving from PHP to Python | 2,131,117 | <p>Currently I do all of my web-based programming in PHP, and each day I get more and more anxious to try Python.</p>
<p>Not that I haven't played with it in an interpreter, but I mean really, write a web-based project in Python, and possibly move pretty much exclusively over to Python.</p>
<p>But, I know that Python... | 8 | 2010-01-25T08:52:03Z | 2,131,139 | <p>Many <a href="http://wiki.python.org/moin/WebFrameworks" rel="nofollow">web frameworks</a> exist for Python, such as Django, werkzeug, etc. If you want to get "closer to the metal" then look into <a href="http://wsgi.org/" rel="nofollow">WSGI</a>.</p>
| 2 | 2010-01-25T08:56:08Z | [
"php",
"python"
] |
Creating a mock web service from a WSDL file in Python | 2,131,207 | <p>We are writing a client for a remote service that exposes SOAP web services and publishes a WSDL definition for those services. </p>
<p>We don't have access to the system during testing, so we'd like to write a mock service. We're using Python for the client, so ideally we'd want to use Python for the mock server, ... | 10 | 2010-01-25T09:14:32Z | 2,131,261 | <p>As a mock server I would really recommend soapUI (<a href="http://www.soapui.org">http://www.soapui.org</a>). </p>
<p>It takes a WSDL and generates the services and service methods automatically. You can then go on and define static returns or dynamic ones using Groovy scripts. Take a look <a href="http://www.soapu... | 8 | 2010-01-25T09:25:46Z | [
"python",
"soap",
"wsdl",
"mocking"
] |
Creating a mock web service from a WSDL file in Python | 2,131,207 | <p>We are writing a client for a remote service that exposes SOAP web services and publishes a WSDL definition for those services. </p>
<p>We don't have access to the system during testing, so we'd like to write a mock service. We're using Python for the client, so ideally we'd want to use Python for the mock server, ... | 10 | 2010-01-25T09:14:32Z | 2,131,262 | <p>I would recommend you use <a href="http://www.soapui.org/" rel="nofollow">soapUI</a> for creating a mock service. It's very easy to install. It's just as easy to create a WS mock service.
It takes the WSDL file from your desired location, it creates the structure for the requests and if you wish, it also creates th... | 4 | 2010-01-25T09:26:04Z | [
"python",
"soap",
"wsdl",
"mocking"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.