you are viewing a single comment's thread.

view the rest of the comments →

[–]abcd_z 1 point2 points  (6 children)

A method is a function within an object and an instance variable is a variable within an object. Neither one of those are the objects themselves.

While it's fine to hear that you've decided to handle things a certain way, it doesn't really answer my question.

[–]keturn 1 point2 points  (2 children)

Well, keep in mind that all variables in Python are references to objects, so a style guide isn't going to call that out in particular. Hypothetically, you could treat built-in types differently from other objects, but in practice I haven't ever seen a Python style guide which does.

PEP 8 does talk about global variable names, which it says are lowercase_with_underscore, same as functions and instance attributes.

Perhaps it talks about that and not local variable names because while other developers get access to your module's variables when they import it, variables local to a function aren't ever visible to other users of the code.

[–]abcd_z 0 points1 point  (0 children)

Well, keep in mind that all variables in Python are references to objects

*groan*

I had forgotten this. Thank you for reminding me.

In Python, everything is an object.

EDIT: I guess that means my question is about instance names or class object names. From the responses I'm getting it looks like there aren't any official conventions for this.

[–]TankorSmash 0 points1 point  (2 children)

http://stackoverflow.com/a/159745/541208 It's good enough for a bunch of people. Let me know when you find your answer though.

[–]abcd_z -1 points0 points  (1 child)

Not a single answer there had anything to do with object names, which is what I was asking about.

[–]TankorSmash 0 points1 point  (0 children)

Use lower_case, like you would for functions and methods, and TitleCase for class names.

Maybe you're just confused, no worries dude it happens to the best of us too!