Python Strings

Alex Martelli aleaxit at
Wed Sep 6 14:16:19 CEST 2000

"Jonadab the Unsightly One" <jonadab at> wrote in message
news:39b5af09.17875966 at
> > although of course the "return something()" can fail at
> > runtime if 'something', while bound to something callable
> > (a function, method, class, or instance having a __call__
> > method, for example), is not callable *without arguments*.
> Ah, a gotcha.  (In some languages, all functions can
> be called with no arguments.  Of course, they are not
> guaranteed to always do something useful, but that's
> the programmer's lookout.)

If you're thinking of BCPL, or Forth, yes, you can
always call anything, but you may get crashes if you
do.  In Python, you can try/except, catch the resulting
TypeError, and even, I think, parse the message "not
enough arguments; expected 1, got 0" to get a hint
about how many args you should supply (alas, it's
harder to find out automatically *WHAT* arguments
the function wants, with what meaning...:-).


More information about the Python-list mailing list