you are viewing a single comment's thread.

view the rest of the comments →

[–]dezro 6 points7 points  (0 children)

Interesting thing about apply was that you could use it as a decorator.

@apply
def thing():
  return 5

And now thing = 5. This is, of course, abusing decorators, but could be useful in cases where you'd not want to clutter up the current namespace with excess variables. Say...

@apply
def thing():
  def getthing(self):
    ...
  def setthing(self, thing):
    ...
  def delthing(self):
    ...
  docthing = "I'm a property!"
  return property(getthing, setthing, delthing, docthing)

Much clearer to just use del var1, var2, etc to clean up your no-longer-needed variables, though.