What's the proper style for a library string function?
Mark Lawrence
breamoreboy at yahoo.co.uk
Sat Jul 19 15:14:15 EDT 2014
On 19/07/2014 18:38, C.D. Reimer wrote:
> Greetings,
>
> I typically write a Python 2.7 string function in my library like this:
>
> def getCompletedTime(start, end): return "Time completed:", str(end
> - start)
>
Further to my earlier post are you aware of the behaviour of your
"string function"?
>>> def getCompletedTime(start, end): return "Time completed:", str(end
- start)
...
>>> t = getCompletedTime(0, -1)
>>> type(t)
<class 'tuple'>
>>> t[0]
'Time completed:'
>>> t[1]
'-1'
Is this what you intended?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Python-list
mailing list