オブジェクト向け<1>


# !/usr/bin/env python
# -*- coding: utf-8 -*-
class Document():
    def __init__(self, title, author, context):
        print('init function called')
        self.title = title
        self.author = author
        self.__context = context # __          

    def get_context_length(self):
        return len(self.__context)

    def intercept_context(self, length):
        self.__context = self.__context[:length]

print type(Document)
harry_potter_book = Document('Harry Potter', 'J. K. Rowling', '... Forever Do not believe any thing is capable of thinking independently ...')
print type(harry_potter_book)

C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled2/socket/t21.py

init function called


Process finished with exit code 0

class Document     Document  ,            ,        Document       。


  :        ,      class        object,

       harry_potter_book。