So if I have 2 files that look like this:
File 1
import class1
import method1
def method2(something):
result = method1(classname=class1)
File 2
def method1(classname):
some_result = classname.resultfinder
return some_result
Will this work?
I mean, since I am not importing class1 in the file where method1 lives, but m...
I am trying to use use the XML/SWF Charts library with cherrypy. I want to generate html reports with nice looking charts.
I am trying to expose one of the default examples of XML/SWF charts with cherryPy, but for some reason the javascript is not working properly with cherryPy.
I created the following python script:
import os.path
i...
This is on PyQt4, Linux and Python 2.5
Can I make PyQt set my window "always on top" over other applications?
For example, in GTK i use the property: Modal.
Now, in PyQt I am using a QWidget, but, I can't find a way to do that.
Any ideas??
...
Hey guys,
I need a functions that iterates over all the lines in the file.
Here's what I have so far:
def LineFeed(file):
ret = ""
for byte in file:
ret = ret + str(byte)
if str(byte) == '\r':
yield ret
ret = ""
All the lines in the file end with \r (not \n), and I'm reading it in "rb" mode, (I have to ...
Hello,
i am trying to read a tree structure file in python.
I created a class to hold the tree objects. One of the members
should hold the parent object.
Since the parentObject member is of the same type as the class itself,
I need to declare this as an empty variable of type "self".
How do I do that in python?
Thank you very much ...
I have been writing a program that searches a file in 3 different ways. But firstly, to choose which search program to use is differentiated in the command line.
For example in the command line I type:
Program 1 search: python file.py
'search_term' 'file-to-be-searched'
program 2 search: python file.py -z
'number' 'search_t...
I am looking for a rules engine in C or Python, but if you know a rules engine that is implemented in another language I would be glad to know about it.
The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc. So no "office" rules there (aka do you rules in Excel or such).
I have l...
I have a website that processes user submitted documents in a variety of ways, one of which is to do a spell check on a part of each document. When I set this website up on a Mac Mini (yes, I realize that's a pretty weak piece of equipment for a website, but it's internal and no one outside the office sees it), I remember having some tr...
I have built an XML-RPC interface in Python and I need to enforce some stricter typing. For example, passing string '10' instead of int 10. I can clean this up with some type casting and a little exception handling, but I am wondering if there is any other way of forcing type integrity such as something XML-RPC specific, a decorator, o...
I'm writing a cross-platform python script that needs to know if and where Cygwin is installed if the platform is NT. Right now I'm just using a naive check for the existence of the default install path 'C:\Cygwin'. I would like to be able to determine the installation path programmatically.
The Windows registry doesn't appear to be an ...
What is the "correct" way of detecting and handling an exception in another thread in Python, when the code in that other thread is not under your control?
For instance, say you set a function that requires 2 parameters as the target of the threading.Thread object, but at runtime attempt to pass it 3. The Thread module will throw an exc...
I've used two different python oauth libraries with Django to authenticate with twitter. The setup is on apache with WSGI. When I restart the server everything works great for about 10 minutes and then the httplib seems to lock up (see the following error).
I'm running only 1 process and 1 thread of WSGI but that seems to make no diff...
I had never worked with the datetime module in Python 2.3, and I have a very silly problem. I need to read a date in the format
'10-JUL-2010'
then subtract a day (I would use timedelta), and return the string
'09-JUL-2010 00:00:00 ET'
of course, this is for hundreds of dates. While it should be trivial, I cannot find the info on ...
We're considering re-factoring a large application with a complex GUI which is isolated in a decoupled fashion from the back-end, to use the new (Python 2.6) multiprocessing module. The GUI/backend interface uses Queues with Message objects exchanged in both directions.
One thing I've just concluded (tentatively, but feel free to confi...
I need major help getting started! I managed to create a new project, and add python.exe as the interpreter. But when the project is created it's blank. How do I start programming? Ugh.
...
I'm having a puzzling problem when trying to import a module in python only when the script is called from php via system or exec.
From the python shell:
import igraph #This works.
if the previous line was in a file, say, test_module.py, then:
python test_module.py in the bash works.
Within PHP:
exec("python test_module.py",$output,...
My code:
print "Hello World!"
I even tried adding a semicolon behind, but everytime I save and run (as Python run) it says:
File "E:\Software\Eclipse\Workspace\Python1\src\main.py", line 1
print "Hello World!";
SyntaxError: invalid syntax
I have no idea why.
...
Hello,
I need some code to get the address of the socket i just created (to filter out packets originating from localhost on a multicast network)
this:
socket.gethostbyname(socket.gethostname())
works on mac but it returns only the localhost IP in linux... is there anyway to get the LAN address
thanks
--edit--
is it possible to ge...
I'm not used to doing things the python way yet, but I'm almost certain the following script can be condensed. I'm not looking for speed optimization here, I'm looking for more readable code. Make it slower for all I care, but what are some ways to make this look more Python-esque.
I'm simply reading in a csv file filled with zipcodes a...
I heard that Python is easy and powerful, but I don't know if I'm on the right track to learning it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
...