From desireect at live.com  Tue Mar  5 12:52:50 2024
From: desireect at live.com (Desiree C .Thomas)
Date: Tue, 5 Mar 2024 17:52:50 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
Message-ID: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>

Hello there,

I hope this reaches you well.

So I am following this https://docs.python.org/3/tutorial/controlflow.html

I'm on 4.8.2. Keyword Argument
Following the example

def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
    print("-- This parrot wouldn't", action, end=' ')
    print("if you put", voltage, "volts through it.")
    print("-- Lovely plumage, the", type)
    print("-- It's", state, "!")

So this is positional arguments

parrot(1000)                                          # 1 positional argument
parrot(voltage=1000)                                  # 1 keyword argument
parrot(voltage=1000000, action='VOOOOOM')             # 2 keyword arguments
parrot(action='VOOOOOM', voltage=1000000)             # 2 keyword arguments
parrot('a million', 'bereft of life', 'jump')         # 3 positional arguments
parrot('a thousand', state='pushing up the daisies')


  1.  So I understand the parrot(1000) would just input into the required argument voltage
  2.  Parrot voltage=1000 also input into the required argument voltage
  3.
parrot(voltage=1000000, action='VOOOOOM') I can enter the requirement argument and skip one of the arguments to input into action. The other non stated arguments just use the default values.
  4.
parrot(action='VOOOOOM', voltage=1000000) Here I accepted that I can state on the arguments I want to filled in just as long as the requirement argument is inputted. I also accepted that the requirement argument doesn't need to be declare first either.
  5.
parrot('a million', 'bereft of life', 'jump') The requirement argument was filled and the remaining two arguments were inputted in the respective order of the functions
  6.
parrot('a thousand', state='pushing up the daisies') I have accepted that the requirement argument was assumed to the first argument and accept to be 'a thousand' and the declared argument was input

Please feel free of my understanding so far.
So continuing


parrot()

The requirement argument isn't inputted therefore error.


parrot(voltage=5.0, 'dead')

This is the error I get: SyntaxError: positional argument follows keyword argument on line 10

>From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.

Thanks
Desiree Cortez-Thomas





From PythonList at DancesWithMice.info  Tue Mar  5 18:07:42 2024
From: PythonList at DancesWithMice.info (dn)
Date: Wed, 6 Mar 2024 12:07:42 +1300
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
Message-ID: <e7852d25-e3d7-46a7-a46e-fe62054a4f0d@DancesWithMice.info>

On 6/03/24 06:52, Desiree C .Thomas wrote:
> Hello there,
> 
> I hope this reaches you well.
> 
> So I am following this https://docs.python.org/3/tutorial/controlflow.html
> 
> I'm on 4.8.2. Keyword Argument
> Following the example
> 
> def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
>      print("-- This parrot wouldn't", action, end=' ')
>      print("if you put", voltage, "volts through it.")
>      print("-- Lovely plumage, the", type)
>      print("-- It's", state, "!")
> 
> So this is positional arguments
> 
> parrot(1000)                                          # 1 positional argument
> parrot(voltage=1000)                                  # 1 keyword argument
> parrot(voltage=1000000, action='VOOOOOM')             # 2 keyword arguments
> parrot(action='VOOOOOM', voltage=1000000)             # 2 keyword arguments
> parrot('a million', 'bereft of life', 'jump')         # 3 positional arguments
> parrot('a thousand', state='pushing up the daisies')
> 
> 
>    1.  So I understand the parrot(1000) would just input into the required argument voltage
>    2.  Parrot voltage=1000 also input into the required argument voltage
>    3.
> parrot(voltage=1000000, action='VOOOOOM') I can enter the requirement argument and skip one of the arguments to input into action. The other non stated arguments just use the default values.
>    4.
> parrot(action='VOOOOOM', voltage=1000000) Here I accepted that I can state on the arguments I want to filled in just as long as the requirement argument is inputted. I also accepted that the requirement argument doesn't need to be declare first either.
>    5.
> parrot('a million', 'bereft of life', 'jump') The requirement argument was filled and the remaining two arguments were inputted in the respective order of the functions
>    6.
> parrot('a thousand', state='pushing up the daisies') I have accepted that the requirement argument was assumed to the first argument and accept to be 'a thousand' and the declared argument was input
> 
> Please feel free of my understanding so far.
> So continuing
> 
> 
> parrot()
> 
> The requirement argument isn't inputted therefore error.
> 
> 
> parrot(voltage=5.0, 'dead')
> 
> This is the error I get: SyntaxError: positional argument follows keyword argument on line 10
> 
>  From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.


You've spotted that there are different ways of looking at function's 
parameters:

- positional
- keyword, and
- default value

A positional-parameter must be matched with an argument at every 
function-call. The choice of description is that the position of each 
argument must match that of the function's parameter.

Contrarily keyword-parameters have no requirement for relative 
positioning, and as you've observed may be supplied in any order.

A default-parameter can be considered to be optional- if it is not 
supplied with an argument-value, then the default is substituted. It's 
behavior is otherwise that of a keyword-parameter.


Now for the slightly-confusing part:

- just because a parameter is "positional", doesn't stop us from 
labeling an argument as if it were a keyword-parameter.

- just because a parameter is "keyword", doesn't stop us from listing 
the arguments without labels and as if they are positional.

Oh great!

ie don't look for hard-and-fast rules, because Python is *flexible*!


Then the issue is what happens when there is a mix of positional- and 
keyword-arguments in the same function-call?

The rule is that we can start with positional-arguments, but once a 
keyword-argument has been used, every argument thereafter must be a 
keyword-argument.

So, positional-arguments first, and keyword-arguments last!

The positional-arguments must be in-order. The keyword-arguments may be 
in any sequence.


Question (which may have occurred to you):
what happens if we call

	parrot( 10_000, "dead", "voom", state="just resting" )

- which argument is applied to the state parameter?
(for you to consider and then dis/prove...)


To round-off (the difference between keyword-parameters and 
default-values): arguments are required for positional-parameters (as 
noted), whereas parameters with default-values may be omitted (optional).

Thus, (rare case) if use a keyword-parameter which does NOT have a 
default-value, an argument must be provided (whether in positional or 
keyword style).


(I've ignored the / and * symbols for defining parameter-types that follow)

-- 
Regards,
=dn

From mats at wichmann.us  Tue Mar  5 18:16:44 2024
From: mats at wichmann.us (Mats Wichmann)
Date: Tue, 5 Mar 2024 16:16:44 -0700
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
Message-ID: <d8fa4c3c-dfcf-4b7b-bb06-193093840496@wichmann.us>

On 3/5/24 10:52, Desiree C .Thomas wrote:

With a signature of:

def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):


> parrot(voltage=5.0, 'dead')
> 
> This is the error I get: SyntaxError: positional argument follows keyword argument on line 10
> 
>  From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.

voltage has no default so it is required, the others are optional.  If 
there are no special indicators in the signature (a lone / for 
positional-only and a lone * for keyword-only), then the original Python 
rules apply, which are that if a parameter is listed with a default it 
is optional and without one it is mandatory.  Positional arguments are 
consumed first, and matched up with the argument order in the signature. 
  Once a keyword argument is seen, all the rest must be keyword 
arguments.  You've violated that last bit: once you did "voltage=5.0" it 
is impossible for there to be any following positional arguments.  It 
would have been ok to say

parrot(voltage=5.0, state='dead')

or

parrot(state='dead', voltage=5.0)

or

parrot(5.0, 'dead')

but once you had a x=y form, no more positional args are accepted. As 
the error message said...



From threesomequarks at proton.me  Wed Mar  6 11:11:44 2024
From: threesomequarks at proton.me (ThreeBlindQuarks)
Date: Wed, 06 Mar 2024 16:11:44 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
Message-ID: <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>


