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

Locals project #5213

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

TectonicLion
Copy link

Description

The `locals()' function returns a dictionary with all of the data necessary to run the program.

Issue Solved

Closes #5116

Type of Change

  • Adding a new entry
  • Updating the documentation

Checklist

  • All writings are my own.
    (I did copy the example results from elsewhere, I wasn't sure where to get them myself. Is that alright?)
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Sep 13, 2024

CLA assistant check
All committers have signed the CLA.

@mamtawardhani mamtawardhani self-assigned this Sep 13, 2024
@mamtawardhani mamtawardhani added python Python entries new entry New entry or entries status: waiting for author status: under review Issue or PR is currently being reviewed and removed status: waiting for author labels Sep 13, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TectonicLion thank you for contributing to Codecademy docs, the entry is nicely written!

I've suggested a few changes, could you please review and modify them at your earliest convenience? Thank you! 😄

Comment on lines +29 to +47
{'In': ['', 'locals()'],
'Out': {},
'_': '',
'__': '',
'___': '',
'__builtin__': ,
'__builtins__': ,
'__name__': '__main__',
'_dh': ['/home/repl'],
'_i': '',
'_i1': 'locals()',
'_ih': ['', 'locals()'],
'_ii': '',
'_iii': '',
'_oh': {},
'_sh': ,
'exit': ,
'get_ipython': >,
'quit': }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be converted to a working code? As this is not a correct code example. One example could be:

def my_function():
    x = 10
    y = 20
    print("Local variables:", locals())

my_function()

This is just an example, feel free to modify

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just an example. I wasn't sure what the actual result would be so I looked up the result elsewhere.

...Was I supposed to write out a function? I thought I was just supposed to show the result of the code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just an example. I wasn't sure what the actual result would be so I looked up the result elsewhere.

...Was I supposed to write out a function? I thought I was just supposed to show the result of the code.

Basically example section should have a code that gives an output, so this could be replaced with a code having locals that gives an output

'quit': }
```

Attempting to edit an active variable by changing `locals()` does not work.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a ##Codebyte Example block at the end that will have the code for the term, the output showcasing does not follow it, just the code is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to bring up the only other use for locals() that I know of. Did I do it wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to bring up the only other use for locals() that I know of. Did I do it wrong?

No no, you just need to add one more code under a ##Codebyte Example block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Term Entry] Python built-in functions locals()
3 participants