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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just add the colon.
To address the question in the comments:
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.