목록전체 글 (41)
youngfromnowhere
https://stackoverflow.com/questions/38254304/python-can-generators-be-recursive Python: can generators be recursive?My recursive generator doesn't work: def recursive_generator(list_): yield list_[0] recursive_generator(list_[1:]) for k in recursive_generator([6,3,9,1]): print(k) Expected output: 6...stackoverflow.com 앞서서 yield문을 이용하여 구현되는 generator에 대해 알아보았다.그런데 이 generator를 recursive하게 구현하고 싶을..
참고자료Data Structure & Algorithms in Python, Michael T. Goodrich (이하 DSnA)Python 공식문서(https://docs.python.org/3.12/) Iteratable을 구현하려면, iterator를 반환하는 __iter__() method를 구현해야한다.https://youngnowhere.tistory.com/58 [Python] Iterator참고자료Data Structure & Algorithms in Python, Michael T. Goodrich (이하 DSnA)Python 공식문서(https://docs.python.org/3.12/) Python 공식문서에서는 Iterator를 다음과 같이 정의하고 있다.An object repre..
참고자료Data Structure & Algorithms in Python, Michael T. Goodrich (이하 DSnA)Python 공식문서(https://docs.python.org/3.12/) Python 공식문서에서는 Iterator를 다음과 같이 정의하고 있다.An object representing a stream of data. Repeated calls to the iterator’s __next__() method (or passing it to the built-in function next()) return successive items in the stream. When no more data are available a StopIteration exception is rai..
디버깅 하다가, 실서버에서는 잘 질의되는 쿼리문이 로컬에서는 에러를 뱉는 현상을 봤다.에러 메세지는The user specified as a definer ('[user_name]'@'[host_name]') does not existuser_name은 실DB서버에서 웹서버 클라이언트가 사용하는 유저명이었다. https://stackoverflow.com/questions/10169960/mysql-error-1449-the-user-specified-as-a-definer-does-not-exist MySQL error 1449: The user specified as a definer does not existWhen I run the following query I get an error: SELE..
https://youngnowhere.tistory.com/54 [Python] pyenv로 가상환경 구축하기. 1. Python의 여러 가상환경 관리 툴 지금 듣고 있는 강의에서 가상환경 구축을 위해 pyenv라는 툴을 이용하라고 한다. 근데 이게 좀 복잡해 보인다. 가상환경만 만드는게 아니라 python 버전 관리 기능 youngnowhere.tistory.com 해당 포스팅에서 pyenv를 설치할 때, 메세지에서 안내하는 바에 따라 .profile, .bashrc 등의 설정파일을 수정했다. 이제 각 파일의 역할이 무엇이었고 거기에 추가한 스크립트는 무슨 의미였는지 알아보자. 로그인 shell 프로세스 이해하기 (출처 리처드 블룸, 트랜지스터팩토리 옮김, 3rd, 176p.) 리눅스 시스템에 로그인했..
1. Python의 여러 가상환경 관리 툴 지금 듣고 있는 강의에서 가상환경 구축을 위해 pyenv라는 툴을 이용하라고 한다. 근데 이게 좀 복잡해 보인다. 가상환경만 만드는게 아니라 python 버전 관리 기능까지 포함하고 있다. 가상환경은 외부 라이브러리에 대한 의존성을 관리하기 위한 것인데, 사실 어떤 프로젝트가 외부 라이브러리 뿐 아니라 python의 버전 그 자체에도 의존성을 가질 수 있기 때문에 버전 관리 기능을 동시에 할 수 있는 툴을 쓰는 것 같다. 난 이미 이전에 python 버전 관리는 update-alternatives 명령으로, 가상환경은 python -m venv로 했었기 때문에 그 냥 그렇게 하려고 했는데, 다음과 같은 메세지가 떴다. (현재 python 버전은 3.10.12) ..
https://youngnowhere.tistory.com/51
include문이 포함된 파일을 include할 때 예상하지 못한 특성이 발견되어 기록한다. test를 위해 다음과 같이 directory를 구성한다. index.php가 a.php를 include하고 a.php가 b.php를 include하도록 만든다. 각 파일의 내용은 다음과 같다. #index.php #subdir_1/a.php #subdir_2/b.php a.php에 대하여 b.php의 상대경로는 ../subdir_2/b.php가 맞으므로, 문제가 없어보인다. 이제 index.php를 실행시키면.. ../subdir_2/b.php를 찾을 수 없다는 에러 메세지가 뜬다. a.php를 다음과 같이 수정한다. #subdir_1/a.php Modified 그러면 의도한대로 작동한다. 즉, a.php에 포..
PHP 공식문서나 모든 강의에는 HTML form을 통해 GET, POST를 메소드로 하여 data를 전달받았을 때 해당 data에 접근하는 방법으로 $_GET, $_POST라는 array 타입의 전역변수를 소개하고 있다. 가령 "http://(사이트 주소)?var_name=data_value"로 get요청을 보내면 $_GET["var_name"]을 통해 data_value 값에 접근하는 식이다. 매번 $_GET["var_name"] 하는 식으로 data를 가져오기 번거로우니 대부분 다음과 같이 다른 변수에 재할당한다. 그런데 공부하면서, 위와 같은 재할당 없이 바로 data에 접근이 되는 현상을 발견했다. $_GET이나 $_POST를 쓰지 않더라도 parameter와 같은 변수명을 쓰면 바로 그 val..
https://youngnowhere.tistory.com/43 [Java] Call-by-Value/Call-by-Address/Call-by-Reference 함수를 호출할 때 함수에 '무엇을' 전달하느냐에 따라 함수 호출방식을 Call-by-Value, Call-by-Address, Call-by-Reference로 나눈다. Call-by-Value. 함수에 어떤 변수의 값을 전달한다. 함수는 값을 전달받았을 youngnowhere.tistory.com 위 글에서 call by value와 call by reference의 차이에 대해 고찰한 바 있다. java에서 함수에 reference type의 변수가 전달되는 case와 c++의 사례를 비교하면서 어째서 java에는 'call by refer..