Skip to content

Instantly share code, notes, and snippets.

@Puriney
Last active August 24, 2016 13:20
Show Gist options
  • Save Puriney/05aff3fc7207f01aa3884944bc0dbfd5 to your computer and use it in GitHub Desktop.
Save Puriney/05aff3fc7207f01aa3884944bc0dbfd5 to your computer and use it in GitHub Desktop.
Mini example of showing intra-package importing

Folder structure:

__init__.py is a blank file.

├── RandInit_HMM_Py
│   ├── __init__.py
│   ├── demoRunPkg.py
│   ├── demoRunIn.py
|.. ├── helper.py
├── demoRun.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from RandInit_HMM_Py.demoRunPkg import *
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
try:
from .helper import *
except SystemError as e:
from helper import *
print_logger("Manage to import file inside")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from .helper import *
print_logger("manage to import module in sub-dir")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@contact: Yun Yan ([email protected])
"""
import os
import time
import shutil
import subprocess
import yaml
def join_path(*args):
x = map(str, args)
return(os.path.join(*x))
def paste(*args, sept=" "):
x = map(str, args)
return(sept.join(x))
def paste0(*args):
return(paste(*args, sept=""))
def print_logger(msg):
localtime = time.asctime(time.localtime(time.time()))
print(paste(">>" + "[" + localtime + "]" + msg))
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment