Malik Posted January 5, 2014 Share Posted January 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 Quote Link to comment Share on other sites More sharing options...
AuronX Posted January 5, 2014 Share Posted January 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 Quote Link to comment Share on other sites More sharing options...
Malik Posted January 5, 2014 Author Share Posted January 5, 2014 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.