Ask coding questions

← Back to all posts
python classes and functions question
isaiah08

if i have this code:

i can't run it like this:

how can i change my function and classes so that i can run it like that? Thanks!

Voters
isaiah08
Comments
hotnewtop
RYANTADIPARTHI

maybe, try initializing both classes, and using the names to get the function.

isaiah08

can you give an example? @RYANTADIPARTHI

RYANTADIPARTHI

@isaiah08 this.

maybe like that.

isaiah08

Nevermind, i decided to have the structure like:

RYANTADIPARTHI

@isaiah08 that is the original way. But i thought you wanted it your way. So all set?

Coder100
Coder100

you can't.

You can either do it like step one or step 2.

Also, make sure your classes are named with proper practices. One not one and Two not two.

https://repl.it/@Coder100/TragicShortStatistics-shut-up-smh#main.py

Why is this you ask? The reason is that python has static methods (which is the first version), and there are instance methods, which require you to make an instance, which means calling the function.

isaiah08

I realized i wasn't describing what i wanted correctly in the post. I updated it. Can you look again? Thanks! @Coder100

Coder100

yeah, two is still a class but it won't become an instance to one @isaiah08