Hey, Mom! The Explanation.

Here's the permanent dedicated link to my first Hey, Mom! post and the explanation of the feature it contains.

Monday, November 20, 2017

Hey, Mom! Talking to My Mother #867- Machine Love: XOSAR - Musical Monday for 1711.20

Hey, Mom! Talking to My Mother #867 - Machine Love: XOSAR - Musical Monday for 1711.20

Hi Mom,

So, here's how this happened.

This morning I was listening to Machine Love, an Oakland, California based musical group specializing in down-tempo electronica. There's a FACEBOOK group, HERE.

I have also written about MACHINE LOVE on this blog, long before I did the Hey Mom Feature.


So, I wanted to check if the Machine Love, the one from that Facebook group had done anything new since I last checked, but all I did was type "Machine Love" into Google.

Apparently, there's a magazine called Resident Advisor that has a featured series called Machine Love in which journalists "geek out" in producer's studios.

And so I found XOSAR and this article.

It so captured my attention that it DEMANDED to be the Musical Monday for today.

And so, a link to one of the XOSAR albums on Bandcamp and the article.

I will be back next Monday, with this feature (and back tomorrow with something else probably non-musical) and probably some MACHINE LOVE of my own.

Happy Monday.


Upon entering Xosar's Berlin studio, your eyes are drawn to a large wooden box standing conspicuously in the centre of an open-plan space. From the outside, it looks like a free-standing vocal booth built out of scrap wood. But inside, it's something of a shrine. It looks like a place for performing rites, perhaps dedicated to the spirit of the numerous Korg Electribes inside it. Surrounding it, her studio has a diverse range of equipment but again, your eyes are drawn to the huge number of Electribes lying about. There's an arcane energy in the air, as if an exorcism might take place. If Xosar, AKA Sheela Rahman, wasn't such an effervescent host, spirits and demons alike might hesitate at the room's threshold. 

In fact, an exorcism of sorts takes place here every day. Rahman describes her writing process as an act of therapeutic purging, of experiencing and processing internal states through sound. Since bursting onto the scene with creepy deep house 12-inches for L.I.E.S., Rush Hour and Crème Organization, her music has become increasingly introspective. Her recent output is twisted and demonic, but for Rahman herself, it's just a necessary and cathartic emotional release. Over the course of an afternoon, I asked her about balancing unfiltered creativity with the demands of releasing music, fusing yoga with music production, and why she's surrounded by so many Electribes. 

How did you end up in this space? 

I used to have a studio a couple of blocks away but it was a weird environment. I moved all my gear in and finally sat down with a glass of water and all of a sudden I hear these booming drums. My glass was vibrating off the table and I'm just like, "What the fuck is this?" I thought it was a wall of amps and a drum machine. I knocked on the door and it was this cute little group of people playing on massive taiko drums. So then I joined the group and started doing that for a year or so. 

Taiko drumming is pretty demanding stuff. Have you ever had a specific routine for working on your own music? 

This is the most difficult point of being an artist. On the one hand, you can't force creativity. On the other, you want to get stuff done. For me, the best solution is having a community, talking about it with friends and having a sense of accountability and support from other people. I really believe that's the best cure for a lack of discipline. 

Do you ever feel like you should be doing more? Or do you take it as it comes? 

That's another paradox of the artistic profession. The lines get blurry. Some people keep a day job in order to preserve the purity of creation. The work is done only when it needs to be done. It's like writing in a journal—you do it if you have something to express and you express it in that moment. 

The things is, I love making music so much that I want do it all the time as a career. Then you have to start drawing lines of whether you're working on something for a release or whether it's just pure expression. People struggle a lot with reconciling the two. There's tension between making a piece pure versus making it presentable. They're conflicting programs. Sometimes you try and bridge them but you lose the essence of the pure expression. 

For me, right now, I'm having a problem with track lengths. I don't want to cut things too short because the process of making the track is a story in itself. It is an evolving situation and I feel I have to stay true to that, to say, "This is how it is." Then there's pressure to edit it down to make it nice and presentable. In the back of your mind you know it's taking something away. I'm sure every artist has felt this and tried to come up with a way to balance the two. Others just say, "Here's the recording. I won't ever touch it again. This is it." I respect that a lot. To be fair, I have done that sometimes, too. 

Is that what your Bandcamp is for? It gives you more space than a 12-inch. 

