Title: Multiple class definitions in the same file raise error "invalid syntax" · Issue #257 · go-python/gpython · GitHub
Open Graph Title: Multiple class definitions in the same file raise error "invalid syntax" · Issue #257 · go-python/gpython
X Title: Multiple class definitions in the same file raise error "invalid syntax" · Issue #257 · go-python/gpython
Description: Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though. Go: context := py.NewContext(py.DefaultContext...
Open Graph Description: Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though. Go: co...
X Description: Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though...
Opengraph URL: https://github.com/go-python/gpython/issues/257
X: @github
Domain: Github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Multiple class definitions in the same file raise error \"invalid syntax\"","articleBody":"Hey, there. It seems like it's not possible to define multiple classes in a single Python file with `py.RunSrc()`, unless I'm misunderstanding something...? It works with `py.RunFile()`, though.\n\nGo:\n```go\n\ncontext := py.NewContext(py.DefaultContextOpts())\n\ndata, _ := fs.ReadFile(g.FS, \"math_stuff.py\")\n\n_, err := py.RunSrc(context, string(data), \"run\", nil)\n\nlog.Println(err)\n\n```\n\n`math_stuff.py`\n```python\nclass A:\n pass\n\n\nclass B:\n pass\n```\n\nGives me the error:\n\n```\n2026/07/02 15:06:16\n File \"run\", line 5, offset 5\n class B:\n\n\nSyntaxError: 'invalid syntax'\n```\n\nI'm testing with the latest commit.","author":{"url":"https://github.com/SolarLune","@type":"Person","name":"SolarLune"},"datePublished":"2026-07-02T22:07:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/257/gpython/issues/257"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:07eeb80d-a478-5630-bb17-2aed5d7f2e13 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D848:8806E:E94A83:141D793:6A625D1B |
| html-safe-nonce | 5d95a52994f48455062c9ad9a74ebe58eac6668849b90102afa81c2f840cf37b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODQ4Ojg4MDZFOkU5NEE4MzoxNDFENzkzOjZBNjI1RDFCIiwidmlzaXRvcl9pZCI6IjY4NjYwMjMwNDI4Nzc5MDYyMDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d0015dbe53acaac27635b024f64ebb7928b3911f2648b8e2ec97ac15e6317c6b |
| hovercard-subject-tag | issue:4798510780 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/go-python/gpython/257/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55429d1f01b6ab46ba4a183d263d76f97ce3d884e5d08ae74c884d757c9fecf1/go-python/gpython/issues/257 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55429d1f01b6ab46ba4a183d263d76f97ce3d884e5d08ae74c884d757c9fecf1/go-python/gpython/issues/257 |
| og:image:alt | Hey, there. It seems like it's not possible to define multiple classes in a single Python file with py.RunSrc(), unless I'm misunderstanding something...? It works with py.RunFile(), though. Go: co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SolarLune |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6d5cd56dfa7e7ed6718ba879da3c0d884bd8b5fecd3883b5f00dcb66b8b8680f |
| turbo-cache-control | no-preview |
| go-import | github.com/go-python/gpython git https://github.com/go-python/gpython.git |
| octolytics-dimension-user_id | 7604679 |
| octolytics-dimension-user_login | go-python |
| octolytics-dimension-repository_id | 143203535 |
| octolytics-dimension-repository_nwo | go-python/gpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143203535 |
| octolytics-dimension-repository_network_root_nwo | go-python/gpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d28abcf30a4025dfeef7673e1509edbc5d402c97 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width