We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
getvalue
runpipe
1 parent 9154dbe commit 761be89Copy full SHA for 761be89
unpythonic/seq.py
@@ -136,11 +136,17 @@ def pipe1(value0, *bodys):
136
x = update(x)
137
return x
138
139
-class getvalue: # sentinel with a nice repr
+getvalue = None
140
+class Getvalue: # singleton sentinel with a nice repr
141
"""Sentinel; pipe into this to exit a shell-like pipe and return the current value."""
142
+ def __new__(cls):
143
+ global getvalue
144
+ if getvalue is None:
145
+ getvalue = super().__new__(cls)
146
+ return getvalue
147
def __repr__(self):
148
return "<sentinel for pipe exit>"
-getvalue = getvalue() # singleton
149
+getvalue = Getvalue()
150
runpipe = getvalue # same thing as getvalue, but semantically better name for lazy pipes
151
152
class piped1:
0 commit comments