Created
June 2, 2018 16:04
-
-
Save igeligel/97d6c9ecdbe9c1615147e59d1534d08d to your computer and use it in GitHub Desktop.
long_generator_expression_named_tuples
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
def generator_expression(): | |
Fruit = collections.namedtuple( | |
'Fruit', ('name', 'size' | |
'price super_long_property_in_tuple')) | |
fruits = [ | |
Fruit( | |
name='apple', | |
size=5, | |
price=10.50, | |
super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit( | |
name='banana', | |
size=7, | |
price=10.50, | |
super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit( | |
name='orange', | |
size=6, | |
price=10.50, | |
super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit( | |
name='kiwi', | |
size=1, | |
price=10.50, | |
super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.')] | |
complicated_fruits_filtered = [ | |
fruit for fruit in fruits if fruit.price >= 10 and size <= 5] |
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
def generator_expression(): | |
Fruit = collections.namedtuple('Fruit', ('name', 'size' 'price super_long_property_in_tuple')) | |
fruits = [ | |
Fruit(name='apple', size=5, price=10.50, super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit(name='banana', size=7, price=10.50, super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit(name='orange', size=6, price=10.50, super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.'), | |
Fruit(name='kiwi', size=1, price=10.50, super_long_property_in_tuple='super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.')] | |
complicated_fruits_filtered = [fruit for fruit in fruits if fruit.price >= 10 and size <= 5] |
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
def generator_expression(): | |
Fruit = collections.namedtuple( | |
"Fruit", ("name", "size" "price super_long_property_in_tuple") | |
) | |
fruits = [ | |
Fruit( | |
name="apple", | |
size=5, | |
price=10.50, | |
super_long_property_in_tuple="super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.", | |
), | |
Fruit( | |
name="banana", | |
size=7, | |
price=10.50, | |
super_long_property_in_tuple="super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.", | |
), | |
Fruit( | |
name="orange", | |
size=6, | |
price=10.50, | |
super_long_property_in_tuple="super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.", | |
), | |
Fruit( | |
name="kiwi", | |
size=1, | |
price=10.50, | |
super_long_property_in_tuple="super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.", | |
), | |
] | |
complicated_fruits_filtered = [ | |
fruit for fruit in fruits if fruit.price >= 10 and size <= 5 | |
] |
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
def generator_expression(): | |
Fruit = collections.namedtuple( | |
'Fruit', ('name', 'size' | |
'price super_long_property_in_tuple') | |
) | |
fruits = [ | |
Fruit( | |
name='apple', | |
size=5, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='banana', | |
size=7, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='orange', | |
size=6, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='kiwi', | |
size=1, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
) | |
] | |
complicated_fruits_filtered = [ | |
fruit for fruit in fruits if fruit.price >= 10 and size <= 5 | |
] |
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
def generator_expression(): | |
Fruit = collections.namedtuple('Fruit', | |
('name', 'size' | |
'price super_long_property_in_tuple')) | |
fruits = [ | |
Fruit( | |
name='apple', | |
size=5, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='banana', | |
size=7, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='orange', | |
size=6, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='kiwi', | |
size=1, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
) | |
] | |
complicated_fruits_filtered = [ | |
fruit for fruit in fruits if fruit.price >= 10 and size <= 5 | |
] |
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
def generator_expression(): | |
Fruit = collections.namedtuple('Fruit', | |
('name', 'size' | |
'price super_long_property_in_tuple')) | |
fruits = [ | |
Fruit( | |
name='apple', | |
size=5, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='banana', | |
size=7, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='orange', | |
size=6, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
), | |
Fruit( | |
name='kiwi', | |
size=1, | |
price=10.50, | |
super_long_property_in_tuple= | |
'super long string here also, lorem ipsum, maybe longer than 80 characters to look for pep8 violations here. lorem ipsum.' | |
) | |
] | |
complicated_fruits_filtered = [ | |
fruit for fruit in fruits if fruit.price >= 10 and size <= 5 | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment