Skip to content

Proposal: from where import name as custom-name #1

@qzivli

Description

@qzivli

https://github.com/guenchi/fli/blob/bee3468b366665067cc947609450208d4a42f0e2/pycall.sc#L87-L90

I tested, it woks. This is example code:

(define-syntax py:from
  (syntax-rules (import as)
    [(_ where import name)
     (py:run-simple-string (format "from ~a import ~a" where name))]
    [(_ where import name as custom-name)
     (py:run-simple-string (format "from ~a import ~a as ~a" where name custom-name))]))

(py:from "requests" import "get" as "GET")
(py:run-simple-string "print(type(GET))")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions