Re: comprehension parsing
Hello, Its probably a priority of avalauation in the chain of operators ans association of themselves. I'm not sure. Philippe. De : "BlindAnagram" A : python-list@python.org Envoyé: dimanche 6 Novembre 2022 00:57 Objet : Re: comprehension parsing On 05/11/2022 22:11, MRAB wrote: > On 2022-11-05 18:52, cactus wrote: >> On Saturday, 5 November 2022 at 16:06:52 UTC, cactus wrote: >> >> I should have quoted the full comprehensions: >> >> all((srt(m, n) in c_np) == (srt(a, b) in c_ap) for (m, a), (n, b) >> in combinations(na8, 2)) >> all( srt(m, n) in c_np == srt(a, b) in c_ap) for (m, a), (n, b) >> in combinations(na8, 2)) > > The comparison operators can be chained, so: > > a == b == c > > is equivalent to: > > (a == b) and (b == c) > > except that the common term ('b' in this case) is evaluated only once. > > 'in' is one of those comparison operators, so: > > srt(m, n) in c_np == srt(a, b) in c_ap > > is equivalent to: > > (srt(m, n) in c_np) and (c_np == srt(a, b)) and (srt(a, b) in c_ap) > > except that the common terms ('c_np' and 'srt(a, b)') are evaluated only > once. > > Chaining makes most sense with multiple '==' or a series of '<' and/or > '<=' or a series of '>' and/or '>=', as in '1 <= n <= 10'. Thanks for a most helpful explanation -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to manage python shebang on mixed systems?
Il 06/11/2022 11:03, Chris Green ha scritto: I have a number of python scripts that I run on a mix of systems. I have updated them all to run on python 3 but many will also run quite happily with python 2. They all have a #!/usr/bin/python3 shebang. This works almost everywhere but there is one system where only python 2 is available (at /usr/bin/python). I don't have python 2 on any of the systems I manage myself now so a #!/usr/bin/python shebang will fail. Is there a neat way of handling this? I could write a sort of wrapper script to run via the shebang but that seems overkill to me. hi, If you can call Python from the shell prompt, then you could remove the path from shebang: #!python -- https://mail.python.org/mailman/listinfo/python-list
Re: How to manage python shebang on mixed systems?
rbowman wrote: > On Sun, 6 Nov 2022 10:03:50 +, Chris Green wrote: > > > > Is there a neat way of handling this? I could write a sort of wrapper > > script to run via the shebang but that seems overkill to me. > > Can you symlink? Not really, since the system where there's no python3 is one where I only have user access. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: How to manage python shebang on mixed systems?
On 06Nov2022 20:51, jak wrote: Il 06/11/2022 11:03, Chris Green ha scritto: I have a number of python scripts that I run on a mix of systems. I have updated them all to run on python 3 but many will also run quite happily with python 2. They all have a #!/usr/bin/python3 shebang. I usually use: #!/usr/bin/env python3 This runs the default "python3" from my $PATH, whatever that is, avoiding a hardwired path to the python3 executable. This works almost everywhere but there is one system where only python 2 is available (at /usr/bin/python). I don't have python 2 on any of the systems I manage myself now so a #!/usr/bin/python shebang will fail. Is there a neat way of handling this? I could write a sort of wrapper script to run via the shebang but that seems overkill to me. It is overkill. I generally dislike batch editing scripts. 1: do these scripts work on both python2 and python3? It seems like they would need to. 2: write a tiny script _named_ "python3" which invokes python 2. I keep a personal "~/bin-local" directory for just such per-system special commands like this. 3: with your pseudo "python3" script in place, make all the scripts use the "#!/usr/bin/env python3" shebang suggested above. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How to manage python shebang on mixed systems?
A possible solution is here. https://superuser.com/questions/815323/can-i-have-a-conditional-shebang From: Python-list on behalf of jak Sent: Sunday, November 6, 2022 2:51:10 PM To: python-list@python.org Subject: Re: How to manage python shebang on mixed systems? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Il 06/11/2022 11:03, Chris Green ha scritto: > I have a number of python scripts that I run on a mix of systems. I > have updated them all to run on python 3 but many will also run quite > happily with python 2. They all have a #!/usr/bin/python3 shebang. > > This works almost everywhere but there is one system where only > python 2 is available (at /usr/bin/python). > > I don't have python 2 on any of the systems I manage myself now so a > #!/usr/bin/python shebang will fail. > > Is there a neat way of handling this? I could write a sort of wrapper > script to run via the shebang but that seems overkill to me. > hi, If you can call Python from the shell prompt, then you could remove the path from shebang: #!python -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!ke_gwJrnkkPx4fdk8CkLm6Qd2lmYIl7st4qz7Mmn0G8BerBOEwRWBfm51eFZ-Ut4WCTXTGoUEP5MTWYjmZE$ -- https://mail.python.org/mailman/listinfo/python-list
Re: How to manage python shebang on mixed systems?
On 7/11/2022 6:51 am, jak wrote: Il 06/11/2022 11:03, Chris Green ha scritto: I have a number of python scripts that I run on a mix of systems. I have updated them all to run on python 3 but many will also run quite happily with python 2. They all have a #!/usr/bin/python3 shebang. This works almost everywhere but there is one system where only python 2 is available (at /usr/bin/python). I don't have python 2 on any of the systems I manage myself now so a #!/usr/bin/python shebang will fail. Is there a neat way of handling this? I could write a sort of wrapper script to run via the shebang but that seems overkill to me. Can you link the interpreter on each system to the same-named local link and put that in your shebang? #!~/scripts/mypython hi, If you can call Python from the shell prompt, then you could remove the path from shebang: #!python -- 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. OpenPGP_signature Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list