|
|
|
|
|
by gabrielsroka
2042 days ago
|
|
I tried a few (not all) of the examples with plain old Python (granted, these are multi-liners, not one-liners, but I think they're easier to read). I'm not sure I see the advantange of curly braces. # --- Example 1
# pwk
pwk 'if "braces"=="bad": { print("Be gone!"); exit(99) } else: { print("Howdy!") }'
# vs
# python
python -c 'if "braces"=="bad": print("Be gone!"); exit(99)
else: print("Howdy!")'
# --- Example 2
pwk 'def s2i(s): { return int(s) } print(s2i("41")+1)'
python -c 'def s2i(s): return int(s)
print(s2i("41")+1)'
# --- Example 3
ls / | pwk 'for s in sys.stdin: try: { print(os.listdir("/"+s.strip())) } except: pass'
ls / | python -c 'import sys, os
for s in sys.stdin:
try: print(os.listdir("/"+s.strip()))
except: pass'
|
|