Skip to content

Python: Vector3(1,2,3)*0.5 works, 0.5*Vector3(1,2,3) not #558

@smoe

Description

@smoe

My poor student (with a life sciences background) could not get beyond

In [4]: print 2*Vector3(1,2,3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
 in ()
----> 1 print 2*Vector3(1,2,3)

TypeError: unsupported operand type(s) for *: 'int' and 'Vector3'

when what he felt inclined to achieve worked perfectly fine as

In [3]: print Vector3(1,2,3)*2
(2.000000 4.000000 6.000000)

This was not ultimately surprising with the background of class operators vs external operators, but I admit not to be ultimately firm on this all myself any more (was I ever?). Just, since the int/float*Vector flavour sounds so much more natural, is there something you might want to do about it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions