Made the world slightly worse
This commit is contained in:
parent
3d31a2d7e5
commit
93a127beed
|
@ -1,2 +1,3 @@
|
|||
# Phpython
|
||||
|
||||
Are you tired of writing so many import statements?
|
||||
Fear not, with Phpython you can just `from star import *`
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# How this works:
|
||||
#
|
||||
# - Make a list of everyhing importable and expose it with __all__
|
||||
# - Python fetches __all__ and tries to import everything
|
||||
# - Via __getattr__ when the stuff starts getting imported by python, import
|
||||
# the required module and return it
|
||||
# - Profit ???
|
||||
import sys
|
||||
import os
|
||||
|
||||
mods = [
|
||||
[
|
||||
f.split(".", 1)[0]
|
||||
for f in os.listdir(spath)
|
||||
if f.endswith(".py")
|
||||
or (
|
||||
os.path.isdir(f)
|
||||
and os.path.exists(os.path.join(f, "__init__.p__init__.py"))
|
||||
)
|
||||
]
|
||||
for spath in sys.path
|
||||
if os.path.exists(spath)
|
||||
]
|
||||
__all__ = [f for m in mods for f in m]
|
||||
__path__ = []
|
||||
|
||||
def __getattr__(name):
|
||||
return __import__(name)
|
|
@ -0,0 +1 @@
|
|||
breakpoint()
|
Loading…
Reference in New Issue