DEV Community

Cover image for Battery Included Philosophy, python

Battery Included Philosophy, python

Hi I'm Yusuf, a computer science probationer student. -I want to keep learning and growing both My interpersonal and technical skills so that I can strive to be the most successful version of myself.
・1 min read

Python has a “batteries included” philosophy. This is best seen through the sophisticated and robust capabilities of its larger packages.

Feel free to share with us your experience in handling jobs with one or Built-in modules that will help in day-to-day work.

Discussion (4)

yusufadel profile image
YusufAdel Author

I'll start with,
The sqlite3 module is a wrapper for the SQLite database library, providing a persistent database that can be updated and accessed using slightly nonstandard SQL syntax.

The code needed to make a database connections:
import sqlite3
con = sqlite3.connect('example.db')

create a cursor:
cur = con.cursor()

Now we can excute SQL statment:
cur.execute('''CREATE TABLE stocks
(date text, trans text, symbol text, qty real, price real)''')

Don't forget to close db connection

Full code:

import sqlite3

con = sqlite3.connect('example.db')
cur = sqlite3.curser()



For further reading Here are sqlite3 official docs

hanpari profile image
Pavel Morava

I am sorry to disappoint you, but I am afraid that battery included philosophy is rather a relic of the days when downloading libraries from the internet was not so easy and managed as it is today.

Becoming part of the standard library could even severely undermine further development of given code as it has to follow stricter release of official Pythons.

Even Guido van Rossum said himself that developers should not aim at becoming the part of it.

Moreover, including code grown elsewhere led to rather obvious inconsistency in said batteries.

The modern approach relies on its package managers, in which developers cherrypick what they want to use.

waylonwalker profile image
Waylon Walker

This does provide a more consistent set of core functionality rather than being scattered in dozens of other packages

waylonwalker profile image
Waylon Walker

Itertools is one I use often and I consider it the most underrated standard library module.

The most common function I use is product to get all combinations of a few lists.