[Tutor] FW: How do you turn something into a number?

Alan G alan.gauld at freenet.co.uk
Mon Aug 22 21:27:45 CEST 2005


> What does it mean when you write the [0] after the return statement?
> e.g. return struct.unpack("!h", bytes)[0]

Its just indexing the list returned by struct.unpack(),
specifically extracting tghe first element.

For more on using struct() see the bottom section of my file handling
topic... (now corrected to fix a bug reported by a recent
reader...)

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld 



More information about the Tutor mailing list