Learn Python From 'Head First Python' [2] : Sharing

1.publish

2.update print_lol

PS:

for Step 1.

write the code in to a py file. put the py file into a folder named nester. new a py file named ‘setup‘ and the content as below:

setup(
        name = ‘nester‘,
        version = ‘1.0.0‘,
        py_modules = [‘nester‘],
        author = ‘myFirstPython‘,
        author_email = ‘[email protected]‘,
        url = ‘http://XXXX‘,
        description = ‘A Simple Demo of Python‘,
    )

put the folder nest upder the folder ‘Python34‘. run a windows command line and run the command: python setup.py sdist

get the screenshot as delow:

Finally, install the problem.

now, all we can go to IDLE and use this funtion.

>>> a=[‘asd‘,[‘wef‘,[‘ergre‘],‘wefw‘],‘asd‘]
>>> import nester
>>> nester.print_lol(a)
asd
wef
ergre
wefw
asd
>>> 

for function override. edit the source code file and put the code below into the file.

def print_lol(the_list,level=0):
    for each in the_list:
        if isinstance(each,list):
            print_lol(each,level+1)
        else:
            for each_tab in range(level):
                print(‘\t‘,end=‘‘)
            print(each)

the level=0 is the default argument. in other words print_lol(list) equals to print_lol(list,0)

finally, go to the windows command line and run script: python setup.py sdist upload. and dont forget to install the problem again( command: python setup.py sdist install )

To Be Continue !

Learn Python From 'Head First Python' [2] : Sharing

时间: 2024-08-05 19:29:00

Learn Python From 'Head First Python' [2] : Sharing的相关文章

Learn Python From 'Head First Python' [3](2) : Pickle

1.the use of 'with open... as ...' 2.the use of pickle(dump and load) for Step1: the 'with open ... as...' is the short format of 'try...except...finally' for Step2: you can store a list with pickle.dump() and get the content again with pickle.load()

Learn Python From 'Head First Python' [1] : The List

1.the concept of List 2. how to define a method of myself 3.how to iterator a list PS: for Step 2,3. it is related with a key word: 'def'. we define a function like below. def function name: XXXXX e.g. list iterator : 1 def print_lol(the_list): 2 for

Learn Python From 'Head First Python' [0] : Install

1. download software form the python‘s webset 2. install the python and set the class path 3. verify if the install is correct PS: for Step 2. if you use the default install. then undre the disk C:, there will be a dir like Python34. go to the env se

Learn Python From 'Head First Python' [3] : Exception

1.the using of exception 2.file opration import os >>> try: data = open('sketch.txt') for each in data: try: (role,message) = each.split(':') print(role + ' says: ' + message, end='') except ValueError: pass data.close() except IOError: print('fi

Python之路,Day1 - Python基础1

本节内容 Python介绍 发展史 Python 2 or 3? 安装 Hello World程序 变量 用户输入 模块初识 .pyc是个什么鬼? 数据类型初识 数据运算 表达式if ...else语句 表达式for 循环 break and continue 表达式while 循环 作业需求 一. Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语

Python之路,Day1 - Python基础1---转自金角大王

本节内容 Python介绍 发展史 Python 2 or 3? 安装 Hello World程序 变量 用户输入 模块初识 .pyc是个什么鬼? 数据类型初识 数据运算 表达式if ...else语句 表达式for 循环 break and continue 表达式while 循环 作业需求 一. Python介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语

How to install Python 2.7 and Python 3.3 on CentOS

In this guide I will show you how to install Python 2.7 and 3.3 on CentOS 6. The examples below are for Python 2.7.6 and Python 3.3.5, but the procedure is the same for any modern version of Python including the upcoming Python 3.4.0. I make regular

install Python 2.7 and Python 3.3 on CentOS 6

来自:http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/ In this guide I will show you how to install Python 2.7 and 3.3 on CentOS 6. The examples below are for Python 2.7.6 and Python 3.3.5, but the procedure is the same for any modern

Python代写,Python作业代写,代写Python,代做Python(微信leechanx)

Python代写,Python作业代写,代写Python,代做Python(微信leechanx) Redis:Cannot assign requested address的解决办法 客户端频繁的连服务器,由于每次连接都在很短的时间内结束,导致很多的TIME_WAIT,以至于用光了可用的端口号,所以新的连接没办法绑定端口,即"Cannot assign requestedaddress".是客户端的问题不是服务器端的问题.通过netstat,的确看到很多TIME_WAIT状态的连接.