« first day (3549 days earlier)      last day (1390 days later) » 
01:00 - 19:0019:00 - 00:00

7:00 PM
Dec 17 '16 at 14:58, by Andras Deak
well, coming up with an MCVE solves 90% of debugging issues
 
I could do that. But it would take a loot of work from me, and a lot of work from those willing to read through the whole thing aswell, and I don't wanna abuse nobody's good will, specially when I can try to debug by myself first.
:)
 
Consider that an MCVE is a good first step for yourself when debugging.
Though admittedly it's easier if you have a hunch of what is going wrong already.
 
I just thought you guys would know because at first I had the impression a python code would run the same way on a windows and a linux machine, but I know it might not be the case now because you told me so (still learning, of course)
I'll find the error :D
 
7:59 PM
for aiohttp should I have the session outside of my function?
the docs say
> Don’t create a session per request. Most likely you need a session per application which performs all requests altogether.
 
I'd create a session in a module and then always import it from there
 
gotchu
 
@PedroSpinola to be fair a lot of those lectures are now free online
I love opencourseware
 
Dev
8:40 PM
Hello Everyone, need some help with a challenge to create JSON file.
I have two commas separated strings.
str1 = "table1,table2,table3,table4,table5"
str2 = "db1,db2"
repeat = 3
I want to assign each value in str2 using repeat(3) number of times to values in str1 starting from beginning
In this case, final JSON should look like this:
[{"table":"table1","db":"db1"},{"table":"table2","db":"db1"},{"table":"table3","db":"db1"},{"table":"table4","db":"db2"},{"table":"table5","db":"db2"}]
In above case, using repeat number(3 in this case), we start assigning each value in str2, 3 times to str1, t
Any help or pointers are much appreciated
The above is just an example. each variable can have different values in real time
 
itertools will be useful. I'm thinking repeat, chain, then zip
 
@Aran-Fey I don't think so, "repeat" is a misnomer
it's more like a chunker used on str1, zipped with str2
@Dev First define str1.split(',') and the same for the other string, those are your relevant inputs. A naive but straightforward approach is taking iter(table_names), then looping over db_names, and in that loop take repeat elements each time from the iterator you defined before the loop. Optionally this can be done with itertools.islice, or just calling next 3 times (watching for StopIteration)
 
str1 = "table1,table2,table3,table4,table5".split(',')
str2 = "db1,db2".split(',')
reps = 3

dbs = chain.from_iterable(repeat(db, reps) for db in str2)
result = [{'table': table, 'db': db} for table, db in zip(str1, dbs)]
 
oooh, you mean repeating the db, sorry, good point
just don't call a list str1 :P
 
Dev
Thanks @Aran-Fey
Thanks @AndrasDeak
 
8:48 PM
it's a bit too late at night for me to care about variable names ¯\_(ツ)_/¯
 
Dev
I am trying above
NameError: name 'chain' is not defined
 
from itertools import *
yes, yes, I know, *-import, I don't care
 
Dev
;) Thanks
 
from itertools import chain, repeat. There.
 
Dev
Thanks much . Trying this with my original code
 
8:52 PM
note that that's why Aran changed the integer's name to reps, it would've clashed with itertools.repeat
 
Hi guys, what python db would you recommend for querying datetimes? I saw tinydb, but it has no datetime handling included
 
@Aran-Fey "details omitted for brevity" solves everything
 
Realistically my db is not gonna hold more than 10k entries and that is max. Just fyi if that is important to what db to chose
 
@Hakaishin pandas dataframe? :)
What do you expect from your db?
 
@Hakaishin what do you mean by "querying datetimes"? That does not seem like a task for the DB. Are you looking for time ranges and series?
 
8:55 PM
@AndrasDeak huh totally forgot about that. That's sound pretty good :)
Basically things like give me all the entries between two dates. How does that not sound like a db task?
 
@Hakaishin It sounds like a DB task if you put it like that.
 
@MisterMiyagi After everything that's happened today, I think it's more likely that it won't solve anything, but rather lead to follow-up questions. "What details?", "What do I need to import?", "How do imports work?", stuff like that
Giving away the solution has had the highest success rate today by far
 
btw first time writing coroutines, biggest changing is slapping await whenever there's an error
 
@Aran-Fey "there lies the path to learning"
 
Dev
@Aran-Fey @AndrasDeak you are AWESOME
Thanks much again
 
9:07 PM
lol pandas docs shows append like it is inplace. But it is not.
 
@Hakaishin link?
 
@Hakaishin what is a "python db"?
 
InvalidOperation: [<class 'decimal.InvalidOperation'>] – That's a surprisingly unhelpful error.
 
9:22 PM
@Hakaishin That could explain why I see so many "why isn't append appending to my data????1"
 
Most of the docs rely on the REPL anyway, don't they?
5 minutes in to the middle of "Independence Day: Resurgence" and it's already ranking pretty high on the ridiculousometer. I wish I'd seen the start
 
just ran out of votes today... it's been a while
 
9:46 PM
TIL argument unpacking works in class statements: class Foo(*[int], **{'metaclass': type}):
 
It makes perfect sense that it'd work though
 
After dealing with a language where if x or y worked differently from z = x or y, I appreciate this kind of consistency
appreciate, but don't expect
 
10:10 PM
@Aran-Fey in what situation is if x or y different from if z?
 
I think he means x or y doesn't always return the same result depending on whether it is used as a condition or an expression. As opposed to languages like JS. Also fun fact, empty lists are truthy in JavaScript.
it's things like that that make you appreciate python a bit more
 
@cs95 I don't think that's fair. x or y has a well-defined value, and if expr has another well-defined behaviour.
 
Yes, you can claim that. But at the end of the day you have logical operators that return different results in different contexts, I think that's slightly less intuitive than people are used to in other languages
 
@cs95 no, they don't. It's not or doing the magic, it's if. Throwing in or is a red herring.
 
10:25 PM
Ah, so it is... I have seen the light...
 
z = x or y is the same as z = x if bool(x) else y. And if x or y is the same as if bool(x or y) which is the same as if bool(x if bool(x) else y) which is the same as if bool(x) if bool(x) else bool(y) which is the same as if bool(x) or bool(y) as expected. Unless I cheated somewhere in this chain.
 
It's not confusion on how or works, it's how if evaluates the expression
 
OK, the one step in there that calls bool(x) twice might be inexact for __bool__ with side-effects
@cs95 yes, which is why I'm not sure that's what Aran meant
perhaps there's some sketchy __bool__ with side-effects where the two are substantially different
 
10:41 PM
OK, I've got one that's even better if I switch to True
 
I am answering this question, someone has already posted an answer but it is not correct. I have modified that code and made it work, plus there are also other methods which I am adding in my answer. Partially I have used the posted answer code and I would like to add credit for that. How should I do that?
 
11:13 PM
@neferpitou just reference the other poster's name. "Building on the answer from X" or something.
You could also work with the other answerer to fix those issues
But if you want to add your own answer, a nod to their work seems reasonable, but they don't actually own it anymore anyway because of the licensing
 
Hey thanks, problem was OP also had to make some changes in their code in order to make it work. And thanks for the point no 2, i will try those in future for now it too late :P
 
01:00 - 19:0019:00 - 00:00

« first day (3549 days earlier)      last day (1390 days later) »