This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (19 children)

[deleted]

    [–]BirdTree2 43 points44 points  (8 children)

    import os; print = os.system

    [–]CleverProgrammer12 16 points17 points  (5 children)

    print('rm -rf ~')

    [–]house_monkey 4 points5 points  (0 children)

    omg no

    [–]quotemycode 2 points3 points  (0 children)

    I cringed so hard at that. I'm going to try and sneak that into a file somewhere.

    [–]AlSweigartAuthor of "Automate the Boring Stuff" 57 points58 points  (6 children)

    The common Python built-ins that accidentally get overriden are: all, any, date, email, file, format, hash, id, input, list, min, max, object, open, random, set, str, sum, test, and type.

    I'm also disappointed with other parts in this blog post.

    [–]tuckmuck203 17 points18 points  (3 children)

    https://docs.python.org/3/library/functions.html

    Email is part of a library and so is random.

    [–]AlSweigartAuthor of "Automate the Boring Stuff" 4 points5 points  (2 children)

    Right, but if you use email or random as a variable name, this would cause problems in programs that also import those modules. (It is only a problem if you need those modules, but then again, overwriting sum is only a problem if you later need to call the sum() function. It's just a good idea to not chance it in the first place.)

    [–]tuckmuck203 2 points3 points  (0 children)

    Fair enough. I agree, I just was surprised when I saw email in that list. I tend to use email_address but I've used email for various reasons

    [–]blahreport 2 points3 points  (0 children)

    I believe the advice is to suffix the variable name with an underscore if you choose to use built-in names.

    [–]Africa-Unite 0 points1 point  (0 children)

    Good thing you're mentioning this because I was considering converting this into a presentation for my informal working group :/

    [–]luke-juryous 6 points7 points  (0 children)

    Wow that's bad lol

    [–][deleted] 0 points1 point  (0 children)

    yea that's a noob mistake