How for example would I convert a type from some external class to another one? I’ve searched around, and gotten stuff like “int to string” and stuff, but I’m talking about something like class “tile” converting to something else, such as “tile2”.
Share
As Daniel mentioned in his answer, casting is not necessary in Python because of the way code for Python is (should be) usually written. The thing you may need however, is converting between non-standard types.
Converting should be probably supported within
__init__method within the class you want it to cast to, if you want to do it the way converting works for eg.int,str,listetc.:and then (after adjusting
__init__to your needs) you should be able to cast it like that:More comprehensive example for converting between types:
Does it answer your question?