« first day (2335 days earlier)      last day (2612 days later) » 

10:00 PM
@Tokencodingnewbie using (*args) will be definition give you a tuple named args inside the function body
 
@Tokencodingnewbie I am not sure about the document which you referred. But you should be looking for "args"
 
calling that function with fun(foo) will give you args==(whatever_is_in_foo,) inside
 
@AndrasDeak But yeah that lower right menu is also a stickler spot -- most complex usage case is the eating section imgur.com/a/TnMD4
 
As Andras mentioned, in your example two, board is of tuple type
 
Can I cast it, force it to not be a tuple?
 
10:01 PM
(and you can also see in that example I have the settings icon moved away into the expanded part of the item because I wasn't sure if it'd be too cluttered keeping it on the main level)
 
@Tokencodingnewbie no, you need to forget about * there because you don't need it
you put * there because you wanted to pass two boards at once, but now you're passing a single board
so just pass that single board and do what you want with it
 
Ah i wanted to make multiple boards at once.
 
I mean, if lines 4-6 work then why do you expect lines 10-14 to also work?
 
Because in my mind I just picture it getting two board lists and filling them
 
if you want to make multiple boards, and don't know their number, then use def fun(*args), but then args is a tuple containing every input parameter and you need to handle it thus
def fun(*args): ... --> fun(board1,board2) will give you sort of args==(board1,board2)
obviously you can't just append to that, you need to loop over your tuple and append to that each
 
10:05 PM
well day is over for me. stay beautiful. \o rbrb
 
rhubarb
 
Great, now OP thinks it's a good idea to use globals too. How did they miss the -6 score answer about it? stackoverflow.com/questions/42680357/…
 
rhubarb @MooingRawr
 
@MarcusS I see
 
Loop through the tuple and append it, hrm.
 
10:05 PM
Wow, they accepted the answer.
 
they have :|
 
wow
 
And someone upvoted it.
 
@Tokencodingnewbie I meant appending to each list inside the tuple...
 
Couldn't have been op, since they don't have 15 rep yet.
 
10:06 PM
@davidism OP?
ah right
pity upvote, because "it's accepted so it can't be that bad"?
depressing either way
 
So now the user has received 25 - 12 = 13 rep for suggesting a terrible solution.
 
well my vote doesn't even count :|
 
The system works.
 
Okay i google converting tuple to list, so I'll give it a shot
Thanks.
I do understand the args thing though, makes sense.
 
you don't need to convert tuple to list
 
10:08 PM
Oh.
 
try just passing two of your boards to a def fun(*args) or whatever you call it, and see what args is and what its elements are, without trying to append anything
It's really not that difficult, but you keep misunderstanding my theoretical guidance. Which is why you need to go practical.
 
Yeah it's the lingo that's throwing me off TBH
 
@davidism that's a good enough reason for me to want to delete that question
I just need 3 close votes and 2 days:D
FWIW it's 25-16=9
 
Room 6 effect
 
although their rep history says +11 so I might be off someplace
or caching
 
10:15 PM
-1
Q: Why doesn't my Leap Year code work?

Rachel KatzI have to write a calculator for leap years for my python class. Why doesn't my code work? def leapyear(x): return leapyear(x) Thank you!!!!!

 
why onebox a shitty question?
 
I have no words.
 
I'd answer the question instead of just complaining about globals, but I'm at work and implementing a counter that's accurate with concurrent access is somewhat involved.
 
@Orange sounds like a troll
all the more reason not to shove it in our face
 
Basically, use multiprocessing.Manager with a lock, or use Redis with atomic increment.
Neither of which is probably what the (brand new) op was actually expecting for "increment a counter".
 
10:17 PM
Well im sorry, my short span here has never seen a troll.
 
Cbg. I've been looking for a builtin lib and can't seem to find it anymore. It allowed loading multiple configs (like DefaultConfig, UserConfig, etc) while keeping each contexts (not overwriting the previous one everytime)
Does it ring a bell to anyone? it was a very simple yet efficient builtin module designed just for that
 
@AndrasDeak One more cv to closure, and then I get to use my shiny new instadelvotepower on the q ...
-2
Q: Increment value by a factor 1 in Flask while using jsonify

