클로저(Closure)

1. Nested Scope def안 다른 def를 정의했을 때 Nested Scope가 생긴다. innter def를 감싸는(enclosing) outer def의 scope를 enclosing function(def) scope라고 한다. (주의: def안에서 선언된 변수는 모두 Local이다.) X = 10...

너비 우선 탐색(Breadth-first search)

1. Basic Breadth를 번역하면 ‘너비’ (또는 폭)다. 그렇다면 여기서 왜 너비라는 단어를 사용하는 것일까? 그래프 G = (V, E)와 source vertex s가 주어져 있다고 가정해보자. s를 기준으로 그래프를 너비 우선...

그래프 나타내기 (Reresentations of graphs)

0. Basic Vertices(점)가 V고 Edges(선)가 E인 그래프 G: G = (V,E) Edge를 기준으로 나눈 그래프의 두 가지 종류: Undirected graph: edge가 양뱡향(bidirectional) ( O — O ) Directed graph: edge가...

유저컨트롤러 만들기(Creating a User conroller) - 2

순서 CRUD 중 Read 구현하기 CRUD 중 Update 구현하기 Reference 사이트 1. CRUD 중 Read 구현하기 Read는 데이저베이스에서 User데이터를 가져와 view에 전달하는 action이다. request시, paramter로 objectId를 전달한다. mongodb에 저장될 때...

LEGB rule

Scope Scope란 변수가 사는 공간이다. 변수는 scope를 벗어나면 소멸하게 된다. 변수의 scope는 변수에 처음 대입(assignment)연산이 이루어진 곳으로 정해진다. # beginning of module x = 1 def func(): x = 1...

유저컨트롤러 만들기(Creating a User conroller) - 1

순서 필요한 패키지와 모듈 불러오기 CRUD 중 create action 구현하기 Reference 사이트 1. 필요한 패키지와 모듈 불러오기 User 모델과 로그인/로그아웃 처리를 위해 passport.js를 불러온다 // controllers/userController.js const User = require("../models/user"),...

iterable과 iterator

1. Iteration Python에서 iteration은 scanning과 selecting의 결합이다. object를 왼쪽에서 오른쪽으로 scanning하여 값을 하나씩 selecting하는 것을 말한다. 가장 기본적인 iteration은 for loop을 통해 구현할 수 있다. iteration의 대상은 iterable object 이며...

궁금한 거 파이썬에게 직접 물어보기(Python Documentation Sources)

1. dir function Python interpreter(shell)에 dir() 를 입력하면 caller의 스코프에 있는 변수들의 list를 보여준다. >>> x = 1 >>> name = "python" >>> dir() ['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__',...

유저모델 만들기(Creating a User model)

순서 mongoose.Schema 정의하기 SchemaTypes 설정하기 Validating virtual property 설정하기 pre hook 설정하기 plugin 설정하기 export reference 사이트 1. mongoose.Schema 정의하기 Schema는 Mongodb의 collection에 mapping되며 Schema 정의는 documents의 shape를 설정하는 단계다....