GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Multiple class definitions in the same file raise error "invalid syntax" · Issue #257 · go-python/gpython

Multiple class definitions in the same file raise error "invalid syntax" #257

New issue
Copy link
New issue
Copy link
Open
#258
Open
Multiple class definitions in the same file raise error "invalid syntax"#257
#258
Copy link

Description

@SolarLune
SolarLune
opened on Jul 2, 2026
Issue body actions

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.DefaultContextOpts())

data, _ := fs.ReadFile(g.FS, "math_stuff.py")

_, err := py.RunSrc(context, string(data), "run", nil)

log.Println(err)

math_stuff.py

class A:
    pass


class B:
    pass

Gives me the error:

2026/07/02 15:06:16
  File "run", line 5, offset 5
    class B:


SyntaxError: 'invalid syntax'

I'm testing with the latest commit.

Activity

  1. ncw commented on Jul 3, 2026

    @ncw
    ncw
    on Jul 3, 2026
    Collaborator
    More actions

    I made an attempt at a fix for this on the fix-257-RunSrc branch - can you test it out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.