{"action":"created","issue":{"url":"https://api.github.com/repos/brython-dev/brython/issues/766","repository_url":"https://api.github.com/repos/brython-dev/brython","labels_url":"https://api.github.com/repos/brython-dev/brython/issues/766/labels{/name}","comments_url":"https://api.github.com/repos/brython-dev/brython/issues/766/comments","events_url":"https://api.github.com/repos/brython-dev/brython/issues/766/events","html_url":"https://github.com/brython-dev/brython/issues/766","id":290177666,"number":766,"title":"library support request: attrs","user":{"login":"glyph","id":716529,"avatar_url":"https://avatars3.githubusercontent.com/u/716529?v=4","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"PierreQuentel","id":3447215,"avatar_url":"https://avatars1.githubusercontent.com/u/3447215?v=4","gravatar_id":"","url":"https://api.github.com/users/PierreQuentel","html_url":"https://github.com/PierreQuentel","followers_url":"https://api.github.com/users/PierreQuentel/followers","following_url":"https://api.github.com/users/PierreQuentel/following{/other_user}","gists_url":"https://api.github.com/users/PierreQuentel/gists{/gist_id}","starred_url":"https://api.github.com/users/PierreQuentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PierreQuentel/subscriptions","organizations_url":"https://api.github.com/users/PierreQuentel/orgs","repos_url":"https://api.github.com/users/PierreQuentel/repos","events_url":"https://api.github.com/users/PierreQuentel/events{/privacy}","received_events_url":"https://api.github.com/users/PierreQuentel/received_events","type":"User","site_admin":false},"assignees":[{"login":"PierreQuentel","id":3447215,"avatar_url":"https://avatars1.githubusercontent.com/u/3447215?v=4","gravatar_id":"","url":"https://api.github.com/users/PierreQuentel","html_url":"https://github.com/PierreQuentel","followers_url":"https://api.github.com/users/PierreQuentel/followers","following_url":"https://api.github.com/users/PierreQuentel/following{/other_user}","gists_url":"https://api.github.com/users/PierreQuentel/gists{/gist_id}","starred_url":"https://api.github.com/users/PierreQuentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PierreQuentel/subscriptions","organizations_url":"https://api.github.com/users/PierreQuentel/orgs","repos_url":"https://api.github.com/users/PierreQuentel/repos","events_url":"https://api.github.com/users/PierreQuentel/events{/privacy}","received_events_url":"https://api.github.com/users/PierreQuentel/received_events","type":"User","site_admin":false}],"milestone":null,"comments":7,"created_at":"2018-01-20T09:05:48Z","updated_at":"2018-04-09T07:32:03Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"One of the major reasons that I want to eventually have a python-in-the-browser option is so that I can easily share complex data structures between the frontend and the backend.\r\n\r\nProblem: I currently define all my complex data structures with https://github.com/python-attrs/attrs, and brython cannot import this code :).\r\n\r\nI think this is a great library to try to get Brython to run unmodified, because it is doing lots of standard Python and platform detection at startup time, and using various standard library modules; yet, it does no I/O, requires no other libraries; it's purely for defining data structures, so it should work just as well in Brython as in CPython.\r\n\r\nJust a few things I hit while trying to import it:\r\n\r\n- `functools.partial()`\r\n- `sys.version_info`\r\n- `platform.python_implementation()`\r\n\r\nNone of these things seem hard to implement individually but there are probably a dozen of them before it will import.\r\n\r\nThanks again for brython!"},"comment":{"url":"https://api.github.com/repos/brython-dev/brython/issues/comments/379660974","html_url":"https://github.com/brython-dev/brython/issues/766#issuecomment-379660974","issue_url":"https://api.github.com/repos/brython-dev/brython/issues/766","id":379660974,"user":{"login":"PierreQuentel","id":3447215,"avatar_url":"https://avatars1.githubusercontent.com/u/3447215?v=4","gravatar_id":"","url":"https://api.github.com/users/PierreQuentel","html_url":"https://github.com/PierreQuentel","followers_url":"https://api.github.com/users/PierreQuentel/followers","following_url":"https://api.github.com/users/PierreQuentel/following{/other_user}","gists_url":"https://api.github.com/users/PierreQuentel/gists{/gist_id}","starred_url":"https://api.github.com/users/PierreQuentel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PierreQuentel/subscriptions","organizations_url":"https://api.github.com/users/PierreQuentel/orgs","repos_url":"https://api.github.com/users/PierreQuentel/repos","events_url":"https://api.github.com/users/PierreQuentel/events{/privacy}","received_events_url":"https://api.github.com/users/PierreQuentel/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T07:32:03Z","updated_at":"2018-04-09T07:32:03Z","author_association":"CONTRIBUTOR","body":"Here is an example of HTML file that works for me : \r\n\r\n```xml\r\n<html>\r\n\r\n<head>\r\n<meta charset=\"utf-8\">\r\n<script src=\"brython.js\"></script>\r\n<script src=\"brython_stdlib.js\"></script>\r\n</head>\r\n\r\n<body onload=\"brython(1)\">\r\n<script type=\"text/python\">\r\nimport attr\r\n\r\n@attr.s\r\nclass SomeClass(object):\r\n    a_number = attr.ib(default=42)\r\n    list_of_numbers = attr.ib(default=attr.Factory(list))\r\n\r\n    def hard_math(self, another_number):\r\n        return self.a_number + sum(self.list_of_numbers) * another_number\r\n\r\n\r\nsc = SomeClass(1, [1, 2, 3])\r\nprint(SomeClass(a_number=1, list_of_numbers=[1, 2, 3]))\r\n\r\nassert sc.hard_math(3) == 19\r\nassert sc == SomeClass(1, [1, 2, 3])\r\nassert sc != SomeClass(2, [3, 2, 1])\r\n</script>\r\n\r\n</body>\r\n\r\n</html>\r\n```\r\nIt's possible that you didn't include __brython_stdlib.js__ in your script (if I remove it I also have an error message related to a missing `__future__` module)"}}
{"actor":{"display_login":"PierreQuentel"}}