About importing classes | Sololearn: Learn to code for FREE!


About importing classes

'Names of weakly private attributes don't get imported.' After reading something like this, I made a file with nothing but one dummy class with dummy attributes and dummy methods. Then I tried to import it from another file. Two things happened: 1. When I tried 'import filexy', there was no exception, but the class was not available at all - 'not defined'! 2. Then I tried 'from filexy import classxy'. Now it worked - but I was able to access everything in the class just fine: Public, weakly and strongly stuff alike, by the names I gave them. So ... what am I missing here?

7/20/2018 6:38:29 PM


6 Answers

New Answer


3. I tried 'from xyfile import *'. Again, everything was there just fine (although I'm still wondering why just 'import xyfile' doesn't work). So what exactly is different if I import or don't import a class with differently privatisized (that a word?) attributes? I don't get it...


Did you try filexy.class_name in the code? Exactly what did you to avail the class? I don't have access to pc now otherwise I would like to help you.


After some time after the question, you will get it.๐Ÿ˜


Roneel, I still don't get it though. ^^'


Roneel, thank you. But I wonder, what would you even help me with? Accomplish LESS? :D I don't remember now, it's already a while ago, but I believe(d) I read somewhere that weakly private stuff isn't imported when you import, and it didn't really make sense to me. So I wrote a little test class, putting random stuff in it, some private, some public, some weakly private, saved it to a file, imported it from another file - and could access every single attribute just fine.


Yes! What can I help you? Python will not change nor its syntax. But I will do a series of experiments and tell if something extraordinary happened. Nothing more