srav03 / GroceryStore

Create software to manage Grocery Store
1 stars 0 forks source link

Fix: Try not to use Keyword names for variables/functions #4

Closed SMan23 closed 9 years ago

SMan23 commented 9 years ago

File Location on 6/20 @ 8:06 PM PT: https://github.com/srav03/GroceryStore/blob/master/src/people/person.py#L42

You should avoid using the keyword names like "dict", "list", "set" to name your variables as this will create a conflict.

For example if in that I have referenced above, what if you want to instantiate a dict object: my_dict = dict()

I have tested it and this would raise an error as I have superseded the keyword argument by naming my variable the same thing:

dict = "something" my_dict = dict()

Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable

Correct functionality would be as follows (I reset interpreter):

my_dict = dict() my_dict['size'] = 'large' my_dict

{'size': 'large'}

A suggestion for a name change would to be more specific, but keep the definition that it is a dict. This will help you keep track in future. But of course since the shopping cart is very specific and you wouldn't likely forget it is a dictionary it may be fine.

examples: "shopping_cart_dict" "cart_dict" "item_dict" "shopping_cart" (non-dict specific)

srav03 commented 9 years ago

changed naming convention dict to price_stock_dict

SMan23 commented 9 years ago

Nice!

El dom, jun 21, 2015 03:54 PM, srav03 notifications@github.com escribió:

Closed #4 https://github.com/srav03/GroceryStore/issues/4.

— Reply to this email directly or view it on GitHub https://github.com/srav03/GroceryStore/issues/4#event-336286491.