What's better about Ruby than Python?
Roy Smith
roy at panix.com
Thu Aug 21 22:14:53 EDT 2003
Juha Autero <Juha.Autero at iki.fi> wrote:
> Alex Martelli <aleax at aleax.it> writes:
>
> > The counter-arguments you present in the following do not affect Mertz's
> > argument in the least, and thus cannot indicate why you don't find it
> > completely compelling. To rephrase David's argument: simplicity suggests
> > that a 'class' statement should always have the same fundamental semantics.
> > Since it SOMETIMES needs to bind a name, therefore, letting it ALWAYS
> > bind a name -- rather than sometimes yes, sometimes no, depending on
> > context -- is the only Pythonic approach.
>
> I think the problem here is same as with understanding Python
> variables and assignment. People think names as objects themself
> rather than bindings to an object. (Maybe I should have said "things"
> to avoid confusin. Though in Python, everything you can bind a name to
> is a Python object.) They think that after
>
> class foo: pass
>
> you get
>
> +-----+
> | foo |
> +-----+
>
> but in Python in reality you get
> +-----+
> foo --> | |
> +-----+
>
> So, in Python all objects are basically anonymous. They just have
> names bound to them. And since everything is an object, this goes for
> classes and functions, too. I'm not sure about modules though.
Well, classes (and modules) are not really anonymous. A class knows
it's name (as does a module).
>>> class foo: pass
...
>>> print foo
__main__.foo
>>> bar = foo
>>> print bar
__main__.foo
>>>
so, a more accurate picture would be
+-----+
foo --> | foo |
+-----+
More information about the Python-list
mailing list