Zanurkuj w Pythonie/Wyjątki i operacje na plikach - wszystko razem: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
m poprawa nawigacji |
tłumaczenie |
||
Linia 2:
== Wszystko razem ==
Jeszcze raz ułożymy wszystkie klocki domina w jednym miejscu. Już wcześniej poznaliśmy, w jaki sposób działa każda linia kodu. Teraz znowu do tego powrócimy i zobaczymy, jak to wszystko jest ze sobą dopasowane.
'''Przykład 6.21. listDirectory'''
Linia 20:
return [getFileInfoClass(f)(f) for f in fileList] #(6)
# <tt>listDirectory</tt>
# As you saw in the previous section, this line of code gets a list of the full pathnames of all the files in directory that have an interesting file extension (as specified by fileExtList).
# Old-school Pascal programmers may be familiar with them, but most people give me a blank stare when I tell them that Python supports nested functions -- literally, a function within a function. The nested function getFileInfoClass can be called only from the function in which it is defined, listDirectory. As with any other function, you don't need an interface declaration or anything fancy; just define the function and code it.
|