That's tough. I'd say conver the vector to a list. But : my_vector.list()
Would apply list on each element of the vector. Globally, I'd say if the vector is used as an argument, it's a usual iterable, if you use a member function (or any other notation like @ or .. or whatever) it's like map. Note that it's just my opinion. Le sam. 2 févr. 2019 à 19:46, MRAB <pyt...@mrabarnett.plus.com> a écrit : > On 2019-02-02 17:31, Adrien Ricocotam wrote: > > I personally would the first option to be the case. But then vectors > shouldn't be list-like but more generator like. > > > OK, here's another one: if you use 'list(...)' on a vector, does it > apply to the vector itself or its members? > > >>> list(my_strings) > > You might be wanting to convert a vector into a list: > > ['one', 'two', 'three'] > > or convert each of its members onto lists: > > Vector([['one'], ['two'], ['three']]) > > > Le sam. 2 févr. 2019 à 19:26, MRAB <pyt...@mrabarnett.plus.com> a > écrit : > > > > On 2019-02-02 09:22, Kirill Balunov wrote: > > > > > > > > > сб, 2 февр. 2019 г. в 07:33, Steven D'Aprano <st...@pearwood.info > > > <mailto:st...@pearwood.info>>: > > > > > > > > > I didn't say anything about a vector type. > > > > > > > > > I agree you did not say. But since you started a new thread > from the > > > one where the vector type was a little discussed, it seemed to > me that > > > it is appropriate to mention it here. Sorry about that. > > > > > > > Therefore, it allows you to ensure that the method is > present for > > > each > > > > element in the vector. The first given example is what > numpy is > > > all about > > > > and without some guarantee that L consists of > homogeneous data it > > > hardly > > > > make sense. > > > > > > Of course it makes sense. Even numpy supports inhomogeneous > data: > > > > > > py> a = np.array([1, 'spam']) > > > py> a > > > array(['1', 'spam'], > > > dtype='|S4') > > > > > > > > > Yes, numpy, at some degree, supports heterogeneous arrays. But > not in > > > the way you brought it. Your example just shows homogeneous > array of > > > type `'|S4'`. In the same way as `np.array([1, 1.234])` will be > > > homogeneous. Of course you can say - np.array([1, 'spam'], > > > dtype='object'), but in this case it will also be homogeneous > array, but > > > of type `object`. > > > > > > Inhomogeneous data may rule out some optimizations, but > that hardly > > > means that it "doesn't make sense" to use it. > > > > > > > > > I did not say that it "doesn't make sense". I only said that > you should > > > be lucky to call `..method()` on collections of heterogeneous > data. And > > > therefore, usually this kind of operations imply that you are > working > > > with a "homogeneous data". Unfortunately, built-in containers > cannot > > > provide such a guarantee without self-checking. Therefore, in > my opinion > > > that at the moment such an operator is not needed. > > > > > Here's a question: when you use a subscript on a vector, does it > apply > > to the vector itself, or its members? > > > > For example, given: > > > > >>> my_strings = Vector(['one', 'two', 'three']) > > > > what is: > > > > >>> my_strings[1 : ] > > > > ? > > > > Is it: > > > > Vector(['ne', 'wo', 'hree']) > > > > or: > > > > Vector(['two', 'three']) > > > > ? > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/