(original) (raw)
On Thu, Sep 7, 2017 at 3:49 PM, Larry Hastings <larry@hastings.org> wrote:
In \[4\]: \[s for s in dir(os) if s.startswith('get')\]
Out\[4\]:
\['get\_blocking',
'get\_exec\_path',
'get\_inheritable',
'get\_terminal\_size',
'getcwd',
'getcwdb',
'getegid',
'getenv',
'getenvb',
'geteuid',
'getgid',
'getgrouplist',
'getgroups',
'getloadavg',
'getlogin',
'getpgid',
'getpgrp',
'getpid',
'getppid',
'getpriority',
'getsid',
'getuid'\]
In \[6\]: \[s for s in dir(sysconfig) if s.startswith('get')\]
Out\[6\]:
\['get\_config\_h\_filename',
'get\_config\_var',
'get\_config\_vars',
'get\_makefile\_filename',
'get\_path',
'get\_path\_names',
'get\_paths',
'get\_platform',
'get\_python\_version',
'get\_scheme\_names'\]
But I can cite at least one place in the standard library that would have been better if it'd been implemented as a module property:
os.stat\_float\_times().
I wish there were a property feature available almost very time I encounter a "get\*" method in the stdlib (or any where):
There are a heck of a lot in the os module:
In \[4\]: \[s for s in dir(os) if s.startswith('get')\]
Out\[4\]:
\['get\_blocking',
'get\_exec\_path',
'get\_inheritable',
'get\_terminal\_size',
'getcwd',
'getcwdb',
'getegid',
'getenv',
'getenvb',
'geteuid',
'getgid',
'getgrouplist',
'getgroups',
'getloadavg',
'getlogin',
'getpgid',
'getpgrp',
'getpid',
'getppid',
'getpriority',
'getsid',
'getuid'\]
Many of those may be good use-cases for getters, but still...
And just yesterday I was getting annoyed by some in sysconfig:
Out\[6\]:
\['get\_config\_h\_filename',
'get\_config\_var',
'get\_config\_vars',
'get\_makefile\_filename',
'get\_path',
'get\_path\_names',
'get\_paths',
'get\_platform',
'get\_python\_version',
'get\_scheme\_names'\]
modules serve the very useful function of a global singleton -- if we think properties are a good idea for classes, then they are a good idea for modules...
-CHB
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov