Repository navigation
Modified approach for time init additions - #6
Conversation
There was a problem hiding this comment.
Don't you want this indented? That is, if you're using replicate you don't want to run the initializer, right? Or is the idea that you want it to still run the initilizer for some reason I'm not understading?
There was a problem hiding this comment.
Yes, it still should run the initializer so that the rest of the attributes (e.g. lat, lon, scale, precision) get set in __init__. If the return self line were indented then the replicate case would return None as the new Time object.
There was a problem hiding this comment.
Ah, I see - I misread this and was thinking in the if statement you meant to return something else, but I now see that it gets set to self as well.
|
Thanks @taldcroft - now that I understand the deal with |
Modified approach for time init additions
Good idea to allow for initializing the Time object with an existing Time object.
There is an existing method
Time.replicate(self, format, copy)that makes a reference copy or deep copy (copy=True) of a Time object. I used this method within a newTime.__new__method to take care of the copying bit whenvalis aTimeobject. The main benefit of this approach is that all the otherTimeinitialization keywords will now function as expected, i.e.format,scale,precision, and so on.Also added code to do the same in
TimeDelta.