[Python-Dev] Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread karld
Hello good people of Python Dev!

My name is Karl and I have been a Python user since 2010, professionally since 
2015. I belong to the "novice, non-technical" group of users, having got my 
start with programming in the 1990s using HyperTalk, possibly the easiest 
language of all, with the most English-like syntax. My move to Python in 2010 
resulted from my move to Linux at that time. The "easy syntax, almost like 
pseudo code"  assessment that is often repeated about Python was a big factor 
in choosing the language for the tools I wanted to build then. I've come a long 
way since those early days, but I will not forget how I got started.

However... To this day, I am bothered by the convention of certain names using 
4 underscores - "__class__", "__init__", "__add__", etc. I find them foreboding 
and difficult to type. They are also difficult to debug because in many editors 
there is no space between two underscores, and it may not be immediately 
obvious whether there is one underscore or two, or even three. I am lucky 
enough to have no disabilities, but I imagine there are segments of the 
"novice, non-technical" user group who would struggle to a greater degree than 
me. Given the focus of the Steering Council on improving inclusiveness and 
access in the Python community, I am hopeful that my message will be heard and 
my suggestion for improvement considered.

I understand how this naming convention came about, no problems there. I do 
think it is a case of too much linear thinking though, progressing from the 
convention of one underscore to two, then to four. I believe by the time we get 
to four, it is time to say "Stop, is there not a better way?"

Looking at the non-alphanumeric symbols in ASCII and considering their existing 
use in Python and other languages, the dollar sign "$" presents itself as the 
best option: "main.$class", "$init", "$add", etc. Of course, the old convention 
would remain for backward compatibility, but new code would be easier to type 
and debug with this new symbol.

Perhaps this solution or something like it has already been considered and 
rejected. In that case, no big deal, this post shall vanish into oblivion with 
no harm done. On the other hand, if my idea is new and has potential, then I am 
hoping that a core dev will step up, say something encouraging, and I will 
write up a PEP.

Thank you for reading and I look forward to your replies.

Karl
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/U3NLUUSN64MUXRRT7DATPQS2YLHCKTIR/


[Python-Dev] Re: Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread Skip Montanaro
My only comment is that this belongs first on python-ideas
.

Skip
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/54OTFAX74ICNALHGC5H4OMZDCIXXJ6J3/


[Python-Dev] Re: Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread karld
Sorry for posting to the wrong list! If this could be moved I'd appreciate it.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/MCD6LDSLNDA4DANEJEDT7FQR4HSCTU36/


[Python-Dev] Sphinx is blocking merges

2019-07-21 Thread Terry Reedy
One of the required CI tests is a Travis doc build, even if a PR does 
not touch any doc file.  The following failure appears to be 
deterministic on master and 3.8.  A 3.7 backport passed.  It has 
happened multiple times on multiple PRs today.  Example:

https://travis-ci.org/python/cpython/jobs/561700698
The failure is
'''
Warning, treated as error:
[distutils/examples:267] "`" found in "This is the description of the 
``foobar`` package."

'''
See https://bugs.python.org/issue37644

--
Terry Jan Reedy
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/L4NW7CVW2JJLKQGGDBGJXEJ4L3HI6JBV/


[Python-Dev] Re: Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread Karl Dolenc
Eric Smith advised me that I'll have to manually re-post to the Ideas list. 
I'll do so once my subscription there is accepted. If possible, this thread 
should be deleted.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/NQJI2ZEH567TFV55SN4J5MHVNEAUZRO2/


[Python-Dev] Re: Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread Eric V. Smith
You’ll have to manually re-send it. 

--
Eric V. Smith
(301) 502-0945 cell

> On Jul 21, 2019, at 11:23 AM, [email protected] wrote:
> 
> Sorry for posting to the wrong list! If this could be moved I'd appreciate it.
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/[email protected]/message/MCD6LDSLNDA4DANEJEDT7FQR4HSCTU36/
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/QVYBOPDF5DXM5PF6ZDBFYEXYULTG32QN/


[Python-Dev] Re: Replacing 4 underscores with a $ sign, idea for a PEP

2019-07-21 Thread Abdur-Rahmaan Janhangeer
forward?

Abdur-Rahmaan Janhangeer
Mauritius
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/FF6OT3JEVMEHHRSNEPEJXRXM5M7XJIZ2/


[Python-Dev] Re: Sphinx is blocking merges

