How do I create a datetime in Python from milliseconds?
I can create a similar Date object in Java by java.util.Date(milliseconds). How do I create the comparable in Python? ...
I can create a similar Date object in Java by java.util.Date(milliseconds). How do I create the comparable in Python? ...
hello there to all, well, I am not a Programming guru in python but manage to write some of them :) The one I am writing is finding and removing the duplicate files from the folder. I have multiple copies of mp3 files, and same is the case with other files. So if anyone can help solving this problem then I will be thankful. I am using sh...
Hi, I have a small project that uses libglade and use the following to load the xml file: self.gladefile = "sdm.glade" self.wTree = gtk.glade.XML(self.gladefile) self.window = self.wTree.get_widget("MainWindow") if (self.window): self.window.connect("destroy", gtk.main_quit) dic = { "on_button1_clicked" : self.button1_clicked, ...
How can I create a bulleted list in ReportLab? The documentation is frustratingly vague. I am trying: text = ur ''' <para bulletText="•"> item 1 </para> <para bulletText="•"> item 2 </para> ''' Story.append(Paragraph(text,TEXT_STYLE)) But I keep getting errors like list index out of range. It seems that I can't put more than...
I have a model which has a required string property like the following: class Jean(db.Model): sex = db.StringProperty(required=True, choices=set(["male", "female"])) When I try calling Jean.all(), python complains about not having a required property. Surely there must be a way to get all of them. If Steve is correct (his answer...
I have a model which is essentially just a string (django.db.models.CharField). There will only be several instances of this model stored. How could I use those values as choices in a form? To illustrate, the model could be BlogTopic. I'd like to offer users the ability to choose one or several topics to subscribe to. I started writing...
I have a simple python script like so: import sys lines = sys.argv[1] for line in lines.splitlines(): print line I want to call it from the command line (or a .bat file) but the first argument may (and probably will) be a string with multiple lines in it. How does one do this? Of course, this works: import sys lines = """This...
Hello. In python, assignment operator can unpack list or tuple into variables, like this: l = (1, 2) a, b = l # here goes auto unpack But i need to specify exactly same amount of names to the left as an items count in the list to the right. But sometimes i don't know a size of the list to the right, for example if i use split(). Examp...
Given a gettext Plural-Forms line, general a few example values for each n. I'd like this feature for the web interface for my site's translators, so that they know which plural form to put where. For example, given: "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" "10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"...
Given these 3 lists of data and a list of keywords: good_data1 = ['hello, world', 'hey, world'] good_data2 = ['hey, man', 'whats up'] bad_data = ['hi, earth', 'sup, planet'] keywords = ['world', 'he'] I'm trying to write a simple function to check if any of the keywords exist as a substring of any word in the data lists. It should ret...
I have a file containing 800 lines like: id binary-coded-info --------------------------- 4657 001001101 4789 110111111 etc. where each 0 or 1 stands for the presence of some feature. I want to read this file and do several bitwise logical operations on the binary-coded-info (the operations depend on user input and on in...
What's a good way to estimate the memory footprint of an object? Conversely, what's a good way to measure the footprint? For example, say I have a dictionary whose values are lists of integer,float tuples: d['key'] = [ (1131, 3.11e18), (9813, 2.48e19), (4991, 9.11e18) ] I have 4G of physical memory and would like to figure out appro...
Basically I want to get a handle of the python interpreter so I can pass a script file to execute (from an external application). ...
What is the best way (or even the various ways) to pretty print xml in python? ...
I've written a little script that collects my external IP address every time I open a new terminal window and appends it, at well as the current time, to a text file. I'm looking for ideas on a way to visualize when/how often my IP address changes. I bounce between home and campus and could separate them using the script, but it would be...
How would I write a function in Python to determine if a list of filenames matches a given pattern and which files are missing from that pattern? For example: Input -> KUMAR.3.txt KUMAR.4.txt KUMAR.6.txt KUMAR.7.txt KUMAR.9.txt KUMAR.10.txt KUMAR.11.txt KUMAR.13.txt KUMAR.15.txt KUMAR.16.txt Desired Output--> KUMAR.5.txt KUMAR.8.txt KU...
Hi again, I've made a function that creates a dictionary. In my previous thread/question, Andrew Jaffe writes this: "In addition to all of the other hints and tips, I think you're missing something crucial: your functions actually need to return something. When you create autoparts() or splittext(), the idea is that this will be a fun...
Is there a good emacs mode that will allow tab-completion of local python variables? I set up ipython.el but it will only tab-complete things in the scope of the interpreter. I'm looking for something that will let me tab-complete tokens in the local namespace of a function or file. ...
Hello. Is it any way to check if a variable (class member or standalone) with specified name defined? Example: if "myVar" in myObject.__dict__ : # not an easy way print myObject.myVar else print "not defined" ...
EDIT: This question has been solved with help from apphacker and ConcernedOfTunbridgeWells. I have updated the code to reflect the solution I will be using. I am currently writing a swarm intelligence simulator and looking to give the user an easy way to debug their algorithms. Among other outputs, I feel it would be beneficial to give ...