Desiree,

Others have responded to your question about the way python handles mixtures of arguments to a function so what I am adding is a bit different.

As you note, when you write your function that may be used by others, they may not know or care about subtle rules that positional arguments come first and are mandatory.

So, in some cases, I find a style useful that makes more or even all arguments to be keyword arguments with a default.

Your first argument of voltage could be written as voltage=NULL or anything else that is meaningful to you as a way of recognizing the user did not specify a value. 

This means no error messages are supplied if the argument is not used so it is up to you, the programmer, to start your function body with appropriate code that detects what is missing and acts appropriately. Sometimes it means supplying an error message and/or returning with some error status. Other times, you can do anything from asking them to interactively supply a value (often not doable) to making up one with some calculation perhaps based on other arguments supplied.

The positive is that a function built with no positional arguments can be called very flexibly with arguments in the right order if not specified by name but also in any order if labeled.

Note not all languages come up with the same rules for something like this and python itself has in some ways evolved to currently be set up with the rules you are learning.

They may even make changes in the future.

- Q



Sent with Proton Mail secure email.

On Tuesday, March 5th, 2024 at 12:52 PM, Desiree C .Thomas <desireect at live.com> wrote:

> Hello there,
> 
> I hope this reaches you well.
> 
> So I am following this https://docs.python.org/3/tutorial/controlflow.html
> 
> I'm on 4.8.2. Keyword Argument
> Following the example
> 
> def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
> print("-- This parrot wouldn't", action, end=' ')
> print("if you put", voltage, "volts through it.")
> print("-- Lovely plumage, the", type)
> print("-- It's", state, "!")
> 
> So this is positional arguments
> 
> parrot(1000) # 1 positional argument
> parrot(voltage=1000) # 1 keyword argument
> parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments
> parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments
> parrot('a million', 'bereft of life', 'jump') # 3 positional arguments
> parrot('a thousand', state='pushing up the daisies')
> 
> 
> 1. So I understand the parrot(1000) would just input into the required argument voltage
> 2. Parrot voltage=1000 also input into the required argument voltage
> 3.
> parrot(voltage=1000000, action='VOOOOOM') I can enter the requirement argument and skip one of the arguments to input into action. The other non stated arguments just use the default values.
> 4.
> parrot(action='VOOOOOM', voltage=1000000) Here I accepted that I can state on the arguments I want to filled in just as long as the requirement argument is inputted. I also accepted that the requirement argument doesn't need to be declare first either.
> 5.
> parrot('a million', 'bereft of life', 'jump') The requirement argument was filled and the remaining two arguments were inputted in the respective order of the functions
> 6.
> parrot('a thousand', state='pushing up the daisies') I have accepted that the requirement argument was assumed to the first argument and accept to be 'a thousand' and the declared argument was input
> 
> Please feel free of my understanding so far.
> So continuing
> 
> 
> parrot()
> 
> The requirement argument isn't inputted therefore error.
> 
> 
> parrot(voltage=5.0, 'dead')
> 
> This is the error I get: SyntaxError: positional argument follows keyword argument on line 10
> 
> From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.
> 
> Thanks
> Desiree Cortez-Thomas
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

From desireect at live.com  Wed Mar  6 11:46:58 2024
From: desireect at live.com (Desiree C .Thomas)
Date: Wed, 6 Mar 2024 16:46:58 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
Message-ID: <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>

Hey Q,

I haven't seen the other replies to my question. Do you know where I can view them?

I have just seen yours. Also can I email you if I have further questions on Python?

Thank you
Desiree
________________________________
From: ThreeBlindQuarks <threesomequarks at proton.me>
Sent: 06 March 2024 16:11
To: Desiree C .Thomas <desireect at live.com>
Cc: tutor at python.org <tutor at python.org>
Subject: Re: [Tutor] Python question 4.8.2. Keyword Argument


Desiree,

Others have responded to your question about the way python handles mixtures of arguments to a function so what I am adding is a bit different.

As you note, when you write your function that may be used by others, they may not know or care about subtle rules that positional arguments come first and are mandatory.

So, in some cases, I find a style useful that makes more or even all arguments to be keyword arguments with a default.

Your first argument of voltage could be written as voltage=NULL or anything else that is meaningful to you as a way of recognizing the user did not specify a value.

This means no error messages are supplied if the argument is not used so it is up to you, the programmer, to start your function body with appropriate code that detects what is missing and acts appropriately. Sometimes it means supplying an error message and/or returning with some error status. Other times, you can do anything from asking them to interactively supply a value (often not doable) to making up one with some calculation perhaps based on other arguments supplied.

The positive is that a function built with no positional arguments can be called very flexibly with arguments in the right order if not specified by name but also in any order if labeled.

Note not all languages come up with the same rules for something like this and python itself has in some ways evolved to currently be set up with the rules you are learning.

They may even make changes in the future.

- Q



Sent with Proton Mail secure email.

On Tuesday, March 5th, 2024 at 12:52 PM, Desiree C .Thomas <desireect at live.com> wrote:

> Hello there,
>
> I hope this reaches you well.
>
> So I am following this https://docs.python.org/3/tutorial/controlflow.html
>
> I'm on 4.8.2. Keyword Argument
> Following the example
>
> def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
> print("-- This parrot wouldn't", action, end=' ')
> print("if you put", voltage, "volts through it.")
> print("-- Lovely plumage, the", type)
> print("-- It's", state, "!")
>
> So this is positional arguments
>
> parrot(1000) # 1 positional argument
> parrot(voltage=1000) # 1 keyword argument
> parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments
> parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments
> parrot('a million', 'bereft of life', 'jump') # 3 positional arguments
> parrot('a thousand', state='pushing up the daisies')
>
>
> 1. So I understand the parrot(1000) would just input into the required argument voltage
> 2. Parrot voltage=1000 also input into the required argument voltage
> 3.
> parrot(voltage=1000000, action='VOOOOOM') I can enter the requirement argument and skip one of the arguments to input into action. The other non stated arguments just use the default values.
> 4.
> parrot(action='VOOOOOM', voltage=1000000) Here I accepted that I can state on the arguments I want to filled in just as long as the requirement argument is inputted. I also accepted that the requirement argument doesn't need to be declare first either.
> 5.
> parrot('a million', 'bereft of life', 'jump') The requirement argument was filled and the remaining two arguments were inputted in the respective order of the functions
> 6.
> parrot('a thousand', state='pushing up the daisies') I have accepted that the requirement argument was assumed to the first argument and accept to be 'a thousand' and the declared argument was input
>
> Please feel free of my understanding so far.
> So continuing
>
>
> parrot()
>
> The requirement argument isn't inputted therefore error.
>
>
> parrot(voltage=5.0, 'dead')
>
> This is the error I get: SyntaxError: positional argument follows keyword argument on line 10
>
> From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.
>
> Thanks
> Desiree Cortez-Thomas
>
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

From threesomequarks at proton.me  Wed Mar  6 15:02:21 2024
From: threesomequarks at proton.me (ThreeBlindQuarks)
Date: Wed, 06 Mar 2024 20:02:21 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
 <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
Message-ID: <ejKyL7qpr85W0DOAdPPAYhAbOP4n7cmzuxs_WUgA5b0O9hybswbHr--FVt6WdYIspzYdivmsjSFD2gUorgSS4prm7tGnx1GIqD-aW-mzylg=@proton.me>



Desiree,

I won't repost what they wrote but will point you to the archives where all messages can be viewed various ways by you and anyone:

https://mail.python.org/pipermail/tutor/

For March of 2024 this is the thread:

[Tutor] Python question 4.8.2. Keyword Argument   Desiree C .Thomas
[Tutor] Python question 4.8.2. Keyword Argument   dn
[Tutor] Python question 4.8.2. Keyword Argument   Mats Wichmann
[Tutor] Python question 4.8.2. Keyword Argument   ThreeBlindQuarks
[Tutor] Python question 4.8.2. Keyword Argument   Desiree C .Thomas

The specific replies by Dave Neal and Mats Wichman are at:

https://mail.python.org/pipermail/tutor/2024-March/120966.html

https://mail.python.org/pipermail/tutor/2024-March/120967.html

I hope this helps.

The bottom line is the people who created this functionality had to write some general code that knows what the function declaration looked like including local names for the arguments and whether they had a default and also sees what the caller to a function supplies, and have to do a fairly complex task of matching positional and other parameters and applying some logic. Choices were made and you are learning the rules they chose.

I have seen other languages make other choices, as mentioned, such as whether they match a partial text like sta=whatever to mean state=whatever or what to do if an option is repeated.

As to why you did not see the other replies, who knows? It may have landed in your junk folder or maybe you only see it if people hit reply all? Also note their reply is embedded around and within your original text.

- Kyu 

Sent with Proton Mail secure email.

On Wednesday, March 6th, 2024 at 11:46 AM, Desiree C .Thomas <desireect at live.com> wrote:

> Hey Q,
> 
> I haven't seen the other replies to my question. Do you know where I can view them?
> 
> I have just seen yours. Also can I email you if I have further questions on Python?
> 
> Thank you
> Desiree
> ________________________________
> From: ThreeBlindQuarks threesomequarks at proton.me
> 
> Sent: 06 March 2024 16:11
> To: Desiree C .Thomas desireect at live.com
> 
> Cc: tutor at python.org tutor at python.org
> 
> Subject: Re: [Tutor] Python question 4.8.2. Keyword Argument
> 
> 
> Desiree,
> 
> Others have responded to your question about the way python handles mixtures of arguments to a function so what I am adding is a bit different.
> 
> As you note, when you write your function that may be used by others, they may not know or care about subtle rules that positional arguments come first and are mandatory.
> 
> So, in some cases, I find a style useful that makes more or even all arguments to be keyword arguments with a default.
> 
> Your first argument of voltage could be written as voltage=NULL or anything else that is meaningful to you as a way of recognizing the user did not specify a value.
> 
> This means no error messages are supplied if the argument is not used so it is up to you, the programmer, to start your function body with appropriate code that detects what is missing and acts appropriately. Sometimes it means supplying an error message and/or returning with some error status. Other times, you can do anything from asking them to interactively supply a value (often not doable) to making up one with some calculation perhaps based on other arguments supplied.
> 
> The positive is that a function built with no positional arguments can be called very flexibly with arguments in the right order if not specified by name but also in any order if labeled.
> 
> Note not all languages come up with the same rules for something like this and python itself has in some ways evolved to currently be set up with the rules you are learning.
> 
> They may even make changes in the future.
> 
> - Q
> 
> 
> 
> Sent with Proton Mail secure email.
> 
> 
> On Tuesday, March 5th, 2024 at 12:52 PM, Desiree C .Thomas desireect at live.com wrote:
> 
> > Hello there,
> > 
> > I hope this reaches you well.
> > 
> > So I am following this https://docs.python.org/3/tutorial/controlflow.html
> > 
> > I'm on 4.8.2. Keyword Argument
> > Following the example
> > 
> > def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
> > print("-- This parrot wouldn't", action, end=' ')
> > print("if you put", voltage, "volts through it.")
> > print("-- Lovely plumage, the", type)
> > print("-- It's", state, "!")
> > 
> > So this is positional arguments
> > 
> > parrot(1000) # 1 positional argument
> > parrot(voltage=1000) # 1 keyword argument
> > parrot(voltage=1000000, action='VOOOOOM') # 2 keyword arguments
> > parrot(action='VOOOOOM', voltage=1000000) # 2 keyword arguments
> > parrot('a million', 'bereft of life', 'jump') # 3 positional arguments
> > parrot('a thousand', state='pushing up the daisies')
> > 
> > 1. So I understand the parrot(1000) would just input into the required argument voltage
> > 2. Parrot voltage=1000 also input into the required argument voltage
> > 3.
> > parrot(voltage=1000000, action='VOOOOOM') I can enter the requirement argument and skip one of the arguments to input into action. The other non stated arguments just use the default values.
> > 4.
> > parrot(action='VOOOOOM', voltage=1000000) Here I accepted that I can state on the arguments I want to filled in just as long as the requirement argument is inputted. I also accepted that the requirement argument doesn't need to be declare first either.
> > 5.
> > parrot('a million', 'bereft of life', 'jump') The requirement argument was filled and the remaining two arguments were inputted in the respective order of the functions
> > 6.
> > parrot('a thousand', state='pushing up the daisies') I have accepted that the requirement argument was assumed to the first argument and accept to be 'a thousand' and the declared argument was input
> > 
> > Please feel free of my understanding so far.
> > So continuing
> > 
> > parrot()
> > 
> > The requirement argument isn't inputted therefore error.
> > 
> > parrot(voltage=5.0, 'dead')
> > 
> > This is the error I get: SyntaxError: positional argument follows keyword argument on line 10
> > 
> > From my understanding, I thought the voltage should accept voltage to be 5.0 and update state into 'dead'? Can I get an explaination for this error.
> > 
> > Thanks
> > Desiree Cortez-Thomas
> > 
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> 
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

From alan.gauld at yahoo.co.uk  Wed Mar  6 18:45:59 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Wed, 6 Mar 2024 23:45:59 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
 <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
Message-ID: <usav7n$10b3$1@ciao.gmane.io>

On 06/03/2024 16:46, Desiree C .Thomas wrote:
> Hey Q,
> 
> I haven't seen the other replies to my question. Do you know where I can view them?

When you post to the list, replies will go to the list. To
see them you need to be subscribed to the list. You can do
so using the link below.

The other option as 'Q' said is to look at the list archives.

> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From PythonList at DancesWithMice.info  Wed Mar  6 20:31:56 2024
From: PythonList at DancesWithMice.info (dn)
Date: Thu, 7 Mar 2024 14:31:56 +1300
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
Message-ID: <28ca4b6e-41dd-45e1-ad19-387ae91cce14@DancesWithMice.info>

On 7/03/24 05:11, ThreeBlindQuarks via Tutor wrote:
> 
> Desiree,
> 
> Others have responded to your question about the way python handles mixtures of arguments to a function so what I am adding is a bit different.
> 
> As you note, when you write your function that may be used by others, they may not know or care about subtle rules that positional arguments come first and are mandatory.
> 
> So, in some cases, I find a style useful that makes more or even all arguments to be keyword arguments with a default.
> 
> Your first argument of voltage could be written as voltage=NULL or anything else that is meaningful to you as a way of recognizing the user did not specify a value.
> 
> This means no error messages are supplied if the argument is not used so it is up to you, the programmer, to start your function body with appropriate code that detects what is missing and acts appropriately. Sometimes it means supplying an error message and/or returning with some error status. Other times, you can do anything from asking them to interactively supply a value (often not doable) to making up one with some calculation perhaps based on other arguments supplied.

+1

The case where it is acceptable to have Python splatting:

TypeError: function_name() missing .. required positional argument: ...

across the terminal is very rare. It might be OK if only you and I will 
ever call the function. Everyone else deserves better!

Let's say the wider system will give us a name or an id, and the 
function's task is to advise whether or not the name/id appears in some 
data-store, it seems reasonable to say that no-one would expect to 
utilise our (magnificent) function without providing the subject-matter. 
However, the operative word is "reasonable"!

Traditionally, pythonista have followed a free-wheeling EAFP* 
life-style. This has been changing, possibly with frequency of 
application to Data Science projects, to LBYL* (which is also how us 
old-timers were originally trained) - see also Type Hints.

