[Python-ideas] Object grabbing

Stephen Hansen me+python at ixokai.io
Tue May 3 04:11:09 EDT 2016


On Tue, May 3, 2016, at 12:21 AM, Robert van Geel wrote:
> summarizing:
>    1- the with statement should not be used for this

with means something now. It shouldn't have two confusing meanings. All
this discussion keeps using with when I hope that's a nonstarter.

If people can get behind 'using' or 'in', I don't know, but 'with'
should be absolutely out. With has a meaning in Python, a meaning which
doesn't map readily into this space (where 'import x as y' and 'except
Ex as y' do map readily, as its about renaming/aliasing)

>    4- the benefits of .dotted shorthand syntax are disputed, some think
> it's pythonic and readable, others don't think it is

To call it disputed undersells the claim. I'd call it horribly
unreadable. A dot is just shy of invisible on its own, a leading dot
evaporates besides the tabbed whitespace. No, no, no.

>    5 - Pascal style has been discussed in the past and has its own faq
> explaining rejection. So anyway a dot would be needed, this would also
> take away possible ambiguity between locals and object properties
>
> About 4, the argument that full variable writing is more explicit, hence
> Pythonic: I think clinging to 20 same-indentation level references to
> 'obj.' is explicit to the point of sillyness. We also dont use
> locals.obj.x because the localness of a variable is also present without
> explicity so a bit of pragmatism could have a voice. People who think
> .dotted syntax is less readable could still use the familiar syntax.

Again: no, no, no. Readability is more important then writability.
"People who think .dotted syntax is less readable" need to be answered
with a *serious* gain to override their objections. What does:

using thing["this"]:
    .that = "okay"
    .other = "right"

gain over

t = thing["this"]
t.that = "okay"
t.other = "right"

This feature is pure syntax sugar over local variables which are just
fine as they are.

--
Stephen Hansen
  m e @ i x o k a i  . i o


More information about the Python-ideas mailing list