FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/syntax/generator_expression.py at main · thomasWeise/programmingWithPythonCode · GitHub
thomasWeise
programmingWithPythonCode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
syntax
/
generator_expression.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (12 loc) · 587 Bytes
Breadcrumbs
programmingWithPythonCode
/
syntax
/
generator_expression.py
Copy path
File metadata and controls
15 lines (12 loc) · 587 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Generator Expressions in Python."""
# Create a generator from all the items in a sequence.
# 'expression' is usually an expression whose result depends on 'item'.
(
expression
for
item
in
sequence
)
# Create a generator from those items in a sequence for which
# 'condition' evaluates to True.
# 'expression' and 'condition' are usually expressions whose results
# depend on 'item'.
(
expression
for
item
in
sequence
if
condition
)
# If generator expressions are single function parameters, then the
# parentheses are unnecessary.
my_func
(
expression
for
item
in
sequence
if
condition
)
Back
|
FazBrowse Home
|
New Git URL