Jody Crothers
Head of Learning Area (Mathematics)
Ridge View Secondary College
Western Australia
Compare to human travel: should I drive or fly?
--
You received this message because you are subscribed to the Google Groups "TI-Innovator for Education" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ti-innovator...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ti-innovator/SL2P216MB1048F314239A4BAF232DDE8EB857A%40SL2P216MB1048.KORP216.PROD.OUTLOOK.COM.
Python lesson… correct me if I’m wrong but:
import ti_rover as rv
is a Python convention to make the ti_rover functions like forward(n) accessible using a special syntax: rv.forward(n) as opposed to
import ti_rover
which would require the function to be called using ti_rover.forward(n)
This is known as aliasing.
You could also write
from ti_rover import *
and use the functions like:
forward(n) without any prefix at all.
OTOH,
from tello import * actually defines a Tello class and creates a tello object behind the scenes. (I think perhaps tello=Tello()). That’s in addition to all the checking under the hood to connect to the micro:bit and drone.
compare to: from turtle import *; t=Turtle() which exposes the creation of the turtle object right in the user’s code. I like this better.
Still studying Python,
John Hanna
To view this discussion on the web visit https://groups.google.com/d/msgid/ti-innovator/4e2a076a-93e7-42d6-9546-e38bd56b1636n%40googlegroups.com.
John,
First of all, agreed, I like the turtle way of creating the object right in the user’s code the most, too. The ‘checking under the hood’ is likely to happen in the ‘__init__()’ part of the class, when an object is assigned. The turtle way of coding also allows creation of multiple turtle objects at the user level. This is different to tello or ti_rover, where only one object instance is supported.
But, although it doesn’t seem that obvious as with tello, there’s a lot of ‘under the hood’ going on in the ti_rover module as well, I believe. E.g., it detects the presence of the Hub and checks if the rover is powered, it is supposed to reset the gyro and encoder values prior to first use of a Rover function, etc..
Due to the implementation that’s visible to us users, rv does not look or feel like an object. But it is one, like almost everything in Python 😊.
Cheers,
Hans-Martin
--
You received this message because you are subscribed to a topic in the Google Groups "TI-Innovator for Education" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ti-innovator/PWzZR0NOFYo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ti-innovator...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ti-innovator/002501d99c72%2486d6d010%2494847030%24%40optonline.net.
Here's a project that does a lot of error trapping using try…except.
See Koch_CX_CE_DT.py
Runs on CX, CE, or desktop software and checks to see if Innovator is present for sound.
To view this discussion on the web visit https://groups.google.com/d/msgid/ti-innovator/SL2P216MB10485C7BEDDE72F7A24D0F1CB857A%40SL2P216MB1048.KORP216.PROD.OUTLOOK.COM.