Re: Use of a variable in parent loop

2020-09-28 Thread 황병희
Stephane Tougard writes: > ... > It's normal, he was an ass. When I manage a team, I don't enforce tools > or language, I ask them to work the best way they can to get the things > done. If they want to write C in Perl (as I often do), I'm happy. If > they prefer Ruby (that I never learnt), or Li

Re: Use of a variable in parent loop

2020-09-28 Thread Python
On Sun, Sep 27, 2020 at 03:18:44PM +0800, 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 glo

Re: Use of a variable in parent loop

2020-09-28 Thread Grant Edwards
On 2020-09-27, Stephane Tougard via Python-list wrote: > However, I discovered that Emacs interprets as well an empty line or a > comment as a breaking point of a block, it's not as good as the use of > pass because I still have to indent up manually, but at least the > indent-region does not bre

Re: Use of a variable in parent loop

2020-09-28 Thread Grant Edwards
On 2020-09-27, Terry Reedy wrote: > 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

Re: Use of a variable in parent loop

2020-09-28 Thread Stephane Tougard via Python-list
On 2020-09-27, Joe Pfeiffer wrote: > 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

Re: Use of a variable in parent loop

2020-09-28 Thread Stephane Tougard via Python-list
On 2020-09-27, MRAB wrote: >> 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. I would do it in Perl, LOL. -- https://mail.python.org/mailman/listinfo/pyth

Re: Use of a variable in parent loop

2020-09-28 Thread Stephane Tougard via Python-list
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. -- https://mail.python.org/mailman/lis

Re: Use of a variable in parent loop

2020-09-28 Thread Stephane Tougard via Python-list
On 2020-09-27, Grant Edwards wrote: > Maybe you need to choose different editors and tools. In my world, humans don't adapt to tools but human adapt tools to their needs. > A guy I worked for many years ago used to write BASIC programs in C by > using a bizarre set of pre-processor macros. Whil

Re: Use of a variable in parent loop

2020-09-28 Thread Manfred Lotz
On Mon, 28 Sep 2020 13:39:08 +0800 Stephane Tougard wrote: > 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 > >

Re: Use of a variable in parent loop

2020-09-28 Thread Christian Gollwitzer
Am 28.09.20 um 07:38 schrieb Stephane Tougard: 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 i

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 si

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 wri

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

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 arg

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 valu

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"

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

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

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 po

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

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 language

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 mar

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

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

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

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 t

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

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

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 othe

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

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

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

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

RE: Use of a variable in parent loop

2020-09-27 Thread Avi Gross via Python-list
es 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-li

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

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 hono

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

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/

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 t

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

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

Re: Use of a variable in parent loop

2020-09-26 Thread 2QdxY4RzWzUUiLuE
On 2020-09-27 at 03:36:48 +0800, Stephane Tougard via Python-list wrote: > Anyway, there's no perfect language, the point is to know it ... Yes. > ... It's just confusing I still have to declare or not declare an > object depending on the action I have with it. As ChrisA noted, Python almost a

Re: Use of a variable in parent loop

2020-09-26 Thread Stephane Tougard via Python-list
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

Re: Use of a variable in parent loop

2020-09-26 Thread Terry Reedy
On 9/26/2020 12:43 AM, Stephane Tougard via Python-list wrote: [Example of Perl block scoping.] ===PYTHON=== #!/usr/local/bin/python if 4 == 4: if True: # Only usefel in Python if you might might to switch to False. name = "Stephane" print(name) pass Noise. Only 'pass' wh

Re: Use of a variable in parent loop

2020-09-26 Thread Chris Angelico
On Sat, Sep 26, 2020 at 4:01 PM Stephane Tougard via Python-list wrote: > > > Hello All, > > I've been working with Perl a long time and recently started to use > Python. I've been surprised by one behavior of Python. > > In Perl: > > ===PERL=== > #!/usr/pkg/bin/perl > > use strict; > > if(4 == 4)

Re: Use of a variable in parent loop

2020-09-26 Thread Joel Goldstick
On Sat, Sep 26, 2020 at 2:01 AM Stephane Tougard via Python-list wrote: > > > Hello All, > > I've been working with Perl a long time and recently started to use > Python. I've been surprised by one behavior of Python. > > In Perl: > > ===PERL=== > #!/usr/pkg/bin/perl > > use strict; > > if(4 == 4)