Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Sehr geehrtes Tinkerforge Team

Ich benötige kurz Hilfe für den Python 3 Syntax um ein Tuple oder eine Liste an eine Methode zu übergeben.

Beispiel:

red = (30, 0, 0)

self.sw.set_color(red)

wie muss das Tuple red auseinander genommen werden um akzeptiert zu werden?

Beste Grüsse

Sven

Geschrieben
  • Autor

Danke vielmals, genau dass was ich gesucht habe.

Geschrieben
  • Autor

Nochmals eine Frage:

Kann man in Python 3 die Bedingungen gleicher Logik z.B != mit mehreren Variablen vergleichen, also in einer Kurzform anstatt diverse "nicht gleich" hintereinander zu schreiben. So das self.sw.get_color() nur einmal aufzuführen ist. "and self.sw.get_color() != [red, green...." geht eben nicht.

if self.ping(self.HOST_Controller) == False and self.sw.get_color() != [red, green, purple]
	self.sw.set_color(*blue)
elif self.ping(self.HOST_Controller) == True and self.sw.get_color() != red and self.sw.get_color() != green and self.sw.get_color() != purple:

 

Geschrieben

Solange red green und blue (wie oben) Tupel sind, kannst du folgendes machen:

if self.sw.get_color() not in [red, green, purple]:
	self.sw.set_color(*blue)

(oder alternativ ohne das not wenn du vergleichen willst ob get_color() gleich einem Element der Liste ist)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.