[DiscordArchive] what do you mean by do until exception?
[DiscordArchive] what do you mean by do until exception?
Archived author: Skarn • Posted: 2018-02-11T11:04:55.822000+00:00
Original source
It is not throwing anything
Archived author: Skarn • Posted: 2018-02-11T11:05:01.635000+00:00
Original source
at least not on python level
Archived author: Amaroth • Posted: 2018-02-11T11:05:33.745000+00:00
Original source
*shrug* I guess I am not explaining that correctly, would have to ask my teacher again
Archived author: Amaroth • Posted: 2018-02-11T11:05:48.637000+00:00
Original source
But Python is his main language, so he should know this
Archived author: Skarn • Posted: 2018-02-11T11:06:20.917000+00:00
Original source
afaik iteraitons are done with generator objects. I messed with that stuff a little before when I tried doing async programming
Archived author: Skarn • Posted: 2018-02-11T11:07:45.237000+00:00
Original source
as far as I know, when you iterate over something in python, it calls an __iter__ magic method of an iterable object, which returns a generator object
Archived author: Skarn • Posted: 2018-02-11T11:07:59.907000+00:00
Original source
I actually overload that magic method in my m2 reading
Archived author: Skarn • Posted: 2018-02-11T11:10:22.393000+00:00
Original source
In M2 we have a lot of M2Array objects. I've done them in a way that there is that actual struct (n_elements, ofs_elements) that is actuall written to the header, and also "values" field with a list of values that were parsed by that adress. So, it'd be fucking horrible if I had to write something like: for sequence in self.m2.sequences.values. So, I overloaded the __iter__ method to return a generator expression of an inner field values. So now you can just do: for sequence in self.m2.sequences: without adressing the values field directly.
Archived author: Skarn • Posted: 2018-02-11T11:10:32.880000+00:00
Original source
I don't really see where an exception could be raised there
Archived author: Skarn • Posted: 2018-02-11T11:11:24.019000+00:00
Original source
Maybe your professor meant the way it is implemented on a C level. Like when generator is asked for providing the next value, and if there is no, it might raise something, yes