Python의 Super() 함수의 역할을 이해할수 있는 예제

class A(object): def save(self): print 'A saved' class B(A): def save(self): print 'B saved' A.save(self) class C(A): def save(self): print 'C saved' A.save(self) class D(B, C): def save(self): print 'D saved' B.save(self) C.save(self) a = D() a.save() print "—————————————-" class A(object): def save(self): print 'A saved' class B(A): def _save(self): print 'B save' def save(self): […]

Python Source 디렉토리 구조 검색

def ls(dir, hidden=False, relative=True): nodes = [] for nm in os.listdir(dir): if not hidden and nm.startswith('.'): continue if not relative: nm = os.path.join(dir, nm) nodes.append(nm) nodes.sort() return nodes def find(root, files=True, dirs=False, hidden=False, relative=True, topdown=True, self_check=False): root = os.path.join(root, '') # add slash if not there for parent, ldirs, lfiles in os.walk(root, topdown=topdown): if relative: […]

Python으로 제작한 자동 resize와 함께, 자동 logo 붙이는 스크립트

#!/usr/bin/python import Image, sys, os, glob type_list = {} type_list["type_A"] = {"horizontal": (415, 482), "vertical": (415, 482)} type_list["type_B"] = {"horizontal": (150, 133), "vertical": (150, 133)} type_list["type_C"] = {"horizontal": (600, 600), "vertical": (600, 600)} type_list["type_D"] = {"horizontal": (200, 200), "vertical": (200, 400)} OriginalDIR = "./psd/" CompleteDIR = "./complete/" LogoDIR = "./logo/" def openImg(file) : targetImage = […]