Ciao, Il giorno 21 giugno 2017 08:24, Karim <lemieli...@gmail.com> ha scritto:
> Salve lista, sono talmente abituato ad usare django che ora che devo farmi > un package che avrei il piacere di distribuire, mi scontro con problemi > banalissimi. > > > Ho creato questo package > > pyfaction/ > ├── __init__.py > ├── __pycache__ > ├── conn.py > ├── constants.py > ├── exceptions.py > ├── managers > │ ├── __init__.py > │ ├── __pycache__ > │ ├── apps.py > │ ├── base.py > │ ├── domains.py > │ └── tests > │ ├── __init__.py > │ ├── __pycache__ > │ ├── tests_apps.py > │ └── tests_domains.py > └── utils.py > > > se sono sul modulo conn.py e faccio: > > from .managers.apps import MyClass > > Tutto e' ok. > > Se da managers/domains faccio: > > from ..exceptions import MyException > Anche se stai facendo un riferimento verso un modulo interno del tuo package credo che in questo caso sarebbe meglio usare from pyfaction.exceptions import MyException; quando il package sarà finito e installato in site-packages questo dovrebbe funzionare "normalmente" mentre in fase di sviluppo credo ti convenga lavorare con PYTHONPATH in alcuni casi, specialmente per le fasi di sviluppo e test, ho trovato comodo aggiungere il parent della directory del package al sys.path in questo modo import *sys* *sys*.path.append('..') questo perchè avevo bisogno di avere il package visibile ad un progetto di test che lo avrebbe usato, immagina una struttura del genere mypackage - __init__.py - somecode.py exampleproject - myexamplecode.py cmq dipende molto da come è impostato il tuo progetto -- "Unix IS user friendly. It's just selective about who its friend are" "Nevertheless I still think it’s a bad idea to make things harder for ourselves if we can avoid it." "C is quirky, flawed, and an enormous success." -- Dennis Ritchie "Shipping is a feature. A really important feature. Your product must have it." "There is no such a thing as a temporary change or workaround: In most cases, workarounds are tech debt." "La gatta frettolosa ha fatto i gattini ciechi"
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python