Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefining name 'tweet_text' from outer scope #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VenkatsQuest
Copy link

DESCRIPTION
The local variable name hides the variable defined in the outer scope, making it inaccessible and might confuse.

Examples:
Bad practice:
filename = 'myfile.txt'

def read_file(filename): # This shadows the global filename
with open(filename) as file:
return file.readlines()
Preferred:
FILENAME = 'myfile.txt' # renamed global to UPPER_CASE as convention

def read_file(filename):
with open(filename) as file:
return file.readlines()

DESCRIPTION
The local variable name hides the variable defined in the outer scope, making it inaccessible and might confuse.

Examples:
Bad practice:
filename = 'myfile.txt'

def read_file(filename):  # This shadows the global `filename`
    with open(filename) as file:
        return file.readlines()
Preferred:
FILENAME = 'myfile.txt'  # renamed global to UPPER_CASE as convention

def read_file(filename):
    with open(filename) as file:
        return file.readlines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant