Re: Use of a variable in parent loop

2020-09-27 Thread Mike Dewhirst
On 28/09/2020 12:56 pm, Stephane Tougard via Python-list wrote:
> On 2020-09-27, Cameron Simpson  wrote:
>>> In many non declarative language, if I do print($var), it just prints
>>> and undefined value with returning an error.
>> And that way lie MANY MANY bugs not detected until an undefined value 
>> actually causes an issue, if that ever happens. In some languages 
> Totally agree, it's not an acceptable behavior.
>
> I would not do some Perl without 'use strict'

I came to Python from Pascal, Perl and PHP. For a while my code was full
of constructs which came from those languages. As time passed and I
lurked on mailing lists I began to see the power of Python. It is
incredibly flexible. You can write code the way you used to or you can
gradually try to write more "Pythonically". The real beauty of Python in
my opinion is genuine OO. And the community.

Perl can be extremely terse, much more so than Python but that is where
the "write-only" criticism comes from. Perl's terseness can only work
for throwaway code.[1] Python is - or can be - quite terse but if
written Pythonically is almost self-documenting. You, or anyone else can
read it in coming years.

Cheers

Mike

[1] If you live with Perl non-stop I agree Perl code can be read in
future. But it requires allocation of serious brain-space for me at
least to come back to it.

-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.



signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I've noticed that Python beginners tend to find this really confusing.

No minor tweak to the exception message will make this go away.  For 
understanding to occur, the only way to forward is to learn a bit about 
hashability.  That is a step that every beginner must take.

Fortunately, the term "hashable" is listed in the glossary.  Also the error 
message itself is easily Googled:

   https://docs.python.org/3/glossary.html#term-hashable

   
https://www.google.com/search?q=TypeError%3A+unhashable+type%3A+%27dict%27=TypeError%3A+unhashable+type%3A+%27dict%27

I suggest that you take this to the python-ideas list.  While there is a valid 
concern that a new user may not understand the error message (this is 
unfortunately true for many our error messages), the proposals don't actually 
improve the situation.

The first proposal adds hard-to-implement context information that still 
doesn't tell a user what the issue is.  The second proposal repeats information 
that is already being shown.  Neither proposal explains what is meant by 
unhashable type, why it matters, what would be an allowable hashable type, or 
how to fix the problem (which is what the user really wants to know).

After a discussion on python-ideas, if a better proposal is found, feel free to 
reopen this issue.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Cameron Simpson
On 28Sep2020 13:43, Chris Angelico  wrote:
>On Mon, Sep 28, 2020 at 12:31 PM Stephane Tougard via Python-list
> wrote:
>> To be frank, I don't really care the rules and supposed best practices,
>> I use a language the way it fits me. So I'll pass on the advices like
>> "we never use this like this" without more reason that "we just don't do
>> it" or "it's not expected to be done this way".
>
>If you're going to ignore advice on how to use Python well and just
>use it your own way, that's fine, but don't expect python-list to help
>you do things your own way. :) Also, please don't try to collaborate
>with anyone unless you're prepared to follow best prac.

Chris: that's not what Stephane said. Stephane passes on advice 
unsupported by reasons.

That said, Stephane: I don't believe in "best practice" as _the_ best 
practice, but I certainly believe there's "bad practice".

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Chris Angelico
On Mon, Sep 28, 2020 at 12:31 PM Stephane Tougard via Python-list
 wrote:
> To be frank, I don't really care the rules and supposed best practices,
> I use a language the way it fits me. So I'll pass on the advices like
> "we never use this like this" without more reason that "we just don't do
> it" or "it's not expected to be done this way".

If you're going to ignore advice on how to use Python well and just
use it your own way, that's fine, but don't expect python-list to help
you do things your own way. :) Also, please don't try to collaborate
with anyone unless you're prepared to follow best prac.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread MRAB

On 2020-09-28 03:53, Stephane Tougard via Python-list wrote:

On 2020-09-27, Chris Angelico  wrote:

Or maybe Emacs *isn't* breaking it, and it's just an autoindentation
thing. I don't know.


  From the discussion I read about this feature, it considers that 'pass' is
use to write an empty def()

def();
pass

So it's logic for it to indent one level up after a 'pass' because the people
who made it did not see any other usage to 'pass' than that.

if True:
pass
print("It's true")

The 'pass' is totally useless by itself, it can be replaced by a comment.


It's used where the language requires a statement.

In, say, C, you would use empty braces:

while (process_next_item()) {
/* Do nothing. */
}

In Python that would be:

while process_next_item():
# Do nothing.
pass
--
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Manfred Lotz
On Mon, 28 Sep 2020 05:20:20 +0800
Stephane Tougard  wrote:

> On 2020-09-27, Manfred Lotz  wrote:
> > - http://localhost:2015/tutorial/controlflow.html#pass-statements  
> ...
> > (In comparison to guys like ChrisA and StefanR and others here I am
> > also a Python beginner)  
> 
> To give me a pointer on your localhost, I could guess.

Don't understand this sentence.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Chris Angelico  wrote:
> Or maybe Emacs *isn't* breaking it, and it's just an autoindentation
> thing. I don't know.

>From the discussion I read about this feature, it considers that 'pass' is
use to write an empty def()

def();
pass

So it's logic for it to indent one level up after a 'pass' because the people
who made it did not see any other usage to 'pass' than that.

if True:
pass
print("It's true")

The 'pass' is totally useless by itself, it can be replaced by a comment.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Cameron Simpson  wrote:
>>In many non declarative language, if I do print($var), it just prints
>>and undefined value with returning an error.
>
> And that way lie MANY MANY bugs not detected until an undefined value 
> actually causes an issue, if that ever happens. In some languages 

Totally agree, it's not an acceptable behavior.

I would not do some Perl without 'use strict'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Terry Reedy  wrote:
> emacs with python-mode has been and likely still is used by some 
> experienced python programmers. I have never seen anyone but a rank 

Yes, since I discovered that an empty has almost the same effect than a
pass to end a block.

> The 'pass' line does not mark the end of the if block.

Yes, I know, I discovered that yesterday. Reading the documentation, it
should not anyway.

The way Emacs understands it is misleading.

> Python only has a temporary overlap mechnism:

That's the only answer I was expecting instead of all this arguing as if
I said any blasphem because I asked how can we change the behavior of
the language. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Avi Gross  wrote:
> But when someone insists Python needs to
> change to meet their preconception, I get less sympathetic.

To clarify my question, I never asked that Python changes for me, I
asked if there was any way to change Python's behavior by using a module
or a configuration for example.

As "use strict;" in Perl or JS who changes the behavior of the language.

That's kind of difference between Perl and Python (or C and GO) is that
each Mongiste has its own style and uses Perl the way it fits for his
needs, while Pythonist has to write Python as it has been defined (this
rule is much stronger with GO).

To be frank, I don't really care the rules and supposed best practices,
I use a language the way it fits me. So I'll pass on the advices like
"we never use this like this" without more reason that "we just don't do
it" or "it's not expected to be done this way".

Anyway, thanks for your help.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't install Python

2020-09-27 Thread Mats Wichmann
On 9/27/20 4:48 PM, MRAB wrote:

>> Whatever I try, whenever I click on the phyton.exe file, Python seems
>> to install, but only ultimately displays a Modify Setup screen.
>> I have tried the modifying and repairing options, but they all just
>> lead to the same Modify Setup screen.


> So you ran "python-3.8.5-amd64.exe"? That's the installer.
> 
> By default it installs into
> "C:\Users\\AppData\Local\Programs\Python\Python38".
> 
> In that folder is "python.exe", which is the version of Python that
> opens a console (Command Prompt) window.

This seems to have been happening to people a lot.  It seems like
Windows is selecting the installer when people think they're launching
Python itself.  Once you've got the install done, you can try removing
the downloaded file - you don't need it any longer.  Maybe that will let
the Python interpreter be found more easily.

How are you trying to launch it?  Windows search/Cortana?

Installing Python from the Microsoft Store is another option, since the
installation process is different (the program isn't), it often avoids
this particular set of issues.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Greg Ewing

On 27/09/20 10:27 pm, Stephane Tougard wrote:

That's not a question of editor, that's a question of having a clear way
to mark the end of a block, I guess the Emacs maintener found this way
and I think it's a great idea.


I doubt whether the authors of the Emacs python-mode had this way
of using "pass" in mind. More likely they're just trying to be helpful
and save you from having to manually unindent in a few rare situations.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread William Pickard


William Pickard  added the comment:

You did just necro a 5 year old bug report...

--
nosy: +WildCard65

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread William Pickard


Change by William Pickard :


--
nosy:  -WildCard65

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Samuel Freilich


Samuel Freilich  added the comment:

> The user already knows

The example I link to in the initial description appears to be one case where 
the user does not in fact know.

I do think context that this restriction applies to dict key in particular is 
very relevant. The line could use the same type for both the key and the value 
in a dict assignment, for example.

> TypeError: unhashable type: 'dict'.  Consider using an int, str, tuple, or 
> frozenset.

That seems like a pretty reasonable wording, though I think mentioning 
"dictionary key" or "set item" specifically still helps.

It could also link to the documentation directly:
https://docs.python.org/3/glossary.html#term-hashable

Though other error messages don't generally follow that pattern.

> Saying it twice doesn't help.

As the comment you were responding to noted, putting it in the type implies 
there might be additional information in documentation (or at least provides a 
place in documentation to put that information). TypeError is too general to 
say something about that specifically:
https://docs.python.org/3/library/exceptions.html#TypeError

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41756] Do not always use exceptions to return result from coroutine

2020-09-27 Thread Vladimir Matveev


Vladimir Matveev  added the comment:

Serhiy, AFAIR PyIter_Send in my PR appear only as a rename from placeholder 
`Name_TBD` and it still was specific to PyGenObjects. Do you mean something 
that was listed in https://bugs.python.org/msg377007 ?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Chris Angelico
On Sun, Sep 27, 2020 at 9:41 PM Manfred Lotz  wrote:
>
> On Sun, 27 Sep 2020 15:18:44 +0800
> Stephane Tougard  wrote:
>
> > On 2020-09-27, 2qdxy4rzwzuui...@potatochowder.com
> > <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > > As ChrisA noted, Python almost always Just Works without
> > > declarations. If you find yourself with a lot of global and/or
> > > nonlocal statements, perhaps you're [still] thinking in another
> > > language.
> >
> >
> > I don't really agree with that, trying to use an undeclared
> > object/variable/whatever :
> >
> > Python 3.7.7 (default, Aug 22 2020, 17:07:43)
> > [GCC 7.4.0] on netbsd9
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> print(name)
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   NameError: name 'name' is not defined
> >   >>>
> >
> > You can say it's not the "declaration" the issue, it's the
> > "definition", that's just a matter of vocabulary and it does not
> > answer the question.
> >
> > In many non declarative language, if I do print($var), it just prints
> > and undefined value with returning an error.
> >
> >
>
> It is very good that you try out things. Nevertheless, it is also good
> to read. In other words the combination of reading and trying out
> things is the best way to make progress.
>
> Here some pointers
>
> pass
>
> - http://localhost:2015/tutorial/controlflow.html#pass-statements
>

