Skip to main content

Python with braces for easy one-liners

Project description

As an old Perl-hack I really miss the convenience of one-line programs where I can easily add block structure. This script emulates the behaviors of perl -e, perl -n and perl -p using braces ({ and }) to generate Pythonesque indentation. There may be other ways to get around this but the goal is to make one-liners as easy as we expect.

Examples:

` >./pb 'for j in range(1,10) { for k in range(0,j) { sys.stdout.write(".") } sys.stdout.write("\n") }' . .. ... .... ..... ...... ....... ........ ......... `

PS. I know this one is very easy as a true Python one-liner:

` >python -c 'print "\n".join("."*j for j in range (1,10))' . .. ... .... ..... ...... ....... ........ ......... `

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page