How to handle '-' in the 'from' part in a "from import" statement?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Mon Oct 7 23:42:14 EDT 2019


DL Neil於 2019年10月8日星期二 UTC+8上午11時02分20秒寫道:
> On 8/10/19 3:45 PM, jfong at ms4.hinet.net wrote:
> > For example:
> > from my-dir import test
> > 
> > I know it can be solved by renaming, but any alternative?
> 
> 
> The manual is your friend:
> - import
> - importlib
> 
> (the latter allows modules to be identified by strings)
> 
> However, Pythons has naming rules. If you try to get around them, sooner 
> or later you'll 'forget' and trip yourself up. Recommend your first idea!
> -- 
> Regards =dn

Yes, I had noticed the naming rules. Thank you.

But most of the download from Github has a directory named 'xxxx-master' which causes a trouble sometimes.

--Jach



More information about the Python-list mailing list