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 = '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:
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 !