Anthony Paul TorresThis is what is inside my python file: from flask import Flask, jsonify app = Flask(__name__) @app.route('/count') def make_count(): count = 0 value = count + 1 return jsonify(count=value) if __name__ == "__main__": app.run(debug=True) How do I increment "value" by a factor o...

 
show-off
 
Ok, just found it after searching for like an hour :D it's ChainMap
 
10:23 PM
what orange linked, 1 more vote needed, any one will do
 
I've been googling "multiple config python" and couldn't find it… obviously.
 
Why did we close the increment a counter question? It's clear, the answer's just wrong.
 
That's a super good use case though :)
 
Holy shit, i think I did it.
 
@JeromeJ ConfigParser?
 
10:24 PM
gameboard1 = []
gameboard2 = []

def make_board(*boards):
    for arg in boards:
        for x in range(5):
            arg.append((["O"] * 5))

def print_board(board):
    for row in board:
        print(" ".join(row))


make_board(gameboard1, gameboard2)

print_board(gameboard1)
print("*" * 9)
print_board(gameboard2)
 
Ahh, needs to be -3 or lower too.
 
@Tokencodingnewbie I suggest for board in boards for additional clarity
 
@MoinuddinQuadri Each consecutive config loaded "overwrites" the previous one
 
but other than that?
 
While ChainMap doesn't,
 
10:25 PM
@Tokencodingnewbie Well, either it works or it doesn't, right? Don't wait for me to tell you which one it is.
 
I want your praise D:
 
I've found a nice article on it but it's in French (for those who can read it out there...) sametmax.com/… (Caution that blog is rather nsfw)
 
stackoverflow.com/q/42680357 clarified question, it's on topic
The question itself was fine, it was the answer that was a problem.
 
@JeromeJ I don't know french, but I can read the code snippets used in the blog. It is just a usage of Python dictionary to maintain the config. (nothing tooo fancy)
 
Ok but you better answer it then ;-)
 
10:29 PM
I'm writing an answer.
 
10:54 PM
0
A: Increment counter for every access to a Flask view

davidismCounting concurrently is hard. Assume the count is 0. If two users both hit the endpoint at close enough intervals, they may each get the value 0, increment it to 1, and put it back. Two users hit the endpoint, but the resulting count is 1, not 2. To get around this, you need to use a data store ...

 
yaaaay
 
Well that became longer than expected. I still feel kinda dirty using shared memory, since it's basically a global, albeit a shared, locked global.
 
brb, commenting "why not use globals instead?"
 
@davidism I was waiting with baited breath, and your answer past with flying collars!!! For all intensive purposes, you've given a new leash of life to a question straddled with a wreckless answer that was beyond the pail. Goes to show that although the cacoughany of downvotes might seem coal-hearted, questions of that elk can be saved.
needs to lie down now
 
10:57 PM
@ZeroPiraeus :-|
 
Hey, I could have written that in all-lowercase leet speak :-P
 
cacoughany? wow
 
I was surprised there wasn't a dupe of this already, but I couldn't find one.
(Waiting for one to be immediately found.)
 
wim
ever seen coverage report a line as uncovered, even though you know it is?
I put in an assert False statement on the line and it triggers
I think it's peephole optimizer
would be nice to turn that fcuking thing off when running coverage
 
DSM
two-days-of-intense-Python-and-pandas-training-of-the-teams-are-over cabbage for all!
 
11:06 PM
cbg
 
OK Django....that wasn't painful....testing with cookies is pretty straight forward.
 
@DSM how bad was the numpy density situation?
 
cbg @DSM
 
DSM
@AndrasDeak: it actually went okay. Students seemed to like it, anyhow, and were surprised by quite a few things. Reassuring, in that at least I wasn't just going over stuff they already knew.
 
11:09 PM
that's great:)
 
DSM
I'd forgotten how exhausting it is to talk for that long, though. Can't believe I used to do that for a living..
 
11:30 PM
I was born in Rochdale :-(
PSA: Rochdale is a shithole.
 

« first day (2335 days earlier)      last day (2612 days later) »