我在Python中创建了一个名为nester.py
的简单模块:
源代码:
"""
This function prints a Python list, which may contain nested lists,
in a sweet format.
This function takes one required and two optional parameters.
Required:
=========
1> bigList - The list that may or may not contain nested lists.
Optional:
=========
1> level - The level of the indent.
2> indent - If a list is to be indented or not.
"""
def nester(bigList, level = 0, indent = False):
for items in bigList: # Traverse through each item.
if isinstance(items, list): # If the current item is a nested list,
nester(items, level + 1, indent) # Recurse with the nested list and +1 indent level.
else: # Else,
if indent: # Check if indent is desired,
for nest in range(level):
print("\t", end = '') # Print `level` numbers of '\t' characters.
print(items) # Finally print atomic item in the list.
我希望在 http://pypi.python.org上上传此模块
所以我创建了以下setup.py
:
from distutils.core import setup
setup(
name = "nester",
version = "1.0.0",
py_modules = ["nester"],
author = "Aditya R.Singh",
author_email = "adipratapsingh.aps@gmail.com",
url = "http://adirascala.site50.net",
description = "A sweet printer of nested Python lists."
)
这是我第一次尝试在PyPi
上传内容
现在从Macbook pro terminal
我输入:
python setup.py register
这是我得到的输出:
Adityas-MacBook-Pro:nester aditya$ python setup.py register
running register
running check
We need to know who you are, so please choose either:
1. use your existing login,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
Your selection [default 1]:
1
Username: AdiSingh
Password:
Registering nester to https://pypi.python.org/pypi
Server response (403): You are not allowed to store 'nester' package information
Adityas-MacBook-Pro:nester aditya$
为什么我不允许存储包裹信息?我确实使用用户名AdiSingh
注册了PyPi,并确认了我的注册。
任何帮助?
我错过了什么?
提前谢谢!
答案 0 :(得分:4)
首先,如果您只是在玩游戏,那么您应该使用TestPyPI,主PyPI站点通常是为实际模块保留的。您需要单独登录,只需阅读链接。
其次,searching PyPI for nester
显示已经存在具有该名称的包(以及许多类似的包),这就是您收到错误的原因。在上传之前,您需要为包选择一个唯一的名称。