|
|
|
|
|
by pkolaczk
2050 days ago
|
|
Seriously? How to do data structures: 1. just put everything ad-hoc into a dict or a list (the "PHP" way :D)
2. use a namedtuple
3. define a class
4. define a dataclass (preferred) but works only if your Python version is recent enough In Scala? Just use case classes and this is the only recommended way (#1 is very impractical so noone does that, #2 doesn't exist, #3 possible, but impractical when you have #4 in all versions). How to map a collection in Python?
- Start from an empty one and add mapped items in a loop
- Use map + lambda
- Use list comprehension
- Update all items in place with a loop Is it really any better than in Scala? |
|