{"action":"created","issue":{"url":"https://api.github.com/repos/brython-dev/brython/issues/115","labels_url":"https://api.github.com/repos/brython-dev/brython/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/brython-dev/brython/issues/115/comments","events_url":"https://api.github.com/repos/brython-dev/brython/issues/115/events","html_url":"https://github.com/brython-dev/brython/issues/115","id":55408346,"number":115,"title":"Adding properties to basic types","user":{"login":"kikocorreoso","id":1939575,"avatar_url":"https://avatars.githubusercontent.com/u/1939575?v=3","gravatar_id":"","url":"https://api.github.com/users/kikocorreoso","html_url":"https://github.com/kikocorreoso","followers_url":"https://api.github.com/users/kikocorreoso/followers","following_url":"https://api.github.com/users/kikocorreoso/following{/other_user}","gists_url":"https://api.github.com/users/kikocorreoso/gists{/gist_id}","starred_url":"https://api.github.com/users/kikocorreoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kikocorreoso/subscriptions","organizations_url":"https://api.github.com/users/kikocorreoso/orgs","repos_url":"https://api.github.com/users/kikocorreoso/repos","events_url":"https://api.github.com/users/kikocorreoso/events{/privacy}","received_events_url":"https://api.github.com/users/kikocorreoso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-25T10:07:28Z","updated_at":"2015-01-26T18:08:56Z","closed_at":null,"body":"Is there a canonical way to add a property to a python type implemented in js?\r\n\r\nFor instance, yesterday I was trying to add some (Python) properties to number classes (*py_float.js, py_int.js, py_complex.js*) using the [builtin `property`](https://github.com/brython-dev/brython/blob/master/src/py_builtin_functions.js#L1139) and the following code wasn't working:\r\n\r\n```javascript\r\n$IntDict.numerator = property(function(self){return self})\r\n$IntDict.denominator = property(function(){return 1})\r\n```\r\n\r\nWhen I try to use the properties:\r\n```python\r\na = 2\r\nprint(a.numerator)\r\n```\r\n I get:\r\n```\r\n<property object>\r\n```\r\nInstead of the expected value `2`.\r\n\r\nI also tried to use js builtin way to define properties:\r\n\r\n```javascript\r\nObject.defineProperty($IntDict, \"numerator\", {\r\n    get: function(self) {return self},\r\n    set: undefined\r\n});\r\n```\r\n\r\nAnd the result was something like `int doesn't have attribute 'numerator'`."},"comment":{"url":"https://api.github.com/repos/brython-dev/brython/issues/comments/71507493","html_url":"https://github.com/brython-dev/brython/issues/115#issuecomment-71507493","issue_url":"https://api.github.com/repos/brython-dev/brython/issues/115","id":71507493,"user":{"login":"kikocorreoso","id":1939575,"avatar_url":"https://avatars.githubusercontent.com/u/1939575?v=3","gravatar_id":"","url":"https://api.github.com/users/kikocorreoso","html_url":"https://github.com/kikocorreoso","followers_url":"https://api.github.com/users/kikocorreoso/followers","following_url":"https://api.github.com/users/kikocorreoso/following{/other_user}","gists_url":"https://api.github.com/users/kikocorreoso/gists{/gist_id}","starred_url":"https://api.github.com/users/kikocorreoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kikocorreoso/subscriptions","organizations_url":"https://api.github.com/users/kikocorreoso/orgs","repos_url":"https://api.github.com/users/kikocorreoso/repos","events_url":"https://api.github.com/users/kikocorreoso/events{/privacy}","received_events_url":"https://api.github.com/users/kikocorreoso/received_events","type":"User","site_admin":false},"created_at":"2015-01-26T18:08:56Z","updated_at":"2015-01-26T18:08:56Z","body":"Thanks @PierreQuentel \r\n\r\nI will test that to see possible drawbacks and the convenience to remove the `$native = true` attribute."}}