4 ms·
> Is records a list, a dict or a database connection? Records is a list of record items. It’s a plural. If it was a dict, it would be recordByID. If it was a d
by nailer 3y ago
> Is records a list, a dict or a database connection?
Records is a list of record items. It’s a plural. If it was a dict, it would be recordByID. If it was a database connection it would be called connection.
Strict typing is good, and you should definitely use it, but you should still have good names.
- vsnf 3y ago>If it was a dict, it would be recordByID. Never have I ever encountered any codebase where dictionaries were so named.
- paganel 3y agoI usually add a “_dict” to the variable name.
- psd1 3y agoI follow that convention. I've written many functions that accept a list of values and, typically as intermediate processing, build a dict from them. Many rest APIs I've coded for require me to fetch from two endpoints to build my output, and this pattern saves iterating over lists.
- mgaunard 3y agoMost good databases actually store data per column. So you'd have a list of batches, each batch being a dict of string to list of T.
- nailer 3y agoThe article mentions connection, so it’s the connection the DB rather than the data. Ie the thing you get after you open the socket.
- imron 3y ago> Strict typing is good, and you should definitely use it, but you should still have good names. Linters and type checkers will understand type hints. They won’t understand your naming conventions.
- nailer 3y agoI know. That’s why I wrote that strict typing is important. But naming variables properly helps your colleagues now and you in the future when you need to come back to this code.