Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python users, why?

Name: Anonymous 2011-12-05 10:39

Seriously asking, for the people that like python, why do you like it, and what do you normally use it for?

Name: Anonymous 2011-12-07 8:30

>>32
If you're changing the layout, you're expecting changes, yes?


### Start with... ###
class Anus:
    def __init__(self):
        self.haxxed = True

myAnus = Anus()
if myAnus.haxxed is True:
    print 'NO EXCEPTIONS'


(Ignoring that we could've just used the Pythonic if myAnus.haxxed: and it would work in both cases above/below.)


### Changes to... ###
class Anus:
    def __init__(self):
        self.haxxed = "thoroughly"

myAnus = Anus()
if myAnus.haxxed == "thoroughly":
    print 'NO EXCEPTIONS'


Using get/set (in any language) wouldn't save you from needing to mirror the change in class with the if statement. If you wanted that kind of resilience sprinkled about your code, you'd use a method in the first place.


### Should've been doing this all along... ###
class Anus:
    def __init__(self):
        self.haxxed = "thoroughly"
   
    def isHaxxed(self):
        return self.haxxed == "thoroughly"

myAnus = Anus()
if myAnus.isHaxxed:
    print 'NO EXCEPTIONS'


Maybe I'm misunderstanding your comment, but that was my first reason for railing against set/get.

What is Java? A miserable little pile of boilerplate.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List