KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to Python and I haven't figured out a simple way of separating code in multiple code files and folders. What I do today is: for each folder I create an __init__.py file. Sometimes it's empty. I don't know why I do it, but it seems necessary. That's the first difference from working with C#. The second difference is that for any file to reference any another I must use an import, like from model.table import Table . And if I have multiple references I need to use multiple imports: from model import table1,table2 and then in the rest of the code I must use table1.Table1 per example. If I don't want to, I should from model.table1 import Table1 from model.table2 import Table2 and then I can use simply Table1 That differs too much from what I'm used to in C#, where if all files were in the same namespace, we didn't have to import . Is there a simpler way for me?
Tags (comma-separated)
Save Edits
Cancel