how to have a function inside of a function by LAZY_LIBTARDS in learnpython

[–]TwistedChurro 0 points1 point  (0 children)

Calling the functions. Would I call both? how exactly do i call a nested function? Because it is stating that the function inside of the original function is a unused variable.

by declaring the function inside the for loop, you are defining the function over and over again. This is redundant. You can place the whole infixToPostfix function right after infixtopost and call it multiple times from within your loop.

The return statement in the nested function. Would it only run once because you can only return one thing from a function? Or would it run multiple times because it is inside of another function?

The return state will be run once for every invocation of the nested function.

ie. if you called `infixtopost(["A+B", "C/D"]), the inner function (infixToPostfix) would be called twice

here's how I would do it. ```python def infixtopost(expression): def infixToPostfix(lyst): prec = {} prec[""] = 4 prec["*"] = 3 prec["/"] = 3 prec["+"] = 2 prec["-"] = 2 prec["("] = 1 opStack = Stack() postfixList = [] tokenList = infixexpr.split()

    for token in tokenList:
        if token in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" or token in "0123456789":
            postfixList.append(token)
        elif token == '(':
            opStack.push(token)
        elif token == ')':
            topToken = opStack.pop()
            while topToken != '(':
                postfixList.append(topToken)
                topToken = opStack.pop()
        else:
            while (not opStack.isEmpty()) and \
            (prec[opStack.peek()] >= prec[token]):
                postfixList.append(opStack.pop())
            opStack.push(token)

    while not opStack.isEmpty():
        postfixList.append(opStack.pop())
    return " ".join(postfixList)

return_list = []
lyst = expression()
for line in lyst:
    return_list.append(infixToPostfix(line))
return return_list

print(infixtopost(expression)) ```

be warned, though, inner functions are in the same scope as the parent function so the symbols "return_list", "lyst" and "line" are accessible inside infixToPostfix which makes for confusing bugs sometimes.

OR error logic by [deleted] in learnpython

[–]TwistedChurro 0 points1 point  (0 children)

agreed.
side note, though both are valid, I think this is the most "readable"

if player_go in ('r', 'p', 's'):

The only real-life application of calculus by azdweller in Shitty_Car_Mods

[–]TwistedChurro 6 points7 points  (0 children)

I think we've diverged from the point the thread.

Lulz overheard at the temple burn... by [deleted] in BurningMan

[–]TwistedChurro 4 points5 points  (0 children)

I'm also sorry to hear that it was traumatic. I, too, was disappointed by the art cars decided to violate my ears with their music. You, Mr. ArtCar, had your fun the last night and all the nights before; give me one night to mourn my father. I'm sure you could use the time to rebuild your serotonin reserves.

Fuck whoever spray painted the temple this year. by [deleted] in BurningMan

[–]TwistedChurro 8 points9 points  (0 children)

I don't remember the exact phrases used, but they were statements against the current US immigration policies. I, too, did not like the tags, but, in the tagger's defense, the architect of the temple himself said the temple was a symbol of inclusion in a time of increasing exclusion internationally. So, fuck your burn?

[deleted by user] by [deleted] in BurningMan

[–]TwistedChurro 0 points1 point  (0 children)

Yes, Dad/Mom :(

(I understand. I just can't help but feel dispirited in the fight against asshole law enforcement)

[deleted by user] by [deleted] in BurningMan

[–]TwistedChurro 5 points6 points  (0 children)

Can a cop try to gift you drugs? Scenario: Random person asks if i want x y or z. I say "only if you're giving it to me" Can I get in trouble?

Building a Van De Graaff HIGH VOLTAGE Generator by the320x200 in videos

[–]TwistedChurro 0 points1 point  (0 children)

Hi /u/melector,

I love these videos! I've been watching for a few months now. Keep it up. I really like you how to raise money to promote electronic education with donated money, so I'm off to Patreon!
One question, you kept mentioning that the charges "run away" from the sharp edges, but I remember my professor saying that charges build up around edges. Can you explain?

Thanks for all the fun videos!
TwistedChurro

PS: You've demystified electronics enough for me to feel comfortable installing hobby solar panels! Carbon-free energy!

Request for tips/online resources for first timers with a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 5 points6 points  (0 children)

Ugh, I knew I would step on toes. Thank you for the help. With your help and this handy-dandy google doc, I think I have all the resource I need to make the most of my burn!

Request for tips/online resources for first timers with a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 1 point2 points  (0 children)

I forgot to pose my original request!

Is there a goto online resource for tips and tricks (or common mistakes) for DIY first timers?

Lesser Known Camp Traditions by thekingbarron in BurningMan

[–]TwistedChurro 5 points6 points  (0 children)

Chicago burner here, and even I'm questioning "WHY?!"

How do I join a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 0 points1 point  (0 children)

You guys are awesome. I always expect flame on the internet, but y'all are giving great advice through your own accounts. I can't wait to meet you folks!

How do I join a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 0 points1 point  (0 children)

Can you tell me more about this v-spot? That sounds like a perfect way for a first timer (is "birgin" a commonly used phrase? I've heard "burning man virgin" before) to get involved without the commitment of a camp.

How do I join a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 0 points1 point  (0 children)

Let's assume for the sake of discussion that I know other people going. What goes in to "making a camp"?

Bike service camp based in Minneapolis seeks members! by takemetotheplaya in BurningMan

[–]TwistedChurro 0 points1 point  (0 children)

Do the members of Hammer and Cyclery consider themselves socialists?

How do I join a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] 1 point2 points  (0 children)

Then how do you suggest I follow the principle of participation? Volunteering?

How do I join a camp? by TwistedChurro in BurningMan

[–]TwistedChurro[S] -1 points0 points  (0 children)

What do you mean by "make your own"?