Need instruction on how to use isinstance
Stephen Hansen
me+list/python at ixokai.io
Mon Jun 28 01:41:53 EDT 2010
On 6/27/10 10:09 PM, alex23 wrote:
> Stephen Hansen<me+list/pyt... at ixokai.io> wrote:
>> What the hell? When did that show up? o.O (Did I not pay attention
>> enough during the ABC conversations? It seemed so boring).
>
> The PEPs& post-release docs detailing Py3 changes were worth reading,
> it's noted in the sections on changes to built-ins:
>
> http://www.python.org/dev/peps/pep-3100/
> http://docs.python.org/py3k/whatsnew/3.0.html
I've actually read nearly all of that multiple times-- I tend to idly
re-read such things. But not everything sticks (as its usually late like
now and I'm multitasking and just exploring curiously). Callable in
collections (and the ABC's in collections-- I swear I thought they were
in a module of their own) totally didn't sink in.
>> A) how is Callable a collection, in any way shape or form? And B) does
>> that really return True for everything callable-esque? (I don't have a
>> 3.x to play with on this temporary computer)
>
> A) I was tempted to say "it's a collection of code" :) But really, the
> role of the collections model has expanded in 3.x to also provide a
> repository for ABCs:
>
> "In addition to containers, the collections module provides some ABCs
> (abstract base classes) that can be used to test whether a class
> provides a particular interface, for example, whether it is hashable
> or a mapping."
>
> http://docs.python.org/py3k/library/collections.html
The documentation might say something crazy, but just because its
*officially* crazy doesn't make it any less actually crazy.
Just because most of the ABC's are vaguely collection-related, doesn't
mean we should put them all into the collections module if there's some
which aren't really collection-ish. It argues for either putting
different ABC's in different places (say, Callable in functools? Who
knows) or just putting them all in a single module. I dunno which: its
far too late to do anything about now, but yeah.
Re-defining a module to suddenly include various random tidbits which
aren't even really related to that module's purpose counts as crazy in
my book.
I don't often think, "That's crazy." about Python, too. And although I'm
not really in a place to use Python 3 yet, I do try to learn more and
more of it as time goes on and play with it (and experiment with it) so
that when I'm able, I'll be ready. And so far I've been largely very
pleased, although Python 2 was rarely crazy (print >>crazy, "not
withstanding") I've been pleased with the less odd edges as I explore Py3.
Until now.
Oh well, nothing can be perfect. :)
--
... Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/
More information about the Python-list
mailing list