Created
June 15, 2015 17:57
-
-
Save kmorcinek/23579e47bb05f6e78575 to your computer and use it in GitHub Desktop.
python funkcyjnie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
http://www.artima.com/weblogs/viewpost.jsp?thread=98196 | |
list("python") | |
https://docs.python.org/3/howto/functional.html | |
line_list = [' line 1\n', 'line 2 \n'] | |
# Generator expression -- returns iterator | |
stripped_iter = (line.strip() for line in line_list) | |
# List comprehension -- returns list | |
stripped_list = [line.strip() for line in line_list] | |
stripped_list = [line.strip() for line in line_list | |
if line != ""] | |
>>> seq1 = 'abc' | |
>>> seq2 = (1,2,3) | |
>>> [(x, y) for x in seq1 for y in seq2] | |
a,b,c = generate_ints(3). | |
def reverse(data): | |
for index in range(len(data)-1, -1, -1): | |
yield data[index] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment