Skip to content

Instantly share code, notes, and snippets.

@BlackVegetable
Last active August 29, 2015 14:10
Show Gist options
  • Save BlackVegetable/2a1aac52ad5b02f9e03c to your computer and use it in GitHub Desktop.
Save BlackVegetable/2a1aac52ad5b02f9e03c to your computer and use it in GitHub Desktop.
# This is module A
colton_salary = 900000
def print_hello():
print "hello"
class Employee:
def __init__(self):
self.salary = colton_salary - 5000
# This is module B
import A
employee = A.Employee()
# This is crashing because colton_salary isn't defined!?
@BlackVegetable
Copy link
Author

Turns out this doesn't crash as written. I was using variable names that began with __ which conflicted with python's name mangling. (I was using it for name mangling too. I've since switched to another form of name mangling that doesn't conflict.)

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