Skip to content

Tag: python-3.x

Using eval in the middle of a python statement

I want to use eval in the middle of the following python statement: but because it does not return any value (it works in an “in place” manner), I cannot actually use it there and instead I receive an error of TypeError: can only concatenate list (not “NoneType”) to list . Is there any…

How can show the singleton object’s attribution?

We can show instance’s attribution with dir function. Now create a class with metaclass method: Show Cls’s _instances attrubution: Why no string _instances in dir(Cls)? Answer Because it’s stored on the metaclass. To be clear, this has nothing to do with the singleton aspect.

How to write a django orm-like module?

I am trying to write a orm package which source data is json, First I created a Department class (I am trying to mimic django model) Then I created Organization class as a search manager. My expected result is: But I have no idea how to achieve it, can anybody help me? Answer If you want to access the parent