파이썬에서 클래스를 선언함에 있어서
class 클래스명 :
__init (self, *args) :
pass
로 만들어 지는데 간혹
class 클래스명 (object) :
__init (self, *args) :
pass
로 만들어 질때를 볼 것이다. 이것은
print(dir(클래스명))
으로 쉽게 확인 할수 있다.
제일 위에 것으로 선언했을 경우는
# ['__doc__', '__module__']
아래에 있는 것으로 선언했을 경구는
# ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
이렇게 나온다. 이렇듯 기본적으로 있는 properties을 사용하고 한다면 (object)를 파라미터를 넣어 선언 해주면 된다.
2015/08/19
2015/08/12
[임시][파이썬] 파이썬에서 레지스트리 값 가져오기
import _winreg as winreg
def regkey_value(path, name="", start_key = None):
if isinstance(path, str):
path = path.split("\\")
if start_key is None:
start_key = getattr(winreg, path[0])
return regkey_value(path[1:], name, start_key)
else:
subkey = path.pop(0)
with winreg.OpenKey(start_key, subkey) as handle:
assert handle
if path:
return regkey_value(path, name, handle)
else:
desc, i = None, 0
while not desc or desc[0] != name:
desc = winreg.EnumValue(handle, i)
i += 1
return desc[1]
# example usage
bios_vendor = regkey_value(r"HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "BIOSVendor")
출처 : https://code.activestate.com/recipes/578689-get-a-value-un-windows-registry/
분석 필요함
피드 구독하기:
글 (Atom)