From Gronicus at SGA.Ninja Tue Sep 1 04:22:04 2020 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 1 Sep 2020 04:22:04 -0400 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? Message-ID: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> Glutton for punishment, I am looking into designing another .py program. I would like to pull two columns of information from Excel but the more I look into coding on the 'net, the more confusing it looks. I don't understand what I need to import or install to get the link. Steve Footnote: Some mornings it just isn't worth chewing through the leather straps. From research at johnohagan.com Tue Sep 1 04:41:09 2020 From: research at johnohagan.com (John O'Hagan) Date: Tue, 1 Sep 2020 18:41:09 +1000 Subject: Threading plus multiprocessing plus cv2 error In-Reply-To: <0A169682-FF32-45E0-923F-B6AE1A566062@barrys-emacs.org> References: <20200829182410.4d3633f1@e7240.home> <5f1lkf9343bqu3u0ius28rh63o255d433a@4ax.com> <0A169682-FF32-45E0-923F-B6AE1A566062@barrys-emacs.org> Message-ID: <20200901183811.31f087e1@e7240.home> On Sun, 30 Aug 2020 09:59:15 +0100 Barry Scott wrote: > > > > On 29 Aug 2020, at 18:01, Dennis Lee Bieber > > wrote: > > > > On Sat, 29 Aug 2020 18:24:10 +1000, John O'Hagan > > declaimed the following: > > > >> There's no error without the sleep(1), nor if the Process is > >> started before the Thread, nor if two Processes are used instead, > >> nor if two Threads are used instead. IOW the error only occurs if > >> a Thread is started first, and a Process is started a little later. > >> > >> Any ideas what might be causing the error? > >> > > > > 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 are > > sharing the thread until the thread exits). > > In the parent you have 1 or more threads. > > After fork the new process has 1 thread, which is not shared with the > parent. Any extra threads are not in the new process. But the memory > in the new process will have data structures from the parents other > threads. > > So no you never have two processes sharing an threads. > > This leads to problems with locks. > > Barry > > > > > > https://stackoverflow.com/questions/54466572/how-to-properly-multithread-in-opencv-in-2019 > > (which points to) > > https://answers.opencv.org/question/32415/thread-safe/?answer=32452#post-id-32452 > > """ > > The library itself is thread safe in that you can have multiple > > calls into the library at the same time, however the data is not > > always thread safe. """ > > > > The sleep(1), when compounded with the overhead of starting > > the thread, and then starting the process, likely means the thread > > had exited before the process actually is started. Try replacing > > the sleep(2) in the work code with something like sleep(30) -- I > > hypothesize that you'll get the same error condition even with the > > sleep(1) in place. > > > > > > -- > > Wulfraed Dennis Lee Bieber AF6VN > > wlfraed at ix.netcom.com > > http://wlfraed.microdiversity.freeddns.org/ > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > Thanks to all who replied. I'm still none the wiser about the error, but I learned something about multiprocessing! John From __peter__ at web.de Tue Sep 1 06:12:53 2020 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Sep 2020 12:12:53 +0200 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> Message-ID: Steve wrote: > Glutton for punishment, I am looking into designing another .py program. > I would like to pull two columns of information from Excel but the more I > look > into coding on the 'net, the more confusing it looks. I don't understand > what I need to import or install to get the link. openpyxl should be fine to to extract data from an Excel table: https://openpyxl.readthedocs.io/en/stable/usage.html Of course this cannot magically turn Python into Basic, and there are probably other limitations. From Richard at Damon-Family.org Tue Sep 1 08:55:55 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 1 Sep 2020 08:55:55 -0400 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> Message-ID: <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> On 8/31/20 6:05 PM, Chris Angelico wrote: > On Tue, Sep 1, 2020 at 5:08 AM Richard Damon wrote: >> The file descriptor could remember the path used to get to it. chroot >> shows that .. needs to be somewhat special, as it needs to go away for >> anyone that . is their current root. > But my point is that there might not actually *be* a valid path that > gets you to a file descriptor. It can't remember something that > doesn't exist. (And it's pretty impractical to do that even if it > does.) Remember, we are talking about a hypothetical OS that handles hardlinks to directories, and defines that .. will point to the parent used to come to it, NOT just having current *NIX allowing hardlinks to directories with no remediation of the issues cause. One result of the definition, is that when you open a file/directory, if it might be a directory, the system WILL need to remember the path to it (so as to provide a value for ..) and that memory will provide a 'reference' for the directories so they can't go away (just like an unlinked file stays around will someone has it open). The normal way to get a file descriptor starts from a path, so the path had to exist in the first place, and since we are assuming that to get .., it keep a reference to that path, it can't truly go away. > >> I see no problem with it being a hardlink, and in fact, executables know >> the name they were executed by, so directories knowing the path isn't >> that different. > Actually no, they don't. They are all taught, and being taught, > believe, that their first argument is their name. > >> The key differnce between a hardlink and a symlink is >> that hardlinks maintain existance, and always point to something that >> exists (things know how many hardlinks refer to them). symlinks don't >> reference the actual file object, but the symbolic path to it, which may >> or may not actually exist, and who doesn't know such a link exists. > Symlinks refer to a path, which may be relative. Hardlinks refer to an > inode (or whatever other way you choose to identify an actual file's > contents). It's entirely possible to have an open file or directory > that no longer has any actual path referring to it; in fact, things > don't know how many hardlinks refer to them, just how many references > there are. > > ChrisA -- Richard Damon From rosuav at gmail.com Tue Sep 1 09:03:48 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 1 Sep 2020 23:03:48 +1000 Subject: Symlinks already present In-Reply-To: <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On Tue, Sep 1, 2020 at 10:57 PM Richard Damon wrote: > > On 8/31/20 6:05 PM, Chris Angelico wrote: > > On Tue, Sep 1, 2020 at 5:08 AM Richard Damon wrote: > >> The file descriptor could remember the path used to get to it. chroot > >> shows that .. needs to be somewhat special, as it needs to go away for > >> anyone that . is their current root. > > But my point is that there might not actually *be* a valid path that > > gets you to a file descriptor. It can't remember something that > > doesn't exist. (And it's pretty impractical to do that even if it > > does.) > > Remember, we are talking about a hypothetical OS that handles hardlinks > to directories, and defines that .. will point to the parent used to > come to it, NOT just having current *NIX allowing hardlinks to > directories with no remediation of the issues cause. Yes. I'm assuming that you can define things any way you like. > One result of the definition, is that when you open a file/directory, if > it might be a directory, the system WILL need to remember the path to it > (so as to provide a value for ..) and that memory will provide a > 'reference' for the directories so they can't go away (just like an > unlinked file stays around will someone has it open). The normal way to > get a file descriptor starts from a path, so the path had to exist in > the first place, and since we are assuming that to get .., it keep a > reference to that path, it can't truly go away. > But as I've pointed out, you don't always *have* a valid path. File descriptors can be passed from process to process (most commonly by being retained when you fork and not closed when you exec, but there are other ways too, eg sockets), so even though starting with a path is the most common, it isn't the only way, and you could easily have an FD with no associated path, and then read it to find out what ".." is. Also, even if all that could be solved, I don't like the idea that reading the same directory from two different sources leads to different results. Is it really the same directory if reading it in different ways gives different results? ChrisA From akkana at shallowsky.com Tue Sep 1 10:44:29 2020 From: akkana at shallowsky.com (Akkana Peck) Date: Tue, 1 Sep 2020 08:44:29 -0600 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> Message-ID: <20200901144429.GA2063@shallowsky.com> Steve writes: > Glutton for punishment, I am looking into designing another .py program. I > would like to pull two columns of information from Excel but the more I look I've found the xlrd module easy to use for extracting data from Excel files. But I've only used it on .xsl and .xsls. I've never encountered a .xlsm, but a web search tells me that extension means it has macros, and if you want macros to be executed, that may be quite a bit more difficult. One person says xlrd works for xlsm: https://stackoverflow.com/questions/23554808/how-to-extract-sheet-from-xlsm-and-save-it-as-csv-in-python and the discussion also includes an example using pandas. So now you have three possible options (including the openpyxl someone else suggested). ...Akkana From eryksun at gmail.com Tue Sep 1 14:55:23 2020 From: eryksun at gmail.com (Eryk Sun) Date: Tue, 1 Sep 2020 13:55:23 -0500 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 9/1/20, Chris Angelico wrote: > > Also, even if all that could be solved, I don't like the idea that > reading the same directory from two different sources leads to > different results. Is it really the same directory if reading it in > different ways gives different results? What's your take on the following example in Linux? "test2/spam" is a bind mount for "test1/spam", and note that `mount --bind` in Linux is a namespace operation, i.e. it's not a new device: >>> os.lstat('test1/spam').st_dev == os.lstat('test2/spam').st_dev True >>> os.lstat('test1/spam').st_ino == os.lstat('test2/spam').st_ino True According to POSIX (st_dev, st_ino), it's the same directory, yet the ".." entry evaluates depending on the path parsing context: >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino True >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino True From python-list at andras.tantosonline.com Tue Sep 1 00:45:18 2020 From: python-list at andras.tantosonline.com (Andras Tantos) Date: Mon, 31 Aug 2020 21:45:18 -0700 Subject: How to set custom locals for function call? Message-ID: All, I'm new here, so please direct me to the right forum, if this is not the one... What I'm trying to do is to call a function, but monitor all the local variable accesses within that function. What I thought I would need to do, is to |exec| the function with a custom |locals| dictionary. The code below attempts to do it. |classMySymbolTable(dict):defset_type(self,t):self.type =t def__getitem__(self,key):print(f"Requesting key {key} from {self.type} table")returnsuper().__getitem__(key)def__setitem__(self,key,value):print(f"Setting key {key} from {self.type} table to value {value}")returnsuper().__setitem__(key,value)defmylocals(func):defwrapper(*args,**kwargs):loc =MySymbolTable()glob =MySymbolTable(globals())loc.set_type("local")glob.set_type("global")exec(func.__code__,glob,loc)returnwrapper @mylocalsdeffun1():print(f"fun1 with locals: {type(locals())} and globals: {type(globals())}")a =1b =2c =3a =b c =5fun1()| However, when I run it, I get the following output: |Requestingkey printfromglobaltable Requestingkey type fromglobaltable Requestingkey locals fromglobaltable Requestingkey type fromglobaltable Requestingkey globals fromglobaltable fun1 withlocals:andglobals:| That is to say, global accesses are redirected to my custom dict, but local assignments are not. You can even see that in the types of the two objects printed in the last line. My hunch is that since I'm using the functions |__code__| member, I end up executing pre-compiled byte-code which has already assumptions about the locals dict built into it. If I'm right (or even if I'm not), what is the right way to achieve my goal: that local assignments get redirected to the supplied dictionary? Thanks, Andras Tantos From beltraoengenhariaclinica at live.com Tue Sep 1 05:36:10 2020 From: beltraoengenhariaclinica at live.com (=?iso-8859-1?Q?Lourival_Beltr=E3o_Martins_Jr?=) Date: Tue, 1 Sep 2020 09:36:10 +0000 Subject: Repair was successful In-Reply-To: References: Message-ID: Lourival Beltr?o Medical Physicist Supervisor Radiation Protection Nuclear Engineer *********************** Go green, make sense ________________________________ Please consider the environment before printing this e-mail. The contents of this e-mail message (including any attachments) are confidential and are intended to be conveyed for the use of the recipient to whom it is addressed only. If you receive this transmission in error, please notify the sender of this immediately and delete the message from your system. Any distribution, reproduction, or use of this message by someone other than the recipient is not authorized and may be unlawful. ________________________________ From: Lourival Beltr?o Martins Jr Sent: Tuesday, September 1, 2020 10:07 To: python-list at python.org Subject: Repair was successful Hello, Good Morning! I have python 3.7 installed on my laptop and I did the download the 3.8.5 version. The message "Repair installation" appears all times when I open Spyder 4.0. Could you help me to fix this issue? Thank you very much! Beltr?o Enviado do Correio para Windows 10 From grant.b.edwards at gmail.com Tue Sep 1 14:42:05 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 1 Sep 2020 18:42:05 -0000 (UTC) Subject: Symlinks already present References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 2020-09-01, Richard Damon wrote: > Remember, we are talking about a hypothetical OS that handles hardlinks > to directories, and defines that .. will point to the parent used to > come to it, NOT just having current *NIX allowing hardlinks to > directories with no remediation of the issues cause. I can testify from personal experience that SunOS 3/4 was in the latter category. After creating a hard-link to a directory, things like fsck and the filesystem dump backup utility got very upset and confused. IIRC the only way to recover was to nuke the involved inodes then let fsck try to pick up the pieces and put them in the lost+found. IIRC, I managed to recover without losing any files, but it wasn't a fun day. -- Grant From python at mrabarnett.plus.com Tue Sep 1 15:41:22 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 1 Sep 2020 20:41:22 +0100 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On 2020-09-01 05:45, Andras Tantos wrote: > All, > > I'm new here, so please direct me to the right forum, if this is not the > one... > > What I'm trying to do is to call a function, but monitor all the local > variable accesses within that function. What I thought I would need to > do, is to |exec| the function with a custom |locals| dictionary. The > code below attempts to do it. > > |classMySymbolTable(dict):defset_type(self,t):self.type =t > def__getitem__(self,key):print(f"Requesting key {key} from {self.type} > table")returnsuper().__getitem__(key)def__setitem__(self,key,value):print(f"Setting > key {key} from {self.type} table to value > {value}")returnsuper().__setitem__(key,value)defmylocals(func):defwrapper(*args,**kwargs):loc > =MySymbolTable()glob > =MySymbolTable(globals())loc.set_type("local")glob.set_type("global")exec(func.__code__,glob,loc)returnwrapper > @mylocalsdeffun1():print(f"fun1 with locals: {type(locals())} and > globals: {type(globals())}")a =1b =2c =3a =b c =5fun1()| > > However, when I run it, I get the following output: > > |Requestingkey printfromglobaltable Requestingkey type fromglobaltable > Requestingkey locals fromglobaltable Requestingkey type fromglobaltable > Requestingkey globals fromglobaltable fun1 > withlocals:andglobals:| > > That is to say, global accesses are redirected to my custom dict, but > local assignments are not. You can even see that in the types of the two > objects printed in the last line. > > My hunch is that since I'm using the functions |__code__| member, I end > up executing pre-compiled byte-code which has already assumptions about > the locals dict built into it. > > If I'm right (or even if I'm not), what is the right way to achieve my > goal: that local assignments get redirected to the supplied dictionary? > CPython is able to identify all of the local names of a function and, basically, for reasons of efficiency, it uses slots for the local names instead of an actual dict. 'locals()' just returns a dict that represents those local names and their current values, but modifying that dict has no effect on the actual local names. In short, there isn't really a local dict that you can replace. From Gronicus at SGA.Ninja Tue Sep 1 16:16:16 2020 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 1 Sep 2020 16:16:16 -0400 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> Message-ID: <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> Ok, I think I ran into this about a year ago when this was suggested back then. I entered ?pip install pandas? I am told to ?install Anaconda which can be deleted later? (huh?) Then it tells me ?Installing with ?Miniconda? (huh? Huh?) Then ?Installing from PyPl which is what I used to get the same page that is telling me all this? ActivePython, then finally Linux which I am not using. Ok, then I see: Installing from source See the contributing guide for complete instructions on building from the git source tree. Further, see creating a development environment if you wish to create a pandas development environment. And the music goes round and round?.. FootNote: If money does not grow on trees, then why do banks have branches? From: Jeffrey Powell Sent: Tuesday, September 1, 2020 5:33 AM To: Steve Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm file? Hi Steve, Yes, you need to install pandas first. I use pip install pandas Kind regards, Jeffrey Powell On Tue, 1 Sep 2020, 11:15 Steve, > wrote: ModuleNotFoundError: No module named 'pandas' I take it that this is an installation. Is there anything I need to know about this first? Steve FootNote: If money does not grow on trees, then why do banks have branches? From: Jeffrey Powell > Sent: Tuesday, September 1, 2020 4:30 AM To: Steve > Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm file? Hi Steve, Maybe something like this: import pandas as pd dt = pd.read_excel("myData.xls", sheet_name="mySheetName", skiprows=0, usecols=list(range(0,11))) where usecols are the column numbers you want. Kind regards, Jeff On Tue, Sep 1, 2020 at 10:24 AM Steve > wrote: Glutton for punishment, I am looking into designing another .py program. I would like to pull two columns of information from Excel but the more I look into coding on the 'net, the more confusing it looks. I don't understand what I need to import or install to get the link. Steve Footnote: Some mornings it just isn't worth chewing through the leather straps. -- https://mail.python.org/mailman/listinfo/python-list -- Jeffrey Powell, PhD. Senior Data Scientist, Dataworkz.nl From rosuav at gmail.com Tue Sep 1 16:27:24 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 06:27:24 +1000 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On Wed, Sep 2, 2020 at 4:55 AM Eryk Sun wrote: > > On 9/1/20, Chris Angelico wrote: > > > > Also, even if all that could be solved, I don't like the idea that > > reading the same directory from two different sources leads to > > different results. Is it really the same directory if reading it in > > different ways gives different results? > > What's your take on the following example in Linux? > > "test2/spam" is a bind mount for "test1/spam", and note that `mount > --bind` in Linux is a namespace operation, i.e. it's not a new device: > > >>> os.lstat('test1/spam').st_dev == os.lstat('test2/spam').st_dev > True > >>> os.lstat('test1/spam').st_ino == os.lstat('test2/spam').st_ino > True > > According to POSIX (st_dev, st_ino), it's the same directory, yet the > ".." entry evaluates depending on the path parsing context: > > >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino > True > >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino > True When you add ".." to the end of a path, it is very frequently handled textually. Can you do this exercise by actually opening the directories and then using openat or statat? ChrisA From rosuav at gmail.com Tue Sep 1 16:42:10 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 06:42:10 +1000 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On Wed, Sep 2, 2020 at 5:00 AM Andras Tantos wrote: > > All, > > I'm new here, so please direct me to the right forum, if this is not the > one... > > What I'm trying to do is to call a function, but monitor all the local > variable accesses within that function. What I thought I would need to > do, is to |exec| the function with a custom |locals| dictionary. The > code below attempts to do it. > > |classMySymbolTable(dict):defset_type(self,t):self.type =t > def__getitem__(self,key):print(f"Requesting key {key} from {self.type} > table")returnsuper().__getitem__(key)def__setitem__(self,key,value):print(f"Setting > key {key} from {self.type} table to value > {value}")returnsuper().__setitem__(key,value)defmylocals(func):defwrapper(*args,**kwargs):loc > =MySymbolTable()glob > =MySymbolTable(globals())loc.set_type("local")glob.set_type("global")exec(func.__code__,glob,loc)returnwrapper > @mylocalsdeffun1():print(f"fun1 with locals: {type(locals())} and > globals: {type(globals())}")a =1b =2c =3a =b c =5fun1()| Your code's messed up in the post, so I'm guessing on how this is actually meant to be written. Most of your whitespace has been destroyed. > That is to say, global accesses are redirected to my custom dict, but > local assignments are not. You can even see that in the types of the two > objects printed in the last line. > > My hunch is that since I'm using the functions |__code__| member, I end > up executing pre-compiled byte-code which has already assumptions about > the locals dict built into it. Yes; and furthermore, CPython generally doesn't even use a dictionary for a function's locals. Instead, it uses cells in a special array; you can poke around with this by disassembling the code (see the built-in "dis" module for details) and looking at the LOAD_FAST/STORE_FAST opcodes. You might be able to mess with this by using a closure, but local variable references are generally considered to be an implementation detail of the function, and it's not going to be easy to mess with them from the outside reliably. What's the goal here? ChrisA From rosuav at gmail.com Tue Sep 1 16:44:22 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 06:44:22 +1000 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> Message-ID: On Wed, Sep 2, 2020 at 6:17 AM Steve wrote: > > Ok, I think I ran into this about a year ago when this was suggested back then. > > I entered ?pip install pandas? > > I am told to ?install Anaconda which can be deleted later? (huh?) > Then it tells me ?Installing with ?Miniconda? (huh? Huh?) > Then ?Installing from PyPl which is what I used to get the same page that is telling me all this? > > ActivePython, then finally Linux which I am not using. > You're on Windows? Get your pandas here: https://www.lfd.uci.edu/~gohlke/pythonlibs/ ChrisA From Gronicus at SGA.Ninja Tue Sep 1 16:59:52 2020 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 1 Sep 2020 16:59:52 -0400 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> Message-ID: <014e01d680a2$d6ecd1b0$84c67510$@SGA.Ninja> Wow, that is quite a list.... Here is what I narrowed it down to. What does that paragraph starting with "Requires" mean? =================================== Pandas: a cross-section and time series data analysis toolkit. Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. pandas?1.1.1?cp39?cp39?win_amd64.whl ============================================================ Footnote: Mars is the only known planet in our solar system solely inhabited by functioning robots. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Tuesday, September 1, 2020 4:44 PM To: Python Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm file? On Wed, Sep 2, 2020 at 6:17 AM Steve wrote: > > Ok, I think I ran into this about a year ago when this was suggested back then. > > I entered ?pip install pandas? > > I am told to ?install Anaconda which can be deleted later? (huh?) > Then it tells me ?Installing with ?Miniconda? (huh? Huh?) Then > ?Installing from PyPl which is what I used to get the same page that > is telling me all this? > > ActivePython, then finally Linux which I am not using. > You're on Windows? Get your pandas here: https://www.lfd.uci.edu/~gohlke/pythonlibs/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list From eryksun at gmail.com Tue Sep 1 17:05:42 2020 From: eryksun at gmail.com (Eryk Sun) Date: Tue, 1 Sep 2020 16:05:42 -0500 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 9/1/20, Chris Angelico wrote: > On Wed, Sep 2, 2020 at 4:55 AM Eryk Sun wrote: > >> "test2/spam" is a bind mount for "test1/spam", and note that `mount >> --bind` in Linux is a namespace operation, i.e. it's not a new device: >> >> >>> os.lstat('test1/spam').st_dev == os.lstat('test2/spam').st_dev >> True >> >>> os.lstat('test1/spam').st_ino == os.lstat('test2/spam').st_ino >> True >> >> According to POSIX (st_dev, st_ino), it's the same directory, yet the >> ".." entry evaluates depending on the path parsing context: >> >> >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino >> True >> >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino >> True > > When you add ".." to the end of a path, it is very frequently handled > textually. Can you do this exercise by actually opening the > directories and then using openat or statat? The Python example doesn't process the input path to normalize or resolve it, so I assume you mean text-based processing in the kernel for the lstat system call. I can switch to using dir_fd, which is implemented via fstatat in Linux. Showing again that the bind mountpoint is the same directory: >>> fd1 = os.open('test1/spam', 0) >>> fd2 = os.open('test2/spam', 0) >>> fs1, fs2 = os.fstat(fd1), os.fstat(fd2) >>> (fs1.st_dev, fs1.st_ino) == (fs2.st_dev, fs2.st_ino) True In agreement with the previous example, the ".." entry evaluates depending on the original path parsing context of the opened fd: >>> os.lstat('..', dir_fd=fd1).st_ino == os.lstat('test1').st_ino True >>> os.lstat('..', dir_fd=fd2).st_ino == os.lstat('test2').st_ino True From rosuav at gmail.com Tue Sep 1 17:07:53 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 07:07:53 +1000 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: <014e01d680a2$d6ecd1b0$84c67510$@SGA.Ninja> References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> <014e01d680a2$d6ecd1b0$84c67510$@SGA.Ninja> Message-ID: On Wed, Sep 2, 2020 at 6:59 AM Steve wrote: > > Wow, that is quite a list.... > Here is what I narrowed it down to. What does that paragraph starting with "Requires" mean? > > =================================== > Pandas: a cross-section and time series data analysis toolkit. > > Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. > It means you need all those things installed before you can install Pandas. ChrisA From Richard at Damon-Family.org Tue Sep 1 18:02:28 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 1 Sep 2020 18:02:28 -0400 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 9/1/20 9:03 AM, Chris Angelico wrote: > On Tue, Sep 1, 2020 at 10:57 PM Richard Damon wrote: >> On 8/31/20 6:05 PM, Chris Angelico wrote: >>> On Tue, Sep 1, 2020 at 5:08 AM Richard Damon wrote: >>>> The file descriptor could remember the path used to get to it. chroot >>>> shows that .. needs to be somewhat special, as it needs to go away for >>>> anyone that . is their current root. >>> But my point is that there might not actually *be* a valid path that >>> gets you to a file descriptor. It can't remember something that >>> doesn't exist. (And it's pretty impractical to do that even if it >>> does.) >> Remember, we are talking about a hypothetical OS that handles hardlinks >> to directories, and defines that .. will point to the parent used to >> come to it, NOT just having current *NIX allowing hardlinks to >> directories with no remediation of the issues cause. > Yes. I'm assuming that you can define things any way you like. > >> One result of the definition, is that when you open a file/directory, if >> it might be a directory, the system WILL need to remember the path to it >> (so as to provide a value for ..) and that memory will provide a >> 'reference' for the directories so they can't go away (just like an >> unlinked file stays around will someone has it open). The normal way to >> get a file descriptor starts from a path, so the path had to exist in >> the first place, and since we are assuming that to get .., it keep a >> reference to that path, it can't truly go away. >> > But as I've pointed out, you don't always *have* a valid path. File > descriptors can be passed from process to process (most commonly by > being retained when you fork and not closed when you exec, but there > are other ways too, eg sockets), so even though starting with a path > is the most common, it isn't the only way, and you could easily have > an FD with no associated path, and then read it to find out what ".." > is. > > Also, even if all that could be solved, I don't like the idea that > reading the same directory from two different sources leads to > different results. Is it really the same directory if reading it in > different ways gives different results? > > ChrisA But when you pass the file descriptors to another process, the OS knows this, so the data that was pointed by the descriptor (which is where you would keep it anyway) still has it.? There is no normal way that I know of from user land to get to a directory except from a path or at least an object that could have remembered a path. For a FD, that FD started with a path, so it could still remember it. Part of your issue is likely that you are used to thinking of the file system as a pure tree, and *nix likes to do that too. Once you accept hard links to directories as 'normal', suddenly the meaning of .. gets funny, as there is not a unique parent, but getting the parent as you got there could be useful for recursive file system searches (which will need protection from getting stuck in a loop). My research says that Unix System V allowed them, but restricted them to super users, to avoid the bigger problems with them. I don't know how it handle the issue of .. -- Richard Damon From python-list at andras.tantosonline.com Tue Sep 1 17:58:10 2020 From: python-list at andras.tantosonline.com (Andras Tantos) Date: Tue, 1 Sep 2020 14:58:10 -0700 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On 9/1/2020 12:41 PM, MRAB wrote: > On 2020-09-01 05:45, Andras Tantos wrote: >> All, >> >> I'm new here, so please direct me to the right forum, if this is not the >> one... >> >> What I'm trying to do is to call a function, but monitor all the local >> variable accesses within that function. What I thought I would need to >> do, is to |exec| the function with a custom |locals| dictionary. The >> code below attempts to do it. >> >> |classMySymbolTable(dict):defset_type(self,t):self.type =t >> def__getitem__(self,key):print(f"Requesting key {key} from {self.type} >> table")returnsuper().__getitem__(key)def__setitem__(self,key,value):print(f"Setting >> >> key {key} from {self.type} table to value >> {value}")returnsuper().__setitem__(key,value)defmylocals(func):defwrapper(*args,**kwargs):loc >> >> =MySymbolTable()glob >> =MySymbolTable(globals())loc.set_type("local")glob.set_type("global")exec(func.__code__,glob,loc)returnwrapper >> >> @mylocalsdeffun1():print(f"fun1 with locals: {type(locals())} and >> globals: {type(globals())}")a =1b =2c =3a =b c =5fun1()| >> >> However, when I run it, I get the following output: >> >> |Requestingkey printfromglobaltable Requestingkey type fromglobaltable >> Requestingkey locals fromglobaltable Requestingkey type fromglobaltable >> Requestingkey globals fromglobaltable fun1 >> withlocals:andglobals:| >> >> That is to say, global accesses are redirected to my custom dict, but >> local assignments are not. You can even see that in the types of the two >> objects printed in the last line. >> >> My hunch is that since I'm using the functions |__code__| member, I end >> up executing pre-compiled byte-code which has already assumptions about >> the locals dict built into it. >> >> If I'm right (or even if I'm not), what is the right way to achieve my >> goal: that local assignments get redirected to the supplied dictionary? >> > CPython is able to identify all of the local names of a function and, > basically, for reasons of efficiency, it uses slots for the local > names instead of an actual dict. 'locals()' just returns a dict that > represents those local names and their current values, but modifying > that dict has no effect on the actual local names. In short, there > isn't really a local dict that you can replace. While I'm sure you're right, it certainly is well hidden: Python 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, 07:34:03) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': } >>> a =3 >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'a': 3} >>> locals()['a'] = 4 >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'a': 4} >>> In other words, I can indeed change the value of a local variable through the locals() dict. I've modified my code to see if I can at least introduce locals through the value passed in for exec, but even that seems to fail: classMySymbolTable(dict): defset_type(self,t): self.type =?t def__getitem__(self,key): print(f"Requesting?key {key}?from {self.type}?table") returnsuper().__getitem__(key) def__setitem__(self,key,value): print(f"Setting?key {key}?from {self.type}?table?to?value {value}") returnsuper().__setitem__(key,?value) defmylocals(func): defwrapper(*args,**kwargs): ????????loc =?MySymbolTable() ????????glob =?MySymbolTable(globals()) ????????loc.set_type("local") ????????loc["xxx"]=123 ????????glob.set_type("global") ????????glob["yyy"]=42 exec(func.__code__,?glob,?loc) return?wrapper @mylocals deffun1(): print("locals?at?the?beginning:") print(", ".join(f"{name}: {value}"for?name,?value inlocals().items())) print("globals?at?the?beginning:") print(", ".join(f"{name}: {value}"for?name,?value inglobals().items())) print(f"fun1?with?locals: {type(locals())}?and?globals: {type(globals())}") ????a =1 ????b =2 ????c =3 ????a =?b ????c =5 print("locals?at?the?end:") print(", ".join(f"{name}: {value}"for?name,?value inlocals().items())) print("globals?at?the?end:") print(", ".join(f"{name}: {value}"for?name,?value inglobals().items())) fun1() This however still fails: Setting key xxx from local table to value 123 Setting key yyy from global table to value 42 Requesting key print from global table locals at the beginning: Requesting key print from global table Requesting key locals from global table Requesting key print from global table globals at the beginning: Requesting key print from global table Requesting key globals from global table __name__: __main__, __doc__: None, __package__: None, __loader__: <_frozen_importlib_external.SourceFileLoader object at 0x000001CA2DC22640>, __spec__: None, __annotations__: {}, __builtins__: , __file__: locals_test.py, __cached__: None, MySymbolTable: , mylocals: , fun1: .wrapper at 0x000001CA2E1394C0>, yyy: 42 Requesting key print from global table Requesting key type from global table Requesting key locals from global table Requesting key type from global table Requesting key globals from global table fun1 with locals: and globals: Requesting key print from global table locals at the end: Requesting key print from global table Requesting key locals from global table a: 2, b: 2, c: 5 Requesting key print from global table globals at the end: Requesting key print from global table Requesting key globals from global table __name__: __main__, __doc__: None, __package__: None, __loader__: <_frozen_importlib_external.SourceFileLoader object at 0x000001CA2DC22640>, __spec__: None, __annotations__: {}, __builtins__: , __file__: locals_test.py, __cached__: None, MySymbolTable: , mylocals: , fun1: .wrapper at 0x000001CA2E1394C0>, yyy: 42 Notice how 'globals()' has the value 'yyy', while 'locals()' doesn't show 'xxx'. It still appears to me that 'exec()' simply ignores the dict passed in as the local parameter: it doesn't even seem to initialize locals() from it. Andras From cs at cskk.id.au Tue Sep 1 18:18:21 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 2 Sep 2020 08:18:21 +1000 Subject: Symlinks already present In-Reply-To: References: Message-ID: <20200901221821.GA9983@cskk.homeip.net> On 01Sep2020 18:42, Grant Edwards wrote: >On 2020-09-01, Richard Damon wrote: >> Remember, we are talking about a hypothetical OS that handles >> hardlinks >> to directories, and defines that .. will point to the parent used to >> come to it, NOT just having current *NIX allowing hardlinks to >> directories with no remediation of the issues cause. > >I can testify from personal experience that SunOS 3/4 was in the >latter category. After creating a hard-link to a directory, things >like fsck and the filesystem dump backup utility got very upset and >confused. IIRC the only way to recover was to nuke the involved >inodes then let fsck try to pick up the pieces and put them in the >lost+found. IIRC, I managed to recover without losing any files, but >it wasn't a fun day. IIRC this is very old behaviour indeed, in that when I was using V7 UNIX the manual mentioned that only root could make a hard link to a directory, and I think there was some allusion to this being how rename was done for directories, just like files (no rename OS call, just link to new name, unlink old). That would mean "mv" was setuid root at that time, which does _not_ ring any bells. So I may be misremembering the details. Cheers, Cameron Simpson From rosuav at gmail.com Tue Sep 1 19:01:07 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 09:01:07 +1000 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On Wed, Sep 2, 2020 at 8:44 AM Andras Tantos wrote: > > While I'm sure you're right, it certainly is well hidden: > > Python 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, > 07:34:03) [MSC v.1916 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> locals() > {'__name__': '__main__', '__doc__': None, '__package__': None, > '__loader__': , '__spec__': > None, '__annotations__': {}, '__builtins__': } > >>> a =3 > >>> locals() > {'__name__': '__main__', '__doc__': None, '__package__': None, > '__loader__': , '__spec__': > None, '__annotations__': {}, '__builtins__': (built-in)>, 'a': 3} > >>> locals()['a'] = 4 > >>> locals() > {'__name__': '__main__', '__doc__': None, '__package__': None, > '__loader__': , '__spec__': > None, '__annotations__': {}, '__builtins__': (built-in)>, 'a': 4} > >>> > > In other words, I can indeed change the value of a local variable > through the locals() dict. Not quite. What you're seeing there is that there aren't any locals, and you're getting the globals: >>> locals() is globals() True In this situation, locals() DOES return a real dictionary, and it can be manipulated as one. But only because it's the same as globals(), and you can do all that with globals. > I've modified my code to see if I can at > least introduce locals through the value passed in for exec, but even > that seems to fail: > > classMySymbolTable(dict): > defset_type(self,t): > self.type = t > def__getitem__(self,key): > print(f"Requesting key {key} from {self.type} table") > returnsuper().__getitem__(key) > def__setitem__(self,key,value): > print(f"Setting key {key} from {self.type} table to value {value}") > returnsuper().__setitem__(key, value) > defmylocals(func): > defwrapper(*args,**kwargs): > loc = MySymbolTable() > glob = MySymbolTable(globals()) > loc.set_type("local") > loc["xxx"]=123 > glob.set_type("global") > glob["yyy"]=42 > exec(func.__code__, glob, loc) > return wrapper Your whitespace is getting messed up again, although not as badly now. Try posting in plain text, not "rich text" or HTML or formatted text or anything. > It still appears to me that 'exec()' simply ignores the dict passed in > as the local parameter: it doesn't even seem to initialize locals() from it. I'm honestly not sure what's going on, because it's hard to follow your code. But my suspicion is that when you exec a code object (rather than compiling and executing a string), it's using cells/slots rather than actually using your locals dict. ChrisA From tjreedy at udel.edu Tue Sep 1 18:57:09 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 1 Sep 2020 18:57:09 -0400 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On 9/1/2020 5:58 PM, Andras Tantos wrote: > > On 9/1/2020 12:41 PM, MRAB wrote: >> CPython is able to identify all of the local names of a function and, Note >>>of a function<<<. >> basically, for reasons of efficiency, it uses slots for the local >> names instead of an actual dict. 'locals()' just returns a dict that >> represents those local names and their current values, but modifying >> that dict has no effect on the actual local names. In short, there >> isn't really a local dict that you can replace. This applies to code in a function (def statement or lambda expression) and only that. [Snip experiments with non-function code at >>> prompt.] > In other words, I can indeed change the value of a local variable > through the locals() dict. This is true for code that is not part of a function body, which is top level code and class code that is not part of a method body. -- Terry Jan Reedy From grant.b.edwards at gmail.com Tue Sep 1 19:28:45 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 1 Sep 2020 23:28:45 -0000 (UTC) Subject: Symlinks already present References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 2020-09-01, Richard Damon wrote: > My research says that Unix System V allowed them, but restricted them to > super users, to avoid the bigger problems with them. I don't know how it > handle the issue of .. SunOS-3/4 (a BSD 4.x derivative) allowed them, but restricted them to root. It did not handle the issue of '..' at all, and if you did much of anything at all with the directory while the "extra" link was present (which meant the filesystem was no longer a tree) it didn't go well. It wasn't something you did a second time. -- Grant From python-list at andras.tantosonline.com Tue Sep 1 20:22:17 2020 From: python-list at andras.tantosonline.com (Andras Tantos) Date: Tue, 1 Sep 2020 17:22:17 -0700 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On 9/1/20 1:42 PM, Chris Angelico wrote: > On Wed, Sep 2, 2020 at 5:00 AM Andras Tantos > wrote: >> All, >> >> I'm new here, so please direct me to the right forum, if this is not the >> one... >> >> What I'm trying to do is to call a function, but monitor all the local >> variable accesses within that function. What I thought I would need to >> do, is to |exec| the function with a custom |locals| dictionary. The >> code below attempts to do it. >> >> |classMySymbolTable(dict):defset_type(self,t):self.type =t >> def__getitem__(self,key):print(f"Requesting key {key} from {self.type} >> table")returnsuper().__getitem__(key)def__setitem__(self,key,value):print(f"Setting >> key {key} from {self.type} table to value >> {value}")returnsuper().__setitem__(key,value)defmylocals(func):defwrapper(*args,**kwargs):loc >> =MySymbolTable()glob >> =MySymbolTable(globals())loc.set_type("local")glob.set_type("global")exec(func.__code__,glob,loc)returnwrapper >> @mylocalsdeffun1():print(f"fun1 with locals: {type(locals())} and >> globals: {type(globals())}")a =1b =2c =3a =b c =5fun1()| > Your code's messed up in the post, so I'm guessing on how this is > actually meant to be written. Most of your whitespace has been > destroyed. Indeed. That's annoying, lemme see if I can copy-paste something in... class MySymbolTable(dict): ??? def set_type(self, t): ??????? self.type = t ??? def __getitem__(self, key): ??????? print(f"Requesting key {key} from {self.type} table") ??????? return super().__getitem__(key) ??? def __setitem__(self, key, value): ??????? print(f"Setting key {key} from {self.type} table to value {value}") ??????? return super().__setitem__(key, value) def mylocals(func): ??? def wrapper(*args, **kwargs): ??????? loc = MySymbolTable() ??????? glob = MySymbolTable(globals()) ??????? loc.set_type("local") ??????? glob.set_type("global") ??????? exec(func.__code__, glob, loc) ??? return wrapper @mylocals def fun1(): ??? print(f"fun1 with locals: {type(locals())} and globals: {type(globals())}") ??? a = 1 ??? b = 2 ??? c = 3 ??? a = b ??? c = 5 fun1() >> That is to say, global accesses are redirected to my custom dict, but >> local assignments are not. You can even see that in the types of the two >> objects printed in the last line. >> >> My hunch is that since I'm using the functions |__code__| member, I end >> up executing pre-compiled byte-code which has already assumptions about >> the locals dict built into it. > Yes; and furthermore, CPython generally doesn't even use a dictionary > for a function's locals. Instead, it uses cells in a special array; > you can poke around with this by disassembling the code (see the > built-in "dis" module for details) and looking at the > LOAD_FAST/STORE_FAST opcodes. > > You might be able to mess with this by using a closure, but local > variable references are generally considered to be an implementation > detail of the function, and it's not going to be easy to mess with > them from the outside reliably. What's the goal here? > > ChrisA I did see these macros in the CPython source code. What it seems to imply is that if I wanted to do what I intend, that is to hook every local variable assignment, I would have to modify the AST. That seems rather more effort than simply supplying my own locals dictionary. I will try to look myself as well, but do you have an inkling as to how complex would it be to convince CPython to optimize locals only if no custom locals is provided during exec? To my untrained eye, it seems to be an unsafe optimization that breaks the contract of the exec API. Andras From centurylinkmailedit at centurylink.net Tue Sep 1 20:22:21 2020 From: centurylinkmailedit at centurylink.net (Barnabas Harris) Date: Tue, 1 Sep 2020 20:22:21 -0400 (EDT) Subject: Turtle Import Message-ID: <793659905.13063028.1599006141711.JavaMail.zimbra@centurylink.net> My import function mysteriously stop working. Is there a way to restore it as I need the second screen to see the turtle move when I command it from python 3.8.5 shell but when I hit enter nothing happens. From rosuav at gmail.com Tue Sep 1 20:31:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 10:31:30 +1000 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On Wed, Sep 2, 2020 at 10:23 AM Andras Tantos wrote: > I did see these macros in the CPython source code. What it seems to > imply is that if I wanted to do what I intend, that is to hook every > local variable assignment, I would have to modify the AST. That seems > rather more effort than simply supplying my own locals dictionary. I > will try to look myself as well, but do you have an inkling as to how > complex would it be to convince CPython to optimize locals only if no > custom locals is provided during exec? > > To my untrained eye, it seems to be an unsafe optimization that breaks > the contract of the exec API. By the time you're calling exec, it's too late to decide whether to optimize, since you're using a precompiled code object. If you want that behaviour, try exec'ing a string of code instead. ChrisA From python-list at andras.tantosonline.com Tue Sep 1 19:54:07 2020 From: python-list at andras.tantosonline.com (Andras Tantos) Date: Tue, 1 Sep 2020 16:54:07 -0700 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: Snipping old parts... On 9/1/20 4:01 PM, Chris Angelico wrote: > On Wed, Sep 2, 2020 at 8:44 AM Andras Tantos > wrote: >> While I'm sure you're right, it certainly is well hidden: >> >> ... >> >> In other words, I can indeed change the value of a local variable >> through the locals() dict. > Not quite. What you're seeing there is that there aren't any locals, > and you're getting the globals: > >>>> locals() is globals() > True > > In this situation, locals() DOES return a real dictionary, and it can > be manipulated as one. But only because it's the same as globals(), > and you can do all that with globals. That could very well be the case. > >> I've modified my code to see if I can at >> least introduce locals through the value passed in for exec, but even >> that seems to fail: >> >> ... > Your whitespace is getting messed up again, although not as badly now. > Try posting in plain text, not "rich text" or HTML or formatted text > or anything. OK, and sorry about that. May third time a charm? class MySymbolTable(dict): ??? def set_type(self, t): ??????? self.type = t ??? def __getitem__(self, key): ??????? print(f"Requesting key {key} from {self.type} table") ??????? return super().__getitem__(key) ??? def __setitem__(self, key, value): ??????? print(f"Setting key {key} from {self.type} table to value {value}") ??????? return super().__setitem__(key, value) def mylocals(func): ??? def wrapper(*args, **kwargs): ??????? loc = MySymbolTable() ??????? glob = MySymbolTable(globals()) ??????? loc.set_type("local") ??????? loc["xxx"] = 123 ??????? glob.set_type("global") ??????? glob["yyy"] = 42 ??????? exec(func.__code__, glob, loc) ??? return wrapper @mylocals def fun1(): ??? print("locals at the beginning:") ??? print(", ".join(f"{name}: {value}" for name, value in locals().items())) ??? print("globals at the beginning:") ??? print(", ".join(f"{name}: {value}" for name, value in globals().items())) ??? print(f"fun1 with locals: {type(locals())} and globals: {type(globals())}") ??? a = 1 ??? b = 2 ??? c = 3 ??? a = b ??? c = 5 ??? print("locals at the end:") ??? print(", ".join(f"{name}: {value}" for name, value in locals().items())) ??? print("globals at the end:") ??? print(", ".join(f"{name}: {value}" for name, value in globals().items())) fun1() >> It still appears to me that 'exec()' simply ignores the dict passed in >> as the local parameter: it doesn't even seem to initialize locals() from it. > I'm honestly not sure what's going on, because it's hard to follow > your code. But my suspicion is that when you exec a code object > (rather than compiling and executing a string), it's using cells/slots > rather than actually using your locals dict. > > ChrisA Thanks for all the help! Indeed, I'm executing a code object and not a string. Is there any way to get to the string version of the function and force a re-compile of it during an exec? Would it help? I guess if I was doing that, I would need to execute the 'body' of the function within the exec and by passing in a local parameter I can pretend it has its own call-stack entry. But is that truly equivalent to calling the original function? It seems to me that even it were all possible, the solution would be very brittle, for example, additional decorators would mess things up. Though that's probably the case independent of the code-object/source-code distinction. Andras From Gronicus at SGA.Ninja Tue Sep 1 21:43:31 2020 From: Gronicus at SGA.Ninja (Steve) Date: Tue, 1 Sep 2020 21:43:31 -0400 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> <014e01d680a2$d6ecd1b0$84c67510$@SGA.Ninja> Message-ID: <017901d680ca$76d55590$648000b0$@SGA.Ninja> >> Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. >It means you need all those things installed before you can install Pandas. If that is the case, then it is just not worth it. However, I am seeing it more as a poorly constructed sentence. How about: >> Requires numpy, dateutil, pytz, setuptools , and optionally: numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. Does it suggest that the first four are required and the rest are optional? Even then, it is still ambiguous. FootNote: If money does not grow on trees, then why do banks have branches? -----Original Message----- From: Chris Angelico Sent: Tuesday, September 1, 2020 5:08 PM To: Steve Cc: Python Subject: Re: What kind of magic do I need to get python to talk to Excel xlsm file? On Wed, Sep 2, 2020 at 6:59 AM Steve wrote: > > Wow, that is quite a list.... > Here is what I narrowed it down to. What does that paragraph starting with "Requires" mean? > > =================================== > Pandas: a cross-section and time series data analysis toolkit. > > Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. > It means you need all those things installed before you can install Pandas. ChrisA From rosuav at gmail.com Tue Sep 1 21:48:02 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 11:48:02 +1000 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On Wed, Sep 2, 2020 at 11:29 AM Andras Tantos wrote: > OK, and sorry about that. May third time a charm? Thank you! Whatever you did this time, that worked :) > Indeed, I'm executing a code object and not a string. Is there any way > to get to the string version of the function and force a re-compile of > it during an exec? Would it help? Eeeuuuuhhhhhhhh.... normally you'd do that by, well, *not* compiling it. But maybe the inspect module can help here: https://docs.python.org/3/library/inspect.html#inspect.getsource There's no guarantee that it will work though. > I guess if I was doing that, I would need to execute the 'body' of the > function within the exec and by passing in a local parameter I can > pretend it has its own call-stack entry. But is that truly equivalent to > calling the original function? I think it is getting an actual call stack entry anyway. Now, if your goal is to do something with an expression evaluator, then there are LOTS of options. Let's say you want to allow people to write code that implicitly calls on some data source, so typing "x ** 2 + y ** 2" would look up x and y in some way and then do arithmetic with them. If you get the original source as a string, you can most certainly do things with the globals as you compile it. Or if you want more reliability, compile it to AST, walk the tree, and replace nodes as required, before compiling it the rest of the way for execution. Or run the code at global scope, with the globals doing your magic and the builtins doing everything else. Lots of ways to do things, as long as you start with the source code. ChrisA From rosuav at gmail.com Tue Sep 1 21:48:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Sep 2020 11:48:54 +1000 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: <017901d680ca$76d55590$648000b0$@SGA.Ninja> References: <00c701d68038$f9c85cf0$ed5916d0$@SGA.Ninja> <00d401d68040$62dcfb40$2896f1c0$@SGA.Ninja> <013b01d6809c$bff18ba0$3fd4a2e0$@SGA.Ninja> <014e01d680a2$d6ecd1b0$84c67510$@SGA.Ninja> <017901d680ca$76d55590$648000b0$@SGA.Ninja> Message-ID: On Wed, Sep 2, 2020 at 11:43 AM Steve wrote: > > >> Requires numpy, dateutil, pytz, setuptools, and optionally numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. > > >It means you need all those things installed before you can install Pandas. > > If that is the case, then it is just not worth it. However, I am seeing it more as a poorly constructed sentence. > > How about: > > >> Requires numpy, dateutil, pytz, setuptools , > and optionally: > numexpr, bottleneck, scipy, matplotlib, pytables, lxml, xarray, blosc, snappy, brotlipy, backports.lzma, statsmodels, sqlalchemy, psycopg2, and whatnot. > > Does it suggest that the first four are required and the rest are optional? > Even then, it is still ambiguous. > I believe you are correct, but I usually let pip do all the work. (But I don't use Windows.) ChrisA From python-list at andras.tantosonline.com Tue Sep 1 21:11:51 2020 From: python-list at andras.tantosonline.com (Andras Tantos) Date: Tue, 1 Sep 2020 18:11:51 -0700 Subject: How to set custom locals for function call? In-Reply-To: References: Message-ID: On 9/1/20 5:31 PM, Chris Angelico wrote: > On Wed, Sep 2, 2020 at 10:23 AM Andras Tantos > wrote: >> I did see these macros in the CPython source code. What it seems to >> imply is that if I wanted to do what I intend, that is to hook every >> local variable assignment, I would have to modify the AST. That seems >> rather more effort than simply supplying my own locals dictionary. I >> will try to look myself as well, but do you have an inkling as to how >> complex would it be to convince CPython to optimize locals only if no >> custom locals is provided during exec? >> >> To my untrained eye, it seems to be an unsafe optimization that breaks >> the contract of the exec API. > By the time you're calling exec, it's too late to decide whether to > optimize, since you're using a precompiled code object. If you want > that behaviour, try exec'ing a string of code instead. > > ChrisA I guess, it depends. I can think of several ways of dealing with this. Probably the highest performant version would be to generate byte-code along these lines for every function body: ??? if <>: ??? ???? <> ??? else: ??? ???? <> This of course makes the byte-code about twice as large as today. One could also patch up the SETLOCAL/GETLOCAL macros to test for this condition, in which case no byte-code changes are needed, but performance would degrade because of all the - normally unnecessary - checks. There's also a possibility of detecting this condition within the underlying C implementation of exec() and trigger a re-generation of the byte-code from source. I don't feel confident enough to even attempt anything but the middle approach, but even then: this is a change to CPython, obviously something that needs community vetting and approval. Reacting to your last sentence: I have investigated how to get the source code, given a function object, but the best I could come up with is: ??? 1. Retrieve the source code for the function, using inspect.getsource() ??? 2. massage it to contain only the function body (that is to remove the def ... line) ??? 3. pass that to exec. With that, I finally have been able to get locals work, but here, I'm back to the other case, where I essentially promoted the body of the function into the global namespace, so now locals() and globals() are the same thing. This is hardly the same context in which the function would originally execute. Andras From larry.martell at gmail.com Wed Sep 2 13:54:42 2020 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 2 Sep 2020 10:54:42 -0700 Subject: grouping and sorting within groups using another list Message-ID: I have a list of tuples, and I want to group them by 3 items (0, 3, 4) and then within each group sort the data by a 4th item (6) using a sort order from another list. The list is always ordered by the 3 grouping items. For example, if I have this list: rows = [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), ('a', 'x', 'y', 'd', 'e', 'f', 'green', ....), ('a', 'q', 'w', 'd', 'e', 'f', 'white', ....), ('p', 'x', 'y', 'd', 'e', 'f', 'white', ....), ('p', 'x', 'y', 'd', 'e', 'f', ' 'blue', ...), ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), ] and I have a list: sort_list = ['blue', 'white', 'green'] Then the result list would be: [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), ('a', 'x', 'y', 'd', 'e', 'f', 'white', ....), ('a', 'q', 'w', 'd', 'e', 'f', 'green', ....), ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ....), ('p', 'x', 'y', 'd', 'e', 'f', ' 'white', ...), ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), ] Been trying to do with using groupby but have not been successful. From David.Raymond at tomtom.com Wed Sep 2 14:21:42 2020 From: David.Raymond at tomtom.com (David Raymond) Date: Wed, 2 Sep 2020 18:21:42 +0000 Subject: grouping and sorting within groups using another list In-Reply-To: References: Message-ID: Would it be something as simple as: rows.sort(key = lambda x: (x[0], x[3], x[4], sort_list.index(x[6]))) -----Original Message----- From: Python-list On Behalf Of Larry Martell Sent: Wednesday, September 2, 2020 1:55 PM To: Python Subject: grouping and sorting within groups using another list I have a list of tuples, and I want to group them by 3 items (0, 3, 4) and then within each group sort the data by a 4th item (6) using a sort order from another list. The list is always ordered by the 3 grouping items. For example, if I have this list: rows = [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), ('a', 'x', 'y', 'd', 'e', 'f', 'green', ....), ('a', 'q', 'w', 'd', 'e', 'f', 'white', ....), ('p', 'x', 'y', 'd', 'e', 'f', 'white', ....), ('p', 'x', 'y', 'd', 'e', 'f', ' 'blue', ...), ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), ] and I have a list: sort_list = ['blue', 'white', 'green'] Then the result list would be: [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), ('a', 'x', 'y', 'd', 'e', 'f', 'white', ....), ('a', 'q', 'w', 'd', 'e', 'f', 'green', ....), ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ....), ('p', 'x', 'y', 'd', 'e', 'f', ' 'white', ...), ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), ] Been trying to do with using groupby but have not been successful. -- https://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Wed Sep 2 14:26:16 2020 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Sep 2020 20:26:16 +0200 Subject: grouping and sorting within groups using another list References: Message-ID: Larry Martell wrote: > I have a list of tuples, and I want to group them by 3 items (0, 3, 4) > and then within each group sort the data by a 4th item (6) using a > sort order from another list. The list is always ordered by the 3 > grouping items. >From your description I deduced from itertools import chain, groupby from operator import itemgetter from pprint import pprint rows = [ ('a', 'b', 'c', 'd', 'e', 'f', 'blue', ...), ('a', 'x', 'y', 'd', 'e', 'f', 'green', ...), ('a', 'q', 'w', 'd', 'e', 'f', 'white', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'white', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue', ...), ] sort_list = ['blue', 'white', 'green'] wanted = [ ('a', 'b', 'c', 'd', 'e', 'f', 'blue', ...), ('a', 'x', 'y', 'd', 'e', 'f', 'white', ...), ('a', 'q', 'w', 'd', 'e', 'f', 'green', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'white', ...), ('p', 'x', 'y', 'd', 'e', 'f', 'green', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'blue', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'white', ...), ('z', 'x', 'y', 'm', 'n', 'o', 'green', ...), ] group_key = itemgetter(0, 3, 4) def sort_key(row, lookup={k: i for i, k in enumerate(sort_list)}): return lookup[row[6]] result = list( chain.from_iterable( sorted(group, key=sort_key) for _key, group in groupby(rows, key=group_key) ) ) pprint(wanted) pprint(result) assert result == wanted Unfortunately the assertion fails. I'm not sure whether I misunderstood your description or if your sample data is incorrect. > > For example, if I have this list: > rows = > [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), > ('a', 'x', 'y', 'd', 'e', 'f', 'green', ....), > ('a', 'q', 'w', 'd', 'e', 'f', 'white', ....), > ('p', 'x', 'y', 'd', 'e', 'f', 'white', ....), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'blue', ...), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), > ] > > and I have a list: > > sort_list = ['blue', 'white', 'green'] > > Then the result list would be: > > [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), > ('a', 'x', 'y', 'd', 'e', 'f', 'white', ....), > ('a', 'q', 'w', 'd', 'e', 'f', 'green', ....), > ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ....), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'white', ...), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), > ] > > Been trying to do with using groupby but have not been successful. From __peter__ at web.de Wed Sep 2 14:38:46 2020 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Sep 2020 20:38:46 +0200 Subject: grouping and sorting within groups using another list References: Message-ID: Peter Otten wrote: > group_key = itemgetter(0, 3, 4) > > > def sort_key(row, lookup={k: i for i, k in enumerate(sort_list)}): > return lookup[row[6]] > > > result = list( > chain.from_iterable( > sorted(group, key=sort_key) > for _key, group in groupby(rows, key=group_key) > ) > ) It just occured to me that if the above code is what you want you can omit the groupby and sort with a combined key: sorted(rows, key=lambda row: (group_key(row), sort_key(row))) (The lambda is for illustration, you could of course merge the two key functions into one) From larry.martell at gmail.com Wed Sep 2 15:27:24 2020 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 2 Sep 2020 12:27:24 -0700 Subject: grouping and sorting within groups using another list In-Reply-To: References: Message-ID: On Wed, Sep 2, 2020 at 11:22 AM David Raymond wrote: > > Would it be something as simple as: > > rows.sort(key = lambda x: (x[0], x[3], x[4], sort_list.index(x[6]))) This is perfect - thanks! > -----Original Message----- > From: Python-list On Behalf Of Larry Martell > Sent: Wednesday, September 2, 2020 1:55 PM > To: Python > Subject: grouping and sorting within groups using another list > > I have a list of tuples, and I want to group them by 3 items (0, 3, 4) > and then within each group sort the data by a 4th item (6) using a > sort order from another list. The list is always ordered by the 3 > grouping items. > > For example, if I have this list: > rows = > [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), > ('a', 'x', 'y', 'd', 'e', 'f', 'green', ....), > ('a', 'q', 'w', 'd', 'e', 'f', 'white', ....), > ('p', 'x', 'y', 'd', 'e', 'f', 'white', ....), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'blue', ...), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), > ] > > and I have a list: > > sort_list = ['blue', 'white', 'green'] > > Then the result list would be: > > [('a', 'b', 'c', 'd', 'e', 'f', 'blue', ....), > ('a', 'x', 'y', 'd', 'e', 'f', 'white', ....), > ('a', 'q', 'w', 'd', 'e', 'f', 'green', ....), > ('p', 'x', 'y', 'd', 'e', 'f', 'blue', ....), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'white', ...), > ('p', 'x', 'y', 'd', 'e', 'f', ' 'green', ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'blue, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'white, ...), > ('z', 'x', 'y', 'm', 'n', 'o', 'green, ...), > ] > > Been trying to do with using groupby but have not been successful. From greg.ewing at canterbury.ac.nz Thu Sep 3 06:58:08 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Thu, 3 Sep 2020 22:58:08 +1200 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 2/09/20 6:55 am, Eryk Sun wrote: > According to POSIX (st_dev, st_ino), it's the same directory, yet the > ".." entry evaluates depending on the path parsing context: > > >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino > True > >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino > True What happens if you go one level deeper? I.e. is os.lstat('test1/spam/eggs/../..').st_ino == os.lstat('test1').st_ino and os.lstat('test2/spam/eggs/../..').st_ino == os.lstat('test2').st_ino ? -- Greg From eryksun at gmail.com Thu Sep 3 08:24:37 2020 From: eryksun at gmail.com (Eryk Sun) Date: Thu, 3 Sep 2020 07:24:37 -0500 Subject: Symlinks already present In-Reply-To: References: <20200831072635.GA27335@cskk.homeip.net> <0a196beb-cdc6-8045-79b2-684b6241fda5@Damon-Family.org> <9dcd2f23-5912-de18-2dbc-ff94eb850d23@Damon-Family.org> <67e375a1-3526-d78d-91c6-fbb42b2e72f5@Damon-Family.org> Message-ID: On 9/3/20, Greg Ewing wrote: > On 2/09/20 6:55 am, Eryk Sun wrote: >> According to POSIX (st_dev, st_ino), it's the same directory, yet the >> ".." entry evaluates depending on the path parsing context: >> >> >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino >> True >> >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino >> True > > What happens if you go one level deeper? I.e. is > os.lstat('test1/spam/eggs/../..').st_ino == os.lstat('test1').st_ino > and > os.lstat('test2/spam/eggs/../..').st_ino == os.lstat('test2').st_ino > ? Those two examples return true. Going a level deeper to 'spam/eggs' doesn't change the behavior of the graft at "test2/spam". An interesting case is bind mounting a directory on one of its child directories. For example, if "spam" is mounted on "spam/mount_spam": >>> s = os.lstat('spam/mount_spam/mount_spam/..') >>> s.st_ino == os.lstat('spam').st_ino True The namespace graft only occurs at "spam/mount_spam". So "spam/mount_spam/mount_spam" is the original filesystem directory, for which the ".." entry references "spam". It's also consistent with "spam/mount_spam" being bound to "spam". From waste at is.invalid Thu Sep 3 10:10:58 2020 From: waste at is.invalid (Termoregolato) Date: Thu, 3 Sep 2020 16:10:58 +0200 Subject: Regex to change multiple lines Message-ID: Hi. I've on file, containing multiple lines, and I need to change every occurrence of a sequence between two chars, in this case "%%". -- original This is the %%text that i must modify%%, on a line, %%but also on the others%% that are following I need to change to -- desidered This is the text that i must modify, on a line, but also on the others that are following I've tryed with this small code rebarredtext = r'~~([^>]*)~~' text = mycontent for line in re.findall(rebarredtext, text): text = text.replace("~~" + line + "~~", "" + line + "") but it changes only the biggest occurrence: how can I do to change all occurrences? I'm really a regex newbie, TIA -- test This is the text that i must modify%%, on a line, %%but also on the others that are following From rosuav at gmail.com Thu Sep 3 10:39:00 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Sep 2020 00:39:00 +1000 Subject: Regex to change multiple lines In-Reply-To: References: Message-ID: On Fri, Sep 4, 2020 at 12:16 AM Termoregolato wrote: > > Hi. I've on file, containing multiple lines, and I need to change every > occurrence of a sequence between two chars, in this case "%%". > > -- original > This is the %%text that i must modify%%, on a line, %%but also > on the others%% that are following > > I need to change to > > -- desidered > This is the text that i must modify, on a line, but also > on the others that are following > > I've tryed with this small code > > rebarredtext = r'~~([^>]*)~~' The trouble here is that the bit in the middle will take as much as it possibly can, even though that includes the marker. (BTW, you're inconsistent here as to whether the marker is "%%" or "~~".) I'm not sure why you're excluding ">" from this group, but I presume that that's intentional. To solve this, you can make the asterisk "non-greedy" by adding a question mark after it: rebarredtext = r'~~([^>]*?)~~' Now it matches as *little* as it possibly can. Additionally, you can get the regex engine to do the work of replacing, too. re.sub(rebarredtext, r'\1', txt) That'll do the whole loop and everything; it replaces every match of the regex with the given replacement text, where "\1" takes whatever was inside the parentheses. Regular expressions are incredibly powerful, but unfortunately hard to debug, so all you can do is test and tinker :) ChrisA From python.list at tim.thechases.com Thu Sep 3 10:27:14 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 3 Sep 2020 09:27:14 -0500 Subject: Regex to change multiple lines In-Reply-To: References: Message-ID: <20200903092714.2dd83dcf@bigbox.attlocal.net> On 2020-09-03 16:10, Termoregolato wrote: > -- original > This is the %%text that i must modify%%, on a line, %%but also > on the others%% that are following > > I need to change to > > -- desidered > This is the text that i must modify, on a line, but > also on the others that are following Should be able to use :%s/%%\(\_.\{-}\)%%/\1<\/del>/g It simplifies slightly if you use a different delimiter :%s@%%\(\_.\{-}\)%%@\1@g -tim From python.list at tim.thechases.com Thu Sep 3 10:39:32 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 3 Sep 2020 09:39:32 -0500 Subject: Regex to change multiple lines In-Reply-To: <20200903092714.2dd83dcf@bigbox.attlocal.net> References: <20200903092714.2dd83dcf@bigbox.attlocal.net> Message-ID: <20200903093932.587b132c@bigbox.attlocal.net> Derp, sorry about the noise. I mistook this message for a similar dialog over on the Vim mailing list. For Python, you want re.sub(r"%%(.*?)%%", r"\1", s, flags=re.S) or put the flag inline re.sub(r"(?s)%%(.*?)%%", r"\1", s) -tim On 2020-09-03 09:27, Tim Chase wrote: > On 2020-09-03 16:10, Termoregolato wrote: > > -- original > > This is the %%text that i must modify%%, on a line, %%but also > > on the others%% that are following > > > > I need to change to > > > > -- desidered > > This is the text that i must modify, on a line, > > but also on the others that are following > > Should be able to use > > :%s/%%\(\_.\{-}\)%%/\1<\/del>/g > > It simplifies slightly if you use a different delimiter > > :%s@%%\(\_.\{-}\)%%@\1@g > > -tim > > > From web at ushills.co.uk Thu Sep 3 11:16:55 2020 From: web at ushills.co.uk (Ian Hill) Date: Thu, 3 Sep 2020 16:16:55 +0100 Subject: What kind of magic do I need to get python to talk to Excel xlsm file? In-Reply-To: References: Message-ID: If you don't need to do any specific data analysis using pandas, try openpyxl. It will read xlsm files and it quite straight forward to use. https://openpyxl.readthedocs.io/en/stable/ pip install openpyxl. Ian From grant.b.edwards at gmail.com Thu Sep 3 11:49:43 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 3 Sep 2020 15:49:43 -0000 (UTC) Subject: Replacement for pygtk? Message-ID: Many years ago I wrote an app that uses pygtk for it's GUI. I still use the app occasionally, and would like to keep it alive. Emerge informs me that dev-python/pygtk is scheduled for removal. Is pygobject the replacement for pygtk? -- Grant From mark at atldes.com Thu Sep 3 15:05:02 2020 From: mark at atldes.com (Mark Barton) Date: Thu, 3 Sep 2020 15:05:02 -0400 Subject: Pyserial and some half-duplex woes. Message-ID: Hey All, I am using Microchip's Python program to download code to a PIC32 microprocessor via Pyserial. There is also Microchip's bootloader code running on the PIC side. This works very well using the a standard serial hardware directly connected to a USB to serial adapter to one of the PIC's UARTs. However in our application the hardware is a single wire thus requiring a half-duplex communications. Fortunately Microchip's protocol lends itself to half-duplex communications, however the problem is that both the PIC and the Python program will receive an echo when one of the other transmits due to the hardware design. It other words the PIC will receive what it transmits and the same on the Python side. The PIC side is easily fixed by simply turning off receive during transmit. I don't think I can do this on the Python side at least there nothing in Pyserial's documentation that you can do that. I have tried to do some flushing of the receive buffer, but I haven't been too successful. Perhaps that is due to timing. I thought I would reach out to see if anyone may have had a similar experience. Thanks for any help. Mark From waste at is.invalid Thu Sep 3 15:30:04 2020 From: waste at is.invalid (Termoregolato) Date: Thu, 3 Sep 2020 21:30:04 +0200 Subject: Regex to change multiple lines In-Reply-To: References: Message-ID: Il 03/09/20 16:10, Termoregolato wrote: > I need to change every occurrence of a sequence between two chars Thanks to all for your replies, it's time to learn regular expressions, but now I've some valid pointers from you. The work I must do here, to explain, is to get some markdown files, and add the strikethrough in a different color from the original, so I've do a bit of confusion between markdown "~~" and my "%%" in examples, where I wanted to reduce the number of lines. From grant.b.edwards at gmail.com Thu Sep 3 15:17:41 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 3 Sep 2020 19:17:41 -0000 (UTC) Subject: Replacement for pygtk? References: Message-ID: On 2020-09-03, Grant Edwards wrote: > [...] > > Is pygobject the replacement for pygtk? It seems to be. I've started porting my pygtk app, and it's going pretty smoothly. I've already got my two custom widgets working. Oddly, the main module provided by the gobject package is called "gi". From rosuav at gmail.com Thu Sep 3 16:16:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Sep 2020 06:16:30 +1000 Subject: Regex to change multiple lines In-Reply-To: References: Message-ID: On Fri, Sep 4, 2020 at 5:36 AM Termoregolato wrote: > > Il 03/09/20 16:10, Termoregolato wrote: > > > I need to change every occurrence of a sequence between two chars > > Thanks to all for your replies, it's time to learn regular expressions, > but now I've some valid pointers from you. > > The work I must do here, to explain, is to get some markdown files, and > add the strikethrough in a different color from the original, so I've do > a bit of confusion between markdown "~~" and my "%%" in examples, where > I wanted to reduce the number of lines. Hmm. Have you considered using CSS to do this? Markdown is generally fairly easy to style with CSS. ChrisA From torriem at gmail.com Thu Sep 3 19:45:44 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 3 Sep 2020 17:45:44 -0600 Subject: Replacement for pygtk? In-Reply-To: References: Message-ID: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> On 9/3/20 1:17 PM, Grant Edwards wrote: > On 2020-09-03, Grant Edwards wrote: >> [...] >> >> Is pygobject the replacement for pygtk? > > It seems to be. I've started porting my pygtk app, and it's going > pretty smoothly. I've already got my two custom widgets working. > Oddly, the main module provided by the gobject package is called "gi". It stands for "gobject introspection." The nice thing about the gi module is it can wrap any gobject-based library, not just GTK+ proper. So if someone made a custom widget in Vala, for example, you could access it via gi. It's a neat idea. My only problem with it is the resulting Python API is not always as pythonic as pygtk code was. I can't think of any specific examples at the moment, however. It's pretty much good enough to not care too much. Similar arguments can be made against PyQt as well. Especially with PyQt the end result feels a bit like writing C++ with a python syntax. From python at bladeshadow.org Thu Sep 3 20:28:14 2020 From: python at bladeshadow.org (Python) Date: Thu, 3 Sep 2020 19:28:14 -0500 Subject: Threading plus multiprocessing plus cv2 error In-Reply-To: <20200829182410.4d3633f1@e7240.home> References: <20200829182410.4d3633f1@e7240.home> Message-ID: <20200904002814.GD5069@bladeshadow.org> On Sat, Aug 29, 2020 at 06:24:10PM +1000, John O'Hagan wrote: > Dear list > > Thanks to this list, I haven't needed to ask a question for > a very long time, but this one has me stumped. > > Here's the minimal 3.8 code, on Debian testing: > > ----- > from multiprocessing import Process > from threading import Thread > from time import sleep > import cv2 > > def show(im, title, location): > cv2.startWindowThread() > cv2.namedWindow(title) > cv2.moveWindow(title, *location) > cv2.imshow(title, im) > sleep(2) #just to keep window open > > im1 = cv2.imread('/path/to/image1') > im2 = cv2.imread('/path/to/image2') > > Thread(target=show, args=(im1, 'im1', (600,0))).start() > sleep(1) > Process(target=show, args=(im2, 'im2', (0, 0))).start() > ----- > > Here's the error: > > ----- > [xcb] Unknown sequence number while processing queue > [xcb] Most likely this is a multi-threaded client and XInitThreads has > not been called > [xcb] Aborting, sorry about that. > python3: ../../src/xcb_io.c:260: poll_for_event: Assertion > `!xcb_xlib_threads_sequence_lost' failed. > ----- It's hard to say EXACTLY what the nature of the error is, without knowing what the underlying libraries are doing. But from this one thing is clear: You are starting a new thread, and then forking a new process. This is very likely to break, because contrary to what several people have said in this thread, the new thread WILL NOT be copied to the new program, so in the new process, part of your program is literally missing. This can have all kinds of consequences. For that reason, you can't spawn a new thread and then fork a new process, in that order, and expect your program to function correctly. Whatever your program does that depends on that new thread won't work correctly, because that thread does not exist in the child (new process). You can, however, do those things in the reverse order and it should be fine... new threads will be started in both processes (unless you take steps to ensure only one of the processes creates the thread). Both processes retain their integrity and should run fine. > There's no error without the sleep(1), nor if the Process is started > before the Thread, nor if two Processes are used instead, nor if two > Threads are used instead. IOW the error only occurs if a Thread is > started first, and a Process is started a little later. Hopefully my explanation above makes it clear why all of those things are true, other than the sleep() issue. That one is most likely just a timing issue: Whatever resource is causing the problem hasn't been set up yet or the critical thread or process has already finished execution before the issue can arise, or something of the sort. When you start new threads or processes, usually there's some delay as your OS schedules each process/thread to run, which is somewhat random based on how the scheduler works and how loaded the system is. Such timing problems (bugs that seem to happen randomly with each run of the program, or over time in a long-executing program) are common in multi-threaded programs that are written incorrectly, especially when the state of one thread depends on the state of the other thread, and the two don't synchronize correctly. This is another way that the first problem above can manifest, too: The threads can't synchronize because one of them does not exist! Hope that helps. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From cs at cskk.id.au Fri Sep 4 00:59:09 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 4 Sep 2020 14:59:09 +1000 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) Message-ID: <20200904045909.GA5294@cskk.homeip.net> I've built 3.8.5 on a few other machines happily recently. Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) 4.9.2 I get this: % gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Modules/gcmodule.o Modules/gcmodule.c Modules/gcmodule.c: In function 'collect.constprop': Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] #define GEN_HEAD(state, n) (&(state)->generations[n].head) ^ Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); ^ Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] #define GEN_HEAD(state, n) (&(state)->generations[n].head) ^ Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); ^ Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] #define GEN_HEAD(state, n) (&(state)->generations[n].head) ^ Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); ^ Any thoughts? I'll try a few other minor versions meanwhile... Cheers, Cameron Simpson From rosuav at gmail.com Fri Sep 4 01:54:35 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Sep 2020 15:54:35 +1000 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: <20200904045909.GA5294@cskk.homeip.net> References: <20200904045909.GA5294@cskk.homeip.net> Message-ID: On Fri, Sep 4, 2020 at 3:01 PM Cameron Simpson wrote: > > I've built 3.8.5 on a few other machines happily recently. > > Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) > 4.9.2 I get this: > > % gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Modules/gcmodule.o Modules/gcmodule.c > Modules/gcmodule.c: In function 'collect.constprop': > Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] > #define GEN_HEAD(state, n) (&(state)->generations[n].head) > ^ > Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' > gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); > ^ > Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] > #define GEN_HEAD(state, n) (&(state)->generations[n].head) > ^ > Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' > gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); > ^ > Modules/gcmodule.c:126:50: warning: array subscript is above array bounds [-Warray-bounds] > #define GEN_HEAD(state, n) (&(state)->generations[n].head) > ^ > Modules/gcmodule.c:1036:43: note: in expansion of macro 'GEN_HEAD' > gc_list_merge(GEN_HEAD(state, i), GEN_HEAD(state, generation)); > ^ > > Any thoughts? > Those are warnings; if there are errors that block compilation, they aren't in what you quoted above. ChrisA From cs at cskk.id.au Fri Sep 4 03:06:59 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 4 Sep 2020 17:06:59 +1000 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: References: Message-ID: <20200904070659.GA51963@cskk.homeip.net> On 04Sep2020 15:54, Chris Angelico wrote: >On Fri, Sep 4, 2020 at 3:01 PM Cameron Simpson wrote: >> I've built 3.8.5 on a few other machines happily recently. >Those are warnings; if there are errors that block compilation, they >aren't in what you quoted above. Yes, that's what I thought. And yet it failed :-( And I just retried and now it's good. That is just.. weird. And I can't find the shell it failed in :-( Sorry to have bugged people. Cheers, Cameron Simpson From cl at isbd.net Fri Sep 4 04:05:04 2020 From: cl at isbd.net (Chris Green) Date: Fri, 4 Sep 2020 09:05:04 +0100 Subject: Replacement for pygtk? References: Message-ID: Grant Edwards wrote: > On 2020-09-03, Grant Edwards wrote: > > [...] > > > > Is pygobject the replacement for pygtk? > > It seems to be. I've started porting my pygtk app, and it's going > pretty smoothly. I've already got my two custom widgets working. > Oddly, the main module provided by the gobject package is called "gi". > I think the 'i' is for instrospection - GTK Introspection. FWIW I ported some Python 2 GTK code to Python 3 and it wasn't *too* painful. Run 2to3 on the code and then fix the odd syntax errors that remain. -- Chris Green ? From waste at is.invalid Fri Sep 4 07:41:48 2020 From: waste at is.invalid (Termoregolato) Date: Fri, 4 Sep 2020 13:41:48 +0200 Subject: Regex to change multiple lines In-Reply-To: References: Message-ID: Il 03/09/20 22:16, Chris Angelico ha scritto: > Hmm. Have you considered using CSS to do this? Markdown is generally > fairly easy to style with CSS. Yes, infact these are files where I'll insert a tag (in the example , to show the errors find at a second revision due they are of another kind, but then something like ", with inline css declaration at the beginning of the file to not confuse the guy, a teacher friend of mine, that will use this application). From joshua at azariah.com Fri Sep 4 12:04:33 2020 From: joshua at azariah.com (Joshua J. Kugler) Date: Fri, 04 Sep 2020 08:04:33 -0800 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: <20200904045909.GA5294@cskk.homeip.net> References: <20200904045909.GA5294@cskk.homeip.net> Message-ID: <36356085.suMMMXmYLk@hosanna> On Thursday, September 3, 2020 8:59:09 PM AKDT Cameron Simpson wrote: > I've built 3.8.5 on a few other machines happily recently. > > Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) > 4.9.2 I get this: I am going to assume the version of C required is past what is in that old of a version of Debian. I don't see anything that calls out the C version required in the Python docs, but I doubt they have Debian 8 in their build farm any more. j -- Joshua J. Kugler - Fairbanks, Alaska - joshua at azariah.com Azariah Enterprises - Programming and Website Design PGP Key: http://pgp.mit.edu/ ID 0x68108cbb73b13b6a From rosuav at gmail.com Fri Sep 4 12:13:07 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Sep 2020 02:13:07 +1000 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: <36356085.suMMMXmYLk@hosanna> References: <20200904045909.GA5294@cskk.homeip.net> <36356085.suMMMXmYLk@hosanna> Message-ID: On Sat, Sep 5, 2020 at 2:06 AM Joshua J. Kugler wrote: > > On Thursday, September 3, 2020 8:59:09 PM AKDT Cameron Simpson wrote: > > I've built 3.8.5 on a few other machines happily recently. > > > > Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) > > 4.9.2 I get this: > > I am going to assume the version of C required is past what is in that old of > a version of Debian. I don't see anything that calls out the C version > required in the Python docs, but I doubt they have Debian 8 in their build > farm any more. > You'd be surprised :) There is, in fact, a Debian 8.9 system in the build farm. I know, because I maintain it. (It's a VM underneath my live system which is Debian 9.) ChrisA From python at bladeshadow.org Fri Sep 4 16:43:14 2020 From: python at bladeshadow.org (Python) Date: Fri, 4 Sep 2020 15:43:14 -0500 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: <36356085.suMMMXmYLk@hosanna> References: <20200904045909.GA5294@cskk.homeip.net> <36356085.suMMMXmYLk@hosanna> Message-ID: <20200904204314.GB8341@bladeshadow.org> On Fri, Sep 04, 2020 at 08:04:33AM -0800, Joshua J. Kugler wrote: > On Thursday, September 3, 2020 8:59:09 PM AKDT Cameron Simpson wrote: > > I've built 3.8.5 on a few other machines happily recently. > > > > Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) > > 4.9.2 I get this: > > I am going to assume the version of C required is past what is in that old of > a version of Debian. No... even the latest versions of GCC will let you use the oldest C standards ("version") by using the -cstd flag, and that flag is set (to c99) on the command line. So unless that's just the wrong version, that's definitely not the problem. There's also nothing to suggest that there's a syntax problem in the output Cameron pasted (it only describes a *usage* problem). An obsolete library would be more likely, but there's nothing in the provided output to suggest that either. It appears to me thatthe output that Cameron pasted is missing the context that would tell you what the problem is. Usually GCC gives an additional error right before compilation stops that gives a sort of summarized description of the reason compilation failed. There's none present in what Cameron provided. But I will also note the -Werror= flag on the compile line, which turns warnings into errors... but I'm too lazy to look up whether the specified option affects the mentioned bounds checking (seems like it wouldn't, but there's no guarantee the bounds checking behavior isn't also implied by that option, without specific knowledge of that compiler behavior, which I lack). If that were the case, FWIW, GCC would usually emit an additional error to the effect of "warnings being treated as errors." -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From python at bladeshadow.org Fri Sep 4 16:56:43 2020 From: python at bladeshadow.org (Python) Date: Fri, 4 Sep 2020 15:56:43 -0500 Subject: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!) In-Reply-To: <20200904204314.GB8341@bladeshadow.org> References: <20200904045909.GA5294@cskk.homeip.net> <36356085.suMMMXmYLk@hosanna> <20200904204314.GB8341@bladeshadow.org> Message-ID: <20200904205643.GC8341@bladeshadow.org> On Fri, Sep 04, 2020 at 03:43:14PM -0500, Python wrote: > On Fri, Sep 04, 2020 at 08:04:33AM -0800, Joshua J. Kugler wrote: > > On Thursday, September 3, 2020 8:59:09 PM AKDT Cameron Simpson wrote: > > > Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2) > > > 4.9.2 I get this: > > > > I am going to assume the version of C required is past what is in that old of > > a version of Debian. > > No... even the latest versions of GCC will let you use the oldest C > standards ("version") by using the -cstd flag, and that flag is set Typo: it's just -std. From chiragatha07 at gmail.com Fri Sep 4 14:22:05 2020 From: chiragatha07 at gmail.com (Chirag Atha) Date: Fri, 4 Sep 2020 11:22:05 -0700 (PDT) Subject: How can I use Haar cascade for face detection and kalman filter for tracking? Message-ID: <95773ec2-f3f6-45e0-890a-5a41c0ffeb24n@googlegroups.com> I am new to computer vision and I am trying to use haar cascade for face detection and kalman filtering for tracking I intend to run the code on raspberry pi 3B. Hence cannot use any deep learning methods for tracking. How can I use cv2.kalmanfilter() (https://docs.opencv.org/trunk/dd/d6a/classcv_1_1KalmanFilter.html) in my code to do the tracking and draw a line for the traversal path? It would be great help if any one can guide me for it My code is : from __future__ import print_function import numpy as np import cv2 from imutils.video import WebcamVideoStream from imutils.video import FPS import argparse import imutils import cv2 faceCascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') #faceCascade = cv2.CascadeClassifier('haarcascade_profileface.xml') fps = FPS().start() cap = cv2.VideoCapture(0) cap.set(3,640) # set Width cap.set(4,480) # set Height while True: ret, img = cap.read() #img = cv2.flip(img, -1) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( gray, scaleFactor=1.2, minNeighbors=5, minSize=(20, 20) ) for (x,y,w,h) in faces: cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) roi_gray = gray[y:y+h, x:x+w] roi_color = img[y:y+h, x:x+w] cv2.imshow('video',img) fps.update() k = cv2.waitKey(30) & 0xff if k == 27: # press 'ESC' to quit break fps.stop() print("[INFO] approx. FPS: {:.2f}".format(fps.fps())) cap.release() cv2.destroyAllWindows() From grant.b.edwards at gmail.com Fri Sep 4 17:24:10 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 4 Sep 2020 21:24:10 -0000 (UTC) Subject: Replacement for pygtk? References: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> Message-ID: On 2020-09-03, Michael Torrie wrote: > On 9/3/20 1:17 PM, Grant Edwards wrote: >> On 2020-09-03, Grant Edwards wrote: >>> [...] >>> >>> Is pygobject the replacement for pygtk? >> >> It seems to be. I've started porting my pygtk app, and it's going >> pretty smoothly. I've already got my two custom widgets working. >> Oddly, the main module provided by the gobject package is called "gi". > > It stands for "gobject introspection." That's what I (later) suspected. > The nice thing about the gi module is it can wrap any gobject-based > library, not just GTK+ proper. So if someone made a custom widget > in Vala, for example, you could access it via gi. It's a neat > idea. My only problem with it is the resulting Python API is not > always as pythonic as pygtk code was. I noticed that right away. In pygtk, most methods (e.g. .pack_start) had named arguments with well chosen defaults. The vast majority of the time, I only supplied one argument for the pack_start() call. With gi's implementation of pack_start, there are no named parameters: they're all positional. You have to specify all four of them every time, even if the last three are False,False,0 95% of the time. And the lack of names makes it impossible to figure out from reading the application source code what those last three actually mean. [The first argument is obvious in context.] I assume that difference is because pygtk was hand-written and gi is built auto-magically using SWIG or something like that? > I can't think of any specific examples at the moment, however. It's > pretty much good enough to not care too much. For native Linux apps I definitely prefer Gtk. The other choices are * WxPython ?- It's bigger and far more complex than pygtk/gi and the extra complexity doesn't ever seem to buy me anything except MS-Windows compatibility [which did matter for a few of the apps I used to maintain]. The last time I looked into Gtk on Windows, it didn't sound usable, but that was many years ago. * PyQt -- I run Gtk-centric Linux systems, and the second you try to use one Qt widget, it always seems to pull in hundreds of packages that take a week to build. * Tkinter -- It's ugly on Linux (yea, I know there are supposed to be ways to fix that, but they never seem to work for me). All of the tkinter apps I maintain all seem to have one or two widgets with behavior that's counter-intuitive. When you bundle a trivial tkinter app (e.g. with cx-freeze), it ends up huge unless you put in a great deal of work manually excluding stuff you don't need. Back when there was a gtk version of Wireshark, I usually didn't have any Qt stuff installed at all. I'm still trying to get _that_ knife pulled out of my back. How dare somebody give me (for free) something tremendously valuable and useful in a slightly different flavor than I would prefer. ;) > Similar arguments can be made against PyQt as well. Especially with > PyQt the end result feels a bit like writing C++ with a python > syntax. -- Grant From grant.b.edwards at gmail.com Fri Sep 4 17:31:09 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 4 Sep 2020 21:31:09 -0000 (UTC) Subject: Replacement for pygtk? References: Message-ID: On 2020-09-04, Chris Green wrote: > Grant Edwards wrote: >> On 2020-09-03, Grant Edwards wrote: >> > [...] >> > >> > Is pygobject the replacement for pygtk? >> >> It seems to be. I've started porting my pygtk app, and it's going >> pretty smoothly. I've already got my two custom widgets working. >> Oddly, the main module provided by the gobject package is called "gi". >> > I think the 'i' is for instrospection - GTK Introspection. > > FWIW I ported some Python 2 GTK code to Python 3 and it wasn't *too* > painful. Run 2to3 on the code and then fix the odd syntax errors that > remain. The 2 -> 3 part is usually trivial except for bytes. I work a lot with raw data from serial ports and network sockets, and trying to write programs that worked in both py2 and py3 was painful. I've started to abandon py2 support, and that makes it a lot easier. The only part of the gtk code that didn't translate directly (or almost so) was some pixbuf stuff. I'm still trying to figure out to "freeze" the size of a button so that when I change its contained label text on-the-fly it doesn't resize and shift everying else slightly. I don't remember that happening with gtk2 (which I can no longer run), but I've no idea why... -- Grant From larry at hastings.org Sat Sep 5 04:53:28 2020 From: larry at hastings.org (Larry Hastings) Date: Sat, 5 Sep 2020 01:53:28 -0700 Subject: [RELEASED] Python 3.5.10 is released Message-ID: <65cad330-de0e-315c-7825-74ca0e24479e@hastings.org> On behalf of the Python development community, I'm plesed to announce the availability of Python 3.5.10. Python 3.5 is in "security fixes only" mode.? This new version only contains security fixes, not conventional bug fixes, and it is a source-only release. Important Notice: The latest releases of Linux (Ubuntu 20.04, Fedora 32) ship with a new version of OpenSSL.? New versions of OpenSSL often include upgraded configuration requirements to maintain network security; this new version no longer finds Python 3.5's OpenSSL configuration acceptable.? As a result, most or all secure-transport networking libraries are broken in this release on systems where this new version of OpenSSL is deployed.? This means, for example, that seven (7) of the regression tests in the test suite now regularly fail.? Older versions of Linux, with older versions of OpenSSL installed, are unaffected.? We're aware of the problem.? Unfortunately, as 3.5 is nearly completely out of support, it has become very low priority, and we've been unable to find the resources to get the problem fixed.? It's possible that these problems simply won't be fixed in 3.5 before it reaches its end-of-life.? As always we recommend upgrading to the latest Python release wherever possible. Python 3.5 will reach its "end of life" at the end of September 2020.? If there are no security patches filed for Python 3.5 after the release of Python 3.5.10, then Python 3.5.10 will be the final release of the 3.5 series. You can find Python 3.5.10 here: https://www.python.org/downloads/release/python-3510/ Cheers, //arry/ From cl at isbd.net Sat Sep 5 05:00:35 2020 From: cl at isbd.net (Chris Green) Date: Sat, 5 Sep 2020 10:00:35 +0100 Subject: Replacement for pygtk? References: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> Message-ID: Grant Edwards wrote: > > The nice thing about the gi module is it can wrap any gobject-based > > library, not just GTK+ proper. So if someone made a custom widget > > in Vala, for example, you could access it via gi. It's a neat > > idea. My only problem with it is the resulting Python API is not > > always as pythonic as pygtk code was. > > I noticed that right away. In pygtk, most methods (e.g. .pack_start) > had named arguments with well chosen defaults. The vast majority of > the time, I only supplied one argument for the pack_start() call. > With gi's implementation of pack_start, there are no named parameters: > they're all positional. You have to specify all four of them every > time, even if the last three are False,False,0 95% of the time. And > the lack of names makes it impossible to figure out from reading the > application source code what those last three actually mean. [The > first argument is obvious in context.] > > I assume that difference is because pygtk was hand-written and gi is > built auto-magically using SWIG or something like that? > In my case a couple of constants/enums changed their names and of course gtk becomes Gtk in many places. -- Chris Green ? From f.leroy at omnias.fr Sat Sep 5 09:54:10 2020 From: f.leroy at omnias.fr (f.leroy at omnias.fr) Date: Sat, 5 Sep 2020 15:54:10 +0200 Subject: Uninstall problem Message-ID: Hello, I commit an error to install python because I chose python 3.8.5 x32bytes So I wanted uninstalling it to install python 3.7.9 x64bytes But 3.8.5 version don't want uninstall !?! And so I have the twice in my computer now ! How can I do to uninstall 3.8.5 ? Thanks https://recrute.pole-emploi.fr/page-entreprise/omnias-001 From luuk at invalid.lan Sat Sep 5 12:34:31 2020 From: luuk at invalid.lan (Luuk) Date: Sat, 5 Sep 2020 18:34:31 +0200 Subject: Uninstall problem In-Reply-To: References: Message-ID: <5f53be17$0$14402$e4fe514c@newszilla.xs4all.nl> On 5-9-2020 15:54, f.leroy at omnias.fr wrote: > Hello, > > > > I commit an error to install python because I chose python 3.8.5 x32bytes > > So I wanted uninstalling it to install python 3.7.9 x64bytes > > But 3.8.5 version don't want uninstall !?! > > > > And so I have the twice in my computer now ! How can I do to uninstall 3.8.5 > ? > > > > Thanks > > You have to tel which OS (Operating System) you are using, And from which place you installed this version. Because i am assuming you use Windows: If it is from here: https://www.microsoft.com/en-us/p/python-38/9mssztt1n39l?activetab=pivot:overviewtab then uninstall info is here: https://support.microsoft.com/en-us/help/4028054/windows-10-repair-or-remove-programs -- Luuk From akkana at shallowsky.com Sat Sep 5 13:18:59 2020 From: akkana at shallowsky.com (Akkana Peck) Date: Sat, 5 Sep 2020 11:18:59 -0600 Subject: Replacement for pygtk? In-Reply-To: Message-ID: <20200905171859.GC4697@shallowsky.com> Grant Edwards writes: > Is pygobject the replacement for pygtk? The easiest way to use it, if you want a quick port with the fewest code changes, is: from gi import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') I don't know if pygtkcompat is going to be supported forever, or will eventually be deprecated, but it does make porting very easy. The harder way, from gi.repository import Gtk (plus Gdk, GdkPixbuf, Pango, PangoCairo etc.) might be more future-proof but requires more porting effort. Grant Edwards writes: > I assume that difference is because pygtk was hand-written and gi is > built auto-magically using SWIG or something like that? Right. Which also has the unfortunate side effect that gi-imported libraries usually have no built-in documentation -- you can't learn much by typing help(object) or help(classname) in the Python console. So you usually have to use the C documentation and guess at the Python signatures. > For native Linux apps I definitely prefer Gtk. The other choices are > extra complexity doesn't ever seem to buy me anything except > MS-Windows compatibility [which did matter for a few of the apps I > used to maintain]. The last time I looked into Gtk on Windows, it > didn't sound usable, but that was many years ago. A few years ago, pip install pygtk worked on Windows for gtk2 (in fact, it *only* worked on Windows; it didn't work on Mac or Linux). I suspect you can install the new gi version of GTK3 etc. via pip3, but I haven't actually verified that. On Mac, python-gtk2 was extremely difficult to install. I hope python3/gi/GTK3 is easier. You can install these packages via pip now on Linux, so I'd hope that's true on Mac as well. > * PyQt -- I run Gtk-centric Linux systems, and the second you try to > use one Qt widget, it always seems to pull in hundreds of packages > that take a week to build. I haven't generally found that about PyQt. Most KDE apps do pull in hundreds of packages, but I haven't had to install that many just to use PyQt. I usually prefer GTK, but there are a few things PyQt offers that aren't available in GTK any more, like an HTML browser/viewer: python-webkit was only available for Python2 and there seems to be no GTK web viewer option now, whereas PyQt5.QtWebEngineWidgets allow for a reasonably functional, if not particularly well documented or configurable, HTML viewer. > * WxPython ?- It's bigger and far more complex than pygtk/gi and > [ ... ] > * Tkinter -- It's ugly on Linux (yea, I know there are supposed to be TkInter and WxPython are fine for bringing up a quick window, but when I've tried to use them for more complex apps, I usually hit limitations in low-level areas like event handling or window management. Though admittedly it's been years since I tried to write anything nontrivial in either one, and they may have matured. Grant Edwards writes: > I'm still trying to figure out to "freeze" the size of a button so > that when I change its contained label text on-the-fly it doesn't > resize and shift everying else slightly. I don't remember that > happening with gtk2 (which I can no longer run), but I've no idea > why... If you figure that out, let me know: I have a couple of apps that have that problem as well, and I've just been putting up with it. ...Akkana From mats at python.org Sat Sep 5 13:40:31 2020 From: mats at python.org (Mats Wichmann) Date: Sat, 5 Sep 2020 11:40:31 -0600 Subject: Uninstall problem In-Reply-To: References: Message-ID: <9c47874b-cc62-983d-adf5-fc99c8f3c2ed@python.org> On 9/5/20 7:54 AM, f.leroy at omnias.fr wrote: > Hello, > > > > I commit an error to install python because I chose python 3.8.5 x32bytes > > So I wanted uninstalling it to install python 3.7.9 x64bytes why not 3.8.5, by the way? > But 3.8.5 version don't want uninstall !?! what does this mean? uninstall should work like any uninstall on your platform. in what way doesn't it want to uninstall? > And so I have the twice in my computer now ! How can I do to uninstall 3.8.5 > ? it doesn't hurt to have more than one. If you're on Windows, and use the Python Launcher, you can show all your installs, and use it to select the one you want: py --list py -3.7 # specifically pick 3.7 py -3.8-32 # pick 32-bit 3.8, if both 64-bit and 32-bit are installed py -3-64 # pick latest 64-bit Py3 The one reason you might be unhappy with both is that the Python Launcher picks the highest numbered one as the default, so just py would get you 32-bit 3.8. if both 64-bit and 32-bit of same version are installed, the 64-bit one is preferred. From juvarfe at gmail.com Sat Sep 5 16:12:06 2020 From: juvarfe at gmail.com (Juanti VF) Date: Sat, 5 Sep 2020 16:12:06 -0400 Subject: Issue with python 3.7.9 installation Message-ID: Hey, I tried installing python 64 bit after uninstalling my 32 bit version. When I try to run python -v on the terminal I get an absolute TON of messages about frozen_importlib. I did add python to PATH during installation and I'm using a 64 bit win 10 machine. This is the .exe file I ran for installation, if that matters: python-3.7.9-amd64.exe Any ideas? Regards, Juan Ignacio. From tony.flury at btinternet.com Fri Sep 4 10:59:56 2020 From: tony.flury at btinternet.com (Tony Flury) Date: Fri, 4 Sep 2020 15:59:56 +0100 Subject: Any ideas for a new language inspired to Python? In-Reply-To: References: <919216B4-BB7C-407A-B61A-616F55A4DE56@barrys-emacs.org> Message-ID: On 08/08/2020 18:18, Marco Sulla wrote: .... > Thank you, some features are interesting, even if I prefer the Python syntax. > > What about the compiler? Is it better to "compile" to C or to > bytecode? How can I generate a bytecode that can be compiled by gcc? > Can I skip the AST generation for now, or it will be a great problem > later? Most modern compilers use an AST - it is simply an internal representation of the syntax, and for most compilers it it is an intermediate step before code generation. I think you mean skipping the bytecode generation and generating straight to C/machine code. -- Tony Flury From python at mrabarnett.plus.com Sat Sep 5 21:26:39 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 6 Sep 2020 02:26:39 +0100 Subject: Issue with python 3.7.9 installation In-Reply-To: References: Message-ID: <62ee205a-f6cf-eb8a-a3c6-6a83b57fbb45@mrabarnett.plus.com> On 2020-09-05 21:12, Juanti VF wrote: > Hey, > > I tried installing python 64 bit after uninstalling my 32 bit version. When > I try to run python -v on the terminal I get an absolute TON of messages > about frozen_importlib. > > I did add python to PATH during installation and I'm using a 64 bit win 10 > machine. > > This is the .exe file I ran for installation, if that matters: > python-3.7.9-amd64.exe > I think you've misunderstood what the -v switch is for. It means "verbose", so you're asking it to report what imports it's doing while it's starting up. From torriem at gmail.com Sun Sep 6 00:20:22 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 5 Sep 2020 22:20:22 -0600 Subject: Replacement for pygtk? In-Reply-To: References: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> Message-ID: <066325ef-ac77-7b89-6086-0363067bfdfb@gmail.com> On 9/4/20 3:24 PM, Grant Edwards wrote: > I assume that difference is because pygtk was hand-written and gi is > built auto-magically using SWIG or something like that? Essentially, yes. Although pygobject does not use a tool like swig to generate static wrappers. Rather it uses the GTK introspection API to ask gobject's for their methods and attributes, and then marshalls and calls them at runtime. So you can use pygobject with any GObject-based binary library, not just GTK+. Hope that makes sense. From digitalfantasy.it86559 at digitalfantasy.it Sun Sep 6 03:36:55 2020 From: digitalfantasy.it86559 at digitalfantasy.it (Liste guru) Date: Sun, 6 Sep 2020 09:36:55 +0200 Subject: Replacement for pygtk? In-Reply-To: <066325ef-ac77-7b89-6086-0363067bfdfb@gmail.com> References: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> <066325ef-ac77-7b89-6086-0363067bfdfb@gmail.com> Message-ID: <5aba8523-c621-27e7-72a2-b3f06747c8b7@digitalfantasy.it> Il 06/09/2020 06:20, Michael Torrie ha scritto: > On 9/4/20 3:24 PM, Grant Edwards wrote: >> I assume that difference is because pygtk was hand-written and gi is >> built auto-magically using SWIG or something like that? > Essentially, yes. Although pygobject does not use a tool like swig to > generate static wrappers. Rather it uses the GTK introspection API to > ask gobject's for their methods and attributes, and then marshalls and > calls them at runtime. So you can use pygobject with any GObject-based > binary library, not just GTK+. Hope that makes sense. ??? AFAIK, from the source code / include files a .gir file is generated (an xml with all the functions, parameters and info). ??? For example for a simple rectangle_int(x. y. width, height) in cairo you have: ??? ????? ??? ????? ????? ??? ????? ????? ??? ????? ????? ??? ????? ??? ??? From this file a .typelib is generated (a binary, compact representation of the data) and the gi library, using this file and the .dll/.so, creates the correct bindings and function for the language you use (at runtime). ??? Switching from Gtk 3.22 to Gtk 3.24 (or a new 3.26) is only a matter of using the new .typelib/.dll with your version of gi, at least until the gi folks puts the handling of the default values for parameters :) ??? So with the gi package for your python (say 3.5.10) you can use all the Gtk versions, you don't have to recompile for example Gtk 3.24.13 for your python/gi version. ??? To have all the Gtk works with python 3.8 you have only to port / build the gi part (and on windows make some magic to handle the new path handling for the .dll search/load location, but this is another story). ??? With best regards ??? ??? Daniele Forghieri From luuk at invalid.lan Sun Sep 6 08:24:05 2020 From: luuk at invalid.lan (Luuk) Date: Sun, 6 Sep 2020 14:24:05 +0200 Subject: Uninstall problem In-Reply-To: References: <9c47874b-cc62-983d-adf5-fc99c8f3c2ed@python.org> Message-ID: <5f54d4e4$0$10266$e4fe514c@news.xs4all.nl> On 5-9-2020 19:40, Mats Wichmann wrote: > On 9/5/20 7:54 AM, f.leroy at omnias.fr wrote: >> Hello, >> >> >> >> I commit an error to install python because I chose python 3.8.5 x32bytes >> >> So I wanted uninstalling it to install python 3.7.9 x64bytes > > why not 3.8.5, by the way? > >> But 3.8.5 version don't want uninstall !?! > > what does this mean? uninstall should work like any uninstall on your > platform. in what way doesn't it want to uninstall? > > >> And so I have the twice in my computer now ! How can I do to uninstall 3.8.5 >> ? > > > it doesn't hurt to have more than one. If you're on Windows, and use > the Python Launcher, you can show all your installs, and use it to > select the one you want: > > py --list > py -3.7 # specifically pick 3.7 > py -3.8-32 # pick 32-bit 3.8, if both 64-bit and 32-bit are installed > py -3-64 # pick latest 64-bit Py3 > > The one reason you might be unhappy with both is that the Python > Launcher picks the highest numbered one as the default, so just > > py > > would get you 32-bit 3.8. if both 64-bit and 32-bit of same version > are installed, the 64-bit one is preferred. > D:\TEMP>python -V Python 3.8.5 D:\TEMP>py --list Installed Pythons found by py Launcher for Windows -3.7-64 * Can you explain above? D:\TEMP>where py C:\Windows\py.exe D:\TEMP>where python C:\Users\Luuk\AppData\Local\Microsoft\WindowsApps\python.exe From mats at python.org Sun Sep 6 09:44:43 2020 From: mats at python.org (Mats Wichmann) Date: Sun, 6 Sep 2020 07:44:43 -0600 Subject: Uninstall problem In-Reply-To: <5f54d4e4$0$10266$e4fe514c@news.xs4all.nl> References: <9c47874b-cc62-983d-adf5-fc99c8f3c2ed@python.org> <5f54d4e4$0$10266$e4fe514c@news.xs4all.nl> Message-ID: <4bbaab41-d089-eb1d-7efd-152af409e3e5@python.org> On 9/6/20 6:24 AM, Luuk wrote: > On 5-9-2020 19:40, Mats Wichmann wrote: >> On 9/5/20 7:54 AM, f.leroy at omnias.fr wrote: >>> Hello, >>> >>> ? >>> I commit an error to install python because I chose python 3.8.5 >>> x32bytes >>> >>> So I wanted uninstalling it to install python 3.7.9 x64bytes >> >> why not 3.8.5, by the way? >> >>> But 3.8.5 version don't want uninstall !?! >> >> what does this mean??? uninstall should work like any uninstall on your >> platform. in what way doesn't it want to uninstall? >> >> >>> And so I have the twice in my computer now ! How can I do to >>> uninstall 3.8.5 >>> ? >> >> >> it doesn't hurt to have more than one.? If you're on Windows, and use >> the Python Launcher, you can show all your installs, and use it to >> select the one you want: >> >> py --list >> py -3.7??????? # specifically pick 3.7 >> py -3.8-32?? # pick 32-bit 3.8, if both 64-bit and 32-bit are installed >> py -3-64????? # pick latest 64-bit Py3 >> >> The one reason you might be unhappy with both is that the Python >> Launcher picks the highest numbered one as the default, so just >> >> py >> >> would get you 32-bit 3.8.?? if both 64-bit and 32-bit of same version >> are installed, the 64-bit one is preferred. >> > > D:\TEMP>python -V > Python 3.8.5 > > D:\TEMP>py --list > Installed Pythons found by py Launcher for Windows > ?-3.7-64 * > > > Can you explain above? Not sure what you're asking here? The python launcher is a separate program which keeps track of (and launches) your python.org Python installations, intended to cut down on the amount of path fiddling you otherwise have to do. Because of where it's installed (your snip below), it's always found. However, the Microsoft Store version of Python doesn't participate in this, as far as I've found in the past - and this would seem to be borne out by your investigation. > D:\TEMP>where py > C:\Windows\py.exe > > D:\TEMP>where python > C:\Users\Luuk\AppData\Local\Microsoft\WindowsApps\python.exe > From fabiofz at gmail.com Sun Sep 6 13:01:05 2020 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Sun, 6 Sep 2020 14:01:05 -0300 Subject: PyDev 8.0 Released Message-ID: PyDev 8.0 Release Highlights - *MyPy* - Make sure that only one MyPy is running at a given time (to prevent cache corruptions). - Properly report MyPy messages that only have a line number. ( *#PyDev-1091*) - MyPy integration now also shows notes for a message. (*#PyDev-1088*) - *Debugger* (updated to pydevd 2.0.0) - The frame evaluation mode (which adds programmatic breakpoints by rewriting bytecode) was redone (it had a critical issue which could make it skip breakpoints). - Fixed issue collecting try..except information. - Fixed issue evaluating numpy array with unexpected dimension. - *Type Inference* - Option to create a method at a given class properly considers type-hinting. (*#PyDev-1092*) - Support code-completion for Optional[]. (*#PyDev-1089*) - Properly handle type information when given as a string. ( *#PyDev-1082*, *#PyDev-1087*) - Fixed issue where line/col was not forwarded properly in go to definition. (*#PyDev-1075*) - Typing info should have priority when available. (*#PyDev-1079*) - Properly get completions considering function annotation. ( *#PyDev-1078*) - *Test running* - Fixed issue running tests which override *address* with nose. ( *#PYDev-1095*) - Fixed issue where test import/export didn't deal well with binary chars that were collected from the test. (*#PyDev-1067*) - *Others* - When finding a file in a project on Windows consider paths as case insensitive. - .mypy_cache and .pytest_cache contents are now marked as derived (so they can be filtered out in searches). - Fixed case where auto-import could be added to wrong location. ( *#PyDev-1085*) - Occurrence was not found in type hint return. (*#PyDev-1076*) - Find references not working for constant depending how it's used. ( *#PyDev-1083*) - Backported fix to properly parse raw f-string in Python 3.6. ( *#PyDev-991*) - Code completion inside f-strings. (*#PyDev-1081*) About PyDev PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and IronPython development, now also available for Python on Visual Studio Code. It comes with goodies such as code completion, syntax highlighting, syntax analysis, code analysis, refactor, debug, interactive console, etc. It is also available as a standalone through LiClipse with goodies such as multiple cursors, theming and support for many other languages, such as Django Templates, Jinja2, Html, JavaScript, etc. Links: PyDev: http://pydev.org PyDev Blog: http://pydev.blogspot.com PyDev on VSCode: http://pydev.org/vscode LiClipse: http://www.liclipse.com PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/ Cheers, Fabio Zadrozny From grant.b.edwards at gmail.com Sun Sep 6 14:29:42 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 6 Sep 2020 18:29:42 -0000 (UTC) Subject: Replacement for pygtk? References: <6efdb7a6-a894-a81f-cd42-29704be70467@gmail.com> <066325ef-ac77-7b89-6086-0363067bfdfb@gmail.com> Message-ID: On 2020-09-06, Michael Torrie wrote: > On 9/4/20 3:24 PM, Grant Edwards wrote: >> I assume that difference is because pygtk was hand-written and gi is >> built auto-magically using SWIG or something like that? > > Essentially, yes. Although pygobject does not use a tool like swig to > generate static wrappers. Rather it uses the GTK introspection API to > ask gobject's for their methods and attributes, and then marshalls and > calls them at runtime. I was wondering about that. Some of the error messages you get when you mistype something hinted that the "wrapping" is being done on-the-fly. > So you can use pygobject with any GObject-based binary library, not > just GTK+. Hope that makes sense. Yes, I think so. I can see how it would be far less work that maintaining something like pygtk. -- Grant From Gronicus at SGA.Ninja Mon Sep 7 03:20:40 2020 From: Gronicus at SGA.Ninja (Steve) Date: Mon, 7 Sep 2020 03:20:40 -0400 Subject: tinker Form question(s) Message-ID: <020c01d684e7$64757760$2d606620$@SGA.Ninja> I am not sure how to post the code for my file here, is copy/paste the best way? Is there another? I understand that attachments are stripped off. """ The following segment of code returns values of "spec". I would like to have it return the associated value of "DataLine" with each spec. It would also be nice to understand how this code works to hold/return the information. In pseudocode, a line something like: DataReturned = DataLine + " " + spec) New_Specs.append(DataReturned) explains what I would like to have returned. """ New_Specs = [] OldSpec = ItemID NewSpec = " " OldLine = ItemID x = 3 y = 0 for lineItem in range(len(ThisList)): DataLine, Spec = GetLineByItem(ThisList[y]) SVRlabel = ttk.Label(window, width = BoxWidth1, text = DataLine) SVRlabel.grid(column = 1, row = x, sticky=tk.W) SVRlabel = ttk.Label(window, width = BoxWidth2, text = Spec) SVRlabel.grid(column = 2, row = x) NewSpec = tk.StringVar() New_Specs.append(NewSpec) SVRCodeEntered = ttk.Entry(window, width = BoxWidth3, textvariable = NewSpec) SVRlabel = ttk.Entry(window, width = BoxWidth3, textvariable = NewSpec) SVRlabel.grid(column = 3, row = x, pady = 5, sticky=tk.W) SVRCodeEntered.grid(column = 3, row = x, pady = 5, padx = 15, sticky=tk.W) SVRCodeEntered.insert(0, OldSpec) x += 1 y += 1 return ([spec.get()for spec in New_Specs]) ========== Steve ================= Footnote: Some mornings it just isn't worth chewing through the leather straps. From sshivlal9601 at gmail.com Mon Sep 7 03:34:51 2020 From: sshivlal9601 at gmail.com (Shivlal Sharma) Date: Mon, 7 Sep 2020 00:34:51 -0700 (PDT) Subject: What this error want to say? Can't we use return without function? In-Reply-To: <5f55e0b9$0$5876$426a74cc@news.free.fr> References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> <5f55e0b9$0$5876$426a74cc@news.free.fr> Message-ID: <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote: > Shivlal Sharma wrote: > > N = int(input("enter a positive integer:")) > > coun = 1 > > while (N > 0): > > coun = coun * N > > N = N - 1 > > return coun > > nice = ntime(N) > > print(nice) > > > > > > error: return outside of the function > What did you expect return out of a function to even mean? I mean that can't we use return keyword outside of the function? From rosuav at gmail.com Mon Sep 7 03:37:28 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Sep 2020 17:37:28 +1000 Subject: What this error want to say? Can't we use return without function? In-Reply-To: <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> <5f55e0b9$0$5876$426a74cc@news.free.fr> <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> Message-ID: On Mon, Sep 7, 2020 at 5:36 PM Shivlal Sharma wrote: > > On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote: > > Shivlal Sharma wrote: > > > N = int(input("enter a positive integer:")) > > > coun = 1 > > > while (N > 0): > > > coun = coun * N > > > N = N - 1 > > > return coun > > > nice = ntime(N) > > > print(nice) > > > > > > > > > error: return outside of the function > > What did you expect return out of a function to even mean? > I mean that can't we use return keyword outside of the function? Well... no. What do you expect it to mean? It's like asking "why can't I use 'else' without 'if'?" - there'd need to be some meaning for it. ChrisA From sshivlal9601 at gmail.com Mon Sep 7 03:40:39 2020 From: sshivlal9601 at gmail.com (Shivlal Sharma) Date: Mon, 7 Sep 2020 00:40:39 -0700 (PDT) Subject: What this error want to say? Can't we use return without function? In-Reply-To: References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> <5f55e0b9$0$5876$426a74cc@news.free.fr> <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> Message-ID: On Monday, 7 September 2020 at 13:08:04 UTC+5:30, Chris Angelico wrote: > On Mon, Sep 7, 2020 at 5:36 PM Shivlal Sharma wrote: > > > > On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote: > > > Shivlal Sharma wrote: > > > > N = int(input("enter a positive integer:")) > > > > coun = 1 > > > > while (N > 0): > > > > coun = coun * N > > > > N = N - 1 > > > > return coun > > > > nice = ntime(N) > > > > print(nice) > > > > > > > > > > > > error: return outside of the function > > > What did you expect return out of a function to even mean? > > I mean that can't we use return keyword outside of the function? > Well... no. What do you expect it to mean? It's like asking "why can't > I use 'else' without 'if'?" - there'd need to be some meaning for it. > > ChrisA Ohh, got it. you mean we can't you return without a function, right? From sshivlal9601 at gmail.com Mon Sep 7 03:48:44 2020 From: sshivlal9601 at gmail.com (Shivlal Sharma) Date: Mon, 7 Sep 2020 00:48:44 -0700 (PDT) Subject: What this error want to say? Can't we use return without function? In-Reply-To: References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> <5f55e0b9$0$5876$426a74cc@news.free.fr> <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> Message-ID: On Monday, 7 September 2020 at 13:10:57 UTC+5:30, Shivlal Sharma wrote: > On Monday, 7 September 2020 at 13:08:04 UTC+5:30, Chris Angelico wrote: > > On Mon, Sep 7, 2020 at 5:36 PM Shivlal Sharma wrote: > > > > > > On Monday, 7 September 2020 at 12:57:16 UTC+5:30, Python wrote: > > > > Shivlal Sharma wrote: > > > > > N = int(input("enter a positive integer:")) > > > > > coun = 1 > > > > > while (N > 0): > > > > > coun = coun * N > > > > > N = N - 1 > > > > > return coun > > > > > nice = ntime(N) > > > > > print(nice) > > > > > > > > > > > > > > > error: return outside of the function > > > > What did you expect return out of a function to even mean? > > > I mean that can't we use return keyword outside of the function? > > Well... no. What do you expect it to mean? It's like asking "why can't > > I use 'else' without 'if'?" - there'd need to be some meaning for it. > > > > ChrisA > Ohh, got it. you mean we can't you return without a function, right? Thank you guys! From petef4+usenet at gmail.com Mon Sep 7 04:31:59 2020 From: petef4+usenet at gmail.com (Pete Forman) Date: Mon, 07 Sep 2020 09:31:59 +0100 Subject: Replacement for pygtk? References: <20200905171859.GC4697@shallowsky.com> Message-ID: <87eeneng1s.fsf@gmail.com> Akkana Peck writes: > Grant Edwards writes: >> * PyQt -- I run Gtk-centric Linux systems, and the second you try to >> use one Qt widget, it always seems to pull in hundreds of packages >> that take a week to build. > > I haven't generally found that about PyQt. Most KDE apps do pull in > hundreds of packages, but I haven't had to install that many just to > use PyQt. Once you have one Qt app in a Gtk DE, or vice versa, then you have taken most of the hit for packages. I doubt that many people run pure versions of either. -- Pete Forman From __peter__ at web.de Mon Sep 7 09:08:44 2020 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Sep 2020 15:08:44 +0200 Subject: tinker Form question(s) References: <020c01d684e7$64757760$2d606620$@SGA.Ninja> Message-ID: Steve wrote: > I am not sure how to post the code for my file here, is copy/paste the > best way? Yes. Try to paste only the relevant parts, or, if possible, post a small self-contained example that can be run by the reader without further editing. > Is there another? I understand that attachments are stripped > off. > > """ > The following segment of code returns values of "spec". > I would like to have it return the associated value of > "DataLine" with each spec. It would also be nice to understand > how this code works to hold/return the information. > > In pseudocode, a line something like: > > DataReturned = DataLine + " " + spec) > New_Specs.append(DataReturned) > > explains what I would like to have returned. > return ([spec.get()for spec in New_Specs]) [spec.get() for spec in New_Specs] is called "list comprehension" and is syntactic sugar for a list-creating loop like result = [] for spec in New_Specs: result.append(spec.get()) The relevant parts of the loop where you set up the GUI and the New_Specs list: > New_Specs = [] > for lineItem in range(len(ThisList)): > DataLine, Spec = GetLineByItem(ThisList[y]) ... > NewSpec = tk.StringVar() > New_Specs.append(NewSpec) First, using range(len(ThisList)) is almost always superfluous as you can iterate over the list directly. In your case: > New_Specs = [] for item in ThisList: > DataLine, Spec = GetLineByItem(item) ... > NewSpec = tk.StringVar() > New_Specs.append(NewSpec) Now, as you need DataLine later-on why not keep a copy? So let's turn New_Specs into a list of StringVar, DataLine tuples: > New_Specs = [] for item in ThisList: > DataLine, Spec = GetLineByItem(item) ... > NewSpec = tk.StringVar() New_Specs.append((NewSpec, DataLine)) When the function terminates (there is a mainloop() missing) you can create and return the result: # long form, with a loop result = [] for spec, dataline in New_Specs: result.append(dataline + " " + spec.get()) return result # alternative using a listcomp: return [dataline + " " + spec.get() for spec, dataline in New_specs] From tjreedy at udel.edu Mon Sep 7 05:54:56 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Sep 2020 05:54:56 -0400 Subject: What this error want to say? Can't we use return without function? In-Reply-To: <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> <5f55e0b9$0$5876$426a74cc@news.free.fr> <2587ea3a-bffa-4cfa-ab1f-3289ea371363n@googlegroups.com> Message-ID: On 9/7/2020 3:34 AM, Shivlal Sharma wrote: >>> nice = ntime(N) >>> error: return outside of the function Please copy and paste exact text. Python actually said SyntaxError: 'return' outside function which means that a 'return' outside of a function is a syntax error. -- Terry Jan Reedy From sshivlal9601 at gmail.com Mon Sep 7 03:08:54 2020 From: sshivlal9601 at gmail.com (Shivlal Sharma) Date: Mon, 7 Sep 2020 00:08:54 -0700 (PDT) Subject: What this error want to say? Can't we use return without function? Message-ID: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> N = int(input("enter a positive integer:")) coun = 1 while (N > 0): coun = coun * N N = N - 1 return coun nice = ntime(N) print(nice) error: return outside of the function From Joseph.Schachner at Teledyne.com Tue Sep 8 14:45:47 2020 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph) Date: Tue, 8 Sep 2020 18:45:47 +0000 Subject: What this error want to say? Can't we use return without function? In-Reply-To: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> References: <3c06fc93-b84f-4603-a837-e7702974d7a5n@googlegroups.com> Message-ID: I see. You didn't declare a function, it's just a python script. So you don't need a return in that situation, the script just ends when there are no more lines. By the way: you certainly don't want to return or quit BEFORE you print(nice). But the fix here is simply to delete "return coun". Then your script will run. --- Joseph S. -----Original Message----- From: Shivlal Sharma Sent: Monday, September 7, 2020 3:09 AM To: python-list at python.org Subject: What this error want to say? Can't we use return without function? N = int(input("enter a positive integer:")) coun = 1 while (N > 0): coun = coun * N N = N - 1 return coun nice = ntime(N) print(nice) error: return outside of the function From ndriuma at yandex.ru Mon Sep 7 19:01:38 2020 From: ndriuma at yandex.ru (Driuma Nikita) Date: Tue, 08 Sep 2020 02:01:38 +0300 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: Message-ID: <2572111599519644@mail.yandex.ru> ? ? -------- ???????????? ????????? -------- 08.09.2020, 01:43, "python-list-owner at python.org" : ? Hello! I see you want to post a message to the Python List. We would be happy to help, but you must subscribe first: ??[1]https://mail.python.org/mailman/listinfo/python-list After you have subscribed, please send your message to [2]python-list at python.org again. Please do not include images as this is a text-only forum -- instead, copy/paste or transcribe the information from the image that you want us to know. Alternatively, this list is mirrored both ways with the comp.lang.python newsgroup (news:comp.lang.python). Some people find it easier to follow this and other lists via gmane ([3]http://news.gmane.org/gmane.comp.python.general), a service which offers a newsgroup interface to many online mailing lists. *NB all posts to the mailing list are publicly archived at:* ??[4]https://mail.python.org/pipermail/python-list ? ? -------- ????? ????????????? ????????? -------- ? ? With Regards. Python is best. ? References Visible links 1. https://mail.python.org/mailman/listinfo/python-list 2. mailto:python-list at python.org 3. http://news.gmane.org/gmane.comp.python.general 4. https://mail.python.org/pipermail/python-list -------------- next part -------------- An embedded message was scrubbed... From: Driuma Nikita Subject: PYTHON BUG. deleting elements of list. Date: Tue, 08 Sep 2020 01:36:16 +0300 Size: 6818 URL: From doedau54 at gmail.com Mon Sep 7 22:22:54 2020 From: doedau54 at gmail.com (Don Edwards) Date: Tue, 8 Sep 2020 10:22:54 +0800 Subject: newbie Message-ID: Purchased the book python-basics-2020-05-18.pdf a few days ago. To direct my learning I have a project in mind as per below; Just started learning python 3.8. At 76 I will be a bit slow but fortunately decades ago l learnt pascal. I am not asking programming help just guidance toward package(s) I may need. My aim is to write a program that simulates croquet - 2 balls colliding with the strikers (cue) ball going into the hoop (pocket), not the target ball. I want to be able to move the balls around and draw trajectory lines to evaluate different positions. Is there a package for this or maybe one to draw and one to move? Any help much appreciated. -- Regards, Don Edwards I aim to live forever - or die in the attempt. So far so good! Perth Western Australia From rnyxscarl01 at gmail.com Tue Sep 8 01:33:28 2020 From: rnyxscarl01 at gmail.com (Rnyx_ Scarl01) Date: Tue, 8 Sep 2020 12:33:28 +0700 Subject: Opening python Message-ID: Hello I've downloaded the newest python but I can't find the python compiler app eventhough I've already downloaded tge necessary files. What shoukd I do? From lukasz at langa.pl Tue Sep 8 17:38:00 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Tue, 8 Sep 2020 23:38:00 +0200 Subject: [RELEASE] Python 3.8.6rc1 is now ready for testing Message-ID: <2FCF1584-1994-4BEA-B9DF-523F8D200654@langa.pl> Python 3.8.6rc1 is the release candidate of the sixth maintenance release of Python 3.8. Go get it here: https://www.python.org/downloads/release/python-386rc1/ Assuming no critical problems are found prior to 2020-09-21, the scheduled release date for 3.8.6, no code changes are planned between this release candidate and the final release. That being said, please keep in mind that this is a pre-release and as such its main purpose is testing. Maintenance releases for the 3.8 series will continue at regular bi-monthly intervals, with 3.8.7 planned for mid-November 2020. What?s new? The Python 3.8 series is the newest feature release of the Python language, and it contains many new features and optimizations. See the ?What?s New in Python 3.8 ? document for more information about features included in the 3.8 series. Python 3.8 is becoming more stable. Our bugfix releases are becoming smaller as we progress. This one contains 80 changes, not even a half of what we got in 3.8.4 (the following release was a hotfix). Detailed information about all changes made in version 3.8.6 specifically can be found in its change log . We hope you enjoy Python 3.8! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Your friendly release team, Ned Deily @nad Steve Dower @steve.dower ?ukasz Langa @ambv From mats at python.org Tue Sep 8 18:58:08 2020 From: mats at python.org (Mats Wichmann) Date: Tue, 8 Sep 2020 16:58:08 -0600 Subject: Opening python In-Reply-To: References: Message-ID: On 9/7/20 11:33 PM, Rnyx_ Scarl01 wrote: > Hello I've downloaded the newest python but I can't find the python > compiler app eventhough I've already downloaded tge necessary files. What > shoukd I do? What have you tried? And what platform are you on? This is mildly more involved on Windows. From mats at wichmann.us Tue Sep 8 19:06:48 2020 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 8 Sep 2020 17:06:48 -0600 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: <2572111599519644@mail.yandex.ru> References: <2572111599519644@mail.yandex.ru> Message-ID: <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> On 9/7/20 5:01 PM, Driuma Nikita wrote: _list = list(range(50)) for i, el in enumerate(_list): del _list[i] print(_list) Don't change the the list while you are iterating over it, it messes up the iteration. It's not "randomly deleting", it's when next is called to fetch the next item, the list has changed. One workaround is to iterate over a copy. For example here's using slicing to create a new list to iterate over: for i, el in enumerate(_list[:]): del _list[i] From Richard at Damon-Family.org Tue Sep 8 19:18:57 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Tue, 8 Sep 2020 19:18:57 -0400 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: <991d0303-e65e-9c97-fe85-aa9ea9adddc1@Damon-Family.org> On 9/8/20 7:06 PM, Mats Wichmann wrote: > On 9/7/20 5:01 PM, Driuma Nikita wrote: > > > _list = list(range(50)) > for i, el in enumerate(_list): > del _list[i] > print(_list) > > > Don't change the the list while you are iterating over it, it messes up > the iteration. It's not "randomly deleting", it's when next is called to > fetch the next item, the list has changed. > > One workaround is to iterate over a copy. For example here's using > slicing to create a new list to iterate over: > > for i, el in enumerate(_list[:]): > del _list[i] > The issue isn't so much that he is modifying the list that he is iterating over, but also when he deletes _list[0], all the other elements move down, so the next time when he does a del _list[1], that will delete what started as _list[2], and with your code, when he gets half way done he will hit an index error as he tries to delete _list[26] from a list with only 25 elements. -- Richard Damon From cs at cskk.id.au Tue Sep 8 18:59:58 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 9 Sep 2020 08:59:58 +1000 Subject: Opening python In-Reply-To: References: Message-ID: <20200908225958.GA14988@cskk.homeip.net> On 08Sep2020 12:33, Rnyx_ Scarl01 wrote: >Hello I've downloaded the newest python but I can't find the python >compiler app eventhough I've already downloaded tge necessary files. What >shoukd I do? After a download it is normally necessary to run the installer. Python is an interpreted language; the compiler phase runs as an automatic component of interpreting a Python script. If there isn't an obvious installer, or you've run the installer but still cannot invoke Python, we need more detail: - what did you download, and from where? - what operating system are you using? - what have you done with the download so far? Cheers, Cameron Simpson From cs at cskk.id.au Tue Sep 8 19:04:37 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 9 Sep 2020 09:04:37 +1000 Subject: newbie In-Reply-To: References: Message-ID: <20200908230437.GA24715@cskk.homeip.net> On 08Sep2020 10:22, Don Edwards wrote: >Purchased the book python-basics-2020-05-18.pdf a few days ago. >To direct my learning I have a project in mind as per below; A project is an excellent way to learn something; personally I find it hard to learn something without something to which to apply it. >Just started learning python 3.8. At 76 I will be a bit slow but >fortunately decades ago l learnt pascal. Aye; I find Python has a very similar "heft" to Pascal - nicely English language like "prose" syntax. >I am not asking programming help >just guidance toward package(s) I may need. My aim is to write a program >that simulates croquet - 2 balls colliding with the strikers (cue) ball >going into the hoop (pocket), not the target ball. I want to be able to >move the balls around and draw trajectory lines to evaluate different >positions. Is there a package for this or maybe one to draw and one to >move? Any help much appreciated. Python ships with a "tkinter" module which lets you define a GUI interface. You probably want some kind of "canvas" or "image" widget from within that to render your playing field diagrams/visualisations. Someone else will have to speak to a nice geometry package for simple 3d renders and lines/angles etc. Cheers, Cameron Simpson From grant.b.edwards at gmail.com Tue Sep 8 21:24:05 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 9 Sep 2020 01:24:05 -0000 (UTC) Subject: newbie References: Message-ID: On 2020-09-08, Don Edwards wrote: > I may need. My aim is to write a program > that simulates croquet - 2 balls colliding with the strikers (cue) ball > going into the hoop (pocket), not the target ball. I want to be able to > move the balls around and draw trajectory lines to evaluate different > positions. Is there a package for this or maybe one to draw and one to > move? Any help much appreciated. Is pygame still a thing? -- Grant From jimoeDESPAM at sohnen-moe.com Wed Sep 9 01:35:03 2020 From: jimoeDESPAM at sohnen-moe.com (James Moe) Date: Tue, 8 Sep 2020 22:35:03 -0700 Subject: Module exists and cannot be found Message-ID: python 3.6.10 opensuse tumbleweed linux 5.8.4 An old program based on Python (BackInTime) has recently been having difficulties functioning. See below. Module PyQt5 is most definitely installed. Apparently there is more to getting modules loaded than there used to be. (Also, I am not familiar with Python.) ----[ error message (verbose option) ]---- Traceback (most recent call last): File "/home/jmoe/diy/backintime-master/qt/app.py", line 35, in import qttools File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "/home/jmoe/diy/backintime-master/qt/qttools.py", line 21, in from PyQt5.QtGui import (QFont, QColor, QKeySequence) File "", line 971, in _find_and_load File "", line 941, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'PyQt5' ----[ end ]---- ----[ the 1st code lines causing the above ]---- qttools.py: import os import sys import gettext from PyQt5.QtGui import (QFont, QColor, QKeySequence) <<<-- line 21 ... app.py: import os import sys if not os.getenv('DISPLAY', ''): os.putenv('DISPLAY', ':0.0') import datetime import gettext import re import subprocess import shutil import signal from contextlib import contextmanager from tempfile import TemporaryDirectory import qttools <<<--- line 35 qttools.registerBackintimePath('common') ... ----[ end ]---- -- James Moe jmm-list at sohnen-moe dot com Think. From cs at cskk.id.au Wed Sep 9 01:19:14 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 9 Sep 2020 15:19:14 +1000 Subject: newbie In-Reply-To: References: Message-ID: <20200909051914.GA62539@cskk.homeip.net> On 09Sep2020 01:24, Grant Edwards wrote: >On 2020-09-08, Don Edwards wrote: >> I may need. My aim is to write a program >> that simulates croquet - 2 balls colliding with the strikers (cue) ball >> going into the hoop (pocket), not the target ball. I want to be able to >> move the balls around and draw trajectory lines to evaluate different >> positions. Is there a package for this or maybe one to draw and one to >> move? Any help much appreciated. > >Is pygame still a thing? Looks like: https://pypi.org/project/pygame/ https://pypi.org/project/pygame-geometry/ Don, there's a "Getting Started" page for Pygame here: https://www.pygame.org/wiki/GettingStarted including some platform specific notes. Cheers, Cameron Simpson From __peter__ at web.de Wed Sep 9 02:37:57 2020 From: __peter__ at web.de (Peter Otten) Date: Wed, 09 Sep 2020 08:37:57 +0200 Subject: Fwd: PYTHON BUG. deleting elements of list. References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: Mats Wichmann wrote: > On 9/7/20 5:01 PM, Driuma Nikita wrote: > > > _list = list(range(50)) > for i, el in enumerate(_list): > del _list[i] > print(_list) > > > Don't change the the list while you are iterating over it, it messes up > the iteration. It's not "randomly deleting", it's when next is called to > fetch the next item, the list has changed. > > One workaround is to iterate over a copy. For example here's using > slicing to create a new list to iterate over: > > for i, el in enumerate(_list[:]): > del _list[i] As Richard says, this won't work. Usually the best approach is to copy the items you want to keep: _list = [item for item in _list if keep(item)] If the list is huge you can also delete in reverse order: for i in reversed(len(_list)): if discard(_list[i]): del _list[i] (If you want to delete /all/ items use _list.clear() or del _list[:]) From Gronicus at SGA.Ninja Wed Sep 9 03:12:59 2020 From: Gronicus at SGA.Ninja (Steve) Date: Wed, 9 Sep 2020 03:12:59 -0400 Subject: Audacity and pipe_test.py Message-ID: <018401d68678$a679b580$f36d2080$@SGA.Ninja> I am trying to adapt this short file to be used for simple control of the Audacity audio recording program. I can get the following does to work: do_command("Record1stChoice") #Creates a new track and starts recording do_command("AddLabel:") #Places a label in the label track do_command("Stop") # stops the recording But not this one: do_command("SetLabel:Label='1' Text='Hello' ") This is supposed to place "Hello" into the label. Steve Foonote: The patient shall strive to suffer the symptoms of the disease that has been diagnosed by the doctor. From __peter__ at web.de Wed Sep 9 03:44:01 2020 From: __peter__ at web.de (Peter Otten) Date: Wed, 09 Sep 2020 09:44:01 +0200 Subject: Fwd: PYTHON BUG. deleting elements of list. References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: Peter Otten wrote: > If the list is huge you can also delete in reverse order: > > for i in reversed(len(_list)): Make that reversed(range(len(_list))). > if discard(_list[i]): > del _list[i] Example: >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i, item in enumerate(items): ... if item in "bcd": ... del items[i] ... >>> items ['a', 'c', 'e'] >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i in reversed(range(len(items))): ... if items[i] in "bcd": ... del items[i] ... >>> items ['a', 'e'] From rosuav at gmail.com Wed Sep 9 03:51:40 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Sep 2020 17:51:40 +1000 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: On Wed, Sep 9, 2020 at 5:45 PM Peter Otten <__peter__ at web.de> wrote: > > Peter Otten wrote: > > > If the list is huge you can also delete in reverse order: > > > > for i in reversed(len(_list)): > > Make that reversed(range(len(_list))). > > > if discard(_list[i]): > > del _list[i] > > Example: > > >>> items = ['a', 'b', 'c', 'd', 'e'] > >>> for i, item in enumerate(items): > ... if item in "bcd": > ... del items[i] > ... > >>> items > ['a', 'c', 'e'] > >>> items = ['a', 'b', 'c', 'd', 'e'] > >>> for i in reversed(range(len(items))): > ... if items[i] in "bcd": > ... del items[i] > ... > >>> items > ['a', 'e'] > But that's still pretty clunky AND inefficient (deleting from the middle of a list is a slow operation). Filtering is far better. items = [i for i in items if i not in "bcd"] And if you absolutely have to mutate in place: items[:] = [i for i in items if i not in "bcd"] ChrisA From nicholas.cole at gmail.com Wed Sep 9 04:17:14 2020 From: nicholas.cole at gmail.com (Nicholas Cole) Date: Wed, 9 Sep 2020 09:17:14 +0100 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: On Wed, Sep 9, 2020 at 8:52 AM Chris Angelico wrote: [snip] > And if you absolutely have to mutate in place: > > items[:] = [i for i in items if i not in "bcd"] How does that work to mutate in place? From rosuav at gmail.com Wed Sep 9 04:36:23 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Sep 2020 18:36:23 +1000 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> Message-ID: On Wed, Sep 9, 2020 at 6:18 PM Nicholas Cole wro > > On Wed, Sep 9, 2020 at 8:52 AM Chris Angelico wrote: > > [snip] > > And if you absolutely have to mutate in place: > > > > items[:] = [i for i in items if i not in "bcd"] > > How does that work to mutate in place? Technically it constructs a new filtered list, and then replaces the contents of the original list with the filtered one. That's effectively an in-place mutation; any other reference to that same list will see the change. Compare: a = list(range(20)) b = a a = [n for n in a if n % 3] print(a) print(b) You'll see that a and b now differ. But if you use slice assignment: a[:] = [n for n in a if n % 3] you'll see that the two are still the same list (and "a is b" will still be True). It's replacing the contents, rather than rebinding the name. ChrisA From mats at python.org Wed Sep 9 10:04:52 2020 From: mats at python.org (Mats Wichmann) Date: Wed, 9 Sep 2020 08:04:52 -0600 Subject: Fwd: PYTHON BUG. deleting elements of list. In-Reply-To: <991d0303-e65e-9c97-fe85-aa9ea9adddc1@Damon-Family.org> References: <2572111599519644@mail.yandex.ru> <2406b060-83f7-b0a1-3e8e-943f7ad7a2eb@wichmann.us> <991d0303-e65e-9c97-fe85-aa9ea9adddc1@Damon-Family.org> Message-ID: <8a910158-f9a0-a5f8-f3fd-7901f27ee43e@python.org> On 9/8/20 5:18 PM, Richard Damon wrote: > On 9/8/20 7:06 PM, Mats Wichmann wrote: >> On 9/7/20 5:01 PM, Driuma Nikita wrote: >> for i, el in enumerate(_list[:]): >> del _list[i] >> > The issue isn't so much that he is modifying the list that he is > iterating over, but also when he deletes _list[0], all the other > elements move down, yes, quite right, brain fail here, ignore me.... From barry at barrys-emacs.org Wed Sep 9 14:33:35 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 9 Sep 2020 19:33:35 +0100 Subject: Module exists and cannot be found In-Reply-To: References: Message-ID: <343FB70B-8213-4EB0-9BEC-862E6CCD79FB@barrys-emacs.org> > On 9 Sep 2020, at 06:35, James Moe via Python-list wrote: > > python 3.6.10 > opensuse tumbleweed > linux 5.8.4 > > An old program based on Python (BackInTime) has recently been having > difficulties functioning. See below. > > Module PyQt5 is most definitely installed. Apparently there is more to getting > modules loaded than there used to be. How did you check you have PyQt5 is installed like this? $ python3.6 >>> import PyQt5 If that works then. How do you run the app? > > (Also, I am not familiar with Python.) > > ----[ error message (verbose option) ]---- > Traceback (most recent call last): > File "/home/jmoe/diy/backintime-master/qt/app.py", line 35, in > import qttools > File "", line 971, in _find_and_load > File "", line 955, in _find_and_load_unlocked > File "", line 665, in _load_unlocked > File "", line 678, in exec_module > File "", line 219, in _call_with_frames_removed > File "/home/jmoe/diy/backintime-master/qt/qttools.py", line 21, in > from PyQt5.QtGui import (QFont, QColor, QKeySequence) > File "", line 971, in _find_and_load > File "", line 941, in _find_and_load_unlocked > File "", line 219, in _call_with_frames_removed > File "", line 971, in _find_and_load > File "", line 953, in _find_and_load_unlocked > ModuleNotFoundError: No module named 'PyQt5' > ----[ end ]---- I forget what does seeing frozen importlib imply? A free stand app with embedded python maybe? > > ----[ the 1st code lines causing the above ]---- > qttools.py: > import os > import sys > import gettext > from PyQt5.QtGui import (QFont, QColor, QKeySequence) <<<-- line 21 > ... > > app.py: > import os > import sys > > if not os.getenv('DISPLAY', ''): > os.putenv('DISPLAY', ':0.0') > > import datetime > import gettext > import re > import subprocess > import shutil > import signal > from contextlib import contextmanager > from tempfile import TemporaryDirectory > > import qttools <<<--- line 35 > qttools.registerBackintimePath('common') > ... > ----[ end ]---- > > -- > James Moe > jmm-list at sohnen-moe dot com > Think. > -- > https://mail.python.org/mailman/listinfo/python-list > From taleen92 at hotmail.com Wed Sep 9 05:23:25 2020 From: taleen92 at hotmail.com (Talin Alnaber) Date: Wed, 9 Sep 2020 09:23:25 +0000 Subject: Python download problem In-Reply-To: References: , , Message-ID: Good evening, I would like to ask for help regarding Python installation , I'm a beginner and I would like to challenge myself to start coding using Python language , but unfortunately I'm having problems while installing it , I used python.org to install the latest Windows version of Python ( 3.8.5) on my Windows 10 64 bit computer , after clicking on this link to download the file Windows (x86-64 executable installer) I opened it and check the boxes , I continued with the steps until it was successfully downloaded . After that I opened CMD and this screen appeared for me I wrote python --version then enter and I got error 'python' is not recognized as an internal or external command,operable program or batch file. I tried to fix it following these steps as the following Edit the system environment variables>>environment variables >>Path >>edit>>browse .exe path C:\Program Files\Python38>>ok (this is the link that I paste in the path) C:\Program Files\Python38 and same problem occurred . I opened Python IDLE , then I wrote Print("HI") >> enter , and I got HI as a result Does that mean that it is python is working fine on my PC and if yes , can I use IDLE to run the future scripts instead of CMD or I need to fix the CMD ? Thank you From torriem at gmail.com Tue Sep 8 23:51:14 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 8 Sep 2020 21:51:14 -0600 Subject: newbie In-Reply-To: References: Message-ID: On 9/8/20 7:24 PM, Grant Edwards wrote: > On 2020-09-08, Don Edwards wrote: > >> I may need. My aim is to write a program >> that simulates croquet - 2 balls colliding with the strikers (cue) ball >> going into the hoop (pocket), not the target ball. I want to be able to >> move the balls around and draw trajectory lines to evaluate different >> positions. Is there a package for this or maybe one to draw and one to >> move? Any help much appreciated. > > Is pygame still a thing? Yes. https://www.pygame.org/. Should be in most Linux distributions' repositories. From mennoholscher at gmail.com Wed Sep 9 06:20:05 2020 From: mennoholscher at gmail.com (Menno Holscher) Date: Wed, 9 Sep 2020 12:20:05 +0200 Subject: Module exists and cannot be found In-Reply-To: References: Message-ID: Op 09-09-2020 om 07:35 schreef James Moe via Python-list: > python 3.6.10 > opensuse tumbleweed Tumbleweed is a rolling distro, so that is extremely old for Tumbleweed. I would expect Python 3.8.4 or 3.8.5 to be current there. If you want to use another version, you would have to run in a virtual environment. Did you do that? > linux 5.8.4 > Module PyQt5 is most definitely installed. How did you check? You want to be in the same virtual environment the program runs in. From my installation (openSuse Leap, so there I run Python 3.6): Python 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import PyQt5 Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'PyQt5' >>> No PyQt5 as I do not have a Qt program in the environment :=) Vriendelijke groet/Kind regards, Menno H?lscher From python at mrabarnett.plus.com Wed Sep 9 17:59:01 2020 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 9 Sep 2020 22:59:01 +0100 Subject: Python download problem In-Reply-To: References: Message-ID: On 2020-09-09 10:23, Talin Alnaber wrote: > > Good evening, > I would like to ask for help regarding Python installation , > I'm a beginner and I would like to challenge myself to start coding using Python language , but unfortunately I'm having problems while installing it , > I used python.org to install the latest Windows version of Python ( 3.8.5) on my Windows 10 64 bit computer , after clicking on this link to download the file Windows (x86-64 executable installer) I opened it and check the boxes > > > , I continued with the steps until it was successfully downloaded . > After that I opened CMD and this screen appeared for me > > > I wrote python --version then enter and I got error > 'python' is not recognized as an internal or external command,operable program or batch file. > > > I tried to fix it following these steps as the following > Edit the system environment variables>>environment variables >>Path >>edit>>browse .exe path C:\Program Files\Python38>>ok > (this is the link that I paste in the path) > C:\Program Files\Python38 > > and same problem occurred . > I opened Python IDLE , then I wrote Print("HI") >> enter , and I got HI as a result > > > Does that mean that it is python is working fine on my PC and if yes , can I use IDLE to run the future scripts instead of CMD or I need to fix the CMD ? > These days it's recommended to use the Python launcher: py --version From Gronicus at SGA.Ninja Thu Sep 10 03:55:46 2020 From: Gronicus at SGA.Ninja (Steve) Date: Thu, 10 Sep 2020 03:55:46 -0400 Subject: Audacity and pipe_test.py In-Reply-To: <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> Message-ID: <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> I used the line you supplied but trying it again, I began to solve the problem through a series of accidents and errors. As it is, apparently the Pipe_Test.py has some peculiar features. >The first is that it will not tell you anything about errors, even whether or not there is one. >The commands are space-delimited so Text=Hello is not the same as Text = Hello even if you have the quotes. >It tolerates no variables. Label=X, if you have X in a loop, will always have the value of text X and not a changing number. As a matter of fact, since Label has to have a numeric value, and seeing X will place the value of label to be the default of 0. So, yes, placing the 1 in the line and no spaces, it worked. I was able to send text to the Label. One thing I would really appreciate is getting the line as follows to work: do_command("SetLabel:Label=T Text=ThisList[T] ") which it a total violation of what I described previously. (-: The object is to pull the text out of ThisList and increment by looping on T to populate the labels. Unfortunately, road bump may well put the kibosh on my project.... But I can dream, can't I? FootNote: If money does not grow on trees, then why do banks have branches? -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Wednesday, September 9, 2020 11:17 AM To: python-list at python.org Subject: Re: Audacity and pipe_test.py On Wed, 9 Sep 2020 03:12:59 -0400, "Steve" declaimed the following: >But not this one: > do_command("SetLabel:Label='1' Text='Hello' ") > >This is supposed to place "Hello" into the label. As I interpret https://manual.audacityteam.org/man/scripting.html#Using_Scripting the label is identified by an integer, not a string. Try do_command("SetLabel: Label=1 Text='Hello'") -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From edmondo.giovannozzi at gmail.com Thu Sep 10 11:10:32 2020 From: edmondo.giovannozzi at gmail.com (edmondo.giovannozzi at gmail.com) Date: Thu, 10 Sep 2020 08:10:32 -0700 (PDT) Subject: newbie In-Reply-To: References: Message-ID: <0bff7d75-d95e-482e-baa2-701af6ea21f0o@googlegroups.com> You can also have a look at www.scipy.org where you can find some packages used for scientific programming like numpy, scipy, matplotlib. The last one is a graphic package that may be useful to make some initial plots. Il giorno marted? 8 settembre 2020 22:57:36 UTC+2, Don Edwards ha scritto: > Purchased the book python-basics-2020-05-18.pdf a few days ago. > To direct my learning I have a project in mind as per below; > > Just started learning python 3.8. At 76 I will be a bit slow but > fortunately decades ago l learnt pascal. I am not asking programming help > just guidance toward package(s) I may need. My aim is to write a program > that simulates croquet - 2 balls colliding with the strikers (cue) ball > going into the hoop (pocket), not the target ball. I want to be able to > move the balls around and draw trajectory lines to evaluate different > positions. Is there a package for this or maybe one to draw and one to > move? Any help much appreciated. > > -- > Regards, Don Edwards > I aim to live forever - or die in the attempt. So far so good! > Perth Western Australia From lizhenlian94 at gmail.com Thu Sep 10 12:48:22 2020 From: lizhenlian94 at gmail.com (LZ Lian) Date: Thu, 10 Sep 2020 16:48:22 +0000 Subject: Your confirmation is required to join the Python-list mailing list In-Reply-To: References: Message-ID: Dear Python Team, I've subscribed as requested. I've attached the subscription email for your reference too Now, for the issue.... I?ve tried to download and install the latest version of Python software a few times. However, each time I run the application, the window showing ?Modify / Repair / uninstall? will pop out. I?ve tried all the options on that pop-up and nothing works. I?ve tried googling for solutions and none are really helpful. Pls assist. Thanks Warmest Regards, Jovial Lian Sent from Mail for Windows 10 Get Outlook for Android ________________________________ From: Python-list on behalf of python-list-confirm+b649e785f0d9b368d0a61c736e9b5b6a5ff7fad9 at python.org Sent: Friday, September 11, 2020 12:44:50 AM To: Lizhenlian94 at gmail.com Subject: Your confirmation is required to join the Python-list mailing list Mailing list subscription confirmation notice for mailing list Python-list We have received a request from 223.25.79.105 for subscription of your email address, "Lizhenlian94 at gmail.com", to the python-list at python.org mailing list. To confirm that you want to be added to this mailing list, simply reply to this message, keeping the Subject: header intact. Or visit this web page: https://mail.python.org/mailman/confirm/python-list/b649e785f0d9b368d0a61c736e9b5b6a5ff7fad9 Or include the following line -- and only the following line -- in a message to python-list-request at python.org: confirm b649e785f0d9b368d0a61c736e9b5b6a5ff7fad9 Note that simply sending a `reply' to this message should work from most mail readers, since that usually leaves the Subject: line in the right form (additional "Re:" text in the Subject: is okay). If you do not wish to be subscribed to this list, please simply disregard this message. If you think you are being maliciously subscribed to the list, or have any other questions, send them to python-list-owner at python.org. From Richard at Damon-Family.org Thu Sep 10 14:04:37 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Thu, 10 Sep 2020 14:04:37 -0400 Subject: Your confirmation is required to join the Python-list mailing list In-Reply-To: References: Message-ID: <4d9fa284-2413-2f36-20a8-d54659aebd2d@Damon-Family.org> On 9/10/20 12:48 PM, LZ Lian wrote: > Dear Python Team, > > I've subscribed as requested. I've attached the subscription email for your reference too > > Now, for the issue.... I?ve tried to download and install the latest version of Python software a few times. However, each time I run the application, the window showing ?Modify / Repair / uninstall? will pop out. I?ve tried all the options on that pop-up and nothing works. I?ve tried googling for solutions and none are really helpful. Pls assist. Thanks > > Warmest Regards, > Jovial Lian > Sounds like you keep re-running the installer rather than the installed version of python. -- Richard Damon From stephie at osohq.com Thu Sep 10 15:28:58 2020 From: stephie at osohq.com (Stephanie Glaser) Date: Thu, 10 Sep 2020 15:28:58 -0400 Subject: ANN: Support for Python, Flask and Django in oso. Message-ID: ANN: Support for Python, Flask and Django in oso. Hey everyone - We built an open source policy engine for authorization that's embedded in your application, called oso . oso works in any Python application. We also have flask-oso and django-oso, integrations for using oso with Flask and Django apps. You write policies using the oso policy language to determine who can do what in your application, then you integrate them with a few lines of Python code using our library. Roles are a common pattern to reach for when setting up permissions, but we've found that they're limited and can get clunky, so oso provides a language (called Polar) that's purpose-built for representing common domain concepts that can be useful like data ownership, hierarchies, relationships, etc. We're continuing to improve oso and add features, so please share any feedback or questions you have. *Some useful links:* Quickstart & Install: https://docs.osohq.com/getting-started/quickstart.html Python library docs: https://docs.osohq.com/using/libraries/python/index.html Django docs: https://docs.osohq.com/using/frameworks/django.html Flask docs: https://docs.osohq.com/using/frameworks/flask.html Source code: https://github.com/osohq/oso/tree/main/languages/python/oso Feel free to join us on Slack for any questions: join-slack.osohq.com From info at wingware.com Thu Sep 10 16:27:22 2020 From: info at wingware.com (Wingware) Date: Thu, 10 Sep 2020 16:27:22 -0400 Subject: ANN: Wing Python IDE version 7.2.5 has been released Message-ID: <5F5A8C2A.2070400@wingware.com> Wing 7.2.5 enhances the accuracy of some types of code warnings, improves Debug I/O process management, streamlines new virtualenv creation, implements vi mode :[range]y, and makes a number of usability improvements. Details: https://wingware.com/news/2020-09-09 Downloads: https://wingware.com/downloads == About Wing == Wing is a light-weight but full-featured Python IDE designed specifically for Python, with powerful editing, code inspection, testing, and debugging capabilities. Wing's deep code analysis provides auto-completion, auto-editing, and refactoring that speed up development. Its top notch debugger works with any Python code, locally or on a remote host. Wing also supports test-driven development, version control, UI color and layout customization, and includes extensive documentation and support. Wing is available in three product levels: Wing Pro is the full-featured Python IDE for professional developers, Wing Personal is a free Python IDE for students and hobbyists (omits some features), and Wing 101 is a very simplified free Python IDE for beginners (omits many features). Learn more at https://wingware.com/ From jimoeDESPAM at sohnen-moe.com Thu Sep 10 17:23:20 2020 From: jimoeDESPAM at sohnen-moe.com (James Moe) Date: Thu, 10 Sep 2020 14:23:20 -0700 Subject: [SOLVED] Module exists and cannot be found In-Reply-To: References: Message-ID: On 9/8/20 10:35 PM, James Moe wrote: > Module PyQt5 is most definitely installed. Apparently there is more to getting > modules loaded than there used to be. > Cause: Operator Error The python installation had become rather messy resulting in the errors I showed. After installing python correctly, the errors disappeared and the app is performing as expected. Thank you all for your replies. -- James Moe jmm-list at sohnen-moe dot com Think. From Gronicus at SGA.Ninja Thu Sep 10 18:22:29 2020 From: Gronicus at SGA.Ninja (Steve) Date: Thu, 10 Sep 2020 18:22:29 -0400 Subject: Audacity and pipe_test.py In-Reply-To: <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> Message-ID: <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> Yes, certainly loving the progress now... Great learning curve. Your line worked except that I used copy/paste to place it in the program. I kept on getting something like "improper indentation or tab" and pointing to the end of that line. I guess hidden characters were imbedded and when I deleted all spaces before and after the paste, then placed them in again, those hiddens went away. Also, this language certainly does not like spaces at all except where IT wants them. The values for ThisList[T] entries were two words, words with spaces between. No go.... I removed spaces and replaced them with - where I wanted them, and it is working really nicely. My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150") lines do not seem to work unless they are immediately after the Record1stChoice instruction. This means that placement of the labels happen after the track is recorded and before the recording is stopped. I can live with that.... Now I am going to see if I can name the label track and the recording Track... Steve FootNote: If money does not grow on trees, then why do banks have branches? -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Thursday, September 10, 2020 1:51 PM To: python-list at python.org Subject: Re: Audacity and pipe_test.py CORRECTION On Thu, 10 Sep 2020 03:55:46 -0400, "Steve" declaimed the following: >One thing I would really appreciate is getting the line as follows to work: > do_command("SetLabel:Label=T Text=ThisList[T] ") which it a total >violation of what I described previously. (-: Forgot the ' quotes... do_command("SetLabel:Label=%s Text='%s'" % (T, ThisList[T])) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From Gronicus at SGA.Ninja Thu Sep 10 18:54:19 2020 From: Gronicus at SGA.Ninja (Steve) Date: Thu, 10 Sep 2020 18:54:19 -0400 Subject: Audacity and pipe_test.py In-Reply-To: <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> Message-ID: <00ec01d687c5$51e668d0$f5b33a70$@SGA.Ninja> PS: and YES I got the track name to happen. Sooo cool ===================================================== Yes, certainly loving the progress now... Great learning curve. Your line worked except that I used copy/paste to place it in the program. I kept on getting something like "improper indentation or tab" and pointing to the end of that line. I guess hidden characters were imbedded and when I deleted all spaces before and after the paste, then placed them in again, those hiddens went away. Also, this language certainly does not like spaces at all except where IT wants them. The values for ThisList[T] entries were two words, words with spaces between. No go.... I removed spaces and replaced them with - where I wanted them, and it is working really nicely. My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150") lines do not seem to work unless they are immediately after the Record1stChoice instruction. This means that placement of the labels happen after the track is recorded and before the recording is stopped. I can live with that.... Now I am going to see if I can name the label track and the recording Track... Steve FootNote: If money does not grow on trees, then why do banks have branches? -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Thursday, September 10, 2020 1:51 PM To: python-list at python.org Subject: Re: Audacity and pipe_test.py CORRECTION On Thu, 10 Sep 2020 03:55:46 -0400, "Steve" declaimed the following: >One thing I would really appreciate is getting the line as follows to work: > do_command("SetLabel:Label=T Text=ThisList[T] ") which it a total >violation of what I described previously. (-: Forgot the ' quotes... do_command("SetLabel:Label=%s Text='%s'" % (T, ThisList[T])) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From torriem at gmail.com Thu Sep 10 19:37:42 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 10 Sep 2020 17:37:42 -0600 Subject: Your confirmation is required to join the Python-list mailing list In-Reply-To: References: Message-ID: <281e36e4-f285-8cde-dc34-459bb0303f9b@gmail.com> On 9/10/20 10:48 AM, LZ Lian wrote: > Dear Python Team, > > I've subscribed as requested. I've attached the subscription email > for your reference too > > Now, for the issue.... I?ve tried to download and install the latest > version of Python software a few times. However, each time I run the > application, the window showing ?Modify / Repair / uninstall? will > pop out. I?ve tried all the options on that pop-up and nothing works. > I?ve tried googling for solutions and none are really helpful. Pls > assist. Thanks Did you read the documentation at https://docs.python.org/3/using/windows.html? Is there something in this document that is lacking? Seems like this identical question comes up on a weekly basis. From Gronicus at SGA.Ninja Fri Sep 11 01:20:09 2020 From: Gronicus at SGA.Ninja (Steve) Date: Fri, 11 Sep 2020 01:20:09 -0400 Subject: Difficulty getting started with Pipeclient.py Message-ID: <011701d687fb$37d2ef00$a778cd00$@SGA.Ninja> I downloaded the software and have been given a few test commands to use. When I run it as it is, I get the request to enter the commands manually and they work. I do not see how to get the commands to work automatically. Somehow, I have to bypass the "Enter command or 'Q' to quit" How do I do this? Is it a batch file? Commands given: SelectTime:End="5" RelativeTo="ProjectStart" Start="5" AddLabel: SetLabel:Label="0" Text="Hello" SelectTime:End="16" RelativeTo="ProjectStart" Start="15" AddLabel: SetLabel:Label="1" Text="World" ====================================== Footnote:] So a priest, a minister, and a rabbit walk into a bar and seat themselves at the counter. The priest orders wine and the minister a glass of water. The bartender turns to the rabbit and asks, "So what'll you have?" "I dunno," the rabbit says with a shrug, "I'm only here because of autocorrect." From cs at cskk.id.au Sat Sep 12 00:31:14 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sat, 12 Sep 2020 14:31:14 +1000 Subject: surprise: dict.get's default is a positional only parameter! Message-ID: <20200912043114.GA95963@cskk.homeip.net> Normally, if one writes a method like this: def get(self, k, default=None): one can call it as foo.get('x',2) or as foo('x',default=2). But not with dict.get. I'm amazed I've never tripped over this before. (Yes, I appreciate that dict is a builtin class written in C.) Cheers, Cameron Simpson From rosuav at gmail.com Sat Sep 12 02:49:09 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Sep 2020 16:49:09 +1000 Subject: surprise: dict.get's default is a positional only parameter! In-Reply-To: <20200912043114.GA95963@cskk.homeip.net> References: <20200912043114.GA95963@cskk.homeip.net> Message-ID: On Sat, Sep 12, 2020 at 4:18 PM Cameron Simpson wrote: > > Normally, if one writes a method like this: > > def get(self, k, default=None): > > one can call it as foo.get('x',2) or as foo('x',default=2). > > But not with dict.get. I'm amazed I've never tripped over this before. > (Yes, I appreciate that dict is a builtin class written in C.) > Yeah. In recent Python versions, you can use this functionality in your own code too. The docs for the get method say: Help on built-in function get: get(key, default=None, /) method of builtins.dict instance Return the value for key if key is in the dictionary, else default. The slash means that everything previous to that parameter is positional-only. Comes in handy, occasionally: >>> def spam(x, y, /, **kw): ... print(x, y, kw) ... >>> spam(1, 2, x=3, y=4) 1 2 {'x': 3, 'y': 4} ChrisA From jkexcel at comcast.net Sat Sep 12 11:28:15 2020 From: jkexcel at comcast.net (nhpython) Date: Sat, 12 Sep 2020 11:28:15 -0400 (EDT) Subject: requests-html 0.10.0 stopped rendering Message-ID: <2039968379.27768.1599924495987@connect.xfinity.com> Windows 10 x64 Pro v10.0.19041.488 build 19041 2020-09 Cumulative Update for Win 10 Ver 2004 for x64 KB4571756 2020-09 Cumulative Update for .NET Framework 3.5 & 4.8 for Win 10 Ver 2004 for x64 KB4576478 requests-html 0.10.0 pyppeteer 0.2.2 python 3.7+ requests 2.24 I've been using requests-html 0.10.0 (with requests) for a little over a week and it has been working perfectly until yesterday after windows updates. The problem is that will not render. I verified that requests-html fetches the webpage and returns HTTP status_code 200, successful response. The rendering process, just hangs. I've uninstalled and reinstalled the modules to force the reinstallation of the chrome engine. requests-html pyppeteer And it still didn't render. Who knows where to post issues with requests-html? From chirania.saurav at gmail.com Fri Sep 11 12:01:27 2020 From: chirania.saurav at gmail.com (Saurav Chirania) Date: Fri, 11 Sep 2020 21:31:27 +0530 Subject: Why doesn't collections.Counter support a "key" argument in its constructor? Message-ID: I really like that python's sort method accepts a key function as a parameter which can be used to specify how elements should be compared. Similarly, we could have a "key" argument which specifies how elements should be counted. Let's say we have a list of a million students. I would like to do something like: c = Counter(students, key = lambda student: student.marks) which would return a Counter which maps marks to the number of students with that marks. Let's say 29 students in the list had scored 100 marks, so one entry in the counter would be key=100, val=29. So, why doesn't Counter's constructor support this argument? Are there other pythonic ways to do this? Regards, Saurav Chirania From rosuav at gmail.com Sat Sep 12 12:39:52 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Sep 2020 02:39:52 +1000 Subject: Audacity and pipe_test.py In-Reply-To: References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> Message-ID: On Sun, Sep 13, 2020 at 2:33 AM Dennis Lee Bieber wrote: > > On Thu, 10 Sep 2020 18:22:29 -0400, "Steve" declaimed > the following: > > >Your line worked except that I used copy/paste to place it in the program. > >I kept on getting something like "improper indentation or tab" and pointing > >to the end of that line. I guess hidden characters were imbedded and when I > >deleted all spaces before and after the paste, then placed them in again, > >those hiddens went away. > > > Most likely your source had a series of spaces, my post had a leading > . > > In Python, a is counted as EIGHT spaces, even if an editor only > moved in by four spaces. Only in legacy versions of Python. In current versions, a tab is counted as a tab. ChrisA From rosuav at gmail.com Sat Sep 12 12:44:42 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Sep 2020 02:44:42 +1000 Subject: Why doesn't collections.Counter support a "key" argument in its constructor? In-Reply-To: References: Message-ID: On Sun, Sep 13, 2020 at 2:29 AM Saurav Chirania wrote: > > I really like that python's sort method accepts a key function as a > parameter which can be used to specify how elements should be compared. > > Similarly, we could have a "key" argument which specifies how elements > should be counted. Let's say we have a list of a million students. I would > like to do something like: > c = Counter(students, key = lambda student: student.marks) > > which would return a Counter which maps marks to the number of students > with that marks. Let's say 29 students in the list had scored 100 marks, so > one entry in the counter would be key=100, val=29. > > So, why doesn't Counter's constructor support this argument? Are there > other pythonic ways to do this? > If I'm interpreting this correctly, a comprehension should work for you: c = Counter(student.marks for student in students) ChrisA From __peter__ at web.de Sat Sep 12 13:00:39 2020 From: __peter__ at web.de (Peter Otten) Date: Sat, 12 Sep 2020 19:00:39 +0200 Subject: Why doesn't collections.Counter support a "key" argument in its constructor? References: Message-ID: Saurav Chirania wrote: > I really like that python's sort method accepts a key function as a > parameter which can be used to specify how elements should be compared. > > Similarly, we could have a "key" argument which specifies how elements > should be counted. Let's say we have a list of a million students. I would > like to do something like: > c = Counter(students, key = lambda student: student.marks) > > which would return a Counter which maps marks to the number of students > with that marks. Let's say 29 students in the list had scored 100 marks, > so one entry in the counter would be key=100, val=29. > > So, why doesn't Counter's constructor support this argument? Are there > other pythonic ways to do this? Yes, as the counter won't store the original student there is no advantage over the direct translation of your code Counter(map(lambda: student.marks, students)) or the more elegant variant with a generator expression Counter(student.marks for student in students) Functions like max() which do offer a key arg are a bit different as max(student.marks for student in students) returns the highest marks whereas max(students, key=lambda: student.marks) returns the student with the highest marks. To spell the latter without a key arg would require something more complicated like max((s.marks, i, s) for i, s in enumerate(students))[-1] If you need to count the marks while remembering the students you would use a dict or defaultdict instead of a counter, d = defaultdict(list) for s in students: d[s.marks] = s or, if the students are sorted by marks, itertools.groupby(). From jkexcel at comcast.net Sat Sep 12 13:56:35 2020 From: jkexcel at comcast.net (nhpython) Date: Sat, 12 Sep 2020 13:56:35 -0400 (EDT) Subject: requests-html 0.10.0 stopped rendering In-Reply-To: <2039968379.27768.1599924495987@connect.xfinity.com> References: <2039968379.27768.1599924495987@connect.xfinity.com> Message-ID: <1660405672.59928.1599933395915@connect.xfinity.com> > On 09/12/2020 11:28 AM nhpython wrote: > > > Windows 10 x64 Pro v10.0.19041.488 build 19041 > 2020-09 Cumulative Update for Win 10 Ver 2004 for x64 KB4571756 > 2020-09 Cumulative Update for .NET Framework 3.5 & 4.8 for Win 10 Ver 2004 for x64 KB4576478 > requests-html 0.10.0 > pyppeteer 0.2.2 > python 3.7+ > requests 2.24 > > I've been using requests-html 0.10.0 (with requests) for a little over a week and it has been working perfectly until yesterday after windows updates. > The problem is that will not render. > I verified that requests-html fetches the webpage and returns HTTP status_code 200, successful response. > The rendering process, just hangs. > > I've uninstalled and reinstalled the modules to force the reinstallation of the chrome engine. > requests-html > pyppeteer > > And it still didn't render. > > Who knows where to post issues with requests-html? > > -- Despite not knowing where to post issues, I solved my own problem. Steps taken. 1. uninstalled module: requests-html 2. uninstalled module: pyppeteer 3. deleted DIR: C:\Users\ME\AppData\Local\pyppeteer Step 2 removed: C:\Users\ME\AppData\Local\Programs\Python\Python37\Lib\site-packages\pyppeteer However it did not remove the existing chrome engine. To delete the Chrome Engine I had to delete its top folder. Step 3 deleted the top folder which contained the chrome engine. ..... (C:\Users\ME\AppData\Local\pyppeteer\pyppeteer\local-chromium\588429\chrome-win32\chrome.exe) Then when I reinstalled the requests-html module, the deletion of .\Local\pyppeteer\ forced the download & reinstallation of the chrome engine. This action brought down a new copy of the chrome engine which now works perfectly. Apparently, the new windows updates unregistered the former copy of chrome.exe and replacing it was necessary. However, simply uninstalling the pyppeteer module did not remove the version of chrome associated with it. I had to find its(.\588429\chrome-win32\chrome.exe) location and delete it manually before re-installing the module requests-html. From Gronicus at SGA.Ninja Sat Sep 12 14:23:25 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sat, 12 Sep 2020 14:23:25 -0400 Subject: Audacity and pipe_test.py In-Reply-To: References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> Message-ID: <028a01d68931$ce2eba60$6a8c2f20$@SGA.Ninja> >>My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150") >>lines > The first does nothing for Audacity processing -- it only blocks the >Python script itself. And you haven't provided the Audacity command >completely -- since I can't find that on the script reference page. You are correct. I use the py timer to pause the commands being sent to the pipe. There seems to be something fluky about that too. It looks as if when I have four or more do_commands, it doesn't run as a timer. Takes more scrutiny... I am not sure how I lost the entire Audacity command for the Audacity time control. Still, I need a timer in there somewhere. Time will tell (-: "ENDIF, ENDFOR, ENDWHILE statements" do exist in my python program. I place them as comments to document the end of the operations. It makes it easier for me to follow the logic especially if they are nested. -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Friday, September 11, 2020 1:32 PM To: python-list at python.org Subject: Re: Audacity and pipe_test.py On Thu, 10 Sep 2020 18:22:29 -0400, "Steve" declaimed the following: >Your line worked except that I used copy/paste to place it in the program. >I kept on getting something like "improper indentation or tab" and >pointing to the end of that line. I guess hidden characters were >imbedded and when I deleted all spaces before and after the paste, then >placed them in again, those hiddens went away. > Most likely your source had a series of spaces, my post had a leading . In Python, a is counted as EIGHT spaces, even if an editor only moved in by four spaces. Python uses indentation to indicate the block structure of the language -- you'll note there are no { } (C or Java), nor ENDIF, ENDFOR, ENDWHILE statements. >Also, this language certainly does not like spaces at all except where >IT wants them. The values for ThisList[T] entries were two words, words >with spaces between. No go.... I removed spaces and replaced them with >- where I wanted them, and it is working really nicely. > If this is in response to my /first/ post, I forgot to include the ' ' delimiters around the string argument. That meant the command you were sending to Audacity was seeing three or more parameters, not two. Python didn't care at that point. If you have the ' ' in place, then Audacity is the application that is complaining. >My time.sleep(60) or the do_command("'Start Time'=0, 'End Time'=150") >lines The first does nothing for Audacity processing -- it only blocks the Python script itself. And you haven't provided the Audacity command completely -- since I can't find that on the script reference page. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From random832 at fastmail.com Sat Sep 12 19:22:29 2020 From: random832 at fastmail.com (Random832) Date: Sat, 12 Sep 2020 19:22:29 -0400 Subject: =?UTF-8?Q?Re:_Why_doesn't_collections.Counter_support_a_"key"_argument_i?= =?UTF-8?Q?n_its_constructor=3F?= In-Reply-To: References: Message-ID: On Fri, Sep 11, 2020, at 12:01, Saurav Chirania wrote: > I really like that python's sort method accepts a key function as a > parameter which can be used to specify how elements should be compared. > > Similarly, we could have a "key" argument which specifies how elements > should be counted. Let's say we have a list of a million students. I would > like to do something like: > c = Counter(students, key = lambda student: student.marks) > > which would return a Counter which maps marks to the number of students > with that marks. Let's say 29 students in the list had scored 100 marks, so > one entry in the counter would be key=100, val=29. > > So, why doesn't Counter's constructor support this argument? Are there > other pythonic ways to do this? I'd like to add to this discussion that a feature like this would not be unreasonable to have on all dictionaries, and when I have wanted it in the past it has been on WeakKeyDictionary, for which the obvious workaround of making a wrapper class that uses the key function for __eq__ and __hash__ isn't usable From Gronicus at SGA.Ninja Sun Sep 13 16:45:52 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 13 Sep 2020 16:45:52 -0400 Subject: Audacity and pipe_test.py In-Reply-To: <72rslf9808jon3ahfj3bv727sdgolerdhj@4ax.com> References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> <028a01d68931$ce2eba60$6a8c2f20$@SGA.Ninja> <72rslf9808jon3ahfj3bv727sdgolerdhj@4ax.com> Message-ID: <03ad01d68a0e$def4d1d0$9cde7570$@SGA.Ninja> "There is no promise on time.sleep() that the program will restart exactly when the time expires." No precision needed, +- two minutes is acceptable, even three.. In my tests, I see scarcely three seconds difference. No problem. As for ENDIF, ENDWHILE, "But they have no syntactic meaning, and may get out of sync with the indentation." Being comments, will have no effect of indents. I use them strictly to see the structure and usually for long segments of code only. -----Original Message----- From: Python-list On Behalf Of Dennis Lee Bieber Sent: Sunday, September 13, 2020 3:06 PM To: python-list at python.org Subject: Re: Audacity and pipe_test.py On Sat, 12 Sep 2020 14:23:25 -0400, "Steve" declaimed the following: > >You are correct. I use the py timer to pause the commands being sent >to the pipe. There seems to be something fluky about that too. It >looks as if when I have four or more do_commands, it doesn't run as a >timer. Takes more scrutiny... time.sleep() is not a "timer" per se. In most implementations it is a blocking call to the operating system; the OS suspends the task and gives the CPU to another task until the requested delay expires, after which the task is placed onto the "ready queue" to /eventually/ continue running. In a system with lots of high priority tasks, that "eventually" could be a long time. There is no promise on time.sleep() that the program will restart exactly when the time expires. >"ENDIF, ENDFOR, ENDWHILE statements" do exist in my python program. I >place them as comments to document the end of the operations. It makes >it easier for me to follow the logic especially if they are nested. But they have no syntactic meaning, and may get out of sync with the indentation. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list From tjreedy at udel.edu Sun Sep 13 21:18:10 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Sep 2020 21:18:10 -0400 Subject: Need tests of turtledemo.colordemo on Windows installations Message-ID: User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed. When he runs ...> py -3.8 -m turtledemo.colormixer and moves the sliders a reasonable amount, he repeatably gets Fatal Python error: Cannot recover from stack overflow. ... https://bugs.python.org/issue41758 I have no problem, regardless of version, PowerShell or Command Prompt, installation or repository build. I suspect that the issue is specific to his machine, but before closing, we need more evidence either way. -- Terry Jan Reedy From grant.b.edwards at gmail.com Sun Sep 13 21:40:53 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 14 Sep 2020 01:40:53 -0000 (UTC) Subject: Audacity and pipe_test.py References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> <028a01d68931$ce2eba60$6a8c2f20$@SGA.Ninja> <72rslf9808jon3ahfj3bv727sdgolerdhj@4ax.com> <03ad01d68a0e$def4d1d0$9cde7570$@SGA.Ninja> Message-ID: On 2020-09-13, Steve wrote: > "There is no promise on time.sleep() that the program will restart exactly > when the time expires." > > No precision needed, +- two minutes is acceptable, even three.. In my > tests, I see scarcely three seconds difference. No problem. > > As for ENDIF, ENDWHILE, > "But they have no syntactic meaning, and may get out of sync with the > indentation." > > Being comments, will have no effect of indents. Exactly. That's the problem. > I use them strictly to see the structure and usually for long > segments of code only. The problem is that since they're comments, the compiler can't warn you when there's a mistake. After the code has been edited a few times, they will end up being wrong and misleading. If you can't see the structure of the code by looking at the code, then you're doing something wrong. Fix the code (or use a better editor). Adding comments to try to clarify the flow of poorly structured code just ends up making the problem worse later on when the comments are wrong. And they will end up being wrong. From Gronicus at SGA.Ninja Sun Sep 13 23:35:55 2020 From: Gronicus at SGA.Ninja (Steve) Date: Sun, 13 Sep 2020 23:35:55 -0400 Subject: Audacity and pipe_test.py In-Reply-To: References: <018401d68678$a679b580$f36d2080$@SGA.Ninja> <6cshlfhm1aioogettonq48ic72u8htf87m@4ax.com> <002f01d68747$cad73ea0$6085bbe0$@SGA.Ninja> <6ppklf9l70g61u50t1gtr6qeaab234d52a@4ax.com> <00df01d687c0$df64e3d0$9e2eab70$@SGA.Ninja> <028a01d68931$ce2eba60$6a8c2f20$@SGA.Ninja> <72rslf9808jon3ahfj3bv727sdgolerdhj@4ax.com> <03ad01d68a0e$def4d1d0$9cde7570$@SGA.Ninja> Message-ID: <03f301d68a48$28084f80$7818ee80$@SGA.Ninja> " The problem is that since they're comments, the compiler can't warn you when there's a mistake. After the code has been edited a few times, they will end up being wrong and misleading." If that is the case, then I would suspect that you are doing it incorrectly. It works especially well for me. It goes a long way to help with indents. It also prevents a lot of excessive scrolling. I do something similar with HTML. A comment at the end of a data structure that explains the purpose of the DS is extremely helpful. -----Original Message----- From: Python-list On Behalf Of Grant Edwards Sent: Sunday, September 13, 2020 9:41 PM To: python-list at python.org Subject: Re: Audacity and pipe_test.py On 2020-09-13, Steve wrote: > "There is no promise on time.sleep() that the program will restart > exactly when the time expires." > > No precision needed, +- two minutes is acceptable, even three.. In my > tests, I see scarcely three seconds difference. No problem. > > As for ENDIF, ENDWHILE, > "But they have no syntactic meaning, and may get out of sync with the > indentation." > > Being comments, will have no effect of indents. Exactly. That's the problem. > I use them strictly to see the structure and usually for long segments > of code only. The problem is that since they're comments, the compiler can't warn you when there's a mistake. After the code has been edited a few times, they will end up being wrong and misleading. If you can't see the structure of the code by looking at the code, then you're doing something wrong. Fix the code (or use a better editor). Adding comments to try to clarify the flow of poorly structured code just ends up making the problem worse later on when the comments are wrong. And they will end up being wrong. -- https://mail.python.org/mailman/listinfo/python-list From frank at chagford.com Mon Sep 14 01:07:19 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 14 Sep 2020 07:07:19 +0200 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: References: Message-ID: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> On 2020-09-14 3:18 AM, Terry Reedy wrote: > User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed.? When > he runs > ...> py -3.8 -m turtledemo.colormixer > and moves the sliders a reasonable amount, he repeatably gets > Fatal Python error: Cannot recover from stack overflow. > ... > https://bugs.python.org/issue41758 > > I have no problem, regardless of version, PowerShell or Command Prompt, > installation or repository build.? I suspect that the issue is specific > to his machine, but before closing, we need more evidence either way. > I am running 3.8.2 on Windows 10, and I can run the test with no issues at all. I will upgrade to 3.8.5 later today and try again. Frank Millman From frank at chagford.com Mon Sep 14 01:07:19 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 14 Sep 2020 07:07:19 +0200 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: References: Message-ID: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> On 2020-09-14 3:18 AM, Terry Reedy wrote: > User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed.? When > he runs > ...> py -3.8 -m turtledemo.colormixer > and moves the sliders a reasonable amount, he repeatably gets > Fatal Python error: Cannot recover from stack overflow. > ... > https://bugs.python.org/issue41758 > > I have no problem, regardless of version, PowerShell or Command Prompt, > installation or repository build.? I suspect that the issue is specific > to his machine, but before closing, we need more evidence either way. > I am running 3.8.2 on Windows 10, and I can run the test with no issues at all. I will upgrade to 3.8.5 later today and try again. Frank Millman From frank at chagford.com Mon Sep 14 02:01:51 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 14 Sep 2020 08:01:51 +0200 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> References: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> Message-ID: <7f848825-0721-37fc-d0c9-9b5e14b07978@chagford.com> On 2020-09-14 7:07 AM, Frank Millman wrote: > On 2020-09-14 3:18 AM, Terry Reedy wrote: >> User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed. >> When he runs >> ...> py -3.8 -m turtledemo.colormixer >> and moves the sliders a reasonable amount, he repeatably gets >> Fatal Python error: Cannot recover from stack overflow. >> ... >> https://bugs.python.org/issue41758 >> >> I have no problem, regardless of version, PowerShell or Command >> Prompt, installation or repository build.? I suspect that the issue is >> specific to his machine, but before closing, we need more evidence >> either way. >> > > I am running 3.8.2 on Windows 10, and I can run the test with no issues > at all. > > I will upgrade to 3.8.5 later today and try again. > > Frank Millman > 3.8.5 (64-bit) also runs with no problems. My machine is a Lenovo T420 laptop. Frank From frank at chagford.com Mon Sep 14 02:01:51 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 14 Sep 2020 08:01:51 +0200 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> References: <40fcfeb5-1997-d5a2-afad-434a820e95d6@chagford.com> Message-ID: <7f848825-0721-37fc-d0c9-9b5e14b07978@chagford.com> On 2020-09-14 7:07 AM, Frank Millman wrote: > On 2020-09-14 3:18 AM, Terry Reedy wrote: >> User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed. >> When he runs >> ...> py -3.8 -m turtledemo.colormixer >> and moves the sliders a reasonable amount, he repeatably gets >> Fatal Python error: Cannot recover from stack overflow. >> ... >> https://bugs.python.org/issue41758 >> >> I have no problem, regardless of version, PowerShell or Command >> Prompt, installation or repository build.? I suspect that the issue is >> specific to his machine, but before closing, we need more evidence >> either way. >> > > I am running 3.8.2 on Windows 10, and I can run the test with no issues > at all. > > I will upgrade to 3.8.5 later today and try again. > > Frank Millman > 3.8.5 (64-bit) also runs with no problems. My machine is a Lenovo T420 laptop. Frank From python at mrabarnett.plus.com Mon Sep 14 12:47:16 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 14 Sep 2020 17:47:16 +0100 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: References: Message-ID: <6bf51581-050e-ba20-aad0-e4c1c30439a0@mrabarnett.plus.com> On 2020-09-14 02:18, Terry Reedy wrote: > User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed. When > he runs > ...> py -3.8 -m turtledemo.colormixer > and moves the sliders a reasonable amount, he repeatably gets > Fatal Python error: Cannot recover from stack overflow. > ... > https://bugs.python.org/issue41758 > > I have no problem, regardless of version, PowerShell or Command Prompt, > installation or repository build. I suspect that the issue is specific > to his machine, but before closing, we need more evidence either way. > No problem here either. From mal at europython.eu Tue Sep 15 07:04:44 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 15 Sep 2020 13:04:44 +0200 Subject: EuroPython 2020: First batch of edited videos available Message-ID: <45f356aa-e466-d55b-cb29-77a7436213ae@europython.eu> We?re happy to release the first 30 cut videos of EuroPython 2020. You can watch them on our YouTube channel http://europython.tv/: * EuroPython 2020 Playlist * https://www.youtube.com/playlist?list=PL8uoeex94UhHgMD9GOCbEHWku7pEPx9fW Over the next few days/weeks, we?ll keep releasing more videos in batches. We are working on over 130 videos in total, so please stop by and check the playlist for more videos, or subscribe to our YouTube channel. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/629320931800694784/europython-2020-first-batch-of-edited-videos Tweet: https://twitter.com/europython/status/1305822961665019906 Thanks, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From mailtosuresh.u at gmail.com Tue Sep 15 03:19:15 2020 From: mailtosuresh.u at gmail.com (Suresh Unnikrishnan) Date: Tue, 15 Sep 2020 12:49:15 +0530 Subject: Unable to install folium using python version 3.8.4. Message-ID: Team, I use python version 3.8.4. I tried to import folium using IDLE but it was unsuccessful as it throws errors. After that, I tried to use pip install folium in the command prompt but it also throws an error. Kindly advise the steps to install folium. Regards, U.Suresh. From python at mrabarnett.plus.com Tue Sep 15 11:42:43 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Sep 2020 16:42:43 +0100 Subject: Unable to install folium using python version 3.8.4. In-Reply-To: References: Message-ID: On 2020-09-15 08:19, Suresh Unnikrishnan wrote: > Team, > > I use python version 3.8.4. > I tried to import folium using IDLE but it was unsuccessful as it throws > errors. After that, I tried to use pip install folium in the command prompt > but it also throws an error. Kindly advise the steps to install folium. > What were the errors? Which OS are you using? You need to provide details. From sami.strat at gmail.com Tue Sep 15 14:41:04 2020 From: sami.strat at gmail.com (SS) Date: Tue, 15 Sep 2020 11:41:04 -0700 (PDT) Subject: python mariadb & html tables Message-ID: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. The environment is Centos 7, I'm using Python3 with apache. Here is copy of the script I'm using: ******* SCRIPT START ********* import mysql.connector import cgitb cgitb.enable() mydb = mysql.connector.connect( host="localhost", user="root", password="somepassword", database="somedb" ) mycursor = mydb.cursor() mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") myresult = mycursor.fetchall() print "Content-type: text/plain:charset=utf-8" print for x in myresult: print(x) ******* SCRIPT STOPS ********* It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: ********* OUTPUT STARTS *********** Content-type: text/plain:charset=utf-8 (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') ********* OUTPUT STOPS *********** Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. TIA From larry.martell at gmail.com Tue Sep 15 14:51:30 2020 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 15 Sep 2020 11:51:30 -0700 Subject: python mariadb & html tables In-Reply-To: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> Message-ID: On Tue, Sep 15, 2020 at 11:45 AM SS wrote: > > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. > > The environment is Centos 7, I'm using Python3 with apache. > > Here is copy of the script I'm using: > > ******* SCRIPT START ********* > > import mysql.connector > import cgitb > cgitb.enable() > > mydb = mysql.connector.connect( > host="localhost", > user="root", > password="somepassword", > database="somedb" > ) > > mycursor = mydb.cursor() > > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") > > myresult = mycursor.fetchall() > > print "Content-type: text/plain:charset=utf-8" > print > for x in myresult: > print(x) > > > ******* SCRIPT STOPS ********* > > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: > > ********* OUTPUT STARTS *********** > > Content-type: text/plain:charset=utf-8 > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > ********* OUTPUT STOPS *********** > > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. What is the extraneous data? From sami.strat at gmail.com Tue Sep 15 15:33:26 2020 From: sami.strat at gmail.com (SS) Date: Tue, 15 Sep 2020 12:33:26 -0700 (PDT) Subject: python mariadb & html tables In-Reply-To: References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> Message-ID: <9fd9c1fa-70d3-4577-a6f1-050d785131ecn@googlegroups.com> On Tuesday, September 15, 2020 at 2:52:35 PM UTC-4, Larry.Martell at gmail.com wrote: > On Tue, Sep 15, 2020 at 11:45 AM SS wrote: > > > > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. > > > > The environment is Centos 7, I'm using Python3 with apache. > > > > Here is copy of the script I'm using: > > > > ******* SCRIPT START ********* > > > > import mysql.connector > > import cgitb > > cgitb.enable() > > > > mydb = mysql.connector.connect( > > host="localhost", > > user="root", > > password="somepassword", > > database="somedb" > > ) > > > > mycursor = mydb.cursor() > > > > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") > > > > myresult = mycursor.fetchall() > > > > print "Content-type: text/plain:charset=utf-8" > > print > > for x in myresult: > > print(x) > > > > > > ******* SCRIPT STOPS ********* > > > > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: > > > > ********* OUTPUT STARTS *********** > > > > Content-type: text/plain:charset=utf-8 > > > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > > > ********* OUTPUT STOPS *********** > > > > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. > What is the extraneous data? Thanks for responding. I am expecting (or would like) to get the following output: Content-type: text/plain:charset=utf-8
host1.mydomain.com 106.11 GB 32.72 GB 1 GB 172.18.33.62 Running 16 MHz
host2.mydomain.com 106.08 GB 56.87 GB 1 GB 1 GB 172.17.4.82 Running 0 Hz
But instead I get the following: Content-type: text/plain:charset=utf-8 (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') So each table row is enclosed in parenthesis, and each field is enclosed in 'u ', Ultimately, my intention is to create an html table, from a Maria DB table using Python. TIA. From python at mrabarnett.plus.com Tue Sep 15 15:41:57 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Sep 2020 20:41:57 +0100 Subject: python mariadb & html tables In-Reply-To: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> Message-ID: <2f1fd91f-44a6-65fa-38a8-dd111ee1b24f@mrabarnett.plus.com> On 2020-09-15 19:41, SS wrote: > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. > > The environment is Centos 7, I'm using Python3 with apache. > > Here is copy of the script I'm using: > > ******* SCRIPT START ********* > > import mysql.connector > import cgitb > cgitb.enable() > > mydb = mysql.connector.connect( > host="localhost", > user="root", > password="somepassword", > database="somedb" > ) > > mycursor = mydb.cursor() > > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") > > myresult = mycursor.fetchall() > > print "Content-type: text/plain:charset=utf-8" > print > for x in myresult: > print(x) > > > ******* SCRIPT STOPS ********* > > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: > > ********* OUTPUT STARTS *********** > > Content-type: text/plain:charset=utf-8 > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > ********* OUTPUT STOPS *********** > > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. > That's not Python 3, that's Python 2. The u'host1.mydomain.com' is a Unicode string. If you're going to print it in Python 2, you'll need to encode it to bytes, UTF-8 in this case. From python at mrabarnett.plus.com Tue Sep 15 16:00:55 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Sep 2020 21:00:55 +0100 Subject: python mariadb & html tables In-Reply-To: <9fd9c1fa-70d3-4577-a6f1-050d785131ecn@googlegroups.com> References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> <9fd9c1fa-70d3-4577-a6f1-050d785131ecn@googlegroups.com> Message-ID: <4d090d01-1b38-e91f-d816-f27b88bb393a@mrabarnett.plus.com> On 2020-09-15 20:33, SS wrote: > On Tuesday, September 15, 2020 at 2:52:35 PM UTC-4, Larry.Martell at gmail.com wrote: >> On Tue, Sep 15, 2020 at 11:45 AM SS wrote: >> > >> > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. >> > >> > The environment is Centos 7, I'm using Python3 with apache. >> > >> > Here is copy of the script I'm using: >> > >> > ******* SCRIPT START ********* >> > >> > import mysql.connector >> > import cgitb >> > cgitb.enable() >> > >> > mydb = mysql.connector.connect( >> > host="localhost", >> > user="root", >> > password="somepassword", >> > database="somedb" >> > ) >> > >> > mycursor = mydb.cursor() >> > >> > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") >> > >> > myresult = mycursor.fetchall() >> > >> > print "Content-type: text/plain:charset=utf-8" >> > print >> > for x in myresult: >> > print(x) >> > >> > >> > ******* SCRIPT STOPS ********* >> > >> > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: >> > >> > ********* OUTPUT STARTS *********** >> > >> > Content-type: text/plain:charset=utf-8 >> > >> > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') >> > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') >> > >> > ********* OUTPUT STOPS *********** >> > >> > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. >> What is the extraneous data? > > Thanks for responding. I am expecting (or would like) to get the following output: > > Content-type: text/plain:charset=utf-8 > > > > > >
host1.mydomain.com 106.11 GB 32.72 GB 1 GB 172.18.33.62 Running 16 MHz
host2.mydomain.com 106.08 GB 56.87 GB 1 GB 1 GB 172.17.4.82 Running 0 Hz
> > > > But instead I get the following: > > Content-type: text/plain:charset=utf-8 > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > So each table row is enclosed in parenthesis, and each field is enclosed in 'u ', > > Ultimately, my intention is to create an html table, from a Maria DB table using Python. TIA. > Each row (from myresult) is a tuple of Unicode strings. You're asking Python to print them, which is what it's doing. If you want a table in HTML, you'll need to write the code to do that. From sami.strat at gmail.com Tue Sep 15 16:31:22 2020 From: sami.strat at gmail.com (SS) Date: Tue, 15 Sep 2020 13:31:22 -0700 (PDT) Subject: python mariadb & html tables In-Reply-To: References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> Message-ID: On Tuesday, September 15, 2020 at 2:52:35 PM UTC-4, Larry.Martell at gmail.com wrote: > On Tue, Sep 15, 2020 at 11:45 AM SS wrote: > > > > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. > > > > The environment is Centos 7, I'm using Python3 with apache. > > > > Here is copy of the script I'm using: > > > > ******* SCRIPT START ********* > > > > import mysql.connector > > import cgitb > > cgitb.enable() > > > > mydb = mysql.connector.connect( > > host="localhost", > > user="root", > > password="somepassword", > > database="somedb" > > ) > > > > mycursor = mydb.cursor() > > > > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") > > > > myresult = mycursor.fetchall() > > > > print "Content-type: text/plain:charset=utf-8" > > print > > for x in myresult: > > print(x) > > > > > > ******* SCRIPT STOPS ********* > > > > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: > > > > ********* OUTPUT STARTS *********** > > > > Content-type: text/plain:charset=utf-8 > > > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > > > ********* OUTPUT STOPS *********** > > > > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. > What is the extraneous data? The extraneous data is: (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') It is all the u characters, the single quotes, and the parenthesis. Ultimately, I would like to create an html table in an html page, from a a MariaDB table. Thanks, From larry.martell at gmail.com Tue Sep 15 16:45:07 2020 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 15 Sep 2020 13:45:07 -0700 Subject: python mariadb & html tables In-Reply-To: References: <21f456fc-d4d8-4ff4-9a1d-b9695aef3152n@googlegroups.com> Message-ID: On Tue, Sep 15, 2020 at 1:35 PM SS wrote: > > On Tuesday, September 15, 2020 at 2:52:35 PM UTC-4, Larry.Martell at gmail.com wrote: > > On Tue, Sep 15, 2020 at 11:45 AM SS wrote: > > > > > > I'm trying to create an table in html from a Maria DB table, from a python script. I'm getting some unexpected results. > > > > > > The environment is Centos 7, I'm using Python3 with apache. > > > > > > Here is copy of the script I'm using: > > > > > > ******* SCRIPT START ********* > > > > > > import mysql.connector > > > import cgitb > > > cgitb.enable() > > > > > > mydb = mysql.connector.connect( > > > host="localhost", > > > user="root", > > > password="somepassword", > > > database="somedb" > > > ) > > > > > > mycursor = mydb.cursor() > > > > > > mycursor.execute("select name, provisioned_space, used_space, memory_size, cpus, ip_address, host_cpu, host_mem from projecttable where name like '%newproject%'") > > > > > > myresult = mycursor.fetchall() > > > > > > print "Content-type: text/plain:charset=utf-8" > > > print > > > for x in myresult: > > > print(x) > > > > > > > > > ******* SCRIPT STOPS ********* > > > > > > It works. But I get alot of extraneous data I don't need or want. Here is an example of the output: > > > > > > ********* OUTPUT STARTS *********** > > > > > > Content-type: text/plain:charset=utf-8 > > > > > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > > > (u'hopst2.mydomain.com', u'106.08 GB', u'56.87 GB', u'1 GB', u'1', u'172.17.4.82', u'Running', u'0 Hz') > > > > > > ********* OUTPUT STOPS *********** > > > > > > Is this typical of Python? Do I need create another script to clean up the output? Or is there a better way to extract data from a MariaDB instance, and put it in an HTML table? Any advise would be appreciated. > > What is the extraneous data? > > The extraneous data is: > > (u'host1.mydomain.com', u'106.11 GB', u'32.72 GB', u'1 GB', u'1', u'172.18.33.62', u'Running', u'16 MHz') > > It is all the u characters, the single quotes, and the parenthesis. Ultimately, I would like to create an html table in an html page, from a a MariaDB table. That is how the data is printed - those things are not part of the data. To generate HTML you will have to iterate over the result set and create the needed markup. E.g.: html = "" for row in myresult: html += "" for item in row: html += "" % item html += "" html += "
%s
" From tjreedy at udel.edu Tue Sep 15 20:39:44 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 15 Sep 2020 20:39:44 -0400 Subject: Need tests of turtledemo.colordemo on Windows installations In-Reply-To: References: Message-ID: On 9/14/2020 10:30 AM, Dennis Lee Bieber wrote: > On Sun, 13 Sep 2020 21:18:10 -0400, Terry Reedy > declaimed the following: > >> User Tushar Sadhwani and I both have Win 10 with 3.8.5 installed. When >> he runs > > 64-bit or 32-bit (or a mix of W10 64 and Python 32)? He has run both in separate directories. But when he ran the test suite, 4 tests failed with a numpy import error that Jeremy Kloth says is due to a mix. -- Terry Jan Reedy From ingdiegohl at gmail.com Wed Sep 16 01:21:20 2020 From: ingdiegohl at gmail.com (Ing Diegohl) Date: Tue, 15 Sep 2020 22:21:20 -0700 (PDT) Subject: dictionaries an matrices Message-ID: <811b5ae0-229c-40ee-acf8-80ba84b298b3n@googlegroups.com> Good morning everyone I would like to know if i can to create a dictionary with two matrices, where every element of the first matrix corresponds to dictionary's keys and the elements of the second matrix will be the values every key. thanks From joepareti54 at gmail.com Wed Sep 16 08:56:35 2020 From: joepareti54 at gmail.com (joseph pareti) Date: Wed, 16 Sep 2020 14:56:35 +0200 Subject: dictionaries an matrices In-Reply-To: <811b5ae0-229c-40ee-acf8-80ba84b298b3n@googlegroups.com> References: <811b5ae0-229c-40ee-acf8-80ba84b298b3n@googlegroups.com> Message-ID: you can use the following: (change the matrices as it suits your app): import numpy as np def set_params(w, b): params = {"w0": w[0], "w1": w[1] , "w2": w[2], "w3": w[3], "w4": w[4], "b": b} return params w = np.random.randn((5)) b = 1 params = set_params(w, b) for i in range(5): W = params.get("w"+str(i)) print(W) B = params.get('b') print(B) Am Mi., 16. Sept. 2020 um 13:14 Uhr schrieb Ing Diegohl < ingdiegohl at gmail.com>: > Good morning everyone > I would like to know if i can to create a dictionary with two matrices, > where every element of the first matrix corresponds to dictionary's keys > and the elements of the second matrix will be the values every key. > thanks > -- > https://mail.python.org/mailman/listinfo/python-list > -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From skip.montanaro at gmail.com Wed Sep 16 16:59:43 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Wed, 16 Sep 2020 15:59:43 -0500 Subject: Artie 3000 the coding robot Message-ID: I'm looking for feedback on Artie 3000 the Coding Robot. It's recommended by wirecutter.com for introductory programming for ages seven and up (though stemfinity.com says 7-12). I was thinking about getting it for my grandson who's turning 12 next month. I worry the introductory lessons might be kind of boring for him (though he's very into Minecraft, so who knows), and I've seen nothing online about transitioning to programming Artie using Python. His dad's a techie, so I'm not worried if he gets stuck. Here's the manufacturer's page for the tool/toy. Any feedback appreciated... Skip From ben.usenet at bsb.me.uk Wed Sep 16 19:45:58 2020 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Thu, 17 Sep 2020 00:45:58 +0100 Subject: musings on static variables References: Message-ID: <87wo0tnv49.fsf@bsb.me.uk> ram at zedat.fu-berlin.de (Stefan Ram) writes: > This C program use a local /static/ variable. > > main.c > > #include > > int f( void ) > { static int i = 0; > return i++; } > > int main( void ) > { printf( "%d\n", f() ); > printf( "%d\n", f() ); > printf( "%d\n", f() ); } > > transcript > > 0 > 1 > 2 > > When asked how to do this in Python, sometimes people > suggest to use a module variable for this, or to add "i" > to "f" as an attribute, or maybe even to use some kind of > closure. Another (more pythonic?) way to do this, would be: > > main.py > > def f_(): > i = 0 > while True: > yield i > i += 1 > > f = f_() > print( next( f )) > print( next( f )) > print( next( f )) > > transcript > > 0 > 1 > 2 def f(i = [0]): i[0] += 1 return i[0] print(f()) print(f()) print(f()) maybe? More than a bit yucky, though. -- Ben. From 22t at tripolho.com Wed Sep 16 13:39:51 2020 From: 22t at tripolho.com (Alberto Sentieri) Date: Wed, 16 Sep 2020 13:39:51 -0400 Subject: Asyncio Queue implementation suggestion Message-ID: <3081d39f-d475-6d5f-4bdf-f9c76feda5d2@tripolho.com> I have a suggestion about the implementation of asyncio queues that could improve performance. I might be missing something, however. I am sort of new to Python. Below a short description of the problem I am facing. I wrote a daemon in Python 3 (running in Linux) which test many devices at the same time, to be used in a factory environment. This daemon include multiple communication events to a back-end running in another country. I am using a class for each device I test, and embedded into the class I use asyncio. Due to the application itself and the number of devices tested simultaneously, I soon run out of file descriptor. Well, I increased the number of file descriptor in the application and then I started running into problems like ?ValueError: filedescriptor out of range in select()?. I guess this problem is related to a package called serial_asyncio, and of course, that could be corrected. However I became curious about the number of open file descriptors opened: why so many? Apparently asyncio Queues use a Linux pipe and each queue require 2 file descriptors. Am I correct? So I asked my self: if a asyncio queue is just a mechanism of piping information between two asyncio tasks, which should never run at the same time, why do I need the operating system in the middle of that? Isn?t the whole idea about asyncio that the operating system would be avoided whenever possible? No one will put anything into a queue if asyncio called epoll, because some Python code should be running to push things into the queue. If there is nothing in a particular queue, nothing will show up while asyncio is waiting for a file descriptor event. So, if I am correct, it would be more efficient to put the queue in a ready-queue list whenever something is pushed into it. Then, just before asyncio calls epoll (or select), it would check that ready queue, and it would process it before the epoll call. I mean that epoll would not be called unless all the queues have been properly processed. Queues would be implemented in a much simpler way, using local memory: a simple array may be enough to do the job. With that the OS would be avoided, and a much lower number of file descriptors would be necessary. From lukasz at langa.pl Thu Sep 17 05:57:24 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Thu, 17 Sep 2020 11:57:24 +0200 Subject: [RELEASE] Python 3.9.0rc2 is now available for testing Message-ID: <681B8B55-381A-4CFE-9A98-BD4F6E71B285@langa.pl> Python 3.9.0 is almost ready. This release, 3.9.0rc2, is the last planned preview before the final release of Python 3.9.0 on 2020-10-05. Get it here: https://www.python.org/downloads/release/python-390rc2/ In the mean time, we strongly encourage maintainers of third-party Python projects to prepare their projects for 3.9 compatibility during this phase. As always, report any issues to the Python bug tracker . Please keep in mind that this is a preview release and its use is not recommended for production environments. Information for core developers The 3.9 branch is now accepting changes for 3.9.1. To maximize stability, the final release will be cut from the v3.9.0rc2 tag. If you need the release manager to cherry-pick any critical fixes, mark issues as release blockers and/or add him as a reviewer on a critical backport PR on GitHub. To see which changes are currently cherry-picked for inclusion in 3.9.0, look at the short-lived branch-v3.9.0 on GitHub. Installer news This is the first version of Python to default to the 64-bit installer on Windows. The installer now also actively disallows installation on Windows 7. Python 3.9 is incompatible with this unsupported version of Windows. Major new features of the 3.9 series, compared to 3.8 Some of the new major new features and changes in Python 3.9 are: PEP 584 , Union Operators in dict PEP 585 , Type Hinting Generics In Standard Collections PEP 593 , Flexible function and variable annotations PEP 602 , Python adopts a stable annual release cadence PEP 615 , Support for the IANA Time Zone Database in the Standard Library PEP 616 , String methods to remove prefixes and suffixes PEP 617 , New PEG parser for CPython BPO 38379 , garbage collection does not block on resurrected objects; BPO 38692 , os.pidfd_open added that allows process management without races and signals; BPO 39926 , Unicode support updated to version 13.0.0; BPO 1635741 , when Python is initialized multiple times in the same process, it does not leak memory anymore; A number of Python builtins (range, tuple, set, frozenset, list, dict) are now sped up using PEP 590 vectorcall; A number of Python modules (_abc, audioop, _bz2, _codecs, _contextvars, _crypt, _functools, _json, _locale, operator, resource, time, _weakref) now use multiphase initialization as defined by PEP 489 ; A number of standard library modules (audioop, ast, grp, _hashlib, pwd, _posixsubprocess, random, select, struct, termios, zlib) are now using the stable ABI defined by PEP 384 . More resources Online Documentation PEP 596 , 3.9 Release Schedule Report bugs at https://bugs.python.org . Help fund Python and its community . Your friendly release team, Ned Deily @nad Steve Dower @steve.dower ?ukasz Langa @ambv From leo at superlel.me Thu Sep 17 10:04:09 2020 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Thu, 17 Sep 2020 16:04:09 +0200 Subject: Asyncio Queue implementation suggestion In-Reply-To: <3081d39f-d475-6d5f-4bdf-f9c76feda5d2@tripolho.com> References: <3081d39f-d475-6d5f-4bdf-f9c76feda5d2@tripolho.com> Message-ID: <9fc78b03-27e2-0a02-52ff-fe48a83e79e0@superlel.me> Hello Alberto, I scrambled your original message a bit here. > Apparently asyncio Queues use a Linux pipe and each queue require 2 file > descriptors. Am I correct? As far as I know (And I know a bit about asyncio in CPython 3.5+) asyncio.queues.Queue doesn't use any file descriptor. It is implemented using futures which are themselves tightly implemented with the inner workings of the event loop in mind. > I wrote a daemon in Python 3 (running in Linux) which test many devices > at the same time, to be used in a factory environment. This daemon > include multiple communication events to a back-end running in another > country. I am using a class for each device I test, and embedded into > the class I use asyncio. Due to the application itself and the number of > devices tested simultaneously, I soon run out of file descriptor. Well, > I increased the number of file descriptor in the application and then I > started running into problems like ?ValueError: filedescriptor out of > range in select()?. I guess this problem is related to a package called > serial_asyncio, and of course, that could be corrected. However I became > curious about the number of open file descriptors opened: why so many? I don't know about a CPython internal called serial_asyncio. I wonder whether the issue is coming from too much file descriptors... 1. If so, then I assume the issue you encounter with the selector is coming from the number of sockets you open (Too many sockets). 2. Otherwise it could come from the fact that some sockets gets destroyed before the selector gets a chance to await on the file descriptors. Without a complete traceback I can't be 100% certain, but the error message you get looks like a EBADF error. So the second hypothesis is my preferred. Have you tried enabling asyncio's debug mode ? I hope it can give you more information on why this is occurring. I believe it's a bug, not a limitation of CPython. - L?o From leo at superlel.me Thu Sep 17 11:53:01 2020 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Thu, 17 Sep 2020 17:53:01 +0200 Subject: Asyncio Queue implementation suggestion In-Reply-To: References: <3081d39f-d475-6d5f-4bdf-f9c76feda5d2@tripolho.com> Message-ID: On 17/09/2020 16:51, Dennis Lee Bieber wrote: > On Wed, 16 Sep 2020 13:39:51 -0400, Alberto Sentieri <22t at tripolho.com> > declaimed the following: > >> devices tested simultaneously, I soon run out of file descriptor. Well, >> I increased the number of file descriptor in the application and then I >> started running into problems like ?ValueError: filedescriptor out of >> range in select()?. I guess this problem is related to a package called > > https://man7.org/linux/man-pages/man2/select.2.html > """ > An fd_set is a fixed size buffer. > """ > and > """ > On success, select() and pselect() return the number of file > descriptors contained in the three returned descriptor sets (that > is, > the total number of bits that are set in readfds, writefds, > exceptfds). > """ > Emphasis "number of bits that are set" -- the two together implies that > these are words/longwords/quadwords used a bitmaps, one fd per bit, and > hence inherently limited to only as many bits as the word-length supports. By the way, Alberto, you can change the selector used by your event loop by instantiating the loop class by yourself [1]. You may want to use selectors.PollSelector [2]. [1] https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.SelectorEventLoop [2] https://docs.python.org/3/library/selectors.html#selectors.PollSelector - L?o From skip.montanaro at gmail.com Thu Sep 17 12:13:37 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 17 Sep 2020 11:13:37 -0500 Subject: Artie 3000 the coding robot In-Reply-To: References: Message-ID: > > Sounds like an expensive way to do turtle graphics... > > > Really expensive -- From what I could make out, the "robot" has no > independent functioning. It is tethered (WiFi, maybe Bluetooth) to the > controlling computer. The programs run on the computer and send command > packets to the robot... Thanks Dennis. My initial thought was that it probably used the turtle module, but I didn't see it mentioned anywhere. Seems the "value add" is just the communication module. I guess I'll pass. Skip From william.pearson at gmail.com Thu Sep 17 11:24:57 2020 From: william.pearson at gmail.com (William Pearson) Date: Thu, 17 Sep 2020 09:24:57 -0600 Subject: Puzzling difference between lists and tuples Message-ID: I am puzzled by the reason for this difference between lists and tuples. A list of with multiple strings can be reduced to a list with one string with the expected results: for n in ['first','second']: print n for n in ['first']: print n The first loop prints "first", "second", and the second prints "first". ==== This is not true for a tuple: for n in ('first','second'): print n for n in ('first'): print n prints "first", "second" in the first case, but "f","i","r","s","t" in the second. Where is this inconsistency explained? From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Sep 17 12:41:15 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 17 Sep 2020 11:41:15 -0500 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: <20200917164115.GI1494@scrozzle> On 2020-09-17 at 09:24:57 -0600, William Pearson wrote: > for n in ('first'): That's not a tuple. That's a string. Try it this way: for n in ('first',): # note the trailing comma print n Dan From ethan at stoneleaf.us Thu Sep 17 12:47:14 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 17 Sep 2020 09:47:14 -0700 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: On 9/17/20 8:24 AM, William Pearson wrote: > I am puzzled by the reason for this difference between lists and tuples. > > A list of with multiple strings can be reduced to a list with one string with the expected results: > for n in ['first']: > print n ['first'] is a list. > for n in ('first'): > print n ('first') is not a tuple. The tuple operator is actually the comma: >>> not_a_tuple = ('first') >>> type(not_a_tuple) >>> is_a_tuple = 'first', >>> type(is_a_tuple) I tend to use both as it makes it stand out a bit more: >>> still_a_tuple = ('first', ) >>> type(still_a_tuple) The only time the parentheses are required for tuple building is when they would otherwise not be interpreted that way: some_func('first', 'second') # some_func called with two str args some_func(('first', 'second')) # some_func called with one tuple arg -- ~Ethan~ From Richard at Damon-Family.org Thu Sep 17 12:50:05 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Thu, 17 Sep 2020 12:50:05 -0400 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: <297abb6b-74c8-3cc3-fa9c-496e826cffb4@Damon-Family.org> On 9/17/20 11:24 AM, William Pearson wrote: > I am puzzled by the reason for this difference between lists and tuples. > > A list of with multiple strings can be reduced to a list with one string with the expected results: > > for n in ['first','second']: > print n > > for n in ['first']: > print n > > The first loop prints "first", "second", and the second prints "first". > > ==== > > This is not true for a tuple: > > for n in ('first','second'): > print n > > for n in ('first'): > print n > > > prints "first", "second" in the first case, but "f","i","r","s","t" in the second. > > Where is this inconsistency explained? > Parenthesis don't always make a tuple (and in fact aren't needed to make them) ('first') is just the string value 'first', inside a set of parenthesis to possible affect order of operations. For 1 element tuples, you need a trailing comma, like ('first,) and in many places it also could be just 'first', just like your first example could be just for n in 'first', 'second': -- Richard Damon From python at mrabarnett.plus.com Thu Sep 17 13:43:39 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 17 Sep 2020 18:43:39 +0100 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: On 2020-09-17 17:47, Ethan Furman wrote: > On 9/17/20 8:24 AM, William Pearson wrote: > >> I am puzzled by the reason for this difference between lists and tuples. >> >> A list of with multiple strings can be reduced to a list with one string with the expected results: > >> for n in ['first']: >> print n > > ['first'] is a list. > >> for n in ('first'): >> print n > > ('first') is not a tuple. The tuple operator is actually the comma: > > >>> not_a_tuple = ('first') > >>> type(not_a_tuple) > > > >>> is_a_tuple = 'first', > >>> type(is_a_tuple) > > > I tend to use both as it makes it stand out a bit more: > > >>> still_a_tuple = ('first', ) > >>> type(still_a_tuple) > > > The only time the parentheses are required for tuple building is when > they would otherwise not be interpreted that way: > They're needed for the empty tuple, which doesn't have a comma. > some_func('first', 'second') # some_func called with two str args > > some_func(('first', 'second')) # some_func called with one tuple arg > From ethan at stoneleaf.us Thu Sep 17 14:03:48 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 17 Sep 2020 11:03:48 -0700 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: <6286b2cf-da4a-ef05-e979-b64554617a6c@stoneleaf.us> On 9/17/20 10:43 AM, MRAB wrote: > On 2020-09-17 17:47, Ethan Furman wrote: >> The only time the parentheses are required for tuple building is when >> they would otherwise not be interpreted that way: >> > They're needed for the empty tuple, which doesn't have a comma. Ah, right. Thanks. -- ~Ethan~ From pedicularis at mail.com Thu Sep 17 17:18:46 2020 From: pedicularis at mail.com (Frank Miles) Date: Thu, 17 Sep 2020 21:18:46 -0000 (UTC) Subject: wxpython-OGL fails to render objects with Python-3 Message-ID: I have a substantial wxpython-based application that I'm trying to port from python-2 to -3. Almost everything is working properly, except for a few small but important sections that use the OGL library. That executes without any exceptions, but the objects created within the diagram/canvas/panel are invisible! {sometimes they are visible for a small fraction of a second}. This occurs on Windows-10 and on Linux(Debian) systems. The colored background and buttons render just fine, the buttons do what they should, but no objects appear on the background (again, only with Py3, Py2 works properly). I have cut the code to a pretty minimum set and will attempt to paste it to the bottom of this message in the hope that it will encourage one of you to see what the problem might be. Alternatively if anyone knows of an example that works with Python-3 I'd be delighted to learn of it. Thanks for any insights!! # --------------------------------------------- # togl.py test 'OGL' shape system. from __future__ import print_function import sys if 2 == sys.version_info.major : import wxversion import wx import random import wx.lib.ogl as ogllib NOMSIZE=80 WINSIZE=400 N_ITEMS=7 shapeTypes= ( 'rect', 'circle', 'rndRect' ) class ShapeGraphicWindow(ogllib.ShapeCanvas): def __init__(self, parent): ogllib.ShapeCanvas.__init__(self, parent) self.diagram= ogllib.Diagram() self.SetDiagram(self.diagram) self.diagram.SetCanvas(self) self.SetBackgroundColour(wx.BLUE) def addShape(self, shape_type, title) : if 'rect' == shape_type : # rectangle shape= ogllib.RectangleShape(50, 35) brush= wx.Brush(wx.TheColourDatabase.Find("RED"), wx.SOLID) elif 'circle' == shape_type : # circle shape= ogllib.CircleShape(65) brush= wx.Brush(wx.TheColourDatabase.Find("YELLOW"), wx.SOLID) elif 'rndRect' == shape_type : # rounded-rectangle shape= ogllib.RectangleShape(45, 30) shape.SetCornerRadius(-0.3) brush= wx.Brush(wx.TheColourDatabase.Find("GOLDENROD"), wx.SOLID) else : raise AssertionError("Unable to add shape: %s : %s",(shape_type,title)) shape.SetBrush( brush ) x= int(random.uniform(NOMSIZE,WINSIZE-NOMSIZE)) shape.SetX(x) y= int(random.uniform(NOMSIZE,WINSIZE-NOMSIZE)) shape.SetY(y) shape.AddText(title) print("Draw",title,"at location ", (x,y), "on canvas of size", self.GetSize()) shape.SetCanvas(self) self.AddShape(shape) self.Refresh() shape.Show(True) return class TestPanel(wx.Panel): def __init__(self, frame) : wx.Panel.__init__(self, parent=frame) self.objcnts= (0,N_ITEMS) sz= wx.BoxSizer(wx.VERTICAL) hsz= wx.BoxSizer(wx.HORIZONTAL) btnq= wx.Button(self, -1, "Quit") btnq.Bind(wx.EVT_BUTTON, self.Quit) hsz.Add(btnq, 0, wx.ALL, 3) btnq= wx.Button(self, -1, "AutoTest") btnq.Bind(wx.EVT_BUTTON, self.AutoTest) hsz.Add(btnq, 0, wx.ALL, 3) sz.Add(hsz, 0, wx.ALIGN_LEFT) self.shp_graph_win= ShapeGraphicWindow(self) sz.Add(self.shp_graph_win, 2, wx.EXPAND) self.SetSizer(sz) #self.Layout() #self.Fit() self.SetAutoLayout(True) def mkTitle(self, index) : return ''.join([ chr(index + ord('A')), ":", str(index) ]) def AutoTest(self, event=None) : for j in range(*(self.objcnts)) : self.shp_graph_win.addShape(shapeTypes[j % len(shapeTypes)], self.mkTitle(j)) self.objcnts= (self.objcnts[1], self.objcnts[1]+N_ITEMS) def Quit(self, event) : self.Destroy() sys.exit(0) class TestFrame(wx.Frame): def __init__(self) : wx.Frame.__init__(self, None, -1, "test basic OGL functionality", size= wx.Size(WINSIZE,WINSIZE) ) TestPanel(self) self.Show(True) app = wx.App(False) frame = TestFrame() ogllib.OGLInitialize() app.MainLoop() sys.exit(0) From barpasc at yahoo.com Thu Sep 17 18:23:59 2020 From: barpasc at yahoo.com (pascal z) Date: Thu, 17 Sep 2020 15:23:59 -0700 (PDT) Subject: python oop learning communication between function inside a class Message-ID: Hello, I would like to know how possible it is to call a member function from a class and pass it a variable Example: class Application(tk.Frame): """docstring for .""" def __init__(self, parent): super(Application, self).__init__(parent) self.parent = parent parent.title('Courses selections') #parent.geometry("700x350") parent.geometry('500x320+0+0') #Width x Height # Create widgets/grid self.create_widgets() self.selected_item = 0 def create_widgets(self): ### FIRST NAME LABEL + ENTRY self.firstName_txt = tk.StringVar() self.firstName_lbl = tk.Label(self.parent, text='First Name', font=('bold')) self.firstName_lbl.place(x=20,y=10) self.firstName_entry = tk.Entry(self.parent, textvariable=self.firstName_txt) self.firstName_entry.place(x=120,y=10) ... def prereq(self): self.boo = 1 if self.firstName_txt.get() == "": msg.showwarning("Missing information", "First name info missing") boo = 0 elif self.lastName_txt.get() == "": msg.showwarning("Missing information", "Last name info missing") boo = 0 elif self.age_txt.get() == "": msg.showwarning("Missing information", "Age info missing") boo = 0 elif self.rBtnGender.get() == 0: msg.showwarning("Missing information", "Gender info missing") boo = 0 if self.boo == 1: self.fname = self.firstName_txt.get() self.lname = self.lastName_txt.get() self.age = int(self.age_txt.get()) self.selectedCourse = self.coursesLBX.get(self.coursesLBX.curselection()) if self.age < 21: msg.showwarning("Invalid Age", "Invalid Age, you are not eligible") return elif self.age >= 21: pass ### SELECTED COURSE if self.selectedCourse == "Quality Management (Adv.)": self.prereq = "The prereq for this course is Quality Management (Int)." self.flag = 1 elif self.selectedCourse == "Financial Management (Adv.)": self.prereq = "The prereq for this course is Financial Management (Bas)." self.flag= 1 elif self.selectedCourse == "Project Management (Adv.)": self.prereq = "The prereq for this course is Project Management (Int)." self.flag = 0 else: self.prereq = "The prereq for this course is Project Management (Bas)." self.flag = 0 ### PART TIME if self.chkBtnPTime.get() == 1 and self.flag == 0: self.str2 = "\nThis course is not available part time." elif self.chkBtnPTime.get() == 1 and self.flag == 1: self.str2 = "\nThis course is available part time." else: self.str2 = "" self.result = self.prereq + self.str2 msg.showinfo('Form info', self.result) def save2db(self): try: db.insert(self.fname, self.lname, self.age) msg.showinfo('DB action', "Selection inserted into db") except: msg.showinfo("Form submission failed", "Plz check ur input") ################################## all script available on github https://github.com/barpasc/python_tuto_400_oop In function save2db, I would like to know if there is any alternative to using try/except. The alternative I'm thinking is something like def save2db(self,boo): if boo == 1: do something else: do something like return to previous step... Is this possible? From grant.b.edwards at gmail.com Thu Sep 17 14:59:37 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 17 Sep 2020 18:59:37 -0000 (UTC) Subject: Puzzling difference between lists and tuples References: Message-ID: On 2020-09-17, MRAB wrote: >> The only time the parentheses are required for tuple building is when >> they would otherwise not be interpreted that way: >> > They're needed for the empty tuple, which doesn't have a comma. > >> some_func('first', 'second') # some_func called with two str args >> >> some_func(('first', 'second')) # some_func called with one tuple arg Yea, the syntax for tuple literals has always been a bit of an ugly spot in Python. If ASCII had only had one more set of open/close brackets... -- Grant From garyfallidis at gmail.com Thu Sep 17 17:23:44 2020 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Thu, 17 Sep 2020 17:23:44 -0400 Subject: ANN: DIPY 1.2.0 Message-ID: Hello all, We are excited to announce a new release of DIPY: DIPY 1.2 is out! Please support us by citing DIPY in your papers using the following DOI: 10.3389/fninf.2014.00008 DIPY 1.2.0 (Wednesday, 9 September 2020) This release received contributions from 27 developers (the full release notes are at: https://dipy.org/documentation/1.2.0./release_notes/release1.2/). Thank you all for your contributions and feedback! Please click here to check API changes. Highlights of this release include: - New command line interfaces for group analysis: BUAN. - Added b-tensor encoding for gradient table. - Better support for single shell or multi-shell response functions. - Stats module refactored. - Numpy's minimum version is 1.2.0. - Fixed compatibilities with FURY 0.6+, VTK9+, CVXPY 1.1+. - Added multiple tutorials for DIPY command line interfaces. - Updated SH basis convention. - Improved performance of tissue classification. - Fixed a memory overlap bug (multi_median). - Large documentation update (typography / references). - Closed 256 issues and merged 94 pull requests. Note: - Have in mind that DIPY does not support Python 2 after version 0.16.0. All major Python projects have switched to Python 3. It is time that you switch too. To upgrade or install DIPY Run the following command in your terminal: pip install --upgrade dipy or conda install -c conda-forge dipy This version of DIPY depends on nibabel (3.0.0+). For visualization you need FURY (0.6.1+). Questions or suggestions? For any questions go to http://dipy.org, or send an e-mail to dipy at python.org We also have an instant messaging service and chat room available at https://gitter.im/dipy/dipy On behalf of the 110 DIPY developers, Eleftherios Garyfallidis, Ariel Rokem, Serge Koudoro https://dipy.org/contributors From rosuav at gmail.com Thu Sep 17 20:55:13 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Sep 2020 10:55:13 +1000 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards wrote: > > On 2020-09-17, MRAB wrote: > >> The only time the parentheses are required for tuple building is when > >> they would otherwise not be interpreted that way: > >> > > They're needed for the empty tuple, which doesn't have a comma. > > > >> some_func('first', 'second') # some_func called with two str args > >> > >> some_func(('first', 'second')) # some_func called with one tuple arg > > Yea, the syntax for tuple literals has always been a bit of an ugly > spot in Python. If ASCII had only had one more set of open/close > brackets... ... then I'd prefer them to be used for sets, actually. I think the set/dict collision is more weird than the tuple/grouping one. Now, if only ASCII had *two* more sets of open/close brackets... ChrisA From redstone-cold at 163.com Fri Sep 18 04:07:29 2020 From: redstone-cold at 163.com (iMath) Date: Fri, 18 Sep 2020 01:07:29 -0700 (PDT) Subject: celery multi celery.exceptions.TimeoutError: The operation timed out Message-ID: I followed the official [Celery guide](https://docs.celeryproject.org/en/stable/getting-started/next-steps.html#in-the-background) to learn, everything works well when using `celery -A proj worker -l info` to start the worker, however , if I run the worker in the background using `celery multi restart w1 -A proj -l info --logfile=./celery.log`, then I got >>> from proj.tasks import add >>> add.delay().get(timeout=19) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/celery/result.py", line 230, in get return self.backend.wait_for_pending( File "/usr/local/lib/python3.8/dist-packages/celery/backends/base.py", line 660, in wait_for_pending meta = self.wait_for( File "/usr/local/lib/python3.8/dist-packages/celery/backends/base.py", line 696, in wait_for raise TimeoutError('The operation timed out.') celery.exceptions.TimeoutError: The operation timed out. >>> So what's wrong ? Test environment : - Python 3.8.2 - celery multi v4.4.7 - rabbitmqctl version ---> 3.8.2 and Project layout ([code files](https://github.com/celery/celery/files/5231502/proj.zip)): > proj/__init__.py > /celery.py > /tasks.py celery.py from __future__ import absolute_import, unicode_literals from celery import Celery app = Celery('proj', broker='amqp://localhost', # backend='db+sqlite:///results.sqlite', # The backend argument? If you don?t need results, it?s better to disable them. Results can also be disabled for individual tasks by setting the @task(ignore_result=True) option. include=['proj.tasks']) # The include argument is a list of modules to import when the worker starts. You need to add our tasks module here so that the worker is able to find our tasks. app.conf.CELERY_RESULT_BACKEND = 'db+sqlite:///results.sqlite' if __name__ == '__main__': app.start() tasks.py from __future__ import absolute_import, unicode_literals from .celery import app import datetime @app.task def add(): return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") The log info as the following , I googled , but didn't find a working solutions ``` [2020-09-15 22:10:03,229: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672// [2020-09-15 22:10:03,238: INFO/MainProcess] mingle: searching for neighbors [2020-09-15 22:10:04,260: INFO/MainProcess] mingle: all alone [2020-09-15 22:10:04,273: INFO/MainProcess] w1 at iZwz962a07bhoio77q4ewxZ ready. [2020-09-15 22:10:10,625: ERROR/MainProcess] Received unregistered task of type 'proj.tasks.add'. The message has been ignored and discarded. Did you remember to import the module containing this task? Or maybe you're using relative imports? Please see http://docs.celeryq.org/en/latest/internals/protocol.html for more information. The full contents of the message body was: '[[], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (77b) Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/celery/worker/consumer/consumer.py", line 562, in on_task_received strategy = strategies[type_] KeyError: 'proj.tasks.add' ``` From barry at barrys-emacs.org Fri Sep 18 12:15:03 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Fri, 18 Sep 2020 17:15:03 +0100 Subject: Asyncio Queue implementation suggestion In-Reply-To: References: <3081d39f-d475-6d5f-4bdf-f9c76feda5d2@tripolho.com> Message-ID: <25383923-BFD6-46E5-B14A-3F0B3E44FB7C@barrys-emacs.org> > On 17 Sep 2020, at 15:51, Dennis Lee Bieber wrote: > > On Wed, 16 Sep 2020 13:39:51 -0400, Alberto Sentieri <22t at tripolho.com> > declaimed the following: > > >> devices tested simultaneously, I soon run out of file descriptor. Well, >> I increased the number of file descriptor in the application and then I >> started running into problems like ?ValueError: filedescriptor out of >> range in select()?. I guess this problem is related to a package called > > > https://man7.org/linux/man-pages/man2/select.2.html > """ > An fd_set is a fixed size buffer. > """ > and > """ > On success, select() and pselect() return the number of file > descriptors contained in the three returned descriptor sets (that > is, > the total number of bits that are set in readfds, writefds, > exceptfds). > """ > Emphasis "number of bits that are set" -- the two together implies that > these are words/longwords/quadwords used a bitmaps, one fd per bit, and > hence inherently limited to only as many bits as the word-length supports. The limit has nothing to do with word size. The bits are passed as unsigned char arrary. Here is the piece expelling the limit: select() can monitor only file descriptors numbers that are less than FD_SETSIZE; poll(2) and epoll(7) do not have this limitation. See BUGS. FD_SETSIZE is typically 1024. Barry From grant.b.edwards at gmail.com Fri Sep 18 14:49:14 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 18 Sep 2020 18:49:14 -0000 (UTC) Subject: Puzzling difference between lists and tuples References: Message-ID: On 2020-09-18, Chris Angelico wrote: > On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards > wrote: >> >> On 2020-09-17, MRAB wrote: >> >> The only time the parentheses are required for tuple building is when >> >> they would otherwise not be interpreted that way: >> >> >> > They're needed for the empty tuple, which doesn't have a comma. >> > >> >> some_func('first', 'second') # some_func called with two str args >> >> >> >> some_func(('first', 'second')) # some_func called with one tuple arg >> >> Yea, the syntax for tuple literals has always been a bit of an ugly >> spot in Python. If ASCII had only had one more set of open/close >> brackets... > > ...then I'd prefer them to be used for sets, actually. I think the > set/dict collision is more weird than the tuple/grouping one. > > Now, if only ASCII had *two* more sets of open/close brackets... Rigth. I had forgotten about sets -- they're still a "new" feature in my mind, and I rarely seem to run into situations where I use them. There must be a few more sets of brackets in Unicode... -- Grant From ekopalypse at gmail.com Fri Sep 18 15:51:45 2020 From: ekopalypse at gmail.com (Eko palypse) Date: Fri, 18 Sep 2020 12:51:45 -0700 (PDT) Subject: importlib changes from py3.7 to py3.8 Message-ID: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> With python3.7 I'm able to use _module = importlib.import_module('app.plugins.plugin_dir.plugin_name') succesfully but with python 3.8 this results in File "D:\ProgramData\Python\Python38_64\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 779, in exec_module File "", line 916, in get_code File "", line 846, in source_to_code File "", line 219, in _call_with_frames_removed ValueError: source code string cannot contain null bytes Any idea what happened here? Thank you Eren From greg.ewing at canterbury.ac.nz Fri Sep 18 20:47:38 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 19 Sep 2020 12:47:38 +1200 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: On 19/09/20 6:49 am, Grant Edwards wrote: > There must be a few more sets of brackets in Unicode... Quite a lot, actually. The character browser in MacOSX is currently showing me 17, not including the ones that are built up from multiple characters. Some of them could be easily confused with normal brackets, but there are a few interesting ones, such as LEFT/RIGHT WHITE/BLACK LENTICULAR BRACKET and LEFT/RIGHT TORTOISE SHELL BRACKET. ? ?? ?? ? -- Greg From valjhuber at gmail.com Fri Sep 18 20:50:06 2020 From: valjhuber at gmail.com (gMail) Date: Fri, 18 Sep 2020 17:50:06 -0700 Subject: Making Python the Best App Dev Platform Message-ID: <37E72204-54F8-4229-AC9E-988E3FEFD5E5@gmail.com> Hello, All We all know Python is a wonderful environment, with fantastic packages for App Dev like Flask, SQLAlchemy and Django. Now let?s make it the only reasonable choice for building database-oriented systems. I?d like to introduce 2 new capabilities: Build a web app in 10 minutes: this generator builds basic multi-page, multi-table apps based on Flask AppBuilder and SQLAlchemy; here?s an article 40x reduction in backend code: this rules engine uses spreadsheet-like rules to automate SQLAlchemy multi-table derivation and constraint logic. The readme and samples show how 5 rules equate to 200 lines of code. The potential value is substantial: a 40X is reduction is not only helpful for our projects, but has the potential to expand our community. The second project is in-progress. If you have feedback on the general value or particular features, I?d love to hear from you. And if you?d like to help, super! Best, Val From ekopalypse at gmail.com Sat Sep 19 10:12:04 2020 From: ekopalypse at gmail.com (Eko palypse) Date: Sat, 19 Sep 2020 07:12:04 -0700 (PDT) Subject: importlib changes from py3.7 to py3.8 In-Reply-To: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> References: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> Message-ID: <46768d9c-d2c9-41e3-a6ee-e04cb3e33d84o@googlegroups.com> Seems I've missed that __init__.py's aren't allowed to be empty anymore. Adding a single # solved the issue. Eren From greg.ewing at canterbury.ac.nz Sat Sep 19 20:03:21 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 20 Sep 2020 12:03:21 +1200 Subject: importlib changes from py3.7 to py3.8 In-Reply-To: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> References: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> Message-ID: On 19/09/20 7:51 am, Eko palypse wrote: > ValueError: source code string cannot contain null bytes > > Any idea what happened here? > Seems I've missed that __init__.py's aren't allowed to be empty anymore. > Adding a single # solved the issue. I just tried importing a package with an empty __init__.py in Python 3.8 and there was no problem: % ls -l empty total 0 -rw-r--r-- 1 greg staff 0 20 Sep 12:00 __init__.py % python3 Python 3.8.2 (default, Mar 23 2020, 11:36:18) [Clang 8.1.0 (clang-802.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import empty >>> It looks more like the file in question wasn't completely empty, but had a null character in it for some reason. I expect that if you re-saved it as truly empty it would work. If not, you should probably report it as a bug. -- Greg From soyeomul at doraji.xyz Sat Sep 19 23:39:20 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Sun, 20 Sep 2020 12:39:20 +0900 Subject: Puzzling difference between lists and tuples References: Message-ID: William Pearson writes: > ... > for n in ('first'): > print n > > > ... but "f","i","r","s","t" in the second. #+BEGIN_SRC: python for n in ('first',): print n #+BEGIN_SRC Then, that will print 'first'. And please use Python3... Sincerely, Byung-Hee -- ^????? _????_ ?????_^))// From soyeomul at doraji.xyz Sat Sep 19 23:42:50 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Sun, 20 Sep 2020 12:42:50 +0900 Subject: sorry for typo (Was: Re: Puzzling difference between lists and tuples) References: Message-ID: > #+BEGIN_SRC: python > for n in ('first',): > print n > #+BEGIN_SRC The last 'BEGIN_SRC' should be 'END_SRC' so sorry ;;; -- ^????? _????_ ?????_^))// From ekopalypse at gmail.com Sun Sep 20 14:07:25 2020 From: ekopalypse at gmail.com (Eko palypse) Date: Sun, 20 Sep 2020 20:07:25 +0200 Subject: importlib changes from py3.7 to py3.8 In-Reply-To: References: <5315bd22-6f03-433b-8195-30029b802cd8o@googlegroups.com> Message-ID: Hello Greg, thank you for your answer. I have checked it twice and the file is really empty. I even opened it with a hex editor - no content. BUT in order to create a bug ticket I tried to make a mcve and I didn't succeed. I copied the function (load_plugins) 1 to 1, but outside my program it works as it should. So it seems that something inside my application is causing this problem. Hmm ... Fortunately this is a pure python application so debugging should lead to enlightenment. :-) Thx Eren Am So., 20. Sept. 2020 um 02:06 Uhr schrieb Greg Ewing < greg.ewing at canterbury.ac.nz>: > On 19/09/20 7:51 am, Eko palypse wrote: > > ValueError: source code string cannot contain null bytes > > > > Any idea what happened here? > > > Seems I've missed that __init__.py's aren't allowed to be empty anymore. > > Adding a single # solved the issue. > > I just tried importing a package with an empty __init__.py in > Python 3.8 and there was no problem: > > % ls -l empty > total 0 > -rw-r--r-- 1 greg staff 0 20 Sep 12:00 __init__.py > % python3 > Python 3.8.2 (default, Mar 23 2020, 11:36:18) > [Clang 8.1.0 (clang-802.0.42)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import empty > >>> > > It looks more like the file in question wasn't completely empty, > but had a null character in it for some reason. I expect that if > you re-saved it as truly empty it would work. If not, you should > probably report it as a bug. > > -- > Greg > -- > https://mail.python.org/mailman/listinfo/python-list > From avigross at verizon.net Sun Sep 20 18:59:15 2020 From: avigross at verizon.net (Avi Gross) Date: Sun, 20 Sep 2020 18:59:15 -0400 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: <016401d68fa1$aa440760$fecc1620$@verizon.net> There is a simple and obvious way to make sure you have a tuple by invoking the keyword/function in making it: >>> a=('first') >>> type(a) >>> a=("first",) >>> type(a) >>> a=tuple("first") >>> type(a) That seems more explicit than adding a trailing comma. It also is a simple way to make an empty tuple but is there any penalty for using the function tuple()? -----Original Message----- From: Python-list On Behalf Of "???" Sent: Saturday, September 19, 2020 11:39 PM To: python-list at python.org Subject: Re: Puzzling difference between lists and tuples William Pearson writes: > ... > for n in ('first'): > print n > > > ... but "f","i","r","s","t" in the second. #+BEGIN_SRC: python for n in ('first',): print n #+BEGIN_SRC Then, that will print 'first'. And please use Python3... Sincerely, Byung-Hee -- ^????? _????_ ?????_^))// -- https://mail.python.org/mailman/listinfo/python-list From python at mrabarnett.plus.com Sun Sep 20 19:34:38 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 21 Sep 2020 00:34:38 +0100 Subject: Puzzling difference between lists and tuples In-Reply-To: <016401d68fa1$aa440760$fecc1620$@verizon.net> References: <016401d68fa1$aa440760$fecc1620$@verizon.net> Message-ID: On 2020-09-20 23:59, Avi Gross via Python-list wrote: > There is a simple and obvious way to make sure you have a tuple by invoking the keyword/function in making it: > >>>> a=('first') >>>> type(a) > > >>>> a=("first",) >>>> type(a) > > >>>> a=tuple("first") >>>> type(a) > > > That seems more explicit than adding a trailing comma. It also is a simple way to make an empty tuple but is there any penalty for using the function tuple()? > [snip] >>> tuple("first") ('f', 'i', 'r', 's', 't') Not the same as ("first",). A simpler way to make an empty tuple is just (). From greg.ewing at canterbury.ac.nz Sun Sep 20 19:57:20 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 21 Sep 2020 11:57:20 +1200 Subject: Puzzling difference between lists and tuples In-Reply-To: References: <016401d68fa1$aa440760$fecc1620$@verizon.net> Message-ID: On 21/09/20 10:59 am, Avi Gross wrote: >>>> a=tuple("first") >>>> type(a) > > > That seems more explicit than adding a trailing comma. It doesn't do what you want, though: >>> a = tuple("first") >>> print(a) ('f', 'i', 'r', 's', 't') If you really want to use tuple() to create a 1-tuple without using a trailing comma, you can do it this way: >>> a = tuple(["first"]) >>> print(a) ('first',) But this costs you both a list creation and a tuple() call. On my machine it seems to be about 17 times slower than using a trailing comma: >>> timeit.repeat("tuple(['first'])") [0.17746889099998953, 0.17687880599999062, 0.17687711000002082, 0.1767632840000033, 0.17684489200001963] >>> timeit.repeat("('first',)") [0.01173928899999055, 0.011569334000000708, 0.011588000000017473, 0.011569761000032486, 0.011579383999958281] -- Greg From avigross at verizon.net Sun Sep 20 20:33:39 2020 From: avigross at verizon.net (Avi Gross) Date: Sun, 20 Sep 2020 20:33:39 -0400 Subject: Puzzling difference between lists and tuples In-Reply-To: References: <016401d68fa1$aa440760$fecc1620$@verizon.net> Message-ID: <02e901d68fae$da4cdc40$8ee694c0$@verizon.net> ('M','R','A','B') is correct. I appreciate the correction. I did not look to see the content of what I created, just the type! >>> a = tuple("first") >>> a ('f', 'i', 'r', 's', 't') >>> type(a) But I thought adding a comma would help and it does not! >>> b = tuple("first",) >>> b ('f', 'i', 'r', 's', 't') Yet something this simple without invoking tuple(), works! >>> c = 'first', >>> c ('first',) So I read the manual page and tuple takes an iterable as an argument and treats a string as an iterator on characters! It is not a simple initializer. I got around it, sort of, using n array with a single object of type string in it so the iterator is iterating at a different level. >>> d = ["first"] >>> tuple(d) ('first',) >>> tuple(["first"]) ('first',) I understand the design choice and can imagine there may be another function that initializes a tuple more directly in some module. Returning to lurking mode ... -----Original Message----- From: Python-list On Behalf Of MRAB Sent: Sunday, September 20, 2020 7:35 PM To: python-list at python.org Subject: Re: Puzzling difference between lists and tuples On 2020-09-20 23:59, Avi Gross via Python-list wrote: > There is a simple and obvious way to make sure you have a tuple by invoking the keyword/function in making it: > >>>> a=('first') >>>> type(a) > > >>>> a=("first",) >>>> type(a) > > >>>> a=tuple("first") >>>> type(a) > > > That seems more explicit than adding a trailing comma. It also is a simple way to make an empty tuple but is there any penalty for using the function tuple()? > [snip] >>> tuple("first") ('f', 'i', 'r', 's', 't') Not the same as ("first",). A simpler way to make an empty tuple is just (). -- https://mail.python.org/mailman/listinfo/python-list From cs at cskk.id.au Sun Sep 20 21:34:55 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 21 Sep 2020 11:34:55 +1000 Subject: Puzzling difference between lists and tuples In-Reply-To: <02e901d68fae$da4cdc40$8ee694c0$@verizon.net> References: <02e901d68fae$da4cdc40$8ee694c0$@verizon.net> Message-ID: <20200921013455.GA37982@cskk.homeip.net> On 20Sep2020 20:33, Avi Gross wrote: >('M','R','A','B') is correct. I appreciate the correction. I did not look to >see the content of what I created, just the type! > >>>> a = tuple("first") >>>> a >('f', 'i', 'r', 's', 't') >>>> type(a) > > >But I thought adding a comma would help and it does not! Ah, the comma is for an expression. But you made a function call (well, "tuple" is a type and types are callable to make instances). In a function call the parmeter separating commas have higher precedence than the commas with defines a tuple, you you've made a function call with one argument "first", not a function call with one _tuple_ argument ("first",). Consider: foo(1, 2) That supplies 2 arguments, not a single tuple. As with other situations where the default precedence groups things in a different way from your intent, brackets get required here if you want to express a tuple. This: foo( (1,2) ) isn't notionally different from needing brakcets to express this: (3+5) * 8 which means something else without its brackets. Also, function calls allow you to include a trailing comma because it helps with code. Consider the following bigger call: x = foo( 1, 2, fred=5, ) laid out on separate lines for readability (a little redundant here, but some complex function calls, or those exceeding the deired line length, are often folded this way). Bu allowing a trailing comma we get consistent formatting and nicer diffs. If a trailing comma were forbidden, the dopping "fred=5" with produce a diff removing not just that line but also the comma on the preceeding line. Ugly and noisy. Cheers, Cameron Simpson From redstone-cold at 163.com Mon Sep 21 06:14:40 2020 From: redstone-cold at 163.com (iMath) Date: Mon, 21 Sep 2020 03:14:40 -0700 (PDT) Subject: celery multi celery.exceptions.TimeoutError: The operation timed out Message-ID: <03d43fd7-6d2f-46e4-8f10-3ab9d8b940d1n@googlegroups.com> Asked 3 days ago at https://stackoverflow.com/questions/63951696/celery-multi-celery-exceptions-timeouterror-the-operation-timed-out But nobody helped yet, anyone ? From macrakis at alum.mit.edu Sun Sep 20 18:34:52 2020 From: macrakis at alum.mit.edu (Stavros Macrakis) Date: Sun, 20 Sep 2020 18:34:52 -0400 Subject: Pythonic style Message-ID: I'm trying to improve my Python style. Consider a simple function which returns the first element of an iterable if it has exactly one element, and throws an exception otherwise. It should work even if the iterable doesn't terminate. I've written this function in multiple ways, all of which feel a bit clumsy. I'd be interested to hear thoughts on which of these solutions is most Pythonic in style. And of course if there is a more elegant way to solve this, I'm all ears! I'm probably missing something obvious! Thanks, -s def firsta(iterable): it = iter(iterable) try: val = next(it) except StopIteration: raise ValueError("first1: arg not exactly 1 long") try: next(it) except StopIteration: return val raise ValueError("first1: arg not exactly 1 long") def firstb(iterable): it = iter(iterable) try: val = next(it) except StopIteration: raise ValueError("first1: arg not exactly 1 long") try: next(it) except StopIteration: return val else: raise ValueError("first1: arg not exactly 1 long") def firstc(iterable): it = iter(iterable) try: val = next(it) except StopIteration: raise ValueError("first1: arg not exactly 1 long") try: next(it) raise ValueError("first1: arg not exactly 1 long") except StopIteration: return val def firstd(iterable): it = iter(iterable) try: val = next(it) except StopIteration: raise ValueError("first1: arg not exactly 1 long") for i in it: raise ValueError("first1: arg not exactly 1 long") return val def firste(iterable): it = iter(iterable) try: good = False val = next(it) good = True val = next(it) good = False raise StopIteration # or raise ValueError except StopIteration: if good: return val else: raise ValueError("first1: arg not exactly 1 long") def firstf(iterable): n = -1 for n,i in enumerate(iterable): if n>0: raise ValueError("first1: arg not exactly 1 long") if n==0: return i else: raise ValueError("first1: arg not exactly 1 long") From brenners at bezeqint.net Mon Sep 21 06:27:00 2020 From: brenners at bezeqint.net (Hylton) Date: Mon, 21 Sep 2020 13:27:00 +0300 Subject: Issues with pip in Python 3.8.3 In-Reply-To: References: Message-ID: Hello, ? I have subscribed to the Python list. The user name (which was optional) I entered as hsb3852, not my real name. Does this matter? ? My question is below? ? Best regards, Hylton ? From: Hylton Sent: Monday, September 21, 2020 6:41 AM To: python-list at python.org Subject: Issues with pip in Python 3.8.3 ? Hello, ? I?m quite new to Python (but not new to programming), and I?ve encountered problems with pip which I have been unable to solve. ? When I tried to update pip using ?python.exe -m pip install --upgrade pip? (I tried to install another package -unsuccessfully, which informed me there was a new version of pip), which failed with the following error: ? ERROR: Exception: Traceback (most recent call last): ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\cli\base_command.py", line 216, in _main ? ? ? status = self.run(options, args) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper ? ? ? return func(self, options, args) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 412, in run ? ? ? installed = install_given_reqs( ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\__init__.py", line 82, in install_given_reqs ? ? ? requirement.install( ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\req_install.py", line 813, in install ? ? ? install_wheel( ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\operations\install\wheel.py", line 852, in install_wheel ? ? ? _install_wheel( ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\operations\install\wheel.py", line 762, in _install_wheel ? ? ? generated_console_scripts = maker.make_multiple(scripts_to_generate) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 418, in make_multiple ? ? ?filenames.extend(self.make(specification, options)) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_internal\operations\install\wheel.py", line 498, in make ? ? ? return super(PipScriptMaker, self).make(specification, options) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 407, in make ? ? ? self._make_script(entry, filenames, options=options) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 307, in _make_script ? ? ? self._write_script(scriptnames, shebang, script, filenames, ext) ? File "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 242, in _write_script ? ? ? launcher = self._get_launcher('t') ? 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. ? C:\Program Files\Python38> ? I checked that the file t64.exe does exist in the location (path) listed (C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts). This path is included in the PATH environment variable. ? Why is this upgrade failing? How do I fix it? ? I get this same error when I try to install other packages too. ? The package I tried to install was numPy. ? I also need to install cv2 and OpenCV, but my searches for them in PyPA returned dozens, if not hundreds of results. Can you perhaps indicate which versions I need to install on my Windows 10 PC? ? Please help as soon as possible by return email. ? Many thanks! Hylton ? ? ? From mennoholscher at gmail.com Mon Sep 21 07:59:41 2020 From: mennoholscher at gmail.com (Menno Holscher) Date: Mon, 21 Sep 2020 13:59:41 +0200 Subject: celery multi celery.exceptions.TimeoutError: The operation timed out In-Reply-To: <03d43fd7-6d2f-46e4-8f10-3ab9d8b940d1n@googlegroups.com> References: <03d43fd7-6d2f-46e4-8f10-3ab9d8b940d1n@googlegroups.com> Message-ID: Op 21-09-2020 om 12:14 schreef iMath: > Asked 3 days ago at https://stackoverflow.com/questions/63951696/celery-multi-celery-exceptions-timeouterror-the-operation-timed-out > > But nobody helped yet, anyone ? > Did you see https://stackoverflow.com/questions/9769496/celery-received-unregistered-task-of-type-run-example ? The error says "Received unregistered task of type 'proj.tasks.add'", so it looks very much like your registry is not correct/complete. Vriendelijke groeten/Kind regards, Menno H?lscher From storchaka at gmail.com Sun Sep 20 14:01:04 2020 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sun, 20 Sep 2020 21:01:04 +0300 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: 18.09.20 03:55, Chris Angelico ????: > On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards > wrote: >> Yea, the syntax for tuple literals has always been a bit of an ugly >> spot in Python. If ASCII had only had one more set of open/close >> brackets... > > ... then I'd prefer them to be used for sets, actually. I think the > set/dict collision is more weird than the tuple/grouping one. > > Now, if only ASCII had *two* more sets of open/close brackets... Then I would use them for sets and frozensets. From rosuav at gmail.com Mon Sep 21 08:20:33 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Sep 2020 22:20:33 +1000 Subject: Puzzling difference between lists and tuples In-Reply-To: References: Message-ID: On Mon, Sep 21, 2020 at 10:14 PM Serhiy Storchaka wrote: > > 18.09.20 03:55, Chris Angelico ????: > > On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards > > wrote: > >> Yea, the syntax for tuple literals has always been a bit of an ugly > >> spot in Python. If ASCII had only had one more set of open/close > >> brackets... > > > > ... then I'd prefer them to be used for sets, actually. I think the > > set/dict collision is more weird than the tuple/grouping one. > > > > Now, if only ASCII had *two* more sets of open/close brackets... > > Then I would use them for sets and frozensets. > Ahem. AMONG the needs for additional types of brackets are such diverse types as......... ChrisA From leo at superlel.me Mon Sep 21 08:58:03 2020 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Mon, 21 Sep 2020 14:58:03 +0200 Subject: Pythonic style In-Reply-To: References: Message-ID: On 21/09/2020 00:34, Stavros Macrakis wrote: > I'm trying to improve my Python style. > > Consider a simple function which returns the first element of an iterable > if it has exactly one element, and throws an exception otherwise. It should > work even if the iterable doesn't terminate. I've written this function in > multiple ways, all of which feel a bit clumsy. > > I'd be interested to hear thoughts on which of these solutions is most > Pythonic in style. And of course if there is a more elegant way to solve > this, I'm all ears! I'm probably missing something obvious! Hello Stavros, As there is no formal definition nor consensus on what is Pythonic and what isn't, this reply will be very subjective. My opinion on your code suggestions is the following: > 1 def firstf(iterable): > 2 n = -1 > 3 for n,i in enumerate(iterable): > 4 if n>0: > 5 raise ValueError("first1: arg not exactly 1 long") > 6 if n==0: > 7 return i > 8 else: > 9 raise ValueError("first1: arg not exactly 1 long") firstf isn't Pythonic: 1. We are checking twice for the same thing at line 4 (n>0) and 6 (n==0). 2. We are using enumarate(), from which we ignore the second element it yields in its tuple > 1 def firstd(iterable): > 2 it = iter(iterable) > 3 try: > 4 val = next(it) > 5 except StopIteration: > 6 raise ValueError("first1: arg not exactly 1 long") > 7 for i in it: > 8 raise ValueError("first1: arg not exactly 1 long") > 9 return val firstd isn't Pythonic. While the usage of a for statement in place of a try..except saves two lines, it is at the expense of showing a clear intent: When I see a for statement, I expect a "complex" operation on the iterable items (which we are ignoring here). > 1 def firsta(iterable): > 2 it = iter(iterable) > 3 try: > 4 val = next(it) > 5 except StopIteration: > 6 raise ValueError("first1: arg not exactly 1 long") > 7 try: > 8 next(it) > 9 except StopIteration: > 10 return val > 11 raise ValueError("first1: arg not exactly 1 long") > 1 def firstb(iterable): > 2 it = iter(iterable) > 3 try: > 4 val = next(it) > 5 except StopIteration: > 6 raise ValueError("first1: arg not exactly 1 long") > 7 try: > 8 next(it) > 9 except StopIteration: > 10 return val > 11 else: > 12 raise ValueError("first1: arg not exactly 1 long") > 1 def firstc(iterable): > 2 it = iter(iterable) > 3 try: > 4 val = next(it) > 5 except StopIteration: > 6 raise ValueError("first1: arg not exactly 1 long") > 7 try: > 8 next(it) > 9 raise ValueError("first1: arg not exactly 1 long") > 10 except StopIteration: > 11 return val firsta, firstb and firstc are equally Pythonic. I have a preference for firsta, which is more concise and have a better "reading flow". > 1 def firste(iterable): > 2 it = iter(iterable) > 3 try: > 4 good = False > 5 val = next(it) > 6 good = True > 7 val = next(it) > 8 good = False > 9 raise StopIteration # or raise ValueError > 10 except StopIteration: > 11 if good: > 12 return val > 13 else: > 14 raise ValueError("first1: arg not exactly 1 long") firste might be Pythonic although it's very "C-ish". I can grasp the intent and there is no repetition. I wouldn't write the assignation at line 7, though. Mixing firsta and firste would make something more Pythonic: def firstg(iterable): it = iter(iterable) try: val = next(it) try: next(it) except StopIteration: return val except StopIteration: pass raise ValueError("first: arg not exactly 1 long") 1. The code isn't repetitive (The "raise ValueError" is written only once) 2. The intent is a bit harder to grasp than for firsta or firste, but the code is shorter than firste 3. The try..catch nesting is considered a bad practice, but the code here is simple enough so it shouldn't trigger a strong aversion reading it - L?o From python.list at tim.thechases.com Mon Sep 21 09:15:00 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Sep 2020 08:15:00 -0500 Subject: Pythonic style In-Reply-To: References: Message-ID: <20200921081500.67459196@bigbox.attlocal.net> On 2020-09-20 18:34, Stavros Macrakis wrote: > Consider a simple function which returns the first element of an > iterable if it has exactly one element, and throws an exception > otherwise. It should work even if the iterable doesn't terminate. > I've written this function in multiple ways, all of which feel a > bit clumsy. > > I'd be interested to hear thoughts on which of these solutions is > most Pythonic in style. And of course if there is a more elegant > way to solve this, I'm all ears! I'm probably missing something > obvious! You can use tuple unpacking assignment and Python will take care of the rest for you: >>> x, = tuple() # no elements Traceback (most recent call last): File "", line 1, in ValueError: not enough values to unpack (expected 1, got 0) >>> x, = (1, ) # one element >>> x, = itertools.repeat("hello") # 2 to infinite elements Traceback (most recent call last): File "", line 1, in ValueError: too many values to unpack (expected 1) so you can do def fn(iterable): x, = iterable return x The trailing comma can be hard to spot, so I usually draw a little extra attention to it with either (x, ) = iterable or x, = iterable # unpack one value I'm not sure it qualifies as Pythonic, but it uses Pythonic features like tuple unpacking and the code is a lot more concise. -tim From rosuav at gmail.com Mon Sep 21 09:46:21 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Sep 2020 23:46:21 +1000 Subject: Pythonic style In-Reply-To: <20200921081500.67459196@bigbox.attlocal.net> References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: On Mon, Sep 21, 2020 at 11:37 PM Tim Chase wrote: > > On 2020-09-20 18:34, Stavros Macrakis wrote: > > Consider a simple function which returns the first element of an > > iterable if it has exactly one element, and throws an exception > > otherwise. It should work even if the iterable doesn't terminate. > > I've written this function in multiple ways, all of which feel a > > bit clumsy. > > > > I'd be interested to hear thoughts on which of these solutions is > > most Pythonic in style. And of course if there is a more elegant > > way to solve this, I'm all ears! I'm probably missing something > > obvious! > > You can use tuple unpacking assignment and Python will take care of > the rest for you: > > >>> x, = tuple() # no elements > Traceback (most recent call last): > File "", line 1, in > ValueError: not enough values to unpack (expected 1, got 0) > >>> x, = (1, ) # one element > >>> x, = itertools.repeat("hello") # 2 to infinite elements > Traceback (most recent call last): > File "", line 1, in > ValueError: too many values to unpack (expected 1) > > so you can do > > def fn(iterable): > x, = iterable > return x > > The trailing comma can be hard to spot, so I usually draw a little > extra attention to it with either > > (x, ) = iterable > > or > > x, = iterable # unpack one value > > I'm not sure it qualifies as Pythonic, but it uses Pythonic features > like tuple unpacking and the code is a lot more concise. Or: [x] = iterable I'd definitely recommend using unpacking as the most obvious way to do this. Among other advantages, it gives different messages for the "too many" and "too few" cases. ChrisA From leo at superlel.me Mon Sep 21 09:46:39 2020 From: leo at superlel.me (=?UTF-8?Q?L=c3=a9o_El_Amri?=) Date: Mon, 21 Sep 2020 15:46:39 +0200 Subject: Pythonic style In-Reply-To: <20200921081500.67459196@bigbox.attlocal.net> References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: On 21/09/2020 15:15, Tim Chase wrote: > You can use tuple unpacking assignment and Python will take care of > the rest for you: > > so you can do > > def fn(iterable): > x, = iterable > return x > > I'm not sure it qualifies as Pythonic, but it uses Pythonic features > like tuple unpacking and the code is a lot more concise. I guess you just beat the topic. I think it is Pythonic and I'd be surprised if someone came with something more Pythonic. FI: The behavior of this assignation is detailed here: https://docs.python.org/3/reference/simple_stmts.html#assignment-statements From python.list at tim.thechases.com Mon Sep 21 10:12:53 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Sep 2020 09:12:53 -0500 Subject: Pythonic style In-Reply-To: References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: <20200921091253.2d49cf36@bigbox.attlocal.net> On 2020-09-21 09:48, Stavros Macrakis wrote: >> def fn(iterable): >> x, = iterable >> return x > > Thanks, Tim! I didn't realize that you could write (x,) on the LHS! > Very nice, very Pythonic! It also expands nicely for other cases, so you want the 3-and-only-3 first values with errors for too many or too few? x, y, z = iterable x, y, z = (1, 2, 3) The (x,) version is just the single case. And it's fast?a single Python UNPACK_SEQUENCE opcode >>> dis.dis(fn) 2 0 LOAD_FAST 0 (i) 2 UNPACK_SEQUENCE 1 4 STORE_FAST 1 (x) 3 6 LOAD_FAST 1 (x) 8 RETURN_VALUE Though now I'm wondering if there's a way to skip the STORE_FAST/LOAD_FAST instructions and create a function that generates the opcode sequence UNPACK_SEQUENCE 1 RETURN_VALUE :-) (totally tangential ramblings) -tkc From frank at chagford.com Mon Sep 21 10:44:19 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 21 Sep 2020 16:44:19 +0200 Subject: Pythonic style In-Reply-To: References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: On 2020-09-21 3:46 PM, Chris Angelico wrote: > On Mon, Sep 21, 2020 at 11:37 PM Tim Chase > wrote: >> >> On 2020-09-20 18:34, Stavros Macrakis wrote: >>> Consider a simple function which returns the first element of an >>> iterable if it has exactly one element, and throws an exception >>> otherwise. It should work even if the iterable doesn't terminate. >>> I've written this function in multiple ways, all of which feel a >>> bit clumsy. >>> >>> I'd be interested to hear thoughts on which of these solutions is >>> most Pythonic in style. And of course if there is a more elegant >>> way to solve this, I'm all ears! I'm probably missing something >>> obvious! >> >> You can use tuple unpacking assignment and Python will take care of >> the rest for you: >> >> >>> x, = tuple() # no elements >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: not enough values to unpack (expected 1, got 0) >> >>> x, = (1, ) # one element >> >>> x, = itertools.repeat("hello") # 2 to infinite elements >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: too many values to unpack (expected 1) >> >> so you can do >> >> def fn(iterable): >> x, = iterable >> return x >> >> The trailing comma can be hard to spot, so I usually draw a little >> extra attention to it with either >> >> (x, ) = iterable >> >> or >> >> x, = iterable # unpack one value >> >> I'm not sure it qualifies as Pythonic, but it uses Pythonic features >> like tuple unpacking and the code is a lot more concise. > > Or: > > [x] = iterable > > I'd definitely recommend using unpacking as the most obvious way to do > this. Among other advantages, it gives different messages for the "too > many" and "too few" cases. > I used something similar years ago, but I made the mistake of relying on the error message in my logic, to distinguish between 'too few' and 'too many'. Guess what happened - Python changed the wording of the messages, and my logic failed. After messing about with some alternatives, I ended up with the OP's first option (with some added comments), and have stuck with it ever since. It is not pretty, but it is readable and unambiguous. Frank Millman From frank at chagford.com Mon Sep 21 10:44:19 2020 From: frank at chagford.com (Frank Millman) Date: Mon, 21 Sep 2020 16:44:19 +0200 Subject: Pythonic style In-Reply-To: References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: On 2020-09-21 3:46 PM, Chris Angelico wrote: > On Mon, Sep 21, 2020 at 11:37 PM Tim Chase > wrote: >> >> On 2020-09-20 18:34, Stavros Macrakis wrote: >>> Consider a simple function which returns the first element of an >>> iterable if it has exactly one element, and throws an exception >>> otherwise. It should work even if the iterable doesn't terminate. >>> I've written this function in multiple ways, all of which feel a >>> bit clumsy. >>> >>> I'd be interested to hear thoughts on which of these solutions is >>> most Pythonic in style. And of course if there is a more elegant >>> way to solve this, I'm all ears! I'm probably missing something >>> obvious! >> >> You can use tuple unpacking assignment and Python will take care of >> the rest for you: >> >> >>> x, = tuple() # no elements >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: not enough values to unpack (expected 1, got 0) >> >>> x, = (1, ) # one element >> >>> x, = itertools.repeat("hello") # 2 to infinite elements >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: too many values to unpack (expected 1) >> >> so you can do >> >> def fn(iterable): >> x, = iterable >> return x >> >> The trailing comma can be hard to spot, so I usually draw a little >> extra attention to it with either >> >> (x, ) = iterable >> >> or >> >> x, = iterable # unpack one value >> >> I'm not sure it qualifies as Pythonic, but it uses Pythonic features >> like tuple unpacking and the code is a lot more concise. > > Or: > > [x] = iterable > > I'd definitely recommend using unpacking as the most obvious way to do > this. Among other advantages, it gives different messages for the "too > many" and "too few" cases. > I used something similar years ago, but I made the mistake of relying on the error message in my logic, to distinguish between 'too few' and 'too many'. Guess what happened - Python changed the wording of the messages, and my logic failed. After messing about with some alternatives, I ended up with the OP's first option (with some added comments), and have stuck with it ever since. It is not pretty, but it is readable and unambiguous. Frank Millman From tjreedy at udel.edu Mon Sep 21 09:39:15 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Sep 2020 09:39:15 -0400 Subject: Pythonic style In-Reply-To: References: Message-ID: On 9/20/2020 6:34 PM, Stavros Macrakis wrote: > I'm trying to improve my Python style. > > Consider a simple function which returns the first element of an iterable > if it has exactly one element, and throws an exception otherwise. It should > work even if the iterable doesn't terminate. I've written this function in > multiple ways, all of which feel a bit clumsy. The 'obvious' thing to me was the double try-except StopIteration. It is clear, and clarity is 'pythonic'. -- Terry Jan Reedy From bonfacemunyoki at gmail.com Mon Sep 21 13:00:13 2020 From: bonfacemunyoki at gmail.com (Bonface M. K.) Date: Mon, 21 Sep 2020 20:00:13 +0300 Subject: Making Python the Best App Dev Platform In-Reply-To: <37E72204-54F8-4229-AC9E-988E3FEFD5E5@gmail.com> (gMail's message of "Fri, 18 Sep 2020 17:50:06 -0700") References: <37E72204-54F8-4229-AC9E-988E3FEFD5E5@gmail.com> Message-ID: <86mu1javwp.fsf@gmail.com> Hi! gMail writes: > Hello, All > > We all know Python is a wonderful environment, > with fantastic packages for App Dev like Flask, > SQLAlchemy and Django. Now let?s make it the only > reasonable choice for building database-oriented > systems. > > I?d like to introduce 2 new capabilities: > > Build a web app in 10 minutes: this generator > > builds basic multi-page, multi-table apps based on > Flask AppBuilder and SQLAlchemy; here?s an article > > > 40x reduction in backend code: this rules engine > uses > spreadsheet-like rules to automate SQLAlchemy > multi-table derivation and constraint logic. The > readme and samples show how 5 rules equate to 200 > lines of code. > > The potential value is substantial: a 40X is > reduction is not only helpful for our projects, > but has the potential to expand our community. > > The second project is in-progress. If you have > feedback on the general value or particular > features, I?d love to hear from you. And if you?d > like to help, super! > > Best, > Val Also, just a suggestion: how about a way to bootstrap tests. I haven't really seen that on theGH link shared above. -- Bonface M. K. (https://www.bonfacemunyoki.com) Chief Emacs Mchochezi / Twitter: @BonfaceKilz GPG key = D4F09EB110177E03C28E2FE1F5BBAE1E0392253F -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 869 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 869 bytes Desc: not available URL: From bonfacemunyoki at gmail.com Mon Sep 21 13:35:47 2020 From: bonfacemunyoki at gmail.com (Bonface M. K.) Date: Mon, 21 Sep 2020 20:35:47 +0300 Subject: Making Python the Best App Dev Platform In-Reply-To: <3752B635-8398-4B9D-8676-2C755A92E3C5@gmail.com> (gMail's message of "Mon, 21 Sep 2020 10:17:48 -0700") References: <37E72204-54F8-4229-AC9E-988E3FEFD5E5@gmail.com> <86wo0nawv6.fsf@gmail.com> <3752B635-8398-4B9D-8676-2C755A92E3C5@gmail.com> Message-ID: <86imc7av7w.fsf@gmail.com> [[Cc'ing the python list for other people to give useful feedback if they can]] gMail writes: > Hi! > > Loved your no-place-like-home joke. > Thanks! > Wanted to better understand your question / comment about testing. > From my understanding of what the project does(I haven't really had a deep dive in it- I've merely skimmed it), it does a lot of bootstrapping for you. It would be nice to have unittests(defaulting to python's unittests would be great). And a way of running said tests. > In general, rules don?t affect testing, you just run tests as usual and check the results. This usually > consists of reading the ?before? data, running the test (an update transaction), and then comparing ?after? > with ?before?. In the past, I wrote a JsonDiff that helped with the comparison. > This sounds like manual testing(?). I've grown to being keen on testing(though I try not to be a zealot about it). You'd be surprised(IMO) at how many people don't know how to write tests, usually not because they don't want to; but because they don't know /how to/. > What did you have in mind? > That being said, it would be nice to see your project have that-- doing bootstrapping for tests for you; and having somewhere that mentions how to run them. I'll try to have a look at it over the weekend? That's seems like something I'd use- though it'd have to be more generic. > Best, > Val > > On Sep 21, 2020, at 10:00 AM, Bonface M. K. wrote: > > Hi! > > gMail writes: > > Hello, All > > We all know Python is a wonderful environment, > with fantastic packages for App Dev like Flask, > SQLAlchemy and Django. Now let?s make it the only > reasonable choice for building database-oriented > systems. > > I?d like to introduce 2 new capabilities: > > Build a web app in 10 minutes: this generator > > builds basic multi-page, multi-table apps based on > Flask AppBuilder and SQLAlchemy; here?s an article > > > 40x reduction in backend code: this rules engine > uses > spreadsheet-like rules to automate SQLAlchemy > multi-table derivation and constraint logic. The > readme and samples show how 5 rules equate to 200 > lines of code. > > The potential value is substantial: a 40X is > reduction is not only helpful for our projects, > but has the potential to expand our community. > > The second project is in-progress. If you have > feedback on the general value or particular > features, I?d love to hear from you. And if you?d > like to help, super! > > Best, > Val > > Also, just a suggestion: how about a way to > bootstrap tests. I haven't really seen that on > theGH link shared above. > > -- > Bonface M. K. (https://www.bonfacemunyoki.com) > Chief Emacs Mchochezi / Twitter: @BonfaceKilz > GPG key = D4F09EB110177E03C28E2FE1F5BBAE1E0392253F -- Bonface M. K. (https://www.bonfacemunyoki.com) Chief Emacs Mchochezi / Twitter: @BonfaceKilz GPG key = D4F09EB110177E03C28E2FE1F5BBAE1E0392253F -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 869 bytes Desc: not available URL: From macrakis at alum.mit.edu Mon Sep 21 09:48:15 2020 From: macrakis at alum.mit.edu (Stavros Macrakis) Date: Mon, 21 Sep 2020 09:48:15 -0400 Subject: Pythonic style In-Reply-To: <20200921081500.67459196@bigbox.attlocal.net> References: <20200921081500.67459196@bigbox.attlocal.net> Message-ID: Thanks, Tim! I didn't realize that you could write (x,) on the LHS! Very nice, very Pythonic! -s On Mon, Sep 21, 2020 at 9:15 AM Tim Chase wrote: > On 2020-09-20 18:34, Stavros Macrakis wrote: > > Consider a simple function which returns the first element of an > > iterable if it has exactly one element, and throws an exception > > otherwise. It should work even if the iterable doesn't terminate. > > I've written this function in multiple ways, all of which feel a > > bit clumsy. > > > > I'd be interested to hear thoughts on which of these solutions is > > most Pythonic in style. And of course if there is a more elegant > > way to solve this, I'm all ears! I'm probably missing something > > obvious! > > You can use tuple unpacking assignment and Python will take care of > the rest for you: > > >>> x, = tuple() # no elements > Traceback (most recent call last): > File "", line 1, in > ValueError: not enough values to unpack (expected 1, got 0) > >>> x, = (1, ) # one element > >>> x, = itertools.repeat("hello") # 2 to infinite elements > Traceback (most recent call last): > File "", line 1, in > ValueError: too many values to unpack (expected 1) > > so you can do > > def fn(iterable): > x, = iterable > return x > > The trailing comma can be hard to spot, so I usually draw a little > extra attention to it with either > > (x, ) = iterable > > or > > x, = iterable # unpack one value > > I'm not sure it qualifies as Pythonic, but it uses Pythonic features > like tuple unpacking and the code is a lot more concise. > > -tim > > > > > > From python at hope.cz Tue Sep 22 03:01:46 2020 From: python at hope.cz (Johny) Date: Tue, 22 Sep 2020 00:01:46 -0700 (PDT) Subject: PyOBEX installation problem Message-ID: I tried to install PyOBEX see the log below C:\Users\expor\Downloads\OBEX>setup.py install running install running bdist_egg running egg_info writing PyOBEX.egg-info\PKG-INFO writing top-level names to PyOBEX.egg-info\top_level.txt writing dependency_links to PyOBEX.egg-info\dependency_links.txt reading manifest file 'PyOBEX.egg-info\SOURCES.txt' writing manifest file 'PyOBEX.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build creating build\lib creating build\lib\PyOBEX copying PyOBEX\client.py -> build\lib\PyOBEX copying PyOBEX\common.py -> build\lib\PyOBEX copying PyOBEX\headers.py -> build\lib\PyOBEX copying PyOBEX\requests.py -> build\lib\PyOBEX copying PyOBEX\responses.py -> build\lib\PyOBEX copying PyOBEX\server.py -> build\lib\PyOBEX copying PyOBEX\__init__.py -> build\lib\PyOBEX creating build\bdist.win-amd64 creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\client.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\common.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\headers.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\requests.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\responses.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\server.py -> build\bdist.win-amd64\egg\PyOBEX copying build\lib\PyOBEX\__init__.py -> build\bdist.win-amd64\egg\PyOBEX byte-compiling build\bdist.win-amd64\egg\PyOBEX\client.py to client.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\common.py to common.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\headers.py to headers.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\requests.py to requests.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\responses.py to responses.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\server.py to server.pyc byte-compiling build\bdist.win-amd64\egg\PyOBEX\__init__.py to __init__.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying PyOBEX.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying PyOBEX.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying PyOBEX.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying PyOBEX.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO zip_safe flag not set; analyzing archive contents... creating dist creating 'dist\PyOBEX-0.29-py2.7.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing PyOBEX-0.29-py2.7.egg Copying PyOBEX-0.29-py2.7.egg to c:\python27\lib\site-packages Adding PyOBEX 0.29 to easy-install.pth file but still I can not use it. See >>> from PyOBEX.client import BrowserClient Traceback (most recent call last): File "", line 1, in ImportError: No module named PyOBEX.client >>> Where can be a problem? Thank you for help From agnese.camellini at gmail.com Tue Sep 22 05:13:50 2020 From: agnese.camellini at gmail.com (Agnese Camellini) Date: Tue, 22 Sep 2020 11:13:50 +0200 Subject: Question from a "java background" developer Message-ID: Hello to everyone, I have a question. I come from a Java background and I would like to develop in python but i'm wondering: is there anything, in python, like Java "reflection"? I mean do i have a keyword to obtain all the methods and the attributes of a class in python? Thanks to anyone that can answer me. Best Agnese From rosuav at gmail.com Tue Sep 22 05:25:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Sep 2020 19:25:54 +1000 Subject: Question from a "java background" developer In-Reply-To: References: Message-ID: On Tue, Sep 22, 2020 at 7:15 PM Agnese Camellini wrote: > > Hello to everyone, I have a question. I come from a Java background and I > would like to develop in python but i'm wondering: is there anything, in > python, like Java "reflection"? > I mean do i have a keyword to obtain all the methods and the attributes of > a class in python? Yes - introspection can be done by looking at a class's dictionary. Check out the dir() function to start exploring! ChrisA From mats at wichmann.us Tue Sep 22 08:59:25 2020 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 22 Sep 2020 06:59:25 -0600 Subject: Question from a "java background" developer In-Reply-To: References: Message-ID: On 9/22/20 3:25 AM, Chris Angelico wrote: > On Tue, Sep 22, 2020 at 7:15 PM Agnese Camellini > wrote: >> >> Hello to everyone, I have a question. I come from a Java background and I >> would like to develop in python but i'm wondering: is there anything, in >> python, like Java "reflection"? >> I mean do i have a keyword to obtain all the methods and the attributes of >> a class in python? > > Yes - introspection can be done by looking at a class's dictionary. > Check out the dir() function to start exploring! Without knowing any specifics of what you're looking for you can examine and modifiy object attributes. Python's dynamic nature makes the modifying part easy (sometimes I think *too* easy :) ). Along with dir(), other functions to read a bit on: type, isinstance, callable, setattr, getattr as well as the attribute __dict__. From arj.python at gmail.com Tue Sep 22 12:14:01 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Tue, 22 Sep 2020 20:14:01 +0400 Subject: Importing from within package Message-ID: Greeting list, I have this main script: https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py However, i get errors after package installation saying: ImportError: cannot import name 'shopyoapi' from 'shopyo' I've tried from .shopyoapi also but to no avail. To reproduce: python -m pip install shopyo==1.1.45 shopyo new . test2 Thanks! Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius From mal at europython.eu Tue Sep 22 13:04:54 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Tue, 22 Sep 2020 19:04:54 +0200 Subject: EuroPython "Ask me Anything" Message-ID: <058191df-cfab-8f1d-9daf-2da2f78d84a8@europython.eu> Dear Community, we want to try a new experiment and run an ?Ask me Anything? (AMA) this Thursday to answer questions you may have, share our knowledge or help you in planning your online event. Some of the topics we can cover: - our tools research and findings - our concepts for running an online conference or event - our experience with running EuroPython online - what we could do to support you - how our Zoom license sharing works - how you can apply for a grant - how the EuroPython Society works - how we run the EuroPython organization with fully remote work groups and, of course, anything else :-) If you?re interested in joining the call, please send your name and email to helpdesk at europython.eu and we?ll send you the invite for the call on * Thursday, Sept 24, starting at 19:30 CEST * When requesting the invite, please also consider adding any more detailed questions, so we can better prepare and make the meeting more effective. If there is demand, we?ll probably have these calls on a monthly basis to keep the momentum going. BTW: We are making our conference resources available on our website, in case you have missed our blog post earlier this year. Many thanks. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/629951901661790208/europython-ask-me-anything Tweet: https://twitter.com/europython/status/1308346430130663426 Thanks, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From walter at pobox.store Tue Sep 22 03:39:41 2020 From: walter at pobox.store (Walter Penn) Date: Tue, 22 Sep 2020 15:39:41 +0800 Subject: PyOBEX installation problem In-Reply-To: References: Message-ID: Johny wrote: > I tried to install PyOBEX Maybe this one instead? pip install PyOBEX see https://pypi.org/project/PyOBEX/ regards. From guy.malkinson at college-de-france.fr Tue Sep 22 03:45:45 2020 From: guy.malkinson at college-de-france.fr (Malkinson Guy) Date: Tue, 22 Sep 2020 09:45:45 +0200 (CEST) Subject: Fwd: Trouble with uninstalling Python 3.8 from windows10 In-Reply-To: <1243640279.1329938.1600759904074.JavaMail.zimbra@college-de-france.fr> References: <1457470682.1305019.1600758723825.JavaMail.zimbra@college-de-france.fr> <1243640279.1329938.1600759904074.JavaMail.zimbra@college-de-france.fr> Message-ID: <1345114300.1351714.1600760745956.JavaMail.zimbra@college-de-france.fr> Hello I'm a Python beginner. I installed last week python 3.8 64bit on windows 10 for the purpose of working with tiff images. I next tried to import PIL (or pil), but was unsuccessful (all stackoverflow solutions didn't work either). I next thought this could be due to the python version, and wanted to removed the 3.8 in order to install an older version. But I can't seem to uninstall: while the uninstaller gives a "successfully uninstalled" message, the python is not removed from the list of programs. I also tried deleting the python folder itself, this doesn't work. And of course have restarted the computer... I then tried to modify via the applications list: I didn't receive the option of "modify" or "repair", only install. So I proceeded with the installation, which failed , error message 0x80070001 Any ideas how to solve these issues? All the best Guy From dieter at handshake.de Tue Sep 22 13:25:02 2020 From: dieter at handshake.de (Dieter Maurer) Date: Tue, 22 Sep 2020 19:25:02 +0200 Subject: Question from a "java background" developer In-Reply-To: References: Message-ID: <24426.13166.619984.160713@ixdm.fritz.box> Chris Angelico wrote at 2020-9-22 19:25 +1000: >On Tue, Sep 22, 2020 at 7:15 PM Agnese Camellini > wrote: >> >> Hello to everyone, I have a question. I come from a Java background and I >> would like to develop in python but i'm wondering: is there anything, in >> python, like Java "reflection"? >> I mean do i have a keyword to obtain all the methods and the attributes of >> a class in python? > >Yes - introspection can be done by looking at a class's dictionary. >Check out the dir() function to start exploring! I find also `help(obj)` very helpful. The basics behind `help` (a built in function) come from the `inspect` module. It is very helpful to programmatically inspect features of Python objects. From macrakis at alum.mit.edu Tue Sep 22 13:49:27 2020 From: macrakis at alum.mit.edu (Stavros Macrakis) Date: Tue, 22 Sep 2020 13:49:27 -0400 Subject: Pythonic style Message-ID: Thanks to everyone for the comments, especially Tim Chase for the simple and elegant tuple unpacking solution, and L?o El Amri for the detailed comments on the variants. Below are some more variants which *don't *use tuple unpacking, on the theory that the coding patterns may be useful in other cases where unpacking doesn't apply. For me, one of the interesting lessons from all these finger exercises is that *for* and unpacking hide a lot of messiness, both the initial *iter* call and the exception handling. I don't see any way to eliminate the *iter*, but there are ways to avoid the verbose exception handling. Using the second arg to *next*, we get what is arguably a more elegant solution: _uniq = [] def firstg(iterable): it = iter(iterable) val0 = next(it,_uniq) val1 = next(it,_uniq) if val0 is not _uniq and val1 is _uniq: return val0 else: raise ValueError("first1: arg not exactly 1 long") But I don't know if the *_uniq* technique is considered Pythonic. If *next* were instead defined to return a flag (rather than raising an exception), the code becomes cleaner and clearer, something like this: def firsth(iterable): it = iter(iterable) (val0, good0) = next2(it) (val1, good1) = next2(it) # val1 is dummy if good0 and not good1: return val0 else: raise ValueError("first1: arg not exactly 1 long") # returns (value, validp) # validp is False if no more values def next2(iterable): try: val = next(iterable) except StopIteration: return (None, False) return (val, True) (To be clear, I'm *not *suggesting that *next2* replace *next*!) Thoughts? -s From rosuav at gmail.com Tue Sep 22 14:15:19 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Sep 2020 04:15:19 +1000 Subject: Pythonic style In-Reply-To: References: Message-ID: On Wed, Sep 23, 2020 at 3:52 AM Stavros Macrakis wrote: > > Thanks to everyone for the comments, especially Tim Chase for the simple > and elegant tuple unpacking solution, and L?o El Amri for the detailed > comments on the variants. Below are some more variants which *don't *use > tuple unpacking, on the theory that the coding patterns may be useful in > other cases where unpacking doesn't apply. When doesn't it apply? Can you elaborate on this? It might be easier to advise on Pythonic style when the specific requirements are known. > For me, one of the interesting lessons from all these finger exercises is > that *for* and unpacking hide a lot of messiness, both the initial *iter* call > and the exception handling. I don't see any way to eliminate the *iter*, > but there are ways to avoid the verbose exception handling. In Python, exception handling IS the way to do these things. Having a two-part return value rather than using an exception is an unusual idiom in Python (although it's well known in other languages; I believe JavaScript does iterators this way, for one). > Using the second arg to *next*, we get what is arguably a more elegant > solution: > > > _uniq = [] > def firstg(iterable): > it = iter(iterable) > val0 = next(it,_uniq) > val1 = next(it,_uniq) > if val0 is not _uniq and val1 is _uniq: > return val0 > else: > raise ValueError("first1: arg not exactly 1 long") > > But I don't know if the *_uniq* technique is considered Pythonic. It is when it's needed, but a more common way to write this would be to have the sentinel be local to the function (since it doesn't need to be an argument): def firstg_variant(iterable): it = iter(iterable) sentinel = object() first = next(it, sentinel) if first is sentinel: raise ValueError("empty iterable") second = next(it, sentinel) if second is not sentinel: raise ValueError("too many values") return first But getting a return value and immediately checking it is far better spelled "try/except" here. (Note, BTW, that I made a subtle change to the logic here: this version doesn't call next() a second time if the first one returned the sentinel. This avoids problems with broken iterators that raise StopException and then keep going.) > If *next* were instead defined to return a flag (rather than raising an > exception), the code becomes cleaner and clearer, something like this: > > > def firsth(iterable): > it = iter(iterable) > (val0, good0) = next2(it) > (val1, good1) = next2(it) # val1 is dummy > if good0 and not good1: > return val0 > else: > raise ValueError("first1: arg not exactly 1 long") > IMO this isn't any better than the previous one. You still need a sentinel, but now you use True and False instead of a special object. It isn't *terrible*, but it's no advantage either. ChrisA From yakov.shalunov at gmail.com Tue Sep 22 15:16:13 2020 From: yakov.shalunov at gmail.com (Yakov Shalunov) Date: Tue, 22 Sep 2020 12:16:13 -0700 (PDT) Subject: List Partition Comprehension (Feature Suggestion) Message-ID: Python list comprehension is substantially faster than plan iteration, to the point where ``` l0, l1 = [],[] for x in l: if cond(x): l0.append(x) else: l1.append(x) ``` runs at about the same speed as ``` l0 = [x for x in l if cond(x)] l1 = [x for x in l if not cond(x)] ``` assuming `cond` is a computationally light conditional. While this isn't an extremely common use, I suggest a "partition comprehension" syntax which extends normal filtered-generator syntax. Such as: ``` l0, l1 = ([x for x in l if cond(x) else x]) ``` (parenthesis there to indicate that the output is a tuple) It could allow extension to n-way partitions as well. Because elif doesn't fit nicely in-line, it would probably be nicer to do it like: ``` l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3]) ``` So l0 would be all elements that match cond0, l1 would be squares of all that match cond1, and l2 would be cubes of everything that matches neither. From yakov.shalunov at gmail.com Tue Sep 22 15:34:14 2020 From: yakov.shalunov at gmail.com (Yakov Shalunov) Date: Tue, 22 Sep 2020 12:34:14 -0700 (PDT) Subject: List Partition Comprehension (Feature Suggestion) In-Reply-To: References: Message-ID: <124488ce-9802-4961-a1e0-03b660700205n@googlegroups.com> A possible alternative would be a partition library function in the same vein as `map` and `filter` ``` def partition(n, key, iter): """ Partitions a list. Args: (n: the number of partitions), (key: function which takes elements and returns the index of the partition to place them in), (iter: the iterable to be partitioned) Returns: A tuple of lists partitioned per the key function. If this were a library function, this would likely return a tuple of generators instead in the same vein as `map` and `filter`. """ lists = tuple([] for _ in range(n)) for x in iter: lists[key(x)].append(x) return lists ``` Except it would be optimized like a library function (which means written in C, I believe) On Tuesday, September 22, 2020 at 12:16:39 PM UTC-7, Yakov Shalunov wrote: > Python list comprehension is substantially faster than plan iteration, to the point where > ``` > l0, l1 = [],[] > for x in l: > if cond(x): > l0.append(x) > else: > l1.append(x) > ``` > runs at about the same speed as > ``` > l0 = [x for x in l if cond(x)] > l1 = [x for x in l if not cond(x)] > ``` > assuming `cond` is a computationally light conditional. > While this isn't an extremely common use, I suggest a "partition comprehension" syntax which extends normal filtered-generator syntax. Such as: > ``` > l0, l1 = ([x for x in l if cond(x) else x]) > ``` > (parenthesis there to indicate that the output is a tuple) > It could allow extension to n-way partitions as well. Because elif doesn't fit nicely in-line, it would probably be nicer to do it like: > ``` > l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3]) > ``` > So l0 would be all elements that match cond0, l1 would be squares of all that match cond1, and l2 would be cubes of everything that matches neither. From rosuav at gmail.com Tue Sep 22 20:31:16 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Sep 2020 10:31:16 +1000 Subject: Importing from within package In-Reply-To: <1g0lmfdl9stt37svn81j7sitiv0gh62307@4ax.com> References: <1g0lmfdl9stt37svn81j7sitiv0gh62307@4ax.com> Message-ID: On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber wrote: > > On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer > declaimed the following: > > >I have this main script: > >https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py > > > > Well, that file name scares me... > > __main__ is the name Python uses internally for the, well, main program > (whatever the real file name is), and becomes part of the convention > > if __name__ == "__main__": > #running as stand-alone program > #do stuff > > where imported files will appear with the name by which they were imported. > In a package, __main__.py does that same job. ChrisA From david at lowryduda.com Tue Sep 22 21:02:37 2020 From: david at lowryduda.com (David Lowry-Duda) Date: Tue, 22 Sep 2020 21:02:37 -0400 Subject: Question from a "java background" developer In-Reply-To: References: Message-ID: <20200923010237.GA23827@mail.lowryduda.com> On Tue, Sep 22, 2020 at 11:13:50AM +0200, Agnese Camellini wrote: > I mean do i have a keyword to obtain all the methods and the > attributes of > a class in python? In addition to the `dir()` that others have mentioned, I'll add that developing interactively is very common, especially in ipython/jupyter sessions or notebooks. With these, you have tab completion or question mark documentation. For example, if you have an instance `myobj` of the class `MyClass`, then in an ipython session, typing `myobj.` will open up a list of all the methods for objects of `MyClass`. And given an object or funcation, appending `?` will bring up the documentation (as given in the docstring) for that object or function. This is true even for user-defined functions and objects, even if they were defined during the same interactive session. Good luck! -- David Lowry-Duda From greg.ewing at canterbury.ac.nz Tue Sep 22 21:31:51 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 23 Sep 2020 13:31:51 +1200 Subject: List Partition Comprehension (Feature Suggestion) In-Reply-To: References: Message-ID: On 23/09/20 7:16 am, Yakov Shalunov wrote: > l0, l1 = ([x for x in l if cond(x) else x]) > l0, l1, l2 = ([x for x in l if cond0(x) else x**2 if cond1(x) else x**3]) This syntax seems a bit convoluted. One of the result expressions is at the beginning as usual, but the rest are tacked on the end. And it's far from obvious that it returns multiple lists instead of a single list with alternative values, as you would get from [(x if cond0(x) else x**2 if cond1(x) else x**3) for x in l] which at first glance seems very similar. Also I'm not sure how this would interact with the existing comprehension syntax in its full generality, where you can have multiple "for" and "if" clauses mixed in any order. > A possible alternative would be a partition library function in the > same vein as `map` and `filter` That sounds like a much better idea for something that is so rarely needed. Although it probably wouldn't be as fast as an LC could potentially be, due to the need to call a user-supplied function for every item. -- Greg From soyeomul at doraji.xyz Tue Sep 22 23:31:29 2020 From: soyeomul at doraji.xyz (=?utf-8?B?6buD54Kz54aZ?=) Date: Wed, 23 Sep 2020 12:31:29 +0900 Subject: Importing from within package References: <1g0lmfdl9stt37svn81j7sitiv0gh62307@4ax.com> Message-ID: Chris Angelico writes: > ... > In a package, __main__.py does that same job. Sorry ChrisA, would you please some example? Because i am working in progress with Python things... Sicnerely, Byung-Hee -- ^????? _????_ ?????_^))// From tjreedy at udel.edu Tue Sep 22 22:17:24 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 22 Sep 2020 22:17:24 -0400 Subject: Importing from within package In-Reply-To: References: <1g0lmfdl9stt37svn81j7sitiv0gh62307@4ax.com> Message-ID: On 9/22/2020 8:31 PM, Chris Angelico wrote: > On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber wrote: >> >> On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer >> declaimed the following: >> >>> I have this main script: >>> https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py >>> >> >> Well, that file name scares me... >> >> __main__ is the name Python uses internally for the, well, main program >> (whatever the real file name is), and becomes part of the convention >> >> if __name__ == "__main__": >> #running as stand-alone program >> #do stuff >> >> where imported files will appear with the name by which they were imported. >> > > In a package, __main__.py does that same job. I am not sure of your intended meaning. Assume that director 'mypac' is in a directory on sys.path. Forget namespace packages, which I have not studied. 'import mypac' within code imports mypac/__init__.py 'python -m mypac' on a command line runs mypac/__main__.py Example: .../pythonxy/lib/idlelib. lib is on sys.path. idlelib/__init__.py is nearly empty. idlelib/__main__.py starts IDLE, so 'python -m idlelib' on a command line starts idle. -- Terry Jan Reedy From tjreedy at udel.edu Tue Sep 22 23:09:20 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 22 Sep 2020 23:09:20 -0400 Subject: List Partition Comprehension (Feature Suggestion) In-Reply-To: References: Message-ID: On 9/22/2020 3:16 PM, Yakov Shalunov wrote: > Python list comprehension is substantially faster than plan iteration, to the point where > ``` > l0, l1 = [],[] > for x in l: > if cond(x): > l0.append(x) > else: > l1.append(x) > ``` > runs at about the same speed as > ``` > l0 = [x for x in l if cond(x)] > l1 = [x for x in l if not cond(x)] > ``` > assuming `cond` is a computationally light conditional. > While this isn't an extremely common use, I suggest a "partition comprehension" syntax which extends normal filtered-generator syntax. Such as: > ``` > l0, l1 = ([x for x in l if cond(x) else x]) > ``` > (parenthesis there to indicate that the output is a tuple) Parentheses only make a tuple when empty. They otherwise group items as function arguments or to indicate precedence. 'else' by itself would be enough to indicate that one wants two streams, even if it is a bit baroque. 'x for x in iterable if condition' is a generator comprehension. Putting {} or [] around it says to run the iteration to make a set or list. Passing the generator comprehension to set() or list() has the same effect, but the set or list comprehensions can be optimized to run faster. 'x:f(x) for x in iterable' is not quite legal as a standalone generator, but '(x,f(x)} for x in iterable' is, and {x:f(x) for x in iterable} has the effect of dict((x,f(x)) for x in iterable). By analogy, 'ftrue(x) for x in iterable if condition else ffalse(x)' should be a double generator comprehension producing a pair of generators '(f(x) for x in iterable if condition), (f(x) for x in iterable if not condition)' Then enclosing in {} or [] applies set() or list() to each separately to produce a pair of sets or lists. But the latter could be optimized. The double generator comprehension is similar to a conditional expression except that both true and false values are produced -- and kept separate. '(ft(x) if condition else ff(x)) for x in iterable' is legal today, but does not separate the true and false results. -- Terry Jan Reedy From yehudisgru at gmail.com Tue Sep 22 23:54:01 2020 From: yehudisgru at gmail.com (yehudisgru at gmail.com) Date: Tue, 22 Sep 2020 23:54:01 -0400 Subject: Python 3.8.5 Not Launching Message-ID: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> Hi, ? I installed Python 3.8.5 on Windows 10 When I click on a python file it launches the program but it closes immediately. ? Please help, thanks. ? Yehudis Gruber ? ? From rosuav at gmail.com Wed Sep 23 00:23:07 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 23 Sep 2020 14:23:07 +1000 Subject: Importing from within package In-Reply-To: References: <1g0lmfdl9stt37svn81j7sitiv0gh62307@4ax.com> Message-ID: On Wed, Sep 23, 2020 at 2:16 PM Terry Reedy wrote: > > On 9/22/2020 8:31 PM, Chris Angelico wrote: > > On Wed, Sep 23, 2020 at 9:24 AM Dennis Lee Bieber wrote: > >> > >> On Tue, 22 Sep 2020 20:14:01 +0400, Abdur-Rahmaan Janhangeer > >> declaimed the following: > >> > >>> I have this main script: > >>> https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py > >>> > >> > >> Well, that file name scares me... > >> > >> __main__ is the name Python uses internally for the, well, main program > >> (whatever the real file name is), and becomes part of the convention > >> > >> if __name__ == "__main__": > >> #running as stand-alone program > >> #do stuff > >> > >> where imported files will appear with the name by which they were imported. > >> > > > > In a package, __main__.py does that same job. > > I am not sure of your intended meaning. > > Assume that director 'mypac' is in a directory on sys.path. Forget > namespace packages, which I have not studied. > 'import mypac' within code imports mypac/__init__.py > 'python -m mypac' on a command line runs mypac/__main__.py > > Example: .../pythonxy/lib/idlelib. lib is on sys.path. > idlelib/__init__.py is nearly empty. > idlelib/__main__.py starts IDLE, > so 'python -m idlelib' on a command line starts idle. > Correct. I was a bit too brief there, but Terry's elaboration is what I was getting at: that __main__.py is a valid and normal member of a package, and will be used as the entry point. ChrisA From ikorot01 at gmail.com Wed Sep 23 00:38:45 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Tue, 22 Sep 2020 23:38:45 -0500 Subject: Python 3.8.5 Not Launching In-Reply-To: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> Message-ID: Hi, On Tue, Sep 22, 2020 at 11:25 PM wrote: > > Hi, > > > > I installed Python 3.8.5 on Windows 10 > > When I click on a python file it launches the program but it closes > immediately. What is the content of this file? Is it a py or pyc file? Thank you. > > > > Please help, thanks. > > > > Yehudis Gruber > > > > > -- > https://mail.python.org/mailman/listinfo/python-list From arj.python at gmail.com Wed Sep 23 00:56:43 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 23 Sep 2020 08:56:43 +0400 Subject: Importing from within package In-Reply-To: References: Message-ID: Greetings list, In case this might help, i am on Python3.8 and running in a virtual env This command also does not work: python -m shopyo new . test2 Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius From dieter at handshake.de Wed Sep 23 14:29:17 2020 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 23 Sep 2020 20:29:17 +0200 Subject: Importing from within package In-Reply-To: References: Message-ID: <24427.37885.21936.582215@ixdm.fritz.box> Abdur-Rahmaan Janhangeer wrote at 2020-9-22 20:14 +0400: >I have this main script: >https://github.com/Abdur-rahmaanJ/shopyo/blob/dev/shopyo/__main__.py > >However, i get errors after package installation >saying: >ImportError: cannot import name 'shopyoapi' from 'shopyo' It is right: `shopyyoapi` is not a module (no corresponding file in `shopyo` and `shopyo:__init__.py` does not define a corresponding name. From arj.python at gmail.com Wed Sep 23 14:41:13 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Wed, 23 Sep 2020 22:41:13 +0400 Subject: Importing from within package In-Reply-To: <24427.37885.21936.582215@ixdm.fritz.box> References: <24427.37885.21936.582215@ixdm.fritz.box> Message-ID: In shopyo/shopyo (the same folder as __main__.py) there is a folder called shopyoapi. What i want is to import create_module from cmd.py from shopyoapi in __main__.py but it does not work or more precisely i am looking how to make it work! Since this is not py2 i guess no init needed in shopyoapi Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. From tjreedy at udel.edu Wed Sep 23 07:38:03 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 23 Sep 2020 07:38:03 -0400 Subject: Python 3.8.5 Not Launching In-Reply-To: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> Message-ID: On 9/22/2020 11:54 PM, yehudisgru at gmail.com wrote: > I installed Python 3.8.5 on Windows 10 > When I click on a python file it launches the program but it closes > immediately. When you run a program that way, the console/terminal window closes when the program finishes executing. -- Terry Jan Reedy From dieter at handshake.de Wed Sep 23 16:12:00 2020 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 23 Sep 2020 22:12:00 +0200 Subject: Importing from within package In-Reply-To: References: <24427.37885.21936.582215@ixdm.fritz.box> Message-ID: <24427.44048.239577.442014@ixdm.fritz.box> Abdur-Rahmaan Janhangeer wrote at 2020-9-23 22:41 +0400: >In shopyo/shopyo (the same folder as __main__.py) there is a folder called >shopyoapi. Not in the distribution: ... shopyo-1.1.45/shopyo/ shopyo-1.1.45/shopyo/__init__.py shopyo-1.1.45/shopyo/__main__.py shopyo-1.1.45/shopyo/app.py shopyo-1.1.45/shopyo/config.py shopyo-1.1.45/shopyo/manage.py shopyo-1.1.45/shopyo/test_frontend.py shopyo-1.1.45/shopyo.egg-info/ ... Maybe, that is your problem (missing folder in the distribution). From barpasc at yahoo.com Wed Sep 23 16:24:03 2020 From: barpasc at yahoo.com (pascal z) Date: Wed, 23 Sep 2020 13:24:03 -0700 (PDT) Subject: python show . Message-ID: <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Hello, I'm working on a script where I want to loop into folders somehow recursively to get information but I want to limit the infos for the files on a certain level of folders for example: /home/user/Documents/folder1 /home/user/Documents/folder2 /home/user/Documents/folder3/folder1/file1 /home/user/Documents/folder4/file1 /home/user/Documents/file1 /home/user/Documents/file2 /home/user/Documents/file3 I only want file1, 2, 3 at the root of Documents to show (write to a csv) and I'm using the script below ### SCRIPT### #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os csv_contents = "" output_file = '/home/user/Documents/csv/output2csv.csv' Lpath = '/home/user/Documents/' csv_contents = "FOLDER PATH;Size in Byte;Size in Kb;Size in Mb;Size in Gb\n" for root, dirs, files in os.walk(Lpath, topdown=False): counter = Lpath.count(os.path.sep) if counter < 5: for f in os.listdir(root): path = os.path.join(root, f) f_size = 0 f_size = os.path.getsize(path) csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (path, f_size, f_size/1024, f_size/1048576, f_size/1073741824) fp = open(output_file, "w") fp.write(csv_contents) fp.close() ### END OF SCRIPT### When I run this script, I get files in subfolders. For now, I need to keep using "os.walk" because the script includes functions that I didn't include to make thing simple. Pascal From arj.python at gmail.com Wed Sep 23 16:35:04 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 24 Sep 2020 00:35:04 +0400 Subject: Importing from within package In-Reply-To: <24427.44048.239577.442014@ixdm.fritz.box> References: <24427.37885.21936.582215@ixdm.fritz.box> <24427.44048.239577.442014@ixdm.fritz.box> Message-ID: Thanks for the lead. Checking tomorrow! If so i'll have to include other folders as well ... Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. From cs at cskk.id.au Wed Sep 23 17:05:45 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Thu, 24 Sep 2020 07:05:45 +1000 Subject: python show . In-Reply-To: <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> References: <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Message-ID: <20200923210545.GA5917@cskk.homeip.net> On 23Sep2020 13:24, pascal z wrote: >Hello, I'm working on a script where I want to loop into folders somehow recursively to get information but I want to limit the infos for the files on a certain level of folders for example: > >/home/user/Documents/folder1 >/home/user/Documents/folder2 >/home/user/Documents/folder3/folder1/file1 >/home/user/Documents/folder4/file1 >/home/user/Documents/file1 >/home/user/Documents/file2 >/home/user/Documents/file3 > >I only want file1, 2, 3 at the root of Documents to show (write to a csv) and I'm using the script below Like the -depth option to the find command? First I would note that if you only want the top level, you don't need to use os.walk, just look at os.listdir. But if you want to be more flexible (eg down to level 3, or just particular directories), then you need os.walk. So, to your script... The first thing to note is that os.walk hands you to actual list of subdirectory names it is going to use as "dirs". If you modify that list (in place), os.walk uses the modified list. You could sort that list to do a lexically ordered tree walk, and you can delete things from the list to prevent os.walk walking into those items. For the deletion thing, indeed for the sort thing, it is often easiest to construct a new list with the desired result, then update the original - you need to update the original because that is the object os.walk is using: for root, dirs, files in os.walk(Lpath, topdown=False): # make a new list of "x*" names, sorted new_subdirs = sorted( dirname for dirname in dirs if dirname.startswith('z') ) # update the original list in place dirs[:] = new_subdirs For the general form of your problem (limiting the depth) you need to know the depth of "root", which os.walk does not tell you directly. Two approaches com to mind: The lexical approach is to look at the path from Lpath to root and measure its length. os.path.relpath will get you the relative path, and you could split that on os.sep to get path components. There's also the Pathlib library. The other approach to it compute the expected path depths. Keep a mapping (a dict) keyed on path with depth as the value. Prepare it with: depths = {Lpath: 0} Inside the loop, get the current depth: depth = depths[root] You can make decisions on that. For example, if the depth reaches your threshold you could simply empty the "dirs" list (remember to do that in place) to prevent os.walk going any deeper. Before the end of the loop, compute and store the depth for each subdirectory: for subdir in dirs: subpath = os.path.join(root, subdir) depths[subpath] = depth + 1 so that they are ready for use when os.walk gives them to you on later iterations. Cheers, Cameron Simpson From macrakis at alum.mit.edu Wed Sep 23 17:04:56 2020 From: macrakis at alum.mit.edu (Stavros Macrakis) Date: Wed, 23 Sep 2020 17:04:56 -0400 Subject: Pythonic style In-Reply-To: References: Message-ID: Thanks, Chris, for the useful comments. Comments in line (with snipping of unnecessary content): > > some more variants which *don't* use tuple unpacking, on the theory > that the coding patterns may be useful in > > other cases where unpacking doesn't apply. > > When doesn't it apply? Can you elaborate on this? It might be easier > to advise on Pythonic style when the specific requirements are known. > No specific requirement. These are *finger exercises* intended to isolate one issue for discussion rather than be useful in themselves. > > ...but there are ways to avoid the verbose exception handling. > In Python, exception handling IS the way to do these things. Good to know. Since *try* statements are at least 4 lines long, I was trying for something more concise. And maybe somewhere in the back of my mind, I have the anti-Pythonic principle that exceptions should be reserved for errors. I'll try to suppress that. I remember one (very old) paper arguing that exceptions were a bad idea in general... but I have implemented and used exceptions in many languages, both before and after that paper! > > _uniq = [] > > def firstg(iterable): > > it = iter(iterable) > > val0 = next(it,_uniq) > > val1 = next(it,_uniq) > > if val0 is not _uniq and val1 is _uniq: > > return val0 > > else: > > raise ValueError("first1: arg not exactly 1 long") > > > > But I don't know if the *_uniq* technique is considered Pythonic. > > It is when it's needed, but a more common way to write this would be > to have the sentinel be local to the function (since it doesn't need > to be an argument): > What do you mean by an argument? Is it not considered Pythonic for constants to be calculated once at the module or class level rather than be recalculated every time a function is entered? def firstg_variant(iterable): > it = iter(iterable) > sentinel = object() > first = next(it, sentinel) > if first is sentinel: > raise ValueError("empty iterable") > second = next(it, sentinel) > if second is not sentinel: > raise ValueError("too many values") > return first > > But getting a return value and immediately checking it is far better > spelled "try/except" here. (Note, BTW, that I made a subtle change to > the logic here: this version doesn't call next() a second time if the > first one returned the sentinel. This avoids problems with broken > iterators that raise StopException and then keep going.) > Yes, I hadn't thought of that. I was trying to avoid repeating the *raise* statement. Thanks again for the helpful comments. They give me a better idea of good Python style. -s From yehudisgru at gmail.com Wed Sep 23 17:59:42 2020 From: yehudisgru at gmail.com (yehudisgru at gmail.com) Date: Wed, 23 Sep 2020 17:59:42 -0400 Subject: Python 3.8.5 Not Launching In-Reply-To: References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol>, Message-ID: It?s a py file with simple python code ? From: [1]Igor Korot Sent: Wednesday, September 23, 2020 12:39 AM To: [2]yehudisgru at gmail.com Cc: [3]python-list at python.org Subject: Re: Python 3.8.5 Not Launching ? Hi, ? On Tue, Sep 22, 2020 at 11:25 PM wrote: >? >??? Hi, >? >? >? >??? I installed Python 3.8.5 on Windows 10 >? >??? When I click on a python file it launches the program but it closes >??? immediately. ? What is the content of this file? Is it a py or pyc file? ? Thank you. ? >? >? >? >??? Please help, thanks. >? >? >? >??? Yehudis Gruber >? >? >? >? > -- > https://mail.python.org/mailman/listinfo/python-list ? References Visible links 1. mailto:ikorot01 at gmail.com 2. mailto:yehudisgru at gmail.com 3. mailto:python-list at python.org From eryksun at gmail.com Wed Sep 23 18:43:43 2020 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 23 Sep 2020 17:43:43 -0500 Subject: Python 3.8.5 Not Launching In-Reply-To: References: <2C524CF8-F881-47EC-B483-EDB9B6EC0A3E@hxcore.ol> Message-ID: On 9/23/20, yehudisgru at gmail.com wrote: > It?s a py file with simple python code If .py files are associated with py.exe or python.exe, then running a .py script either inherits or allocates a console and attaches to it. The console closes automatically as soon as the last reference to it closes. If you need the console to remain open, then it should be inherited from the parent process. Typically that's a shell such as CMD or PowerShell, but any process can manually allocate an inheritable console via WinAPI AllocConsole. To run a script from a shell command line, simply enter "path\to\some_script.py". If the script is in a PATH directory and .PY is in PATHEXT, then you can simply run "some_script" in CMD or PowerShell. From barpasc at yahoo.com Wed Sep 23 19:24:32 2020 From: barpasc at yahoo.com (pascal z) Date: Wed, 23 Sep 2020 16:24:32 -0700 (PDT) Subject: python show folder files and not subfolder files In-Reply-To: References: <20200923210545.GA5917@cskk.homeip.net> <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Message-ID: Please advise if the following is ok (i don't think it is) #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os csv_contents = "" output_file = '/home/user/Documents/csv/output3csv.csv' Lpath = '/home/user/Documents/' csv_contents = "FOLDER PATH;Size in Byte;Size in Kb;Size in Mb;Size in Gb\n" d_size = 0 for root, dirs, files in os.walk(Lpath, topdown=False): for i in files: d_size += os.path.getsize(root + os.sep + i) csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (root, d_size, d_size/1024, d_size/1048576, d_size/1073741824) counter = Lpath.count(os.path.sep) if counter < 5: for f in os.listdir(Lpath): path = os.path.join(Lpath, f) f_size = 0 f_size = os.path.getsize(path) csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (path, f_size, f_size/1024, f_size/1048576, f_size/1073741824) fp = open(output_file, "w") fp.write(csv_contents) fp.close() From barpasc at yahoo.com Wed Sep 23 20:00:12 2020 From: barpasc at yahoo.com (pascal z) Date: Wed, 23 Sep 2020 17:00:12 -0700 (PDT) Subject: python show folder files and not subfolder files In-Reply-To: References: <20200923210545.GA5917@cskk.homeip.net> <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Message-ID: <71b1eca6-cee4-492f-b67b-1edd4e836c3en@googlegroups.com> ok, i came up with if os.path.isfile(path) following path = os.path.join(Lpath, f) and it seems to be ok, no dupplicates or wrong sizes... thanks From dcwhatthe at gmail.com Thu Sep 24 03:33:18 2020 From: dcwhatthe at gmail.com (dcwh...@gmail.com) Date: Thu, 24 Sep 2020 00:33:18 -0700 (PDT) Subject: Is there a way to install 3.4.10, without Visual Studio? Message-ID: <6832a921-769b-4446-9e95-b5575124993en@googlegroups.com> Hi, I'm downgrading, for one particular project, and am trying to install 3.4.10 32 bit There's no Windows installer for this, so I installed 3.4, and then copied the contents of https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tgz into the c:\Python34 folder and subfolders. The c:\Python34\PCBuild\Readme.txt file seems to indicate that I have to install Visual C++ 2010, in order to build this. Is there an alternative to going this route? There is this package, http://matejhorvat.si/en/windows/python/index.htm , but I'm not sure how reliable it is. Should I just use the most recent 3.4.x version that has a Windows Installer, and not worry about the final 3.4.10 version? Or is there a way to get to 3.4.10? From rosuav at gmail.com Thu Sep 24 03:51:05 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 24 Sep 2020 17:51:05 +1000 Subject: Is there a way to install 3.4.10, without Visual Studio? In-Reply-To: <6832a921-769b-4446-9e95-b5575124993en@googlegroups.com> References: <6832a921-769b-4446-9e95-b5575124993en@googlegroups.com> Message-ID: On Thu, Sep 24, 2020 at 5:36 PM dcwh... at gmail.com wrote: > Should I just use the most recent 3.4.x version that has a Windows Installer, and not worry about the final 3.4.10 version? Or is there a way to get to 3.4.10? > I would STRONGLY recommend using a newer Python rather than pinning yourself to the 3.4.x branch. But if you absolutely must use a now-ancient version, your only options are to build it yourself (which requires Visual Studio as you have discovered) or to use a slightly older release. It's entirely up to you whether the changes in 3.4.10 are significant enough to build Python manually. Either way, you're basically on your own. If you really really have to use such an old Python, maybe consider using Linux instead of Windows; building from source is generally easier, and you may even be able to find a distribution that packages Python 3.4 for you (Red Hat and Debian being the best contenders here). ChrisA From lukasz at langa.pl Thu Sep 24 06:58:45 2020 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Thu, 24 Sep 2020 12:58:45 +0200 Subject: [RELEASE] Python 3.8.6 is now available Message-ID: <30EA5AA1-44DB-4166-AFB2-FDD1298E437B@langa.pl> Python 3.8.6 is the sixth maintenance release of Python 3.8. Go get it here: https://www.python.org/downloads/release/python-386/ Maintenance releases for the 3.8 series will continue at regular bi-monthly intervals, with 3.8.7 planned for mid-November 2020. What?s new? The Python 3.8 series is the newest feature release of the Python language, and it contains many new features and optimizations. See the ?What?s New in Python 3.8 ? document for more information about features included in the 3.8 series. Python 3.8 is becoming more stable. Our bugfix releases are becoming smaller as we progress. This one contains 122 changes, less than two thirds of the previous average for a new release. Detailed information about all changes made in version 3.8.6 specifically can be found in its change log . Note that compared to 3.8.5 this release also contains all changes present in 3.8.6rc1. We hope you enjoy Python 3.8! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Your friendly release team, Ned Deily @nad Steve Dower @steve.dower ?ukasz Langa @ambv From tjreedy at udel.edu Thu Sep 24 01:52:28 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Sep 2020 01:52:28 -0400 Subject: python show folder files and not subfolder files In-Reply-To: References: <20200923210545.GA5917@cskk.homeip.net> <90128d85-b46a-474c-80f6-9d705dcf2fd3n@googlegroups.com> Message-ID: On 9/23/2020 7:24 PM, pascal z via Python-list wrote: > Please advise if the following is ok (i don't think it is) > > #!/usr/bin/env python3 > # -*- coding: utf-8 -*- > > import os > > csv_contents = "" > output_file = '/home/user/Documents/csv/output3csv.csv' > Lpath = '/home/user/Documents/' > > csv_contents = "FOLDER PATH;Size in Byte;Size in Kb;Size in Mb;Size in Gb\n" > > d_size = 0 > for root, dirs, files in os.walk(Lpath, topdown=False): > for i in files: > d_size += os.path.getsize(root + os.sep + i) > csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (root, d_size, d_size/1024, d_size/1048576, d_size/1073741824) > > counter = Lpath.count(os.path.sep) > if counter < 5: > for f in os.listdir(Lpath): > path = os.path.join(Lpath, f) > f_size = 0 > f_size = os.path.getsize(path) > csv_contents += "%s ;%.2f ;%.2f ;%.2f ;%.2f \n" % (path, f_size, f_size/1024, f_size/1048576, f_size/1073741824) > > fp = open(output_file, "w") > fp.write(csv_contents) > fp.close() Read https://docs.python.org/3/faq/programming.html#what-is-the-most-efficient-way-to-concatenate-many-strings-together -- Terry Jan Reedy From singh.bhashkar at gmail.com Thu Sep 24 14:21:12 2020 From: singh.bhashkar at gmail.com (bhashkar prakash Singh) Date: Thu, 24 Sep 2020 23:51:12 +0530 Subject: stackless python 2.7.9 and openssl-1.1.1g Message-ID: Hi, I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. I just upgraded the Openssl version to 1.1.1g, due to which python compilation started failing. So, I patched _hashopenssl.c and _ssl.c file in Python Modules as per new openssl to make compilation successful. But when I run my image on target HW, I am getting below errors. It looks like Openssl 1.1.1g libraries are not linked to Python. I am struggling with this issue since many days. Looks like something I missed in my patching. Could someone please help on this. ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File "/usr/lib/python2.7/hashlib.py", line 147, in globals()[__func_name] = __get_hash(__func_name) File "/usr/lib/python2.7/hashlib.py", line 109, in __get_openssl_constructor return __get_builtin_constructor(name) File "/usr/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha512 Thanks & Regards, Bhashkar From barry at barrys-emacs.org Thu Sep 24 17:10:46 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Thu, 24 Sep 2020 22:10:46 +0100 Subject: stackless python 2.7.9 and openssl-1.1.1g In-Reply-To: References: Message-ID: <67969C77-5B57-4F7D-85E6-06AFC3F9144A@barrys-emacs.org> > On 24 Sep 2020, at 19:21, bhashkar prakash Singh wrote: > > Hi, > > I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. > I just upgraded the Openssl version to 1.1.1g, due to which python > compilation started failing. So, I patched _hashopenssl.c and _ssl.c file > in Python Modules as per new openssl to make compilation successful. > But when I run my image on target HW, I am getting below errors. It > looks like Openssl 1.1.1g libraries are not linked to Python. > I am struggling with this issue since many days. Looks like something I > missed in my patching. Could someone please help on this. I recently built python 2.7.18 against openssl 1.1.1g without issue. Maybe look see what is in the cpython code that works fine. Barry > Thanks & Regards, > Bhashkar > -- > https://mail.python.org/mailman/listinfo/python-list > From mikeboom at mikeboom.com Thu Sep 24 19:56:12 2020 From: mikeboom at mikeboom.com (Michael Boom) Date: Thu, 24 Sep 2020 23:56:12 +0000 Subject: Question Message-ID: I have a Python manager and clients. I added a feature that if the client or server are killed, they will be restarted. When I restart the server after being killed the clients get a broken pipe error, but the connect call that worked on the first connect, doesn't work now. When a client is restarted it runs the same connection code as always. The connect seems to complete, but the calls don't complete. They just hang. Is there an issue with broken connections and multiprocessing managers? I have tried this with the 3.9.0rc2 and the problem still exists. Also, I have a single connection to a manager. I get two proxies to that manager on the one connection. The documentation says that proxies to a manager are not thread safe. What about two proxies. Do I need to use a single mutex for both proxies, or can I have one mutex for each proxy? If I have a blocking call on one proxy, would using the other proxy step on the toes of the first? Michael L. Boom 858-240-6059 mikeboom at mikeboom.com 11532 Hadar Dr. San Diego, CA. 92126 From singh.bhashkar at gmail.com Thu Sep 24 22:27:47 2020 From: singh.bhashkar at gmail.com (bhashkar prakash Singh) Date: Fri, 25 Sep 2020 07:57:47 +0530 Subject: stackless python 2.7.9 and openssl-1.1.1g In-Reply-To: <67969C77-5B57-4F7D-85E6-06AFC3F9144A@barrys-emacs.org> References: <67969C77-5B57-4F7D-85E6-06AFC3F9144A@barrys-emacs.org> Message-ID: Hi Barry, Thanks for your response. I am not an expert in python code. Could you please elaborate a bit more on this. Which cpython code are you referring to? did you modify other files also apart from _hashopenssl.c and _ssl.c to work with openssl-1.1.1g ? Regards, Bhashkar On Fri, Sep 25, 2020 at 2:40 AM Barry Scott wrote: > > > > On 24 Sep 2020, at 19:21, bhashkar prakash Singh < > singh.bhashkar at gmail.com> wrote: > > > > Hi, > > > > I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. > > I just upgraded the Openssl version to 1.1.1g, due to which python > > compilation started failing. So, I patched _hashopenssl.c and _ssl.c > file > > in Python Modules as per new openssl to make compilation successful. > > But when I run my image on target HW, I am getting below errors. It > > looks like Openssl 1.1.1g libraries are not linked to Python. > > I am struggling with this issue since many days. Looks like something I > > missed in my patching. Could someone please help on this. > > I recently built python 2.7.18 against openssl 1.1.1g without issue. > Maybe look see what is in the cpython code that works fine. > > Barry > > Thanks & Regards, > > Bhashkar > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > From frank at chagford.com Fri Sep 25 01:41:42 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 25 Sep 2020 07:41:42 +0200 Subject: list comprehension namespace problem Message-ID: Hi all I have a problem related (I think) to list comprehension namespaces. I don't understand it enough to figure out a solution. In the debugger, I want to examine the contents of the current instance, so I can type (Pdb) dir(self) and get the result with no problem. However, it is a long list containing attribute names and method names, and I only want to see the attribute names. So I tried this - (Pdb) [x for x in dir(self) if not callable(getattr(self, x))] *** NameError: name 'self' is not defined (Pdb) Q1. Can someone explain what is going on? Q2. Is there a way to get what I want? Thanks Frank Millman From rosuav at gmail.com Fri Sep 25 01:46:43 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 25 Sep 2020 15:46:43 +1000 Subject: list comprehension namespace problem In-Reply-To: References: Message-ID: On Fri, Sep 25, 2020 at 3:43 PM Frank Millman wrote: > > Hi all > > I have a problem related (I think) to list comprehension namespaces. I > don't understand it enough to figure out a solution. > > In the debugger, I want to examine the contents of the current instance, > so I can type > > (Pdb) dir(self) > > and get the result with no problem. > > However, it is a long list containing attribute names and method names, > and I only want to see the attribute names. So I tried this - > > (Pdb) [x for x in dir(self) if not callable(getattr(self, x))] > *** NameError: name 'self' is not defined > (Pdb) > > Q1. Can someone explain what is going on? > > Q2. Is there a way to get what I want? > If you put that line of code into your actual source code, does it work? I think this might be a pdb-specific issue, since normally the comprehension should have no difficulty seeing names from its surrounding context. A minimal case will probably involve the debugger and a function with a local, unless in some way this depends on 'self' being special. ChrisA From frank at chagford.com Fri Sep 25 01:53:08 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 25 Sep 2020 07:53:08 +0200 Subject: list comprehension namespace problem In-Reply-To: References: Message-ID: <2e747bf9-e80a-22c4-3ecf-eb4d936c1f37@chagford.com> On 2020-09-25 7:46 AM, Chris Angelico wrote: > On Fri, Sep 25, 2020 at 3:43 PM Frank Millman wrote: >> >> Hi all >> >> I have a problem related (I think) to list comprehension namespaces. I >> don't understand it enough to figure out a solution. >> >> In the debugger, I want to examine the contents of the current instance, >> so I can type >> >> (Pdb) dir(self) >> >> and get the result with no problem. >> >> However, it is a long list containing attribute names and method names, >> and I only want to see the attribute names. So I tried this - >> >> (Pdb) [x for x in dir(self) if not callable(getattr(self, x))] >> *** NameError: name 'self' is not defined >> (Pdb) >> >> Q1. Can someone explain what is going on? >> >> Q2. Is there a way to get what I want? >> > > If you put that line of code into your actual source code, does it > work? I think this might be a pdb-specific issue, since normally the > comprehension should have no difficulty seeing names from its > surrounding context. > > A minimal case will probably involve the debugger and a function with > a local, unless in some way this depends on 'self' being special. > Yes, is does work from within my source code. Frank From frank at chagford.com Fri Sep 25 01:53:08 2020 From: frank at chagford.com (Frank Millman) Date: Fri, 25 Sep 2020 07:53:08 +0200 Subject: list comprehension namespace problem In-Reply-To: References: Message-ID: <2e747bf9-e80a-22c4-3ecf-eb4d936c1f37@chagford.com> On 2020-09-25 7:46 AM, Chris Angelico wrote: > On Fri, Sep 25, 2020 at 3:43 PM Frank Millman wrote: >> >> Hi all >> >> I have a problem related (I think) to list comprehension namespaces. I >> don't understand it enough to figure out a solution. >> >> In the debugger, I want to examine the contents of the current instance, >> so I can type >> >> (Pdb) dir(self) >> >> and get the result with no problem. >> >> However, it is a long list containing attribute names and method names, >> and I only want to see the attribute names. So I tried this - >> >> (Pdb) [x for x in dir(self) if not callable(getattr(self, x))] >> *** NameError: name 'self' is not defined >> (Pdb) >> >> Q1. Can someone explain what is going on? >> >> Q2. Is there a way to get what I want? >> > > If you put that line of code into your actual source code, does it > work? I think this might be a pdb-specific issue, since normally the > comprehension should have no difficulty seeing names from its > surrounding context. > > A minimal case will probably involve the debugger and a function with > a local, unless in some way this depends on 'self' being special. > Yes, is does work from within my source code. Frank From barry at barrys-emacs.org Fri Sep 25 03:13:21 2020 From: barry at barrys-emacs.org (Barry) Date: Fri, 25 Sep 2020 08:13:21 +0100 Subject: stackless python 2.7.9 and openssl-1.1.1g In-Reply-To: References: Message-ID: >> On 25 Sep 2020, at 03:28, bhashkar prakash Singh wrote: > ? > Hi Barry, > > Thanks for your response. > > I am not an expert in python code. Could you please elaborate a bit more on this. Which cpython code are you referring to? > did you modify other files also apart from _hashopenssl.c and _ssl.c to work with openssl-1.1.1g ? Get the source of python.org python 2.7.18 and you will find that builds without patches against OpenSSL 1.1.1g. I would then diff the C files that do not compile in stackless to look for the required fixes. Barry > > Regards, > Bhashkar > >> On Fri, Sep 25, 2020 at 2:40 AM Barry Scott wrote: >> >> >> > On 24 Sep 2020, at 19:21, bhashkar prakash Singh wrote: >> > >> > Hi, >> > >> > I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. >> > I just upgraded the Openssl version to 1.1.1g, due to which python >> > compilation started failing. So, I patched _hashopenssl.c and _ssl.c file >> > in Python Modules as per new openssl to make compilation successful. >> > But when I run my image on target HW, I am getting below errors. It >> > looks like Openssl 1.1.1g libraries are not linked to Python. >> > I am struggling with this issue since many days. Looks like something I >> > missed in my patching. Could someone please help on this. >> >> I recently built python 2.7.18 against openssl 1.1.1g without issue. >> Maybe look see what is in the cpython code that works fine. >> >> Barry >> > Thanks & Regards, >> > Bhashkar >> > -- >> > https://mail.python.org/mailman/listinfo/python-list >> > From rhettprince at gmail.com Sat Sep 26 00:00:57 2020 From: rhettprince at gmail.com (Rhett Prince) Date: Sat, 26 Sep 2020 00:00:57 -0400 Subject: FW: pipenv has issues In-Reply-To: <005f01d693b8$80cbbe30$82633a90$@gmail.com> References: <005f01d693b8$80cbbe30$82633a90$@gmail.com> Message-ID: <007601d693b9$a3f39210$ebdab630$@gmail.com> 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 thanks From stephane at sdf.org Sat Sep 26 00:43:34 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sat, 26 Sep 2020 12:43:34 +0800 Subject: Use of a variable in parent loop Message-ID: 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 code will trigger an error because $name is declared inside the if and is not usable outside of the block code. That looks logic to me. ===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. Can we change this behavior or is there any point to keep it this way ? From joel.goldstick at gmail.com Sat Sep 26 03:48:12 2020 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Sat, 26 Sep 2020 03:48:12 -0400 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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) > { > my $name = "Stephane"; > print("$name\n" > } > print("Out $name\n"); > ========= > > This code will trigger an error because $name is declared inside the if > and is not usable outside of the block code. That looks logic to me. > > ===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. Can we change this behavior or is there > any point to keep it this way ? > -- > https://mail.python.org/mailman/listinfo/python-list It looks like perl creates a local namespace inside the code suite of the if statement. Python namespace is function based. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays From rosuav at gmail.com Sat Sep 26 04:38:32 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 26 Sep 2020 18:38:32 +1000 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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) > { > my $name = "Stephane"; > print("$name\n" > } > print("Out $name\n"); > ========= > > This code will trigger an error because $name is declared inside the if > and is not usable outside of the block code. That looks logic to me. > > ===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. Can we change this behavior or is there > any point to keep it this way ? Just to get this part out of the way: No, that behaviour won't change. :) The distinction is that, in Python, you didn't declare the variable at all. It's not like C where you have to declare everything, and the place it's declared defines the scope; in Python, variables generally *aren't* declared, and there are a small number of cases where you declare that something's a global when it would otherwise be local. But for the most part, Python's default rules handle the situations admirably. Most variables are either global (if you assign something outside of any function) or local (inside a function). There's no concept of scoping a variable to just a single 'if' statement, so you don't have to worry about it disappearing prematurely. ChrisA From tjreedy at udel.edu Sat Sep 26 03:22:00 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 26 Sep 2020 03:22:00 -0400 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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' when there is no other code. > 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. 'name' is bound to a object, not declared The only declarations are 'global' and 'nonlocal'. Python only creates new scopes for class and function definitions. At least for CPython, comprehensions are implicit function definitions. > This does not look right to me. Because you are accustomed to block scoping. Can we change this behavior No. > or is there any point to keep it this way ? 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. -- Terry Jan Reedy From redstone-cold at 163.com Sat Sep 26 11:26:34 2020 From: redstone-cold at 163.com (iMath) Date: Sat, 26 Sep 2020 08:26:34 -0700 (PDT) Subject: celery multi celery.exceptions.TimeoutError: The operation timed out In-Reply-To: References: <03d43fd7-6d2f-46e4-8f10-3ab9d8b940d1n@googlegroups.com> Message-ID: <909391e6-754e-447e-a30c-0246f28d878fn@googlegroups.com> ? 2020?9?21???? UTC+8 ??8:02:44? ??? > Op 21-09-2020 om 12:14 schreef iMath: > > Asked 3 days ago at https://stackoverflow.com/questions/63951696/celery-multi-celery-exceptions-timeouterror-the-operation-timed-out > > > > But nobody helped yet, anyone ? > > > Did you see > https://stackoverflow.com/questions/9769496/celery-received-unregistered-task-of-type-run-example > ? > > The error says "Received unregistered task of type 'proj.tasks.add'", so > it looks very much like your registry is not correct/complete. > > Vriendelijke groeten/Kind regards, > > Menno H?lscher None of the answers helped . Finally ,I switched to https://github.com/jarekwg/django-apscheduler I found it is elegant and easy to use From rhettprince at gmail.com Sat Sep 26 11:47:42 2020 From: rhettprince at gmail.com (Rhett Prince) Date: Sat, 26 Sep 2020 11:47:42 -0400 Subject: pipenv picks up bad paths and crashes Message-ID: <000401d6941c$5f6136d0$1e23a470$@gmail.com> pipenv is a bad program it conflicts with anaconda. I removed anaconda and it still crashes. also, I repaired my python 3.8 installation uninstalled and reinstalled pipenv and it still picks up paths from anaconda anaconda sucks too. see below Administrator at rcplt MINGW64 /c/dev_env $ ls a.txt dd.py notes.txt pipenv_help.txt Administrator at rcplt MINGW64 /c/dev_env $ pip uninstall pipenv Found existing installation: pipenv 2020.8.13 Uninstalling pipenv-2020.8.13: Would remove: c:\program files (x86)\python38-32\lib\site-packages\pipenv-2020.8.13.dist-i nfo\* c:\program files (x86)\python38-32\lib\site-packages\pipenv\* c:\program files (x86)\python38-32\scripts\pipenv-resolver.exe c:\program files (x86)\python38-32\scripts\pipenv.exe Proceed (y/n)? y Successfully uninstalled pipenv-2020.8.13 Administrator at rcplt MINGW64 /c/dev_env $ pip install pipenv Collecting pipenv Using cached pipenv-2020.8.13-py2.py3-none-any.whl (3.9 MB) Requirement already satisfied: virtualenv-clone>=0.2.5 in c:\program files (x86) \python38-32\lib\site-packages (from pipenv) (0.5.4) Requirement already satisfied: setuptools>=36.2.1 in c:\program files (x86)\pyth on38-32\lib\site-packages (from pipenv) (41.2.0) Requirement already satisfied: virtualenv in c:\program files (x86)\python38-32\ lib\site-packages (from pipenv) (20.0.31) Requirement already satisfied: pip>=18.0 in c:\program files (x86)\python38-32\l ib\site-packages (from pipenv) (20.2.3) Requirement already satisfied: certifi in c:\program files (x86)\python38-32\lib \site-packages (from pipenv) (2020.6.20) Requirement already satisfied: distlib<1,>=0.3.1 in c:\program files (x86)\pytho n38-32\lib\site-packages (from virtualenv->pipenv) (0.3.1) Requirement already satisfied: six<2,>=1.9.0 in c:\program files (x86)\python38- 32\lib\site-packages (from virtualenv->pipenv) (1.15.0) Requirement already satisfied: appdirs<2,>=1.4.3 in c:\program files (x86)\pytho n38-32\lib\site-packages (from virtualenv->pipenv) (1.4.4) Requirement already satisfied: filelock<4,>=3.0.0 in c:\program files (x86)\pyth on38-32\lib\site-packages (from virtualenv->pipenv) (3.0.12) Installing collected packages: pipenv Successfully installed pipenv-2020.8.13 Administrator at rcplt MINGW64 /c/dev_env $ ls a.txt dd.py notes.txt pipenv_help.txt Administrator at rcplt MINGW64 /c/dev_env $ pipenv install pytz Traceback (most recent call last): File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\python.py", line 618, in parse_executable result_version = get_python_version(path) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\utils.py", line 105, in get_python_version c = subprocess.Popen(version_cmd, **subprocess_kwargs) File "c:\program files (x86)\python38-32\lib\subprocess.py", line 854, in __in it__ self._execute_child(args, executable, preexec_fn, close_fds, File "c:\program files (x86)\python38-32\lib\subprocess.py", line 1307, in _ex ecute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files (x86)\python38-32\lib\runpy.py", line 194, in _run_modu le_as_main return _run_code(code, main_globals, None, File "c:\program files (x86)\python38-32\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Program Files (x86)\Python38-32\Scripts\pipenv.exe\__main__.py", line 7, in File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 829, in __call__ return self.main(*args, **kwargs) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 782, in main rv = self.invoke(ctx) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 610, in invoke return callback(*args, **kwargs) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \decorators.py", line 73, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \core.py", line 610, in invoke return callback(*args, **kwargs) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\click \decorators.py", line 21, in new_func return f(get_current_context(), *args, **kwargs) File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\cli\command. py", line 232, in install retcode = do_install( File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\core.py", li ne 1920, in do_install ensure_project( File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\core.py", li ne 576, in ensure_project ensure_virtualenv( File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\core.py", li ne 498, in ensure_virtualenv python = ensure_python(three=three, python=python) File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\core.py", li ne 388, in ensure_python path_to_python = find_a_system_python(python) File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\core.py", li ne 350, in find_a_system_python return next(iter(finder.find_all_python_versions()), None) File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\vendor\pytho nfinder\pythonfinder.py", line 312, in find_all_python_versions python_version_dict = getattr(self.system_path, "python_version_dict", {}) File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\vendor\pytho nfinder\pythonfinder.py", line 120, in system_path self._system_path = self.create_system_path() File "c:\program files (x86)\python38-32\lib\site-packages\pipenv\vendor\pytho nfinder\pythonfinder.py", line 82, in create_system_path return pyfinder_path.SystemPath.create( File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\path.py", line 682, in create instance = instance._run_setup() File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\path.py", line 233, in _run_setup new_instance = new_instance._setup_windows() File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\path.py", line 411, in _setup_windows windows_finder = WindowsFinder.create() File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\windows.py", line 146, in create return cls() File "", line 13, in __init__ File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\windows.py", line 113, in get_versions versions[py_version.version_tuple[:5]] = base_dir File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\python.py", line 365, in __getattribute__ result = super(PythonVersion, self).__getattribute__(key) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\python.py", line 430, in version_tuple self.patch, File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\python.py", line 375, in __getattribute__ instance_dict = self.parse_executable(executable) File "C:\Program Files (x86)\Python38-32\Lib\site-packages\pipenv\vendor\pytho nfinder\models\python.py", line 620, in parse_executable raise ValueError("Not a valid python path: %r" % path) ValueError: Not a valid python path: 'C:/ProgramData/Anaconda3/python.exe' Administrator at rcplt MINGW64 /c/dev_env $ 5~ Administrator at rcplt MINGW64 /c/dev_env $ From stephane at sdf.org Sat Sep 26 15:36:48 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sun, 27 Sep 2020 03:36:48 +0800 Subject: Use of a variable in parent loop References: Message-ID: 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 ? > 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). In Perl, use strict will break any non-strict code. So each is free to chose between strict and not strict. Anyway, there's no perfect language, the point is to know it. It's just confusing I still have to declare or not declare an object depending on the action I have with it. From 2QdxY4RzWzUUiLuE at potatochowder.com Sat Sep 26 23:07:27 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Sat, 26 Sep 2020 22:07:27 -0500 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: <20200927030727.GA38645@scrozzle> 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 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. From raju.mailinglists at gmail.com Sat Sep 26 23:59:47 2020 From: raju.mailinglists at gmail.com (kamaraju kusumanchi) Date: Sat, 26 Sep 2020 23:59:47 -0400 Subject: check dependencies of a pypi package Message-ID: How can I check the dependencies of a pypi package without installing it? For example, looking at the pandas 1.1.2 package in https://pypi.org/project/pandas/1.1.2/, is there a way to determine the numpy version it depends upon without installing the package? thanks raju -- Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog From stephane at sdf.org Sun Sep 27 03:15:15 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sun, 27 Sep 2020 15:15:15 +0800 Subject: Use of a variable in parent loop References: Message-ID: <3pq54h-8a7.ln1@superman.unices.org> 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. From stephane at sdf.org Sun Sep 27 03:18:44 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sun, 27 Sep 2020 15:18:44 +0800 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> Message-ID: On 2020-09-27, 2QdxY4RzWzUUiLuE at potatochowder.com <2QdxY4RzWzUUiLuE at 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. From rosuav at gmail.com Sun Sep 27 07:15:30 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Sep 2020 21:15:30 +1000 Subject: Use of a variable in parent loop In-Reply-To: <3pq54h-8a7.ln1@superman.unices.org> References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: 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 From rosuav at gmail.com Sun Sep 27 07:16:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 27 Sep 2020 21:16:54 +1000 Subject: Use of a variable in parent loop In-Reply-To: References: <20200927030727.GA38645@scrozzle> Message-ID: On Sun, Sep 27, 2020 at 9:01 PM Stephane Tougard via Python-list wrote: > > On 2020-09-27, 2QdxY4RzWzUUiLuE at potatochowder.com <2QdxY4RzWzUUiLuE at 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 From ml_news at posteo.de Sun Sep 27 07:36:44 2020 From: ml_news at posteo.de (Manfred Lotz) Date: Sun, 27 Sep 2020 13:36:44 +0200 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> Message-ID: <20200927133644.793215d2@arcor.com> On Sun, 27 Sep 2020 15:18:44 +0800 Stephane Tougard wrote: > On 2020-09-27, 2QdxY4RzWzUUiLuE at potatochowder.com > <2QdxY4RzWzUUiLuE at 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 From 2QdxY4RzWzUUiLuE at potatochowder.com Sun Sep 27 08:17:10 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Sun, 27 Sep 2020 07:17:10 -0500 Subject: Use of a variable in parent loop In-Reply-To: References: <20200927030727.GA38645@scrozzle> Message-ID: <20200927121710.GB38645@scrozzle> 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. From pfeiffer at cs.nmsu.edu Sun Sep 27 12:47:20 2020 From: pfeiffer at cs.nmsu.edu (Joe Pfeiffer) Date: Sun, 27 Sep 2020 10:47:20 -0600 Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: <1blfgvmajr.fsf@pfeifferfamily.net> 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. From mats at python.org Sun Sep 27 13:08:55 2020 From: mats at python.org (Mats Wichmann) Date: Sun, 27 Sep 2020 11:08:55 -0600 Subject: FW: pipenv has issues In-Reply-To: <007601d693b9$a3f39210$ebdab630$@gmail.com> References: <005f01d693b8$80cbbe30$82633a90$@gmail.com> <007601d693b9$a3f39210$ebdab630$@gmail.com> Message-ID: <6b4d765f-ac4e-0685-57de-7013401bb457@python.org> 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 From avigross at verizon.net Sun Sep 27 16:17:34 2020 From: avigross at verizon.net (Avi Gross) Date: Sun, 27 Sep 2020 16:17:34 -0400 Subject: Use of a variable in parent loop In-Reply-To: <20200927121710.GB38645@scrozzle> References: <20200927030727.GA38645@scrozzle> <20200927121710.GB38645@scrozzle> Message-ID: <018301d6950b$3ce04d40$b6a0e7c0$@verizon.net> 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 2QdxY4RzWzUUiLuE at potatochowder.com Sent: Sunday, September 27, 2020 8:17 AM To: python-list at 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.python.org/mailman/listinfo/python-list From auriocus at gmx.de Sun Sep 27 16:42:48 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sun, 27 Sep 2020 22:42:48 +0200 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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 From Richard at Damon-Family.org Sun Sep 27 16:57:56 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 27 Sep 2020 16:57:56 -0400 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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 From cs at cskk.id.au Sun Sep 27 17:24:07 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 28 Sep 2020 07:24:07 +1000 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: <20200927212407.GA62780@cskk.homeip.net> 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 From brenners at bezeqint.net Sat Sep 26 22:33:14 2020 From: brenners at bezeqint.net (Hylton) Date: Sun, 27 Sep 2020 05:33:14 +0300 Subject: pip update fails Message-ID: 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: Vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ? 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 ? From grant.b.edwards at gmail.com Sun Sep 27 10:57:35 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sun, 27 Sep 2020 14:57:35 -0000 (UTC) Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: 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... From tjreedy at udel.edu Sun Sep 27 11:35:24 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Sep 2020 11:35:24 -0400 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: 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 From stephane at sdf.org Sun Sep 27 05:27:30 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sun, 27 Sep 2020 17:27:30 +0800 Subject: Use of a variable in parent loop References: Message-ID: <2h264h-fpo.ln1@superman.unices.org> 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. From stephane at sdf.org Sun Sep 27 09:23:01 2020 From: stephane at sdf.org (Stephane Tougard) Date: Sun, 27 Sep 2020 21:23:01 +0800 Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: 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 !!! From HughPittman at outlook.com Sun Sep 27 17:43:10 2020 From: HughPittman at outlook.com (Hugh Pittman) Date: Sun, 27 Sep 2020 21:43:10 +0000 Subject: Can't install Python Message-ID: 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 From python at mrabarnett.plus.com Sun Sep 27 18:34:01 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 27 Sep 2020 23:34:01 +0100 Subject: Use of a variable in parent loop In-Reply-To: <2h264h-fpo.ln1@superman.unices.org> References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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. From python at mrabarnett.plus.com Sun Sep 27 18:48:45 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 27 Sep 2020 23:48:45 +0100 Subject: Can't install Python In-Reply-To: References: Message-ID: <481671ac-c793-40e6-281c-199b7093b95c@mrabarnett.plus.com> 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. From rosuav at gmail.com Sun Sep 27 18:54:33 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 28 Sep 2020 08:54:33 +1000 Subject: Use of a variable in parent loop In-Reply-To: <2h264h-fpo.ln1@superman.unices.org> References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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 From rosuav at gmail.com Sun Sep 27 18:55:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 28 Sep 2020 08:55:54 +1000 Subject: Use of a variable in parent loop In-Reply-To: <20200927133644.793215d2@arcor.com> References: <20200927030727.GA38645@scrozzle> <20200927133644.793215d2@arcor.com> Message-ID: 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, 2QdxY4RzWzUUiLuE at potatochowder.com > > <2QdxY4RzWzUUiLuE at 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 From greg.ewing at canterbury.ac.nz Sun Sep 27 19:50:40 2020 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 28 Sep 2020 12:50:40 +1300 Subject: Use of a variable in parent loop In-Reply-To: <2h264h-fpo.ln1@superman.unices.org> References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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 From mats at python.org Sun Sep 27 20:28:43 2020 From: mats at python.org (Mats Wichmann) Date: Sun, 27 Sep 2020 18:28:43 -0600 Subject: Can't install Python In-Reply-To: <481671ac-c793-40e6-281c-199b7093b95c@mrabarnett.plus.com> References: <481671ac-c793-40e6-281c-199b7093b95c@mrabarnett.plus.com> Message-ID: <276d9592-0c15-0218-b644-c1b604396713@python.org> 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. From stephane at sdf.org Sun Sep 27 22:29:13 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:29:13 +0800 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> <20200927121710.GB38645@scrozzle> <018301d6950b$3ce04d40$b6a0e7c0$@verizon.net> Message-ID: 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. From stephane at sdf.org Sun Sep 27 22:47:22 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:47:22 +0800 Subject: Use of a variable in parent loop References: Message-ID: 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. From stephane at sdf.org Sun Sep 27 22:53:11 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:53:11 +0800 Subject: Use of a variable in parent loop References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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. From stephane at sdf.org Sun Sep 27 22:56:01 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:56:01 +0800 Subject: Use of a variable in parent loop References: <20200927212407.GA62780@cskk.homeip.net> Message-ID: <1vv74h-6gd.ln1@superman.unices.org> 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' From ml_news at posteo.de Sun Sep 27 22:42:42 2020 From: ml_news at posteo.de (Manfred Lotz) Date: Mon, 28 Sep 2020 04:42:42 +0200 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> <20200927133644.793215d2@arcor.com> Message-ID: <20200928044242.4679ddf4@arcor.com> 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. From python at mrabarnett.plus.com Sun Sep 27 23:33:09 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 28 Sep 2020 04:33:09 +0100 Subject: Use of a variable in parent loop In-Reply-To: References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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 From rosuav at gmail.com Sun Sep 27 23:43:12 2020 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 28 Sep 2020 13:43:12 +1000 Subject: Use of a variable in parent loop In-Reply-To: References: <20200927030727.GA38645@scrozzle> <20200927121710.GB38645@scrozzle> <018301d6950b$3ce04d40$b6a0e7c0$@verizon.net> Message-ID: 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 From cs at cskk.id.au Mon Sep 28 00:08:28 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 28 Sep 2020 14:08:28 +1000 Subject: Use of a variable in parent loop In-Reply-To: References: Message-ID: <20200928040828.GA13822@cskk.homeip.net> 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 From miked at dewhirst.com.au Mon Sep 28 01:22:36 2020 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Mon, 28 Sep 2020 15:22:36 +1000 Subject: Use of a variable in parent loop In-Reply-To: <1vv74h-6gd.ln1@superman.unices.org> References: <20200927212407.GA62780@cskk.homeip.net> <1vv74h-6gd.ln1@superman.unices.org> Message-ID: <8856451f-e242-3eb7-5b1b-147c77f3d6f6@dewhirst.com.au> 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. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From stephane at sdf.org Mon Sep 28 01:38:08 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 13:38:08 +0800 Subject: Use of a variable in parent loop References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: <0f984h-rrh.ln1@superman.unices.org> 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 From stephane at sdf.org Mon Sep 28 01:39:08 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 13:39:08 +0800 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> <20200927133644.793215d2@arcor.com> <20200928044242.4679ddf4@arcor.com> Message-ID: 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. From stephane at sdf.org Mon Sep 28 01:47:00 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 13:47:00 +0800 Subject: Use of a variable in parent loop References: <20200928040828.GA13822@cskk.homeip.net> Message-ID: 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). From stephane at sdf.org Mon Sep 28 02:26:02 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 14:26:02 +0800 Subject: Use of a variable in parent loop References: <20200927212407.GA62780@cskk.homeip.net> <1vv74h-6gd.ln1@superman.unices.org> <8856451f-e242-3eb7-5b1b-147c77f3d6f6@dewhirst.com.au> Message-ID: 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. From auriocus at gmx.de Mon Sep 28 04:05:58 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Mon, 28 Sep 2020 10:05:58 +0200 Subject: Use of a variable in parent loop In-Reply-To: <0f984h-rrh.ln1@superman.unices.org> References: <2h264h-fpo.ln1@superman.unices.org> <0f984h-rrh.ln1@superman.unices.org> Message-ID: 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 it works fine. > > #include > > int main(int argc, char * argv[]) > { > if(1 == 1) > ; No. You put ";", that's not nothing. Christian From ml_news at posteo.de Mon Sep 28 07:48:03 2020 From: ml_news at posteo.de (Manfred Lotz) Date: Mon, 28 Sep 2020 13:48:03 +0200 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> <20200927133644.793215d2@arcor.com> <20200928044242.4679ddf4@arcor.com> Message-ID: <20200928134803.7b69c45a@arcor.com> 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 > >> > > >> ... > >> > (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. It is amazing that I just didn't see it. I am a bad at spotting things. Sigh. Anyway: https://docs.python.org/3/tutorial/controlflow.html#pass-statements -- Manfred From stephane at sdf.org Sun Sep 27 17:20:20 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 05:20:20 +0800 Subject: Use of a variable in parent loop References: <20200927030727.GA38645@scrozzle> <20200927133644.793215d2@arcor.com> Message-ID: 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. From stephane at sdf.org Sun Sep 27 17:26:42 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 05:26:42 +0800 Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> <1blfgvmajr.fsf@pfeifferfamily.net> Message-ID: 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 suck it up and learn to > program in the language as intended. Not that I disagree, but coming from twenty years of Perl, it means where nobody really understands the code of anybody else, that never has really been a concern to me. 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 break it. From stephane at sdf.org Sun Sep 27 22:40:58 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:40:58 +0800 Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: 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. While it provided his > employees with plenty of amusement, he could never get the programs to > work right... 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 Lisp ... as long as it works and they are able to maintain it, I'm happy as well. Nothing is more enjoyable than a platform running a variety of languages and technologies, working all together. And FYI, I've done this way since 25 years and I count a few good success in my career. Practically, my way of doing things works is at least as well as any. From stephane at sdf.org Sun Sep 27 22:48:49 2020 From: stephane at sdf.org (Stephane Tougard) Date: Mon, 28 Sep 2020 10:48:49 +0800 Subject: Use of a variable in parent loop References: <2h264h-fpo.ln1@superman.unices.org> Message-ID: 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. From paarjun234 at gmail.com Sun Sep 27 23:45:40 2020 From: paarjun234 at gmail.com (Arjun_tech) Date: Mon, 28 Sep 2020 09:15:40 +0530 Subject: check dependencies of a pypi package In-Reply-To: References: Message-ID: just go to command prompt and type pip install pandas. it will install the latest version with all the dependencies. On Sun, 27 Sep 2020 at 09:30, kamaraju kusumanchi < raju.mailinglists at gmail.com> wrote: > How can I check the dependencies of a pypi package without installing it? > > For example, looking at the pandas 1.1.2 package in > https://pypi.org/project/pandas/1.1.2/, is there a way to determine > the numpy version it depends upon without installing the package? > > thanks > raju > -- > Kamaraju S Kusumanchi | http://raju.shoutwiki.com/wiki/Blog > -- > https://mail.python.org/mailman/listinfo/python-list > From grant.b.edwards at gmail.com Mon Sep 28 13:40:04 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 28 Sep 2020 17:40:04 -0000 (UTC) Subject: Use of a variable in parent loop References: Message-ID: 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 and do not break the indentation. Huh? What is emacs doing to "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. It works for me. > emacs with python-mode has been and likely still is used by some > experienced python programmers. I've been usnig emacs in python-mode for almost 20 years. I've never had any problems with. -- Grant From grant.b.edwards at gmail.com Mon Sep 28 13:47:33 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 28 Sep 2020 17:47:33 -0000 (UTC) Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> <1blfgvmajr.fsf@pfeifferfamily.net> Message-ID: 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 break it. I don't understand what you expect emacs 'indent-region' to do. With token-delimited languages, it will re-do the indentation of a block with respect to the first selected line. That's possible because for C et al. indentation can be deduced from keywords and block delimiters. That's simply not possible with Python because indentation _is_ the delimiters. Expecting Python to know how your code is supposed to be indented would be like entering a block of C code with no curly braces and then expecting emacs to know where to insert them so that the code does what you want. You can increase/decrease indentation by selecting a block and hitting C-c < or C-c >. -- Grant From eryksun at gmail.com Mon Sep 28 18:19:44 2020 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 28 Sep 2020 17:19:44 -0500 Subject: Can't install Python In-Reply-To: <7qv3nf1krhnd9e4ol5qqdl8012nj0b2q8m@4ax.com> References: <7qv3nf1krhnd9e4ol5qqdl8012nj0b2q8m@4ax.com> Message-ID: On 9/28/20, Dennis Lee Bieber wrote: > > Python is not a GUI. You do not "click on the phyton.exe file" (sic). > You open a command shell and, in a proper install which sets up the PATH > environment variable, enter "python" as the command to execute. You can run python.exe directly from Explorer -- typically from the start menu or the Win+R run dialog. The only issue is that by default the console that python.exe creates will close when the Python shell exits. If you need to keep the console output around, you can simply spawn a system shell before exiting, e.g. >>> subprocess.Popen('pwsh'); exit() From eryksun at gmail.com Mon Sep 28 18:43:20 2020 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 28 Sep 2020 17:43:20 -0500 Subject: pip update fails In-Reply-To: References: Message-ID: On 9/28/20, Dennis Lee Bieber wrote: > On Sun, 27 Sep 2020 05:33:14 +0300, "Hylton" > declaimed the following: > >> "C:\Users\user\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\ >> distlib\scripts.py", line 386, in _get_launcher > > That path seems to imply that you have a Python installed for single > user... No, it implies that the pip package was installed for just the current user via, for example, `py -m ensurepip --user`. Per-user package installs in 3.8 go in "%APPDATA%\Python\Python38\site-packages" (roaming appdata). For a per-user installation of Python 3.8, pip would be installed in "%LOCALAPPDATA%\Programs\Python\Python38\site-packages" (local appdata programs). From python at bladeshadow.org Mon Sep 28 20:48:13 2020 From: python at bladeshadow.org (Python) Date: Mon, 28 Sep 2020 19:48:13 -0500 Subject: Use of a variable in parent loop In-Reply-To: References: <20200927030727.GA38645@scrozzle> Message-ID: <20200929004813.GC30895@bladeshadow.org> On Sun, Sep 27, 2020 at 03:18:44PM +0800, Stephane Tougard via Python-list wrote: > On 2020-09-27, 2QdxY4RzWzUUiLuE at potatochowder.com <2QdxY4RzWzUUiLuE at 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. No it's not... those two words mean different things, and the difference actually matters. If you use strict in perl you need BOTH (at least, if you want your variable to actually have a value): my $foo; $foo = 1; The declaration and definition serve different purposes. You can combine them into one statement for syntactic convenience, much as you can in C/C++, but nevertheless both functions still exist and are explicitly expressed. In Python, you almost always only need the definition. From soyeomul at doraji.xyz Mon Sep 28 23:25:10 2020 From: soyeomul at doraji.xyz (=?utf-8?B?7Zmp67OR7Z2s?=) Date: Tue, 29 Sep 2020 12:25:10 +0900 Subject: Use of a variable in parent loop References: <3pq54h-8a7.ln1@superman.unices.org> Message-ID: 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 Lisp ... as long as it works > and they are able to maintain it, I'm happy as well. > > Nothing is more enjoyable than a platform running a variety of languages > and technologies, working all together. > > And FYI, I've done this way since 25 years and I count a few good > success in my career. Practically, my way of doing things works is at least > as well as any. Maybe you seems like lisp or emacs lisp just i think, not serious... Sincerely, Byung-Hee from South Korea -- ^????? _????_ ?????_^))// From singh.bhashkar at gmail.com Tue Sep 29 08:13:16 2020 From: singh.bhashkar at gmail.com (bhashkar prakash Singh) Date: Tue, 29 Sep 2020 17:43:16 +0530 Subject: stackless python 2.7.9 and openssl-1.1.1g In-Reply-To: References: Message-ID: >Get the source of python.org python 2.7.18 and you will find that builds without patches >against OpenSSL 1.1.1g. >I would then diff the C files that do not compile in stackless to look for the required fixes. Thanks Barry. Some warnings were left in code after patching cpython files. After fixing them, all those errors are gone. Now I have another issue. now the threading module in python is not found. I don't see this is anyway related to openssl upgrade but this issue is not occurred where openssl has not been upgraded. File "/usr/lib/python2.7/site-packages/websocket/__init__.py", line 22, in from ._abnf import * File "/usr/lib/python2.7/site-packages/websocket/_abnf.py", line 30, in from threading import Lock File "threading.py", line 6, in import thread ImportError: No module named thread Could you give any clue on this ? Thanks & Regards, Bhashkar On Fri, Sep 25, 2020 at 12:43 PM Barry wrote: > > > On 25 Sep 2020, at 03:28, bhashkar prakash Singh > wrote: > > ? > Hi Barry, > > Thanks for your response. > > I am not an expert in python code. Could you please elaborate a bit more > on this. Which cpython code are you referring to? > did you modify other files also apart from _hashopenssl.c and _ssl.c to > work with openssl-1.1.1g ? > > > Get the source of python.org python 2.7.18 and you will find that builds > without patches against OpenSSL 1.1.1g. > > I would then diff the C files that do not compile in stackless to look for > the required fixes. > > Barry > > > Regards, > Bhashkar > > On Fri, Sep 25, 2020 at 2:40 AM Barry Scott > wrote: > >> >> >> > On 24 Sep 2020, at 19:21, bhashkar prakash Singh < >> singh.bhashkar at gmail.com> wrote: >> > >> > Hi, >> > >> > I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. >> > I just upgraded the Openssl version to 1.1.1g, due to which python >> > compilation started failing. So, I patched _hashopenssl.c and _ssl.c >> file >> > in Python Modules as per new openssl to make compilation successful. >> > But when I run my image on target HW, I am getting below errors. It >> > looks like Openssl 1.1.1g libraries are not linked to Python. >> > I am struggling with this issue since many days. Looks like something I >> > missed in my patching. Could someone please help on this. >> >> I recently built python 2.7.18 against openssl 1.1.1g without issue. >> Maybe look see what is in the cpython code that works fine. >> >> Barry >> > Thanks & Regards, >> > Bhashkar >> > -- >> > https://mail.python.org/mailman/listinfo/python-list >> > >> >> From alexandre.fournel at sia-partners.com Tue Sep 29 10:11:51 2020 From: alexandre.fournel at sia-partners.com (Alexandre FOURNEL) Date: Tue, 29 Sep 2020 07:11:51 -0700 (PDT) Subject: Logging lib doesn't work Message-ID: Hi all ! I'm trying to use logging lib in my python program. To try this lib, I am using basic code like : "import logging logging.basicConfig(filename='pont.txt', filemode='w',format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %H:%M:%S', level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too')" But between 2 execution, I have to open a new terminal to get new data in my file pont.txt. Do you know why ? Thanks Alexandre From barry at barrys-emacs.org Tue Sep 29 10:27:45 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 29 Sep 2020 15:27:45 +0100 Subject: stackless python 2.7.9 and openssl-1.1.1g In-Reply-To: References: Message-ID: <5881541B-DC2E-4EC2-99C8-230DF567A675@barrys-emacs.org> > On 29 Sep 2020, at 13:13, bhashkar prakash Singh wrote: > > >Get the source of python.org python 2.7.18 and you will find that builds without patches >against OpenSSL 1.1.1g. > >I would then diff the C files that do not compile in stackless to look for the required fixes. > > Thanks Barry. Some warnings were left in code after patching cpython files. After fixing them, all those errors are gone. > > Now I have another issue. now the threading module in python is not found. > I don't see this is anyway related to openssl upgrade but this issue is not occurred where openssl has not been upgraded. When working on a project like this I tend to write a shell script that automates the build so that I repeat the build in the future. Example (untested) rm -rf tmp.build mkdir tmp.build cd tmp.build tar xf ../Python-xxx.tar.gz ./configure --with-openssl=... make Then I can prove to myself that just changing the openssl changes the build. And I run that script and create a log of the build output $ ./do-build 2>&1 | tee build.log Then I can go back and check what happened. > > File "/usr/lib/python2.7/site-packages/websocket/__init__.py", line 22, in > from ._abnf import * > File "/usr/lib/python2.7/site-packages/websocket/_abnf.py", line 30, in > from threading import Lock > File "threading.py", line 6, in > import thread > ImportError: No module named thread > > Could you give any clue on this ? The cool thing about open source is that you have the source. When hitting a problem like this I tend to search the sources for where, in this case, thread might be. That lead me the Python/thread.c in cpython. Is that the same in stackless? Does the build compile that file? It seems that if you are missing pthreads then its not going to work. When you ran configure did it find pthread.h? Are there any "not found" reports in configure output? Barry > > Thanks & Regards, > Bhashkar > > On Fri, Sep 25, 2020 at 12:43 PM Barry > wrote: > > >> On 25 Sep 2020, at 03:28, bhashkar prakash Singh > wrote: >> >> ? >> Hi Barry, >> >> Thanks for your response. >> >> I am not an expert in python code. Could you please elaborate a bit more on this. Which cpython code are you referring to? >> did you modify other files also apart from _hashopenssl.c and _ssl.c to work with openssl-1.1.1g ? > > Get the source of python.org python 2.7.18 and you will find that builds without patches against OpenSSL 1.1.1g. > > I would then diff the C files that do not compile in stackless to look for the required fixes. > > Barry > >> >> Regards, >> Bhashkar >> >> On Fri, Sep 25, 2020 at 2:40 AM Barry Scott > wrote: >> >> >> > On 24 Sep 2020, at 19:21, bhashkar prakash Singh > wrote: >> > >> > Hi, >> > >> > I am using stackless Python 2.7.9 in my project and openssl-1.0.2q. >> > I just upgraded the Openssl version to 1.1.1g, due to which python >> > compilation started failing. So, I patched _hashopenssl.c and _ssl.c file >> > in Python Modules as per new openssl to make compilation successful. >> > But when I run my image on target HW, I am getting below errors. It >> > looks like Openssl 1.1.1g libraries are not linked to Python. >> > I am struggling with this issue since many days. Looks like something I >> > missed in my patching. Could someone please help on this. >> >> I recently built python 2.7.18 against openssl 1.1.1g without issue. >> Maybe look see what is in the cpython code that works fine. >> >> Barry >> > Thanks & Regards, >> > Bhashkar >> > -- >> > https://mail.python.org/mailman/listinfo/python-list >> > >> From barry at barrys-emacs.org Tue Sep 29 10:33:07 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 29 Sep 2020 15:33:07 +0100 Subject: Logging lib doesn't work In-Reply-To: References: Message-ID: <0C5B13A0-9297-49AF-AC84-99E7AA0A8FB5@barrys-emacs.org> > On 29 Sep 2020, at 15:11, Alexandre FOURNEL wrote: > > Hi all ! > > I'm trying to use logging lib in my python program. > > To try this lib, I am using basic code like : > > "import logging > logging.basicConfig(filename='pont.txt', filemode='w',format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %H:%M:%S', level=logging.DEBUG) Do you want to over write the file each run? That is what 'w' says you want. Maybe try 'a' - append? > logging.debug('This message should go to the log file') > logging.info('So should this') > logging.warning('And this, too')" > > But between 2 execution, I have to open a new terminal to get new data in my file pont.txt. Do you know why ? Each time you run it the time stamps change right? Barry > > Thanks > > Alexandre > -- > https://mail.python.org/mailman/listinfo/python-list > From alexandre.fournel at sia-partners.com Tue Sep 29 10:35:16 2020 From: alexandre.fournel at sia-partners.com (Alexandre FOURNEL) Date: Tue, 29 Sep 2020 07:35:16 -0700 (PDT) Subject: Logging lib doesn't work In-Reply-To: References: <0C5B13A0-9297-49AF-AC84-99E7AA0A8FB5@barrys-emacs.org> Message-ID: Le mardi 29 septembre 2020 ? 16:33:39 UTC+2, Barry Scott a ?crit?: > > On 29 Sep 2020, at 15:11, Alexandre FOURNEL wrote: > > > > Hi all ! > > > > I'm trying to use logging lib in my python program. > > > > To try this lib, I am using basic code like : > > > > "import logging > > logging.basicConfig(filename='pont.txt', filemode='w',format='%(asctime)s %(message)s', datefmt='%d/%m/%Y %H:%M:%S', level=logging.DEBUG) > Do you want to over write the file each run? > That is what 'w' says you want. Maybe try 'a' - append? > > logging.debug('This message should go to the log file') > > logging.info('So should this') > > logging.warning('And this, too')" > > > > But between 2 execution, I have to open a new terminal to get new data in my file pont.txt. Do you know why ? > Each time you run it the time stamps change right? > > Barry > > > > > > Thanks > > > > Alexandre > > -- > > https://mail.python.org/mailman/listinfo/python-list > > If I use also "a" instead of "w", it doesn't work ... It works only when I use a new terminal (I am using Spyder to code) From barpasc at yahoo.com Tue Sep 29 10:42:32 2020 From: barpasc at yahoo.com (pascal z) Date: Tue, 29 Sep 2020 07:42:32 -0700 (PDT) Subject: python if and same instruction line not working Message-ID: I need to change the script commented out to the one not commented out. Why? # for x in sorted (fr, key=str.lower): # tmpstr = x.rpartition(';')[2] # if x != csv_contents and tmpstr == "folder\n": # csv_contentsB += x # elif x != csv_contents and tmpstr == "files\n": # csv_contentsC += x for x in sorted (fr, key=str.lower): if x != csv_contents: tmpstr = x.rpartition(';')[2] if tmpstr == "folder\n": csv_contentsB += x elif tmpstr == "file\n": csv_contentsC += x From David.Raymond at tomtom.com Tue Sep 29 11:16:42 2020 From: David.Raymond at tomtom.com (David Raymond) Date: Tue, 29 Sep 2020 15:16:42 +0000 Subject: [RELEASE] Python 3.8.6 is now available In-Reply-To: <30EA5AA1-44DB-4166-AFB2-FDD1298E437B@langa.pl> References: <30EA5AA1-44DB-4166-AFB2-FDD1298E437B@langa.pl> Message-ID: > Python 3.8.6 is the sixth maintenance release of Python 3.8. Go get it here: > https://www.python.org/downloads/release/python-386/ Just a quick note that there still seem to be a few places on the website which are still showing 3.8.5 as the latest release. (Looking at it with Firefox on Windows) On the main page www.python.org it has 3.8.6 down in the latest news section, and a direct link in the little download box right above that. But if you hover over the big "Downloads" tab at the top it gives a big 3.8.5 button If you click on that Downloads tab and go to www.python.org/downloads, again there's a big gold button for 3.8.5, and if you scroll down to the "Looking for a specific release?" section there is no 3.8.6 visible. The most recent line is 3.5.10 from Sept 5th From python at mrabarnett.plus.com Tue Sep 29 11:27:43 2020 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 29 Sep 2020 16:27:43 +0100 Subject: python if and same instruction line not working In-Reply-To: References: Message-ID: On 2020-09-29 15:42, pascal z via Python-list wrote: > I need to change the script commented out to the one not commented out. Why? > > # for x in sorted (fr, key=str.lower): > # tmpstr = x.rpartition(';')[2] > # if x != csv_contents and tmpstr == "folder\n": > # csv_contentsB += x > # elif x != csv_contents and tmpstr == "files\n": > # csv_contentsC += x > > for x in sorted (fr, key=str.lower): > if x != csv_contents: > tmpstr = x.rpartition(';')[2] > if tmpstr == "folder\n": > csv_contentsB += x > elif tmpstr == "file\n": > csv_contentsC += x > You haven't defined what you mean by "not working" for any test values to try, but I notice that the commented code has "files\n" whereas the uncommented code has "file\n". From pierre.bonville49 at gmail.com Tue Sep 29 09:48:31 2020 From: pierre.bonville49 at gmail.com (Pierre Bonville) Date: Tue, 29 Sep 2020 15:48:31 +0200 Subject: tkinter and input() Message-ID: Hello everybody, I have a small problem with the method .quit() of tkinter. Below is a sketch of a much larger program, which shows the problem. I would like to run the main program but keeping the tk window on the screen until the end. Presently, execution stops after the first "plot" instruction. I don't understand why. The program runs fine if one replaces "quit" by "destroy", but then the tk window disappears. Is there a solution? Thanks in advance for any answer, Regards, P.Bonville # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np from tkinter import * def init(): global vit def print_par(): global vitt vitt = vit.get() print("velocity= ",vitt," cm/s") fen.quit() vit = "" fen = Tk() vit0 = StringVar() Label(fen, text = "velocity (cm/s): ").grid(row=0) vit = Entry(fen,text = vit0) vit0.set(7.) vit.grid(row=0, column=1) button = Button(fen, text='OK', command=print_par).grid(row=5,column=0) fen.mainloop() vit = float(vitt) init() print(vit) x = np.arange(0,4*np.pi,0.1) y = np.sin(x) for i in range(0,10): plt.plot(x,y) plt.show() re = input("Hit RETURN to continue:") From ronviki_99 at yahoo.com Tue Sep 29 18:31:18 2020 From: ronviki_99 at yahoo.com (Ron Villarreal) Date: Tue, 29 Sep 2020 22:31:18 +0000 (UTC) Subject: Problem References: <652624127.90690.1601418678143.ref@mail.yahoo.com> Message-ID: <652624127.90690.1601418678143@mail.yahoo.com> Tried to open Python 3.8. I have Windows 10. Icon won?t open. From tjreedy at udel.edu Tue Sep 29 19:34:29 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 29 Sep 2020 19:34:29 -0400 Subject: tkinter and input() In-Reply-To: References: Message-ID: On 9/29/2020 9:48 AM, Pierre Bonville wrote: > I have a small problem with the method .quit() of tkinter. What problem? It works for me (3.9 on Win 10). >>> import tkinter as tk >>> r = tk.Tk() >>> b = tk.Button(r, text= r.quit) >>> b = tk.Button(r, text='quit', command=r.quit) >>> b.pack() >>> r.mainloop() # This blocks until press button. >>> # Root window with button is still displayed. Your program has a lot more stuff extraneous to your question and requires matplotlib and numpy. Posted code should be a minimal reproducible example such as above. Try adding a few lines at a time until it breaks or does what you want. -- Terry Jan Reedy From rob at despammer.com Wed Sep 30 08:27:43 2020 From: rob at despammer.com (RobH) Date: Wed, 30 Sep 2020 13:27:43 +0100 Subject: error in install.sh Message-ID: I had to do a reinstall of my linux system due to a faulty ssd, and have a problem with a install.sh script.The said script is included in with lcd files. which I downloaded from github. When I run ./install.sh, it fails at ./install.sh: line 34: syntax error: unexpected end of file. I don't know what the syntax should be here; These are the last 4 lines in the script, and if I count the spaces then: echo "Should be now all finished. Please press any key to now reboot. After rebooting run" echo "'sudo python demo_lcd.py' from this directory" read -n1 -s <<<<<<<<<<<<<<<<<<<<< I think this is the line in question sudo reboot Thanks From 2QdxY4RzWzUUiLuE at potatochowder.com Wed Sep 30 08:49:13 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Wed, 30 Sep 2020 07:49:13 -0500 Subject: error in install.sh In-Reply-To: References: Message-ID: <20200930124913.GE128690@scrozzle> On 2020-09-30 at 13:27:43 +0100, RobH wrote: > I had to do a reinstall of my linux system due to a faulty ssd, and have a > problem with a install.sh script.The said script is included in with lcd > files. which I downloaded from github. > > When I run ./install.sh, it fails at > ./install.sh: line 34: syntax error: unexpected end of file. > > I don't know what the syntax should be here; > > These are the last 4 lines in the script, and if I count the spaces then: > > echo "Should be now all finished. Please press any key to now reboot. After > rebooting run" > echo "'sudo python demo_lcd.py' from this directory" > read -n1 -s <<<<<<<<<<<<<<<<<<<<< I think this is the line in question > sudo reboot I'm not sure that this is a Python problem, but usually "unexpected end of file" errors are due to missing or mismatched quotes. Basically, the interpreter (Python, shell, or whatever) detects an opening quoute and doesn't find the matching closing quote until it runs off the end of the file (or the script). I'd check with other users or the support system of that specific script ("lcd files" isn't enough for me to know where it came from), or check any modifications you may have made to it. From rob at despammer.com Wed Sep 30 08:58:25 2020 From: rob at despammer.com (RobH) Date: Wed, 30 Sep 2020 13:58:25 +0100 Subject: error in install.sh In-Reply-To: References: <20200930124913.GE128690@scrozzle> Message-ID: On 30/09/2020 13:49, 2QdxY4RzWzUUiLuE at potatochowder.com wrote: > On 2020-09-30 at 13:27:43 +0100, > RobH wrote: > >> I had to do a reinstall of my linux system due to a faulty ssd, and have a >> problem with a install.sh script.The said script is included in with lcd >> files. which I downloaded from github. >> >> When I run ./install.sh, it fails at >> ./install.sh: line 34: syntax error: unexpected end of file. >> >> I don't know what the syntax should be here; >> >> These are the last 4 lines in the script, and if I count the spaces then: >> >> echo "Should be now all finished. Please press any key to now reboot. After >> rebooting run" >> echo "'sudo python demo_lcd.py' from this directory" >> read -n1 -s <<<<<<<<<<<<<<<<<<<<< I think this is the line in question >> sudo reboot > > I'm not sure that this is a Python problem, but usually "unexpected end > of file" errors are due to missing or mismatched quotes. Basically, the > interpreter (Python, shell, or whatever) detects an opening quoute and > doesn't find the matching closing quote until it runs off the end of the > file (or the script). > > I'd check with other users or the support system of that specific script > ("lcd files" isn't enough for me to know where it came from), or check > any modifications you may have made to it. > This is where I got the files from: https://github.com/the-raspberry-pi-guy/lcd/find/master Thanks From pierre.bonville49 at gmail.com Wed Sep 30 09:46:39 2020 From: pierre.bonville49 at gmail.com (Pierre Bonville) Date: Wed, 30 Sep 2020 15:46:39 +0200 Subject: Interference tkinter and plot from matplotlib Message-ID: Hi everybody, I am running this little program below on Win 10 with Python 3.8 (just typing prog.py after the prompt c:\Users ...>), and while it correctly displays the window and does the first plt.plot(), it does not reach the input command and remains waiting after I shut the plot. If I replace 'quit' by 'destroy' in the button command, it works correctly. I looked on various Python forums on the Net, but didn't find an answer. Regards, P.Bonville import tkinter as tk import matplotlib.pyplot as plt r = tk.Tk() b = tk.Button(r, text= r.quit) b = tk.Button(r, text='quit', command=r.quit) b.pack() r.mainloop() # This blocks until press button. # Root window with button is still displayed. plt.plot() plt.show() rep = input("Return") plt.plot() plt.show() From auriocus at gmx.de Wed Sep 30 10:56:26 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Wed, 30 Sep 2020 16:56:26 +0200 Subject: Interference tkinter and plot from matplotlib In-Reply-To: References: Message-ID: Am 30.09.20 um 15:46 schrieb Pierre Bonville: > Hi everybody, > Interference tkinter and plot from matplotlib You are mixing different ways of control flow. In a GUI program, don't call input(). Use the mainloop() as the very last of your calls, and only work in the callbacks. That means you would integrate a "Next" button in your GUI which switches the plots - or even show them side by side. Concerning matplotlib, you'll need to tell it to integrate with Tk properly. https://matplotlib.org/3.3.1/gallery/user_interfaces/embedding_in_tk_sgskip.html If you want a simple solution instead of full-blown GUI programming, use IPython https://ipython.readthedocs.io/en/stable/config/eventloops.html or jupyter notebooks. Christian From 5377074j at gmail.com Wed Sep 30 11:34:43 2020 From: 5377074j at gmail.com (yonatan) Date: Wed, 30 Sep 2020 08:34:43 -0700 (PDT) Subject: new feature in Python. Message-ID: Hi, My name is Jonatan and i am programming in Python for about 4 years, I have a great idea, there are __iX__` methods, such as `__ior__`, `__iadd__`, `__iand__` etc.., which implements the |=, +=, &= behavior, it would be nice if you could implement also `__igetattr__` or something, which means: instead of con = "some text here" con = con.replace("here", "there") we could do con = "some text here" con .= replace("here", "there") Please let me know what do you think about it, Jonatan. From codemouse92 at outlook.com Wed Sep 30 12:13:24 2020 From: codemouse92 at outlook.com (Jason C. McDonald) Date: Wed, 30 Sep 2020 16:13:24 +0000 Subject: new feature in Python. In-Reply-To: References: Message-ID: <9d6f11a182e014cd64f08cff349b59f3c9cd3cef.camel@outlook.com> > I have a great idea, there are __iX__` methods, such as `__ior__`, > `__iadd__`, `__iand__` etc.., which implements the |=, +=, &= > behavior,? > it would be nice if you could implement also `__igetattr__` or > something, which means: > > instead of > con = "some text here" > con? = con.replace("here", "there") > > we could do > > con = "some text here" > con? .= replace("here", "there") I have three concerns about this. First, there's a lot of wizardry under the covers with getattr() and dot access to begin with, so this would be significantly non-trivial. I suspect the behavior would wind up being "surprising" too often. Second, explicit is better than implicit. It's better to explicitly rebind the name (or mutate on the name) rather than have a fancy shorthand for trampling over an existing mutable value. In the case of the compound operators on numbers, you're dealing with immutable types anyway, so you're really just rebinding the name. The same is true of your string there. But what about a list? spam = [1, 2, 3] eggs = spam eggs .= append(4) ?# what is happening???? eggs .= sort() ?# how about now? eggs .= sorted(eggs) # and now? You see? It's going to be a lot of surprises, because you're stripping the usual visual cues of explicit assignment: spam = [1, 2, 3] eggs = spam eggs.append(4) ?# mutating spam too eggs.sort() ?# mutating spam too eggs = eggs.sorted() # rebinding eggs to a new value, spam is safe Yes, yes, I know, you could "get used to it", but it's adding complexity and detracting from the One Obvious Way to do things. If an object decides to implement those compound operators and abuse them thusly, that's a consenting adults situation. Introducing this new syntax into the language creates a trip hazard for the user. Third, that proposed operator, .= ?owwwwww that's hard to see. It looks like a typo, and could easily be typed as one, or overlooked altogether (again, surprises). Explicit-is-better-than-implicit'ly yrs, -- Jason C. McDonald (CodeMouse92) Author | Speaker | Hacker | Time Lord -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: This is a digitally signed message part URL: From rosuav at gmail.com Wed Sep 30 12:35:32 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Oct 2020 02:35:32 +1000 Subject: new feature in Python. In-Reply-To: <9d6f11a182e014cd64f08cff349b59f3c9cd3cef.camel@outlook.com> References: <9d6f11a182e014cd64f08cff349b59f3c9cd3cef.camel@outlook.com> Message-ID: On Thu, Oct 1, 2020 at 2:14 AM Jason C. McDonald wrote: > > > > I have a great idea, there are __iX__` methods, such as `__ior__`, > > `__iadd__`, `__iand__` etc.., which implements the |=, +=, &= > > behavior, > > it would be nice if you could implement also `__igetattr__` or > > something, which means: > > > > instead of > > con = "some text here" > > con = con.replace("here", "there") > > > > we could do > > > > con = "some text here" > > con .= replace("here", "there") > > I have three concerns about this. First, there's a lot of wizardry > under the covers with getattr() and dot access to begin with, so this > would be significantly non-trivial. I suspect the behavior would wind > up being "surprising" too often. > > Second, explicit is better than implicit. It's better to explicitly > rebind the name (or mutate on the name) rather than have a fancy > shorthand for trampling over an existing mutable value. In the case of > the compound operators on numbers, you're dealing with immutable types > anyway, so you're really just rebinding the name. The same is true of > your string there. But what about a list? > > spam = [1, 2, 3] > eggs = spam > eggs .= append(4) # what is happening???? > eggs .= sort() # how about now? > eggs .= sorted(eggs) # and now? > > You see? It's going to be a lot of surprises, because you're stripping > the usual visual cues of explicit assignment: > > spam = [1, 2, 3] > eggs = spam > eggs.append(4) # mutating spam too > eggs.sort() # mutating spam too > eggs = eggs.sorted() # rebinding eggs to a new value, spam is safe > These examples reveal a few other issues, though, which can best be highlighted by this: x = 5 x *= 2 + 3 print(x) x = 5 x = x * 2 + 3 print(x) Augmented assignment works with a single other operand. It's not textually equivalent to "x = x other"; it's closer to "x = x (other)", putting the right hand side in parentheses. That doesn't work with a hypothetical igetattr, because you're invariably going to want to do more than just get an attribute. It's also notable that the in-place *methods* are actually used something like this (omitting detaily bits about slots): x += y # is roughly equivalent to x = x.__iadd__(y) So there's assignment *as well as* the in-place method call. The only value of the __iadd__ family of methods is with types that can implement them directly; for instance, a list can append to itself, rather than copying itself and then reassigning (which is semantically different, as well as being far less efficient). The ".=" operator wouldn't be able to take advantage of that. If you find yourself frequently writing long chains of statements that all do "thing = thing.method()", it may be better to consider writing them as a single statement instead: name = (name .capitalize() .expandtabs() .lstrip(" ") .replace(", ", ",") ) It'd be as efficient and readable as the augmented assignment form would be. ChrisA From dvl at psu.edu Wed Sep 30 13:05:41 2020 From: dvl at psu.edu (Christman, Roger Graydon) Date: Wed, 30 Sep 2020 17:05:41 +0000 Subject: new feature in Python Message-ID: On 30/09/2020, yonatan <5377074j at gmail.com> proposed: > instead of > con = "some text here" > con = con.replace("here", "there") > we could do > con = "some text here" > con .= replace("here", "there") That would require a major rewrite of the grammer of the Python language, which would probably be a bad thing. The operands to all of those assignment operators are complete objects in their own rights. This 'replace' is not an independent object, but a member of the string object. Without that "con." in front of it, you would likely get the error about "'replace' not defined" For the grammar to be clean and orthogonal, it would not be at all good to have a context-sensitivity introduced to allow orphaned method names to be permitted, just because there was this ".=" token somewhere earlier in the program statement. Besides, I could foresee a lot of programming errors when people would start to generalize this operation to do things like: list .= append(item) list .= sort() which would most certainly be incorrect. Roger Christman Pennsylvania State University From dieter at handshake.de Wed Sep 30 14:06:48 2020 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 30 Sep 2020 20:06:48 +0200 Subject: error in install.sh In-Reply-To: References: Message-ID: <24436.51512.392551.737948@ixdm.fritz.box> RobH wrote at 2020-9-30 13:27 +0100: >I had to do a reinstall of my linux system due to a faulty ssd, and have >a problem with a install.sh script.The said script is included in with >lcd files. which I downloaded from github. > >When I run ./install.sh, it fails at >./install.sh: line 34: syntax error: unexpected end of file. > >I don't know what the syntax should be here; > >These are the last 4 lines in the script, and if I count the spaces then: > >echo "Should be now all finished. Please press any key to now reboot. >After rebooting run" >echo "'sudo python demo_lcd.py' from this directory" >read -n1 -s <<<<<<<<<<<<<<<<<<<<< I think this is the line in question The command above is broken: `read` is a `SHELL BUILTIN COMMAND`; its purpose is to read words from standard input into shell variables specified on the command line. The command above does not name any variables. The "<<" in the command above introduces a `HERE DOCUMENT` redirection: it allows a script to privide input data. Its syntax is: [n]<<[-]word here-document delimiter The "HERE DOCUMENT" redirection reads the script text following the command until *delimiter* (derived from *word*) is found on a line by itself. In your case, the delimiter is not found resulting in "unexpected EOF". -- Dieter From mats at wichmann.us Wed Sep 30 14:35:11 2020 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 30 Sep 2020 12:35:11 -0600 Subject: [RELEASE] Python 3.8.6 is now available In-Reply-To: References: <30EA5AA1-44DB-4166-AFB2-FDD1298E437B@langa.pl> Message-ID: <315d2a1a-ca91-d59d-554c-957af995b485@wichmann.us> On 9/29/20 9:16 AM, David Raymond wrote: >> Python 3.8.6 is the sixth maintenance release of Python 3.8. Go get it here: > >> https://www.python.org/downloads/release/python-386/ > > > Just a quick note that there still seem to be a few places on the website which are still showing 3.8.5 as the latest release. (Looking at it with Firefox on Windows) > > On the main page www.python.org it has 3.8.6 down in the latest news section, and a direct link in the little download box right above that. But if you hover over the big "Downloads" tab at the top it gives a big 3.8.5 button > > If you click on that Downloads tab and go to www.python.org/downloads, again there's a big gold button for 3.8.5, and if you scroll down to the "Looking for a specific release?" section there is no 3.8.6 visible. The most recent line is 3.5.10 from Sept 5th > A lot of this is automated. But if you go to https://www.python.org/downloads/windows, the entry for 3.8.6 says "No files for this release". That's somewhat going to impact the ability to download :) From eryksun at gmail.com Wed Sep 30 16:52:00 2020 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 30 Sep 2020 15:52:00 -0500 Subject: Problem In-Reply-To: <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> Message-ID: On 9/30/20, Dennis Lee Bieber wrote: > On Tue, 29 Sep 2020 22:31:18 +0000 (UTC), Ron Villarreal via Python-list > declaimed the following: > >>Tried to open Python 3.8. I have Windows 10. Icon won?t open. > > What "Icon"? > > Python is a language interpreter/compiler -- it runs from a command > prompt/shell. Clicking on a Python SCRIPT might open a shell, which will > almost immediately close when the script finishes executing No shell should be executed by a normal .py file association. If it's running CMD or PowerShell, or any other shell, it's likely a mistake. Double clicking on an icon for a .py file should run "py.exe" -> "python.exe" or just "python.exe", assuming .py scripts are configured to execute by default as opposed to opening in an editor. These are console applications, which, when executed without an inherited console session, will automatically create a new console session that creates a window for the console/terminal user interface. The latter includes keyboard and mouse input and display of the active screen buffer. Client applications access the session's input buffer and screen buffers via console I/O files that are attached to the console session. (In Windows 7+, a console session is an instance of conhost.exe. In Windows 8+, console I/O files are provided by the ConDrv device, which is implemented by the condrv.sys driver. In Windows 10, console I/O also supports virtual-terminal ANSI sequences, which improves API compatibility with terminals on other platforms.) From jamtlu at gmail.com Wed Sep 30 16:45:47 2020 From: jamtlu at gmail.com (James Lu) Date: Wed, 30 Sep 2020 16:45:47 -0400 Subject: A library that converts a type-annotated function into a webpage with HTML forms? Message-ID: Is there a python library available that converts a type-annotated Python function into a webpage with HTML forms? Something like: def foo(name: str, times: int): return f"Hello {name}!" * times serve_from(foo, host="0.0.0.0", port=3000) Turning into a server that serves something like this:
And hitting the submit button executes the function. I'm aware I could use sls, and build a form manually, but that's extra work. From mirkok.lists at googlemail.com Wed Sep 30 17:32:04 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Wed, 30 Sep 2020 23:32:04 +0200 Subject: Problem In-Reply-To: <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> Message-ID: <5F74F954.30700@googlemail.com> Am 30.09.2020 um 17:55 schrieb Dennis Lee Bieber: > On Tue, 29 Sep 2020 22:31:18 +0000 (UTC), Ron Villarreal via Python-list > declaimed the following: > >> Tried to open Python 3.8. I have Windows 10. Icon won?t open. > > What "Icon"? > > Python is a language interpreter/compiler -- it runs from a command > prompt/shell. Clicking on a Python SCRIPT might open a shell, which will > almost immediately close when the script finishes executing (files with a > .pyw extension are supposed to create their own GUI using one of a couple > of libraries, and don't open a shell). I'm just a lurker, hobby programmer and Linux geek, so take my words with some caution. We are seeing these troubles from newcomers on Windows all of the time -- and that for years. Isn't it time to ask if the way Python installs itself on Windows-Systems is appropriate? I have only limited knowledge about current Windows systems. But it seems to me that newcomers download some setup exe/msi and then search the menu to run what ever is found (python.exe or even the setup-program.) That's Ok, if you understand what an interpreter/compiler for the command-line is. But programming beginners usually don't know that (especially not if there are Windows users). There has been a lot of effort to make this group inclusive and newcomer-friendly. But it seems to me that this is not the case for the software itself. Given that Python ships with a rudimentary IDE (IDLE), should that one be promoted more intensively? Shouldn't IDLE be named something like "Python Editor" (or Python IDE/App) in the menu, so beginners can more easily find it? Further it might be a good idea to make this "Repair/Modify/Remove"-Dialog more explicit by clearly saying "Python is already installed. If you want to use it, do ...". From rosuav at gmail.com Wed Sep 30 17:44:39 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 1 Oct 2020 07:44:39 +1000 Subject: Problem In-Reply-To: <5F74F954.30700@googlemail.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: On Thu, Oct 1, 2020 at 7:33 AM Mirko via Python-list wrote: > > Am 30.09.2020 um 17:55 schrieb Dennis Lee Bieber: > > On Tue, 29 Sep 2020 22:31:18 +0000 (UTC), Ron Villarreal via Python-list > > declaimed the following: > > > >> Tried to open Python 3.8. I have Windows 10. Icon won?t open. > > > > What "Icon"? > > > > Python is a language interpreter/compiler -- it runs from a command > > prompt/shell. Clicking on a Python SCRIPT might open a shell, which will > > almost immediately close when the script finishes executing (files with a > > .pyw extension are supposed to create their own GUI using one of a couple > > of libraries, and don't open a shell). > > > I'm just a lurker, hobby programmer and Linux geek, so take my words > with some caution. > > We are seeing these troubles from newcomers on Windows all of the > time -- and that for years. Isn't it time to ask if the way Python > installs itself on Windows-Systems is appropriate? > The problem is that there isn't "the way". Did the person: 1) Download an MSI file from python.org? 2) Install ActiveState? 3) Install Enthought? 4) Install Anaconda? 5) Get Python from the Microsoft Store? 6) Something else? They're all different, they all behave differently, they all have different defaults. And then there's the question of "did you install it for everyone or just you?", and so on. The core Python devs have control of the first option, and some control over the fifth, but none of the others. And quite often, it turns out that these issues come from someone doing *more than one* of these, making it even more difficult to figure out what's happened. So, go ahead, ask if it's appropriate.... good luck getting a useful response :| ChrisA From eryksun at gmail.com Wed Sep 30 19:23:05 2020 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 30 Sep 2020 18:23:05 -0500 Subject: Problem In-Reply-To: <5F74F954.30700@googlemail.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: On 9/30/20, Mirko via Python-list wrote: > > I have only limited knowledge about current Windows systems. But it > seems to me that newcomers download some setup exe/msi and then > search the menu to run what ever is found (python.exe or even the > setup-program.) It might help some people who try to run Python via the installer if it actually had "installer" in the name. For example, "python-3.8.5-amd64-installer.exe" instead of "python-3.8.5-amd64.exe". > Shouldn't IDLE be named something like "Python Editor" (or Python > IDE/App) in the menu, so beginners can more easily find it? Further > it might be a good idea to make this "Repair/Modify/Remove"-Dialog > more explicit by clearly saying "Python is already installed. If you > want to use it, do ...". Explorer tracks recently added start-menu items and indicates them as "New". The Python 3.x start-menu folder has clearly named shell links such as "IDLE (Python 3.9 64-bit)" and "Python 3.9 (64-bit)" (run python.exe), as well as "Python 3.9 Manuals (64-bit)" (chm docs) and "Python 3.9 Module Docs (64-bit)" (pydoc browser). The successful installation message was recently changed to include brief instructions for running Python via the `py` command as well as a direct link to Python on Windows docs [1]: New to Python? Start with the online tutorial [link] and documentation [link]. At your terminal, type "py" to launch Python, or search for Python in your Start menu. See what's new [link] in this release, or find more info about using Python on Windows [link]. I'd wager that Steve would welcome a PR to add a similar message to the modify/repair dialog. [1] https://github.com/python/cpython/blob/v3.9.0rc2/Tools/msi/bundle/Default.wxl#L108 From torriem at gmail.com Wed Sep 30 07:35:07 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 30 Sep 2020 05:35:07 -0600 Subject: Problem In-Reply-To: <652624127.90690.1601418678143@mail.yahoo.com> References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> Message-ID: <7be02c87-15eb-c3f3-96e4-89f869cd364c@gmail.com> On 9/29/20 4:31 PM, Ron Villarreal via Python-list wrote: > Tried to open Python 3.8. I have Windows 10. Icon won?t open. Did you read the documentation? https://docs.python.org/3/using/windows.html Seems like this comes up several times a week. Perhaps the installer should automatically open this page. From kushal at locationd.net Wed Sep 30 21:36:12 2020 From: kushal at locationd.net (Kushal Kumaran) Date: Wed, 30 Sep 2020 18:36:12 -0700 Subject: A library that converts a type-annotated function into a webpage with HTML forms? In-Reply-To: (James Lu's message of "Wed, 30 Sep 2020 16:45:47 -0400") References: Message-ID: <87eemid8xf.fsf@copper.locationd.net> On Wed, Sep 30 2020 at 04:45:47 PM, James Lu wrote: > Is there a python library available that converts a type-annotated Python > function into a webpage with HTML forms? > > Something like: > > > def foo(name: str, times: int): > return f"Hello {name}!" * times > > serve_from(foo, host="0.0.0.0", port=3000) > > Turning into a server that serves something like this: > >
> > > >
> > And hitting the submit button executes the function. > > I'm aware I could use sls, and build a form manually, but that's extra work. https://fastapi.tiangolo.com/ https://fastapi.tiangolo.com/tutorial/path-params/#documentation Depending on what you need to use the forms for, this might suffice. -- regards, kushal From grant.b.edwards at gmail.com Wed Sep 30 22:21:41 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 1 Oct 2020 02:21:41 -0000 (UTC) Subject: Problem References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: On 2020-09-30, Mirko via Python-list wrote: > We are seeing these troubles from newcomers on Windows all of the > time -- and that for years. Isn't it time to ask if the way Python > installs itself on Windows-Systems is appropriate? And that's been asked every few months for years. Time and time again, people suggest that the installer should be tweaked to end with a page explaining how to run python, or that some sort of "launcher" or other be added. Those sound like good ideas to me (even though I'm not sure exactly what the "launger" suggestion is), but I'm a Linux user, so what do I know? -- Grant From grant.b.edwards at gmail.com Wed Sep 30 22:23:09 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 1 Oct 2020 02:23:09 -0000 (UTC) Subject: Problem References: <652624127.90690.1601418678143.ref@mail.yahoo.com> <652624127.90690.1601418678143@mail.yahoo.com> <3ca9nf58vdp162r6ana145dcukd50knshu@4ax.com> <5F74F954.30700@googlemail.com> Message-ID: On 2020-09-30, Eryk Sun wrote: > On 9/30/20, Mirko via Python-list wrote: >> >> I have only limited knowledge about current Windows systems. But it >> seems to me that newcomers download some setup exe/msi and then >> search the menu to run what ever is found (python.exe or even the >> setup-program.) > > It might help some people who try to run Python via the installer if > it actually had "installer" in the name. For example, > "python-3.8.5-amd64-installer.exe" instead of > "python-3.8.5-amd64.exe". Yep. And, that too has been suggested many times over the years. -- Grant