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


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 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 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 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 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


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


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


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.
--
https://mail.p

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 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 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


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


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 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


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, 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


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


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


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 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: 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 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


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 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: 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, 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, 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 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 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 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 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 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


Re: Use of a variable in parent loop

2020-09-27 Thread Stephane Tougard via Python-list
On 2020-09-28, MRAB  wrote:
> It's used where the language requires a statement.
>
> In, say, C, you would use empty braces:
>
>  while (process_next_item()) {
>  /* Do nothing. */
>  }

If I want to express nothing in C, I put nothing and it works fine.

#include 

int main(int argc, char * argv[])
{
  if(1 == 1)
;
  printf("Hello\n");
  return 0;
}

>  while process_next_item():
>  # Do nothing.
>  pass

while p():
# do nothing
continue

-- 
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-28, Manfred Lotz  wrote:
> 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.

The URL you gave is pointing to your localhost, your own computer if you
prefer.
-- 
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-28, Cameron Simpson  wrote:
> That said, Stephane: I don't believe in "best practice" as _the_ best 
> practice, but I certainly believe there's "bad practice".

I kind of disagree with that, what I mean that there is no bad practice
to get the work done. There may be bad practice to write a code that you
intend to share or as part of a bigger project. Still, that depends how
you deliver your code.

For example, in Perl I sometime make extensive usage of goto(), through
this is usually considered bad practice I've read several documents who
stated otherwise.

Using goto() may make the code much simpler to understand when you
encounter a lot of error cases in a code.

The try: except: of Python, as I understand it, is never more than a
goto() in disguise (at least, that's the way I use goto() in Perl).

-- 
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-28, Mike Dewhirst  wrote:
> [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.

Let's be franc, I can read my own Perl code (very C-ish) without any
issue. I live with it since 20 years.

But I've seen some Perl code that is total gebbiresh to me, still doing
the job correctly.


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