Python execution
Is it possible for a python script to execute at a low run level? Edit: To clarify, is it possible for a python script to run in the background, kind of like a daemon. ...
Is it possible for a python script to execute at a low run level? Edit: To clarify, is it possible for a python script to run in the background, kind of like a daemon. ...
I want to delete all files with the extension bak in a directory. How can I do that in Python? ...
In Python, is there any difference between creating a generator object through a generator expression versus using the yield statement? Using yield: def Generator(x, y): for i in xrange(x): for j in xrange(y): yield(i, j) Using generator expression: def Generator(x, y): return ((i, j) for i in xrange(x) f...
How can I use buildbot's IRC bot to connect to an IRC server that wants SSL connections? ...
I would like to create a number like: 000000000001 to save to the database. I obviously cannot increment in this fashion (I don't think) in a database, so I'm looking for the most efficient method for pulling the previous number from the database and incrementing it by 1 to create the next record: 000000000002 and so on... If I st...
I need to turn a formatted integer into a regular integer: 000000000001 needs to be turned into 1 000000000053 needs to be turned into 53 000000965948 needs to be turned into 965948 And so on. It seems that a simple int(000000000015) results in the number 13. I understand there is some weird stuff behind the scenes. What is the be...
I need it to show: 49 as 49.00 and: 54.9 as 54.90 I need it to have no limitations on length (ie, a trillion dollars), but still always have just 2 decimal places so that it is formatted like money (without the dollar sign): eg, 4898489.00 Is this efficient, BTW? ...
Right now I use the parameter object's class to be inherited like so class A(): def __init__(self,p1,p2): self.p1, self.p2 = p1, p2 class B(A): def __init__(self,b): self.p1, self.p2 = b.p1, b.p2 This trims up the absurdity of using the code but not the class code itself. So, I'd like to do the C++ thing and p...
Just about everyone uses them, but many, including me simply take it for granted that they just work. I am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me. Now, C++ is probably a good place to start since you can throw anything in that language. Also, C is close to...
hi, I am looking for a way to create a border in python.Is there any library in Python which we can import to create a border. Note that I do not want to use any image masks to create this effect (e.g. I don't want to use any image editing package like GIMP to create a border image mask) . Here is what I am looking for: import fooIm...
The question is to find the 1000th prime number. I wrote the following python code for this. The problem is, I get the right answer for the 10th , 20th prime but after that each increment of 10 leaves me one off the mark. I can't catch the bug here :( count=1 #to keep count of prime numbers primes=() #tuple to hold p...
Our application's "documents" are single binary files. Our customers have asked if we can add MS Office-like document properties to our document files so that they are easier for users to manage. By easier to manage, I mean the ability for Windows Explorer to display common document properties in tooltips. My research seems to indicate...
Hi all, I am new to python and programming, I am looking for a code, or a sample code that can have a predefined set of hex values and that can find the 3 used values within to generate a certain value. lets say I have a value of : 0x50158A51 this is a 4 byte (32 bit) hex value now i need to find the values which when added or subt...
MVC 'architecture'. I would like a convenient way of specifying the rules of a card game including aspects such as hands or tricks, scoring, which cards from the deck or pack are used, and so on. Does anyone know of anything like this, preferably in Javascript? Thanks for any guidance. ...
I am currently writing a fsm editor with tkinter. But, I stuck on connecting two states. I have two questions: 1) How can make the transition arrow growable according to mouse movement? 2) How can I stick the starting point of the arrow on a state and the end point of the arrow on another state? PS. Do you think the documentation of t...
thought i would write some quick code to download the number of 'fans' a page had of fb, just b/c i thought would be interested to get a handle on the regex search in python. for some reason despite a fair number of iterations i've tried, i cant get the following code to pick out the number of fans in the html - none of the other solut...
Hi I've this simple problem, I can grab the event of a click on button, but now I need to handle a click over a widget, here is part of the code: self.widget = QtGui.QWidget(self) self.widget.setStyleSheet("QWidget { background-color: %s }" % color.name()) self.widget.setGeometry(150, 22, 50, 50) self.connect(???) well, what should i...
I'm working through a Python 3 book and came across the string function isidentifier(). The text description is "s.isidentifier() : Returns True if s is non empty and is a valid identifier". I tested it in the Python Shell like this: >>> s = 'test' >>> s.isidentifier() True >>> 'blah'.isidentifier() True I would expect the 2nd state...
How can I get the output of a process run using subprocess.call()? Passing a StringIO.StringIO object to stdout gives this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 444, in call return Popen(*popenargs,...
Hi, I want to retrieve the bit depth for a jpeg file using Python. Using the Python Imaging Library: import Image data = Image.open('file.jpg') print data.depth However, this gives me a depth of 8 for an obviously 24-bit image. Am I doing something wrong? Is there some way to do it with pure Python code? Thanks in advance. Edit: It...