January 5, 2014 at 11:10 AMJan 5, 2014 Moin, ich habe gerade mal die "get_position()" Funktion in Python (mit IDLE / Python 2.7.3) für das Joystick-Bricklet probiert (FW 2.0.3). Bei "print js.get_position()" bekomme ich als Resultat eine formatierte Ausgabe statt (int, int), z.B.: "Position(x=-60, y=42)". Ist das etwa mit dem Satz "Das zurückgegebene namedtuple enthält die Variablen x und y." so gemeint? Muss ich x und y aus dem String extrahieren? Ratlos, Malik
January 5, 2014 at 12:08 PMJan 5, 2014 Ich vermute es geht so: position = js.get_position() print position.x print position.y Aber das ist geraten und eine google-suche nach python named tuple würde mich vermutlich weiterbringen... edit: http://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python
January 5, 2014 at 01:17 PMJan 5, 2014 Author Jau, es geht so. Danke für die schnelle Antwort und den Link. Named Tuples gibt es also hauptsächlich wegen der "object notation". Schönen Sonntag noch!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.