Skip to content

Instantly share code, notes, and snippets.

@PortWhisperer
Created December 31, 2017 02:07
Show Gist options
  • Save PortWhisperer/fbfaa0488e05bc609b3dfe13166b1156 to your computer and use it in GitHub Desktop.
Save PortWhisperer/fbfaa0488e05bc609b3dfe13166b1156 to your computer and use it in GitHub Desktop.
pyhelp
>>> k=os.listdir('C:\\')
>>> print [filemame for filename in k if 'Bin' in filename]
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'filemame' is not defined
>>> print [filemame for filename in k if 'Bin' in k]
[]
>>> print [k for k in k if 'Bin' in k]
['$Recycle.Bin']
>>> print [k for filename in k if 'Bin' in filename]
[]
>>> print [filename for filename in k if 'Bin' in filename]
[]
>>> print [e for e in k if 'Bin' in e]
[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment