Skip to content

Instantly share code, notes, and snippets.

__repr__ __str__
Provides an unambiguous string representation of an object. Provides a human-readable string representation of an object.
Mainly intended for developers and debugging purposes. Intended for end-users and display purposes.
If not explicitly defined, Python will use the default implementation. If not explicitly defined, Python will call the __repr__ method as a fallback.
@yeaske
yeaske / startup_vs_micro-startup.csv
Created January 1, 2023 22:25
comparison between a traditional startup and a micro startup:
Traditional Startup Micro Startup
Large team Small team
Broad focus Narrow focus
Higher overhead costs Lower overhead costs
Greater scalability potential Limited scalability
More expertise and experience Limited expertise
Greater market potential Limited market potential
Higher risk Lower risk
May take longer to get off the ground May be able to get off the ground more quickly
print(f"Total number of elements in list: {len(object_list)}")
# for obj in object_list:
# print(obj)
# Create a set from the list of objects
object_set = set(object_list)
# OR
books = [
{
"author": "Chinua Achebe",
"title": "Things Fall Apart",
"year": 1958
},
{
"author": "Hans Christian Andersen",
"title": "Fairy tales",
"year": 1836
class Book:
title = None
author = None
year = None
def __init__(self, author, title, year):
self.author = author
self.title = title
self.year = year
@yeaske
yeaske / binary_tree.py
Created November 27, 2018 03:08
Binary Tree in Python
class Node:
def __init__(self, data):
self.data = data
self.left, self.right = None, None
def __str__(self):
return str(self.data)
def insert(self, data):
if self.data: