[Python-ideas] Object grabbing

Stephen Hansen me+python at ixokai.io
Mon May 2 01:07:54 EDT 2016

On Sun, May 1, 2016, at 08:27 PM, Guido van Rossum wrote:
> If a coder currently writes
> team.evict_user(team.users[i].uid, team.users[i].email, "Bye bye")
> because they can't be bothered to write
> user = team.users[i]
> team.evict_user(user.uid, user.email, "Bye bye")
> then would they bother writing this instead?
> using team.users[i]:
> team.evict_user(.uid, .email, "Bye bye")
I seriously don't clean my screen enough to find this an OK syntax.
"self.x" is perfectly readable, but not because the dot is particularly
visible, but because the dot is sufficient to combine those two parts
into a single unit to my eye. It makes the two parts blur together more
then the dot is, itself, strongly visible.
Every use case I can think of for this feature is better (as defined as
more readable?) spelled as a local variable, even if its a short
variable I'd normally argue against, like:
u = team.users[i]
team.evict_user(u.uid, u.email, "Bye bye")
Normally I don't like variables like 'u', but if they're very local
in functions that aren't long, they're fine. In those cases where
they aren't fine, the proposed using's dot syntax would remove from
vision what you're currently operating on and would therefore not be
good either.
To me this feature sacrifices readability for writability, and
readability is more important.
Stephen Hansen
m e @ i x o k a i  . i o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160501/3443e9b7/attachment-0001.html>

More information about the Python-ideas mailing list