Re: Can't use class variable with private nested class

2007-03-28 Thread tron . thomas
On Mar 27, 10:08 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: Forget all the naming silliness and use self.__class__.printOnce instead. Alex I tried self.__class__.printOnce and that worked. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list

Can't use class variable with private nested class

2007-03-27 Thread tron . thomas
The following code will print a message only once: class PrintOnce: printOnce = True def __init__(self): if PrintOnce.printOnce: print 'Printing once.' PrintOnce.printOnce = False first = PrintOnce() second =

Re: How to use pdb?

2006-07-21 Thread tron . thomas
peter wrote: I haven't tried to use pdb myself, but this looks fairly helpful ... http://www.ferg.org/papers/debugging_in_python.html good luck Peter That link was indeed helpful. I was finally able to debug the program -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use pdb?

2006-07-21 Thread tron . thomas
R. Bernstein wrote: Perhaps what you are looking for is: python /usr/lib/python2.4/pdb.py Myprogram.py I tried this and it did not work. pdb did not load the file so it could be debugged. -- http://mail.python.org/mailman/listinfo/python-list

How to use pdb?

2006-07-20 Thread tron . thomas
I am trying to figure out how to use the pdb module to debug Python programs, and I'm having difficulties. I am pretty familiar with GDB which seems to be similar, however I cannot even get the Python debugger to break into a program so I can step through it. I wrote a simple program and below

Modifying values in a list

2005-12-29 Thread tron . thomas
The following code: numbers = [1, 2, 3] for value in numbers: value *= 2 print numbers results in the following output: [1, 2, 3] The intent of the code was to produce this output: [2, 4, 6] What is the reason for the output produced? What code should be used to obtain the desired

What makes an object uncopyable?

2005-06-17 Thread tron . thomas
I am trying to make a copy of a certain Python object using the copy.copy() function. When I try to perform this operation I get an error like the following: copy.Error: un(shallow)copyable object of type ... What factors determine whether an object can be copied? --

How to implement multiple constructors

2005-05-08 Thread tron . thomas
I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something like the following: class MyClass