Programming/Python2010.12.06 14:10
[출처 : http://www.imp17.com/tc/myevan/72?category=4]


dir 만으로는 원하는 함수를 찾기 힘들때가 있다.

def candi(obj, findName):
    return [itemName for itemName in dir(obj) if itemName[:len(findName)] == findName]

import os
print "dir"
print dir(os.path)
print ""
print "candi"
print candi(os.path, "split")


~(-_-)~ 짠

dir
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '_getfullpathname
', 'abspath', 'altsep', 'basename', 'commonprefix', 'curdir', 'defpath', 'devnul
l', 'dirname', 'exists', 'expanduser', 'expandvars', 'extsep', 'getatime', 'getc
time', 'getmtime', 'getsize', 'isabs', 'isdir', 'isfile', 'islink', 'ismount', '
join', 'lexists', 'normcase', 'normpath', 'os', 'pardir', 'pathsep', 'realpath',
 'sep', 'split', 'splitdrive', 'splitext', 'splitunc', 'stat', 'supports_unicode
_filenames', 'sys', 'walk']

candi
['split', 'splitdrive', 'splitext', 'splitunc']
저작자 표시
신고
Posted by nlogn

티스토리 툴바