본문 바로가기

PYTHON36

[Python] Slash and Asterisk for Function Parameters Function의 헤더에서 parameters 를 정의하는데, 해당 parameters 중, 어떤 것들이 positional parameters 로만 사용가능한지, 어떤 것들이 일반적인 parameters로서 positional parameters 또는 keyword parameters 모두 사용가능한지, 어떤 것들은 keyword parameters 로만 사용가능한지 를 명시적으로 선언하는데 사용되는 symbol이 바로 slash / 와 asterisk * 임. 사용법 사용법은 다음과 같음. def ds_func(pos_only_arg0, pos_only_arg1, /, arg0, arg1, *, kw_only_arg0, kw_only_arg1): pass slash / 앞의 파라메터들은 positio.. 2024. 2. 4.
[linter] Linter (or Lint) 린트(lint) 또는 린터(linter) 라고 불리는 Tool은 다양한 프로그래밍 언어에서 source code를 분석하여 프로그램밍 오류, 버그, 스타일 오류 또는 불일치, 잠재적인 문제점(issue) 등을 식별하고 표시(flag)를 달아놓는 tool (or software)임. 이러한 tool은 source code (이후 code) 검사를 자동화하여, 코드의 가독성과 유지보수성을 향상시키며, 개발 초기 단계에서 문제를 발견하고 이를 해결하도록 도와주어 개발 시간과 비용을 절감하는데 효과적임. Python의 경우, pylint 와 pyflkes, flake8 과 같은 여러 linter tools가 존재함. code style를 체크해주는 pep8 도 있으나 linter라고 보기엔 조금 기능이 약함. .. 2024. 2. 3.
[Python] mutable and immutable: Mutability Python에서 Data Types를 구분짓는 중요 속성. Python에서 Object 는 id, type, value, reference count 를 가지는데, 이 중 value를 변경할 수 있는지를 나타내는 것이 바로 mutability임. Mutable인 type의 object(객체)는 자신의 value를 다른 값으로 변경할 수 있음. 하지만 immutable type의 object는 자신의 value를 초기에 할당받고 나서는 다른 값으로 변경이 안됨. Function등에서 argument로 mutable type을 넘겨줄 경우, 주의를 기울여야 함 (function 내에서 변경이 function 외에서도 영향을 줌). 주의할 것은 mutable이나 immutable이냐에 상관없이 Python에서.. 2024. 2. 3.
[Python] Arithmetics, Variables, Types and Assignment Numeric Type and Arithmetic in Python (+Augmented Assignment) https://dsaint31.tistory.com/516 [Python] Arithmetic in Python and Augmented Assigment 1. Precedence of Arithmetic Operations Higher ** > -(negation) > * = / = // = % > + = -(subtraction) Lower 우선순위를 기억하는 것도 중요하지만, 헷갈리면 그냥 parentheses로 묶어주면 된다. (가독성을 위해서도 이를 추천 dsaint31.tistory.com https://dsaint31.tistory.com/515 [Python] (Data) Type.. 2024. 1. 24.
[Python] File Handling File 열고 닫기. 2023.07.04 - [Python] - [Python] file : open and close [Python] file : open and close Python 에서 file을 처리하기 위해선 다른 프로그래밍 언어와 마찬가지로 file에 대한 접근이 가능한 object를 얻어와야함. 이같은 object는 file handler, file descriptor 등의 여러 이름으로 불리며, 이를 얻 ds31x.tistory.com Text file 처리 2023.07.04 - [Python] - [Python] Text File : read and write [Python] Text File : read and write 쓰기 open으로 얻은 file object의 메서드 writ.. 2023. 12. 5.
[Python] input 함수 사용하여 사용자 입력받기. Python의 input() 함수는표준 입력 스트림(stdin)으로부터 데이터를 받는 함수 Terminal에서 수행되는 CLI (Command Line Interface) 프로그램은입력을 stdin (표준 입력, standard input)에서 받아드리고출력은 stdout (표준 출력, standard output)에서 수행함.stdout과 stdin은 일종의 file stream이며데이터를 해당 stream에 흘려보내거나 흘려받아서 출력과 입력이 이루어짐.  A stream is a fairly abstract, high-level conceptrepresenting a communications channel to a file, device, or process.2024.09.11 - [CE] - [.. 2023. 10. 10.
반응형