Challenge: change the code so that only .py and .txt files of a given directory are listed. ''' filename_list_given_dir1.py use module glob to list all the filenames of .jpg files or any extension(s) you specify in a given directory ''' import glob import os # all files (split off file names) in a given directory directory = "C:/Temp/*.jpg" # this would give you all files #directory = "C:/Temp/*.*" for path in glob.glob(directory): #print(path) # test # separate path from filename dirname, filename = os.path.split(path) print(filename)

Member Avatar
Member Avatar
+0 forum 14

Dear Kind-Coders, I am trying to learn to use boost::shared_ptr to manage the lifetime of a DLL, but I am having a type conversion problem whilst setting it up. Please see the following code: #include <boost/make_shared.hpp> int main() { { class CMyClass { public: CMyClass() {} ~CMyClass() {} int MyInt; }; typedef void* (*fpFunct1)(); fpFunct1 CreateFoo; /*********************************************** Build error because cannot convert from 'HINSTANCE__ *' to 'HINSTANCE__ **' ************************************************/ boost::shared_ptr<HMODULE> spHDL (LoadLibrary("DllMain.dll"), FreeLibrary); // get the function pointer CreateFoo = (fpFunct1)(GetProcAddress(*spHDL, "CreateFooClassInstance")); // get pointer to object auto pMyClass = boost::make_shared<CMyClass*> (static_cast<CMyClass*> (CreateFoo())); (*pMyClass)->MyInt = 9; } // See destructor/custom_deleter …

Member Avatar
Member Avatar
+0 forum 5

The End.