Faqts : Computers : Programming : Shopping For You : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 13 people (69%) answered Yes
Recently 8 of 10 people (80%) answered Yes


JaPy - Just another Python hacker

Dec 18th, 2009 12:40
new acct, Shopping Snooper, Joe Bloggs, chat alarab, games games, Nathan Wallace, Hans Nowak, Snippet 181, Andrew Dalke

Packages: miscellaneous.fun
Given the continuing "Not to start a language war" war^H^H^H
discussion, I have composed a series of what I will call "JAPy" for our
beloved Perl bretheren who worry about our straight-laced language
print "Just another Pythoneer"
print "Just", "another", "Pythoneer" 
print '''%s %s %s''' % ("Just", "another", "Pythoneer") 
print '%(j)s %(a)s %(py)s' % { "j": "Just", "a": "another", \
  "pl": "Perl Hacker", "py": "Pythoneer", "c": "C Coder", \
  "f": "Fortran Freak", "turtle" : "Logo Lover" } 
import sys
sys.stdout.write("Just another Pythoneer\n")
x = ['r','e','e','n','o','h','t','y','P',' ','r','e','h','t','o', 'n',
  'a',' ','t','s','u','J'];
print ''.join(x)
import pickle
print pickle.loads("S'Just another Pythoneer'\012p0\012.") 
def k(x):
     if type(x) == type({}): return x.keys()[0] + k(x.values()[0])     
     return x
print k({"Just ": {"another ": "Pythoneer"}}) 
import sys
for c in "Just another Pythoneer\n":
import uu, StringIO
s = StringIO.StringIO()
uu.decode(StringIO.StringIO('begin 666 '+\
  '-\01262G5S="!A;F]T:&5R(%!Y=&AO;F5E<@  \012 \012end\012'), s)
print s.getvalue()
x = ["Just", "another", "Pythoneer"] 
while x: print x[0], ; x = x[1:]
import re
a = ["Pythoneer", "extra", "Just", "words", "another", "Hello!"] 
m = re.match("(?P<three>\d+).(?P<one>\d+).(?P<two>\d+)", "1A5l2") 
print a[m.start("one")], a[m.start("two")], a[m.start("three")] 
import mailbox, StringIO
mb = mailbox.UnixMailbox(StringIO.StringIO(
'''From - Fri Oct 30 00:00:00 1998\nFrom: [email protected]
Subject: Just another Pythoneer
Newsgroup: comp.lang.python\nHello, world!\n'''))
print mb.next().getheader("Subject")
  raise "Just another Pythoneer"
  print sys.exc_info()[0]
import random, sys
x = "Just another Pythoneer\n"
while x:
  y = random.choice(x)
  try: assert(y == x[0]);sys.stdout.write(y)
  except AssertionError: pass
  else: x = x[1:]
def f(z):
  '''Just another Pythoneer (and remember to document your code!)'''  
print f.__doc__[:22]
# And finally, my personal favorite!
class Print:
    def __call__(self): print
    def __getattr__(self, name): print name, ; return self
Okay, that's where I end.  You can tell I haven't been obscuring Python
much -- not a lambda in sight  :)