Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import math
- class pipe(object):
- def __init__(self, start_value):
- self.value = start_value
- def __or__(self, function):
- self.value = function(self.value)
- return self
- def main():
- average = lambda sequence: math.fsum(sequence) / len(sequence)
- pipe(range(1, 10)) | average | 'The average is {0}'.format | print
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement