Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Albert-Jan Roskam
   On Dec 21, 2022 06:01, Chris Angelico  wrote:

 On Wed, 21 Dec 2022 at 15:28, Jach Feng  wrote:
 > That's what I am taking this path under Windows now, the ultimate
 solution before Windows has shell similar to bash:-)

 Technically, Windows DOES have a shell similar to bash. It's called
 bash. :) The trouble is, most people use cmd.exe instead.

   =
   I use Git Bash quite a lot: https://gitforwindows.org/
   Is that the one you're referring to?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Lars Liedtke

Or you could have "native" bash ($SHELL) with WSL. But I assume not everyone is 
using it.

Cheers

Lars


Lars Liedtke
Software Entwickler

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail]l...@solute.de


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]


Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de 
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 21.12.22 um 13:15 schrieb Albert-Jan Roskam:

  On Dec 21, 2022 06:01, Chris Angelico 
 wrote:

On Wed, 21 Dec 2022 at 15:28, Jach Feng 
 wrote:
> That's what I am taking this path under Windows now, the ultimate
solution before Windows has shell similar to bash:-)

Technically, Windows DOES have a shell similar to bash. It's called
bash. :) The trouble is, most people use cmd.exe instead.

  =
  I use Git Bash quite a lot: https://gitforwindows.org/
  Is that the one you're referring to?

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


Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Chris Angelico
On Wed, 21 Dec 2022 at 23:16, Albert-Jan Roskam  wrote:
>
>
>
> On Dec 21, 2022 06:01, Chris Angelico  wrote:
>
> On Wed, 21 Dec 2022 at 15:28, Jach Feng  wrote:
> > That's what I am taking this path under Windows now, the ultimate solution 
> > before Windows has shell similar to bash:-)
>
> Technically, Windows DOES have a shell similar to bash. It's called
> bash. :) The trouble is, most people use cmd.exe instead.
>
>
> =
>
> I use Git Bash quite a lot: https://gitforwindows.org/
>
> Is that the one you're referring to?
>

Yeah, that's probably the easiest way to get hold of it.

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


Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Jach Feng
Chris Angelico 在 2022年12月21日 星期三下午1:02:01 [UTC+8] 的信中寫道:
> On Wed, 21 Dec 2022 at 15:28, Jach Feng  wrote: 
> > That's what I am taking this path under Windows now, the ultimate solution 
> > before Windows has shell similar to bash:-)
> Technically, Windows DOES have a shell similar to bash. It's called 
> bash. :) The trouble is, most people use cmd.exe instead. 
> 
> ChrisA
Really? Where? I can't find it in my Windows 8.1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Chris Angelico
On Thu, 22 Dec 2022 at 03:11, Jach Feng  wrote:
>
> Chris Angelico 在 2022年12月21日 星期三下午1:02:01 [UTC+8] 的信中寫道:
> > On Wed, 21 Dec 2022 at 15:28, Jach Feng  wrote:
> > > That's what I am taking this path under Windows now, the ultimate 
> > > solution before Windows has shell similar to bash:-)
> > Technically, Windows DOES have a shell similar to bash. It's called
> > bash. :) The trouble is, most people use cmd.exe instead.
> >
> > ChrisA
> Really? Where? I can't find it in my Windows 8.1

Ah, I didn't mean "ships with"; bash for Windows is very much
available, but you'd have to go fetch it. Try the Windows app store
first, and if not, a quick web search will find it. Or install Git for
Windows, which comes with bash.

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


Re: How to enter escape character in a positional string argument from the command line?

2022-12-21 Thread Chris Angelico
On Thu, 22 Dec 2022 at 03:11, Stefan Ram  wrote:
>
> Lars Liedtke  writes:
> >Or you could have "native" bash ($SHELL) with WSL.
>
>   In this newsgroup, it would actually be obvious to use Python.

Less obvious than you might think - partly because bash is just so
dang good that it's really really hard to outdo it :) Sure, bash has a
lot of weird and wonky edge cases, but it's an incredibly practical
shell to use.

>   When commands are typed manually, this might be a bit verbose,
>   though. I mean
>
> os.chdir( r'C:\EXAMPLE' )
>
>   versus
>
> CD C:\EXAMPLE

Exactly. What's good for a programming language is often not good for a shell.

