Burning, the roads through my mind are on fire

Burning, the roads through my mind are on fire

Marika Hackman's 'before I sleep' is just the best. I wanted to quote it again today.

Constructors in Python are so hard I needed a separate blog post for them.
A goddess, a beautiful young woman with dark blue skin and hair and a silver crown and dressed in blue and silver armour stands in front of the moon.
Nyx, the Goddess of the Night

Constructors in Python

I asked Chat GPT to explain things to me but it still didn't really help.

I understand NOTHING but here's some code that I wrote:

class Circle:
pi = 3.14
# Add constructor here:
def __init__(self, diameter):
print("New circle with diameter: {} ".format(diameter))
teaching_table = Circle(36

Like as in absolutely NOTHING.

Instance Variables

Oh no even more complicated stuff. Oh so help me God please help me.

Classes vs. Objects - courtesy of Chat GPT

Class

A class is like a blueprint or template for creating objects.

It defines the structure and behaviour that all instances of the class will have. 

This includes methods.

And class variables.

Object (Instance)

An object is a specific instance of a class. 

When you create an object, you're creating a unique entity that has its own set of attributes and behaviours.

These unique attributs are known as INSTANCE VARIABLES AND THEY ARE UNIWUE TO EACH INDIVIDUAL OBJECT.

"This flexibility allows us to model real-world entities more accurately and efficiently in our programs."

Attribute Functions

Oh no.


What on earth is this.

Okay so this last bit now makes a bit more sense now thank you:


Winter has been unbelievably tough this year for me what with the layoffs and everything at work. I cannot wait for the summer!

So for example, what does the one with the optional parameter look like?

So getattr() can have a default value that we have provided for it, that it returns, if an attribute doesn't exist, instead of an error. I seeeeeeee thank you. Thank you.

Self

I did the lesson on it and no need to right it down. At my level it reminds me of this in JavaScript. I never got it fully but I can do it...

Might leave it there for the blog post for today but let's see...

dir()

dir = /is short for, directiory.

...

"Python automatically adds a number of attributes to all objects that get created"

I am doing this because I love renewable energy. I am here in my office at 4.15 on a weekend having been in here every day for days... for weeks... because I love renewable energy. Because I love it so so much. Because I love it most in the world. And that is what I'm supposed to do. That is what I'm supposed to do. That is what I'm supposed to do.

💖💜

String Representation

My meditation teacher once said to me: 

"It's beautiful. You're following what you love. It's beautiful".

In fact... every time I talked to him about my career path, he could only refer to it as ... "beautiful".

I want to believe that it is beautiful too.

I want to believe that it is beautiful too today. Thank you.

Man Shall Not Live By Bread Alone

A first for Susanna Codes... I am quoting the Bible.

The material world isn't enough to live on.

You have to have faith and belief and hope sometimes.

I have to have faith and belief and hope sometimes.

Having just learned Python in 10 days, I am exhausted... I have to have faith and belief and hope.

I have to have faith and belief and hope... I have to have faith and belief and hope that this will all work out now. Thank you.

String Representation, part II

Aha! Here is another dunder method! It's called:

__repr__

"This is a method we can use to tell Python what we want the string representation of the class to be."






Comments

Popular posts from this blog

Hello World

Yosemite

Two Lines of Thought, Makes Me Wonder What I'm Missing