* if don't know these acronyms/terms, please invest a little bit of 
valuable reading - and reflection...


Adding to the above, advice that as soon as the parameter-list reaches 
three elements, switch to named-parameters; simply because the process 
of checking relative-positioning is a recipe for eye-strain and 
cross-eyes (both meanings)!

-- 
Regards,
=dn

From PythonList at DancesWithMice.info  Wed Mar  6 21:22:49 2024
From: PythonList at DancesWithMice.info (dn)
Date: Thu, 7 Mar 2024 15:22:49 +1300
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <usav7n$10b3$1@ciao.gmane.io>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
 <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <usav7n$10b3$1@ciao.gmane.io>
Message-ID: <bc786e2c-5f42-487e-9844-6464b9589c8e@DancesWithMice.info>

On 7/03/24 12:45, Alan Gauld via Tutor wrote:
> On 06/03/2024 16:46, Desiree C .Thomas wrote:
>> Hey Q,
>>
>> I haven't seen the other replies to my question. Do you know where I can view them?
> 
> When you post to the list, replies will go to the list. To
> see them you need to be subscribed to the list. You can do
> so using the link below.

Surely the OP must be - to have posted in the first place?

Possibly a local problem with filtering?

-- 
Regards,
=dn

From alan.gauld at yahoo.co.uk  Thu Mar  7 04:58:01 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Thu, 7 Mar 2024 09:58:01 +0000
Subject: [Tutor] Python question 4.8.2. Keyword Argument
In-Reply-To: <bc786e2c-5f42-487e-9844-6464b9589c8e@DancesWithMice.info>
References: <GVXPR09MB6656775437D6CEDBB44BFA06DD222@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <0y0NYwFwRp6DjccFlD32Vzo6hJsSvdzTwhI1PMChEsp_tArL1lz0MRWSC1Hhh5ItLwulCGJH1I84twxpJW9JniaUQI9oLjXU4yVrGqdVVhk=@proton.me>
 <GVXPR09MB66568C2BC6FDA335390E50A6DD212@GVXPR09MB6656.eurprd09.prod.outlook.com>
 <usav7n$10b3$1@ciao.gmane.io>
 <bc786e2c-5f42-487e-9844-6464b9589c8e@DancesWithMice.info>
Message-ID: <usc339$ijd$1@ciao.gmane.io>

On 07/03/2024 02:22, dn via Tutor wrote:

>> see them you need to be subscribed to the list. You can do
>> so using the link below.
> 
> Surely the OP must be - to have posted in the first place?

Nope, anyone can post, it just drops into the moderation
queue. If it looks like a valid Python question I will
let it go through...

You only need to subscribe if you want to receive mail
from the list.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From PythonList at DancesWithMice.info  Sun Mar 17 02:46:01 2024
From: PythonList at DancesWithMice.info (dn)
Date: Sun, 17 Mar 2024 19:46:01 +1300
Subject: [Tutor] MTG: Introductions to PyQt and DataClasses
Message-ID: <8f393a18-9b22-484b-b9cb-5652d87ff842@DancesWithMice.info>

The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT 
(0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual 
meeting.

Part 1: Learn the basics of PyQt with code examples.
Hannan Khan is currently consulting as a Data Scientist for the (US) 
National Oceanic and Atmospheric Administration. He holds a Bachelor's 
degree in Neuroscience as well as a Masters in Computer Science. As a 
keen member of the PySprings Users' Group (Colorado), his contribution 
is part of a collaboration between our two PUGs.

Part 2: Why use Dataclasses?
- will be the question asked, and answered, by yours truly. After 
surveying a number of groups, it seems most of us know that Dataclasses 
are available, but we don't use them - mostly because we haven't 
ascertained their place in our tool-box. By the end of this session you 
will, and will have good reason to use (or not) Dataclasses!

Everyone is welcome from every location and any time-zone. The NZPUG 
Code of Conduct applies. JetBrains have kindly donated a door-prize. Our 
BigBlueButton web-conferencing instance is best accessed using Chromium, 
Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set 
will facilitate asking questions but text-chat will be available.

Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
See you there!
=dn, Branch Leader

From PythonList at DancesWithMice.info  Sun Mar 17 16:34:36 2024
From: PythonList at DancesWithMice.info (dn)
Date: Mon, 18 Mar 2024 09:34:36 +1300
Subject: [Tutor] MTG: Introductions to PyQt and DataClasses
In-Reply-To: <1C9A4783-B8A0-436E-ADBC-B22D1F510C8E@sbcglobal.net>
References: <8f393a18-9b22-484b-b9cb-5652d87ff842@DancesWithMice.info>
 <1C9A4783-B8A0-436E-ADBC-B22D1F510C8E@sbcglobal.net>
Message-ID: <8260dfe2-c027-4302-b623-1712eebc93b7@DancesWithMice.info>

On 17/03/24 23:40, Jim Schwartz wrote:
> Will it be recorded?

Better than that (assumption) "coming soon" - please join-up or keep an 
eye on PySprings' Meetup ANNs: https://www.meetup.com/pysprings/


>> On Mar 17, 2024, at 1:47?AM, dn via Python-list <python-list at python.org> wrote:
>>
>> ?The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual meeting.
>>
>> Part 1: Learn the basics of PyQt with code examples.
>> Hannan Khan is currently consulting as a Data Scientist for the (US) National Oceanic and Atmospheric Administration. He holds a Bachelor's degree in Neuroscience as well as a Masters in Computer Science. As a keen member of the PySprings Users' Group (Colorado), his contribution is part of a collaboration between our two PUGs.
>>
>> Part 2: Why use Dataclasses?
>> - will be the question asked, and answered, by yours truly. After surveying a number of groups, it seems most of us know that Dataclasses are available, but we don't use them - mostly because we haven't ascertained their place in our tool-box. By the end of this session you will, and will have good reason to use (or not) Dataclasses!
>>
>> Everyone is welcome from every location and any time-zone. The NZPUG Code of Conduct applies. JetBrains have kindly donated a door-prize. Our BigBlueButton web-conferencing instance is best accessed using Chromium, Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set will facilitate asking questions but text-chat will be available.
>>
>> Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
>> See you there!
>> =dn, Branch Leader
>> --
>> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
Regards,
=dn


From PythonList at DancesWithMice.info  Sun Mar 17 17:18:08 2024
From: PythonList at DancesWithMice.info (dn)
Date: Mon, 18 Mar 2024 10:18:08 +1300
Subject: [Tutor] MTG: Introductions to PyQt and DataClasses
In-Reply-To: <8588900C-3514-4B70-BD78-ABD3073BCC7F@sbcglobal.net>
References: <8260dfe2-c027-4302-b623-1712eebc93b7@DancesWithMice.info>
 <8588900C-3514-4B70-BD78-ABD3073BCC7F@sbcglobal.net>
Message-ID: <62cace3b-bcfa-481b-ab12-5b457caac18f@DancesWithMice.info>

On 18/03/24 10:02, Jim Schwartz wrote:
> Actually, I have a sleep disorder that requires me to keep a constant sleep schedule. Thats why I asked.

At a weekend meeting, discussion swirled around topics such as the best 
way to learn/work, how much work we should attempt in one sitting, 
could/should I 'do more', and similar.

One of the valuable observations is that most of us would benefit by 
improving our sleep-schedule and ensuring we do sleep for sufficient 
time (probably longer than current habit).

-- 
Regards,
=dn


From nathan-tech at hotmail.com  Sun Mar 17 18:38:15 2024
From: nathan-tech at hotmail.com (Nathan Smith)
Date: Sun, 17 Mar 2024 22:38:15 +0000
Subject: [Tutor] MTG: Introductions to PyQt and DataClasses
In-Reply-To: <8260dfe2-c027-4302-b623-1712eebc93b7@DancesWithMice.info>
References: <8f393a18-9b22-484b-b9cb-5652d87ff842@DancesWithMice.info>
 <1C9A4783-B8A0-436E-ADBC-B22D1F510C8E@sbcglobal.net>
 <8260dfe2-c027-4302-b623-1712eebc93b7@DancesWithMice.info>
Message-ID: <AS2PR10MB76389F2E91130B82DCFEBCCFE42E2@AS2PR10MB7638.EURPRD10.PROD.OUTLOOK.COM>

Hello,


Is there any chance this will be, or could be, recorded?


I am extremely interested in this, but the timing is bad for me, :(


Best,

Nathan

On 17/03/2024 20:34, dn via Tutor wrote:
> On 17/03/24 23:40, Jim Schwartz wrote:
>> Will it be recorded?
>
> Better than that (assumption) "coming soon" - please join-up or keep 
> an eye on PySprings' Meetup ANNs: 
> https://www.meetup.com/pysprings/
>
>
>>> On Mar 17, 2024, at 1:47?AM, dn via Python-list 
>>> <python-list at python.org> wrote:
>>>
>>> ?The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 
>>> NZDT (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a 
>>> virtual meeting.
>>>
>>> Part 1: Learn the basics of PyQt with code examples.
>>> Hannan Khan is currently consulting as a Data Scientist for the (US) 
>>> National Oceanic and Atmospheric Administration. He holds a 
>>> Bachelor's degree in Neuroscience as well as a Masters in Computer 
>>> Science. As a keen member of the PySprings Users' Group (Colorado), 
>>> his contribution is part of a collaboration between our two PUGs.
>>>
>>> Part 2: Why use Dataclasses?
>>> - will be the question asked, and answered, by yours truly. After 
>>> surveying a number of groups, it seems most of us know that 
>>> Dataclasses are available, but we don't use them - mostly because we 
>>> haven't ascertained their place in our tool-box. By the end of this 
>>> session you will, and will have good reason to use (or not) 
>>> Dataclasses!
>>>
>>> Everyone is welcome from every location and any time-zone. The NZPUG 
>>> Code of Conduct applies. JetBrains have kindly donated a door-prize. 
>>> Our BigBlueButton web-conferencing instance is best accessed using 
>>> Chromium, Brave, Vivaldi, Safari, etc, (rather than Firefox - for 
>>> now). A head-set will facilitate asking questions but text-chat will 
>>> be available.
>>>
>>> Please RSVP at 
>>> https://www.meetup.com/nzpug-auckland/events/299764049/
>>> See you there!
>>> =dn, Branch Leader
>>> -- 
>>> https://mail.python.org/mailman/listinfo/python-list 
>>>
>>
>

From jschwar at sbcglobal.net  Sun Mar 17 06:40:44 2024
From: jschwar at sbcglobal.net (Jim Schwartz)
Date: Sun, 17 Mar 2024 05:40:44 -0500
Subject: [Tutor] MTG: Introductions to PyQt and DataClasses
In-Reply-To: <8f393a18-9b22-484b-b9cb-5652d87ff842@DancesWithMice.info>
References: <8f393a18-9b22-484b-b9cb-5652d87ff842@DancesWithMice.info>
Message-ID: <1C9A4783-B8A0-436E-ADBC-B22D1F510C8E@sbcglobal.net>

Will it be recorded?  

Sent from my iPhone

> On Mar 17, 2024, at 1:47?AM, dn via Python-list <python-list at python.org> wrote:
> 
> ?The Auckland Branch of NZPUG meets this Wednesday, 20 March at 1830 NZDT (0530 UTC, midnight-ish Tue/Wed in American time-zones), for a virtual meeting.
> 
> Part 1: Learn the basics of PyQt with code examples.
> Hannan Khan is currently consulting as a Data Scientist for the (US) National Oceanic and Atmospheric Administration. He holds a Bachelor's degree in Neuroscience as well as a Masters in Computer Science. As a keen member of the PySprings Users' Group (Colorado), his contribution is part of a collaboration between our two PUGs.
> 
> Part 2: Why use Dataclasses?
> - will be the question asked, and answered, by yours truly. After surveying a number of groups, it seems most of us know that Dataclasses are available, but we don't use them - mostly because we haven't ascertained their place in our tool-box. By the end of this session you will, and will have good reason to use (or not) Dataclasses!
> 
> Everyone is welcome from every location and any time-zone. The NZPUG Code of Conduct applies. JetBrains have kindly donated a door-prize. Our BigBlueButton web-conferencing instance is best accessed using Chromium, Brave, Vivaldi, Safari, etc, (rather than Firefox - for now). A head-set will facilitate asking questions but text-chat will be available.
> 
> Please RSVP at https://www.meetup.com/nzpug-auckland/events/299764049/
> See you there!
> =dn, Branch Leader
> --
> https://mail.python.org/mailman/listinfo/python-list


From sjeik_appie at hotmail.com  Tue Mar 19 07:16:45 2024
From: sjeik_appie at hotmail.com (Albert-Jan Roskam)
Date: Tue, 19 Mar 2024 12:16:45 +0100
Subject: [Tutor] Patching os.environ
Message-ID: <DB9PR10MB6689202CE9979073FBBDD8A5832C2@DB9PR10MB6689.EURPRD10.PROD.OUTLOOK.COM>

   Hi,
   What is the correct way of patching a dict in a test fixture? Below,
   MyTest1 fails, while MyTest2 succeeds. I thought the two tests were
   equivalent!
   Thanks!
   Albert-Jan
   import os
   import unittest
   from unittest.mock import patch
   class MyTest1(unittest.TestCase):
       def setUp(self):
           patcher = patch.dict(os.environ, {"FOO": "bar"}, clear=True)
           self.addCleanup(patcher.stop)
       def test_bla1(self):
           # why does this test fail?
           self.assertEqual(os.environ.get("FOO"), "bar")
   class MyTest2(unittest.TestCase):
       @patch.dict(os.environ, {"FOO": "bar"}, clear=True)
       def test_bla2(self):
           self.assertEqual(os.environ.get("FOO"), "bar")
   if __name__ == "__main__":
       unittest.main()

From sjeik_appie at hotmail.com  Tue Mar 19 07:41:31 2024
From: sjeik_appie at hotmail.com (Albert-Jan Roskam)
Date: Tue, 19 Mar 2024 12:41:31 +0100
Subject: [Tutor] Patching os.environ
In-Reply-To: <DB9PR10MB6689202CE9979073FBBDD8A5832C2@DB9PR10MB6689.EURPRD10.PROD.OUTLOOK.COM>
Message-ID: <DB9PR10MB6689BCFAB2F444FDF51C04C7832C2@DB9PR10MB6689.EURPRD10.PROD.OUTLOOK.COM>

   Aaah.. got it already: I have use "patcher.start()" after I've defined
   it.
   On Mar 19, 2024 12:16, Albert-Jan Roskam <sjeik_appie at hotmail.com> wrote:

        Hi,
        What is the correct way of patching a dict in a test fixture? Below,
        MyTest1 fails, while MyTest2 succeeds. I thought the two tests were
        equivalent!
        Thanks!
        Albert-Jan
        import os
        import unittest
        from unittest.mock import patch
        class MyTest1(unittest.TestCase):
            def setUp(self):
                patcher = patch.dict(os.environ, {"FOO": "bar"}, clear=True)
                self.addCleanup(patcher.stop)
            def test_bla1(self):
                # why does this test fail?
                self.assertEqual(os.environ.get("FOO"), "bar")
        class MyTest2(unittest.TestCase):
            @patch.dict(os.environ, {"FOO": "bar"}, clear=True)
            def test_bla2(self):
                self.assertEqual(os.environ.get("FOO"), "bar")
        if __name__ == "__main__":
            unittest.main()
     _______________________________________________
     Tutor maillist  -  Tutor at python.org
     To unsubscribe or change subscription options:
     https://mail.python.org/mailman/listinfo/tutor

From miwuala at yahoo.com  Wed Mar 20 00:09:55 2024
From: miwuala at yahoo.com (Iwuala Chibueze)
Date: Wed, 20 Mar 2024 04:09:55 +0000 (UTC)
Subject: [Tutor] I need help with Django
References: <125065740.88035.1710907795871.ref@mail.yahoo.com>
Message-ID: <125065740.88035.1710907795871@mail.yahoo.com>

Dear Sir/Madam,I need complete details of running a inventory website with python Django.
Kind Regards?
Chibueze?

Yahoo Mail: Search, Organize, Conquer

From alan.gauld at yahoo.co.uk  Thu Mar 21 05:30:07 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Thu, 21 Mar 2024 09:30:07 +0000
Subject: [Tutor] I need help with Django
In-Reply-To: <125065740.88035.1710907795871@mail.yahoo.com>
References: <125065740.88035.1710907795871.ref@mail.yahoo.com>
 <125065740.88035.1710907795871@mail.yahoo.com>
Message-ID: <utgumv$rr7$1@ciao.gmane.io>

On 20/03/2024 04:09, Iwuala Chibueze via Tutor wrote:
> Dear Sir/Madam,I need complete details of running a inventory website with python Django.

This forum is for the Pyhon language and standard library,
Django is a bit beyond that scope.

There is an active community for Django however.
You might try here:

https://www.djangoproject.com/community/

It will help if you ask specific questions and provide
some background for them to work with.
For example:
Did you write the website? If not where did you get it?
What kind of issues are you having? Configuration? Bugs?
Performance etc.?

If you are seeing error message post them too.

The more specific you can be the better chance you will
have of them helping you.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From aayushshah342 at gmail.com  Sat Mar 23 04:08:24 2024
From: aayushshah342 at gmail.com (aayushshah342 at gmail.com)
Date: Sat, 23 Mar 2024 13:38:24 +0530
Subject: [Tutor] Ubale to install Mediapipe
Message-ID: <002101da7cf9$4880ea40$d982bec0$@gmail.com>

Unable to install mediapipe library on python version 3.12

Please help


From mats at wichmann.us  Sat Mar 23 08:25:10 2024
From: mats at wichmann.us (Mats Wichmann)
Date: Sat, 23 Mar 2024 06:25:10 -0600
Subject: [Tutor] Ubale to install Mediapipe
In-Reply-To: <002101da7cf9$4880ea40$d982bec0$@gmail.com>
References: <002101da7cf9$4880ea40$d982bec0$@gmail.com>
Message-ID: <7EA8BEFE-72A4-44E5-8C8F-85B6DC48EFCE@wichmann.us>

On March 23, 2024 2:08:24 AM MDT, aayushshah342 at gmail.com wrote:
>Unable to install mediapipe library on python version 3.12
>
>Please help
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor

use 3.11. you can look here: https://pypi.org/project/mediapipe/#files 
and see that project has not released wheels for python 3.12.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

From aayushshah342 at gmail.com  Sat Mar 23 12:26:06 2024
From: aayushshah342 at gmail.com (Aayush shah)
Date: Sat, 23 Mar 2024 21:56:06 +0530
Subject: [Tutor] Ubale to install Mediapipe
In-Reply-To: <7EA8BEFE-72A4-44E5-8C8F-85B6DC48EFCE@wichmann.us>
References: <7EA8BEFE-72A4-44E5-8C8F-85B6DC48EFCE@wichmann.us>
Message-ID: <E875E8A8-B0AA-4DF1-B54C-3C232D48A2F5@gmail.com>

Thanks, It worked 


> On 23-Mar-2024, at 17:55, Mats Wichmann <mats at wichmann.us> wrote:
> 
> ?On March 23, 2024 2:08:24 AM MDT, aayushshah342 at gmail.com wrote:
>> Unable to install mediapipe library on python version 3.12
>> 
>> Please help
>> 
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
> 
> use 3.11. you can look here: https://pypi.org/project/mediapipe/#files
> and see that project has not released wheels for python 3.12.
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.

From phillor9 at gmail.com  Mon Mar 25 03:07:40 2024
From: phillor9 at gmail.com (Phil)
Date: Mon, 25 Mar 2024 17:07:40 +1000
Subject: [Tutor] Expanding a frame into an expanding window
Message-ID: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>

Thank you for reading this.

I've created a custom widget that I'm importing into an app.? The app 
includes 3 frame classes including the imported custom widget class. The 
widgets on those frames all use the grid method.

When the app window is expanded the frames expand and frame's widgets 
move except for the frame that uses the imported class. That frame 
expands but the widgets on that frame remain in place. So there must be 
a problem with the custom widget class.

The following are 2 simplified versions of the custom widget class to 
illustrate the problem.

The version that uses the pack method does expand correctly but, of 
course, the two widgets are under each other rather than beside each 
other.? The frame that uses the imported class also expands but the two 
widgets do not move.

import tkinter as tk


class SimpleEntry(tk.Frame):
 ??? def __init__(self, parent, bg_colour="light blue"): # default 
colour is light blue
 ??????? super().__init__(parent, bg=bg_colour)

 ??????? self.enter_label = tk.Label(self, text="enter a number")
 ??????? self.number_enter = tk.Entry(self)

 ??????? self.enter_label.grid(row=0, column=0, padx=5, pady=5, 
sticky="nsew")
 ??????? self.number_enter.grid(row=0, column=1, padx=5, pady=5, 
sticky="nsew")

'''

import tkinter as tk


class SimpleEntry(tk.Frame):
 ??? def __init__(self, parent, bg_colour="light blue"):
 ??????? super().__init__(parent, bg=bg_colour)

 ??????? self.enter_label = tk.Label(self, text="enter a number")
 ??????? self.number_enter = tk.Entry(self)

 ??????? self.enter_label.pack(expand=True)
 ??????? self.number_enter.pack(expand=True)

'''

I've spent all day on this and all I've achieved is a headache.

-- 
Regards,
Phil


From alan.gauld at yahoo.co.uk  Mon Mar 25 07:05:34 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Mon, 25 Mar 2024 11:05:34 +0000
Subject: [Tutor] Expanding a frame into an expanding window
In-Reply-To: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>
References: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>
Message-ID: <utrlpv$10eo$1@ciao.gmane.io>

On 25/03/2024 07:07, Phil wrote:

> When the app window is expanded the frames expand and frame's widgets 
> move except for the frame that uses the imported class. That frame 
> expands but the widgets on that frame remain in place. So there must be 
> a problem with the custom widget class.

I'm not seeing the problem. Both widgets move when the window is expanded.
Here is my code, only slightly modified from yours:


########################
import tkinter as tk


class SimpleEntryGrid(tk.Frame):
     def __init__(self, parent, bg_colour="light blue"):
         super().__init__(parent, bg=bg_colour)

         self.enter_label = tk.Label(self, text="enter a number")
         self.number_enter = tk.Entry(self)

         self.enter_label.grid(row=0, column=0,
                               padx=5, pady=5, sticky="nsew")
         self.number_enter.grid(row=0, column=1,
                               padx=5, pady=5, sticky="nsew")


class SimpleEntryPack(tk.Frame):
     def __init__(self, parent, bg_colour="light blue"):
         super().__init__(parent, bg=bg_colour)

         self.enter_label = tk.Label(self, text="enter a number")
         self.number_enter = tk.Entry(self)

         self.enter_label.pack(side=tk.LEFT,
                               padx=5, pady=5, expand=True)
         self.number_enter.pack(side=tk.LEFT,
                                padx=5, pady=5, expand=True)

top = tk.Tk()
seg = SimpleEntryGrid(top)
sep = SimpleEntryPack(top, bg_colour="grey")
seg.pack(side=tk.LEFT, padx=15, pady=10, expand=True)
sep.pack(side=tk.LEFT, padx=15, pady=10, expand=True)

top.mainloop()


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From phillor9 at gmail.com  Mon Mar 25 18:57:09 2024
From: phillor9 at gmail.com (Phil)
Date: Tue, 26 Mar 2024 08:57:09 +1000
Subject: [Tutor] Expanding a frame into an expanding window
In-Reply-To: <utrlpv$10eo$1@ciao.gmane.io>
References: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>
 <utrlpv$10eo$1@ciao.gmane.io>
Message-ID: <1e7d0b19-3819-4642-9cd4-694475cf1cde@gmail.com>


On 25/3/24 21:05, Alan Gauld via Tutor wrote:
> On 25/03/2024 07:07, Phil wrote:
>
> I'm not seeing the problem. Both widgets move when the window is expanded.
> Here is my code, only slightly modified from yours:
>
>
> Thank you Alan for your reply and I appreaciate it geatly. The problem only occures when the class SimpleEntry is imported. The ButtonFrame widget moves but the EnrtyFrame widget (SimpleEntry) does not move.

import tkinter as tk
from tkinter_entry_class import SimpleEntry


class EntryFrame(tk.Frame):
 ??? def __init__(self, parent):
 ??????? super().__init__(parent)
 ??????? self.entry_widget = SimpleEntry(self, bg_colour="yellow")
 ??????? self.entry_widget.pack(fill="both", expand=True)


class ButtonFrame(tk.Frame):
 ??? def __init__(self, parent):
 ??????? super().__init__(parent, bg="light green")
 ??????? self.add_button = tk.Button(self, text="Press me", 
command=self.on_button_click)
 ??????? self.add_button.pack()

 ??? def on_button_click(self):
 ??????? pass


class App(tk.Tk):
 ??? def __init__(self):
 ??????? super().__init__()
 ??????? self.title("Simple Class Test")

 ??????? self.entry_frame = EntryFrame(self)
 ??????? self.button_frame = ButtonFrame(self)

 ??????? self.entry_frame.grid(row=0, column=0, padx=5, pady=5, 
sticky="nsew")
 ??????? self.button_frame.grid(row=1, column=0, padx=5, pady=5, 
sticky="nsew")

 ??????? self.grid_rowconfigure(0, weight=1)
 ??????? self.grid_rowconfigure(1, weight=1)
 ??????? self.grid_columnconfigure(0, weight=1)


def main():
 ??? app = App()
 ??? app.mainloop()


if __name__ == "__main__":
 ??? main()


-- 
Regards,
Phil

From alan.gauld at yahoo.co.uk  Mon Mar 25 20:58:12 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 26 Mar 2024 00:58:12 +0000
Subject: [Tutor] Expanding a frame into an expanding window
In-Reply-To: <1e7d0b19-3819-4642-9cd4-694475cf1cde@gmail.com>
References: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>
 <utrlpv$10eo$1@ciao.gmane.io>
 <1e7d0b19-3819-4642-9cd4-694475cf1cde@gmail.com>
Message-ID: <utt6j4$fn8$1@ciao.gmane.io>

On 25/03/2024 22:57, Phil wrote:

>> Thank you Alan for your reply and I appreaciate it geatly. 
> The problem only occures when the class SimpleEntry is imported. 
> The ButtonFrame widget moves but the EnrtyFrame widget (SimpleEntry) does not move.


class SimpleEntry(tk.Frame):
     def __init__(self, parent, bg_colour="light blue"):
         super().__init__(parent, bg=bg_colour)

         self.enter_label = tk.Label(self, text="enter a number")
         self.number_enter = tk.Entry(self)

         self.enter_label.grid(row=0, column=0,
                               padx=5, pady=5, sticky="nsew")
         self.number_enter.grid(row=0, column=1,
                                padx=5, pady=5, sticky="nsew")

> class EntryFrame(tk.Frame):
>  ??? def __init__(self, parent):
>  ??????? super().__init__(parent)
>  ??????? self.entry_widget = SimpleEntry(self, bg_colour="yellow")
>  ??????? self.entry_widget.pack(fill="both", expand=True)
> 
> 
> class ButtonFrame(tk.Frame):
>  ??? def __init__(self, parent):
>  ??????? super().__init__(parent, bg="light green")
>  ??????? self.add_button = tk.Button(self, text="Press me", 
>                                      command=self.on_button_click)
>  ??????? self.add_button.pack(fill="both", expand=True)
> 
>  ??? def on_button_click(self):
>  ??????? pass
> 
> 
> class App(tk.Tk):
>  ??? def __init__(self):
>  ??????? super().__init__()
>  ??????? self.title("Simple Class Test")
> 
>  ??????? self.entry_frame = EntryFrame(self)
>  ??????? self.button_frame = ButtonFrame(self)
> 
>  ??????? self.entry_frame.grid(row=0, column=0,                                  padx=5, pady=5, sticky="nsew")
>  ??????? self.button_frame.grid(row=1, column=0, 
                                  padx=5, pady=5, sticky="nsew")
> 
>  ??????? self.grid_rowconfigure(0, weight=1)
>  ??????? self.grid_rowconfigure(1, weight=1)
>  ??????? self.grid_columnconfigure(0, weight=1)

Notice that you set the frames here to have weight=1
That means these two frames expand when resized.
But notice that inside the SimpleEntry frame you do not
set the weights to 1 so they use the default of zero
and do not expand.

Adding

>          self.grid_rowconfigure(0, weight=1)
>          self.grid_columnconfigure(0, weight=1)

to the SimpleEntry class should resolve things

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From phillor9 at gmail.com  Mon Mar 25 21:14:17 2024
From: phillor9 at gmail.com (Phil)
Date: Tue, 26 Mar 2024 11:14:17 +1000
Subject: [Tutor] Expanding a frame into an expanding window
In-Reply-To: <utt6j4$fn8$1@ciao.gmane.io>
References: <51b7daa9-f3d2-491f-b699-4835d986c357@gmail.com>
 <utrlpv$10eo$1@ciao.gmane.io>
 <1e7d0b19-3819-4642-9cd4-694475cf1cde@gmail.com> <utt6j4$fn8$1@ciao.gmane.io>
Message-ID: <d856e569-b68d-49a8-9926-976010ac5d75@gmail.com>


On 26/3/24 10:58, Alan Gauld via Tutor wrote:
>           self.grid_rowconfigure(0, weight=1)
>           self.grid_columnconfigure(0, weight=1)
Thank you again Alan and the problem is now solved. I think I had tried 
that earlier because I'd seen it on StackOverflow but it didn't make any 
difference at the time so I discounted that idea. I can see that I need 
to read up on weight and understand it's importance.

-- 
Regards,
Phil

From jlocklee at sfsu.edu  Mon Mar 25 15:52:23 2024
From: jlocklee at sfsu.edu (Jonathan Wilson)
Date: Mon, 25 Mar 2024 19:52:23 +0000
Subject: [Tutor] Thank you for your review and assistance
Message-ID: <DM6PR02MB49539ACBF1AFCC179AFBF4BEBE362@DM6PR02MB4953.namprd02.prod.outlook.com>

Hello. I am getting an error in the beginning of my python script and it is referring to this line:

newDBFileName = today.strftime(.format(today.month, today.day)) + '  '
                                   ^
SyntaxError: invalid syntax

Can someone tell me what the invalid syntax is here for this line? Appreciate any help you can give. (new python coder)

Best,

Jonathan

From jlocklee at sfsu.edu  Mon Mar 25 15:59:20 2024
From: jlocklee at sfsu.edu (Jonathan Wilson)
Date: Mon, 25 Mar 2024 19:59:20 +0000
Subject: [Tutor] Thanks for your review
Message-ID: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>

Hello. I am getting an error in the beginning of my python script and it is referring to this line:

newDBFileName = today.strftime(.format(today.month, today.day)) + '  '
                                   ^
SyntaxError: invalid syntax

Can someone tell me what the invalid syntax is here for this line? Appreciate any help you can give. (new python coder)

The arrow is pointing to the .ahead of the format.

Best,

Jonathan

From PythonList at DancesWithMice.info  Tue Mar 26 01:18:35 2024
From: PythonList at DancesWithMice.info (dn)
Date: Tue, 26 Mar 2024 18:18:35 +1300
Subject: [Tutor] Thanks for your review
In-Reply-To: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>
References: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>
Message-ID: <f8fb617b-194e-4a97-b545-d296af01ce8d@DancesWithMice.info>

On 26/03/24 08:59, Jonathan Wilson via Tutor wrote:
> Hello. I am getting an error in the beginning of my python script and it is referring to this line:
> 
> newDBFileName = today.strftime(.format(today.month, today.day)) + '  '
>                                     ^
> SyntaxError: invalid syntax
> 
> Can someone tell me what the invalid syntax is here for this line? Appreciate any help you can give. (new python coder)
> 
> The arrow is pointing to the .ahead of the format.

Have you copied this from somewhere, or is it your own code?

The error.message is telling you that the dot cannot come after the 
left-parenthesis.

However, more importantly, in tutorials the word "format" is usually a 
place-holder for codes which determine how you want the datetime object 
to be formatted. Sorry if this notation has caused confusion.

Don't ask me where the dot came in.

The contents of the inner parenthesis don't look like formatting 
instructions.


Perhaps you could describe the expected output in English?


Web.Refs:

The docs: 
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior

A useful tutorial: https://pynative.com/python-datetime-format-strftime/

-- 
Regards,
=dn

From alan.gauld at yahoo.co.uk  Tue Mar 26 05:39:16 2024
From: alan.gauld at yahoo.co.uk (Alan Gauld)
Date: Tue, 26 Mar 2024 09:39:16 +0000
Subject: [Tutor] Thanks for your review
In-Reply-To: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>
References: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>
Message-ID: <utu544$k15$1@ciao.gmane.io>

On 25/03/2024 19:59, Jonathan Wilson via Tutor wrote:

> newDBFileName = today.strftime(.format(today.month, today.day)) + '  '
>                                    ^
> SyntaxError: invalid syntax
> 
> Can someone tell me what the invalid syntax is here for this line?

> The arrow is pointing to the .ahead of the format.

Python has already told you, it is the dot in front of format.
Or more specifically the lack of anything in front of the dot.

format is a method of the string class. It expects to be
attached to a string instance with placeholders into which
it places its arguments. However, your usage of it
is also strange since strftime does much the same
for datetime objects. It's not clear why you'd use
both together.

In fact looking at the strftime call it looks like format
should be a variable containing a format string to tell
strftime how to do its work.

To help further you'd need to show us more context and
explain what it is you are trying to do! It is not at
all clear from this single line snippet.

As I see it there are two possible solutions depending on what you are
trying to do:
1) Add a format string and closing paren to strftime and apply format()
to the result:

newDBFileName = today.strftime("{}{} ").format(today.month, today.day))

2) Replace .format with a strftime format string and remove the
month/day arguments.

