Listing User-Defined Functions in a Python Shell
Learn how to retrieve a list of user-defined functions in a Python shell session using list comprehension and the globals() function.

Adrian Dolinay
84 views • Dec 27, 2024

About this video
To retrieve a list of the user-defined functions with a Python Shell session utilize list comprehension:
1. functions = [name for name, obj in globals().items() if callable(obj) and obj.__class__.__name__ == 'function']
2. print(functions)
globals Function on python.org: https://docs.python.org/3/library/functions.html#globals
CONNECT:
LinkedIn: https://www.linkedin.com/in/adrian-dolinay-frm-96a289106/
GitHub: https://github.com/ad17171717
X: https://twitter.com/DolinayG
Odysee: https://odysee.com/@adriandolinay:0
Medium: https://medium.com/@adriandolinay
PODCAST:
Apple Podcasts: https://podcasts.apple.com/us/podcast/the-aspiring-stem-geek/id1765996824
Audible: https://www.audible.com/podcast/The-Aspiring-STEM-Geek/B0DC73S9SN?eac_link=ONLefHtKpP93&ref=web_search_eac_asin_1&eac_selected_type=asin&eac_selected=B0DC73S9SN&qid=ZLZCJYZ17Q&eac_id=145-9930582-4977616_ZLZCJYZ17Q&sr=1-1
iHeart Radio: https://iheart.com/podcast/202676097/
Spotify: https://open.spotify.com/show/60dPNJbDPaPw7ru8g5btxV?si=26e034e416f446d8
1. functions = [name for name, obj in globals().items() if callable(obj) and obj.__class__.__name__ == 'function']
2. print(functions)
globals Function on python.org: https://docs.python.org/3/library/functions.html#globals
CONNECT:
LinkedIn: https://www.linkedin.com/in/adrian-dolinay-frm-96a289106/
GitHub: https://github.com/ad17171717
X: https://twitter.com/DolinayG
Odysee: https://odysee.com/@adriandolinay:0
Medium: https://medium.com/@adriandolinay
PODCAST:
Apple Podcasts: https://podcasts.apple.com/us/podcast/the-aspiring-stem-geek/id1765996824
Audible: https://www.audible.com/podcast/The-Aspiring-STEM-Geek/B0DC73S9SN?eac_link=ONLefHtKpP93&ref=web_search_eac_asin_1&eac_selected_type=asin&eac_selected=B0DC73S9SN&qid=ZLZCJYZ17Q&eac_id=145-9930582-4977616_ZLZCJYZ17Q&sr=1-1
iHeart Radio: https://iheart.com/podcast/202676097/
Spotify: https://open.spotify.com/show/60dPNJbDPaPw7ru8g5btxV?si=26e034e416f446d8
Tags and Topics
Browse our collection to discover more content in these categories.
Video Information
Views
84
Likes
3
Duration
0:39
Published
Dec 27, 2024
Related Trending Topics
LIVE TRENDSRelated trending topics. Click any trend to explore more videos.