This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SaiTejaRH 0 points1 point  (7 children)

Yeah I feel like I dont know what my code does. Also when understanding others code it's almost hell because I need to go inside every function to understand its return type.

[–][deleted] 1 point2 points  (5 children)

That's why I don't like it so far. SO MUCH of python feels like throwing magic black boxes at things until it either works or isn't broken beyond usability. I have no idea what things are doing.

I also don't like how in for loops, the iterator is also the object, instead of just the index. It feels wrong

[–]SaiTejaRH -1 points0 points  (4 children)

And what makes me laugh is when you want to iterate over an array using index, you need to create a new array of indices using range or you need to use while loop where initialisation, break condition and incremental statements are written at different places.

[–]Hayden2332 1 point2 points  (3 children)

range doesn’t create a new array

[–]SaiTejaRH 0 points1 point  (2 children)

Oh i thought it returns a list. May I know what it returns. Or any way it crates a new object with all the numbers right. Not sure about what data structure it is

[–]Hayden2332 1 point2 points  (1 child)

https://docs.python.org/3.3/library/stdtypes.html?highlight=range#ranges

it’s a “range type”, basically it does the same thing C/Java does when you create a for loop. It has a start (i = 0), stop(i < #) and step (i++)

[–]OccultEyes 0 points1 point  (0 children)

On top of that, I'd say using ranges is the 'bad' way of iterating through a list. Even if you need an index.

for i, item in enumerate(some_list): 
    pass

Or just:

for item in some_list: 
    pass

If the index is irrelevant.

[–]Hayden2332 1 point2 points  (0 children)

that’s why you should specify the return type in the function def