loader

[ad_1]

What is e-poetry, and how can it make you a better programmer?

A Python programming file containing part of a love poem on a wooden desk.
This file is named love.py and forms together with the file poem.py a love poem about intimacy as a complex and challenging but ultimately rewarding experience.

Python has the potential to be one of the most beautiful languages in the world. Actions speak louder than words, but the truth is also in the eye of the beholder.

E-poems are often short and concise and can also be very complex and nuanced. This means that every word and phrase must be carefully chosen in order to convey the desired meaning. Writing e-poems pushes you to choose variable names that are both descriptive and valid, and makes you mindful of how they will affect the readability and maintainability of your code.

Python poem project

I initiated the project by writing a class in a file named love.py including functions that assemble the output of the code.

class Twosomeness:

def __init__(self, noun, adjective, verb):
self.noun = noun
self.adjective = adjective
self.verb = verb

def what(self):
print("Intimacy is a journey, a dance, a " + self.noun[0])
print("it's a feeling that generates " + self.noun[1])

def why(self):
print("Intimacy makes us " + self.adjective[0])
print("it helps us to face our fears and grow " + self.adjective[1])

def how(self):
print("Give and receive, returning equal " + self.verb[0])
print("and let your love mature with " + self.verb[1])

Then I named the main file poem.py just for the pun – love poem.

from random import choice
from love import Twosomeness

nouns = {
"blindness": "kindness",
"heart": "art",
"kiss": "bliss",
"hug": "snug",
"caress": "mess"
}
noun_pair = noun, rhymeword = choice(list(nouns.items()))

adjectives = {
"longer": "stronger",
"passionate": "compassionate",
"demanding": "understanding",
"playful": "grateful"
}
adjective_pair = adjective, rhymeword = choice(list(adjectives.items()))

verbs = {
"cuddle": "snuggle",
"turns": "burns",
"kisses": "hisses",
"petting": "sweating"
}
verb_pair = verb, rhymeword = choice(list(verbs.items()))

intimacy = Twosomeness(noun_pair, adjective_pair, verb_pair)

intimacy.what()
intimacy.why()…

[ad_2]

Source link