News for hackers. Stuff that matters.
Re:The Sororicide Antipattern by gweinberg on Thursday June 01, 2017 @05:21PM (#14464895)
class Bprime(object):

     def __init__(self, a):

         for var in dir(a):

            setattr(self, var, getattr(a, var))

Has anyone ever done such a thing? Why?
Re:The Sororicide Antipattern by thesmallestcat on Thursday June 01, 2017 @10:03PM (#14466884)
It's blindingly wrong. It creates a mutable snapshot of the other object. Depending on the size of `a` and how many instances are being wrapped in this way, it could increase memory footprint substantially. I can't imagine a time where you'd want to do this. This sort of effect is usually achieved by a __getattribute__ that falls back to whichever object(s) are being shadowed. Not that that's ideal, but weird to see somebody who knows Python so well throw out such a useless example.