I am probably going about this in the wrong manner, but I was wondering how to handle this in python.
First some c code:
int i;
for(i=0;i<100;i++){
if(i == 50)
i = i + 10;
printf("%i\n", i);
}
Ok so we never see the 50's...
My question is, how can I do something similar in python? For instance:
for line in cdata.split('\...
Hey, I'm trying to create a basic program that will generate a number based on variables entered by the user. The formula is
a = b / (c * d)
This is a formula for finding specific heat, whereas b=energy, c=mass, and d= change in temperature.
So my problem is that I'm not making this program for myself, otherwise I could just assign ...
When I run Google App Engine likeso:
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Father(polymodel.PolyModel):
def hello(self):
print "Father says hi"
class Son(Father):
def hello(self):
print "Spawn says hi"
When I run, e.g.
s = Son()
s.put()
son_fr...
Scott,
I'd like to thank you for your BitString program. I am working on interpreting data from a neutron detector, and I've found that this module is just the tool I need. Unfortunately, I have yet to get the module to successfully pass test-bitstring.py. I'm running Windows XP and Python 3.1. I've downloaded your file bitstring-0.4...
lets say I have a list like so:
['one','two','three','four','five','six','seven','eight','nine']
and I want to experiment with turning this data into a HTML table of various dimensions:
one two three
four five six
seven eight nine
or
one four seven
two five eight
three six nine
or
one two three...
My class contains a socket that connects to a server. Some of the methods of the class can throw an exception. The script I'm running contains an outer loop that catches the exception, logs an error, and creates a new class instance that tries to reconnect to the server.
Problem is that the server only handles one connection at a time (...
Hi Everyone
I was wondering if there is "global counter" in Django application, like the way I store "global counter" in Servlet Context scope in Tomcat.
Thanks
something like
getServletContext().getAttribute("counter");
counter++;
...
I'm far from a python expert but I hear this one all the time, about its C/C++ bindings. How does this concept work, and how does Python (and Java) bind to C-based APIs like OpenGL? This stuff has always been a mystery to me.
...
I need to emulate "tail -f" in python, but I don't want to use time.sleep in the reading loop. I want something more elegant like some kind of blocking read, or select.select with timeout, but python 2.6 "select" documentation specifically says: "it cannot be used on regular files to determine whether a file has grown since it was last r...
I want to be able to run my Python project from the command line. I am referencing other projects, so I need to be able run modules in other folders.
One method of making this work would be to modify the Pythonpath environment variable, but I think this is an abuse. Another hack would be to copy all the files I want into a single direc...
I'm on the google appengine, and trying to resize images. I do :
from google.appengine.api import images
image = images.resize(contents, w, h)
And for some images I get a nice transparent resize, and others I get a black background.
How can I keep the transparency for all images?
Original : http://www.stdicon.com/g-flat/application...
At work I have a programming language encoded in a database record. I'm trying to write a print function in python to display what the record contains.
This is the code I'm having trouble with:
# Un-indent the block if necessary.
if func_option[row.FRML_FUNC_OPTN] in ['Endif', 'Else']:
self.indent = self.indent - 1
...
Dear python programmers,
I want to convert a perl SOAP client into a python SOAP client.
The perl client is initialized like
$url = 'https://host:port/cgi-devel/Service.cgi';
$uri = 'https://host/Service';
my $soap = SOAP::Lite
-> uri($uri)
-> proxy($url);
I tried to replicate this in python 2.4.2 with suds 0.3.6 doing
fro...
For debugging purposes, I'd like a quick way (e.g. in manage.py shell) of looking up which view that will be called as a result of a specific URL being requested.
I know this is what django.core.urlresolvers.resolve does, but when having a decorator on the view function it will return that decorator.
Example:
>>>django.core.urlresolvers...
I've killed half a day trying to compile matplotlib for python on Snow Leopard. I've used the googles and found this helpful page (http://blog.hyperjeff.net/?p=160) but I still can't get it to compile. I see comments from other users on that page, so I know I'm not alone.
I already installed zlib, libpng and freetype independently.
I...
Hi, I am trying to create a localized version of my project.
I started from the following:
mkdir my
cd my
wget http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py
After the last command I get the following message:
Warning: wildcards not supported in
HTTP.
--08:42:17-- http://svn.zope.org/checkout/zc.buil...
I'd like to test the Unicode handling of my code. Is there anything I can put in random.choice() to select from the entire Unicode range, preferably not an external module? Neither Google nor StackOverflow seems to have an answer.
Edit: It looks like this is more complex than expected, so I'll rephrase the question - Is the following co...
Hi, I have locally installed a newer version of Python. For that I did the following:
$ cd
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz
$ tar xvzf Python-2.6.2.tgz
$ cd Python-2.6.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install
In .bash_prof...
I've been working with Python for a while and I find the syntax for declaring methods as static to be peculiar.
A regular method would be declared:
def mymethod(self, params)
...
return
A static method is declared:
def mystaticethod(params)
...
return
mystaticmethod = staticmethod(mystaticmethod)
If you don't add the s...
I need to dynamically load code (comes as source), run it and get the results. The code that I load always includes a run method, which returns the needed results. Everything looks ridiculously easy, as usual in Python, since I can do
exec(source) #source includes run() definition
result = run(params)
#do stuff with result
The only pr...