[Python-ideas] __first__ method
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Feb 14 05:03:10 EST 2019
The Big Cheese wrote:
> however at the start of this module it imports os and glob and it also
> runs some setup for how it reads the sensors and has such I have to just
> do 'import temperature' and then every time I create a sensor I have to
> call temperature.Sensor which isn't as nice.
I think you may be mistaken about how module importing works.
Doing 'from temperature import Sensor' still runs all the
top-level code in the temperature module, just the same as
'import temperature' does.
So, the feature you're requesting is not necessary. All you
have to do is write your setup code as top-level statements
in the module where the class is defined.
--
Greg
More information about the Python-ideas
mailing list