본문 바로가기

시행착오/[python]

(17)
How to make a system tray application in Tkinter? 파이썬 tkinter 로 시스템 트레이 애플리케이션 만드는 예시 코드 https://www.tutorialspoint.com/how-to-make-a-system-tray-application-in-tkinter How to make a system tray application in Tkinter? How to make a system tray application in Tkinter? A System Tray application is created for the continuous execution of the program. Whenever an application is closed by the user, it will get its state running on the taskbar. To identify a system tray appli www.tutoria..
[Python] Python 심볼릭 링크 설정 [Linux] yum 실행 시 Keyboard.. : 네이버블로그 (naver.com) [Linux] yum 실행 시 KeyboardInterrupt, e 에러 OS 에 default 로 설치된 python 의 버전을 교체하면 아래와 같은 에러가 발생할 수 있다. 이것은 /usr/b... blog.naver.com https://eehoeskrap.tistory.com/316 [Python] Python 심볼릭 링크 설정 Python 은 버전 관리 하는 것이 필수이다. 나중에 Python Dependency 가 꼬여버리면 컴퓨터를 포맷하거나 일일히 꼬인 링크들을 제거해줘야하는 번거롭고 끔찍한 일이 발생한다. pip 도 마찬가지이다. eehoeskrap.tistory.com centos7 환경에서 pyth..
[python] dictionary(딕셔너리)의 clear(), {} 차이 https://brownbears.tistory.com/21 [Python]Dictionary의 clear()와 {} 차이점 아래와 같은 dict 타입의 변수가 존재한다고 할 때, 첫 번째와 두 번쨰의 차이점은 무엇일까? dict_test={"a":"1","b":"2"} #1 dict_test.clear() #2 dict_test={} 두 코드 기능은 "지운다" 라는 점에 있어 동일합.. brownbears.tistory.com dict_tmp1 = dict() dict_tmp1 = dict_tmp2 dict_tmp2 = {} # dict_tmp2 재할당, dict_tmp1 영향 X dict_tmp1 = dict() dict_tmp1 = dict_tmp2 dict_tmp2.clear() # dict_tm..
[python] argument가 없는 lambda 람다식 x = lambda : 6 print(x()) # prints -> 6 어떠한 계산없이 그냥값을 넘겨줌 https://stackoverflow.com/questions/43807953/empty-parameter-for-python-lambda-function Empty Parameter for Python Lambda Function Is it possible in python to write a lambda function that does not need any parameters passed to it? For instance, is there a way to translate this function: def file_opener(): f = open('filena... stackoverflow..
[python] 파이썬 daemon 데몬 만들기 파이썬으로 백그라운드에서 계속 동작하게 하는 프로그램을 실행시키거나 끌때 nohup 과 pkill 을 써서 해도 되나 너무 번거롭고 기존에 데몬이 돌아가고 있는지 체크되지 않으므로 인터넷에서 조사하다가 Sander Marechal 란 사람이 만든 샘플코드가 도움이 되서 기록으로 남김 stackoverflow.com/questions/473620/how-do-you-create-a-daemon-in-python www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ 아래는 위 샘플코드로 간단하게 +1 증가하는 로그 남기는 데몬 프로그램 (리눅스) python main.py start => 시작 python main.py stop => 정지..
[python] 로컬 및 원격 서버내 파일/디렉토리 존재 확인법 [로컬] isdir isfile import os print(os.path.isdir("/home/temp")) print(os.path.isfile("/home/temp/test.txt")) technote.kr/207 [원격] import errno import os def exists_remote(sftp_client, path): try: sftp_client.stat(path) except IOError as e: if e.errno == errno.ENOENT: return False raise else: return True stackoverflow.com/questions/4409502/directory-transfers-with-paramiko docs.python.org/ko/3/lib..
[python] filter 함수 사용시 주의할 점 - iterator stackoverflow.com/questions/44420135/filter-object-becomes-empty-after-iteration/44420191#44420191 >>> l = range(10) >>> k = filter(lambda x: x > 5, l) >>> list(k) [6, 7, 8, 9] >>> list(k) [] filter 함수 나온 결과값 확인하기 위해 프린트 찍고 그 값을 다른 곳에 넘기니까 빈 값이 나와 문제가 생긴적이 있다 위 사이트에 따르면 filter 함수는 이터레이터 객체를 반환하고 이 객체는 한번만 iterate 가능하다고 함 첫번째 list() 함수를 호출함으로서 끝까지 다 돌았으므로 두번째 list() 함수호출에서는 끝까지 다 돌아서 더이상 literate..
[python] paramiko ssh 연결되어있는 상태인지 체크법 stackoverflow.com/questions/28288533/check-if-paramiko-ssh-connection-is-still-alive Check if paramiko ssh connection is still alive Is there a way to check if a paramiko SSH connection is still alive? In [1]: import paramiko In [2]: ssh = paramiko.SSHClient() In [3]: ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())... stackoverflow.com if ssh.get_transport() is not None: print(ssh.get_..