python -c "for x in range(1,10) print x"
I enjoy python one liners with -c, but it is limited when indentation is needed.
Any ideas?
python -c "for x in range(1,10): print x"
Just add the colon.
To address the question in the comments:
How can I make this work though? python -c "import calendar;print calendar.prcal(2009);for x in range(1,10): print x"
python -c "for x in range(1,10): x==1 and __import__('calendar').prcal(2009); print x;"
As you can see it's pretty gross. We can't import before the loop. To get around this we check if x is at the first iteration in the loop, if so we do the import.
More examples here.
Not a python script, but might help:
for /L %i in (1, 1, 10) do echo %i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With