There's a hundred reasons but yes, that's one part of it. I know in my head that these tracks need to be together, they need to be in this order, and that's it. If I can't put it on a record, I'll put it on the internet for free. I'm not going to compromise what I have to say. There have been times in the past where I felt the burn of compromising. But it's all a learning experience. I have no regrets but now I'm more refined and don't want to compromise anything. 

Sometimes a label asks you to make tracks for a release. Other times, you've made the tracks already, sent them to a label and then the label offers to release them. Do you have a preference for one or the other? 

I've definitely worked with people who said, "Do whatever you want," and only offered minor advice on things like track order. I've also had situations where they're micromanaging, saying, "You should put this acid line at 16 bars rather than 32." Which is ridiculous. But again, I feel like I needed to go through that to understand how I wanted things to be and what my limits are. Some people thrive under those conditions and want more guidance. Perhaps it was good for me early on. But I really hated it. 

You've obviously put a lot of work into creating a certain type of energy in here. Is this the happiest you've been with a studio? 

I was always looking for a studio, my whole life. I was almost depressed about not having a place where I could be loud whenever I wanted. It makes such a drastic difference to your quality of life when you're free to express yourself whenever you want. There's always been some kind of limitation—a neighbour banging on a wall, or not having enough space. 

Having to move all the time was my big issue. In Berlin, I was moving from sublet to sublet for two years. One month here, two months there. After a while you go a little crazy and just crave your own space. I can't even tell you how fucking ecstatic I am to have found this place. There was four years of searching, waiting, being miserable. And I wanted a place I could design from the ground up. Obviously you can't do that when you're subletting places with someone else's furniture. You feel awkward and small in that environment. 

You have a sizeable amount of equipment here and a lot of pedals. How often are you configuring it into new setups? 

I literally have hundreds of photos of all the different setups I've used in different studios because I like to remember the configurations. The ritual of unplugging everything, moving it around and connecting it all together is like a magic reset button for accessing your creative forces. 

I go through phases with the pedals. Right now I'm really into chaining multiple harmonisers together. Of course, playing around with different types of delays, distortions and reverbs is interesting, but I was always looking for strange pedals. That's where my interest in modular synthesis started because all the weirdest stuff is being made in Eurorack format these days. The Make Noise gear is crazy. 

How often are you packing it all down and starting again? 

I play live so I'm forced to every time I have a gig. In any case, I would normally change it around within two weeks anyway. You know how some people have beautiful studios where everything permanently stays where it is? I could never do that. If I don't move it around I'd go insane. It's like a fresh burst of energy when you change it. 

What stays in the setup no matter the configuration? 

The Elektron Octatrack and an Electribe. Those are the two main things. For a while it was just the Electribe. 

I've never seen so many Electribes in one space before. 

The Electribe is the one thing in my life that I can claim to have mastered. There's something intuitive about them. I don't feel it with the new Electribes but there's something about the layout of the old ones. Somebody put a lot of effort into making sure it feels good, that certain functions are where they need to be. Mapping it with the brain. It makes logical sense. This sets it up for being an easy tool for expression, at least for me. 

It's all about the workflow. You have a pattern, you edit it a bit, save it, copy it to the next pattern, edit it a bit more, save it. Along the way you're building a really detailed composition with a cohesive, linear structure without a computer. It's a natural progression in the moment. Then you can also recreate it live. 

You know how some keyboard players need the keys to be weighted in a certain way so they can put their body force into it? For me, I found it with the Electribe. The way you can bring parts in and out is handled in an elegant way. It's very easy to make fluid transitions between sections. It's not quite so simple on a lot of other machines. 

Why have you got so many of them? 

They break when I tour with them. For example, the master volume breaks in a way where the output becomes mono instead of stereo, which is completely unacceptable because I compose using the full stereo space, from left to right. I'll modulate parts to bounce back and forth every four steps then have another element panning slower, say, every 16 steps. You're mixing down inside the machine. 

Were you using the stock sounds or sampling stuff? 

Every time I got a new Electribe I would wipe it clean and load my own sounds. 

Where would you get the sounds from? 

Everywhere. My own recordings of synths and drum machines, some of them manipulated on the computer and then loaded into the machine. But even though there is a nice sonic palette, it turned out to be a bit limited. Say if you were an amateur painter, your canvas is only so big. It's perfect when you're learning because you need to be able to control this small space. You don't know what you're going to say when you have too much in front of you, but after time your vision gets wider. This is why I moved to the Octatrack. Although it doesn't have the same intuitive flow as the Electribe, the expanded sonic palette gave me much more freedom to express. 

Were any of your early records just taken from the stereo out of an Electribe? 

A lot of them. I remember one time I made a track that I really liked and I was going to release it. But the label was like, "You have to rerecord it, track it all separately" and so on. I spent a long time doing it but it ended up losing something, so I ended up dropping it completely. 

Did you stop using the Electribes live because of the sound? 

It was mostly to do with the sound. It's like working with VHS your whole life and then going to the TV store and seeing all these perfectly crisp images of fish where you can see every scale. 

How does using the Octatrack live compare to the Electribe? 

The Electribe has nine drum patterns and two melodic parts. The Octatrack has eight tracks and eight MIDI channels that you can send to different synths. So on a certain level, they're similar. In a live set with the Octatrack, you're mixing between the different tracks with EQ almost like a DJ. A track might contain a single drum or a texture and you bring them in and out as you go along, moving from pattern to pattern and track to track. Dropping new tracks in suddenly can be harsh if you're a little off with the timing. 

Are you making loops from scratch when you're playing live or is it pre-programmed? 

Usually I get into it later. I have something concrete to start off with. My last set at Tresor was cool because it was mostly improvised. 

What else was onstage with you at Tresor? 

Apart from the Octatrack, I had a Dave Smith Mopho and a Poly Evolver, a few effects and the Electribe. I was considering bringing a guitar and an amp, too, because I've been using them for a lot of textural, noisy stuff. 

And you're taking a direct line out of the amp onstage rather than using a mic? 

Yeah, out of the amp, through a lot of pedals and into the mixer. I only do more complex stuff like this in Berlin because I can carry all the equipment easily. Next time I play here I'll use a crazy setup for sure. 

I assume you're not playing the guitar in a traditional way. How are you getting sounds out of it? 

I always tune it differently. I have a collection of objects in different materials, shapes and sizes that I use to get different sounds from the strings. For instance, I use a little roller that's used for massaging your face. It looks like a tiny rolling pin. 

The Octatrack is notoriously painful to learn. How did you fare with it? 

It took me three years to get to the level I'm at now. Learning how to make a beat takes a day but then mastering it really takes years. It's mostly to do with muscle memory and practice. You have to double tap and hold down combinations of buttons to access certain functions. It takes time to ingrain it in your memory so that you can do it fast. It's like learning a new language. You're trying to have a conversation in German but you can't express the idea fast enough to keep up with the natural flow of the conversation. Once you're fluent with the machine, you can express yourself more accurately. 

I read that you transcribed the entire Octatrack manual in different colours in order to memorise it. 

I have a lot of notebooks. I need them when I'm learning a machine so that I'm not forgetting everything, which is very easy to do. You can watch a tutorial and think you understand a function and then you forget how you even got there. Every time I come across a certain technique that I'm really into, I write it down so I can return to it instantly. I use different colour inks to convey different energies. "Do not hit function and clear or you delete your entire pattern and you can't undo it" is in red. Reviewing the notes is really important to me. 

While I was spending so much time learning the Octatrack and other gear, I had a realisation that the human body is also a type of machine. Learning the intricacies of how that machine works will ultimately help you in whatever production you're doing. Whether it's increasing your stamina to work longer and harder or increasing your focus. 

I decided last year to attend a school for energy healing and yoga. I got my license to be a yoga instructor. For me, this knowledge aligned metaphorically with the technical stuff I was learning with the machines. Learning how the energy circuits of your body work—it's like your body is a giant modular system, only you're making connections with yoga positions rather than patch cables. Each pose is connecting a new energetic circuit. I consider the body to be the most important machine in my productions.

What yoga positions are beneficial for producers? 

It was a bit of a joke but recently I was posting stuff online about undoing the physical damage caused by producing music. I like to say that I get "octaneck" from looking down at that tiny screen all day. Upward facing dog counters the hunched position most people adopt when they're making music. Neck rotations and shoulder rotations are good, too. Basic chest-opening exercises. Little things like getting up and touching your toes make a big difference, especially when you do it regularly. 

A lot of my yoga students are artists and musicians, and many of them have physical problems from making art all day. I feel like my job lately has been to help people heal their bodies and to get them more in harmony with their craft so that they're not abusing their bodies in their creative work. It's very simple just to listen to your body. 

Has being more aware of your body influenced how you work? 

I did a release on my label called Show Yourself with a track titled "Manmeat PCP." There's a synth line that's just a single note going through a distortion pedal and I was really angry when I made it. It was one take of modulating the synth and the pedal and I was throwing my whole body force into it. You know how people use gestures in a conversation? It says something that words can't. In this case, the body force gives a spring to the sound and it has a different layer of energy. There's a human essence. I want to bang on more shit. 

You had a stint in an engineering school. Did you have a positive experience? 

Everyone on the face of the earth thrives off different ways of learning. Some people need to be alone. Some need to read the manual. Some people can only interact with the machine itself. Others thrive off being in a learning environment and having other people around to engage in dialogue and ask questions. My favourite way to learn is in a community setting where there are like-minded people who can support you and give you information. 

Do you feel like the technical aspect of making music overinflates its importance to the detriment of other factors? 

Yeah. I'm always interested in meeting people who dropped out of something. They played some instrument then they quit; they went to art school but they quit; they went to audio engineering school but they quit. I feel that people who have a strong vision just need to get the basics down and then they're done. It depends on what the person is trying to do, but too much information can pollute the expression process. It depends on what the person is trying to do with their life. 

I think the issue is that relying on this external knowledge can create a loss of intuition. You're potentially disempowering your intuitive voice. That's definitely a problem with music school, art school and so on. Even the entire school system programs you to learn in a manner where you have an authority figure telling you the unassailable truth. It's important to learn how to feel for yourself and never ever to take anyone else's word as truth. Never form an opinion immediately, just take in the information and come to your own conclusions. 

You're known primarily as a live performer. Did you get into club music through listening to productions or actually going out? 

My parents didn't let me listen to much music with words in it. They took away all my rap CDs. But 160 BPM pystrance was allowed. They thought rap would make me a bad girl. Little did they know that the aggressive psytrance would make me even badder! 

Your sound took a pretty clear turn around 2014. Was this to do with changing your environment or equipment? 

The gear was definitely part of it. I'm still learning and developing so these changes can be confusing or jarring to people on the outside but it'll all come together in the end. All the music is going to convey my essence, even though it's harder now to get it out of these new machines. In terms of the linear progression of my output, the last thing I put out on Bandcamp sounds new and different from my other work but it's actually extremely old. They're some of the first tracks I ever made. 

It's hard for an artist to carve out a space and be understood as who they are now. There's a struggle in every artist to align their output with what they're all about at any given moment because it takes so long to get anything out. One release takes two years, another takes six months, then I put out something brand new and then another old thing. I guess it's just how it is and the best thing to do is explain yourself, which I suck at. Hopefully at the end of the day people will see the big picture. I'm not worried. 

What was the response like to your changing sound? 

In the beginning it was a lot harder but I think people came around to it. If you're known for a sound, it's hard to do something even slightly different. Human psychology wants to understand and categorise things. It's human nature. But you progress in a chaotic way depending on what you're exposed to. For me, it was just a natural progression. 

A lot of so-called dark or angry music feels like so much more of an emotional release to me now. Every style of music serves a different function for the person making it, depending on their intention. People started saying my music was becoming more aggressive but for me it was a pleasurable way of releasing emotions. That's the whole idea behind the label I started. We have these demons inside of us and making music is a way of exorcising them. By feeling them fully and processing them through sound, I felt lighter. It was therapeutic. 


Reflect and connect.

Have someone give you a kiss, and tell you that I love you, Mom.

I miss you so very much, Mom.

Talk to you tomorrow, Mom.


- Days ago = 869 days ago

- Bloggery committed by chris tower - 1711.20 - 10:10

NEW (written 1708.27) NOTE on time: I am now in the same time zone as Google! So, when I post at 10:10 a.m. PDT to coincide with the time of your death, Mom, I am now actually posting late, so it's really 1:10 p.m. EDT. But I will continue to use the time stamp of 10:10 a.m. to remember the time of your death, Mom. I know this only matters to me, and to you, Mom.

Sunday, November 19, 2017

Hey, Mom! Talking to My Mother #866 - Python- A case for "self" in classes

enter image description here

Hey, Mom! Talking to My Mother #866 - Python- A case for "self" in classes

Hi Mom,

Today. we're back to the content that is my study and not my teaching and lately I have been studying Python.

A few weeks ago in my studies I was curious about the use of "self" in classes. I was pretty sure that it was similar to the use of "this" in the other programs, like Java, to denote the object itself during instantiation (making an instance) of the class.

