Skip to content

Sort global variables into mutable and immutable#3533

Open
naderidkeidek-star wants to merge 1 commit into
mate-academy:masterfrom
naderidkeidek-star:patch-2
Open

Sort global variables into mutable and immutable#3533
naderidkeidek-star wants to merge 1 commit into
mate-academy:masterfrom
naderidkeidek-star:patch-2

Conversation

@naderidkeidek-star
Copy link
Copy Markdown

3rd Try

Copy link
Copy Markdown
Author

@naderidkeidek-star naderidkeidek-star left a comment

Choose a reason for hiding this comment

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

again

Copy link
Copy Markdown
Author

@naderidkeidek-star naderidkeidek-star left a comment

Choose a reason for hiding this comment

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

mutable = []
immutable = []

#def sort_variables():
for name, value in globals().items():
if name.startswith("__") or name in (
"mutable",
"immutable",
"sorted_variables",
"sort_variables",
):
continue

    if isinstance(value, (list, dict, set, tuple)):
        mutable.append(value)
    else:
        immutable.append(value)

sort_variables()

sorted_variables = {
"mutable": mutable,
"immutable": immutable,
}

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.

1 participant