Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74831

Re: What's the proper style for a library string function?

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: What's the proper style for a library string function?
Date 2014-07-19 20:14 +0100
References <53CAAD27.9010207@cdreimer.com>
Newsgroups comp.lang.python
Message-ID <mailman.12059.1405797273.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What's the proper style for a library string function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-19 20:14 +0100

csiph-web