Michael Yanowitz wrote: > Hello: > > I know this will probably turn about to be another dumb question > and I know I have asked a few really dumb ones lately on this list, > but I am hoping otherwise this time: > > suppose I type: > ip = 123.45.67.89 > (no quotes) > - is it possible (maybe by catching an exception), to have this > automatically converted to an ip address and maybe have the exception > convert this into: > ip = make_ip_address (123, 45, 67, 89) > > Or even better, if possible. Can I define my own type > IP = BYTE + '.' + BYTE + '.' + BYTE + '.' + BYTE > BYTE = in range(256) > and have Python over-ride its rules so that if I type in a number > followed by a dot followed by number followed by a dot followed by a > number followed by a dot and another number, it can call > make_ip_address() on the value? > No, because the interpreter will raise a syntax error rather than compiling the code.
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list