AmitDiwan has Published 11365 Articles

How do I access the serial (RS232) port in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:56:47

19K+ Views

To access the serial port in Python, use the pyserial module, which Python Serial Port Extension for Win32, OSX, Linux, BSD, Jython, IronPython. Let us see the features - Access to the port settings through Python properties. Support for different byte sizes, stop bits, parity and flow control with ... Read More

How do I find the current module name in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:24:17

10K+ Views

A module can find out its own module name by looking at the predefined global variable __name__. If this has the value '__main__', the program is running as a script. Example def main(): print('Testing…...') ... if __name__ == '__main__': main() ... Read More

How do I parcel out work among a bunch of worker threads in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:18:19

105 Views

To parcel out work among a bunch of worker threads, use the concurrent.futures module, especially the ThreadPoolExecutor class. With that an alternative, if you want fine control over the dispatching algorithm, you can write your own logic manually. Use the queue module to create a queue containing a list of ... Read More

How do you implement persistent objects in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:17:02

671 Views

To implement persistent objects in Python, use the following libraries. shelve pickle The shelve module A “shelf” is a persistent, dictionary-like object. The difference with “dbm” databases is that the values (not the keys!) in a shelf can be essentially arbitrary Python objects — anything that the pickle ... Read More

How do I create documentation from doc strings in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:15:24

576 Views

To create documentation from doc strings, we can use the following packages and modules − Pydoc Epydoc Sphinx Let us understand them one by one − Pydoc The pydoc module can create HTML from the doc strings in your Python source code. The pydoc module automatically generates documentation ... Read More

How can I remove Python from my Windows Machine?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:13:52

5K+ Views

To complete remove Python from the Windows machine, uninstall it, remove the path and the remaining files if still present on the system. Uninstall Python To uninstall Python, go to START, type Python. Click Uninstall − After clicking Uninstall, the following screen is visible. To uninstall Python, you need ... Read More

Python - Can’t we get rid of the Global Interpreter Lock?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:09:56

539 Views

The Global Interpretor Lock is a mutex in Python. Let’s first understand what is a Global Interpreter Lock (GIL) − What is a GIL? The global interpreter lock, or GIL, is a mutex that − Protects access to Python objects, Prevents multiple threads from executing Python bytecodes at once. ... Read More

What WWW tools are there for Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:08:55

126 Views

With Python, we can also create Web Applications. Python provides multiple frameworks for the web development. Let us see some them which are widely used. Django Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much ... Read More

How do I create a .pyc file in Python?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:08:04

9K+ Views

To create a .pyc file in Python, use the PyCompile. The official documentation even suggests the same as shown below − The py_compile module The py_compile module provides a function to generate a byte-code file from a source file, and another function used when the module source file is ... Read More

How do I make an executable from a Python script?

AmitDiwan

AmitDiwan

Updated on 20-Sep-2022 11:07:12

824 Views

To make an executable from a Python script, you need to install the PyInstaller library. Install the PyInstaller Library To install the PyInstaller library, use the pip in Python. Type the below command on Command Prompt and press Enter − pip install pyinstaller Our Python Script Let’s say we ... Read More

Advertisements