Looks like you're linking to a local copy of the documentation. Here's
the same page from the official docs:

https://docs.python.org/3/tutorial/controlflow.html#pass-statements

(It'll be the same information, modulo version differences, but this
one should be available everywhere.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Chris Angelico
On Mon, Sep 28, 2020 at 7:50 AM Stephane Tougard via Python-list
 wrote:
>
> On 2020-09-27, Stefan Ram  wrote:
> >>Is there any other instruction to end a if than pass and ensure Emacs
> >>does not break the indentation during a copy paste or an indent-region ?
> >
> >   We usually do not wish to tie our code to a defective editor.
> >   I use vi, and can assure you that there is no such restriction
> >   in a real editor.
>
> It's funny, I've made a few tests and I see that pass has no impact on
> if block in fact, I can put it anywhere and add code behind, it works
> fine. I was sure that pass was breaking the if block, it does not.
>
> That's however still the way Emacs seems to see it (I can not add
> any code in a if block after a pass, pass acts as if it breaks the if
> block).

Well, then Emacs is the thing breaking it, because the 'pass'
statement has absolutely no code associated with it. It's equivalent
to an empty pair of braces in C.

Or maybe Emacs *isn't* breaking it, and it's just an autoindentation
thing. I don't know.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't install Python

2020-09-27 Thread MRAB

On 2020-09-27 22:43, Hugh Pittman wrote:

Hi;

I've spent several hours over two days unsuccessfully trying to install Python.
I am trying to install it on a desktop computer running on a Windows10 64-bit / 
AMD CPU platform.
I have tried installing various versions.
I have also tried downloading Python from other websites, aside from python.org.
I have tried different sequences of steps.
For example, I have tried selecting Downloads > Windows > Python 3.85 from the 
.org download webpage.
Alternatively, I have tired specifying 'Windows x86-64 executable installer' 
under 'Files'.
Whatever I try, whenever I click on the phyton.exe file, Python seems to 
install, but only ultimately displays a Modify Setup screen.
I have tried the modifying and repairing options, but they all just lead to the 
same Modify Setup screen.
A message always say to contact pyton.org if the issues continue.
So, that is what I am now doing.
I can't think of what else I could try.
Any suggestions?


So you ran "python-3.8.5-amd64.exe"? That's the installer.

By default it installs into 
"C:\Users\\AppData\Local\Programs\Python\Python38".


In that folder is "python.exe", which is the version of Python that 
opens a console (Command Prompt) window.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread MRAB

On 2020-09-27 10:27, Stephane Tougard via Python-list wrote:

On 2020-09-27, Stefan Ram  wrote:

Is there any other instruction to end a if than pass and ensure Emacs
does not break the indentation during a copy paste or an indent-region ?


  We usually do not wish to tie our code to a defective editor.
  I use vi, and can assure you that there is no such restriction
  in a real editor.


It's funny, I've made a few tests and I see that pass has no impact on
if block in fact, I can put it anywhere and add code behind, it works
fine. I was sure that pass was breaking the if block, it does not.

That's however still the way Emacs seems to see it (I can not add
any code in a if block after a pass, pass acts as if it breaks the if
block).

As pass does nothing anyway, that looks like a good way to mark the end
of a block and I did not find any valid reason to not use it this way.
That's not a question of editor, that's a question of having a clear way
to mark the end of a block, I guess the Emacs maintener found this way
and I think it's a great idea.

If a extremist Pythonist takes over my code some day, he'll have to
search and delete hundreds of useless pass. I laugh already thinking
about it.


He could write some code to do it.
--
https://mail.python.org/mailman/listinfo/python-list


[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Guido van Rossum


Guido van Rossum  added the comment:

I've only seen it in test cases too -- that's one of the very few
situations where it makes sense to define a class inside a function.
(Creating a class is an expensive operation, so any function that expects
to be called more than once is better off moving the class out of the
function.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Can't install Python

2020-09-27 Thread Hugh Pittman
Hi;

I've spent several hours over two days unsuccessfully trying to install Python.
I am trying to install it on a desktop computer running on a Windows10 64-bit / 
AMD CPU platform.
I have tried installing various versions.
I have also tried downloading Python from other websites, aside from python.org.
I have tried different sequences of steps.
For example, I have tried selecting Downloads > Windows > Python 3.85 from the 
.org download webpage.
Alternatively, I have tired specifying 'Windows x86-64 executable installer' 
under 'Files'.
Whatever I try, whenever I click on the phyton.exe file, Python seems to 
install, but only ultimately displays a Modify Setup screen.
I have tried the modifying and repairing options, but they all just lead to the 
same Modify Setup screen.
A message always say to contact pyton.org if the issues continue.
So, that is what I am now doing.
I can't think of what else I could try.
Any suggestions?

Cheers,
Hugh
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30953] Fatal python error when jumping into except clause

2020-09-27 Thread ppperry


Change by ppperry :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Stefan Ram  wrote:
>>Is there any other instruction to end a if than pass and ensure Emacs
>>does not break the indentation during a copy paste or an indent-region ?
>
>   We usually do not wish to tie our code to a defective editor.
>   I use vi, and can assure you that there is no such restriction
>   in a real editor.

It's funny, I've made a few tests and I see that pass has no impact on
if block in fact, I can put it anywhere and add code behind, it works
fine. I was sure that pass was breaking the if block, it does not.

That's however still the way Emacs seems to see it (I can not add 
any code in a if block after a pass, pass acts as if it breaks the if
block). 

