summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fmsvcrt.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/library%2Fmsvcrt.html')
-rw-r--r--devdocs/python~3.12/library%2Fmsvcrt.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fmsvcrt.html b/devdocs/python~3.12/library%2Fmsvcrt.html
new file mode 100644
index 00000000..5cd9cf7d
--- /dev/null
+++ b/devdocs/python~3.12/library%2Fmsvcrt.html
@@ -0,0 +1,59 @@
+ <span id="msvcrt-useful-routines-from-the-ms-vc-runtime"></span><h1>msvcrt — Useful routines from the MS VC++ runtime</h1> <p>These functions provide access to some useful capabilities on Windows platforms. Some higher-level modules use these functions to build the Windows implementations of their services. For example, the <a class="reference internal" href="getpass#module-getpass" title="getpass: Portable reading of passwords and retrieval of the userid."><code>getpass</code></a> module uses this in the implementation of the <a class="reference internal" href="getpass#module-getpass" title="getpass: Portable reading of passwords and retrieval of the userid."><code>getpass()</code></a> function.</p> <p>Further documentation on these functions can be found in the Platform API documentation.</p> <p>The module implements both the normal and wide char variants of the console I/O api. The normal API deals only with ASCII characters and is of limited use for internationalized applications. The wide char API should be used where ever possible.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.3: </span>Operations in this module now raise <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a> where <a class="reference internal" href="exceptions#IOError" title="IOError"><code>IOError</code></a> was raised.</p> </div> <section id="file-operations"> <span id="msvcrt-files"></span><h2>File Operations</h2> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.locking">
+<code>msvcrt.locking(fd, mode, nbytes)</code> </dt> <dd>
+<p>Lock part of a file based on file descriptor <em>fd</em> from the C runtime. Raises <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a> on failure. The locked region of the file extends from the current file position for <em>nbytes</em> bytes, and may continue beyond the end of the file. <em>mode</em> must be one of the <code>LK_*</code> constants listed below. Multiple regions in a file may be locked at the same time, but may not overlap. Adjacent regions are not merged; they must be unlocked individually.</p> <p class="audit-hook">Raises an <a class="reference internal" href="sys#auditing"><span class="std std-ref">auditing event</span></a> <code>msvcrt.locking</code> with arguments <code>fd</code>, <code>mode</code>, <code>nbytes</code>.</p> </dd>
+</dl> <dl class="py data"> <dt class="sig sig-object py" id="msvcrt.LK_LOCK">
+<code>msvcrt.LK_LOCK</code> </dt> <dt class="sig sig-object py" id="msvcrt.LK_RLCK">
+<code>msvcrt.LK_RLCK</code> </dt> <dd>
+<p>Locks the specified bytes. If the bytes cannot be locked, the program immediately tries again after 1 second. If, after 10 attempts, the bytes cannot be locked, <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a> is raised.</p> </dd>
+</dl> <dl class="py data"> <dt class="sig sig-object py" id="msvcrt.LK_NBLCK">
+<code>msvcrt.LK_NBLCK</code> </dt> <dt class="sig sig-object py" id="msvcrt.LK_NBRLCK">
+<code>msvcrt.LK_NBRLCK</code> </dt> <dd>
+<p>Locks the specified bytes. If the bytes cannot be locked, <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a> is raised.</p> </dd>
+</dl> <dl class="py data"> <dt class="sig sig-object py" id="msvcrt.LK_UNLCK">
+<code>msvcrt.LK_UNLCK</code> </dt> <dd>
+<p>Unlocks the specified bytes, which must have been previously locked.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.setmode">
+<code>msvcrt.setmode(fd, flags)</code> </dt> <dd>
+<p>Set the line-end translation mode for the file descriptor <em>fd</em>. To set it to text mode, <em>flags</em> should be <a class="reference internal" href="os#os.O_TEXT" title="os.O_TEXT"><code>os.O_TEXT</code></a>; for binary, it should be <a class="reference internal" href="os#os.O_BINARY" title="os.O_BINARY"><code>os.O_BINARY</code></a>.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.open_osfhandle">
+<code>msvcrt.open_osfhandle(handle, flags)</code> </dt> <dd>
+<p>Create a C runtime file descriptor from the file handle <em>handle</em>. The <em>flags</em> parameter should be a bitwise OR of <a class="reference internal" href="os#os.O_APPEND" title="os.O_APPEND"><code>os.O_APPEND</code></a>, <a class="reference internal" href="os#os.O_RDONLY" title="os.O_RDONLY"><code>os.O_RDONLY</code></a>, and <a class="reference internal" href="os#os.O_TEXT" title="os.O_TEXT"><code>os.O_TEXT</code></a>. The returned file descriptor may be used as a parameter to <a class="reference internal" href="os#os.fdopen" title="os.fdopen"><code>os.fdopen()</code></a> to create a file object.</p> <p class="audit-hook">Raises an <a class="reference internal" href="sys#auditing"><span class="std std-ref">auditing event</span></a> <code>msvcrt.open_osfhandle</code> with arguments <code>handle</code>, <code>flags</code>.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.get_osfhandle">
+<code>msvcrt.get_osfhandle(fd)</code> </dt> <dd>
+<p>Return the file handle for the file descriptor <em>fd</em>. Raises <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a> if <em>fd</em> is not recognized.</p> <p class="audit-hook">Raises an <a class="reference internal" href="sys#auditing"><span class="std std-ref">auditing event</span></a> <code>msvcrt.get_osfhandle</code> with argument <code>fd</code>.</p> </dd>
+</dl> </section> <section id="console-i-o"> <span id="msvcrt-console"></span><h2>Console I/O</h2> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.kbhit">
+<code>msvcrt.kbhit()</code> </dt> <dd>
+<p>Return <code>True</code> if a keypress is waiting to be read.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.getch">
+<code>msvcrt.getch()</code> </dt> <dd>
+<p>Read a keypress and return the resulting character as a byte string. Nothing is echoed to the console. This call will block if a keypress is not already available, but will not wait for <kbd class="kbd docutils literal notranslate">Enter</kbd> to be pressed. If the pressed key was a special function key, this will return <code>'\000'</code> or <code>'\xe0'</code>; the next call will return the keycode. The <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Control</kbd>-<kbd class="kbd docutils literal notranslate">C</kbd></kbd> keypress cannot be read with this function.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.getwch">
+<code>msvcrt.getwch()</code> </dt> <dd>
+<p>Wide char variant of <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code>getch()</code></a>, returning a Unicode value.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.getche">
+<code>msvcrt.getche()</code> </dt> <dd>
+<p>Similar to <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code>getch()</code></a>, but the keypress will be echoed if it represents a printable character.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.getwche">
+<code>msvcrt.getwche()</code> </dt> <dd>
+<p>Wide char variant of <a class="reference internal" href="#msvcrt.getche" title="msvcrt.getche"><code>getche()</code></a>, returning a Unicode value.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.putch">
+<code>msvcrt.putch(char)</code> </dt> <dd>
+<p>Print the byte string <em>char</em> to the console without buffering.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.putwch">
+<code>msvcrt.putwch(unicode_char)</code> </dt> <dd>
+<p>Wide char variant of <a class="reference internal" href="#msvcrt.putch" title="msvcrt.putch"><code>putch()</code></a>, accepting a Unicode value.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.ungetch">
+<code>msvcrt.ungetch(char)</code> </dt> <dd>
+<p>Cause the byte string <em>char</em> to be “pushed back” into the console buffer; it will be the next character read by <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code>getch()</code></a> or <a class="reference internal" href="#msvcrt.getche" title="msvcrt.getche"><code>getche()</code></a>.</p> </dd>
+</dl> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.ungetwch">
+<code>msvcrt.ungetwch(unicode_char)</code> </dt> <dd>
+<p>Wide char variant of <a class="reference internal" href="#msvcrt.ungetch" title="msvcrt.ungetch"><code>ungetch()</code></a>, accepting a Unicode value.</p> </dd>
+</dl> </section> <section id="other-functions"> <span id="msvcrt-other"></span><h2>Other Functions</h2> <dl class="py function"> <dt class="sig sig-object py" id="msvcrt.heapmin">
+<code>msvcrt.heapmin()</code> </dt> <dd>
+<p>Force the <code>malloc()</code> heap to clean itself up and return unused blocks to the operating system. On failure, this raises <a class="reference internal" href="exceptions#OSError" title="OSError"><code>OSError</code></a>.</p> </dd>
+</dl> </section> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/library/msvcrt.html" class="_attribution-link">https://docs.python.org/3.12/library/msvcrt.html</a>
+ </p>
+</div>