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


Release history Release notifications

This version
History Node

0.0.1

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page