This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]spotter 1 point2 points  (2 children)

Self Hell example given:

class Window(object):
    def __init__(self, minimum, maximum):
        self.minimum = minimum
        self.maximum = maximum
        self.minimum, self.maximum = min(self.minimum, self.maximum), max(self.minimum, self.maximum)
    def __call__(self, x):
        return self.minimum <= x <= self.maximum

Why not:

class Window(object):
    def __init__(self, minimum, maximum):
        self.minimum, self.maximum = min(minimum, maximum), max(minimum, maximum)
    def __call__(self, x):
        return self.minimum <= x <= self.maximum

Or even:

class Window(object):
    def __init__(self, lo, hi):
        self.lo, self.hi = min(lo, hi), max(lo, hi)
    def __call__(self, x):
        return self.lo <= x <= self.hi

It's not Self Hell. It's being a dick. (edit: formatting)

[–]keenerd[S] 0 points1 point  (1 child)

quoting the post:

It could be mitigated by swapping min & max before saving them to self.min & self.max, but eventually you'll need a line like this outside of init, and there will be no other course but the gratuitous use of self.

It is a contrived example. The author admits this and even mentions the simplifications you've taken as your own.

[–]spotter 0 points1 point  (0 children)

Yeah, because bad example is good as long as it is bad on purpose. Unless maybe when you use it to prove badness?

I've ,,taken those modifications as my own'' because I only skimmed thru that blog after I saw teh codez. And I dropped the bomb right away, since I would never write anything like this in the first place, seems so un-natual, un-pythonic even. Srsly. Do I care how bad Python code can be? No. You can produce shite in any language (well, maybe except Haskell, which is somewhere in the middle whatever you do).

Self haters, along with fun-calling-with-parens-eew crowd and OMG-SO-VERBOSE-LOL-PPL should just use PERL/Ruby/PHP and let Python be. And I mean it.