__init__() is a dunder. It starts and ends with __, a double underbar, aka: dunder. Change _init_ to __init__.
Code:
class student:
def __init__(self, name, age):
self.name = name
self.age = age
def display(self):
return ("this is a " + self.name + str(self.age))
stu = student("chad", 14)
print(stu.display())
Results:
this is a chad14
Answer from Stephen Rauch on Stack Overflow Top answer 1 of 3
1
__init__() is a dunder. It starts and ends with __, a double underbar, aka: dunder. Change _init_ to __init__.
Code:
class student:
def __init__(self, name, age):
self.name = name
self.age = age
def display(self):
return ("this is a " + self.name + str(self.age))
stu = student("chad", 14)
print(stu.display())
Results:
this is a chad14
2 of 3
1
Try this:
class student:
def __init__(self,name,age):
self.name = name
self.age = age
def display(self):
stu=student("chad",14)
print("this is a "+(stu.name)+str(stu.age))
s = student(None,None)
s.display()
Python
bugs.python.org › issue42565
Issue 42565: Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'python' is not defined - Python tracker
December 4, 2020 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/86731
python - How Do I get rid of this error:Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program? - Stack Overflow
I keep trying to start my python backend with uvicorn main:app --reload but I keep getting this error: INFO: Will watch for changes in these directories: ['C:\\Users\\darkg\\OneDrive\\Desktop\\ More on stackoverflow.com
python - why 'Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named django' when im trying to install django? - Stack Overflow
So I was trying to install django. I have used pip3 install django, and this what happened: Then i tried to look if my django was having no problem by typing import django on python. But this what More on stackoverflow.com
Just downloaded python 3.10 and no matter what I type I keep getting this error
When you see >>> you're already in the Python interpreter, so the commands you enter have to be statements in the Python programming language. More on reddit.com
File "<stdin>", line 1, in <module> NameError: name 'hello' is not defined
Leah Tibbets is having issues with: This is my code: first_name More on teamtreehouse.com
Reddit
reddit.com › r/learnpython › just downloaded python 3.10 and no matter what i type i keep getting this error
r/learnpython on Reddit: Just downloaded python 3.10 and no matter what I type I keep getting this error
April 25, 2022 -
Using pycharm, but told have to go through the python terminal first to instal packages, then stuck here.
Using windows 10, went to start and typed in python 3.10 app, then type in anything and this happens:
>>> python Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'python' is not defined >>> pip Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'pip' is not defined. Did you mean: 'zip'? >>> asdfsda Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'asdfsda' is not defined
don't know how to read traceback, and the python file location doesn't have any file called stdin or module?
Edit: thanks for all the responses!
Top answer 1 of 5
138
When you see >>> you're already in the Python interpreter, so the commands you enter have to be statements in the Python programming language.
2 of 5
28
Because the ‘>>>’ is there, it means you’re already in the python interpreter, which essentially means you can write python code in your terminal now. If you type ‘quit()’, it’ll return you to the regular terminal. If you just want to install packages, open up the regular terminal and type in ‘pip install ’ with the package you need. A good test to make sure you’re downloading the right package is to check the PyPi docs. Hope this helps!
Python documentation
docs.python.org › 3 › tutorial › errors.html
8. Errors and Exceptions — Python 3.14.3 documentation
>>> 10 * (1/0) Traceback (most recent call last): File "<stdin>", line 1, in <module> 10 * (1/0) ~^~ ZeroDivisionError: division by zero >>> 4 + spam*3 Traceback (most recent call last): File "<stdin>", line 1, in <module> 4 + spam*3 ^^^^ NameError: name 'spam' is not defined >>> '2' + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> '2' + 2 ~~~~^~~ TypeError: can only concatenate str (not "int") to str
Top answer 1 of 2
3
I had this problem, and it was a simple solution.
I was already running python (you'll see >>> in the Terminal when python is active), but when you run the command "python hello.py", it is asking to startup python again.
Type in exit() and press enter to exit python. Then type in the complete command "python hello.py". This was it can also find the file you are looking for and should work now.
2 of 2
2
I can replicate this by running $ python hello.py instead of $ python3 hello.py. So, for anyone running into the same error, try running this using python3 instead of a legacy version:
$ python3 hello.py
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
it's giving this error in my code: Traceback (the last most recent call): File "<stdin>", line 22, in <module> ImportE - Raspberry Pi Forums
As a general guess, I'd say one of the modules you are attempting to import has not been correctly installed. ... Sun Sep 25, 2022 6:22 am As a general guess, I'd say one of the modules you are attempting to import has not been correctly installed. @OP: it's probably the one with the import ...
Edureka Community
edureka.co › home › community › categories › python › error traceback most recent call last file ...
Error Traceback most recent call last File stdin line 1 in ImportError cannot import name path | Edureka Community
August 5, 2020 - Tried to run command: from django.urls import path Getting error: Traceback (most recent call last): ... : cannot import name 'path'] Any help??
GitHub
github.com › tensorflow › tensorflow › issues › 9033
Problem anaconda tensorflow Windows : Traceback <most recent call last>: File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'tensorflow' · Issue #9033 · tensorflow/tensorflow
June 4, 2017 - Problem anaconda tensorflow Windows : Traceback <most recent call last>: File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'tensorflow'#9033
Author stephano-ops
GitHub
github.com › stereolabs › zed-python-api › issues › 171
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pyzed/sl.pyx", line 1, in init pyzed.sl ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject · Issue #171 · stereolabs/zed-python-api
March 10, 2021 - Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pyzed/sl.pyx", line 1, in init pyzed.sl ValueError: numpy.ufunc size changed, may indicate binary incompatibility.
Author ergouu
GitHub
github.com › python › cpython › issues › 125380
Syntax error display skips the first line of the traceback · Issue #125380 · python/cpython
October 12, 2024 - Bug report Bug description: Steps to reproduce: c := 3 Expected is: Traceback (most recent call last): File " ", line 1, in c := 3 ^^ SyntaxError: inva...
Author SukramLeinad
SideFX
sidefx.com › forum › topic › 86069
Getting some really weird errors and node breaks in LOPs | Forums | SideFX
Unable to evaluate expression ( Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.561/houdini/python3.7libs\loputils.py", line 576, in getMetersPerUnit stage = inputnode.stage() File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.561/houdini/python3.7libs\hou.py", line 56268, in stage return _hou.LopNode_stage(self, output_index, apply_viewport_overrides, ignore_errors, use_last_cook_context_options, apply_post_layers) RuntimeError (/stage/domelight1/xn__houdiniguidescale_s3a)).I am able to fix that one by deleting the function out of the parameter it is on, but that feels really weird as that should be a piece of SideFX code.