You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have an EV3 brick, those two are interchangeable. ev3dev, however, supports a couple of other systems (like raspberry pi based brick pi). Those may have slightly different hardware configuration, and each of the supported systems have a dedicated submodule in ev3dev (now there are just ev3 and brickpi). auto, when imported, just tries to detect your system and imports the correct module. It mostly is needed to keep the scripts as generic as possible.
Wow, that was quick. So you're saying I should usually use auto, which should always work. When would it ever be preferable to use ev3? Also auto means I don't have to precede everything with ev3 e.g. ts=ev3.TouchSensor() , right, so more legible code?
@ndward the difference hat you are seeing is a result of the fact that there are multiple ways to import modules in Python, and the examples use both ways. import foo as bar makes it so that all the items inside foo can be accessed by the name bar. from foo import *, meanwhile, just makes everything within foo accessible everywhere, as if you had declared them in your code yourself.
ev3dev.auto doesn't really work like it is supposed to unless you have certain combinations of hardware, so I would avoid it. Also, code introspection in PyCharm doesn't work with ev3dev.auto - another reason to not use it.
We have stated the pros and cons so it is up to you to make an informed decision. Here they are again, in case it was not clear...
from ev3dev.auto import *
Pro:
The same program should work an all hardware (EV3, BrickPi, PiStorms, EVB)
Cons:
This is actually broken and only works for EV3 and BrickPi on Raspberry Pi model 1. It will not work on any other combination of devices. (See PiStorms support #170).
Code completion does not work in PyCharm (and probably other IDEs)
from ev3dev.ev3 import *
Pro:
Code completion will work in PyCharm
Con:
Users of non-EV3 hardware (PiStorms, BrickPi, EVB) will have to change the import line or else the program won't work.
Based on your comments I opt for ev3 rather than auto and have just modified all the sample programs on ev3python.com (there are about twenty so far). I understand that users of non-EV3 hardware (PiStorms, BrickPi, EVB) (I imagine there are not many people in this situation) will have to change the import line but it's not obvious exactly what change they have they to make - it this documented somewhere?
Activity
ddemidov commentedon Sep 4, 2016
If you have an EV3 brick, those two are interchangeable. ev3dev, however, supports a couple of other systems (like raspberry pi based brick pi). Those may have slightly different hardware configuration, and each of the supported systems have a dedicated submodule in ev3dev (now there are just
ev3andbrickpi).auto, when imported, just tries to detect your system and imports the correct module. It mostly is needed to keep the scripts as generic as possible.ndward commentedon Sep 4, 2016
Wow, that was quick. So you're saying I should usually use auto, which should always work. When would it ever be preferable to use ev3? Also auto means I don't have to precede everything with ev3 e.g. ts=ev3.TouchSensor() , right, so more legible code?
ddemidov commentedon Sep 4, 2016
Yes
Not exactly. If you do it like
or
then yes, you can drop the
ev3preffix from your code. But you can also do it likewhich may be preferred in some cases. For example, it does not pollute global namespace (which is not that important for small scripts I guess).
WasabiFan commentedon Sep 4, 2016
@ndward the difference hat you are seeing is a result of the fact that there are multiple ways to import modules in Python, and the examples use both ways.
import foo as barmakes it so that all the items insidefoocan be accessed by the namebar.from foo import *, meanwhile, just makes everything withinfooaccessible everywhere, as if you had declared them in your code yourself.ndward commentedon Sep 4, 2016
I'm making ev3python.com for beginners, so I'll happily pollute my global namespace in the name of legibility!
dlech commentedon Sep 4, 2016
ev3dev.autodoesn't really work like it is supposed to unless you have certain combinations of hardware, so I would avoid it. Also, code introspection in PyCharm doesn't work withev3dev.auto- another reason to not use it.ndward commentedon Sep 22, 2016
With ddemidov encouraging me to use auto rather than ev3 and dlech encouraging me to avoid auto I'm a bit lost at the moment...
dlech commentedon Sep 22, 2016
We have stated the pros and cons so it is up to you to make an informed decision. Here they are again, in case it was not clear...
from ev3dev.auto import *Pro:
Cons:
from ev3dev.ev3 import *Pro:
Con:
importline or else the program won't work.ndward commentedon Sep 23, 2016
Based on your comments I opt for ev3 rather than auto and have just modified all the sample programs on ev3python.com (there are about twenty so far). I understand that users of non-EV3 hardware (PiStorms, BrickPi, EVB) (I imagine there are not many people in this situation) will have to change the import line but it's not obvious exactly what change they have they to make - it this documented somewhere?
ddemidov commentedon Sep 23, 2016
There are currently just two options: ev3 and brickpi. EV3 users have to
and BrickPI users will
I guess the rest of the users will be restricted to core (universal) functionality and should
ndward commentedon Sep 23, 2016
I'm sure you mean for BrickPi users
from ev3dev.brickpi import *ddemidov commentedon Sep 23, 2016
I've edited the comma away already :)