Access all PythonObjects attributes

Skip to first unread message

Filipe Duarte

Jan 22, 2021, 1:35:23 PMJan 22
to Swift for TensorFlow
Hi, I have been using Python for machine learning research for time series data. I feel that I need to take another step to learn another and more performant programming language. In this sense, I found Julia and Swift for Tensorflow, which both seem to have a good foundation and promises to be an alternative for Python. 

I started to learn Swift's interoperability with Python on Google Colab notebooks, using NumPy and Scikit-learn. The problem is that I didn't find how to access all the PythonObjects attributes. For example, assuming that I fit a LinearRegression on some randomly NumPy array:

var reg = lm.LinearRegression(), Y)
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None, normalize=False)

I would like to access the `reg`'s attributes but did not find how to do this.

Nicholas Gustafson

Jan 22, 2021, 3:34:22 PMJan 22
to Swift for TensorFlow,

When you say you would like to access the `reg's attributes, what do you mean exactly? In python you access an objects attributes using the dotted-syntax, which you employed in your linear regression example. If you would like a list of all a python object's attributes you can use python's built in dir function. Try:


I hope that helps!

Filipe Duarte

Jan 22, 2021, 5:45:35 PMJan 22
to Swift for TensorFlow,, Filipe Duarte
Reply all
Reply to author
0 new messages