I have seen this coding pattern in codes I am (re)writing:
class Outside(object):
pass
Outside.example = 10.
My instinct was that I didn't like it! I'd prefer:
class Inside(object):
example = 10.
Are there any advantages or situations where the former is preferred? I guess if you are inheriting a complicated class, you might want to deliberately take advantage of the fact that setting attributes outside the class will be late-binding? But this seems fairly hellish...
Aucun commentaire:
Enregistrer un commentaire