Jonadab the Unsightly One
jonadab at bright.net
Wed Sep 6 11:51:05 CEST 2000
"Alex Martelli" <aleaxit at yahoo.com> wrote:
> > So, anyway, how flexible is Python's typeing?
> It's pretty strict, but entirely carried by *objects*, never
> by *names*. All a 'name' does is act as a label, or, maybe
> better, a 'post-it', since it can most easily be "peeled off"
> any object and (just-as-temporarily) bound to any other. The
> "items" in a list or dictionary work just the same way as
> 'names' (as they should, since names are pretty transparently
> just keys to items in some dictionary:-), as do the arguments
> to functions and the values they return.
Sounds good. IIUC.
> Most everything you'll care about is an object (and thus
> can be named, appended to a list, placed in a dictionary,
> passed as an argument, returned as a function's result):
> numbers, strings, functions, classes, modules, methods
> (either unbound or bound), instances, lists, dictionaries,
> and quite a few other things.
Sounds very good.
> 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.)
> But, if need be, you can do more 'introspection' (aka
> 'reflection'), and find out more about the object than
> just whether it's callable or not. Python excels at this
> (it's so inebriating and liberating that it's easy to go
> overboard and forget one doesn't normally HAVE to do any
> such analysis -- it's there for the time in a hundred it
> may really be useful...!-).
Stop it. You're making a believer out of me. It's
too soon for that. I don't even *know* this language yet.
More information about the Python-list