2019-07-21 Thread Ned Deily
On Jul 21, 2019, at 18:49, Terry Reedy  wrote:
> One of the required CI tests is a Travis doc build, even if a PR does not 
> touch any doc file.  The following failure appears to be deterministic on 
> master and 3.8.  A 3.7 backport passed.  It has happened multiple times on 
> multiple PRs today.  Example:
> https://travis-ci.org/python/cpython/jobs/561700698
> The failure is
> '''
> Warning, treated as error:
> [distutils/examples:267] "`" found in "This is the description of the 
> ``foobar`` package."
> '''
> See https://bugs.python.org/issue37644

master is now fixed; 3.8 should be fixed in a few minutes

--
  Ned Deily
  [email protected] -- []
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/TCDT7RPRMTLD2MNKLZWCAIJUTR77JJQC/


[Python-Dev] Re: The order of operands in the comparison

2019-07-21 Thread Grant Jenks
There's also bisect_left and bisect_right which each do different things.
The bisect_left function puts the needle on the right while the
bisect_right function puts the needle on the left.

I've thought a bit about these scenarios as the author of Sorted Containers
but no user has ever raised an issue about it. Personally, I think the
needle should go on the left as it offers the caller greater opportunity to
control and customize the __eq__ method that is used.

But personal preferences aside, I think the "ship has sailed" and the
differences are not worth fixing. I agree with Guido that developers should
fix __eq__ to use NotImplemented as it was intended.

Grant


On Sat, Jul 20, 2019 at 8:33 AM Guido van Rossum  wrote:

> In an ideal world, needle is on the right. Let's replace needle with a
> constant: which of the following looks more natural?
>
>   for x in sequence:
>   if x == 5: return True
>
> or
>
>   for x in sequence:
>   if 5 == x: return True
>
> For me, 'x == 5' wins with a huge margin. (There is a subculture of C
> coders who have trained themselves to write '5 == x' because they're afraid
> of accidentally typing 'x = 5', but that doesn't apply to Python.)
>
> Should we unify the stdlib? I'm not sure -- it feels like a sufficiently
> obscure area that we won't get much benefit out of it (people should fix
> their __eq__ implementation to properly return NotImplemented) and changing
> it would surely cause some mysterious breakage in some code we cannot
> control.
>
> --Guido
>
> On Sat, Jul 20, 2019 at 7:31 AM Serhiy Storchaka 
> wrote:
>
>> Usually the order of operands of the == operator does not matter. bool(a
>> == b) should return the same as bool(b == a). Correct __eq__ should look
>> like:
>>
>>  def __eq__(self, other):
>>  if not know how to compare with other:
>>  return NotImplemented
>>  return the result of comparison
>>
>> But we work with non-perfect code written by non-perfect people.
>> __eq__() can return False instead of NotImplemented for comparison with
>> different type (it is not the worst case, in worst case it raises
>> AttributeError or TypeError). So the order of operands can matter.
>>
>> See https://bugs.python.org/issue37555 as an example of a real world
>> issue.
>>
>> The typical implementation of the __contains__ method looks like:
>>
>>  def __contains__(self, needle):
>>  for item in self:
>>  if item == needle:  # or needle == item
>>  return True
>>  return False
>>
>> The question is where the needle should be: at the right or at the left
>> side of ==?
>>
>> In __contains__ implementations in list, tuple and general iterators
>> (see PySequence_Contains) the needle is at the right side. But in
>> count(), index() and remove() it is at the left side. In array it is
>> effectively always at the left side since its __eq__ is not invoked.
>>
>> The question is whether we should unify implementations and always use
>> the needle at some particular side and what this side should be.
>> ___
>> Python-Dev mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>> https://mail.python.org/mailman3/lists/python-dev.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/[email protected]/message/VSV4K4AOKM4CBQMOELPFV5VMYALPH464/
>>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> *Pronouns: he/him/his **(why is my pronoun here?)*
> 
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/WRNIZS3E4NO74JDANPGPX2JZEDHOTPFC/
>
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/KZI77A7BBXOHRNJSTHI5SOS3SV46PDRN/


[Python-Dev] Re: The order of operands in the comparison

2019-07-21 Thread raymond . hettinger
FWIW, the bisect_left and bisect_right functions have different argument order 
so that they can both use __lt__, making them consistent with sorting and with 
the heapq functions.

Raymond
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/O2AETKAY5EVLIQNRRSFV53NQ6K3TF5EN/