Am 02.11.2017 um 15:33 schrieb Diez B. Roggisch:
>> In einer raspberry pi Zeitschrift habe ich gesehen
>> dann man stattdessen auch
> Und da ist schon der Casus Knacktus: so viel Spass ich persoenlich mit dem PI habe,
> das Python-Code-Oekosystem um hin herum ist eher eine stinkende Sumpflandschaft
> statt ein bluehender Garten der gelungenen Codierung.
> Alles was du also aus dem Umfeld (und Popularitaet noch Publikation aendern das)
> solltest du mit einer gehoerigen Portion Skepsis betrachten.
Zumindest liefern die vielen kleinen
einfachen Beispiele von Python Programme gelegentlich
Anregung für Änderungen im eigenen Programmierstil.
Wenn auch..
Nach Kofler raspberry pi scheint es pygame für python3 zugeben.
SuSE mag kein pygame für Python3
Pygame_SDL2 ist im internet angekündigt.
Hermann
der bei SDL2 weiterhin auf C angewiesen ist.
Und demnächst seine class Global_() anders aufbaut.
--
http://www.hermann-riemann.de
Am 02.11.2017 um 15:22 schrieb Thomas Güttler:
> Prinzipel geht das, aber bei Datentypen die mutable sind (zB Listen) kann
> es zu Konsequenzen kommen, die du ggf nicht haben willst.
> class Foo():
> my_list = []
> Dann teilen sie alle Instanzen der Klasse die gleiche Liste.
> Also bei
> foo= Foo()
> foo.my_list.append(1)
> foo2 = Foo()
> foo2.append(2)
> print foo2
>
> wirst du ggf erstaunt sein.
>
>> Am 02.11.2017 um 15:09 schrieb Hermann Riemann:
>>Bisher habe ich etwas wie
>> class Cl():
>> def __init__(self):
>> self.x=1
>> gemacht.
>> So wie das in Buecher ueblich ist.
>> In einer raspberry pi Zeitschrift habe ich gesehen
>> dann man stattdessen auch
>> class Cl():
>> x=1
>> schreiben kann.
>> Hat funktioniert.
>> ( mit c=Cl(); print(c.x); c.x=2; print(c.x) )
>> fragend ob er jetzt viele __init__
>> bedenkenlos ersetzen kann.
Dein Schreiben hat mich zu
c1=Cl(); print(c1.x)
motiviert.
Ergebnis war 2.
Also ohne __init__ haben
die Variablen für alle angelegte Objekte
den gleichen Speicherplatz,
die bei der Klassendefinition angelegt werden.
Hermann
der diese Art von Anlegen globaler Variable
bisher nicht sonderlich mag.
--
http://www.hermann-riemann.de