Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
99 views

Scraping website with Python and Selenium to collect data from dynamic website

Summary: The code scrapes the website and collects the data to store it in CSV. It also downloads selected information that is available for download in PDF format. The details and the entire code are ...
sangharsh's user avatar
  • 269
2 votes
2 answers
197 views

Checking file header for magic number in Python

I wrote this to check files for successful compression with LZ4. Any advice is welcome. Particularly regarding raising exceptions and error handling. ...
voices's user avatar
  • 767
1 vote
1 answer
198 views

Python exception for handling invalid argument types

Greetings One small problem that anyone have to tackle with in Python is handling invalid argument types ( without an automatic static type checking tool like Mypy ) One of the best methods for ...
KhodeNima's user avatar
  • 419
3 votes
2 answers
486 views

Hardware API, primarily for Error handling

I have a piece of equipment that I am interacting with. The manufacturer provided an SDK and some simple examples of how to interact with the device. However, I need to write an API for interacting ...
Michael's user avatar
  • 303
1 vote
1 answer
135 views

Two versions of user-specified exception filters that log a different message on match

I'd like to show you two versions of my two functions that support my logging tools. Their purpose is to log a different message (here abort) when an error occured ...
t3chb0t's user avatar
  • 44.6k
1 vote
1 answer
410 views

Protecting functions from empty DataFrames

Pandas likes to throw cryptic errors when you feed its functions with empty DataFrames saying nothing that would help you to identify the root cause. In order to ...
t3chb0t's user avatar
  • 44.6k
1 vote
1 answer
235 views

Function to return a file name from lists/dictionary constants

I'm reworking a set of two functions that return a text file name, constructed from a string argument and string variables from a module called inventory. It seems ...
Dan's user avatar
  • 301
3 votes
1 answer
76 views

Cancelling function execution with a ContinuationError

Although throwing excptions for control flow is a controversial topic there are some quite popular examples of using this anti-pattern like C#'s async routines throwing the ...
t3chb0t's user avatar
  • 44.6k
3 votes
1 answer
170 views

Take in 10 numbers, validate each input, append then in a list and then prints the sum of the list values

I'm practicing loops in Python and started trying to have a better approach with user inputs, is there better ways of dealing with inputs when coding? And I tried using deques too, it worked very well,...
eddyxide's user avatar
  • 141
3 votes
1 answer
100 views

Sending a CSV file for a client list from a database

What can I improve about this code in order to be production-ready? I'm not worried about security but about errors that could occur. What exceptions should I catch? I feel overwhelmed about ...
escarta's user avatar
  • 43
4 votes
0 answers
87 views

Error handling best practices using a custom error handling module

I am trying to learn how to effectively use error handling in my code. To do this, I have created a class inside main.py which reads the value of a specified curve ...
John Smith's user avatar
1 vote
3 answers
1k views

Custom exception handling function or logging library?

I want to document every exception handled in my code and some states of the code when it works properly. What I've done is two functions, one that creates an 'error report' (function: ...
Lucas Fernandez's user avatar
-3 votes
3 answers
99 views

Opinion on Python exceptions? [closed]

Just looking for opinions on which is the best way to use exceptions? Should the exception handling go inside the function or should it go outside the function when you actually call the function. ...
alicia johnson's user avatar
1 vote
1 answer
79 views

File handling with try and except [closed]

I am learning programming with Python. I am not sure if I can write a try/except block like this. ...
Gunasekar Desaiyan's user avatar
4 votes
1 answer
2k views

Minesweeper - Python 3 (beginner)

I’ve just created Minesweeper game, which work perfectly fine (for me). Any suggestions on how to improve this code would be greatly appreciate, in terms of: Object-oriented Array Error handling ...
uchaosis's user avatar

15 30 50 per page