Re: []=[]

2023-09-25 Thread Chris Angelico via Python-list
On Tue, 26 Sept 2023 at 02:52, Piergiorgio Sartor via Python-list
 wrote:
>
> On 23/09/2023 09.41, Stefan Ram wrote:
> > r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >> []=[]
> >
> >I was watching a video of a David Beazley talk "Python
> >Concurrency From the Ground Up" , where he wrote
> >
> > can_recv, can_send, [] = select(recv_wait, send_wait, [])
> >
> >. Later, he clarified that he actually wanted to write
> >
> > can_recv, can_send, _ = select(recv_wait, send_wait, [])
> >
> >and that he was surprised how the "[]" gave no error.
> >("I wonder why that works.")
>
> If you try:
>
> [] = [1]
>
> and check the error, it will be clear how it works.
> Maybe not why... :-)
>

Note that the reason it gives no error is that select() returned an
empty iterable as the third value. And you can be sure that it will
ALWAYS return an empty iterable, because select() returns three values
that correspond to the three parameters, and are subsets of them -
that is to say, everything in can_recv must have previously been in
recv_wait, and everything in can_send must have been in send_wait.
Since the third (waiting for exceptional conditions) was empty, there
can't ever be anything to return, and so [] will work, and unpack zero
elements.

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


Re: []=[]

2023-09-25 Thread Piergiorgio Sartor via Python-list

On 23/09/2023 09.41, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

[]=[]


   I was watching a video of a David Beazley talk "Python
   Concurrency From the Ground Up" , where he wrote

can_recv, can_send, [] = select(recv_wait, send_wait, [])

   . Later, he clarified that he actually wanted to write

can_recv, can_send, _ = select(recv_wait, send_wait, [])

   and that he was surprised how the "[]" gave no error.
   ("I wonder why that works.")


If you try:

[] = [1]

and check the error, it will be clear how it works.
Maybe not why... :-)

bye,

--

piergiorgio

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


Re: Using generator expressions

2023-09-25 Thread Chris Angelico via Python-list
On Tue, 26 Sept 2023 at 01:39, Jonathan Gossage via Python-list
 wrote:
>
> Many thanks, all. It turned out that my problem was not fully understanding
> the use and power of the unpack operator *. Using it to activate my
> generator made things start to work. I changed the line where I invoked the
> generator to:
> y = test1(*(a for a in st))
>
> adding the unpack operator.
>

You could simplify this with just the unpacking:

y = test1(*st)

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


Re: Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
Many thanks, all. It turned out that my problem was not fully understanding
the use and power of the unpack operator *. Using it to activate my
generator made things start to work. I changed the line where I invoked the
generator to:
y = test1(*(a for a in st))

adding the unpack operator.

On Mon, Sep 25, 2023 at 11:15 AM Thomas Passin via Python-list <
python-list@python.org> wrote:

> On 9/25/2023 10:15 AM, Jonathan Gossage via Python-list wrote:
> > I am having a problem using generator expressions to supply the arguments
> > for a class instance initialization. The following example shows the
> > problem:
> >
> > class test1(object):
> >  def __init__(self, a, b):
> >
> >>  self.name = a
> >
> >  self.value = b
> > st = 'Programming Renaissance, Any'.split(', ')
> > y = test1(a for a in st)
> > print(f'Object values are: {y._a}, {y._b}')
> >
> > I would expect to get the values from the list generated by splitting the
> > string passed in as arguments to the new instance of test1, but instead
> > I get the generator expression by itself as a generator object. The
> > generator
> > expression is treated like a passive object instead of being run. If I
> had
> > wanted to pass the generator expression itself, I would have expected to
> > have
> > to use parentheses around the generator expression. Any suggestions on
> how
> > to
> > get the generator expression to run?
> > If I change the definition of the input arguments to *args I can capture
> the
> > arguments within __init__ but it is verbose and ugly. Also, I could
> accept
> > the
> > arguments from a Sequence and extract the Sequence members into the class
> > values. I would prefer my solution if I could get it to work.
> > Note that I tried generator expressions both inside parentheses and not,
> > without success.
> >
>
> You should get an error at the y assignment.  The argument of test1() is
> a generator, which would get assigned to the "a" argument, and there
> would be no "b" argument, which is an error.
>
> In any event, even if this were to work as you want, it would only work
> for strings that contain one comma.  And you ask for values like y._a,
> but y._a is never created, only y.a.  If you did convert the generator
> to a list, and if you fix the underscored variable names, it still
> wouldn't work because the arguments don't expect a list.
>
> Time to step back and figure out exactly what you actually want to do.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


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


