I have a module (tools.py) containing many classes. I'd like to extract these out into its own "whyteboard.tools" package, each class being inside its own file.
However, I previously moved from having all my classes in one base directory to being in a package below the root of my project, and had issues with loading in pickled files tha...
Just need some clarification on how to design a python script file test.py.
When defining functions, do they have to go on the top of the file right after the imports?
should I be doing that main check in my file?
I want to run this file on my server as a cron job. If the file gets too big (I have my sqlalchemy definitions in it also...
in an effort to solve question #3367795 here on SO i have to cope with a number of subproblems. one of these is: in said algorithm (levenshtein distance), several arrays are allocated in memory and initialized with the lines
cdef char *m1 = <char *>calloc( blen + 2, sizeof( char ) )
cdef char *m2 = <char *>calloc( ble...
Hey,
I am trying to solve problem 41, but i don't know why my code stops at 987654319:
def IsPandigital(No):
a = sorted(str(No))
for i in range(1,10):
if a[i - 1] != str(i):
return False
return True
def IsPrime(No):
i = 2
while i < No:
if No % i == 0:
return False
i += 1
return True
i = 987654321
while i > 0:
print i
...
If I have 177 items, and each page has 10 items that means I'll have 18 pages.
I'm new to python and having used any of the math related functions.
How can I calculate 177/10 and then get round up so I get 18 and not 17.7
...
Using Python + PyGTK.
Is there a signal/event way of checking for a window resize? If so then what is the easiest way of implementing and using this signal.
...
I'm coming from a c# background, and I do this:
Console.Write("some text" + integerValue);
So the integer automatically gets converted to a string and it outputs.
In python I get an error when I do:
print 'hello' + 10
Do I have to convert to string everytime?
How would I do this in python?
String.Format("www.someurl.com/{0}/blah...
I don't want to get into complex trigonometry to calculate rotations and things like that for my 3D world so gluLookAt seems like a nice alternative. According to the documentation all I need to do is place 3 coordinates for the cameras position, three for what I should be looking at and an "up" position. The last made no sense until I a...
I've done a mysqldump of a large database, ~300MB. It has made an error though, it has not escaped any quotes contained in any <o:p>...</o:p> tags. Here's a sample:
...Text here\' escaped correctly, <o:p> But text in here isn't. </o:p> Out here all\'s well again...
Is it possible to write a script (preferably in Python, but I'll take ...
Hello,
With this code, urllib2 make a GET request:
#!/usr/bin/python
import urllib2
req = urllib2.Request('http://www.google.fr')
req.add_header('User-Agent', '')
response = urllib2.urlopen(req)
With this one (which is almost the same), a POST request:
#!/usr/bin/python
import urllib2
headers = { 'User-Agent' : '' }
req = urllib2.Re...
I'm writing a small sqlalchemy shim to export data from a MySQL database with some lightweight data transformations—mostly changing field names. My current script works fine but requires me to essentially describe my model twice—once in the class declaration and once as a list of field names to iterate over.
I'm trying to figure out ...
I am creating a mapping application that uses a WSGI service and needs a different config file for each map. Currently, I launch the service with:
import os, sys
tilecachepath = '/usr/local/lib/python2.6/dist-packages/TileCache-2.10-py2.6.egg/TileCache'
sys.path.append(tilecachepath)
from TileCache.Service import Service, wsgiHandler
f...
Hi there,
Using SQLite and Python 3.1, I want to display currency data in a HTML table via. a template which accepts a cursor as a parameter. Hence all currency values must have 2 decimal places, but SQLite stores them as float type (even though the structure states decimal :-( ) so some must be converted before display (eg. I want 12....
Ok so I have a little test program here:
This is in my file that I load through gtk.Builder
<object class="GtkWindow" id="mainWindow">
<property name="default_width">500</property>
<property name="default_height">250</property>
<signal name="delete_event" handler="endProgram" />
</object>
I then use this:
def endProgram ...
import os
path= os.getcwd()
final= path +'\xulrunner.exe ' + path + '\application.ini'
print final
I want the out put:
c:\python25\xulrunner.exe
c:\python25\application.ini
I don't want slash to work as string, i mean don't want it to escape or do anything special. But i get an error
Invalid \x escape
How can i use a '\' ...
i made simple web server like below.
import BaseHTTPServer, os, cgi
import cgitb; cgitb.enable()
html = """
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
File upload: <input type="file" name="upfile">
<input type="submit" value="upload">
</form>
</body>
</html>
"""
class Handler(BaseHTTPServer.BaseHTTPRequ...
I'm using feincms in a django project and I want to use manage.py dumpdata but I get nothing:
python manage.py dumpdata feincms
[]
...
The script I ran
# p2e_simple_con.py
# very simple script to make an executable file with py2exe
# put this script and your code script into the same folder
# run p2e_simple_con.py
# it will create a subfolder 'dist' where your exe file is in
# has the same name as the script_file with extension exe
# (the other subfolder 'build' can be...
I know that .index() will return where a substring is located in python.
However, what I want is to find where a substring is located for the nth time, which would work like this:
>> s = 'abcdefacbdea'
>> s.index('a')
0
>> s.nindex('a', 1)
6
>>s.nindex('a', 2)
11
Is there a way to do this in python?
...
I need to convert (0, 128, 64) to something like this #008040. I'm not sure what to call the latter, making searching difficult.
...