S
Steven D'Aprano
I can not use the above approach as I mentioned its problem in my
previous message.
Either I have not seen it, or I have not understood it, but I don't
understand why you can not use this approach.
This artificially introduces the constraint that the file name can not
be the same as the class/function name. There is no constraint like this
if I can C++.
It is not a constraint, it is a convention. You are free to ignore it if
you like.
Some people don't like writing "glob.glob" (for example). Some people
would like to see Python ban modules with the same name as objects inside
them, to avoid this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'datetime.datetime' has no attribute
'datetime'
You seem to be inconsistent -- you say you want to name the file the same
as the function in it, so you know which file to look for a function, but
then you complain about writing:
test.A.A
so when we suggest naming A.py a.py, so you can write:
test.a.A
you complain about that too. Frankly, I think you are just complaining
because Python isn't C++.
This sentence is confusing. Can you spell out what you mean?
If you supply a package
test/
+-- __init__.py
+-- A.py
+-- B.py
there is nothing stopping your users from doing this:
import test.A as A
import test.B as SomethingElse
[...]
I have defined 'long' in one of my previous message. I consider a file
long, when it does not fit in one or two screen. Basically, I want to
get a whole picture of the file after glancing of the file.
You must only write incredibly trivial programs then.
There is more to understanding a program than understanding one single
function. Any serious function will call other functions. To get the
whole picture, you have to understand them too. Your requirement simply
shifts the burden from "open one file, and read ten functions" to "open
ten files, and read ten functions".