When to use a python script vs module?

This is the place for queries that don't fit in any of the other categories.

When to use a python script vs module?

Postby marciokoko » Thu Sep 08, 2016 10:42 pm

I have this py file which toggles relays on a ble enabled relay board. The python file runs on a RPi2 with a serial ble module. I've got 2 separate files doing 2 separate things so far;

sendat5.py - actually sends a command to read relay states on the board:
togglerelay.py - toggles a relay on and off. To do so at present i actually modify the command sent, since "e" turns on and "o" turns off


Id like to put this together into some sort of module or script. At present my plans are to simply have a user run the script manually and have it ask the user what command it wishes to send and maybe return a read command after each command sent. So in other words, the relay board has 4 relays. The script would be run and automatically return the state of all 4 relays (as sendat5.py currently does). It would prompt the user for a command to send, send it when user hits enter and then return a read again, updating the state of all 4 relays based on command sent by user.

Im new to python but Im thinking create a class with a read and write function and then somehow create a script to be run which prompts the user for input?

Thats what the tsrb430.py file I came up with is.

What is the difference between just running a script through python srcipt.py and a module?
Posts: 5
Joined: Wed Sep 07, 2016 11:25 pm

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 13 guests