我认为''import long.name as short''语法将帮助你的手腕最多,但仍保留显式模块引用的清晰度。 你不会有无关的任务(tmp = long.name) 混乱你的代码。 干杯, Clifffullpath);and I keep wondering where basename came from. Is it a builtin? Was itfrom File:: A prefix, no matter how short, how obscure, howundescriptive, will let you trace exactly where each name came from.Which I find deeply beautiful. All you have to do is look up the page,and it''s there somewhere. You *can* do the same with Perl, but it''sactually discouraged by the structure of the language. In other words,the simplest case does the wrong thing.Python does allow you to import all names from a module, unprefixed butit leads you into the same ugliness and namespace clobbering that youget with Perl, so I''m not going to tell you how to do it.I think the ''import long.name as short'' syntax will help your wrists themost while still retaining the clarity of explicit module referencing.And you won''t have the extraneous assignment (tmp = long.name)cluttering up your code.Cheers,Cliff 这篇关于Python“with”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 01:36