> class PythonShell( cmd.Cmd ):
>
> intro = 'Welcome to the Python shell. Type help or ? to list commands.\n'
> prompt = '(Python) '
> file = None
>
> def do_cd( self, arg ):
> 'change directory:  CD C:\EXAMPLE'
> os.chdir( *parse( arg ))
>
> def do_bye( self, arg ):
> 'Exit:  BYE'
> print( 'Thank you for using the Python Shell!' )
> return True

Sure, you can always create your own shell. But I think you'll find
that, as you start expanding on this, you'll end up leaning more
towards "implementing bash-like and/or cmd-like semantics in Python"
rather than "creating a Python shell". Shells, in general, try to
execute programs as easily and conveniently as possible. Programming
languages try to stay inside themselves and do things, with subprocess
spawning being a much less important task.

Fun challenge: see how much you can do in bash without ever forking to
another program. And by "fun", I mean extremely difficult, and by
"challenge" I really mean "something you might have to do when your
system is utterly hosed and all you have available is one root shell".

It's amazing how far you can go when your hard drive has crashed and
you desperately need to get one crucial login key that you thought you
had saved elsewhere but hadn't.

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


Re: How to enter escape character in a positional string argumentfrom the command line?

2022-12-21 Thread gene heskett

On 12/21/22 11:22, Chris Angelico wrote:

On Thu, 22 Dec 2022 at 03:11, Stefan Ram  wrote:


Lars Liedtke  writes:

Or you could have "native" bash ($SHELL) with WSL.


   In this newsgroup, it would actually be obvious to use Python.


Less obvious than you might think - partly because bash is just so
dang good that it's really really hard to outdo it :) Sure, bash has a
lot of weird and wonky edge cases, but it's an incredibly practical
shell to use.

When you make a statement like that, Chris, you should also note that 
every single one of those "wonky edge cases" is documented down to the 
last dotted i. Bash's docs will kill a good sized pulp tree, needing 
around a ream of paper to print on a duplex printer. I know, I did it 
around a decade ago. If you like to write scripts, having a dead tree 
copy of the docs at your elbow in incredibly useful.  That huge man page 
does not cover it like the printed docs do.



   When commands are typed manually, this might be a bit verbose,
   though. I mean

os.chdir( r'C:\EXAMPLE' )

   versus

CD C:\EXAMPLE


Exactly. What's good for a programming language is often not good for a shell.


class PythonShell( cmd.Cmd ):

 intro = 'Welcome to the Python shell. Type help or ? to list commands.\n'
 prompt = '(Python) '
 file = None

 def do_cd( self, arg ):
 'change directory:  CD C:\EXAMPLE'
 os.chdir( *parse( arg ))

 def do_bye( self, arg ):
 'Exit:  BYE'
 print( 'Thank you for using the Python Shell!' )
 return True


Sure, you can always create your own shell. But I think you'll find
that, as you start expanding on this, you'll end up leaning more
towards "implementing bash-like and/or cmd-like semantics in Python"
rather than "creating a Python shell". Shells, in general, try to
execute programs as easily and conveniently as possible. Programming
languages try to stay inside themselves and do things, with subprocess
spawning being a much less important task.

Fun challenge: see how much you can do in bash without ever forking to
another program. And by "fun", I mean extremely difficult, and by
"challenge" I really mean "something you might have to do when your
system is utterly hosed and all you have available is one root shell".

It's amazing how far you can go when your hard drive has crashed and
you desperately need to get one crucial login key that you thought you
had saved elsewhere but hadn't.

ChrisA


Cheers, Gene Heskett.
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 

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


Re: How to enter escape character in a positional string argumentfrom the command line?

2022-12-21 Thread Chris Angelico
On Thu, 22 Dec 2022 at 03:58, gene heskett  wrote:
>
> On 12/21/22 11:22, Chris Angelico wrote:
> > On Thu, 22 Dec 2022 at 03:11, Stefan Ram  wrote:
> >>
> >> Lars Liedtke  writes:
> >>> Or you could have "native" bash ($SHELL) with WSL.
> >>
> >>In this newsgroup, it would actually be obvious to use Python.
> >
> > Less obvious than you might think - partly because bash is just so
> > dang good that it's really really hard to outdo it :) Sure, bash has a
> > lot of weird and wonky edge cases, but it's an incredibly practical
> > shell to use.
> >
> When you make a statement like that, Chris, you should also note that
> every single one of those "wonky edge cases" is documented down to the
> last dotted i. Bash's docs will kill a good sized pulp tree, needing
> around a ream of paper to print on a duplex printer. I know, I did it
> around a decade ago. If you like to write scripts, having a dead tree
> copy of the docs at your elbow in incredibly useful.  That huge man page
> does not cover it like the printed docs do.
>