As pass does nothing anyway, that looks like a good way to mark the end
of a block and I did not find any valid reason to not use it this way.
That's not a question of editor, that's a question of having a clear way
to mark the end of a block, I guess the Emacs maintener found this way
and I think it's a great idea.

If a extremist Pythonist takes over my code some day, he'll have to
search and delete hundreds of useless pass. I laugh already thinking
about it.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Terry Reedy

On 9/26/2020 3:36 PM, Stephane Tougard via Python-list wrote:

On 2020-09-26, Terry Reedy  wrote:

Noise.  Only 'pass' when there is no other code.


Why ?




I use pass and continue each time to break a if or a for because emacs
understands it and do not break the indentation.

Is there any other instruction to end a if than pass and ensure Emacs
does not break the indentation during a copy paste or an indent-region ?


Emacs should come with python.el or python-mode.el defining a 
python-mode.  Are you using it?  I presume it understands python block 
structure without extra passes.


emacs with python-mode has been and likely still is used by some 
experienced python programmers. I have never seen anyone but a rank 
beginner misunderstanding 'pass' misusing it as an end-block marker. 
(Ditto for putting ';' at the end of every line.)  Dedents or EOF do that.


if a:
b = 3
pass
c = 5
else:
b = 1
c = 2

The 'pass' line does not mark the end of the if block.


Aside from not breaking most every existing Python program?  If block
scoped, one would have to add an otherwise useless fake declaration
before the block to use the name outside the block.  Python tries to
avoid boilerplate code.


I'm not talking about a general change in Python as a language, I'm
talking about a module who would enforce a block namespace as it works with
C or Perl (and many).


The existence of a permanent alternate syntax mechanism would be a 
general change to the language.


Python only has a temporary overlap mechnism:

from __future__ import new_syntax.

This gives people usually 2 versions to adjust to a new syntax that 
breaks compatibility by switching to the new syntax anytime before it 
becomes mandatory.


For example, making 'with' a keyword broke any other use of the word. 
So people temporarily had to add

from __future__ import with_statement
at the top of a file to use with statements in that file.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Chris Angelico  wrote:
> If you MUST use a block-end marker, try "# end" instead - at least
> then everyone *knows* it's nothing more than a comment.

Damn, you could not say that earlier !!!
-- 
https://mail.python.org/mailman/listinfo/python-list


pip update fails

2020-09-27 Thread Hylton
Hello,

 �

When I tried to install a package using pip, it informed me that there is a new 
version available.

 �

Per the recommendation, I tried to update pip, but the update failed.

 �

The following is the last few lines of the failure messages:

V

 �

  File 
"C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py",
 line 386, in _get_launcher

raise ValueError(msg)

ValueError: Unable to find resource t64.exe in package pip._vendor.distlib

WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.

You should consider upgrading via the 'C:\Program Files\Python38\python.exe -m 
pip install --upgrade pip' command.

 �



 �

I can of course supply the full error traceback, if needed, not just these last 
few lines.

 �

The file:

c:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\t64.exe

DOES exist.

 �

I just installed the latest python version 3.8.6 – I would have thought it 
would already include the latest version of pip…

 �

Any help resolving this failure will be much appreciated.

 �

Thanks,

Hylton

 �

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Grant Edwards
On 2020-09-27, Stephane Tougard via Python-list  wrote:

> an indentation is not good enough for me to end a block

Maybe you need to choose a different language -- one that has block
delimiter keywords or tokens.

> and it may
> trigger some problem when using different editors or tools on the
> code.

Maybe you need to choose different editors and tools.

A guy I worked for many years ago used to write BASIC programs in C by
using a bizarre set of pre-processor macros.  While it provided his
employees with plenty of amusement, he could never get the programs to
work right...



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Cameron Simpson
On 27Sep2020 15:18, Stephane Tougard  wrote:
>In many non declarative language, if I do print($var), it just prints
>and undefined value with returning an error.

And that way lie MANY MANY bugs not detected until an undefined value 
actually causes an issue, if that ever happens. In some languages 
undefined values are quietly promotes to eg 0 in a numeric context. No 
errors, no exceptions, just silent incorrect results.

In Python the choice was made to raise an error for use of a variable 
not previously bound.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers


Chris Withers  added the comment:

The tough one is that no-one wants an ugly sys._getframe() call, but by 
avoiding it in the standard library, we force each library that needs this to 
have the ugly sys._getframe() call rather than it being an unpleasant 
implementation detail of get_type_hints that users of the function don't have 
to know about.

That said, I've only hit this so far when writing a unit test, but will update 
this issue if I see real-world cases of this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14243] tempfile.NamedTemporaryFile not particularly useful on Windows

2020-09-27 Thread Evgeny


Evgeny  added the comment:

Hello, this is to let you know, that I have created a pull request for this 
issue

https://github.com/python/cpython/pull/22431

I am not really an experienced programmer, but I will give it a try

