Something similar to PHP's SimpleXML in Python?
Is there a way in Python to handle XML files similar to the way PHP's SimpleXML extension does them? Ideally I just want to be able to access certain xml datas from a list object. ...
Is there a way in Python to handle XML files similar to the way PHP's SimpleXML extension does them? Ideally I just want to be able to access certain xml datas from a list object. ...
I come from the Java world, where you can hide variables and functions and then run unit tests against them using reflection. I have used nested functions to hide implementation details of my classes so that only the public API is visible. I am trying to write unit tests against these nested functions to make sure that I don't break th...
Hey, In my python linux console application I use curses to handle displaying of data. At the same time I'd like to have an input line to enter commands, pretty much in good ol' irssi-style. With default curses getch() I'd have to do a lot of coding just to get the basic funcionality of raw_input function - arrow keys to move cursor / b...
I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power? UPDATE This is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works? I sent Guido van Rossum an email ca...
hi! I use something like this: screen.addstr(text, color_pair(1) | A_BOLD), but it doesn't seem to work.. However, A_REVERSE and all others attribute does work! In fact, I'm trying to print something in white, but the COLOR_WHITE prints it gray.. and after a while of searching, it seems that printing it gray + BOLD makes it! Any he...
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just technical comments...
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the ...
The list sort method is a modifier function that returns None. So if I want to iterate through all of the keys in a dictionary I cannot do: for k in somedictionary.keys().sort(): dosomething() instead, i must: keys = somedictionary.keys() keys.sort() for k in keys: dosomething() Is there a pretty way to iterate through t...
In one of my current side projects, I am scanning through some text looking at the frequency of word triplets. In my first go at it, I used the default dictionary three levels deep. In other words, topDictionary[word1][word2][word3] returns the number of times these words appear in the text, topdictionary[word1][word2] returns a dictio...
The documentation of the Python readline module says "Availability: Unix". However, it doesn't appear to be available on OS X, although other modules marked as Unix are available. Here is what I'm using: $ uname -a Darwin greg.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i38...
The topic title pretty much says it all. Does anyone know how the built in dictionary type for python is implemented? My understanding is that it is some sort of hash table, but I haven't been able to find any sort of definitive answer. ...
I'm trying to do the following in python: In a file called foo.py: # simple function that does something: def myFunction(a,b,c): print "call to myFunction:",a,b,c # class used to store some data: class data: fn = None # assign function to the class for storage. data.fn = myFunction And then in a file called bar.py: import f...
Hello, I have a list of data that looks like the following: // timestep,x_position,y_position 0,4,7 0,2,7 0,9,5 0,6,7 1,2,5 1,4,7 1,9,0 1,6,8 ... and I want to make this look like: 0, (4,7), (2,7), (9,5), (6,7) 1, (2,5), (4,7), (9,0), (6.8) My plan was to use a dictionary, where the value of t is the key for the dictionary, and t...
I need to quickly build a parser for a very simplified version of a html-like markup language in Java. In python, I would use pyparsing library to do this. Is there something similar for Java? Please, don't suggest libraries already out there for html parsing, my application is a school assignment which will demonstrate walking a tree of...
Hi. I'm giving my first steps on python... I saw that we don't have switch case statment, so I would you guys implement a text Menu in python? Thanks ...
Hi Imagine I have a file with Xpto,50,30,60 Xpto,a,v,c Xpto,1,9,0 Xpto,30,30,60 that txt file can be appended a lot of times and when I open the file I want only to get the values of the last line of the txt file... How can i do that on python? reading the last line? Thanks ...
I have a model that looks like this: class Category(models.Model): name = models.CharField(max_length=60) class Item(models.Model): name = models.CharField(max_length=60) category = models.ForeignKey(Category) I want select count (just the count) of items for each category, so in SQL it would be as simple as this: select...
I would like to draw lines (of arbitrary position and length) onto a surface in pygame, which itself is an image loaded from a file on disk. Can anyone point me to some example code that does this? ...
The last line of my file is: 29-dez,40, How can I modify that line so that it reads: 29-Dez,40,90,100,50 Note: I don't want to write a new line. I want to take the same line and put new values after 29-Dez,40, I'm new at python. I'm having a lot of trouble manipulating files and for me every example I look at seems difficult...
If I have a notebook with three spreadsheet widgets, what is the best way to have changes to the spreadsheet update a dictionary (or maybe an sqlite file?). Do all wx grid objects come with a built in dictionary related to the SetNumberRows and SetNumberCols? Basically I am looking for guidance on how to work with the user-input data f...