Advertisement
Advertisement

More Related Content

Advertisement

Javascript개발자의 눈으로 python 들여다보기

  1. Javascript개발자가 바라보는 Python기초
  2. python high-level programming language interpreted object oriented simple easy to learn tutorial,,, libraries...
  3. python 으로 할 수 있는 일 웹 어플리케이션 프레임웍,CGI UI 어플리케이션, 시스템프로그래밍, 서버,
  4. python의 철학 중, ‘Complex is better than complicated’ counter = 0 while counter < 5: for i in xrange(5): print counter print i counter += 1
  5. 실행 print “hello world” python hello.py
  6. ; 과 {,} block구분을 위한 brace나 (syntaxError), statement의 끝을 의미하는 semicolon 사용을 권장하지 않음 def calculateFactorial(number { if number == 0{ return 1; }else { result = number * calculateFactorial(number-1); return result; } }
  7. indent python interpreter는 들여쓰기를 기준으로 해석. def calculateFactorial(number): if number == 0: return 1 else : result = number * calculateFactorial(number-1) return result
  8. 변수 count = 1000 //integer pi = 3.14 //floating point name =“jisu” //string type(count) //typeof 와 비슷
  9. global 변수 count = 1; count = 1; def addCount() : def addCount() : global count count +=1 count +=1 print count print count >>> 1 >>> 1
  10. 연산자 javascript python "abc"+"233" "abc"+"233" ->“abc233” ->“abc233”
  11. 함수 javascript python function def aaa() : aaa() { print(1) alert(1); }
  12. lists t = [‘a’, ‘b’ , ‘c’] del t[1] print t [‘a’, ‘c’]
  13. lists t = ‘pining for the fjords’.split() print t ['pinging', 'for', 'the', 'jfords'] >>> print t[1:3] ['for', 'the']
  14. dictionaries var obj = {“name”: “jisu”, “age”:20} >>> dict = {} >>> dict["name"] = "jisu" >>> print dict {'name': 'jisu'}
  15. dictionaries 열거하기 dict = {“name”: “jisu”, “age”:20} >>> for name in dict: ... print(dict[name])
  16. python code. ex) def calculateFactorial(number): if number == 0: return 1 else : result = number * calculateFactorial(number-1) return result def main(): inputVal = input("input number : ") if inputVal: result = calculateFactorial(int(inputVal)) print(result) main()
  17. comment 여러줄 """ getErrorData 메서드는 객체 형태의 에러데이터를 반환한다 @ method getErrorData @ param {void} @ return {Dictionaries} , [count, detailErrorMsg2....] } """ <원래는 triple-quotes는 multiline string 을 변수에 담으려고 사용된 형태임> 한줄 # test 함수입니다 def getErrorData(self): ....
  18. OOP class based, not prototype-based class testClass: def __init__(self,name): self.name = name 정의 def getName(self): return self.name def setReName(self, addText): self.name = self.name + addText elp = testClass("jslounge") 호출 print (elp.getName()); elp.setReName("is forever") print (elp.getName());
  19. modules jslounge.py def print_func(arg): print(arg) 다른 파일에서 jslounge.py에서 정의한 print_func()함수를 사용하고 싶다면?
  20. modules jslounge.py def print_func(arg): print(arg) call.py import jslounge or from jslounge import print_func jslounge.print_func(“4th”) print_func(“4th”)
  21. End ;-D
Advertisement