list variables in memory using function in python

Multi tool use


list variables in memory using function in python
I would like to create a utility function that filters variables in my current environment and prints them (ie print all variables that have type pd.core.frame.DataFrame
) and then put this function in my utils module. I used (Pandas Get a List Of All Data Frames loaded into memory):
pd.core.frame.DataFrame
import pandas as pd
def list_my_frames():
f = [var for var in dir() if isinstance(eval(var), pd.core.frame.DataFrame)]
return f
I would like to be able to pass my current environment to dir()
so that I can use it outside of my utils module. How can I get a handle to my current environment in python?
dir()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.