Re: Is there a way to implement the ** operator on a custom object

2024-02-08 Thread Chris Angelico via Python-list
On Fri, 9 Feb 2024 at 17:03, Cameron Simpson via Python-list
 wrote:
>
> On 08Feb2024 12:21, tony.fl...@btinternet.com  
> wrote:
> >I know that mappings by default support the ** operator, to unpack the
> >mapping into key word arguments.
> >
> >Has it been considered implementing a dunder method for the **
> >operator so you could unpack an object into a key word argument, and
> >the developer could choose which keywords would be generated (or could
> >even generate 'virtual' attributes).
>
> Can you show us why you think that would look like in code?
>
> Note that Python already has `a ** b` to raise `a` to the power of `b`,
> and it has a bunder method `__pow__` which you can define.

I presume this is more like:

obj = SomeObject()
func(**obj)

ie making the object behave in a dict-like way. I can't remember how
this is implemented, but you can create the necessary methods to have
your object produce whatever it likes.

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


Re: Is there a way to implement the ** operator on a custom object

2024-02-08 Thread Cameron Simpson via Python-list

On 08Feb2024 12:21, tony.fl...@btinternet.com  wrote:
I know that mappings by default support the ** operator, to unpack the 
mapping into key word arguments.


Has it been considered implementing a dunder method for the ** 
operator so you could unpack an object into a key word argument, and 
the developer could choose which keywords would be generated (or could 
even generate 'virtual' attributes).


Can you show us why you think that would look like in code?

Note that Python already has `a ** b` to raise `a` to the power of `b`, 
and it has a bunder method `__pow__` which you can define.

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


Is there a way to implement the ** operator on a custom object

2024-02-08 Thread Tony Flury via Python-list
I know that mappings by default support the ** operator, to unpack the 
mapping into key word arguments.


Has it been considered implementing a dunder method for the ** operator 
so you could unpack an object into a key word argument, and the 
developer could choose which keywords would be generated (or could even 
generate 'virtual' attributes).


--
Anthony Flury
email : anthony.fl...@btinternet.com

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


Re: Python misbehavior

2024-02-08 Thread Richard Damon via Python-list

On 2/6/24 10:46 PM, Jim via Python-list wrote:

Friends,
Please forgive me if this is not the proper forum for dealing with an issue of mine, but 
I am at a loss in finding a fix for a python problem in the program ClipGrab. The program 
allows one to download videos or audios from YouTube and other media sites. My limited 
understanding of the process suggests that python facilitates the transfer of data from 
YouTube to ClipGrab. As of recently, I am unable to use the ClipGrab program and the 
issue at fault has something to do with python. In an "about" screen within 
ClipGrab my (now) incapable python script reads:

youtube-dlp: (C:\Program Files (x86)\ClipGrab\python\python.exe: can't find '_main_' 
module in " ) Python: C:/Program Files (x86)/ClipGrab/python/python.exe (Python 
3.8.9)

Since this problem began I downloaded ClipGrab on to another desktop computer and it runs perfectly 
without a problem. The script on the "about" page does not indicate anything about 
"can't find -main- module" etc. Is there any advice you can offer to overcome this and 
recover my downloading connections to YouTube? Or, if this is the wrong group to handle such 
issues, could you please pass my message on to a better choice?

Gratefully,
Jim Haas

Sent from my iPhone


Python itself doesn't have any code to do this, but does have some
support libraries that help.

It looks like your "ClipGrab" program is using the python module
"youtube-dlp" to get the data (that module probabaly has the details of
how to do the operation), but somehow ClipGrab hasn't packaged the
module into itself properly.

You probably should seek help with the support for the ClipGrab program
from the people that make it.

If you look up the documentation for youtube-dlp, you may find that you
can use that module directly, and not need the ClipGrab wrapper at all
(though it may provide some benefits if you can get it working again).


--
Richard Damon

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