Note: This post was updated to work with Python 3.12. It may not work with different versions.
Here’s a JAPH composed solely for effect. For each letter in 'just another python hacker'
it loops over each the characters ' abcdefghijklmnopqrstuvwxyz'
, printing each. Between characters it pauses for 0.05 seconds, backing up and moving on to the next if it hasn’t reached the desired one yet. This achieves a sort of rolling effect by which the final string appears on our screen over time.
import string
import sys
import time
letters = ' ' + string.ascii_lowercase
for l in 'just another python hacker':
for x in letters:
print(x, end='')
sys.stdout.flush()
time.sleep(0.05)
if x == l:
break
else:
print('\b', end='')
print()
We locate and print each letter in the string with a list comprehension. At the end we have an extra line of code (the eval statement) that gives us our newline.
[[(lambda x,l:str(print(x,end=''))+str(__import__(print.
__doc__[print.__doc__.index('stdout') - 4:print.__doc__.
index('stdout')-1]).stdout.flush()) + str(__import__(''.
join(reversed('emit'))).sleep(0o5*1.01/0x64))+str(print(
'\b',end='\x09'.strip())if x!=l else'*&#'))(x1,l1)for x1
in('\x20'+getattr(__import__(type('phear').__name__+'in'
'g'),dir(__import__(type('snarf').__name__+'ing'))[15]))
[:('\x20'+getattr(__import__(type('smear').__name__+'in'
'g'),dir(__import__(type('slurp').__name__+'ing'))[15]))
.index(l1)+1]]for l1 in'''just another python hacker''']
eval('''\x20\x09eval("\x20\x09eval('\x20 print()')")''')