PyCall question

It seems that PyCall does not support class methods? e.g.

julia> using PyCall

julia> @pyimport datetime

julia> datetime.date(2018,1,1)
2018-01-01

julia> datetime.date.today()
ERROR: type PyObject has no field today

Ref: 8.1. datetime — Basic date and time types — Python 3.6.15 documentation

From the README:

Important: The biggest difference from Python is that object attributes/members are accessed with o[:attribute] rather than o.attribute, so that o.method(...) in Python is replaced by o[:method](...) in Julia.

Try datetime.date[:today]() and see if that works.

1 Like

If PyCall overloads getfield in v0.7, that would really cool since pieces of code and tutorials can then be copied over from Python to Julia with few changes.

It will.

6 Likes