Is there a way to define list(obj) method on a user defined class in python? -


one can can implement method __str__(self) return string. there __list__(self) counterpart? (__list__ doesn't work!) .tolist() way go?

there no direct counterpart, list() implemented iterating on argument. implement either the iterator protocol (__iter__()) or bound indexing (__len__() , __getitem__()).


Comments

Popular posts from this blog

java - JavaScript + Thymeleaf - select onchange -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

node.js - Using Node without global install -