newDBFileName = today.strftime("%m%d ")

Here is some actual code:
>>> d = dt.datetime(2020,6,18)
>>> d.strftime("{} {} ").format(d.day, d.month)
'18 6 '
>>> d.strftime("%d %m ")
'18 06 '

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




From learn2program at gmail.com  Tue Mar 26 21:09:46 2024
From: learn2program at gmail.com (Alan Gauld)
Date: Wed, 27 Mar 2024 01:09:46 +0000
Subject: [Tutor] Thanks for your review
In-Reply-To: <DM6PR02MB495354A7CD2E7DE0AB37A149BE352@DM6PR02MB4953.namprd02.prod.outlook.com>
References: <DM6PR02MB4953DF38544406A985207004BE362@DM6PR02MB4953.namprd02.prod.outlook.com>
 <utu544$k15$1@ciao.gmane.io>
 <DM6PR02MB495354A7CD2E7DE0AB37A149BE352@DM6PR02MB4953.namprd02.prod.outlook.com>
Message-ID: <cc83f8b5-35d2-407d-93fe-ea68364e0d0f@yahoo.co.uk>

Always reply-All when respoding to the list. Otherwise it only goes
to the individual and you lose the benefit of the "hive mind" on
the list. (I've CCd the list on this reply)

On 26/03/2024 16:42, Jonathan Wilson wrote:

> ??? main(sys.argv[1], sys.argv[2])
> 
> ?*?File "C:\Users\918856164\Desktop\SFSU\UpdateDBFromConsole.py", line
> 61, in main*
> 
> *??? newDBFileName = date.today().strftime("%y.%-m.%-d") + '? ' +
> dbFileName*
> 
> *ValueError: Invalid format string*

That's correct, the format string is not a valid strftime format.
I'm not certain what format you want but I suspect it might be:

newDBFileName = date.today().strftime("%y.%m.%d") + '  ' + dbFileName

Which would output something like:

2024.03.26  SomeFilename.db


> newDBFileName = today.strftime("%m%d ")
> 
> Here is some actual code:
>>>> d = dt.datetime(2020,6,18)
>>>> d.strftime("{} {} ").format(d.day, d.month)
> '18 6 '
>>>> d.strftime("%d %m ")
> '18 06 '

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


From mk1853387 at gmail.com  Sat Mar 30 20:09:43 2024
From: mk1853387 at gmail.com (marc nicole)
Date: Sun, 31 Mar 2024 01:09:43 +0100
Subject: [Tutor] Can you help me with this memoization simple example?
Message-ID: <CAGJtH9S0o_S_bJvYWRSYBvymzF3p1Y-hcG_gMc1UjCSEaiB2TQ@mail.gmail.com>

I am creating a memoization example with a function that adds up / averages
the elements of an array and compares it with the cached ones to retrieve
them in case they are already stored.

In addition, I want to store only if the result of the function differs
considerably (passes a threshold e.g. 500000 below).

I created an example using a decorator to do so, the results using the
decorator is slightly faster than without the memoization which is OK, but
is the logic of the decorator correct ? anybody can tell me ?

My code is attached below:



import time


def memoize(f):
    cache = {}

    def g(*args):
        if args[1] == "avg":
            sum_key_arr = sum(list(args[0])) / len(list(args[0]))
        elif args[1] == "sum":
            sum_key_arr = sum(list(args[0]))
        if sum_key_arr not in cache:
            for (
                key,
                value,
            ) in (
                cache.items()
            ):  # key in dict cannot be an array so I use the sum of the
array as the key
                if (
                    abs(sum_key_arr - key) <= 500000
                ):  # threshold is great here so that all values are
approximated!
                    # print('approximated')
                    return cache[key]
            else:
                # print('not approximated')
                cache[sum_key_arr] = f(args[0], args[1])
        return cache[sum_key_arr]

    return g


@memoize
def aggregate(dict_list_arr, operation):
    if operation == "avg":
        return sum(list(dict_list_arr)) / len(list(dict_list_arr))
    if operation == "sum":
        return sum(list(dict_list_arr))
    return None


t = time.time()
for i in range(200, 15000):
    res = aggregate(list(range(i)), "avg")

elapsed = time.time() - t
print(res)
print(elapsed)