Re: Verstaendnisproblem

Stefan Schwarzer <[email protected]>
Newsgroups gmane.comp.python.general.german
Message-ID <[email protected]>
On 2021-02-12 15:29, eilfh wrote:
> Am Donnerstag, 11. Februar 2021, 18:48:23 CET schrieb Peter Otten:
> Hallo, Peter
> 
> danke für Deine Antwort.
> 
> Das war das fehlende Puzzle in meinem Programm
> 
>>  >>> x
>>
>> 0    4
>> Name: B, dtype: int64
>>
>>  >>> type(x)
>>
>> <class 'pandas.core.series.Series'>
>>
>>
>> kannst Du einfach entpacken
>>
>>  >>> [y] = x
>>  >>> y
>>
>> 4
> 
> 
> um ehrlich zu sein, ich versteh's zwar nicht, 
> aber es läuft und erfüllte genau den Zweck

Falls du `[y] = x` meinst, kann ich mir vorstellen, dass das
komisch aussieht. Das ist sogenanntes implizites "Tuple
unpacking", hier vielleicht eher "List unpacking". Du kannst
das auch als `y = x[0]` schreiben; ich denke, das ist klarer.

Die Schreibweise `[y] = x` hat allerdings wiederum den Vorteil,
dass du eine Exception bekommst, wenn `x` mehr als ein zu
"entpackendes" Element enthält, obwohl du das in deinem Code
nicht erwartest.

Viele Grüße
Stefan
_______________________________________________
python-de maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/python-de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.