+ 1
Interaction between classes in python (comparing to Java)
I explain myself a little better with examples, so i'll use them. Okay, in Java you can create a package (e.g. netbeans and eclipse way) and create your different classes there; without import them, if they are public, you can engage one with the other (as also in the main). In Python, do i always have to import the classes to engage them with each other? If i use another (idk if call that template or workspace) to every different class?
2 Respuestas
+ 1
the difference is that if you are creating a package, you have to use the keyword 'package' in Java, but you don't have to do it in Python
+ 1
A single code file, may it contain one class, several classes, bunch of different stuff or nothing, has to be imported, if you want to use it in that other code.
Basically, the code from the other file is *run* when you import it, at the moment you do import it. So if that other file only contains function or class definitions, these definitions will be right now executed in your code.
How you can access the names differs by how you import (import math, from math import factorial or whatever).