Python – Parsing PDFs with Tika
Reading from a pdf is actually quite an easy task with Python. If the PDF is of course “readable”, e.g. made from a word processor. The first thing to do is to install Tika and Java: pip install tika conda …
Reading from a pdf is actually quite an easy task with Python. If the PDF is of course “readable”, e.g. made from a word processor. The first thing to do is to install Tika and Java: pip install tika conda …
After writing about Default Dictionary in Python some time ago, now it is time to take a look at the ordered dictionary and the heap queue as these are built-in structures, coming out of the box. And they are fancy. …
Reading and writing to an Excel ActiveX textbox with Python can be fun. If you really do not have anything better to do. Anyway, if this is your current task, you are on the correct place to see how it …
Python – Read and Write to Excel ActiveX Textbox Read more →
Docstrings in Python are actually quite simple – the are 3 times this “”” and the code between opening and closing them can be formatted in any possible way. The reason I have decided to dedicate a whole article to …
Logging in Python is beautifully implemented with the logging library – https://docs.python.org/3/howto/logging.html It simply does anything you need and you do not need to write something yourself, like I did some time ago here in my VBA Boilerplate. So, if …
Python – Logging in Python. Formatting with Black Read more →
Ok, so you probably have heard about set in Python – it is a collection with non-repeatable elements – as if you are a stamp collector and you need to collect only the unique stamps into your album. However, in …
Python – Multisets – A class to count the elements of a set Read more →
Functions in Python are objects. If this is the first time you read this sentence, then you will not get a lot from this article, but it will show you, that there is quite a lot to learn about Python. …
Python – Writing a Logger in Python with a decorator Read more →
Have you seen the error below? Traceback (most recent call last): File “C:/Users/foo/PycharmProjects/pythonProject3/main.py”, line 29, in <module> main() File “C:/Users/foo/PycharmProjects/pythonProject3/main.py”, line 19, in main a[‘foo’] += 5 KeyError: ‘foo’ Of course you have. And you know, that it is because …
Python – DefaultDict Object. Or how to avoid the Key Error. Read more →
Intersection of dictionary (or of any two lists) is a list with elements, that are present in both other lists. Thus, if we have the following 3 dictionaries in Python: dict_a = dict([(‘aa’, 4139), (‘bb’, 4127), (‘cc’, 4098)]) dict_b = …
Class variables vs instance variables could seem a bit strange, if you have no OOP experience, but after a few thausand lines of code they become logical. So, in around two days of programming you will be getting it intuitively …
__repr__ and __str__ dunders are quite similar in Python. If you need a quick summary of these 2, then these 3 points will be enough: __repr__ dunder presents the class object, whenever it is called by the terminal __str__ dunder …
Python – Difference between __str__ and __repr__ Read more →
The difference between json.dump and json.dumps is actually quite visible: dump() – dumps into a file or StringIO dumps() – dumps a string, that could be printed Still, I am going to give a few example with these, as the …
One of the benefits of having your own blog and not following any schedule for subjects to write about is that you may write for whatever you feel like, whenever you feel like. So, Iterations in Python is the subject …
Making a CRUD application with Python is actually one of the basic thing a Python Developer should be able to do. Although some may argue it is extremely basic – it is not. Requirements The basic requirements for this one, …
Exception handling in python is actually quite an interesting topic. In general, the exceptions in programming could be of three types: syntactic errors – these would be noticed by your IDE or by the interpretor, thus you do not need …
Using API calls with VBA and Python to write a database is actually a pretty decent architecture. Here, I would like to say that “It takes the best of the both worlds”, but the truth is that it takes the …
Using API calls with VBA and Python to Read and Write to a Database Read more →
Months ago, I was planning to take part in the #RailGirls event in Sofia, and I was even a partner in the event. Anyway, as it was postponed up to somewhere in the future, I have decided to go through …
Python – Django Girls – Introduction to Django – Video Read more →
In the previous article for abstraction and inheritance I wrote some classes, showing the basics of these two programming concepts. In this one, I will write unit tests for one of the classes, written before. Software testing is an important …
Python – Writing Unit Tests with unittest library – Video Read more →
Abstract classes in Python are classes that inherit from the ABC (Abstract base class). In the video below, I have solved a problem, showing how 2 classes inherit from an abstract class and implement its methods. The abstract class is …
In this article I am planning to give an answer of the following two questions: What is a closure? A closure is a function, inheriting variables from enclosing environment. Operationally, a closure is a record storing a function together with …
Abstract class and abstract methods are one of the pillars of Object Oriented Programming. In Python, an abstract class is a class, inheriting from Abstract Base Classes (ABC) library. And an abstract method is a method of this class, which …
Python – Abstract Methods and Abstract Class – Live Coding Video Read more →
Long time ago, various people, including me, were trying to make permutations and combinations with nested loops and various other “heavy” structures. Anyway, in Python there is a library, which does this for us and sets the end of the …
Python – Permutations and Combinations Made Easy with Itertools Read more →
Today I have decided to check whether I can pass the first homework from SoftUni OOP with Python, through a live coding session. I have not read the problem before the video, thus I may say it took me exactly …
Python – Defining Classes and Methods with Python – LiveCoding Video Read more →
Cartopy is a Python package designed for geospatial data processing in order to produce maps and other geospatial data analyses. Making a map with Python and Cartopy is actually easier than you might think, but still it has its own …
The Bayes’ theorem is interesting, as far as it is both quite challenging to understand and shocking once you really realize the simplicity of the numbers behind it. It describes the probability of an event, based on prior knowledge of conditions that …
Python – Bayes’ theorem – Drug testing example. 99% is not enough! Read more →
In 2013 and 2014 (wow, already 7 years ago!) I wrote two articles about linear regression with Excel. Now, I am getting more and more interested in Python, thus I guess it would be interesting to remake the article into …
Working with python, pandas and dataframes is quite challenging even for experienced Excel & VBA developer, as I love to consider myself for one. Thus, today I was fighting for quite some time to add new columns to a dataframe, …
Python – Building New Columns in a Dataframe, Based on Other Columns Read more →
The good, the bad and the ugly is a famous western. In Python, “the ugly” is probably the **kwargs, as far as it has two stars before it. Anyhow, the idea of *args, **kwargs and arg is simply to pass arguments. …
Python – *args, **kwargs and the normal ones (arg) Read more →
List comprehension in Python is creation of lists from iterables and other lists, following a condition. It is lightning fast and it looks nice, because it is a 1 liner. In this article, I will show a few examples of …
Today I was “fighting” with the numpy reshape function and I found something strange like matrix.reshape(1, -1). Thus, I have researched quite some time and I found, that the -1 is actually a placeholder for python to change the dimensions …
Python – What is the idea of “-1” in numpy reshape? Read more →