About print exception message

2008-10-09 Thread WaterWalk
Until Python 2.5, the exception object still uses ansi string. Thus, in the following example: f = open(u\u6d4b.log) Suppose the file to open does not exist, the output message of the exception maybe like: [Errno 2] No such file or directory: u'\u6d4b.log' This is not a clear message. I

Re: About print exception message

2008-10-09 Thread WaterWalk
On Oct 9, 9:46 pm, Jean-Paul Calderone [EMAIL PROTECTED] wrote: On Thu, 9 Oct 2008 06:37:04 -0700 (PDT), WaterWalk [EMAIL PROTECTED] wrote: Until Python 2.5, the exception object still uses ansi string.  Thus, in the following example: f = open(u\u6d4b.log) Suppose the file to open does

Name lookup inside class definition

2008-06-18 Thread WaterWalk
Hello. Consider the following two examples: class Test1(object): att1 = 1 def func(self): print Test1.att1// ok class Test2(object): att1 = 1 att2 = Test2.att1 // NameError: Name Test2 is not defined It seems a little strange. Why a class name can be used in a method

Re: Name lookup inside class definition

2008-06-18 Thread WaterWalk
Ah, I see. Thank you all. -- http://mail.python.org/mailman/listinfo/python-list

unicode in exception traceback

2008-04-03 Thread WaterWalk
Hello. I just found on Windows when an exception is raised and traceback info is printed on STDERR, all the characters printed are just plain ASCII. Take the unicode character u'\u4e00' for example. If I write: print u'\u4e00' If the system locale is PRC China, then this statement will print

Re: unicode in exception traceback

2008-04-03 Thread WaterWalk
On Apr 3, 5:56 pm, Peter Otten [EMAIL PROTECTED] wrote: WaterWalk wrote: Hello. I just found on Windows when an exception is raised and traceback info is printed on STDERR, all the characters printed are just plain ASCII. Take the unicode character u'\u4e00' for example. If I write

Re: About reading Python code

2008-03-17 Thread WaterWalk
On Mar 17, 1:54 pm, Stargaming [EMAIL PROTECTED] wrote: On Sun, 16 Mar 2008 20:54:01 -0700, WaterWalk wrote: Hello. I wonder what's the effective way of figuring out how a piece of python code works. If your Python code is well-written, it should be easy figuring out what it means by just

About reading Python code

2008-03-16 Thread WaterWalk
Hello. I wonder what's the effective way of figuring out how a piece of python code works. With C I often find it very useful to be able to run the code in step mode and set breakpoints in a debugger so I can watch how the it executes, how the data change and how the code jumps from one function

Re: About reading Python code

2008-03-16 Thread WaterWalk
On Mar 17, 11:54 am, WaterWalk [EMAIL PROTECTED] wrote: Hello. I wonder what's the effective way of figuring out how a piece of python code works. With C I often find it very useful to be able to run the code in step mode and set breakpoints in a debugger so I can watch how the it executes

Python's only one way to do it philosophy isn't good?

2007-06-08 Thread WaterWalk
I've just read an article Building Robust System by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: Indeed, one often hears arguments against building exibility into an engineered sys-

Make Tkinter canvas respond to MouseWheel event

2007-02-28 Thread WaterWalk
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget receives this event and the result showed that only the top Tk widget gets it. This is really annoying.

Re: I'm having trouble understanding scope of a variable in a subclass

2006-12-28 Thread WaterWalk
Pyenos wrote: Approach 1: class Class1: class Class2: def __init__(self):self.variable=variable class Class3: def method():print Class1().Class2().variable #problem Approach 1.1: class Class1: class Class2:

Re: Noobie: Open file - read characters multiply

2006-12-26 Thread WaterWalk
gonzlobo wrote: I've been using Python for a few days. It's such the perfect language for parsing data! I really like it so far, but I'm having a hard time reading a file, reading the first few hex characters converting them to an integer. Once the characters are converted to an integer,

Re: Noobie: Open file - read characters multiply

2006-12-26 Thread WaterWalk
WaterWalk wrote: gonzlobo wrote: I've been using Python for a few days. It's such the perfect language for parsing data! I really like it so far, but I'm having a hard time reading a file, reading the first few hex characters converting them to an integer. Once the characters

Re: Noobie: Open file - read characters multiply

2006-12-26 Thread WaterWalk
WaterWalk wrote: WaterWalk wrote: gonzlobo wrote: I've been using Python for a few days. It's such the perfect language for parsing data! I really like it so far, but I'm having a hard time reading a file, reading the first few hex characters converting them to an integer

Re: Why does Python never add itself to the Windows path?

2006-12-25 Thread WaterWalk
Ben Sizer wrote: I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH environment variable. Every time, I've had to go through and add this by hand, to

Emulate @classmethod using decorator and descriptor

2006-12-12 Thread WaterWalk
Hello, I was recently learning python decorator and descriptor and emulated a @classmethod decorator: class EmuClassMethod(object): def __init__(self, f=None): self.f = f def __get__(self, obj, klass=None): if klass is None: klass = type(obj) def