Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions likepython/README
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ Here's a version that asks you for your name, then says hi. (Note that 'yo' is a
toootally just exit()
else:
um yeah
print like "Hi %s, nice to meet you." % name
tellem like "Hi %s, nice to meet you." % name

A full list of Like, Python keywords is below (swearing optional):
Like, Python also adds mappings so you don't have to keep using the same lame keywords. For example, instead of `print`, `tellem` or `holla`, and instead of `exit`ing you can just `fuckit`.

A full list of Like, Python keywords and mappings is below (swearing optional):

Valleygirl: omg, so, like, totally, right, toootally
Frat guy: friggin, fuckin, dude, man, bro, broheim, broseph
Internets: lol, rofl, teh, ohai, plz
Snoop: yo, homey, homeboy, sup, dog, shit, girl, ma, biatch, ho, shiiit
Local: wicked, hella, anyways
Misc: just, hey, yeah, ok, um, uh, ah, actually, something

Mappings: tellem => print, holla => print, srsly => finally, rockon => continue, an => and, mostdef => assert, fuckit => exit


INSTALLATION
Expand Down
10 changes: 9 additions & 1 deletion likepython/trunk/likepython
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@ like_python_tokens = ['omg','so','like','totally','right','toootally',
'something',
]

like_python_mappings = {'tellem':'print', 'holla':'print', 'srsly':'finally',
'rockon':'continue', 'an':'and', 'mostdef':'assert',
'fuckit':'exit'
}

def handle_input():
if len(sys.argv) == 2:
return sys.argv[1]
else:
print "Usage: likepython path/to/file.lp"
exit()

def py_map(token):
return token if token not in like_python_mappings else like_python_mappings[token]

def main():
# Parse input file for tokens
input_file = handle_input()
file = open(input_file)
tokens = tokenize.generate_tokens(file.readline)

# Remove likepython tokens, leaving valid python temp file behind.
py_tokens = [(type,token) for (type,token, _, _, _) in tokens if token not in like_python_tokens]
py_tokens = [(type,py_map(token)) for (type,token, _, _, _) in tokens if token not in like_python_tokens]
py = tokenize.untokenize(py_tokens)
output_filename = input_file + ".py"
output_file = open(output_filename, 'w')
Expand Down
6 changes: 3 additions & 3 deletions likepython/trunk/test.lp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!usr/bin/python
from sys import exit

# Grab the user's name.
ok so like name = raw_input("yo! what's your name? " ) right

# Make sure they entered something and say hi.
if name.strip() is actually like "":
toootally just exit()
toootally just fuckit()
else:
um yeah
print like "Hi %s, nice to meet you." % name
tellem like "Hi %s, nice to meet you." % name