Skip to content

Comment on Python bug: Can assign [] = (), but not () = []parent

Comments

I use R predominantly, so forgive the lack of adequate Python-ese.

Is this behavior because numpy overloads the multiplication operation with a string as string repetition and then implicitly casts the float64 down to an integer of 3? I'm curious why this behavior manifests. When I get a chance I'll test 'xyz'*np.float(3.5)

It's "normal" in python for this to work with integers:

    >>> "x" * 3
    xxx
The only weird part (and it's not that weird IMO) is that numpy's "float" can be implicitly coerced to integer.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.