###Styleguide (PEP8 )
Styleguide (PEP8 )
- avoid useless comments
- you should have two new lines between your methods
- docstrings should be written within triple double-quotes
- after
#
you should have a space
###Identity vs equality
Identity vs equality
There is a simple rule of thumb to tell you when to use ==
or is
.
==
is for value equality. Use it when you would like to know if two objects have the same value.is
is for reference equality. Use it when you would like to know if two references refer to the same object.
For example:
def not_singleton(tag):
return is_singleton(tag) == False
Should actually be:
def not_singleton(tag):
return is_singleton(tag) is False
###Iterating over keys and values of a dict
Iterating over keys and values of a dict
Instead of this:
for key, value in zip(kw.keys(), kw.values()):
...
You should do this:
for key, value in kw.items():
...
To be continued
###Styleguide (PEP8 )
- avoid useless comments
- you should have two new lines between your methods
- docstrings should be written within triple double-quotes
- after
#
you should have a space
###Identity vs equality
There is a simple rule of thumb to tell you when to use ==
or is
.
==
is for value equality. Use it when you would like to know if two objects have the same value.is
is for reference equality. Use it when you would like to know if two references refer to the same object.
For example:
def not_singleton(tag):
return is_singleton(tag) == False
Should actually be:
def not_singleton(tag):
return is_singleton(tag) is False
###Iterating over keys and values of a dict
Instead of this:
for key, value in zip(kw.keys(), kw.values()):
...
You should do this:
for key, value in kw.items():
...
To be continued
Styleguide (PEP8 )
- avoid useless comments
- you should have two new lines between your methods
- docstrings should be written within triple double-quotes
- after
#
you should have a space
Identity vs equality
There is a simple rule of thumb to tell you when to use ==
or is
.
==
is for value equality. Use it when you would like to know if two objects have the same value.is
is for reference equality. Use it when you would like to know if two references refer to the same object.
For example:
def not_singleton(tag):
return is_singleton(tag) == False
Should actually be:
def not_singleton(tag):
return is_singleton(tag) is False
Iterating over keys and values of a dict
Instead of this:
for key, value in zip(kw.keys(), kw.values()):
...
You should do this:
for key, value in kw.items():
...
To be continued
###Styleguide (PEP8)
- avoid useless comments
- you should have two new lines between your methods
- docstrings should be written within triple double-quotes
- after
#
you should have a space
###Identity vs equality
There is a simple rule of thumb to tell you when to use ==
or is
.
==
is for value equality. Use it when you would like to know if two objects have the same value.is
is for reference equality. Use it when you would like to know if two references refer to the same object.
For example:
def not_singleton(tag):
return is_singleton(tag) == False
Should actually be:
def not_singleton(tag):
return is_singleton(tag) is False
###Iterating over keys and values of a dict
Instead of this:
for key, value in zip(kw.keys(), kw.values()):
...
You should do this:
for key, value in kw.items():
...
To be continued