Hacker News new | comments | show | ask | jobs | submit login

I agree - Python is great and rather neutral (as soon as snake_case_naming stops causing you nausea and as soon as you stop worrying about types and the fact you can't make a class member truly private) yet it has one thing I really hate - the module/package system. Coming from C# I could never "grok" it in Python (might anybody have a link to a great intro in this subject optimized for a C# mind - I'd be more than grateful) and being unable to split a single namespace into a number of files is outrageous (especially for an ADHD person who can't stand long code files and importing every this and that manually everywhere).

> being unable to split a single namespace into a number of files is outrageous

The usual solution to that is an __init__.py that pulls in the names from its subpackages. I'm sure you'll be able to find an example of that in basically any large open-source Python project.

I have tried this once and it didn't work although pylint has passed with no errors (surely I admit that's because of a mistake I have made but I haven't managed to find and fix it so I've ended up just putting all the code in one file). Anyway it's not what I need as far as I understand (I have described what I need in a comment below, the answer to mixmastamyk).

Import several files into one, then import it elsewhere.

E.g. I have file aaa.py, bbb.py and ccc.py (placed in the same directory but I don't mind adding a line of code to declare their relationship explicitly). What I want is not only to be able to import them all at once in ddd.py but to access everything from aaa and bbb in ccc, everything from bbb and ccc in aaa and everything from aaa and ccc in bbb [almost] seamlessly.

You could create a __init__.py file that imports everything from each of those files:

    from .aaa import *
    from .bbb import *
    from .ccc import *
Then in each of the other files (aaa.py, etc) put:

    from . import *

Thats a circular import and thus not guaranteed to work.

Python3 typing is fine, on a par with all other mainstream languages. Its extreme dynamism makes namespace control a non issue, just plug what you want where you want it dynamically.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact