+ 2

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?

20th Jul 2018, 6:38 PM
HonFu
HonFu - avatar
6 Respuestas
+ 2
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...
20th Jul 2018, 7:48 PM
HonFu
HonFu - avatar
+ 2
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.
7th Nov 2018, 9:53 PM
Roneel
Roneel - avatar
+ 1
After some time after the question, you will get it.😁
7th Nov 2018, 8:08 PM
Roneel
Roneel - avatar
+ 1
Roneel, I still don't get it though. ^^'
7th Nov 2018, 9:22 PM
HonFu
HonFu - avatar
+ 1
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.
7th Nov 2018, 10:50 PM
HonFu
HonFu - avatar
0
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
7th Nov 2018, 10:53 PM
Roneel
Roneel - avatar