--
nosy: +ev2geny

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Richard Damon
On 9/27/20 4:42 PM, Christian Gollwitzer wrote:
> Am 26.09.20 um 06:43 schrieb Stephane Tougard:
>> ===PYTHON===
>> #!/usr/local/bin/python
>> if 4 == 4:
>>  name = "Stephane"
>>  print(name)
>>  pass
>>
>> print("Out {}".format(name))
>> 
>>
>> The exact same code in Python works fine, the variable name is used
>> outside of the if block even it has been declared inside.
>>
>> This does not look right to me. 
>
> I'll try another way of explaining it. You seem to be confused that
> the scope of the variable assignment[*] continues after the if.
> However, look at this:
>
> def f():
> a=3
>
> f()
> a
>
> NameError
> Traceback (most recent call last)
>  in ()
> > 1 a
>
> NameError: name 'a' is not defined
>
> So the "def f()" obviously introduces local scope, but control
> structures like if and while do not.
>
> Christian
>
>
> [*] In Python it's called "name binding", but it mostly works like
> variable assignment

Yes, functions and classes have a scope, control structures do not. If
control structures created a scope it would be ugly.

You do need to watch out about the difference between classical
'variables' and pythons name binding when you deal with mutable objects;

For example:

a = []

b = a

a.append(1)

print(b)

give [1] as a and b are bound to the same object, even though you want
to think of them as different variables.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Christian Gollwitzer

Am 26.09.20 um 06:43 schrieb Stephane Tougard:

===PYTHON===
#!/usr/local/bin/python
if 4 == 4:
 name = "Stephane"
 print(name)
 pass

print("Out {}".format(name))


The exact same code in Python works fine, the variable name is used
outside of the if block even it has been declared inside.

This does not look right to me. 


I'll try another way of explaining it. You seem to be confused that the 
scope of the variable assignment[*] continues after the if. However, 
look at this:


def f():
a=3

f()
a

NameError
Traceback (most recent call last)
 in ()
> 1 a

NameError: name 'a' is not defined

So the "def f()" obviously introduces local scope, but control 
structures like if and while do not.


Christian


[*] In Python it's called "name binding", but it mostly works like 
variable assignment

--
https://mail.python.org/mailman/listinfo/python-list


RE: Use of a variable in parent loop

2020-09-27 Thread Avi Gross via Python-list
These discussions can be  bit frustrating. People talk past each other.
Languages seem almost like religions, as do paradigms.

I try to stay above it and absorb each paradigm  as an alternative choice
made and then try to think of what problems I can solve better with one or
another and so on.

 Programming languages are often created when people have new ideas and want
to try them out, often keeping a good chunk of the language similar enough
to other languages so they seem partially familiar and then diverge.

Whether a particular text editor has a mode than honors your typing in a
language is  a side issue. Whether you can use cut and paste properly is a
similar side issue. Python chose indentation so you can remove lots of curly
braces and often semi-colons that clutter other languages. There is a
trade-off. In general, you can use superfluous symbols harmlessly such as
curly braces above and below a region so that it looks like a BLOCK but that
won't make it a block for purposes that language does not consider a good
feature.

And another trade-off is that it is not really a compiled language and
variables are looked up dynamically in a varying path of namespaces and the
same name can constantly change what kinds of objects it holds. There is
lots of freedom there that I appreciate as compared to some C-inspired
languages including GO that I am learning now, just for fun. I do lots of
prototyping and that is easier to do when less constrained but a final
program may well run better in a compiled form.

But like human languages, some people may not easily be able to switch to a
new one that violates what to them seem obvious rules. I was exposed to many
in childhood so some sounds are easy for me to hear and pronounce that
others cannot deal with but I am apparently tone deaf when I try to learn a
language like Mandarin that uses some kind of "tones" and certainly am not
willing to learn an alphabet that is not sound-based and has tens of
thousands of characters. But, I seem able to handle many alphabets that exit
in European and Semitic languages even when they use the same apparent
letters in very different ways. To each their own.

So for those replying here that the person asking a question needs to drop
their preconceptions and instead learn what Python IS DOING, I fully agree
as long as it is done gently. But when someone insists Python needs to
change to meet their preconception, I get less sympathetic. A language that
has been around for decades is often hard to change without breaking things
and we know Python 2.X and earlier are not particularly compatible and what
trouble that has caused. Other languages like PERL have had such schisms and
growing pains. Sometimes a better solution is to start a new language from
scratch and just keep what you want and freely add new.

Dumb example, perhaps, is  features I see in GO. Some are quite interesting
but I am not demanding they be added to Python or R or any other language I
use. Heck, some may mess up existing programs. Go has a "defer" statement
that creates a stack of function calls to be done AFTER the function
creating them returns. While that can be nifty, it is a very different
paradigm. But a different paradigm in say R allows you to specify what must
be done on exit from a function even if it exist badly. Python has variants
as well including for some protocols that close open files if used  in a
"with" and so on. Lots of ideas out there but you have to use what your
language comes with to a point, or work out your own variants of objects or
add wrappers around functions and so on. Python has tons of such techniques
if you read the documentation and other literature.

And, yes, there are text editors designed better to handle writing code in
python and also external utilities you can use to reformat the code in many
cases to your needs.

I have found that in programming IDEAS, there are many forks in the road as
design decisions you make and amazingly often you can find one or more
programming environments where one or another fork has been taken. There
often is no one right answer that everyone agrees with and choices are often
made for other reasons such as how easy the creators can implement things
even if the result is harder to program some things in.

Avi

-Original Message-
From: Python-list  On
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Sunday, September 27, 2020 8:17 AM
To: python-list@python.org
Subject: Re: Use of a variable in parent loop

On 2020-09-27 at 15:18:44 +0800,
Stephane Tougard via Python-list  wrote:

> In many non declarative language, if I do print($var), it just prints 
> and undefined value with returning an error.

If I want "many non declarative language[s]," I know where to find them, and
I won't expect them to honor Python's semantics.  In Python, a name doesn't
have a value unless and until you bind it to one.

There's a lot more to learning a new language than the syntax.
--

[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Guido van Rossum


Guido van Rossum  added the comment:

This cannot be helped (unless we were to add an ugly sys._getframe() call to 
get_type_hints(), which I don't want to do). The solution is to pass 
`localns=locals()`, e.g.

get_type_hints(foo, None, locals())

or

get_type_hints(foo, localns=locals())

--
keywords: +3.6regression
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41865] doc search for super().__init__() returns no useful results

2020-09-27 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41861] Convert sqlite3 to PEP 384

2020-09-27 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +21462
pull_request: https://github.com/python/cpython/pull/22428

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23706] pathlib.Path.write_text should include a newline argument

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It should work exactly as the newline argument of open(). Anything else would 
be surprising.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Do you think it would help if the exception was of type UnhashableType

That would not add more information. The message already says "unhashable 
type".  Saying it twice doesn't help.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: FW: pipenv has issues

2020-09-27 Thread Mats Wichmann
On 9/25/20 10:00 PM, Rhett Prince wrote:
> see below: 
> 
>  
> 
> pipenv gets lost and crashes.  
> 
>  
> 
>  
> 
> hi, where do we write to to post defects in  pipenv? on a windows 8.1
> machine after installing pipenv with poip as administrator  pipenv simply
> crashes with a trace dump  it gets confused with an old version of anaconda
> and crashes. my base python is 3.8 
> 
>  
> 
> please let me know where to send defects about pipenv 

The project lives within the PyPA group:

https://github.com/pypa/pipenv


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23706] pathlib.Path.write_text should include a newline argument

2020-09-27 Thread Maxim Burov


Maxim Burov  added the comment:

For the newline parameter, what is the expected behaviour? To work as newline 
from io.open() which supports only so called "legal" newlines which are: None, 
'', '\n', '\r', and '\r\n', or to allow users use any sequence as newline hence 
do replacing before passing text to io.open()?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Joe Pfeiffer
Stephane Tougard  writes:

> On 2020-09-27, Stefan Ram  wrote:
>>>Is there any other instruction to end a if than pass and ensure Emacs
>>>does not break the indentation during a copy paste or an indent-region ?
>>
>>   We usually do not wish to tie our code to a defective editor.
>>   I use vi, and can assure you that there is no such restriction
>>   in a real editor.
>
> You do not answer the question. I consider that indentation alone is not
> enough to make the end of a block. It's not a question of editor and I
> had some issues with vim as well because of that.
>
> pass looks good to me to end a if block, continue is good to end a for
> block and return is good to end a def block. If that's NOT good, just
> tell me why and give me another solution to end a block who is not the
> indentation because an indentation is not good enough for me to end a
> block and it may trigger some problem when using different editors or
> tools on the code.

The language designers appear to disagree with you.

Decades ago I learned C after having first become proficient in Pascal,
and *really* didn't like the terseness of the block beginning and ending
symbols.

So, I went through a phase in which I wrote lots of macroes like
#define begin {
#define end }

and so forth.  What I discovered in fairly short order was that it made
it easier for me to read my own code, but did absolutely nothing for
either me reading other people's code, nor for them reading mine.  I
eventually concluded my best move was to just suck it up and learn to
program in the language as intended.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24427] subclass of multiprocessing Connection segfault upon attribute acces

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I think this issue is out of date. 

1. I replaced the import statement in the script by "from 
multiprocessing.connection import Connection" and it gave "AttributeError: 
'Crash' object has no attribute 'bar'" rather than a segfault. 

2.  I can't find "ConnectionObject" in the current codebase.

--
components: +Interpreter Core
nosy: +iritkatriel
type:  -> crash

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread hai shi


hai shi  added the comment:

> You always can use PyObject_CallMethod(). It is not a method called in tight 
> loop for which the overhead of calling method is significant.
Thanks, serhiy. You are right.
To PR19069, it's fine to use `PyList_SetSlice` or `PyObject_CallMethod`.
We don't have the enough reason to add `PyList_Remove()`,so I decided close 
this bpo now.

PS: I attach a PR which have add `PyList_Remove` in here in case we will meet 
another appropriate user case somedays: 
https://github.com/python/cpython/compare/master...shihai1991:add_PyList_Remove?expand=1

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41842] Add codecs.unregister() to unregister a codec search function

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

If add a function for unregistering a codec search function, it would be worth 
to add also a function for unregistering an error handler.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2020-09-27 Thread Eric V. Smith


Change by Eric V. Smith :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

literal_eval() is not purposed to evaluate arbitrary arithmetic expressions. It 
is only purposed to handle strings produced by repr() of some simple builtin 
objects. repr(6j+3) is '(3+6j)', not '(6j+3)' and not '(6j--3)', so it accepts 
the former form and not the latters.

If Nick no longer works on this I propose to close this issue. literal_eval() 
supports now more types of expressions, but it is more strict in other cases. I 
have doubts that any test changes are applicable to the current code.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13790] In str.format an incorrect error message for list, tuple, dict, set

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

This seems complete.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41872] get_type_hints fails to resolve forward references in nested function

2020-09-27 Thread Chris Withers


New submission from Chris Withers :

Reproducer:

def test_forward_type_references(self):
def foo(a: 'Foo') -> 'Bar': pass

class Foo: pass
class Bar: pass

get_type_hints(foo)


The above gives the following exception, rather than resolving the type:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:1001: 
in get_type_hints
value = _eval_type(value, globalns, localns)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:260: 
in _eval_type
return t._evaluate(globalns, localns)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py:464: 
in _evaluate
eval(self.__forward_code__, globalns, localns),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   NameError: name 'Foo' is not defined

--
components: Library (Lib)
messages: 377569
nosy: cjw296
priority: normal
severity: normal
status: open
title: get_type_hints fails to resolve forward references in nested function
type: behavior
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

You always can use PyObject_CallMethod(). It is not a method called in tight 
loop for which the overhead of calling method is significant.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40471] Grammar typo in issubclass docstring

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

Should this PR be backported? Otherwise this issue can be closed.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41871] Add PyList_Remove() in listobject.c

2020-09-27 Thread hai shi


New submission from hai shi :

Do we need add PyList_Remove() in C level? same thing like list.remove().
As victor comment in: 
https://github.com/python/cpython/pull/19069#discussion_r491893466.

--
components: C API
messages: 377566
nosy: shihai1991, vstinner
priority: normal
severity: normal
status: open
title: Add PyList_Remove() in listobject.c
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


Change by Dong-hee Na :


--
components: +Interpreter Core

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


Change by Dong-hee Na :


--
keywords: +patch
pull_requests: +21461
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22427

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41870] Use PEP 590 vectorcall to speed up calls to bool()

2020-09-27 Thread Dong-hee Na


New submission from Dong-hee Na :

bool type is well-used builtin types, I noticed that if we use vector call to 
bool type, it shows the awesome performance enhancement.

Mean +- std dev: [master] 91.4 us +- 3.3 us -> [vectorcall] 48.6 us +- 3.1 us: 
1.88x faster (-47%)

--
assignee: corona10
files: bench_bool.py
messages: 377565
nosy: corona10, vstinner
priority: normal
severity: normal
status: open
title: Use PEP 590 vectorcall to speed up calls to bool()
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file49475/bench_bool.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41858] Fix incomplete line on optparse documentation

2020-09-27 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Thanks for the help and review!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39862] Why are the union relationships not implemented by default for ≤ and ≥?

2020-09-27 Thread Géry

Géry  added the comment:

Alright @rhettinger, here is the post: 
https://discuss.python.org/t/add-missing-default-implementations-of-le-and-ge/5327

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread 2QdxY4RzWzUUiLuE
On 2020-09-27 at 15:18:44 +0800,
Stephane Tougard via Python-list  wrote:

> In many non declarative language, if I do print($var), it just prints
> and undefined value with returning an error.

If I want "many non declarative language[s]," I know where to find them,
and I won't expect them to honor Python's semantics.  In Python, a name
doesn't have a value unless and until you bind it to one.

There's a lot more to learning a new language than the syntax.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I just noticed that the patch by Serhiy has unit tests for this case, expecting 
ValueError. So this is apprently a feature and not a bug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41861] Convert sqlite3 to PEP 384

2020-09-27 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a937ab45d6af4f99ff16fec73d5d75d93c569456 by Erlend Egeberg 
Aasland in branch 'master':
bpo-41861: Convert _sqlite3 cache and node static types to heap types (GH-22417)
https://github.com/python/cpython/commit/a937ab45d6af4f99ff16fec73d5d75d93c569456


--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17490] Improve ast.literal_eval test suite coverage

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

I think this is a bug in literal_eval:

>>> 3+6j
(3+6j)
>>> 6j+3
(3+6j)
>>> ast.literal_eval('3+6j')
(3+6j)
>>> ast.literal_eval('6j+3')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\User\src\cpython\lib\ast.py", line 105, in literal_eval
return _convert(node_or_string)
  File "C:\Users\User\src\cpython\lib\ast.py", line 104, in _convert
return _convert_signed_num(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 78, in _convert_signed_num
return _convert_num(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 69, in _convert_num
_raise_malformed_node(node)
  File "C:\Users\User\src\cpython\lib\ast.py", line 66, in _raise_malformed_node
raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: 


literal_eval accepts complex rhs, but not lhs: 
https://github.com/python/cpython/blame/master/Lib/ast.py#L99
if isinstance(left, (int, float)) and isinstance(right, complex):

This was introduced here, I'm not sure why:
https://github.com/python/cpython/commit/d8ac4d1d5ac256ebf3d8d38c226049abec82a2a0


In Nick's aborted patch, he removed that check.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Use of a variable in parent loop

2020-09-27 Thread Manfred Lotz
On Sun, 27 Sep 2020 15:18:44 +0800
Stephane Tougard  wrote:

> On 2020-09-27, 2qdxy4rzwzuui...@potatochowder.com
> <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > As ChrisA noted, Python almost always Just Works without
> > declarations. If you find yourself with a lot of global and/or
> > nonlocal statements, perhaps you're [still] thinking in another
> > language.  
> 
> 
> I don't really agree with that, trying to use an undeclared
> object/variable/whatever :
> 
> Python 3.7.7 (default, Aug 22 2020, 17:07:43) 
> [GCC 7.4.0] on netbsd9
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print(name)  
> Traceback (most recent call last):
>   File "", line 1, in 
>   NameError: name 'name' is not defined
>   >>>   
> 
> You can say it's not the "declaration" the issue, it's the
> "definition", that's just a matter of vocabulary and it does not
> answer the question.
> 
> In many non declarative language, if I do print($var), it just prints
> and undefined value with returning an error.
> 
> 

It is very good that you try out things. Nevertheless, it is also good
to read. In other words the combination of reading and trying out
things is the best way to make progress.

Here some pointers

pass

- http://localhost:2015/tutorial/controlflow.html#pass-statements

about variables

- https://realpython.com/python-variables/ 

Regarding your question above: As long as `name` is not attached to an
object it doesn't exist and the error message above is correct.

You have to assign a value (or object as everything is an object in
Python) to `name`, Then you can use it. 


(In comparison to guys like ChrisA and StefanR and others here I am also
a Python beginner)


-- 
Manfred

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Chris Angelico
On Sun, Sep 27, 2020 at 9:01 PM Stephane Tougard via Python-list
 wrote:
>
> On 2020-09-27, 2qdxy4rzwzuui...@potatochowder.com 
> <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > As ChrisA noted, Python almost always Just Works without declarations.
> > If you find yourself with a lot of global and/or nonlocal statements,
> > perhaps you're [still] thinking in another language.
>
>
> I don't really agree with that, trying to use an undeclared
> object/variable/whatever :
>
> Python 3.7.7 (default, Aug 22 2020, 17:07:43)
> [GCC 7.4.0] on netbsd9
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print(name)
> Traceback (most recent call last):
>   File "", line 1, in 
>   NameError: name 'name' is not defined
>   >>>
>
> You can say it's not the "declaration" the issue, it's the "definition",
> that's just a matter of vocabulary and it does not answer the question.
>
> In many non declarative language, if I do print($var), it just prints
> and undefined value with returning an error.
>

>>> name = "Fred"
>>> print(name)
Fred

Lack of declaration doesn't imply that every variable is initialized
to some null value.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Chris Angelico
On Sun, Sep 27, 2020 at 9:01 PM Stephane Tougard via Python-list
 wrote:
>
> On 2020-09-27, Stefan Ram  wrote:
> >>Is there any other instruction to end a if than pass and ensure Emacs
> >>does not break the indentation during a copy paste or an indent-region ?
> >
> >   We usually do not wish to tie our code to a defective editor.
> >   I use vi, and can assure you that there is no such restriction
> >   in a real editor.
>
> You do not answer the question. I consider that indentation alone is not
> enough to make the end of a block. It's not a question of editor and I
> had some issues with vim as well because of that.

Why? What benefit do you gain by having a keyword like that?
Indentation DOES end a block, and adding a noise word just before you
unindent just leaves the possibility for it to be incorrect and thus
misleading - not to mention that it's fundamentally misleading to
anyone who is accustomed to Python syntax and the normal use of those
keywords.

If you MUST use a block-end marker, try "# end" instead - at least
then everyone *knows* it's nothing more than a comment.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, Stefan Ram  wrote:
>>Is there any other instruction to end a if than pass and ensure Emacs
>>does not break the indentation during a copy paste or an indent-region ?
>
>   We usually do not wish to tie our code to a defective editor.
>   I use vi, and can assure you that there is no such restriction
>   in a real editor.

You do not answer the question. I consider that indentation alone is not
enough to make the end of a block. It's not a question of editor and I
had some issues with vim as well because of that.

pass looks good to me to end a if block, continue is good to end a for
block and return is good to end a def block. If that's NOT good, just
tell me why and give me another solution to end a block who is not the
indentation because an indentation is not good enough for me to end a
block and it may trigger some problem when using different editors or
tools on the code.

>   Objects never are declared, at most names are declared.
>   /First/ learn a language, /then/ suggest changes.

Are all pythonist such pain in the ass or are you an exception ?

I've never suggesting to change the language, I'm asking if there is way
to do things. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-27, 2qdxy4rzwzuui...@potatochowder.com 
<2qdxy4rzwzuui...@potatochowder.com> wrote:
> As ChrisA noted, Python almost always Just Works without declarations.
> If you find yourself with a lot of global and/or nonlocal statements,
> perhaps you're [still] thinking in another language.


I don't really agree with that, trying to use an undeclared
object/variable/whatever :

Python 3.7.7 (default, Aug 22 2020, 17:07:43) 
[GCC 7.4.0] on netbsd9
Type "help", "copyright", "credits" or "license" for more information.
>>> print(name)
Traceback (most recent call last):
  File "", line 1, in 
  NameError: name 'name' is not defined
  >>> 

You can say it's not the "declaration" the issue, it's the "definition",
that's just a matter of vocabulary and it does not answer the question.

In many non declarative language, if I do print($var), it just prints
and undefined value with returning an error.


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41114] "TypeError: unhashable type" could often be more clear

2020-09-27 Thread Irit Katriel


Irit Katriel  added the comment:

Do you think it would help if the exception was of type UnhashableType 
(subclass of TypeError)? This would give the user a hint that this error is a 
thing which is worth looking for in the docs and understanding.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41858] Fix incomplete line on optparse documentation

2020-09-27 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the report and the PR, Emmanuel!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41863] IDLE shell not opening with 3.5 on Mac Mohave.

2020-09-27 Thread GJL


GJL  added the comment:

Thank you both. Decided to just download 3.8.6 instead of dealing with 3.5

IDLE shell works. Appreciate the help.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com