Skip to main content

Posts

Python Frameworks

What is a framework? A framework in programming refers to a pre-built structure or set of tools that developers use to create software applications. It provides a foundation that developers can build upon, allowing them to focus on the specific logic and functionality of their application rather than the low-level details of coding everything from scratch. Frameworks often include libraries, APIs, and other components that streamline the development process by providing common functionalities like database access, user authentication, and web services integration. Frameworks are designed to promote best practices, maintainability, scalability, and efficiency in software development. There are many frameworks available in Python but we will talk about some famous of them. Django Flask Pyramid CherryPy Tornado Let's get some overview of all frameworks here: Django : A high-level web framework that provides rapid development and clean, robust design. It includes many useful built-in

Python List

What is a List? List is a data type in Python. List is used to store multiple values ( it can string, integer, float and other lists also ) in a single variable. Lists are mutable, which means you can modify, add, and remove elements from them. We can define a list in the following ways, 1. myList = [value1, value2, value3] 2. myTuple = (value1, value2, value3) myTupleList = list(myTuple) 3. myStr = 'My String' myStrList = list(myStr)  Example: a = [1,2,3] print(a) Output: [1,2,3] You can access individual elements in a list using square brackets and the index of the element. Indexing starts from 0 in the Python List. Like we want to access the third element of the above example list, we can write, a[2] Output: 3 If we want a string in a list, we will use double quotes for the element. Also if we want to use a list in the list we can use it. Example: myList = [2,4, ["a", 4]] myList[2] Output: ["a", 4] List can have duplicate elements. We can add, remove

Data Types

We can identify the type of data/variable based on value. It indicates which type of data that you are using like string, integer, float or other. Data types are classifications of data items, indicating the kind of values they can hold and the operations that can be performed on them. In programming and computer science, data types are crucial because they determine the structure of data and the ways in which it can be manipulated. In Python, data types are dynamically inferred, meaning you don't need to explicitly declare the type of a variable. Python automatically determines the data type based on the value assigned to it. List of Data Types: Name Keyword Example Integer int a = 2 Float float b = 1.2 String str name = "John" Boolean bool is_valid = True List list numList = [10,20,30,40, 50]

Best IDEs for Python Programming

5 Best IDEs for Python Programming Today, there are many IDEs available in the market. I tried many of them, but some have fabulous features to enjoy while programming in those IDEs.  I will give you some of the best IDEs for you that boost your writing efficiency as well as save you time. You can use it as per your requirements and flexibility. Here is the list of top 5 python editor: 1. PyCharm 2. Eclipse 3.  Visual Studio Code 4. Spyder 5.  Sublime Text Let's begin to clear your confusion to choose the best. 1. PyCharm PyCharm is a popular integrated development environment (IDE) used primarily for Python development. Developed by JetBrains, it provides a robust set of features for writing, debugging, and deploying Python code. PyCharm offers features such as code completion, syntax highlighting, debugging tools, version control integration, and support for various frameworks and libraries. PyCharm offers comprehensive support for web development with Python, including framework

Lambda Function

A lambda function is a small and anonymous function. "Anonymous function is a function without a name". We can define this function using lambda keyword.

Title Operation Function : Making Title as Slug

Example >> INPUT : myStr = "Legal Counsel 3 - 8 yrs' PQE"  >>  CODE : import re def apply_operation(title): title = unicode(title.lower().strip()) // if not work so just remove unicode title = title.replace('&','') title = re.sub(r'(?s)\s+', r'-', title) title = re.sub(r"(?s)[^a-z-0-9]",r"-", title) title = re.sub(r'(?s)\-{2,}', r'-', title)           return title result = apply_operation(myStr) print(result) >>  OUTPUT : legal-counsel-3-8-yrs-pqe >>  Additional Note : Add the following code if you want to convert non-english to english characters  with "import unicodedata" module. unicodedata.normalize('NFKD', title).encode('ASCII', 'ignore')

String Replace using List method

Example >> INPUT : myStr  = " https://pythonsmallsoultions.blogspot.com/?lang=en&page=0&pageSize=10" myStr_list = myStr.split("&") myStr_list[1] = 'page='+str(1) myStr = "&".join( myStr_list ) >> OUTPUT : https://pythonsmallsoultions.blogspot.com/?lang=en&page1&pageSize=10