Oh yes, absolutely true. Its wonkiness is dependable and consistent;
but it is definitely quirky (look at all the different ways to embed
arguments into things, and the ways that $*, $@, "$*, and "$@" behave
when put into variables). Not usually a problem, but it does sometimes
leave you thinking "wow, wouldn't it be easier to just use something
like Python?". And in the complicated cases, yeah, it can be. But in
the simple cases? Bash rocks.

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


Re: How to enter escape character in a positional string argumentfrom the command line?

2022-12-21 Thread Chris Angelico
On Thu, 22 Dec 2022 at 04:12, Barry  wrote:
> I see bash scripts that are 1000’s of line of code at work and its a 
> maintenance nightmare.
>
> Knowing when to make the move from “handy bash script” to “this is a 
> production application” and needs to be python is what I see people miss.
>
> After a certain point in complexity the python code wins on maintenance.
> Personally i set a low bar to move from bash to python.

Agreed 100%. However, how many commands do you type a day at the bash
prompt? *Every one of those* is a simple case that doesn't need
Python. That's what makes bash such a great shell. You can type
simple, convenient commands, and they *just work*. Need something a
bit more complicated? You can do that too. Want to automate a short
sequence of commands? Don't have to translate them into another system
(like Python subprocess calls), just copy/paste them into a shell
script.

Yes, there absolutely is a point beyond which it's better to translate
everything. But the vast number of commands executed every day? Most
of them are fine with bash. And that's why Python will never replace
bash as a shell.

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


Re: How to enter escape character in a positional string argumentfrom the command line?

2022-12-21 Thread Barry


> On 21 Dec 2022, at 17:06, Chris Angelico  wrote:
> 
> On Thu, 22 Dec 2022 at 03:58, gene heskett  wrote:
>> 
>>> On 12/21/22 11:22, Chris Angelico wrote:
>>> On Thu, 22 Dec 2022 at 03:11, Stefan Ram  wrote:
 
 Lars Liedtke  writes:
> Or you could have "native" bash ($SHELL) with WSL.
 
   In this newsgroup, it would actually be obvious to use Python.
>>> 
>>> Less obvious than you might think - partly because bash is just so
>>> dang good that it's really really hard to outdo it :) Sure, bash has a
>>> lot of weird and wonky edge cases, but it's an incredibly practical
>>> shell to use.
>>> 
>> When you make a statement like that, Chris, you should also note that
>> every single one of those "wonky edge cases" is documented down to the
>> last dotted i. Bash's docs will kill a good sized pulp tree, needing
>> around a ream of paper to print on a duplex printer. I know, I did it
>> around a decade ago. If you like to write scripts, having a dead tree
>> copy of the docs at your elbow in incredibly useful.  That huge man page
>> does not cover it like the printed docs do.
>> 
> 
> Oh yes, absolutely true. Its wonkiness is dependable and consistent;
> but it is definitely quirky (look at all the different ways to embed
> arguments into things, and the ways that $*, $@, "$*, and "$@" behave
> when put into variables). Not usually a problem, but it does sometimes
> leave you thinking "wow, wouldn't it be easier to just use something
> like Python?". And in the complicated cases, yeah, it can be. But in
> the simple cases? Bash rocks.

I see bash scripts that are 1000’s of line of code at work and its a 
maintenance nightmare.

Knowing when to make the move from “handy bash script” to “this is a production 
application” and needs to be python is what I see people miss.

After a certain point in complexity the python code wins on maintenance.
Personally i set a low bar to move from bash to python.

Barry


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

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


Re: ContextVars in async context

2022-12-21 Thread Dieter Maurer
Marce Coll wrote at 2022-12-20 22:09 +0100:
>Hi python people, hope this is the correct place to ask this!
>
>For a transactional async decorator I'm building I am using contextvars in 
>order to know when a transaction is open in my current context.
>
>My understanding is that if given the following call stack
>
>A
>|- B
>|  |- C
>|- D
>   |- E
>
>If you set a context var at A with value 1, and then override it at B with 
>value 2, then A, D and E will see value 1 and B and C will se value 2. Very 
>similar (although a bit more manual) than dynamic scopes in common lisp.

