Skip to content

Fix issue from video: Python for data engineers > Advanced Python > Modules#6

Open
jkjack wants to merge 1 commit intoteam-data-science:mainfrom
jkjack:fix-modules
Open

Fix issue from video: Python for data engineers > Advanced Python > Modules#6
jkjack wants to merge 1 commit intoteam-data-science:mainfrom
jkjack:fix-modules

Conversation

@jkjack
Copy link
Copy Markdown

@jkjack jkjack commented Mar 22, 2026

Problem

When modules.py imported MyAge from my_classes.py, Python executed the entire file — including the hardcoded MyAge("1982-08-04", ...) instance at the bottom. This caused unintended output and made it appear that changes to the date in modules.py had no effect.

Fix

Wrapped the standalone instantiation in if __name__ == "__main__": so it only runs when my_classes.py is executed directly.

Reference

Addresses the issue demonstrated in:
Python for data engineers > Advanced Python > Modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant