Re: [Python-ideas] PEP 505: None-aware operators

2018-07-22 Thread Peter J. Holzer
On 2018-07-22 10:33:23 -0700, Michael Selik wrote:
> On Sat, Jul 21, 2018, 6:55 PM Steven D'Aprano  wrote:
> On Sun, Jul 22, 2018 at 01:56:35AM +0200, Giampaolo Rodola' wrote:
> > On Thu, Jul 19, 2018 at 3:39 PM Steven D'Aprano 
> > wrote:
> > > Tens of thousands of non-English speakers have had to learn the 
> meaning
> > > of what might as well be meaningless, random sets of symbols (to them)
> > > like "class", "import", "while" and "True". If they can do so, perhaps
> > > we English-speakers should stop complaining about how hard it is to
> > > memorise the meaning of a couple of symbols like ??.
> >
> > "class", "import", "while" and "True" are keywords, not symbols.
> 
> They are only key WORDS if you are an English speaker.

They are also words if you are not an English speaker. I don't speak
Chinese, but "Pǔtonghuà" is certainly a word for me (although I wouldn't
recognize 普通话 as that word).

> If your language
> doesn't use the Latin script, they don't even look like words. They look
> like gibberish: ∌≇⊅∇∫
> 
> 
> Are you familiar with how people who don't speak English code? I'm curious how
> they teach and use Python.

I know a few people who don't know enough English to read English
documentation. But AFAIK they didn't have a problem memorizing a few
dozen keywords. Learning the semantics of a programming language is a
much larger task than learning a few words, and having familiar keywords
probably doesn't really help much (they still don't mean what they mean
in English).

Of course we do use the Latin alphabet, I don't know how somebody who
had to learn the Latin alphabet specifically for programming would cope.
It's probably like programming in APL.

I guess I could learn PerlYuYan[1] to find out ;-).

hp

[1] https://metacpan.org/pod/Lingua::Sinica::PerlYuYan


-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>


signature.asc
Description: PGP signature
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] PEP 505: None-aware operators

2018-07-22 Thread Peter J. Holzer
On 2018-07-22 09:01:58 -0400, David Mertz wrote:
> On Sun, Jul 22, 2018, 8:11 AM Steven D'Aprano  wrote:
> To me, the ?? operator seems like a clear and obvious win. The other
> variants are more complex and the benefit is not as obvious to me, so I
> haven't decided where I stand on them.
> 
> 
> Yes, that is the only one I'm merely -0 on. The others I'm -1000.

For me it's the opposite. ?? is +0: While I use the equivalent // in
Perl quite frequently, the benefit isn't all that great.

But ?. and ?[] are really useful.

Sequences like request.context.user.email occur quite frequently in
code, and I find 

request?.context?.user?.email

much more readable than

email = None
context = request.context
if context is not None:
user = context.user
if user is not None:
email = user.email

Note that 

request and request.context and request.context.user and 
request.context.user.email

is not equivalent even if you assume that None is the only possible
falsey value in this context. It evaluates request 4 times,
request.context 3 times, and request.context.user 2 times.

hp


-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>


signature.asc
Description: PGP signature
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/