Everything in Python is an object. 파이썬에서 모든 것은 개체(오브젝트, object)다. 파이썬 함수도 예외는 아니다. 예전에 파이썬 코딩을 하다가 이상한 것을 목격했다. 빈 리스트를 기본값으로 가지고 있는 함수의 반환값이 계속 변화하는 것이다! >>> def func(l=[]): ... l.append('lol') ... return l ... >>> func() ['lol'] >>> func() ['lol', 'lol'] >>> func() ['lol', 'lol', 'lol'] >>> func() ['lol', 'lol', 'lol', 'lol'] 이런 일이 발생하는 것은 파이썬에서 함수는 하나의 개체로써, 기본값들을 속성으로 저장하고 있기 때문이다. 함수의 dunder..

.NET에서 프로그램을 작성하다보면 Stream(스트림)을 사용할 때가 많은데, 공식 문서를 읽어보면 이렇게 쓰여있다. Stream is the abstract base class of all streams. A stream is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. The Stream class and its derived classes provide a generic view of these different types of input and output, and isolate the program..
- Total
- Today
- Yesterday