This is not the way I understand context variables.
In my view (--> PEP 0567), the context is the coroutine not the call stack.
This means: all calls in the same coroutine share the same context
variables. In your example, if `B` overrides the context variable, then
all later calls in this coroutine will see the overridden value.
-- 
https://mail.python.org/mailman/listinfo/python-list


pygame.midi input/output not working

2022-12-21 Thread Patrick EGLOFF
HI,
Some time ago I wrote a small software using pygame.midi
It worked just fine with Win10/ python 3.9 / SDL 2.0.14 / pygame 2.0.1

I had to change my computer and now I installed Win10 / Python 3.11.1 / SDL
2.0.18 / pygame 2.1.2

The following instructions don't work anymore, making the IDE stop
execution :

my_input = pygame.midi.Input(MidiDeviceIn)
midi_out = pygame.midi.Output(MidiDeviceOut)

Does someone have a suggestion?

Thanks,

-- 
Patrick Egloff
email : pegl...@gmail.com
Web page : http://www.egloff.eu
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygame.midi input/output not working

2022-12-21 Thread Thomas Passin

On 12/21/2022 4:32 PM, Patrick EGLOFF wrote:

HI,
Some time ago I wrote a small software using pygame.midi
It worked just fine with Win10/ python 3.9 / SDL 2.0.14 / pygame 2.0.1

I had to change my computer and now I installed Win10 / Python 3.11.1 / SDL
2.0.18 / pygame 2.1.2

The following instructions don't work anymore, making the IDE stop
execution :

my_input = pygame.midi.Input(MidiDeviceIn)
midi_out = pygame.midi.Output(MidiDeviceOut)

Does someone have a suggestion?


The pygame web site says this:

"Pygame still does not run on Python 3.11"

Also from the same page:

"Make sure you install python with the "Add python to PATH" option 
selected. This means that python, and pip will work for you from the 
command line."


See https://www.pygame.org/wiki/GettingStarted#Pygame%20Installation

So what to do until pygame runs in Python 3.11?  I'd install an earlier 
version of Python.  You can have several versions on your machine at the 
same time.  Remember, you have to install all the required packages with 
each version of Python - they don't use each other's code or libraries.

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


Fwd: pygame.midi input/output not working

2022-12-21 Thread Patrick EGLOFF
Hi Thomas,

Thanks for the answer AND solution !
That was it... shame on me, I didn't notice this warning.

I uninstalled 3.11.1 and installed 3.10.9, and my software is back to live
!

Now I have to figure out another problem. I will make another post about
this serial weird behavior.

Thanks for making my day !
Patrick

Le mer. 21 déc. 2022 à 23:27, Thomas Passin  a écrit :

> On 12/21/2022 4:32 PM, Patrick EGLOFF wrote:
> > HI,
> > Some time ago I wrote a small software using pygame.midi
> > It worked just fine with Win10/ python 3.9 / SDL 2.0.14 / pygame 2.0.1
> >
> > I had to change my computer and now I installed Win10 / Python 3.11.1 /
> SDL
> > 2.0.18 / pygame 2.1.2
> >
> > The following instructions don't work anymore, making the IDE stop
> > execution :
> >
> > my_input = pygame.midi.Input(MidiDeviceIn)
> > midi_out = pygame.midi.Output(MidiDeviceOut)
> >
> > Does someone have a suggestion?
>
> The pygame web site says this:
>
> "Pygame still does not run on Python 3.11"
>
> Also from the same page:
>
> "Make sure you install python with the "Add python to PATH" option
> selected. This means that python, and pip will work for you from the
> command line."
>
> See https://www.pygame.org/wiki/GettingStarted#Pygame%20Installation
>
> So what to do until pygame runs in Python 3.11?  I'd install an earlier
> version of Python.  You can have several versions on your machine at the
> same time.  Remember, you have to install all the required packages with
> each version of Python - they don't use each other's code or libraries.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Patrick Egloff
email : pegl...@gmail.com
Web page : http://www.egloff.eu


-- 
Patrick Egloff
email : pegl...@gmail.com
Web page : http://www.egloff.eu
-- 
https://mail.python.org/mailman/listinfo/python-list