• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

내부 class에 대한 질문 입니다.

22.03.17 22:50 작성 조회수 136

0

안녕하세요 강사님.

세가지 질문 있습니다.

1. class를 만들때, class명을 대문자로 쓰잖아요.

   예)   class Car , class Persion

   근데 왜 내장 클래스들 str 은 class 인데 이름이 소문자 인가요?

   class str 로 되어 있던데

 

2.

   s = str()

print(s)

위 소스에서 

 str()에 포커스를 가져다 놓으면 아래 처럼 나옵니다.

class str 이라고요.

==나오는 내용==

builtins class str(Sequence[str])

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

 

근데 정작 파이참에서 ctrl+click 하면

정의 부분인  class str의 __init__(self) 로 가지 않고

buitins.py 로 가는 이유는 먼가요?

읽어 주셔서 감사합니다.

답변 1

답변을 작성해보세요.

0

내부적으로 cpython 실행전에 빌트인에서 오버라이딩으로 실행되게 

됩니다.

좀 더 로우레벨로 문서를 확인하려면 공식문서를 읽어보세요~