Readit News logoReadit News
Aefiam commented on Crimes with Python's Pattern Matching (2022)   hillelwayne.com/post/pyth... · Posted by u/agluszak
quotemstr · 3 days ago
I've never understood why Python's pattern-matching isn't more general.

First, "case foo.bar" is a value match, but "case foo" is a name capture. Python could have defined "case .foo" to mean "look up foo as a variable the normal way" with zero ambiguity, but chose not to.

Second, there's no need to special-case some builtin types as matching whole values. You can write "case float(m): print(m)" and print the float that matched, but you can't write "case MyObject(obj): print(obj)" and print your object. Python could allow "..." or "None" or something in __match_args__ to mean "the whole object", but didn't.

Aefiam · 3 days ago
case .foo is explicitly mentioned in https://peps.python.org/pep-0622/ :

> While potentially useful, it introduces strange-looking new syntax without making the pattern syntax any more expressive. Indeed, named constants can be made to work with the existing rules by converting them to Enum types, or enclosing them in their own namespace (considered by the authors to be one honking great idea)[...] If needed, the leading-dot rule (or a similar variant) could be added back later with no backward-compatibility issues.

second: you can use case MyObject() as obj: print(obj)

Aefiam commented on Uber, Postmates Agree on $2.65B All-Stock Deal   bloomberg.com/news/articl... · Posted by u/uptown
jhallenworld · 5 years ago
So city dwellers in the ancient Roman world did not have kitchens- possibly they ate out more than we do.

So there must have been demand for food delivery... I wonder if they accomplished it with slaves?

Well there is some history:

https://www.thevintagenews.com/2019/01/08/food-delivery/

The Indian "dabbawala" maybe is where it has to go: some kind of standardized service where one driver can deliver to many people in a single traveling-salesman minimized trip. The packaging is designed to keep the food warm for a long time to allow this. But this probably only works for pre-arranged food delivery, not call for food now.

https://en.wikipedia.org/wiki/Dabbawala

Aefiam · 5 years ago
> So city dwellers in the ancient Roman world did not have kitchens

Thats not true ( https://quatr.us/romans/roman-kitchens-houses-ancient-rome.h... ).

Rich romans did have kitchens, poor people could not afford one and instead made food in their appartment room or bought food from streetvendors or takeout food from thermopolia.

There was likely no demand for food delivery as poor people couldnt afford it and rich people had slaves to make their food.

u/Aefiam

KarmaCake day5July 6, 2020View Original