Question: I'm making a simulation of the solar system, and am using object oriented programming to make it easier to add new planets.

```
from vpython import *

#gravitational constant
G = 6.674e-11
#seconds in a day
dt = 86400

step = 1
maxstep = 3000

class Planet:

    def __init__(self, mass, radius, position, velocity):
        self.mass = mass
        self.radius = radius
        self.position = position
        self.velocity = velocity

class Star:

    def __init__(self, mass, radius):
        self.mass = mass
        self.radius = radius

Earth = Planet(5.972e24, 6371, vector(0,1.47e8,0), vector(-29.951,0,0))
Mercury = Planet(3.285e23, 2439.7, vector(0,4.6e7,0), vector(-47.400,0,0))
Sun = Star(1.989e30, 696340)

#acceleration vectors
a_Earth = -G*Sun.mass*Earth.position/mag(Earth.position)**3
a_Mercury = -G*Sun.mass*Mercury.position/mag(Mercury.position)**3

#position vectors
Earth.position = Earth.position + Earth.velocity*dt + 0.5*a_Earth*dt**2

```

What I'm trying to do is to use VPython's sphere command to represent the planets and star, is there a way to use it in the class when defining new ones?

Answer: 
Your method `split_scale_data` returns the following

```
return self.X_train, self.X_test

```

but it should return the local variables from that method

```
return X_train, X_test

```

By the way you can also modify your `__init__` method to use this method as

```
self.X_train, self.X_test = self.split_scale_data(X,y)

```
You are returning attributes which are not defined 

```
return self.X_train, self.X_test

```

and here the error. You should change it to

```
return X_train, X_test

```

However, for your use case it might be worth to use a [classmethod](https://docs.python.org/3/library/functions.html#classmethod) and keep the `__init__` simple.

```
class Model:
    def __init__(self, X, y, X_train, X_test):
        self.X = X
        self.y = y
        self.X_train = X_train
        self.X_test = X_test

    @classmethod
    def from_data(cls, X, y):
       ...
       return cls(X, y, X_train, X_test)

```