I am new to Python, and have been reading some API examples of python scientific libraries.
in one library, scikit-learn, the code examples always call the constructor once without arguments, and then later again with all the arguments.
Here is an example (see the last line, and the third before last line (clf = linear_....), taken from the documentation of sklearn.linear_model.SGDRegressor:
>>> import numpy as np
>>> from sklearn import linear_model
>>> n_samples, n_features = 10, 5
>>> np.random.seed(0)
>>> y = np.random.randn(n_samples)
>>> X = np.random.randn(n_samples, n_features)
>>> clf = linear_model.SGDRegressor()
>>> clf.fit(X, y)
...
SGDRegressor(alpha=0.0001, average=False, epsilon=0.1, eta0=0.01,
fit_intercept=True, l1_ratio=0.15, learning_rate='invscaling',
loss='squared_loss', n_iter=5, penalty='l2', power_t=0.25,
random_state=None, shuffle=True, verbose=0, warm_start=False)
I think I might misunderstand something about Python, because I don't see why the constructor is called twice? Is there a reason for this, or is it just a weird way to show all the possible parameters of the constructor?
__repr__of the constructed instance ? The line isn't prefixed by>>>.