![]() |
The gentag library in python provides an efficient way for tagging Python objects. These arbitrary Python objects once assigned with a python tag can further be quarried based on the tags. In this article, the focus is on assignment, manipulations, and operations on tagging using python. Installation:Use the below command to install the gentag library. pip install gentag Defining and Assigning TagsThe tags object needs to assigned using Scope() class of gentag library. Post that each tag can be assigned using define() method, which accepts object name and list of tags to assign to it as the parameter. Example: Python3
Output : ![]() Tagged objects Working with operations and ‘all’ tags:Simple set operations such as &(and), or(|), -(difference) and symmetric difference(^) can be performed over tags using evaluate(). The intersection of all tags can be performed using ‘all’. Example: Python3
Output : ![]() Operations on tags Assigning tags as tags :Each new tag can be initialized as the composition of a set of tag operations using define(). Just passing tags operations as 2nd parameter. Example: Python3
Output : ![]() New assigned tag. |
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |