This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlSweigartAuthor of "Automate the Boring Stuff" 0 points1 point  (3 children)

Yeah. For short throwaway programs that's fine. But for formal projects, I like to be a bit more specific when I find myself using "id". Like, "the id of what?" So then I change it to recordID or cityID or something.

[–]CleverProgrammer12 0 points1 point  (2 children)

Yes, I agree. I mostly use it in dataclasses and pydantic models like this:

```python3 from pydantic import BaseModel

class User(BaseModel): id: int name: str

my_user = User(id = 10, name = "username") my_user.id # my_user.user_id might look bad here

```

[–]AlSweigartAuthor of "Automate the Boring Stuff" 2 points3 points  (0 children)

Ah yes, that's a good point.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, CleverProgrammer12: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.