Skip to content

Commit 0f27fb2

Browse files
committed
Use list comprehension for parsing standard_name
1 parent be9a235 commit 0f27fb2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cf_xarray/accessor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,13 @@ def _get_list_standard_names(obj: xr.Dataset) -> List[str]:
313313
-------
314314
list of standard names in dataset
315315
"""
316-
names = []
317-
for k, v in obj.variables.items():
318-
if "standard_name" in v.attrs:
319-
names.append(v.attrs["standard_name"])
320-
return sorted(names)
316+
return sorted(
317+
[
318+
v.attrs["standard_name"]
319+
for k, v in obj.variables.items()
320+
if "standard_name" in v.attrs
321+
]
322+
)
321323

322324

323325
def _getattr(

0 commit comments

Comments
 (0)