I currently do:
(local['echo'][var] | sth)()
Which seems inelegant and inefficient.
I found the solution in the plumbum documentation :
You can use the shift-left operator <<
.
from plumbum import local
if __name__ == '__main__':
var = "some text in a python variable"
sth = local["cat"]
x = (local['echo'][var] | sth)()
print(x)
print("alternative:")
x = (sth << var)()
print(x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.