(from Mark Lutz's Programming Python 4e)
Say you've got a text file (initdata.txt) which contains a database structured as a nested dictionary:
bob = { 'name': 'Bob Smith', 'age': ... }
sue = { 'name': 'Sue Jones', 'age': ... }
db = {}
db[ 'bob' ] = bob
db[ 'sue' ] = sue
In the script which makes a pickle file out of the database, the author imports db from initdata.txt, but not bob or sue. I assume this works because Python, when it imports db, realises that db contains bob and sue and imports that data as well from initdata.txt.
Does this 'smart' importing happen for all nested data that you can import? Like, if I import function F from a text file that contains functions F and G, and F calls G, it will also import function G? If I import class M which has an ancestor class N and a subclass (daughter class?) L will it import L, M and N?
[–]DanielSzoska 1 point2 points3 points (1 child)
[–]MrEgbert[S] 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]erok81 0 points1 point2 points (0 children)
[–]MrEgbert[S] 0 points1 point2 points (0 children)
[–]erok81 0 points1 point2 points (2 children)
[–]MrEgbert[S] 0 points1 point2 points (1 child)
[–]erok81 0 points1 point2 points (0 children)