Last active
May 20, 2016 09:00
-
-
Save wieczorek1990/e18a8c8c8934e682296c8f49591e8103 to your computer and use it in GitHub Desktop.
Circular imports in Python & Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./ruby/a.rb | |
require_relative 'b' | |
class B; end | |
class A | |
@b = B.new | |
end | |
./ruby/main.rb | |
require_relative 'a' | |
require_relative 'b' | |
puts A.new.object_id | |
puts B.new.object_id | |
./ruby/b.rb | |
require_relative 'a' | |
class A; end | |
class B | |
@a = A.new | |
end | |
### | |
./python/main.py | |
from a import A | |
from b import B | |
print id(A()) | |
print id(B()) | |
./python/a.py | |
from b import B | |
class A: | |
b = B() | |
./python/b.py | |
from a import A | |
class B: | |
a = A() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment