#๐ Is that right? If not, where is my erros?
46 messages ยท Page 1 of 1 (latest)
@sonic ice
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
syntax most likely
so with python you use indents and colons to define a scope
this would be done when making a function or a class
class Foo:
def __init__(self, name):
self.name = name
class Too(Foo):
def __init__(self, thing):
super.()__init__(Fooo)
self.thing = thing
print(name, thing)
seems like some other stuff is wrongf
still missing :
mb
also name and thing isnt defined in the global scope
yes it is, it's a parameter of the method
I mean for when they try to print it
if you want to call it directly you could call it form the class
class Foo:
def __init__(self, name):
self.name = name
class Too(Foo):
def __init__(self, thing):
super().__init__(Fooo)
self.thing = thing
print(Foo.name, Too.thing)
ur right
make sure to pass in an argument
but you also cant just call it directly since you never gave a direct value for them either
^^
that and a typo on line 7. it should be Foo not Fooo
it doesn't need that at all
super().__init__()
no need to pass in the class name
so if I understand your goal correctly it should be
class Foo:
def __init__(self, name):
self.name = name
class Too(Foo):
def __init__(self, thing):
super().__init__(Foo)
self.thing = thing
print(Foo("Bar").name, Too("Par").thing)
that returns a error
you would need to pass it a name
so Too class should either be passing in a default value or the init should be asking for name and thing
class Foo:
def__init__(self, name)
self.name = name
class Too(Foo):
def__init__(self, thing)
super().__init__(Fooo)
self.thing = thing
print(name, thing)```
what about now
1st. use tab buttons for indents
if you want to indent once, only hit tab once
example:
def foo():
print("bar")
class Foo:
def __init__(self, name):
self.name = name
class Too(Foo):
def __init__(self, thing):
super().__init__(Foo)
self.thing = thing
print(name="The", thing="Rock")
almost. when working with a function you want to assign the variable inside by using ()
so it would be name("the")
id reccomend looking at beginner python guides to fully understand the syntax and then moving on to OOP
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.