Counterpoint: verbs in attribute names indicate an action (i.e. a method) while a verbless attribute indicates a property. An action may modify some state and may take some arguments, while a property only reads static data. e.g. foo = item.get_foo(bar=False) vs. item.fооhttps://twitter.com/raymondh/status/1428457757674508289 …
-
-
I agree. I think as far as principles go, using a verb (even if it's "get") to let users know "this performs some sort of IO or computational task" is worth the extra couple characters.
-
Properties in Python can be a trap: you think you're just doing an O(1) __dict__ lookup but in reality you're making an HTTP request or calling some recursive function repeatedly. It might be trivial to cache the value, but no reason to do that if you think it's just a lookup.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.