Re: [Tutor] Printing the code of a function

2008-12-28 Thread wormwood_3
I actually didn't have a definite use case in mind, it was pure curiosity that arose while writing a few simple test functions. After having considered it more, I can't come up with a case where it would really be necessary, so I apologize for that. It makes sense why it wouldn't be possible wit

Re: [Tutor] Exception Handling

2008-12-28 Thread bob gailer
David wrote: David wrote: Hi, Is this the correct way to handle a ValueError exception and should I get in the practice of catching them? Well yes and no. I think it is better to use the string method isdigit to test for digits only. Also IMHO it is bad design to put a lot of code inside

Re: [Tutor] Printing the code of a function

2008-12-28 Thread bob gailer
wormwood_3 wrote: Hello all, This might be trivially easy, but I was having a hard time searching on it since all the component terms are overloaded:-) I am wondering if there is a way to print out the code of a defined function. Python does not store the source when compiling thing

Re: [Tutor] Printing the code of a function

2008-12-28 Thread Michiel Overtoom
wormwood_3 wrote: > I am wondering if there is a way to > print out the code of a defined function. When Python compiles source code, it doesn't store the source code itself; only the compiled intermediate code. With the 'dis' package you can disassemble that: def foo(): print "Show me

[Tutor] Printing the code of a function

2008-12-28 Thread wormwood_3
Hello all, This might be trivially easy, but I was having a hard time searching on it since all the component terms are overloaded:-) I am wondering if there is a way to print out the code of a defined function. So if I have: def foo(): print "Show me the money." then I would like to do so

Re: [Tutor] Exception Handling

2008-12-28 Thread David
David wrote: Hi, Is this the correct way to handle a ValueError exception and should I get in the practice of catching them? Also any suggestions on the program. thanks -david Might help if I included the program :) #!/usr/bin/python import time print "Enter year as " print "Enter month

[Tutor] Exception Handling

2008-12-28 Thread David
Hi, Is this the correct way to handle a ValueError exception and should I get in the practice of catching them? Also any suggestions on the program. thanks -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist

Re: [Tutor] Fwd: Class Extend Help

2008-12-28 Thread Omer
Thx for help, extreme lack of free time lately, will look into it. [Wouldn't've noticed myself that urlopen is not a class.] On Tue, Dec 23, 2008 at 6:03 PM, Richard Lovely wrote: > OK, going on Kent's post: > > from urllib import urlopen > > class fetch(object): >def __init__(self, *args):

Re: [Tutor] telnetlib unable to cath gaierror

2008-12-28 Thread spir
Le dimanche 28 décembre 2008 à 10:17 -0800, Steve Willoughby a écrit : > On Sun, Dec 28, 2008 at 07:09:51PM +0100, Sander Sweers wrote: > > I am having issues cathing exceptions from telnetlib. What I am doing is: > > except gaierror: > > Which gives me "NameError: name 'gaierror' is not defined" :

Re: [Tutor] telnetlib unable to cath gaierror

2008-12-28 Thread Sander Sweers
On Sun, Dec 28, 2008 at 19:17, Steve Willoughby wrote: > On Sun, Dec 28, 2008 at 07:09:51PM +0100, Sander Sweers wrote: >> I am having issues cathing exceptions from telnetlib. What I am doing is: >> except gaierror: >> Which gives me "NameError: name 'gaierror' is not defined" :-( > > This error

Re: [Tutor] telnetlib unable to cath gaierror

2008-12-28 Thread Steve Willoughby
On Sun, Dec 28, 2008 at 07:09:51PM +0100, Sander Sweers wrote: > I am having issues cathing exceptions from telnetlib. What I am doing is: > except gaierror: > Which gives me "NameError: name 'gaierror' is not defined" :-( This error message contains your clue. If the name you're referencing is n

[Tutor] telnetlib unable to cath gaierror

2008-12-28 Thread Sander Sweers
Hello All, I am having issues cathing exceptions from telnetlib. What I am doing is: - tc = telnetlib.Telnet() try: tc.open('abc') except gaierror: print 'Invalid hostname' - Which gives me "NameError: name 'gaierror' is not define

Re: [Tutor] Redux: optparse

2008-12-28 Thread Kent Johnson
On Sat, Dec 27, 2008 at 2:55 PM, Matt Herzog wrote: > What I can't figure out now is how to pass a compiled regex to an optparse > option. I'm confused ias to "option" versus "arg" when using the optparse > module. In fact there seems to be no way to define what the arg should be; > only option

Re: [Tutor] Anagram creator

2008-12-28 Thread spir
Le samedi 27 décembre 2008 à 19:32 -0500, btk...@email.unc.edu a écrit : > Hi everyone, > > I'm having trouble with an anagram generating program that I am writing > in Python. My output is not what it should be and I think the reason > has something to do with my helper functions creating a re