python-object Questions

7

Solved

I am absolutely new to Python (I came from Java) and I have the following doubts about class fields. Considering code like this: class Toy(): def __init__(self, color, age): self.color = color s...
Eme asked 14/12, 2019 at 16:29

3

Solved

I have written a simple example to illustrate what exactly I'm banging my head onto. Probably there is some very simple explanaition that I just miss. import time import multiprocessing as mp impor...

3

Solved

Please consider the below code class DataMember(): def __init__(self, **args): self.default = {"required" : False , "type" : "string" , "length": -1} self.default.update(args) def __call__(sel...

1

Solved

Why can't you override a class name declaratively, e.g. to use a class name which is not a valid identifier? >>> class Potato: ... __name__ = 'not Potato' ... >>> Potato.__name_...

1

Solved

I am trying to print a list of python objects that contain a list as a property and i am having some unexpected results: here is my code: class video(object): name = '' url = '' class topic(o...
Interesting asked 19/7, 2016 at 3:3

2

Solved

When I try to override the magic method __eq__, and use super to access the base method found in object, I get an error. There's no way this is a bug, but it sure feels like one: class A(object): ...
Hostage asked 23/5, 2016 at 1:11
1

© 2022 - 2024 — McMap. All rights reserved.