Pylenin Weekly #7

Blogs updates on Python data types, decision making, and for loops. Also, check out youtube comments of the week.

Pylenin Weekly #7

Hello everyone,

Welcome to Pylenin Weekly #7, a newsletter dedicated to improving the lives of my fellow peers through knowledge sharing. This week, we have been busy writing some important articles for you all. Let's take a look at those!

Python Data types

A dictionary is a collection that is ordered, changeable, and does not allow duplicates. It stores data in a key: value pair. Learn about dictionaries from this article.

Dictionaries in Python
A comprehensive guide to using Python dictionaries and different methods associated with it.

Tuples in Python are written as a series of items/objects in a parenthesis. They are immutable objects. Check out this article on tuples containing topics like tuple slicing, common methods used with tuple and tuple swap.

Python Tuples (With Examples)
A comprehensive guide to using tuple data type in Python 3 with examples.

Sets are an unordered collection of unique and immutable objects. It supports mathematical operations from the set theory. Learn about Python sets in this article.

Python Sets (With Examples)
Learn to create and use sets in Python 3 with examples.

Python Decision making

Decision-making is required when we want to execute a code only if a certain condition is satisfied. The if-elif-else statement is used in Python for decision-making.

Python if elif else statements (With Examples)
Learn to evaluate decisions in Python 3 using if, elif and else statements with examples.

Python for loops

The for statement is used to iterate generic sequences in Python like lists, strings, dictionaries, etc. In Python, the for statement iterates over the items in the order that they appear. Learn about for loops in this article.

Python for loops (With Examples)
Learn to perform iterations on Python sequences using for loops with examples.

Introducing ...

I always address the comments on my youtube channel. But I also feel that the same questions might be useful to other people as it could have been a pain point for them earlier(or maybe it still exists!). So I will use this section to address those comments. so you can also learn something!

How to read column name with its data type by CSV module?

The above question was asked in the comments section of "How to read CSV files with Python #2 - Using csv library"

Answer: I don't believe that the CSV module would be of any help for this case at all. CSV reader doesn't perform automatic data conversion. If you are aware of the column types in your csv, you have to map each row. Here is an example.

import csv
from io import StringIO 

data = """True,Lenin,29,94,programmer

reader = csv.reader(StringIO(data), delimiter=",")
data = (({'True':True}.get(row[0], False),
          for row in reader)
for row in data:

>>> (True, 'Lenin', 29, 94, 'programmer')
    (False, 'Sonali', 22, 60, 'analyst')

What if there are many libraries and the zipped folder is >50MB?

The above question was posted in the video of "AWS Lambda Layers Tutorial | Managing Python libraries in a better way".

Answer: You cannot increase the deployment package size for Lambda Layers. AWS Lambda Layers doesn't solve the sizing problem, they just help with management & maybe faster code development.

If your packages are bigger than 50 MB, it just means that AWS Lambda is not the right choice for your problem.

To solve this issue, you have to build your own container. Check out this article from the AWS blog, where they have discussed ways to package and deploy Lambda functions as container images of up to 10 GB in size.

Hope you had a great week! I will see you again next week with some new blogs, thoughts, and Youtube comments of the week.

Subscribe to Pylenin

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.