开发者

How important is it to use short names for Python packages and modules?

PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?

edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answ开发者_如何学Goer here, so I'm going to flip a coin to help me decide.


If you need to make sure your code works on DOS, use 8 characters. :p

Otherwise, it's a free world. But nobody likes to type insanely long strings. (See powershell = fail). So use your best judgement, and be reasonable.


The common Python platforms all support directory and file names of 32 characters or more, but I personally feel that if you find yourself breaking 11 characters often that you need to rethink things.


The issue is with old(er) file systems (used before Windows 95 and fat16) that don't support names larger than, say, 32 characters (it varies with the file system). It's only an issue if your scripts need to run on old computers.


Long names make it easy to make stupid typing mistakes later on. Any modern computer shouldn't have a problem with long filenames, but it's good practice to pick short, descriptive names. Abbreviations are your friend, especially when you like knowing what a function does off the bat,etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