Not sure how to implement a python class in PyCall

I am trying to use PyCall to reuse a python script which has this code component. I have avoided using python’s oo class system and so I’m not too sure what is going on.

from ib_insync import *

ib = IB()

ib.connect('nnn.nnn.n.nnn', 1234, clientId=12)

I would like to expose the class IB as ib as in the code segment as in

ib = IB()

I have read through Pycall docs " defining python classes" but I’m just winging it here.

Defining Python Classes
using PyCall
tk = pyimport("Tkinter")

@pydef mutable struct SampleApp <: tk.Tk

so would the following julia code achieve the same thing?

IB  = pyimport("ib_insync")

@pydef mutable struct ib  <: IB()

ib.connect('nnn.nnn.n.nnn', 1234, clientId=12

This doesn’t involve defining a new Python class at all, so you could replicate it in PyCall simply with:

ib_insync = pyimport("ib_insync")
ib = ib_insync.IB()
ib.connect("nnn.nnn.n.nnn", 1234, clientId=12)

Are you confusing defining a new class with instantiating an existing class?

hi @stevengj
thank you for taking the time. I had a slight issue initially because I didn’t spot the change from single to double quotes. I “think” it’s working now.

I wish you and yours a VERY happy new year.