Re:The Perl Jam: Exploiting a 20 Year-old Vulnerability [pdf]
by collyw on Friday January 02, 2015 @08:15AM
(#8826629)
Yes but I would expect my strings to behave as a scalar variable, not a list or set.
I prefer the Perl way of having one function push, and specifically referencing the list if you want it stored that way. That has caused me far less confusion in Perl than the Python way of doing things.
list.extend(data) works like "for item in data: list.append(item)"
strings (str) do not behave differently than a list or a set. Try .append() on a list or a set, you get the same behaviour.
Maybe your confusion comes from the fact that strings are immutable in Python, and a list is not a string.
You may like bytearray() in Python 2 (bytearray.append raises an error if you pass a string longer than 1 character), but there is not mutable type for Unicode strings.