[Tutor] Advice Please

John Weller john at johnweller.co.uk
Mon Jun 15 10:21:48 EDT 2020


I seek advice.  I am writing an application to control the humidity in a building.  I am new to Python but not programming.  I have an external class provided by the hardware supplier which will access the hardware to obtain the temperature and humidity.  I will create an instance of the class in the main part of the program then use it in a loop to get the data, process it and display it.  Accessing the data and checking it will be done in a function which I want to return the two values and an error count.  In the languages I am used to I would pass the parameters to the function by reference so as to be able to access the values outside the function however I understand that this is not available in Python.  Can Python return multiple values, (return temperature, humidity)?  If not I could make the variables global (not recommended but as these values are fundamental to the whole program then perhaps acceptable) or use a compound data structure such as a dictionary or create a class just to hold the data?  My question is – what do you recommend?

 

Can anyone recommend a book that I can use as a reference to perhaps answer some question without having to bother you guys 😊.  I’ve looked at a few books but they all have failings – most I have seen don’t have an index (essential) or their code examples are screenshots from Terminal with coloured text on a black background which I find difficult to read or their style is too jokey, ‘print(“Hello World”) – now you are a programmer’ sort of thing.  A bit like the Three Bears, something not too technical but not too easy.  😊

 

TIA

 

John

 

John Weller

01380 723235

07976 393631

 



More information about the Tutor mailing list