Life's better without braces
Gerrit Holl
gerrit.holl at pobox.com
Sat Feb 26 04:28:17 EST 2000
<quote name="Moshe Zadka" date="951515287">
> On Fri, 25 Feb 2000, Gerrit Holl wrote:
>
> > def callable(f):
> > try:
> > f()
> > return 1
> > except TypeError:
> > return 0
> >
> > Hmm, this is wrong.
>
> To emphasize Gerrit's point:
>
> def f():
> raise TypeError()
Much simpler, you just don't want to call a certain function to
know if it's callable!
> > > ord should also be possible.
> >
> > Possible with some dictionairy.
>
> Hey, we can always right a Python program to write a Pythonic huge
> if statement:
>
> >>> def his():
> ... print "def ord(c):"
> ... print "\tif type(c) is not type('') or len(c)!=1:"
> ... print "\t\traise TypeError('too lazy')"
> ... for i in range(256):
> ... print "\tif c=='\\x%x': return %d" % (i, i)
> ... print "\traise TypeError('this is impossible')"
>
> (I was merciful enough to include the output)
Where?
regards,
Gerrit.
--
Comparison Python GUI's: http://www.nl.linux.org/~gerrit/gui.html
Please comment!
More information about the Python-list
mailing list