Re:Python-patterns – A collection of design patterns/idioms ...
by stinos on Tuesday May 31, 2022 @09:13AM
(#31569086)
Idiomatic for me would be this simple, short, clear thing:
Or else a class. I don't quite understand why you'd want a global in a module not mean the canonical 'this singletone thingie configures this module' ?
[ Parent
| on HN ]
Re:Python-patterns – A collection of design patterns/idioms ...
by born2discover on Tuesday May 31, 2022 @02:33PM
(#31573093)
IMHO that greeter function of yours is unnecessarily complicated. The same could be achieved in an easier way:
"""python
from functools import partial
def greeter(name):
print(f"Hello {name}")
greet1 = partial(greeter, "Joe")greet2 = partial(greeter, "Sue")
greet1()
greet2()
"""