Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with prefix-in Requires #3

Open
abhillman opened this issue Nov 11, 2023 · 1 comment
Open

Issues with prefix-in Requires #3

abhillman opened this issue Nov 11, 2023 · 1 comment

Comments

@abhillman
Copy link

Observed:

If pyffi is qualified via (require (prefix-in pyffi/ pyffi)), attributes cannot be read off of bound python objects via dot . syntax.

Expected:
Not sure. Maybe "just works" or some kind of mention of this in the documentation ideally with a workaround.

Repro:

Save this in py-point-qualified.rkt:

#lang racket

;; load `pyffi` qualified as `pyffi/`
(require (prefix-in pyffi/ pyffi))

;; initialize the python interpreter
(pyffi/initialize)
(pyffi/post-initialize)

;; define `Point` via `collections.namedtuple`
(pyffi/import collections)
(pyffi/run* "Point = collections.namedtuple('Point', 'x y')")

;; create a `Point` object and bind it
(define py-point (pyffi/run "Point(1, 2)"))

(print py-point.x)

Then run it:

$ racket py-point-qualified.rkt
py-point-qualified.rkt:20:7: py-point.x: unbound identifier
  in: py-point.x
  location...:
   py-point-qualified.rkt:20:7

Extra info:

This is not an issue if prefix-in is not used:

$ cat py-point-qualified.rkt
#lang racket

;; require pyffi
(require pyffi)

;; initialize the python interpreter
(initialize)
(post-initialize)

;; define `Point` via `collections.namedtuple`
(import collections)
(run* "Point = collections.namedtuple('Point', 'x y')")

;; create a `Point` object and bind it
(define py-point (run "Point(1, 2)"))

;; expose py-point
(provide py-point)

(print py-point.x)

$ racket py-point-qualified.rkt
1
@abhillman
Copy link
Author

Workaround #2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant