Regular Expression In Python

The module defines several functions, constants, and an exception. Some of the functions are simplified versions of the full-featured methods for compiled regular expressions. Most non-trivial applications always use the compiled form. re.compile(pattern, flags=0) Compile a regular expression pattern into a regular expression object, which can be used for matching using its match() and search() methods, described below. The expression’s […]

Python Exception Handling

Until now error messages haven’t been more than mentioned, but if you have tried out the examples you have probably seen some. There are (at least) two distinguishable kinds of errors: syntax errors and exceptions. 1. Syntax Errors Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are […]

File Handling In Python

There are always two parts of a file in the computer system, the filename and its extension. Also, the files have two key properties – its name and the location or path, which specifies the location where the file exists. The filename has two parts, and they are separated by a dot (.) or period. Figure – File and its path: A built-in open method is used to create […]

Python Oops Concept

A Word About Names and Objects Python Scopes and Namespaces 2.1. Scopes and Namespaces Example A First Look at Classes 3.1. Class Definition Syntax 3.2. Class Objects 3.3. Instance Objects 3.4. Method Objects 3.5. Class and Instance Variables Random Remarks Inheritance 5.1. Multiple Inheritance Private Variables Odds and Ends Iterators Generators Generator Expressions Classes provide […]

Python Control Flow

This tutorial will discuss how the python interpreter shares the processing among the source code. To prioritize the control python used below keywords to direct the control flow. 1. if Statements 2. for Statements 3. The range() Function 4. break and continue Statements, and else Clauses on Loops 5. pass Statements 6. Defining Functions 7. More on Defining Functions 7.1. Default Argument Values 7.2. Keyword Arguments 7.3. Arbitrary Argument […]

Python Naming Convention Rules

1. General Avoid using names that are too general or too wordy. Strike a good balance between the two. Bad: data_structure, my_list, info_map, dictionary_for_the_purpose_of_storing_data_representing_word_definitions Good: user_profile, menu_options, word_definitions Don’t be a jackass and name things “O”, “l”, or “I” When using CamelCase names, capitalize all letters of an abbreviation (e.g. HTTPServer) 2. Packages Package names […]

Learn Numpy

Numpy is a general-purpose array-processing package. It provides a high-performance multidimensional array object, and tools for working with these arrays. It is the fundamental package for scientific computing with Python.Besides its obvious scientific uses, Numpy can also be used as an efficient multi-dimensional container of generic data. Numpy Array Array in Numpy is a table of […]

Unix / Linux – Shell Basic Operators

There are various operators supported by each shell. We will discuss in detail about Bourne shell (default shell) in this chapter.According to the operation performed on the operators it has been classified into the below types. We will now discuss the following operators − Arithmetic Operators Relational Operators Boolean Operators String Operators File Test Operators […]

Python 3.X base64.standard_b64encode encoding is required byte given str

Python 3.* is required byte not string to resolve this issue we need to convert the string into UTF-8 then again after encoding we need to convert in to ascii. token = base64.standard_b64encode(” samplestring “.encode(‘UTF-8’) + ‘:’.encode(‘UTF-8’) + “samplestring”.encode(‘UTF-8’)).decode(‘ascii’)

Python Operator – Types of Operators in Python

Being a high level language where it can fit into most of the system it has the capability to handle the all data types.To handle this data the operators are categorized into below 7 categories . Python Arithmetic Operator Python Relational Operator Python Assignment Operator Python Logical Operator Python Membership Operator Python Identity Operator Python Bitwise Operator Python Arithmetic Operator […]