recursively import python modules (intermediate) anthony explains #372

preview_player
Показать описание
today I show how to recursively import all modules in a directory and also show a few use cases I have for this!

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

We always find your content to be super informative, educational and useful in a productive way! Today Dec 17, 2021 according to India time, marks my one year anniversary following you on this platform and I wanna confess or say, "YOU ARE THE BEST YOUTUBER!" (not just a tutor) in my honest opinion! I always find your content super useful for practical day job and educational at the same time. In my lifetime, if I ever get an opportunity to meet you, I'll cry my eyes out by happiness! My man you're AWESOME!

akshaymestry
Автор

ok, this plugin architecture is way better than the idea I had before, which was to use globs xD

sadhlife
Автор

I can give you my use-case and I've actually left a feature just because I didn't know how to execute it.

So my use-case was to dynamically import classes that have a common interface and can be used in some ORM-like way such as select(class_name).where(...) and we did that by importing the class and passing it as a reference to the select function. What I did was a function which will resolve it dynamically by passing a string to the select function and then using the __subclasses__() method to get a list with the classes that derive from that particular class that can be used in the select. The thing was that not all modules were loaded during this dynamic importing and the list in the __subclasses__() was incomplete, I added the missing entries manually with __import__ but i didn't like the solution and I left it, now I can get back to it and finish it with that.

Great Information as always, I am following this channel since a year and I learned a lot, thank you for your efforts!!

dimitarganev
Автор

Hey Anthony thank you for the videos i watch them all!

i just have a question if there is any reason for using __path__ instead of __file__?

xaro