payment by upi: sinhamit@icici or payment by bank account name: amit kumar sinha, account number: 2646728782 IFSC code: KKBK0005660 SWIFT: KKBKINBB

Please support if you like my work by payment through upi: sinhamit@icici or payment by bank

account name: Amit Kumar Sinha,
account number: 2646728782
IFSC code: KKBK0005660
SWIFT: KKBKINBB


Help Function   in Category: पाइथन   by amit

🕙 Posted on 2023-06-24 at 14:22:29


मदद प्राप्त करें

    ऐसे विभिन्न तरीके हैं जिनसे आप PYTHON CONSOLE (अर्थात, >>>इंटरैक्टिव शेल) या यहां तक ​​कि अपनी .py एक्सटेंशन वाली फ़ाइल में कोड लिखने से सहायता प्राप्त कर सकते हैं। आइए देखें कि यह कैसे किया जा सकता है। अपना VSCode संपादक खोलें, और अपने प्रोजेक्ट फ़ोल्डर के भीतर new.py फ़ाइल में (इसमें पहले से लिखे गए सभी कोड को हटाने या मिटाने के बाद) निम्न कमांड टाइप करें। आप एक नई फ़ाइल जैसे, 001.py, 002.py, आदि भी बना सकते हैं, और संबंधित फ़ाइल को कमांड शेल या VSCode टर्मिनल से चलाएँ/निष्पादित (run/execute) करें, जैसा कि पिछले पृष्ठ में बताया गया है।

print( dir(list) )     # dir()एक अंतर्निहित फ़ंक्शन है, जो किसी क्लास या फ़ंक्शन के लिए सभी उपलब्ध विधियों (methods) को दिखाता है। यह किसी भी ऑब्जेक्ट की विशेषताओं और विधियों की सूची लौटाता है (जैसे फ़ंक्शंस, मॉड्यूल, स्ट्रिंग्स, सूचियां, शब्दकोश आदि)। रिटर्न: dir() उस ऑब्जेक्ट की विशेषताओं की एक वैध सूची वापस करने का प्रयास करता है जिस पर इसे बुलाया जाता है। यह कथन पायथन में सूची list क्लास/फ़ंक्शन के लिए उपलब्ध निम्नलिखित विधियों को प्रदर्शित करता है।

    आप देख सकते हैं कि कुछ कंस्ट्रक्टर विधियाँ हैं, जो दो अंडरस्कोर प्रतीकों के साथ शुरू और समाप्त होती हैं। हालाँकि, व्यवहार में, पायथन प्रोग्रामिंग में विधियों (दो अंडरस्कोर द्वारा उपसर्ग prefix और पोस्ट-फिक्स के बिना) का उपयोग किया जाता है, उदाहरण के लिए, 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'।