One of the things I like to do with my blog, now, in the second year is use it as a place to store material that I am studying, and then to aggregate some of that material in a place where people can find it in a search on the subject.

Lots of texts on Python will imply that "self" is required more so than a convention. I prefer "self" for calls to the class object to "this" that is used in other languages, such as Java: THIS KEYWORD. In Java, "this" is a keyword, meaning it is a word reserved to refer to an instance of the class in the constructor and used for initializing variables or referring to members of the class. But unlike Java, in Python, self is set up explicitly in the "constructor" or __init__ method of the class.

I like that what I have collected here both explains "self" a s a convention for referencing an object, but also shows Python creator Guido Van Rossum's remarks on his own blog in response to a proposal to make "self" a reserved keyword in Python.

I know, Mom, and many of my regular readers, this is outside your interest, probably (unless I have new coding readers), but this is my study more often than my teaching, and I have finished my grading for the week, so I can post this one. I have been noodling it for quite some time.

So, this is a good collection of material about the use of "self" and the debate about its use a s a convention rather than a reserved keyword all collected here for your convenience. If you're studying Python and found this through search, leave me a comment.




The self variable in python explained

Hi there fellas. In this post I am going to teach you about the selfvariable in python. I have seen many beginners struggling to grasp the concept of self variable. If you are one of them then this post is for you. So lets start by making a class involving the self variable.
A simple class :
So here is our class:
class Restaurant(object):
    bankrupt = False
    def open_branch(self):
        if not self.bankrupt:
            print("branch opened")
First let me explain the above code without the technicalities. First of all we make a class Restaurant. Then we assign it a property “bankrupt” which is currently false. After that we assign it a function open_branch which can only occur if “bankrupt” is False which means that the Restaurant has some money.
Making a resturant:
Now that we have made a class for a Restaurant, lets actually make a resturant:
x = Restaurant()
Now x is a Restaurant which has a property bankrupt and a function open_branch. Now we can access the property bankrupt by typing:
The above command is same as:
Now you can see that self refers to the bound variable or object. In the first case it was x because we had assigned the Restaurant class to x whereas in the second case it referred to Restaurant(). Now if we have another Restaurant y, self will know to access the bankrupt value of y and not x. For example check this example:
>>> x = Restaurant()
>>> x.bankrupt

>>> y = Restaurant()
>>> y.bankrupt = True
>>> y.bankrupt

>>> x.bankrupt
The first argument of every class method, including init, is always a reference to the current instance of the class. By convention, this argument is always named self. In the init method, self refers to the newly created object; in other class methods, it refers to the instance whose method was called. For example the below code is the same as the above code.
class Restaurant(object):
    bankrupt = False
    def open_branch(this):
        if not this.bankrupt:
            print("branch opened")
Free Tip:
However self is not a reserved keyword in python it’s just a strong convention. Many people say that why do we have to write self ? Why can’t we have it set automatically like in Java ? Someone also filed a PEP (improvement suggestion) in which he suggested to remove the explicit assignment of self keyword. However Guido Van Rossum (the maker of python) wrote a blogpost in which he told why explicit self has to stay.
I hope you have understood to concept of self. If you have any other questions then feel free to comment. If you liked this post then make sure that you share it on facebook, tweet it on twitter and follow our blog.



I like this answer..........................................

When objects are instantiated, the object itself is passed into the self parameter.
enter image description here
Because of this, the object’s data is bound to the object. Below is an example of how you might like to visualize what each object’s data might look. Notice how ‘self’ is replaced with the objects name. I'm not saying this example diagram below is wholly accurate but it hopefully with serve a purpose in visualizing the use of self.
enter image description here
The Object is passed into the self parameter so that the object can keep hold of its own data.
Although this may not be wholly accurate, think of the process of instantiating an object like this: When an object is made it uses the class as a template for its own data and methods. Without passing it's own name into the self parameter, the attributes and methods in the class would remain as a general template and would not be referenced to (belong to) the object. So by passing the object's name into the self parameter it means that if 100 objects are instantiated from the one class, they can all keep track of their own data and methods.
See the illustration below:
enter image description here




Reading Time : ~ .

Before understanding the "self" and "__init__" methods in python class, it's very helpful if we have the idea of what is a class and object.
Class : 
Class is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.
In technical terms we can say that class is a blue print for individual objects with exact behaviour.
Object :
object is one of instances of the class. which can perform the functionalities which are defined in the class.
self :
self represents the instance of the class. By using the "self" keyword we can access the attributes and methods of the class in python.
__init__ :
"__init__" is a reseved method in python classes. It is known as a constructor in object oriented concepts. This method called when an object is created from the class and it allow the class to initialize the attributes of a class.
How can we use  "__init__ " ?
Let's consider that you are creating a NFS game. for that we should have a car. Car can have attributes like "color", "company", "speed_limit" etc. and methods like "change_gear", "start", "accelarate", "move" etc.

class Car(object):
  blueprint for car

 def __init__(self, model, color, company, speed_limit):
  self.color = color
  self.company = company
  self.speed_limit = speed_limit
  self.model = model

 def start(self):

 def stop(self):

 def accelarate(self):
  "accelarator functionality here"

 def change_gear(self, gear_type):
  print("gear changed")
  " gear related functionality here"
Lets try to create different types of cars
maruthi_suzuki = Car("ertiga", "black", "suzuki", 60)
audi = Car("A6", "red", "audi", 80)
We have created two different types of car objects with the same class. while creating the car object we passed arguments  "ertiga", "black", "suzuki", 60  these arguments will pass to "__init__" method  to initialize the object. 
Here, the magic keyword "self"  represents the instance of the class. It binds the attributes with the given arguments.
Usage of "self" in class to access the methods and attributes
Case: Find out the cost of a rectangular field with breadth(b=120), length(l=160). It costs x (2000) rupees per 1 square unit
class Rectange:
   def __init__(self, length, breadth, unit_cost=0):
       self.length = length
       self.breadth = breadth
       self.unit_cost = unit_cost
   def get_perimeter(self):
       return 2 * (self.length + self.breadth)
   def get_area(self):
       return self.length * self.breadth
   def calculate_cost(self):
       area = self.get_area()
       return area * self.cost
# breadth = 120 cm, length = 160 cm, 1 cm^2 = Rs 2000
r = Rectangle(160, 120, 2000)
print("Area of Rectangle: %s cm^2" % (r.get_area()))
print("Cost of rectangular field: Rs. %s ", %(r.calculate_cost()))
As we already discussed  "self" represents the same object or instance of the class. If you see, inside the method "get_area"  we have used "self.length" to get the value of the attribute "length".  attribute "length" is bind to the object(instance of the class) at the time of object creation. "self" represents the object inside the class. "self" works just like "r" in the statement  "r = Rectangle(160, 120, 2000)".  If you see the method structure "def get_area(self): "  we have used "self" as a parameter in the method because whenever we call the method  the object (instance of class) automatically passes as a first argument along with other argumets of the method.If no other arguments are provided only "self" is passed to the method. That's the reason we use "self" to call the method inside the class("self.get_area()").  we use object( instance of class) to call the method outside of the class definition("r.get_area()"). "r" is the instance of the class, when we call method "r.get_area()"  the instance "r" is passed as as first argument in the place of self.
r = Rectangle(160, 120, 2000)
Note: "r" is the representation of the object outside of the class and "self"  is the representation of the object inside  the class.
for more details please visit python documentation



Why explicit self has to stay

Bruce Eckel has blogged about a proposal to remove 'self' from the formal parameter list of methods. I'm going to explain why this proposal can't fly.

Bruce's Proposal

Bruce understands that we still need a way to distinguish references to instance variables from references to other variables, so he proposes to make 'self' a keyword instead. Consider a typical class with one method, for example:
class C:
   def meth(self, arg):
      self.val = arg
      return self.val
Under Bruce's proposal this would become:
class C:
   def meth(arg):  # Look ma, no self!
      self.val = arg
      return self.val
That's a saving of 6 characters per method. However, I don't believe Bruce proposes this so that he has to type less. I think he's more concerned about the time wasted by programmers (presumably coming from other languages) where the 'self' parameter doesn't need to be specified, and who occasionally forget it (even though they know better -- habit is a powerful force). It's true that omitting 'self' from the parameter list tends to lead to more obscure error messages than forgetting to type 'self.' in front of an instance variable or method reference. Perhaps even worse (as Bruce mentions) is the error message you get when the method is declared correctly but the call has the wrong number of arguments, like in this example given by Bruce:
Traceback (most recent call last):
File "classes.py", line 9, in
TypeError: m2() takes exactly 3 arguments (2 given)
I agree that this is confusing, but I would rather fix this error message without changing the language.

