{"id":18265,"date":"2021-11-11T08:41:58","date_gmt":"2021-11-11T03:11:58","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/?p=18265"},"modified":"2021-11-11T08:42:00","modified_gmt":"2021-11-11T03:12:00","slug":"python-getch-library","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/","title":{"rendered":"The Untold Secret of Python getch Library"},"content":{"rendered":"\n<p>In this article, we will learn about the python getch module.  While building the user interface for the console, we sometimes want to get some feature of pausing the screen or reading a text without showing it out on the console; This module helps us in those scenarios. So, let&#8217;s start learning this module.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Usage_of_Python_getch_library\" title=\"Usage of Python getch library\">Usage of Python getch library<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Installing_Python_getch\" title=\"Installing Python getch\">Installing Python getch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Python_getch_on_Unix_and_MacOS\" title=\" Python getch on Unix and MacOS \"> Python getch on Unix and MacOS <\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Examples\" title=\"Examples\">Examples<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Python_getch_on_windows\" title=\"Python getch on windows\">Python getch on windows<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Example_1\" title=\"Example 1\">Example 1<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Python_getch_for_arrow_keys\" title=\"Python getch for arrow keys\">Python getch for arrow keys<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Equivalent_libraries_to_Python_getch\" title=\"Equivalent libraries to Python getch\">Equivalent libraries to Python getch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#FAQs_Related_to_Python_getch_Library\" title=\"FAQs Related to Python getch Library\">FAQs Related to Python getch Library<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#Trending_Python_Articles\" title=\"Trending Python Articles\">Trending Python Articles<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-usage-of-python-getch-library\"><span class=\"ez-toc-section\" id=\"Usage_of_Python_getch_library\"><\/span>Usage of Python getch library<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While coding, we are often stuck in situations where we need to perform some action when the user hits any button from the keyboard or may enter some value. Based on different conditions, python getch is used in different ways. So, getch module does single-char input by providing wrappers for the &#8220;<strong>conio.h<\/strong>&#8221; library functions. However, if <strong>conio.h <\/strong>is missing, it uses a stub-library using &#8220;<strong>terminos.h<\/strong>&#8221; to follow up the functionality. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>[ Note:- Stub libraries are&nbsp;<strong>import libraries that export symbols but do not contain any code<\/strong><\/strong>.]<\/p><\/blockquote>\n\n\n\n<p>The getch module contains two functions with almost the same functionalities with some differences. Those are <strong>&#8220;getch()&#8221;<\/strong> and <strong>&#8220;getche()&#8221;. <\/strong>They are used to reading single characters from CLI. The only difference is that getch() doesn&#8217;t show the input value on the screen while getche() does. The most general case in which getch() is used is while entering a password. However, sometimes we also want to hold the screen till the user hits something. We can also use it there. So before discussing examples on it, first see its installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installing-python-getch\"><span class=\"ez-toc-section\" id=\"Installing_Python_getch\"><\/span>Installing Python getch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So, It is essential to install it before importing it as it is not a built-in python library. To do that, we can use the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install getch<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-getch-on-unix-and-macos\"><span class=\"ez-toc-section\" id=\"Python_getch_on_Unix_and_MacOS\"><\/span> Python getch on Unix and MacOS <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-examples\"><span class=\"ez-toc-section\" id=\"Examples\"><\/span>Examples<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let&#8217;s understand each function of getch library using examples to get hands-on to them. But, before that, we need to import it using the following command. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from getch import getch, getche<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.pythonpool.com\/import-classes-from-another-file-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Learn to import classes from other resources here.<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-1\">Example 1<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom getch import getche, getch\n\na = getch()\nprint(a)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-code\"><code>Input:<em>(Invisible on the console)<\/em>\n\n4 <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Output:\n\n4<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-example-4\">Example 4<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom getch import getche, getch\n\na = getche()\nprint(a)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-code\"><code>Input:<em>(Visible on the console)<\/em>\n\n3<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Output:\n\n3<\/code><\/pre>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-kilo monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-getch-on-windows\"><span class=\"ez-toc-section\" id=\"Python_getch_on_windows\"><\/span>Python getch on windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While the above discussed getch module is only compatible with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Linux\" target=\"_blank\" rel=\"noreferrer noopener\">Linux<\/a> OS, we can also use it in windows by <strong>&#8220;msvcrt module&#8221;<\/strong>. getch() function is also available there for use, and it functions the same way getch module does. Let&#8217;s discuss an example of it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-1-1\"><span class=\"ez-toc-section\" id=\"Example_1\"><\/span>Example 1<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom msvcrt import getche, getch\n\na = getch()\nprint(a)\n\na = getche()\nprint(a)\n<\/pre><\/div>\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Input: <em>(Invisible on the console)<\/em>\n3\n\nOutput:\n3\n\nInput:<em>(Visible on the console)<\/em>\n4\n\nOutput:\n4\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-python-getch-for-arrow-keys\"><span class=\"ez-toc-section\" id=\"Python_getch_for_arrow_keys\"><\/span>Python getch for arrow keys<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>However, we will be able to use characters as input for getch() and getche() method but, we can&#8217;t use arrow keys in the same way. The reason behind that definition of those <span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.pythonpool.com\/matplotlib-arrow\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>arrow<\/strong><\/a><\/span> keys is different for the console, and hence we have to define it the way they are defined for the console. Without making it more complex, let&#8217;s try to understand it through an example,<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef get_key():\n    first_char = gh.getch()\n    if first_char == '\\x1b':\n        return {'&#x5B;A': 'up', '&#x5B;B': 'down', '&#x5B;C': 'right', '&#x5B;D': 'left'}&#x5B;gh.getch() + gh.getch()]\n    else:\n        return first_char\n\n\nkey = ''\nwhile key != 'q':\n    key = get_key()\n    print(key)\n<\/pre><\/div>\n\n\n<p>In the above example, we used the exact meaning of the escape sequence to understand accordingly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-equivalent-libraries-to-python-getch\"><span class=\"ez-toc-section\" id=\"Equivalent_libraries_to_Python_getch\"><\/span>Equivalent libraries to Python getch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>However, it can be used, but several <a href=\"https:\/\/www.pythonpool.com\/pymy\/\" target=\"_blank\" rel=\"noopener\">libraries can function the same way<\/a>. Some of them are independent of OS, unlike getch, or some of them provide non-blocking also. Let&#8217;s see them.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>Library<\/strong><\/th><th><strong>Description<\/strong><\/th><\/tr><\/thead><tbody><tr><td>py-getch<\/td><td>Provides pause() and pause_exit() as well.<\/td><\/tr><tr><td>getchlib<\/td><td>OS Independent, Blocking and non-blocking keypress reading<\/td><\/tr><tr><td>pygetch<\/td><td>Same as py-getch but platform-independent.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs-related-to-python-getch-library\"><span class=\"ez-toc-section\" id=\"FAQs_Related_to_Python_getch_Library\"><\/span>FAQs Related to Python getch Library<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1636545264136\"><strong class=\"schema-faq-question\">What does Msvcrt getch return?<\/strong> <p class=\"schema-faq-answer\">It is as same as getch.getch() method, just the difference is that it is used for windows console and getch.getch() is used for Unix Console.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1636545395239\"><strong class=\"schema-faq-question\">What is getch in C?<\/strong> <p class=\"schema-faq-answer\">It is the predefined non-standard function defined in conio.h header file. It is used to hold the output screen until the user presses any key.<\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>So, In this article, we learned about the python getch module. We also looked at its core functionality of reading a character only using getch() and getche() methods. We also looked at the differences between both of them.<\/p>\n\n\n\n<p>I hope this article has helped you. Thank you.<\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-delta monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-2\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Python_Articles\"><\/span>Trending Python Articles<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 11, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Solved-runtimeerror-cuda-error-invalid-device-ordinal.webp 1200w \" alt=\"[Solved] runtimeerror: cuda error: invalid device ordinal\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Solved] runtimeerror: cuda error: invalid device ordinal<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-type-numpy-ndarray-doesnt-define-__round__-method\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-typeerror-type-numpy.ndarray-doesnt-define-__round__-method.webp 1200w \" alt=\"[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror: type numpy.ndarray doesn&#8217;t define __round__ method<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>In this article, we will learn about the python getch module. While building the user interface for the console, we sometimes want to get some &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"The Untold Secret of Python getch Library\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/#more-18265\" aria-label=\"More on The Untold Secret of Python getch Library\">Read more<\/a><\/p>\n","protected":false},"author":25,"featured_media":18321,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4345],"tags":[4516,4519,4517,4520],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Untold Secret of Python getch Library - Python Pool<\/title>\n<meta name=\"description\" content=\"In this article, we will discuss the python getch library. We will discuss its usage and how to install it in python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-getch-library\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Untold Secret of Python getch Library\" \/>\n<meta property=\"og:description\" content=\"In this article, we will learn about the python getch module. While building the user interface for the console, we sometimes want to get some feature of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-getch-library\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-11T03:11:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-11T03:12:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Rishav Raj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rishav Raj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/\"},\"author\":{\"name\":\"Rishav Raj\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4\"},\"headline\":\"The Untold Secret of Python getch Library\",\"datePublished\":\"2021-11-11T03:11:58+00:00\",\"dateModified\":\"2021-11-11T03:12:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/\"},\"wordCount\":635,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp\",\"keywords\":[\"getch python 3\",\"getch python list\",\"install getch python\",\"python use getch\"],\"articleSection\":[\"Module\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-getch-library\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-getch-library\/\",\"name\":\"The Untold Secret of Python getch Library - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp\",\"datePublished\":\"2021-11-11T03:11:58+00:00\",\"dateModified\":\"2021-11-11T03:12:00+00:00\",\"description\":\"In this article, we will discuss the python getch library. We will discuss its usage and how to install it in python.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136\"},{\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-getch-library\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp\",\"width\":1200,\"height\":628,\"caption\":\"Python getch\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Untold Secret of Python getch Library\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4\",\"name\":\"Rishav Raj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/23ea47a45532b57ae2a81f274f5ae257?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/23ea47a45532b57ae2a81f274f5ae257?s=96&d=wavatar&r=g\",\"caption\":\"Rishav Raj\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136\",\"name\":\"What does Msvcrt getch return?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It is as same as getch.getch() method, just the difference is that it is used for windows console and getch.getch() is used for Unix Console.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239\",\"position\":2,\"url\":\"https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239\",\"name\":\"What is getch in C?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It is the predefined non-standard function defined in conio.h header file. It is used to hold the output screen until the user presses any key.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"The Untold Secret of Python getch Library - Python Pool","description":"In this article, we will discuss the python getch library. We will discuss its usage and how to install it in python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/","og_locale":"en_US","og_type":"article","og_title":"The Untold Secret of Python getch Library","og_description":"In this article, we will learn about the python getch module. While building the user interface for the console, we sometimes want to get some feature of","og_url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/","og_site_name":"Python Pool","article_published_time":"2021-11-11T03:11:58+00:00","article_modified_time":"2021-11-11T03:12:00+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp","type":"image\/webp"}],"author":"Rishav Raj","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Rishav Raj","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/"},"author":{"name":"Rishav Raj","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4"},"headline":"The Untold Secret of Python getch Library","datePublished":"2021-11-11T03:11:58+00:00","dateModified":"2021-11-11T03:12:00+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/"},"wordCount":635,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp","keywords":["getch python 3","getch python list","install getch python","python use getch"],"articleSection":["Module"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/","name":"The Untold Secret of Python getch Library - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp","datePublished":"2021-11-11T03:11:58+00:00","dateModified":"2021-11-11T03:12:00+00:00","description":"In this article, we will discuss the python getch library. We will discuss its usage and how to install it in python.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136"},{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp","contentUrl":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/11\/Python-getch.webp","width":1200,"height":628,"caption":"Python getch"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"The Untold Secret of Python getch Library"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#\/schema\/person\/025222e28182ecbb97e17f9f1bf15ac4","name":"Rishav Raj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/secure.gravatar.com\/avatar\/23ea47a45532b57ae2a81f274f5ae257?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/secure.gravatar.com\/avatar\/23ea47a45532b57ae2a81f274f5ae257?s=96&d=wavatar&r=g","caption":"Rishav Raj"}},{"@type":"Question","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136","position":1,"url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545264136","name":"What does Msvcrt getch return?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It is as same as getch.getch() method, just the difference is that it is used for windows console and getch.getch() is used for Unix Console.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239","position":2,"url":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/python-getch-library\/#faq-question-1636545395239","name":"What is getch in C?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It is the predefined non-standard function defined in conio.h header file. It is used to hold the output screen until the user presses any key.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/18265"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=18265"}],"version-history":[{"count":14,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/18265\/revisions"}],"predecessor-version":[{"id":24538,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/18265\/revisions\/24538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/18321"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=18265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=18265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=18265"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926033832\/https:\/\/api.w.org\/{rel}","templated":true}]}}