Posted to tcl by Stu at Mon Mar 25 08:18:35 GMT 2024view raw
- Notice how the return can be "dedented" without breaking the fucntion.
- def current1 (self, pos=None):
- if pos is None:
- return self[self._pos]
- else:
- self._pos = pos
- return self.adjust()
- def current2 (self, pos=None):
- if pos is None:
- return self[self._pos]
- else:
- self._pos = pos
- return self.adjust()
- Reduced indenting:
- def current3 (self, pos=None):
- return self[self._pos] if pos is None else (lambda y,x:x)(self.pos_set(pos), self.adjust())
- def pos_set (self, pos):
- self._pos = pos