Python QA - doraithodla/notes GitHub Wiki
can you give me some python library ideas that I could build an publish myself?
Pytutor: Here are some Python library ideas that you could build and publish:
-
Date and Time Library: A library that simplifies date and time manipulation in Python.
-
Text Processing Library: A library that simplifies natural language processing tasks such as tokenization, stemming, and sentiment analysis.
-
Image Processing Library: A library that simplifies image processing tasks in Python, such as resizing, cropping, and filtering.
-
CSV Handling Library: A library that makes it easy to read, write, and manipulate CSV files.
-
Web Scraping Library: A library that simplifies web scraping tasks in Python, using frameworks such as BeautifulSoup and Scrapy.
-
CLI Application Framework: A library that simplifies the creation of command-line applications with Python.
-
File System Library: A library that adds functionality for file system operations such as reading, writing, and copying files within Python code.
My comments:
- Many of these libraries already exist so you just want to build simpler versions.
Question: Suggest me to learn oops concept in python: Anser: We will cover this in either the next session or the one following. I need to do it with examples that you can all relate to. Also unless you can program in the large, you will appreciate the advantages of OOP.
Question: What methods do you utilize to manage errors and exceptions in your Python code, and what strategies do you follow for debugging and testing?
PyTutor: - In Python, we can handle errors and exceptions using the try-except block. The code block inside the try block is executed, and if an error occurs, we catch it inside the except block. Here is an example:
try:
num1 = 10
num2 = 'a'
result = num1 / num2
except Exception as e:
print("Error: ", e)
In this example, we are trying to divide an integer by a string, which is not possible. So, we catch the error inside the except block and print the error message.
For debugging and testing, we can use the Python debugger `pdb`. It allows us to inspect the code, and check the value of variables at any point during the program execution. We can set breakpoints and step through the code to find the exact location of the error.
For testing, we can use the built-in Python `unittest` library which provides various tools for writing and running tests. We can write test cases for our functions, and ensure that they work correctly under different conditions. It is a good practice to write tests for all our code and run them frequently to catch errors early.
6 Mar, 10:48 pm
We will cover this in a future session
There may be other higher order libraries like shapes library (build different shapes) with or without Turtle