On Sat, 30 Sep 2017 00:09:29 +0100 (BST), "Dave Liquorice"
declaimed the following:
>
>A lot of low level driver stuff for breakout boards is for Python, my
>current project is using a couple of those and thus is being written
>in Python. I don't like it either. It's probably my lack of knowledge
>about the very basics of how Python expects you to construct your
>program and how to properly organise the source code file structure.
>I've yet to find a good, clear, guide/tutorial on those aspects.
>
It's not Java; you don't have the restriction of one class definition
per file, with the corresponding imports. During development you could
easily get by with just one master file for all your code, importing just
standard libraries. Later you can extract out portions that implement
significant yet independent functionality into a separate module. If you
are creating libraries for specific cards, you still end up with fewer
files than Java.
Easiest way to get familiar with how to configure modules would be to
study some of the standard library -- I've yet to have to create a
"package" module; single file modules are the most I've needed.
A common idiom for Python is to set up the main program as:
-=-=-=-
import ...
class ...
def ...
def main(...):
#main program logic
if __name__ == "__main__":
main(...)
-=-=-=-
When the file is run from the command line, it runs with the inherent
name of __main__; but if the file is used later as a module (a file does
"import theModule") it gets the name "theModule" and hence does NOT
automatically run the main logic.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|