Skip to content

yichangwang/ensai_intro_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concepts from class

Read doc / Search from Internet

Built-in data structure

int / float

string

  • format method

list / tuple

  • methods: insert, append, sort, etc.
  • list comprehension
  • mutable / immutable object

dictionary

set

boolean type / None type

Function

  • built-in functions (range, print, sort, etc.)
  • create / execute a function
  • parameter / argument
    • positional argument
    • argument with default value
    • key word argument
  • lambda function

Module

  • __name__ == '__main__'

Class

attribute

  • class variable
  • instance method

call

instance = MyClass()  # there's the __eq__ method in MyClass
another_instance = MyClass()
# call
MyClass.__eq__(instance, another_instance)
instance.__eq__(another_instance)
instance == another_instance  # overload the == operator with __eq__ method

inheritance(simple and multiple), overload, polymorphism

  • magic method (__init__, __str__, __eq__, __add__, etc.)

method (instance), class method, statistic method

Good to know

  • use debugger

  • sys.argv[]

  • closure

  • copy, deepcopy

  • id(), dir(), help()

  • To check the if two objects is the same

    a = 3
    b = a
    a is b  # True
    
    a = {"one": 1, "two": 2, "three": 3}
    b = dict(one=1, two=2, three=3)
    a == b  # True
    a is b  # False
  • venv or virtualenv

  • use pylint (with graphviz) to generate uml graph

TODO: add unittest for tp6

About

corrections for exercises of <oop with python> in ensai

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages