Suppose i want to check 1.1 belongs to range 0 to 0.5 how can i do it?
with range i can do :
for i in range(0,0.5):
if i == 1.1:
print 'yes'
if i != 1.1:
print 'no'
Is ther any other way to do this ????
...
I have complex GUI application written in Python and wxPython.
I want it to be certified for Windows Vista, so it has to crash in a way that causes Windows Error Reporting dialog (The one that asks "Do you want to send report to Microsoft?") to appear. This is relevant to test case no 32 from "Certified for Windows Vista Test Cases" doc...
I wanted to cut up a string of email addresses which may be separated by any combination of commas and white-space.
And I thought it would be pretty straight-forward :
sep = re.compile('(\s*,*)+')
print sep.split("""[email protected], [email protected]
[email protected],,[email protected]""")
But it isn't. I can't find a regex that won't leave some empty slots like thi...
I'm using something like this in my template
<select multiple="multiple" name="services" id="services" size="5">
{% for service in services %}
<option value="{{service.id}}">{{service}}</option>
{% endfor %}
</select>
When I view the POST data in Firebug or the Django debug, I see it only sends one value. Am I doing som...
My application is running on Google App Engine and most of requests constantly gets yellow flag due to high CPU usage. Using profiler I tracked the issue down to the routine of creating jinja2.Environment instance.
I'm creating the instance at module level:
from jinja2 import Environment, FileSystemLoader
jinja_env = Environment(loader...
Hi!
from ipython console:
In [16]: b
Out[16]: datetime.datetime(2008, 3, 1, 0, 0)
In [17]: e
Out[17]: datetime.datetime(2010, 5, 2, 0, 0)
In [18]: rrule(MONTHLY).between(b, e, inc=True)
Out[18]:
[datetime.datetime(2009, 3, 6, 14, 42, 1),
datetime.datetime(2009, 4, 6, 14, 42, 1),
datetime.datetime(2009, 5, 6, 14, 42, 1),
datetime.da...
I started using Pyant recenently to do various build/release tasks but have recently discovered that development for this project has ended.
I did some research and can't seem to find any other Python build scripts that are comparable. Just wondering if anyone can recommend one? I basically need it to do what ANT does - do SVN updates, ...
I've been hacking classes in python like this :
def hack(f,aClass) :
class MyClass(aClass) :
def f(self) :
f()
return MyClass
A = hack(afunc,A)
Which looks pretty clean to me. It takes a class A, creates a new class derived from it, that has an extra method, calling f, and then reassigns the new clas to A.
How does t...
I'm creating an app where I drag button widgets into a panel. I would like to have a visible grid in the panel where i drop the widgets so the widgets will be aligned to the grid.
I guess it isn't hard making a grid where the squares are 15x15 pixels using a GridBagSizer(since the widgets will span between multiple cells), but how can t...
I often need to execute custom sql queries in django, and manually converting query results into objects every time is kinda painful. I wonder how fellow Slackers deal with this. Maybe someone had written some kind of a library to help dealing with custom SQL in Django?
...
From what I have seen and read on the blogs PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exer...
I want to start writing a http proxy that will modify responses according to some rules/filters I will configure. However, before I start coding it, I want to make sure I'm making the right choice in going with Python. Later, this tool would have to be able to process a lot of requests, so, I would like to know I can count on it later on...
I am writing a backup system in Python, with a Django front-end. I have decided to implement the scheduling in a slightly strange way - the client will poll the server (every 10 minutes or so), for a list of backups that need doing. The server will only respond when the time to backup is reached. This is to keep the system platform indep...
Hi,
I am creating images using PIL that contain numerous exactly placed text strings. My first attempt was to convert pixel fonts into the pil-compatible format as described here. For example, I download the Silksreen font and convert it:
otf2bdf -p 8pt -o fonts/slkscr.bdf fonts/slkscr.ttf
pilfont.py fonts/slkscr.bdf
I can then us...
Here's how my university handles authentication: we redirect the user to a website, they enter in their username and password, then they get redirected back to us with the username and a login key passed in the query string. When we get the user back, we call a stored procedure in the university's database that takes the username, logi...
Greetings.
I have written a little python script that calls MySQL in a subprocess. [Yes, I know that the right approach is to use MySQLdb, but compiling it under OS X Leopard is a pain, and likely more painful if I wanted to use the script on computers of different architectures.] The subprocess technique works, provided that I supply...
I'm hoping to make a quick script to log-out/restart windows at a set time. For example, start a script to "Restart windows in ten minutes". For this implementation I don't need it to run in the background or pop=up on its own. I just want to set the script and walk away knowing that the computer will log-out/restart at a set time.
Why...
I'm using the Python "datetime" module, i.e.:
>>> import datetime
>>> today = datetime.datetime.now()
>>> print today
2009-03-06 13:24:58.857946
and I would like to compute the day of year that is sensitive of leap years. e.g. oday (March 6, 2009) is the 65th day of 2009. Here's web-based DateTime calculator.
Anyway, I see a two opt...
I created a sub-directory of my Django project called bin where I want to put all command-line run Python scripts. Some of these scripts need to import my Django project settings.py file that is in a parent directory of bin.
How can I import the settings.py file from a sub-directory of the project?
The code that I use in my command-li...
Are there any alternatives to the code below:
startFromLine = 141978 # or whatever line I need to jump to
urlsfile = open(filename, "rb", 0)
linesCounter = 1
for line in urlsfile:
if linesCounter > startFromLine:
DoSomethingWithThisLine(line)
linesCounter += 1
if I'm processing a huge text file (~15MB) with lines o...