Object Modularity Thoughts - Intermediate Python Programming p.16

preview_player
Показать описание
Welcome to part 16 of the intermediate Python programming tutorial series. In this part of the series, we're going to discuss the modularity of the class we wrote.

Рекомендации по теме
Комментарии
Автор

You could use the unpacking operator * to save you from writing [0] and [1] all the time. For example:

self.size = random.randrange(*size_range)

Then you could have x_range and y_range rather than x_boundary, so all your arguments would expect tuples.
Just a suggestion. :)

Enjoying the series. Thanks for making these videos!

elmarzimmermann
Автор

For me, this video was the clicking moment for OOP. Thank you so much for your tutorials. You've made learning python really enjoyable.

goobypls
Автор

Just came across a nice way that saves you adding all the arguments one by one to the class namesspace:

def __init__(self, color, **kwargs):

That makes the init method much shorter/cleaner!

elmarzimmermann
Автор

Hi, sentdex, good video as usual. The way I see the "Boundaries" is that the full blob has to lie inside the white area. Do you think we should take into consideration the radius of the blob when we initialise variables like self.x_boundary and self.y_boundary?
That is, in the init method:
radius = 0.5 * self.size
self.x_boundary = x_boundary - radius
self.y_boundary = y_boundary - radius
self.x = random.randrange(radius, self.x_boundary)
self.y = random.randrange(radius, self.y_boundary)
This way the blob is guaranteed inside the boundaries.
Happy new year to you.

daniellin
Автор

why does movement_range's -ve value have to be one lower than +ve, else there's a high bias towards moving towards one direction?

abhitruechamp
Автор

Is size_range and movement_range a list? But why you use size_range = (4, 8) instead of size_range = [4, 8]??

PavelIvanovskii
Автор

In movement_range[0], movement_range[1], why are we giving 0 - 1 as element range in the tuple ?

rohan
Автор

Please make other raspberry pi robotic tutorials... thanks

riseoftechk
Автор

I don't want to call it blob.py, eh let's call it blob.py

marcinkovalevskij
Автор

i think your videos can be a little shorter, i dont know why but it sometimes gets really exhausting to watch your 15 min video

ahbarahad