Jeff Sandys wrote:
I showed this thread at the SeaPIG meeting and we
talked about handling attributes. I pointed out
that the dot is an operator and that you can have
a space between the dot, and the group didn't
believe me until they tried it.
s = "my string"
s . split()
['my', 'string']
I think by showing the students that dot is an
operator helps them understand what is going on
and they might not be so concerned about making
the long variable and method dotted chains.
It's important that they realize that the dot is not a pure operator as the
rest of Pythons operators: the thing on its right side is not an arbitrary
expression but an identifier. So you can't do ``foo . (bar + baz)`` the way
you can do ``foo * (bar + baz)``. Showing the equivallence to `getattr()` is
a nice way to demonstarte the fact the right argument is not an expression
evaluated in the current environment but actually just a string.
--
Beni Cherniavsky <[EMAIL PROTECTED]>, who can only read email on weekends.
_______________________________________________
Edu-sig mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/edu-sig