Python Immutable datatypes(int, float, str, tuple and frozensets)


Python Immutable datatypes(int, float, str, tuple and frozensets) is another important parameter used by different programmers . Learn more about it here. Python Immutable datatypes: Individual characters of strings are not assignable foo = “bar”foo[0] = “c” # Error Immutable variable value can not be changed once they are created. Section 148.2: Tuple’s individual members … Read more

Python Incompatibilities moving from Python 2 to Python 3

Unlike most languages, Python supports two major versions. Since 2008 when Python 3 was released, many have made the transition, while many have not. In order to understand both, this section covers the important differences between Python 2 and Python 3. Learn More about Python Incompatibilities, Integer Division The standard division symbol (/) operates differently … Read more

ChemPy – python package

Chapter 178: ChemPy – python package ChemPy is a python package designed mainly to solve and address problems in physical, analytical and inorganic Chemistry. It is a free, open-source Python toolkit for chemistry, chemical engineering, and materials science applications. Section 178.1: Parsing formulae from chempy import Substanceferricyanide = Substance.from_formula(‘Fe(CN)6-3’) ferricyanide.composition == {0: -3, 26: 1, … Read more

Python Pyglet Tutorial | Pyglet Module In Python Tutorial

Chapter 180: Pyglet Pyglet is a Python module used for visuals and sound. It has no dependencies on other modules. See [][1] for the official information. [1]: Section 180.1: Installation of Pyglet Install Python, go into the command line and type: Python 2: pip install pyglet Python 3: pip3 install pyglet Section 180.2: Hello … Read more

Python Audio Tutorial | Audio Module In Python Tutorial


Chapter 181: Audio Section 181.1: Working with WAV files winsound Windows environment import winsoundwinsound.PlaySound(“path_to_wav_file.wav”, winsound.SND_FILENAME) wave Support mono/stereo Doesn’t support compression/decompression import wavewith“path_to_wav_file.wav”, “rb”) as wav_file: # Open WAV file in read-only mode. Get basic information. n_channels = wav_file.getnchannels() # Number of channels. (1=Mono, 2=Stereo).sample_width = wav_file.getsampwidth() # Sample width in bytes.framerate = wav_file.getframerate() … Read more

Python 2To3 Tool Tutorial | 2To3 Tool In Python Tutorial

Python 2to3 tool is another important parameter used by different programmers in performing different tasks. Learn more about it here. Python 2to3 tool Parameter filename / directory_name Option -f FIX, –fix=FIX -j PROCESSES, –processes=PROCESSES -x NOFIX, –nofix=NOFIX -l, –list-fixes-p, –print-function -v, –verbose –no-diffs -w -n, –nobackups -o OUTPUT_DIR, –output-dir=OUTPUT_DIR -W, –write-unchanged-files –add-suffix=ADD_SUFFIX Description 2to3 accepts … Read more

Python Pyaudio Tutorial | Pyaudio Module In Python Tutorial

Chapter 182: pyaudio PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio on a variety of platforms. PyAudio is inspired by: 1.pyPortAudio/fastaudio: Python bindings for PortAudio v18 API. 2.tkSnack: cross-platform sound toolkit for Tcl/Tk and Python. Section 182.1: Callback Mode Audio … Read more

Python Shelve Tutorial | Shelve In Python Tutorial


Chapter 183: shelve Shelve is a python module used to store objects in a file. The shelve module implements persistent storage for arbitrary Python objects which can be pickled, using a dictionary-like API. The shelve module can be used as a simple persistent storage option for Python objects when a relational database is overkill. The … Read more

Python Unicode And Bytes Tutorial | Unicode And Bytes In Python

Game Development

Python Unicode and bytes are two different parameters used in encoding Parameter Detailsencoding The encoding to use, e.g. , , etc…’ascii’ ‘utf8’The errors mode, e.g. to replace bad characters with question marks, to ignoreerrors ‘replace’ ‘ignore’bad characters, etc… Python Unicode and bytes: Encoding/decoding error handling .encode and .decode both have error modes. The default is … Read more

Python Abstract Syntax Tree Tutorial | Abstract Syntax Tree In Python

Python Abstract syntax tree is an important function used by programmers to solve different problems easily. Learn all about the module here. Python Abstract syntax: Analyze functions in a python script This analyzes a python script and, for each defined function, reports the line number where the function began, where the signature ends, where the … Read more

Non-offcial Python implementations

Non-offcial Python implementations are another important thing to learn by Python programmers. Learn all you need to know about this module here. IronPython Open-source implementation for .NET and Mono written in C#, licensed under Apache License 2.0. It relies on DLR (Dynamic Language Runtime). It supports only version 2.7, version 3 is currently being developed. … Read more

Python ArcPy Tutorial | ArcPy Module In Python Tutorial

Python ArcPy is used to create a file and perform many other functions by using Python programming language. Learn more about it here. createDissolvedGDB to create a file gdb on the workspace def createDissolvedGDB(workspace, gdbName):gdb_name = workspace + “/” + gdbName + “.gdb”if(arcpy.Exists(gdb_name):arcpy.Delete_management(gdb_name)arcpy.CreateFileGDB_management(workspace, gdbName, “”)else:arcpy.CreateFileGDB_management(workspace, gdbName, “”)return gdb_name Python ArcPy: Printing one field’s value for … Read more

Python Abstract Base Classes (abc)

Python Abstract Base Classes (abc) are designed to inherit but avoid implementing specific methods. They only leave method signature. Learn more here. Setting the ABCMeta metaclass Abstract classes are classes that are meant to be inherited but avoid implementing specific methods, leaving behind only method signatures that subclasses must implement. Abstract classes are useful for … Read more

Python Attribute Access

Python Attribute Access is another important module to learn while programming in Python. This topic covers all you need to know about attribute access. Basic Attribute Access using the Dot Notation Let’s take a sample class. class Book:def init(self, title, author):self.title = = authorbook1 = Book(title=”Right Ho, Jeeves”, author=”P.G. Wodehouse”) In Python you can … Read more

Python Alternatives to switch statement from other languages


Python Alternatives to switch statement from other languages is useful in many cases, especially during programming complex items. Learn more here. Python Alternatives: Use what the language o ers: the if/else construct Well, if you want a switch/case construct, the most straightforward way to go is to use the good old if/else construct: def switch(value):if … Read more

Python List destructuring (aka packing and unpacking)


Python List destructuring (aka packing and unpacking) is used for splitting various modules and elements mainly. Here is all you need to know about it. Destructuring assignment In assignments, you can split an Iterable into values using the “unpacking” syntax: Destructuring as values a, b = (1, 2)print(a)Prints: 1 print(b)Prints: 2 If you try to … Read more