cdgriffith / cdgriffith/Box

I can create a method in a box that overwrite a key

Open
#222 2 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
2.8k
Forks
135
PR merge metrics
No merged PRs in 30d

Description

I was playing with the lib by subclassing it and I founds some funny behaviour. I know it's not the intended usage but though that was worth reporting. Feel free to close it if you think it's useless:

```python
class toto(Box):

def __init__(self, valeur):

super().__init__({"valeur": [valeur, valeur], "print": "toto"})

def print(self):
print(self.valeur)
return

toto("truc").print
>>>>
```

I didn't know what to expect but it's the method that have priority over the key.

but the key still exist

```python
toto("truc")["print"]
>>>>'toto'
```

I think it would be handy to at least raise a warning ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.