The Last Starfighter

Hacker and musician.

« Back to blog

yo just print like "hello world" bro

Here's a version that asks you for your name, then says hi. (Note that 'yo' is a Like, Python keyword but the interpreter actually understands real Python syntax, so the 'yo' in the input string works just fine.

  #!usr/bin/python
  uh 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, then say hi.
  if name.strip() is actually like "":
      toootally just exit()
  else:
      um yeah
      print like "Hi %s, nice to meet you." % name

Wow.  Check it out at http://www.staringispolite.com/likepython/

Loading mentions Retweet
Feb 24, 2010
That's awesome!

Does "um yeah" actually do anything, or is it a no-op?

Feb 24, 2010
Adam Blinkinsop said...
I think they're all just no-ops, honestly. :)
Feb 24, 2010
I think you're right. I just read the page you linked to, and it seems like it just ignores all the new tokens. It couldn't be anything too fancy, because it sounds like this guy wrote it when he should have been sleeping instead.
Feb 24, 2010
Adam Blinkinsop said...
Hey, even adding no-op tokens to the Python parser is pretty fancy, imho. Looks like a good starting point for writing general Python extensions, actually...
Feb 24, 2010

True. Speaking of extending languages, have you seen mit's xoc project? It's basically an object oriented grammar that lets you extend languages easily and even compose several independent extensions.

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    twitter