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):
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?