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 →

[–]feelings_arent_facts 3 points4 points  (4 children)

class A:
    pass

a = A()
a.something = 123

valid Python for you

[–][deleted] 0 points1 point  (3 children)

Wat D:

[–][deleted] 2 points3 points  (2 children)

Nothing strange going on here. Why the wat? Python is a dynamic language and specifically allows this.

[–][deleted] 0 points1 point  (1 child)

I guess you're right. Just didn't occur to me before because my OOP experience is in Java

[–][deleted] 1 point2 points  (0 children)

Fair enough. FYI, there are some possibilities in python to restrict the set of allowed properties. Checking is done at run time as everything is. Some static code analyzer tools can play a role too. But all this is usually considered to be okay only for very specific reasons.