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:629f8737-b8aa-4fdb-586b-a7f5601c04b1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C95C:21BB93:751C4F:A52DC6:6A6247A1 |
| html-safe-nonce | 687a487336d62d36cbd8bba6bb89353cc816b648818ddae46c5cdf1826a1b36e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTVDOjIxQkI5Mzo3NTFDNEY6QTUyREM2OjZBNjI0N0ExIiwidmlzaXRvcl9pZCI6IjYyODQzMjMwODMzMDgzODYyMDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6b9283d0933ea8e45b10129a190f137fdf5b4f0791bb705c8fdf4102a6bbfa81 |
| 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 | 5d6ba65d73ecc4e3394fe318d2b2f98e6f8eed4878b5421b938e20d30bde267b |
| 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 | 2dadc56fd5989b76a8ae7304e3aa56d0b485e5dc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width