Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 2nd, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (List()                    # Create a new instance of moka.List
  2.    .extend(range(1,20))    # Insert the numbers from 1 to 20
  3.    .keep(lambda x: x > 5)  # Keep only the numbers bigger than 5
  4.    .rem(operator.gt, 7)    # Remove the numbers bigger than 7 using partial application
  5.    .rem(eq=6)              # Remove the number 6 using the 'operator shortcut'
  6.    .map(str)               # Call str on each numbers (Creating a list of string)
  7.    .invoke('zfill', 3)     # Call zfill(x, 3) on each string (Filling some 0 on the left)
  8.    .insert(0, 'I am')      # Insert the string 'I am' at the head of the list
  9.    .join(' '))             # Joining every string of the list and separate them with a space.
  10.  
  11. # 'I am 007'