Why Bruce's Proposal Can't Work

Let me first bring up a few typical arguments that are brought in against Bruce's proposal.

There's a pretty good argument to make that requiring explicit 'self' in the parameter list reinforces the theoretical equivalency between these two ways of calling a method, given that 'foo' is an instance of 'C':
foo.meth(arg) == C.meth(foo, arg)

Another argument for keeping explicit 'self' in the parameter list is the ability to dynamically modify a class by poking a function into it, which creates a corresponding method. For example, we could create a class that is completely equivalent to 'C' above as follows:
# Define an empty class:
class C:

# Define a global function:
def meth(myself, arg):
   myself.val = arg
   return myself.val

# Poke the method into the class:
C.meth = meth
Note that I renamed the 'self' parameter to 'myself' to emphasize that (syntactically) we're not defining a method here. Now instances of C have a method with one argument named 'meth' that works exactly as before. It even works for instances of C that were created before the method was poked into the class.

I suppose that Bruce doesn't particularly care about the former equivalency. I agree that it's more of theoretical importance. The only exception I can think of is the old idiom for calling a super method. However, this idiom is pretty error-prone (exactly due to the requirement to explicitly pass 'self'), and that's why in Python 3000 I'm recommending the use of 'super()' in all cases.

Bruce can probably think of a way to make the second equivalency work -- there are some use cases where this is really important. I don't know how much time Bruce spent thinking about how to implement his proposal, but I suppose he is thinking along the lines of automatically adding an extra formal parameter named 'self' to all methods defined directly inside a class (I have to add 'directly' so that functions nested inside methods are exempted from this automatism). This way the first equivalency can be made to hold still.

However, there's one situation that I don't think Bruce can fix without adding some kind of ESP to the compiler: decorators. This I believe is the ultimate downfall of Bruce's proposal.

When a method definition is decorated, we don't know whether to automatically give it a 'self' parameter or not: the decorator could turn the function into a static method (which has no 'self'), or a class method (which has a funny kind of self that refers to a class instead of an instance), or it could do something completely different (it's trivial to write a decorator that implements '@classmethod' or '@staticmethod' in pure Python). There's no way without knowing what the decorator does whether to endow the method being defined with an implicit 'self' argument or not.

I reject hacks like special-casing '@classmethod' and '@staticmethod'. I also don't think it would be a good idea to automagically decide whether something is supposed to be a class method, instance method, or static method from inspection of the body alone (as someone proposed in the comments on Bruce's proposal): this makes it harder to tell how it should be called from the 'def' heading alone.

In the comments I saw some pretty extreme proposals to save Bruce's proposal, but generally at the cost of making the rules harder to follow, or requiring deeper changes elsewhere to the language -- making it infinitely harder to accept the proposal as something we could do in Python 3.1. For 3.1, by the way, the rule will be once again that new features are only acceptable if they remain backwards compatible.

The one proposal that has something going for it (and which can trivially be made backwards compatible) is to simply accept
def self.foo(arg): ...

inside a class as syntactic sugar for
def foo(self, arg): ...

I see no reason with this proposal to make 'self' a reserved word or to require that the prefix name be exactly 'self'. It would be easy enough to allow this for class methods as well:
def cls.foo(arg): ...
Now, I'm not saying that I like this better than the status quo. But I like it a lot better than Bruce's proposal or the more extreme proposals brought up in the comments to his blog, and it has the great advantage that it is backward compatible, and can be evolved into a PEP with a reference implementation without too much effort. (I think Bruce would have found out the flaws in his own proposal if he had actually gone through the effort of writing a solid PEP for it or trying to implement it.)

I could go on more, but it's a nice sunny Sunday morning, and I have other plans... :-)



Reflect and connect.

Have someone give you a kiss, and tell you that I love you, Mom.

I miss you so very much, Mom.

Talk to you tomorrow, Mom.


- Days ago = 868 days ago

- Bloggery committed by chris tower - 1711.19 -10:10

NEW (written 1708.27) NOTE on time: I am now in the same time zone as Google! So, when I post at 10:10 a.m. PDT to coincide with the time of your death, Mom, I am now actually posting late, so it's really 1:10 p.m. EDT. But I will continue to use the time stamp of 10:10 a.m. to remember the time of your death, Mom. I know this only matters to me, and to you, Mom.