From 20274f7b8a9be6cdb03ffc4d0a6a0fa21a4875d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 30 Sep 2020 07:50:44 +0200 Subject: [PATCH] FAQ --- web/faq.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/faq.html b/web/faq.html index 330bea0..7b0374a 100644 --- a/web/faq.html +++ b/web/faq.html @@ -24,8 +24,8 @@
What exactly is <collection>?
    Collection is my name for an iterable object. An iterable object in Python is any object that has at least one of iter() and getitem() special methods defined. By convention, <object>.__iter__() should return an iterator of object's items and <object>.__getitem__(<index>) an item at that index. I chose not to use the name iterable because it sounds scarier and more vague than collection, even though it has a precise definition.

-    To make matters a bit more confusing, an abstract base class called Iterable doesn't fully follow this definition. An expression isinstance(<object>, collections.abc.Iterable) only checks whether an object has iter() special method, disregarding the getitem().

-    Although collection has no definition in Python's glossary, there exists a Collection abstract base class. Expression isinstance(<object>, collections.abc.Collection) returns 'True' for any object that has len() and at least one of iter() and getitem() special methods defined. By convention, <object>.__len__() should return the number of object's elements. +    To make matters a bit more confusing, an abstract base class called Iterable doesn't fully follow this definition. An expression instanceof(<object>, collections.abc.Iterable) only checks whether an object has iter() special method, disregarding the getitem().

+    Although collection has no definition in Python's glossary, there exists a Collection abstract base class. Expression instanceof(<object>, collections.abc.Collection) returns 'True' for any object that has len(), iter() and contains() special methods defined. <object>.__len__() should return the number of elements and <object>.__contains__(<el>) should check if object contains the passed element.

What about PEP 8?