码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-09-09 10:44:28      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   ar   for   2014   

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 = XXXX@163.com,
        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:

bubuko.com,布布扣

bubuko.com,布布扣

 

Finally, install the problem.

bubuko.com,布布扣

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

标签:des   style   blog   http   color   io   ar   for   2014   

原文地址:http://www.cnblogs.com/zhuojiniao/p/3960819.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!