[Tutor] How (not!) lengthy should functions be?
Alan Gauld
alan.gauld at btinternet.com
Fri Apr 17 00:40:09 CEST 2015
On 16/04/15 22:03, Alan Gauld wrote:
>> def percent2Gy(dose_percent, target_dose_cGy):
>> """
>> Convert a dose given as a percent of target dose into Gy (Gray).
>> """
>> dose_Gy = cGy2Gy((dose_percent / 100.0) * target_dose_cGy)
>> return dose_Gy
>
> Note in this case you could just create an alias
>
> percent2GY = cGy2Gy
Except that the name would then be misleading - my bad!
The value that your function adds is the percentage calculation.
But if it is a straight renaming exercise then an alias would
be more appropriate than defining a new wrapper function.
Sorry, for the bad example.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list