PS C:\xampp\htdocs> cd .\python2023\
PS C:\xampp\htdocs\python2023> py new.py
['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

print( dir() )     # यह कथन निम्नलिखित आउटपुट प्रदर्शित करता है:

PS C:\xampp\htdocs> cd .\python2023\
PS C:\xampp\htdocs\python2023> py new.py
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']

print( help(dir()) )     # यह कथन आउटपुट को संदर्भ में प्रदर्शित करता है, अर्थात dir() को सूची के रूप में माना जाता है , और इस प्रकार, नीचे वर्णित help( dir(list) ) या help( list() ) के परिणाम को आउटपुट करता है।

print( help(dir) )     # आपको अंतर्निहित फ़ंक्शन (dir या exit) के बारे में अधिक जानने के लिए help() फ़ंक्शन के भीतर कोष्ठक के बिना कीवर्ड का उपयोग करना चाहिए, या पायथन कंसोल (यानी, >>> इंटरैक्टिव शेल) के अंदर help> सीएलआई (CLI) का उपयोग करना चाहिए।

C:\Users\yourName>python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 3.10's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the internet at https://docs.python.org/3.10/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> dir
Help on built-in function dir in module builtins:

dir(...)
    dir([object]) -> list of strings

    If called without an argument, return the names in the current scope.
    Else, return an alphabetized list of names comprising (some of) the attributes
    of the given object, and of attributes reachable from it.
    If the object supplies a method named __dir__, it will be used; otherwise
    the default dir() logic is used and returns:
        for a module object: the module's attributes.
        for a class object: its attributes, and recursively the attributes
            of its bases.
        for any other object: its attributes, its class's attributes, and
            recursively the attributes of its class's base classes.

print( help() )     # जब आप कमांड लाइन कंसोल से py new.py फ़ाइल निष्पादित करेंगे तो यह स्टेटमेंट help> सीएलआई खोलेगा। यदि आप भ्रमित हैं, या नहीं जानते कि क्या करना है, Enter या Return दो या तीन बार दबाएं, और आप help> सीएलआई (CLI) से बाहर निकल जाएंगे। Python कंसोल यानी, >>> से बाहर निकलने के लिए, आपको exit() या quit() फ़ंक्शन टाइप करना होगा और Enter या Return कुंजी दबाना होगा।

print( help(list) )     # यह कथन निम्नलिखित परिणाम देगा।

C:\Users\yourName>python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 3.10's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the internet at https://docs.python.org/3.10/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> list
Help on class list in module builtins:

class list(object)
  |   list(iterable=(), /)
  |
  |   Built-in mutable sequence.
  |
  |   If no argument is given, the constructor creates a new empty list.
  |   The argument must be an iterable if specified.
  |
  |   Methods defined here:
  |
  |   __add__(self, value, /)
  |       Return self+value.
  |
  |   __contains__(self, key, /)
  |       Return key in self.
  |
  |   __delitem__(self, key, /)
  |       Delete self[key].
  |
  |   __eq__(self, value, /)
  |       Return self==value.
  |
  |   __ge__(self, value, /)
  |       Return self>=value.
  |
  |   __getattribute__(self, name, /)
  |       Return getattr(self, name).
  |
  |   __getitem__(...)
  |       x.__getitem__(y) <==> x[y]
  |
  |   __gt__(self, value, /)
  |       Return self>value.
  |
  |   __iadd__(self, value, /)
  |       Implement self+=value.
  |
  |   __imul__(self, value, /)
  |       Implement self*=value.
  |
  |   __init__(self, /, *args, **kwargs)
  |       Initialize self. See help(type(self)) for accurate signature.
  |
  |   __iter__(self, /)
  |       Implement iter(self).
  |
  |   __le__(self, value, /)
  |       Return self<=value.
  |
  |   __len__(self, /)
  |       Return len(self).
  |
  |   __lt__(self, value, /)
  |       Return self<value.
  |
  |   __mul__(self, value, /)
  |       Return self*value.
  |
  |   __ne__(self, value, /)
  |       Return self!=value.
  |
  |   __repr__(self, /)
  |       Return repr(self).
  |
  |   __reversed__(self, /)
  |       Return a reverse iterator over the list.
  |
  |   __rmul__(self, value, /)
  |       Return value*self.
  |
  |   __setitem__(self, key, value, /)
  |       Set self[key] to value.
  |
  |   __sizeof__(self, /)
  |       Return the size of the list in memory, in bytes.
  |
  |   append(self, object, /)
  |       Append object to the end of the list.
  |
  |   clear(self, /)
  |       Remove all items from list.
  |
  |   copy(self, /)
  |       Return a shallow copy of the list.
  |
  |   count(self, value, /)
  |       Return number of occurrences of value.
  |
  |   extend(self, iterable, /)
  |       Extend list by appending elements from the iterable.
  |
  |   index(self, value, start=0, stop=9223372036854775807, /)
  |       Return first index of value.
  |
  |       Raises ValueError if the value is not present.
  |
  |   insert(self, index, object, /)
  |       Insert object before index.
  |
  |   pop(self, index=-1, /)
  |       Remove and return item at index (default last).
  |
  |       Raises IndexError if list is empty or index is out of range.
  |
  |   remove(self, value, /)
  |       Remove first occurrence of value.
  |
  |       Raises ValueError if the value is not present.
  |
  |   reverse(self, /)
  |       Reverse *IN PLACE*.
  |
  |   sort(self, /, *, key=None, reverse=False)
  |       Sort the list in ascending order and return None.
  |
  |       The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
  |       order of two equal elements is maintained).
  |
  |       If a key function is given, apply it once to each list item and sort them,
  |       ascending or descending, according to their function values.
  |
  |       The reverse flag can be set to sort in descending order.
  |
  |   ----------------------------------------------------------------------
  |   Class methods defined here:
  |
  |   __class_getitem__(...) from builtins.type
  |       See PEP 585
  |
  |   ----------------------------------------------------------------------
  |   Static methods defined here:
  |
  |   __new__(*args, **kwargs) from builtins.type
  |       Create and return a new object. See help(type) for accurate signature.
  |
  |   ----------------------------------------------------------------------
  |   Data and other attributes defined here:
  |
  |   __hash__ = None

print( help(dir(list)) )     # यह कथन उपरोक्त जैसा ही परिणाम देगा, लेकिन Help on list object: (क्लास नहीं बल्कि ऑब्जेक्ट के रुप में)

    अगले पृष्ठों में, आप अंतर्निहित फ़ंक्शंस, उनकी विधियों और उन्हें वास्तविक (real) दुनिया के programs में कैसे लागू करें, इसके बारे में जानेंगे।


Leave a Comment: