Python ABC not working properly in Python 2.7.6?

null

Why can I do this?

from abc import ABCMeta, abstractmethod

class AbstractClass(object):

    _metaclass__ = ABCMeta

    @abstractmethod
    def foo():
        pass


    @abstractmethod
    def bar():
        pass

class ConcreteClass(AbstractClass):
    pass


a = AbstractClass()
nb = ConcreteClass()

There is no error. Everything runs perfectly. Why can I instantiate an abtract class and why can I instantiate an object of ConcreteClass though it did not implement abstract methods?

Padraic Cunningham

You are missing a _

__metaclass__ = ABCMeta

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

CAGradientLayer is not working on iOS 7 (But working on iOS 6)

분류에서Dev

Arrays not sorting properly in python

분류에서Dev

tcl/tk on mac os, Python IDLE won't start and Macports not working properly

분류에서Dev

Python Pyler code not working

분류에서Dev

업데이트 선택 = (choice % 6) + 1 from python 2 to python 3

분류에서Dev

업데이트 선택 = (choice % 6) + 1 from python 2 to python 3

분류에서Dev

How to properly generate summarizing text files in Python

분류에서Dev

collections.abc.Callable은 Python 3.9.1에서 버그가 있습니까?

분류에서Dev

Python- 개체 목록 <class 'xyz.models.abc'>에 집합 사용

분류에서Dev

Fn key not properly working

분류에서Dev

debounce (AfterValueChanged) Not working properly

분류에서Dev

Array Enumeration Not Working Properly?

분류에서Dev

listview setItemChecked not working properly

분류에서Dev

Rspec is not working properly with mongodb

분류에서Dev

Simple slideshow not working properly

분류에서Dev

Navigation Properties are not working properly

분류에서Dev

Fitviewport not working properly

분류에서Dev

For loop is not working properly in nodejs

분류에서Dev

Back Key not working properly

분류에서Dev

ps command not working properly?

분류에서Dev

Matlab loop not working properly

분류에서Dev

Sed into Variable not working properly

분류에서Dev

python list, working with multiple elements

분류에서Dev

pyplot not working in python 3.3 windows

분류에서Dev

/ operand not working as expected in python 3

분류에서Dev

Python sort/ reverse with argparse not working

분류에서Dev

Pip and distribute not working on Python 3.3

분류에서Dev

Python: Why isn't this working?

분류에서Dev

Python : 다른 ABC로부터 상속하는 ABC를 만드는 방법은 무엇입니까?

Related 관련 기사

뜨겁다태그

보관