Python Forum
problem with help(type(self)) in Idle
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with help(type(self)) in Idle
#1
hi
I use idle for Python learning.
in idle i wrote help(type) and then appeared a text that contained somethings as mro(self, / ) or __sizeof__(self, / ) and ... .
what is the meaning of self and / ?
also, there was in the result of the above command :
Quote: __init__(self, /, *args,**kwargs)
Initialize self. see help(type(self) for accurate signature.
then I typed
help(type(self))
in idle, but i got an error as:
Error:
... NameError: name 'self' is not defined.
what is the problem?
thanks for any guidance.
Reply
#2
For the meaning of slash and asterisk in function paremeters, you could read this

self is the name usually given to the implicit object occuring in methods definitions in a class.

I think the meaning of the help message that you got is that in order to get help about the __init__ method of an object, you should read the help of the type of the object. For example with a string

>>> foo = 'some string'
>>> help(foo)
No Python documentation found for 'some string'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

>>> help(type(foo))  # this gives me help about the type of foo which is str, and the help includes details about how to initialize a str instance
...
akbarza likes this post
« We can solve any problem by introducing an extra level of indirection »
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PROBLEM] Removing IDLE from context menu WebSpider 1 479 Sep-28-2023, 03:35 PM
Last Post: deanhystad
  What do i have to type in the IDLE shell to use this password manager program? MaartenRo 4 1,754 Jan-15-2022, 02:01 PM
Last Post: MaartenRo
  Idle and pycharm problem noithatgooccho 1 2,345 Jan-06-2021, 10:49 AM
Last Post: Larz60+
  Idle and pycharm problem gr3yali3n 3 2,346 Sep-05-2020, 03:28 AM
Last Post: gr3yali3n
  Type hinting - return type based on parameter micseydel 2 2,504 Jan-14-2020, 01:20 AM
Last Post: micseydel
  IDLE not importing pygame (ok outside of IDLE) miner_tom 1 3,333 Sep-14-2018, 07:54 PM
Last Post: Larz60+
  Python IDLE 3.6.2 on WIn7 vs Pyhton 3 IDLE raspberry djdan_23 5 5,730 Sep-07-2017, 12:51 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020