728x90 반응형 Python286 [Python] sys 모듈 Python VM (or Interpreter) 와의 상호작용 담당. sys 모듈은interpreter에 의해 사용되거나 유지되는 variables 와interpreter와 밀접(interpreter 종료 등)하게 관련된 functions 에대한 access를 제공함. 주로 많이 이용되는 attributes는 다음과 같음.sys.argvPython script에 command line을 통해 전달된 argument list.argv[0] : script file 이름.argv[1] 부터는 script file 명 다음에 전달된 argument임. 공백문자로 구분됨.python -c 를 통해 python code가 주어진 경우에는 argv[0]가 -c임. #!/bin/env python# test_argv.. 2023. 9. 25. [Pandas] Index 지정 관련 메서드 : reset_index, set_index DataFrame 인스턴스에서 index를 새로 만들거나 다른 columns 를 index로 지정하는데 사용된다.reset_indexDataFrame 인스턴스에서 기존 index 대신하는 새로운 index를 만든다.drop 파라메터의 값을True로 지정한 경우, 기존의 index 는 삭제됨 (default는 False임) :False인 경우, 이전의 index가 column으로 추가됨.inplace 파라메터의 값을True로 지정한 경우, 기존의 객체를 변경한다.default는 False임.set_indexDataFrame 인스턴스에서 특정 column을 index로 지정한다.keys 파라메터의 값으로 새롭게 index로 지정할 columns의 이름들을 지정한다.drop 파라메터는 새롭게 index로 지정.. 2023. 9. 20. [Python] IPython shell 에서 shell cmds 사용하기. IPython 에서 지원하는 shell commandsPython interactive shell에서 OS등이 지원하는 shell commands를 사용하지 못하는 것과 달리, IPython shell에서는 많이 사용되는 shell commands는 다음과 같이 지원함.In [17]: pwdOut[17]: '/home/dsaint31'In [18]: lslectures@ Mambaforge.sh* Miniconda3-latest-Linux-x86_64.sh* test/mambaforge/ miniconda3/ pdfsizeopt/In [19]: cd pdfsizeopt//home/dsaint31/pdfsizeoptIn [20]: lspdfsizeopt_libexec/ pdfsizeop.. 2023. 9. 19. [Python] else: break checker 반복문에서 else는loop 가 break로 끝나지 않을 경우 수행되는 code block을 지정.조건문에서 else일반적으로 else의 경우, 앞서의 if 와 elif문들에서 실행된 block이 없는 경우 수행되는 것을 의미한다.2023.07.28 - [Python] - [Python] if, elif, else statements [Python] if, elif, else statementsif, elif, else statements (조건분기문)프로그램의 flow control를 담당하는 compound statement. (loop문과 함께)더보기Flow control을 위한 Control Structures에 대한 내용은 다음 URL을 참고.2025.04.23 - [Python] - [Prog.. 2023. 9. 18. [Python] Type Annotation: 파이썬에서 변수 및 함수에 type 지정. Python은 Dynamic language이기 때문에 variable은 여러 type object를 가리킬 수 있다.이는 매우 높은 유연성을 제공해주고, 작은 규모의 소스코드에서는 잘 동작한다. (특히 type에 대해 자유롭다보니 언어의 진입장벽을 낮춰주는 효과도 있다.)하지만, object의 implici type conversion이 제한되는 strong typing language 이므로runtime에서 TypeError가 발생할 확률이 커지기 때문에 대규모의 프로젝트에서는 버그가 많아진다는 단점을 가진다.더보기2025.12.09 - [Python] - Typing: dynamic vs. static and strong vs. weak Typing: dynamic vs. static and st.. 2023. 8. 30. [Python] functools.partial functools.partial(func, /, \*args, \*\*keywords) ref.: functools.partial function 처럼 동작하는 partial object를 반환한다. 반환되는 partaial object를 호출시 parameter로 받은 func이 호출되며 partial object를 호출할 때 넘겨진 positional arguments args와 keyword arguments keywords가 해당 func의 argument로 주어져 호출된다. 만약 partial object가 호출될 때 더 많은 arguments가 주어질 경우, partial object를 생성할 때 주어졌던 args와 keywords에 append되어 func에 넘겨진다 (keyword에 따라 .. 2023. 8. 25. 이전 1 ··· 38 39 40 41 42 43 44 ··· 48 다음 728x90 반응형