Jedi/Rockstar/Ninja in Development

How I'm learning to be a master coder

hide

Read Next

Some things I didn't know about Python

I just did my first interview in Python and it turns out I made the switch from Java prematurely. Disaster. Here are some things I didn't know.

Constructor overloading. Function overloading is when a function with the same name is defined in two different ways and distinguished by its parameters. In particular, constructor overloading would allow you to instantiate a class in two different ways. Say a rational number that is defined either by two ints as a/b or by one float. Does Python have function overloading? I didn't know.

It turns out Python is quite flexible in its parameters and relies on that flexibility rather than method overloading. So for the rational number example, you could either have two optional parameters and check them, or you could have a dictionary datatype where you check.

Throwing exceptions. The interviewer was insistent that my class constructor conform to the two constructor options, so my suggestion was to check the parameters and throw an exception when it didn't work. Of course, I didn't know how. The keyword in Python is raise, and it can either be called alone or with an exception object (which can be user-defined). See more at http://docs.python.org/2/tutorial/errors.html

Identity testing. Later, I wanted to test if two objects were the same object in memory. I suggested == but it turns out this does a value equality test. For a custom class, you need to define an __eq__ function to determine equality and without that == is true only if they are the same object (though I'm not completely sure about this). So technically I think it worked. But the right way to test for the same object in memory is Python's is keyword:

Python for Data mining and Analytics

On The Learning Curve

Python is probably one of the easiest language to learn and with the strong adoption rate from the programming community, I think it is worth it to invest time in learning python.

My journey with python started with a course of Artificial Intelligence and then due to a search engine development course that used python. But I haven't used Python for about 2 years now.

Now a days, I am more interested in doing Data mining and analytics with Python. So here is the first lesson:

(More on this later)

Rendering New Theme...