How can I express a method (e.g. dir(os)
) like a keyword (e.g. dir_ os
)? Is it even possible?
The opposite is quite easy to achieve:
# `assert` expressed like a method
def assert_(x): assert x
assert_(1 == 1)
How can I express a method (e.g. dir(os)
) like a keyword (e.g. dir_ os
)? Is it even possible?
The opposite is quite easy to achieve:
# `assert` expressed like a method
def assert_(x): assert x
assert_(1 == 1)
No, it's not possible. Parentheses are required in order to call a function or method.