Return and set
- From: Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Jul 2011 09:23:52 -0400
I have a method getToken() which checks to see if a value is set, and if so, return it. However, it doesn't feel pythonic to me:
def getToken(self):
if self.tok:
t = self.tok
self.tok = None
return t
# ...
Is there a way to trim the 'if' block to reset self.tok upon return?
--
Bill
.
- Follow-Ups:
- Re: Return and set
- From: Ben Finney
- Re: Return and set
- Prev by Date: Re: The following modules appear to be missing - py2exe
- Next by Date: (Maybe off topic) Can someone explain what a finite state machine is?
- Previous by thread: Stopwatch - pause counter
- Next by thread: Re: Return and set
- Index(es):