python

XML Parsing in Python using document builder factory

Hi, I am working in STAF and STAX. Here python is used for coding . I am new to python. Basically my task is to parse a XML file in python using Document Factory Parser. The XML file I am trying to parse is : <?xml version="1.0" encoding="utf-8"?> <operating_system> <unix_80sp1> <tests type="quick_sanity_test"> <prerequisi...

Opening a wx.Frame in Python via a new thread

I have a frame that exists as a start up screen for the user to make a selection before the main program starts. After the user makes a selection I need the screen to stay up as a sort of splash screen until the main program finishes loading in back. I've done this by creating an application and starting a thread: class App(wx.App): ...

How to make two elements in gtk have the same size?

I'm using pyGTK. I want to layout a large element with 2 smaller ones on each side. For aesthetic reasons, I want the 2 smaller ones to be the same size. As it is, they differ by a few pixels, and the middle element is not centered as a result. I tried using gtk.Table with 3 cells, but having homogeneous=True doesn't have the desired ef...

Two parter: Django book recommendation + Django real world advice

First question: What is your favorite Django book or online learning material? CodeProject examples + Django documentation, O'Reilly, etc. Second Question: What are some good tips and advice you have picked up along the way which helps you to use Django more effectively? Certain design patterns, language idioms, frameworks which tie ...

What is the % operator in python for?

I've seen the % operator being used in some Python code related to strings, such as: String = "Value: " % variable What does that mean? How is it different from using: String = "Value: " + variable ...

Decode complex JSON in Python

Hey, I have a JSON object created in PHP, that JSON object contains another escaped JSON string in one of it's cells: php > $insidejson = array('foo' => 'bar','foo1' => 'bar1'); php > $arr = array('a' => array('a1'=>json_encode($insidejson))); php > echo json_encode($arr); {"a":{"a1":"{\"foo\":\"bar\",\"foo1\":\"bar1\"}"}} Then, wit...

Does using properties on an old-style python class cause problems

Pretty simple question. I've seen it mentioned in many places that using properties on an old-style class shouldn't work, but apparently Qt classes (through PyQt4) aren't new-style and there are properties on a few of them in the code I'm working with (and as far as I know the code isn't showing any sorts of problems) I did run across ...

Does Django have a built in way of getting the last app url the current user visited?

I was hoping that Django had a built in way of getting the last url that was visited in the app itself. As I write this I realize that there are some complications in doing something like that (excluding pages that redirect, for example) but i thought I'd give it a shot. if there isn't a built-in for this, what strategy would you use...

Do I only need to check the users machine for the version of the MSVCR90.dll that was installed with my python installation?

I was working on an update to my application and before I began I migrated to 2.62 because it seemed to be the time to. I walked right into the issue of having problems building my application using py2exe because of the MSVCR90.dlls. There seems to be a fair amount of information on how to solve this issue, including some good answers...

python unittest assertRaises throws exception when assertRaises fails

I've got code where assertRaises throws an exception when assertRaises fails. I thought that if assertRaises fails then the test would fail and I'd get a report at the end that says the test failed. I wasn't expecting the exception to be thrown. Below is my code. I'm I doing something wrong? I'm using Python 2.6.2. import unittest ...

How do you force refresh of a wx.Panel?

Hi All, I am trying to modify the controls of a Panel, have it update, then continue on with code execution. The problem seems to be that the Panel is waiting for Idle before it will refresh itself. I've tried refresh of course as well as GetSizer().Layout() and even sent a resize event to the frame using the SendSizeEvent() method, b...

subprocess: deleting child processes in Windows

On Windows, subprocess.Popen.terminate calls win32's TerminalProcess. However, the behavior I see is that child processes of the process I am trying to terminate is still running. Why is that? How do I ensure killing every god damn processes started by the process? ...

How should I close a multi-line variable/comment in Python?

I am receiving this error: File "/DateDbLoop.py", line 33 d.Id""" % (str(day), str(2840))" ^ SyntaxError: EOL while scanning single-quoted string Here is the script. There are 4 double quotes to open this, but I am unsure how to correctly close this out? Follow Up Question: Does this % (str(day), str(2840)) need to ...

New to Python. Need info on the environment for it.

I'm a complete newbie to Python. I've worked on PHP/JavaScript earlier but starting today I'm moving onto Python. I have no idea about the environment needed for it. I could use some suggestions on it for me to get started. ...

simple wsdl python

how to write simple wsdl in python ? ...

Python Multiprocessing Exit Elegantly How?

import multiprocessing import time class testM(multiprocessing.Process): def __init__(self): multiprocessing.Process.__init__(self) self.exit = False def run(self): while not self.exit: pass print "You exited!" return def shutdown(self): self.exit = True ...

How to get a reference to the module something is implemented in from within that implementation?

Say I have the following code: from foo.bar import Foo from foo.foo import Bar __all__ = ["Foo", "Bar"] def iterate_over_all(): ... How can I implement code in the function iterate_over_all() that can dynamically obtain references to whatever is referenced in __all__ the module where the function is implemented? IE: in ite...

How do I remove packages installed with Python's easy_install?

Python's easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn't implement the other common features of a dependency manager - listing and removing installed packages. What is the best way of finding out what's installed, and what is the preferred way of removing installed packages? Are...

python String Formatting Operations

Faulty code: pos_1 = 234 pos_n = 12890 min_width = len(str(pos_n)) # is there a better way for this? # How can I use min_width as the minimal width of the two conversion specifiers? # I don't understand the Python documentation on this :( raw_str = '... from %(pos1)0*d to %(posn)0*d ...' % {'pos1':pos_1, 'posn': pos_n} Required outpu...

Classes nested in functions and attribute lookup

Hi all! The following works Ok, i.e. it doesn't give any errors: def foo(arg): class Nested(object): x = arg foo('hello') But the following throws an exception: def foo(arg): class Nested(object): arg = arg # note that names are the same foo('hello') Traceback: Traceback (most recent call last): File "...