Poor Example of Python

Apologies in Advance, but I have to say that the code for Exercise 3 is not very Pythonic, and not Pep 8 compliant.

The code block uses the same variable name for the input to the function as a variable in the outer scope with omega_array being used in the outer scope for the array and as the input function. Also L_array is used within the function to hold a variable, is the return variable and in the outer storage scope is the assignment variable. Although the interpreter can keep all this straight it is bad practice.

In Exercise 2, the prices_A and prices_b variable are accessed in the function , and are not explicitly passed in, but referenced from the outer scope. Again, not pythonic and prone to confusion and error.

IT may not matter now, but further down the road on complicated projects; code needs to be more pythonic. Start now with a good example. If someone wrote this code in a job interview, I would not hire them.

Can we get this improved?

Hi! Thanks for your feedback, we really appreciate it!

@esanina, can you take a look at it when you get the chance?

Cheers,
Lucas

2 Likes

Wow. I didn’t expect an answer so fast. I’m impressed.
I hope I didn’t sound harsh, but one thing that makes a lot of data science projects more difficult is that the initial code doesn’t scale up into “software”

1 Like

@Nicholas_J_Feliccia thank you for the feedback, we will take that into consideration.

1 Like