allow shorter imports; update examples to match #223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
adafruit_esp32spilibrary (and a few others) have a redundant module naming structure that looks like this:adafruit_esp32spi/adafruit_esp32spi.py, which means you usually dofrom adafruit_esp32spi import adafruit_esp32spi.I have always found the duplicate name confusing. By adding
from adafruit_esp32spi import *in__init__.pyyou can now just doimport adafruit_esp32spiand have direct access to the definitions.adafruit_esp32spi_socketpool.pyandadafruit_esp32spi_wifimanageralso have unnecessary prefixes on their names, which could just besocketpool.pyandwifimanager.pyI added such files that also dofrom ... import *to allow this.So with this PR, you can now do:
etc.
I changed all the
examples/file to use the shorter import names. After this is merged Learn Guide code can be changed. But since it's backwards compatible, that doesn't need to be done all at once.I would release this as 10.1.0 or even 11.0.0. (Any opinion on that?)
Eventually we might remove the backwards compatibility.
I am working a native module version of
adafruit_esp32spiin core CircuitPython, and removing this extra layer of naming simplifies the code notably. My plan would be to only support the newer naming scheme here.