About getattr()

2007-02-11 Thread Jm lists
Hello, Since I can write the statement like: print os.path.isdir.__doc__ Test whether a path is a directory Why do I still need the getattr() func as below? print getattr(os.path,isdir).__doc__ Test whether a path is a directory Thanks! --

Does eval has the same features as Perl's?

2007-01-20 Thread Jm lists
Hello members, I want to know does the eval in python have the same features as in Perl (capture errors)? For example,in perl I can wrote: $re = eval { 1 / 0 }; Though 1/0 is a fatal error but since it's in eval block so the perl interpreter doesn't get exit. Thanks again. --

Re: Does eval has the same features as Perl's?

2007-01-20 Thread Jm lists
Thank you.I'm just learning Python and want to make something clear to me.:) 2007/1/20, Steven D'Aprano [EMAIL PROTECTED]: On Sat, 20 Jan 2007 17:30:24 +0800, Jm lists wrote: Hello members, I want to know does the eval in python have the same features as in Perl (capture errors

Re: Why this script can work?

2007-01-19 Thread Jm lists
due to compilation errors. 2007/1/19, Diez B. Roggisch [EMAIL PROTECTED]: Jm lists wrote: Please help with this script: class ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self,length,atleast): Exception.__init__(self

**argv can't work

2007-01-19 Thread Jm lists
hello members, See my script piece below: def testB(shift,**argv): print first argument is %s %shift print all other arguments are:,argv testB('mails','Jen','[EMAIL PROTECTED]','Joe','[EMAIL PROTECTED]') It can't work at all.please help tell me the reasons.thanks. --

Re: **argv can't work

2007-01-19 Thread Jm lists
Thanks for all the kind helps! 2007/1/20, Parthan SR [EMAIL PROTECTED]: On 1/20/07, Jm lists [EMAIL PROTECTED] wrote: hello members, See my script piece below: def testB(shift,**argv): print first argument is %s %shift print all other arguments are:,argv testB('mails

Why this script can work?

2007-01-18 Thread Jm lists
Please help with this script: class ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self,length,atleast): Exception.__init__(self) self.length=length self.atleast=atleast try: