Skip to content

Instantly share code, notes, and snippets.

@igeligel
Created June 2, 2018 16:04
Show Gist options
  • Save igeligel/97d6c9ecdbe9c1615147e59d1534d08d to your computer and use it in GitHub Desktop.
Save igeligel/97d6c9ecdbe9c1615147e59d1534d08d to your computer and use it in GitHub Desktop.
long_generator_expression_named_tuples
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]
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]
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
]
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
]
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
]
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