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

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

Use of a variable in parent loop

2020-09-25 Thread Stephane Tougard via Python-list
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) { my $name = "Stephane"; print("$name\n" } print("Out $name\n"); = This

Re: Threading plus multiprocessing plus cv2 error

2020-08-30 Thread Stephane Tougard via Python-list
On 2020-08-30, Barry wrote: >* The child process is created with a single thread—the one that > called fork(). The entire virtual address space of the parent is > replicated in the child, including the states of mutexes, > condition variables, and other pthr

Re: Threading plus multiprocessing plus cv2 error

2020-08-30 Thread Stephane Tougard via Python-list
On 2020-08-30, Chris Angelico wrote: >> I'm not even that makes sense, how 2 processes can share a thread ? >> > They can't. However, they can share a Thread object, which is the > Python representation of a thread. That can lead to confusion, and > possibly the OP's error (I don't know for sure,

Re: Threading plus multiprocessing plus cv2 error

2020-08-29 Thread Stephane Tougard via Python-list
On 2020-08-29, Dennis Lee Bieber wrote: > Under Linux, multiprocessing creates processes using fork(). That means > that, for some fraction of time, you have TWO processes sharing the same > thread and all that entails (if it doesn't overlay the forked process with > a new executable, they a

Re: Multithread and locking issue

2020-05-14 Thread Stephane Tougard
On 2020-05-15, Chris Angelico wrote: > Seconded. If you know how many threads you're going to have, just open > that many connections. If not, there's a connection-pooling feature as > part of psycopg2 (if I'm not mistaken). This would be far far easier > to work with than a fragile queueing setu

Re: Multithread and locking issue

2020-05-14 Thread Stephane Tougard
On 2020-05-14, MRAB wrote: > On 2020-05-14 23:36, Stephane Tougard wrote: >> > Are there 100 threads running execute_sql? Do you put 100 "EXIT" > messages into the queue, one for each thread? Nope, the EXIT comes from the main thread at the very end, once all other thr

Multithread and locking issue

2020-05-14 Thread Stephane Tougard
Hello, A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no issue with the return of the SQL request). As lon