Skip to content

Instantly share code, notes, and snippets.

@Python1Liners
Forked from 140bytes/LICENSE.txt
Created February 20, 2012 19:14
Show Gist options
  • Save Python1Liners/1870819 to your computer and use it in GitHub Desktop.
Save Python1Liners/1870819 to your computer and use it in GitHub Desktop.
Python 1-Liners -- Click ↑↑ fork ↑↑ to play!
# Your entry, a useful, unique, and valid Python expression that packs as much functionality into 1 line as possible.

Python 1-Liners

You will wonder how much Python can done within a line of code.

How to play

  1. Click the Fork button above to fork this gist.
  2. Modify all the files to according to the rules below.
  3. Save your entry and tweet it up!

Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.

Rules

Logical part must exist in an aline.py file, whose contents are

  1. an assignable, valid Python expression that
  2. contains no more than 1 line of code.

All entries must also be licensed under the WTFPL or equally permissive license.

For more information

Python 1-Liners is a just for fun fork of 140byt.es (which is JavaScript), and brought to you by Nattawut Phetmak. You may check out this original article: Powerful Python One-Liners.

import is_allowed
init = 'something' if any('variable') else None
code = 'here' \
and 'there'
# expand your code and annotate so everyone can learn form it!
# however, multi-line code separate with ; is not allowed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "name_of_your_code",
"description": "This should be a short description of your entry.",
"keywords": [
"five",
"descriptive",
"keywords",
"or",
"fewer"
]
}
import something
init = variable
code = here
########## test ##########
input("test case")
print("expected value")
print("actual output")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment