[Tutor] Advice Please
John Weller
john at johnweller.co.uk
Tue Jun 16 04:04:21 EDT 2020
Many thanks to all who replied - problem solved!!
John
John Weller
01380 723235
07976 393631
-----Original Message-----
From: Tutor <tutor-bounces+john=johnweller.co.uk at python.org> On Behalf Of David Rock
Sent: 15 June 2020 21:24
To: tutor at python.org
Subject: Re: [Tutor] Advice Please
* John Weller <john at johnweller.co.uk> [2020-06-15 15:21]:
> 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
yes, it's possible to return multiple values
temp, humidity = read_temp_humidity()
Where the return statement within your function will look like:
return temp, humidity
> 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?
Globals or returning a single dictionary would also work. Generally, I use a dict if there are going to be many element to return, and a tuple if only a few (eg, just temp and humidity as above).
> 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
That's hard to do without more of a solid understanding of your tastes and needs. There's the Python Books list on python.org https://wiki.python.org/moin/PythonBooks
There are several good web-based "books" as well "Dive Into Python"
usually bubbles to the top: https://diveintopython3.net/
I honestly do most of my stuff searching within the online docs.
--
David Rock
david at graniteweb.com
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list