본문 바로가기 메뉴 바로가기

고래처럼: Engineer<Computer>

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

고래처럼: Engineer<Computer>

검색하기 폼
  • 분류 전체보기 (15)
    • 생각정산 (5)
    • 컴퓨터 (10)
    • 세상동향 (0)
  • 방명록

프로그래밍 (2)
Python 함수의 기본값의 비밀

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..

컴퓨터 2023. 4. 25. 11:30
.NET Stream 효율적으로 사용하기

.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..

컴퓨터 2023. 4. 24. 00:20
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday

Blog is powered by Tistory / Designed by Tistory

티스토리툴바