ব্যবহারকারী-সংজ্ঞায়িত বেস ক্লাসগুলি একটি ইন্টারফেস অনুকরণ করে একটি পদ্ধতি বা আচরণকে একটি সাবক্লাস দ্বারা সংজ্ঞায়িত করতে হবে তা নির্দেশ করতে NotImplementedError বাড়াতে পারে৷ এই ব্যতিক্রম RuntimeError থেকে প্রাপ্ত। ব্যবহারকারীর সংজ্ঞায়িত বেস ক্লাসে, বিমূর্ত পদ্ধতির এই ব্যতিক্রমটি উত্থাপন করা উচিত যখন তারা পদ্ধতিটিকে ওভাররাইড করার জন্য প্রাপ্ত ক্লাসের প্রয়োজন হয়।
উদাহরণ
import sys
try:
class Super(object):
@property
def example(self):
raise NotImplementedError("Subclasses should implement this!")
s = Super()
print s.example
except Exception as e:
print e
print sys.exc_type আউটপুট
Subclasses should implement this! <type 'exceptions.NotImplementedError'>