ANN: Python Meeting Düsseldorf - 27.09.2023

2023-09-25 Thread eGenix Team via Python-list


/This announcement is in German since it targets a local user 
group//meeting in Düsseldorf, Germany/



   Ankündigung

   Python Meeting Düsseldorf - September 2023
   

   Ein Treffen von Python Enthusiasten und Interessierten
   in ungezwungener Atmosphäre.

   *27.09.2023, 18:00 Uhr*
   Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk
   
   Düsseldorfer Arcaden
   , Bachstr. 145,
   40217 Düsseldorf
   



   Programm

Bereits angemeldete Vorträge:

 * Moritz Damm:
   /Einführung in '*Kedro - A framework for production-ready data science*'

   /
 * Marc-André Lemburg:
   /Parsing structured content with *Python 3.10's new match-case

   */
 * Arkadius Schuchhardt:
   /*Repository Pattern in Python*: Why and how?

   /
 * Jens Diemer:
   */CLI Tools/*

Weitere Vorträge können gerne noch angemeldet werden. Bei Interesse, 
bitte unter i...@pyddf.de melden.



 Startzeit und Ort

Wir treffen uns um 18:00 Uhr im Bürgerhaus in den Düsseldorfer Arcaden.

Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet 
sich an der Seite der Tiefgarageneinfahrt der Düsseldorfer Arcaden.


Über dem Eingang steht ein großes "Schwimm’ in Bilk" Logo. Hinter der 
Tür direkt links zu den zwei Aufzügen, dann in den 2. Stock hochfahren. 
Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt.


>>> Eingang in Google Street View 

*⚠️ Wichtig*: Bitte nur dann anmelden, wenn ihr absolut sicher seid, 
dass ihr auch kommt. Angesichts der begrenzten Anzahl Plätze, haben wir 
kein Verständnis für kurzfristige Absagen oder No-Shows.



   Einleitung

Das Python Meeting Düsseldorf  ist eine regelmäßige 
Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der 
Region wendet.


Einen guten Überblick über die Vorträge bietet unser PyDDF YouTube-Kanal 
, auf dem wir Videos der Vorträge nach 
den Meetings veröffentlichen.


Veranstaltet wird das Meeting von der eGenix.com GmbH 
, Langenfeld, in Zusammenarbeit mit Clark 
Consulting & Research , Düsseldorf:



   Format

Das Python Meeting Düsseldorf  nutzt eine Mischung aus 
(Lightning) Talks und offener Diskussion.


Vorträge können vorher angemeldet werden, oder auch spontan während des 
Treffens eingebracht werden. Ein Beamer mit HDMI und FullHD Auflösung 
steht zur Verfügung.


(Lightning) Talk Anmeldung bitte formlos per EMail an i...@pyddf.de 




   Kostenbeteiligung

Das Python Meeting Düsseldorf  wird von Python Nutzern 
für Python Nutzer veranstaltet.


Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren, bitten 
wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00 inkl. 19% 
Mwst. Schüler und Studenten zahlen EUR 5,00 inkl. 19% Mwst.


Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.


   Anmeldung

Da wir nur 25 Personen in dem angemieteten Raum empfangen können, 
möchten wir bitten, sich vorher anzumelden.


   *Meeting Anmeldung* bitte per Meetup
   


   Weitere Informationen

Weitere Informationen finden Sie auf der Webseite des Meetings:

https://pyddf.de/

Viel Spaß !

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Sep 25 2023)

Python Projects, Coaching and Support ...https://www.egenix.com/
Python Product Development ...https://consulting.egenix.com/



::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48

D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   https://www.egenix.com/company/contact/
 https://www.malemburg.com/
--
https://mail.python.org/mailman/listinfo/python-list


Re: Using generator expressions

2023-09-25 Thread Thomas Passin via Python-list

On 9/25/2023 10:15 AM, Jonathan Gossage via Python-list wrote:

I am having a problem using generator expressions to supply the arguments
for a class instance initialization. The following example shows the
problem:

class test1(object):
 def __init__(self, a, b):


 self.name = a


 self.value = b
st = 'Programming Renaissance, Any'.split(', ')
y = test1(a for a in st)
print(f'Object values are: {y._a}, {y._b}')

I would expect to get the values from the list generated by splitting the
string passed in as arguments to the new instance of test1, but instead
I get the generator expression by itself as a generator object. The
generator
expression is treated like a passive object instead of being run. If I had
wanted to pass the generator expression itself, I would have expected to
have
to use parentheses around the generator expression. Any suggestions on how
to
get the generator expression to run?
If I change the definition of the input arguments to *args I can capture the
arguments within __init__ but it is verbose and ugly. Also, I could accept
the
arguments from a Sequence and extract the Sequence members into the class
values. I would prefer my solution if I could get it to work.
Note that I tried generator expressions both inside parentheses and not,
without success.



You should get an error at the y assignment.  The argument of test1() is 
a generator, which would get assigned to the "a" argument, and there 
would be no "b" argument, which is an error.


In any event, even if this were to work as you want, it would only work 
for strings that contain one comma.  And you ask for values like y._a, 
but y._a is never created, only y.a.  If you did convert the generator 
to a list, and if you fix the underscored variable names, it still 
wouldn't work because the arguments don't expect a list.


Time to step back and figure out exactly what you actually want to do.

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


Re: Using generator expressions

2023-09-25 Thread Dom Grigonis via Python-list
y = test1(*[a for a in st])
y = test1(*st)
Maybe any of these would be ok for you?

Regards,
DG


> On 25 Sep 2023, at 17:15, Jonathan Gossage via Python-list 
>  wrote:
> 
> I am having a problem using generator expressions to supply the arguments
> for a class instance initialization. The following example shows the
> problem:
> 
> class test1(object):
>def __init__(self, a, b):
> 
>>self.name = a
> 
>self.value = b
> st = 'Programming Renaissance, Any'.split(', ')
> y = test1(a for a in st)
> print(f'Object values are: {y._a}, {y._b}')
> 
> I would expect to get the values from the list generated by splitting the
> string passed in as arguments to the new instance of test1, but instead
> I get the generator expression by itself as a generator object. The
> generator
> expression is treated like a passive object instead of being run. If I had
> wanted to pass the generator expression itself, I would have expected to
> have
> to use parentheses around the generator expression. Any suggestions on how
> to
> get the generator expression to run?
> If I change the definition of the input arguments to *args I can capture the
> arguments within __init__ but it is verbose and ugly. Also, I could accept
> the
> arguments from a Sequence and extract the Sequence members into the class
> values. I would prefer my solution if I could get it to work.
> Note that I tried generator expressions both inside parentheses and not,
> without success.
> 
> -- 
> Jonathan Gossage
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Using generator expressions

2023-09-25 Thread Jonathan Gossage via Python-list
I am having a problem using generator expressions to supply the arguments
for a class instance initialization. The following example shows the
problem:

class test1(object):
def __init__(self, a, b):

> self.name = a

self.value = b
st = 'Programming Renaissance, Any'.split(', ')
y = test1(a for a in st)
print(f'Object values are: {y._a}, {y._b}')

I would expect to get the values from the list generated by splitting the
string passed in as arguments to the new instance of test1, but instead
I get the generator expression by itself as a generator object. The
generator
expression is treated like a passive object instead of being run. If I had
wanted to pass the generator expression itself, I would have expected to
have
to use parentheses around the generator expression. Any suggestions on how
to
get the generator expression to run?
If I change the definition of the input arguments to *args I can capture the
arguments within __init__ but it is verbose and ugly. Also, I could accept
the
arguments from a Sequence and extract the Sequence members into the class
values. I would prefer my solution if I could get it to work.
Note that I tried generator expressions both inside parentheses and not,
without success.

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