Python Packages

Python Packages:

A package is a hierarchical file directory structure that defines the single python application environment. This package consists of a module, sub packages, and sub-sub packages and so on ..usually packages are the way of structuring the python module namespace using dotted module names. This python packages allows the uniform handling of files and data.

For example, A.B indicates, Package A contains a sub-module B.In order to treat the python directories as packages, __init__.py files are required. And there is no restriction for the __init__.py file w.r.t to the number of code line . (i.e it can be empty files (or) a file that contains some code). Besides this python interpreter allows the user to execute the individual modules of the package.

So, are you looking at the example code? If so don’t waste your time by scrolling your mouse up and down. Since this concept is common in other programming languages like Java, I would like to leave for you as an assignment. visit Python online education for support.

In the definition of the package, we have seen the package is a combination of several directories, functions, module so on. In some cases, we require only a few components of the package. And in some other cases, we require all the modules of the package. And there is no limit regarding the number of modules, files in the package. Its good to use import statement, if the package contains less than 5 modules, function. But what if the package contains 100’s of modules/ directories.Its a bad way of programming to use import statement for those 100 files/directories inclusion. In such cases, we need to use an alternative to the problem. * provides a good solution to the problem. Usually * is used to import all the package modules.

Also check the essential packages in Python and IOT

Note :

If the package imports the file name from the current module, usually dot notation is used. And the leading dot indicates the packages involved in the relative import.

Beside this Python interpreter also supports the special attribute __path__. Usually, this contains the directory name that contains the __init__.py.

So in python tutorial, we will next about

Python Regular expressions:

A regular expression is a character sequence that forms a search pattern. In a variety of ways, these expressions permit you to match various string values. These are essentially a tiny highly specialized programming language available inside the python and made available through re-module. With this language, you can specify the rules for the set of possible strings to match. And this possible string may be English sentence, e-mail address (or) any other Tex commands.

Additionally, this module re provides full support for Perl like the regular expression in python. At the compilation time, if an error occurs, the re-module raises re.error exception.

Without invoking the special meaning, regular expressions use the backslash (\) to indicate the special forms (or)special meaning.

Regular expression syntax :

It is a set of strings that match the required expression. Additionally, this regular expression allows the concatenation to form new strings. If A and B are the regular expression, then AB is also a regular expression.

Ex: if the string  P matches  A and the other string q matches B then the string pq will match AB. Now let  us have a look over the python regular expression characters

Regular Expression characters :
Symbol Meaning
. Except new line character matches any character
^ It matches any string starting
$ It matches any string ending
* In the given regular expression, it searches zero (or)more repetition
\ Either a special character (or) a regular expression character (or) special regular expression sequences.
? It Matches one (or) more previous regular expressions
+ In the One(or) more occurrences
| It is used in the cases of Either (or)
() Capture and gr
{} It is  used to specify the exact number of sequences
. Uses for any character (except newline character)
^ It is used for starting of the regular expression
[] It is used for the  character set
[…] Matches any single line character in brackets
[^…] Matches  any single character but not in brackets

Get the real-time examples on regular expression characters at python course

Besides this regular expression match, Python interpreter also supports the match expressions.

Match expressions:

So now, let us have a look over the match expressions:

Pattern Descriptions
re* It matches for the  zero (or) more occurrences of the preceding expression
re+ It matches one (or) more occurrence of the preceding expression
re? It matches for the one (or) more occurrence of the preceding expression
re{ n} It matches for the exactly ‘n’occurances of the preceding expression
re{n, } It matches for n (or) more occurrences of the preceding expression
re{n,m} It matches for at least ‘n’ of the’ occurrences of the preceding expression
a|b It matches for  either a (or) b
(re) It groups the regular expressions and remembers matches text

Like match expression, it supports the special sequences.Now let us have a look over those special sequences.

Special Sequences :
Character Description
\A It returns the match if the specified characters are the string beginning
\b It returns the match where the specified characters are at the beginning (or) end of the word
\B Returns a match where the special characters are present. But not at the beginning (or) end of the word.
\d Returns the string that contains numbers  0-9
\D Returns the string that does not contain digits
\s It returns the string that contains the special character
\S It returns the string that does not contain the special character
\w It Returns a match, where the string contains any words
\W It Returns a match, but string does not contain any word characters
\Z It Returns the match, if the specified characters are the string end

Besides this, it additionally supports some built-in functions. Now let us have a look over those.

Functions :
Function _name Description
search() It searches the string for the match. If there is a match, it returns the match object
split() The split() returns a list. Here the string has been split at each match.
sub() It replaces the text match with the text of your choice
group() It returns the string that was matched by the regular expression
start() It returns the starting position of the match
end() It returns the ending position of the match
span() It returns  the tuple that contains the staring position of the match

Match():

A match object is an object containing the information about the search and result

So likewise python supports  regular expressions. Since I have said the working of these functions I would like to leave the example code for you as an assignment. If you struck up anywhere feel  contact the experts at Python training in hyderabad

Drop Us A Query

Trending Courses
  • PEGA Testing Training
  • Today application testing is the deciding factor to launch the application into the market. And people do not launch the application unless it goes true.

  • Cyber Security Training
  • Days were moving very quickly. With days, technology is moving simultaneously. Today technology has bot the advantages and disadvantages. Moreover, today data is the heart of any company.

  • Blockchain Online Course
  • Today many people were enthusiastic, to know the exact details of things happening around him. This can get the proper knowledge on Blockchain.

  • Python Online Training
  • Python is a dynamic interrupted language which is used in wide varieties of applications. It is very interactive object oriented and high-level programming language.

  • Tableau Training
  • Tableau is a Software company that caters interactive data visualization products that provide Business Intelligence services. The company’s Head Quarters is in Seattle, USA.

  • PEGA Online Training
  • Pega Systems Inc. is a Cambridge, Massachusetts based Software Company. It is known for developing software for Customer Relationship Management (CRM) and Business process Management (BPM).


100% Secure Payments. All major credit & debit cards accepted.