« first day (4109 days earlier)      last day (833 days later) » 

6:35 AM
cbg
 
 
3 hours later…
9:38 AM
Finally managed to get those lunch breaks working properly in my solver but it's cost me dearly. The abominable hacks to the logic means I have no choice but to add customer-specific settings to my library's config, meaning that it's no longer a completely generalised solver :'( Pandora's box is open now; I bet a year down the line I'll have to support it running in 20 different configurations
@Aran-Fey Pretty much. It's effectively just a dictionary. MongoDB would support querying of JSON-like structures
Again, though, it doesn't package well because you'll still need the server. Maybe you will have to write your own implementation. That just seems... ambitious
 
Building something more convenient on top of sqlite shouldn't be too difficult... I hope
 
Are you sure that sqlalchemy + alembic hasn't already got this for you? Database migrations really are easy to apply in a prototyping phase
For SQLite3 you just have to remember to set render_as_batch=True if you start messing with the database schema. Not doing that will get you off on an annoying bad foot
 
10:02 AM
I don't know, maybe they can do what I want, but I've been reading their docs for 15 minutes now and all I'm thinking is "this seems needlessly complicated"
 
In terms of the ORM?
Once you have your classes set up to inherit from Base, alembic is a CLI with like 2 commands every time you rearrange your schema
 
But I don't want my classes to inherit from anything
Why do I have to write my code differently just because my data is going to be stored in a database?! What kind of spaghetti is this?
 
Because it adds utility to save you time? Otherwise you now have to write the boilerplate every time something changes
If you want to write your read/write queries directly, that's fine, but nothing is going to be there to keep your schema up to date for you if something changes in another part of your code
Also, you won't even have create_all(), the most basic of DB bootstrapping so it could be problematic with version control if you're disseminating your package
 
You know what, let's drop this topic. I should be investing all this energy into writing code
 
Sure
 
10:28 AM
@PM2Ring Thanks
 
 
2 hours later…
12:32 PM
Finding sequence length of DNA between 90 and 110. I used following code, but all of sudden I am confused. df = df.loc[(df['SeqLen'] >= 90) & (df['SeqLen'] <= 110)]. Is this condition okay? I mean it should be SeqLen > 90 or SeqLen >= 90. I $uck at maths :P
 
It depends on your problem
Iff you want length 90 to be included, use >=
 
the problem says this (between 90 and 110)
So i am confused
 
Ask who gave the problem. We can't help.
It's probably inclusive.
 
Okay. Thanku
 
I was just typing the same. I would always interpret it as inclusive unless specified otherwise
 
12:37 PM
@roganjosh Thanks
 
12:55 PM
Hey all, is there a preferred way to maintain a redis connection in a flask app? rn I make a new connection for every request I get
so if I go to my endpoint (get) and press refresh a couple times, my app crashes
 
cbg
What would be the best way to write settings of an app? configparser seems too much for simple settings, like dark=True, name=John, etc.
 
lazy option is to have a json
you can then read the json as dict and do what you want
 
What are the other options? I am looking for a good way, so that I can learn it in with small projects and expand it later on
 
yaml is more end user friendly from what I am told, other than these two I have not used others
 
I think its time I try yaml :)
 
1:14 PM
No
Yaml is inherently insecure. Toml then.
 
YAML is a good way for less technical people to screw up in my experience. Its formatting is sometimes more difficult to appreciate than JSON
 
1:29 PM
Ooo I see, let me give Toml a try then
So we have install toml first right? Then load the file
 
2:05 PM
Yes
And lo, the repo I've inherited with multiple branches, all at least 400 commits ahead of main, is biting. I've angered the git gods but I can't figure out what it's upset about. Please merge more often than this :'(
 
Life, uh, finds a way
 
January seems to be my month for Git-Gate. The 2022 edition is shaping up to be a doozie. I have no idea what's going on at this point :/
 
lambda:(map(lambda:(x:= "Teacher Response Rate") , self.arg1))
will it work?
as assigning value to string in my class
 
Does it work?
 
it seems legit but no
 
2:17 PM
Nope
You can fix it by removing two lambdas and a map
 
haha yeah but i need that in pyqt5 connect
 
No, you don't
 
In which case, it's unclear why you're asking "will it work?" since you already answered that part? It would be far easier to actually explain the problem rather than giving a disembodied attempt at code
 
Write out a proper function
Then pass the function where you'd use the lambda
 
yeah that's a long way to it I was just wandering if there was a shorter one
 
2:20 PM
For what reason?
 
@temoadeishvili there probably is but you won't know how it works and what it does two weeks from now
 
well educational purposes
 
For educational purposes write out the full function, then rewrite that to be a lambda
Obfuscation is a kind of refactoring so you must start from a working state
 
lambda cant do assignments to values from class (well not with my knowledge) that's what I was trying
yeah well thanks anyways I'll not bother you guys anymore today, have a good day
 
I can't commment on that without knowing what you're trying to do
@temoadeishvili you too
 
 
4 hours later…
6:17 PM
@feners I don't see any python there. So how about the SQL chatroom instead?
 
Sorry, it was dead so thought about asking here
 
So nobody answered your question you never asked?
 
Lol Andras
 
Chatrooms get frozen after 2 weeks, and that room is not frozen. People keep saying hi there. Perhaps if you ask a question you'll get a reply.
even active chatrooms get little traffic on weekends
 
 
1 hour later…
7:34 PM
cbg all
 
7:46 PM
cbg. Long time no see.
 
Yeah, that one's better.
Ideally, I'd want one where the questioner thinks the actual stored data is wrong, and the top answer corrects the misconception.
 
picky, picky, picky
stackoverflow.com/questions/53841516/… and unanswered stackoverflow.com/questions/45932197/… but overall worse than what I linked earlier
I guess you could just add all of the eligible ones
 
8:29 PM
Some of those answers are pretty ancient, and use clunky stuff to display all the hex codes. I didn't notice one using f-strings. I posted an f-string example as a comment, but I guess I can delete it if/when a suitable dupe target is posted.
 
@holdenweb yeah, I've been around, had my hands full :)
 
8:47 PM
So I had 2 dices (1-6 number each). I calculated all possible (36) combinations. Python code gave me this kind of output, which is okay. print(comb)
[(1, 1), (1, 2), (1, 3), ... (6, 5), (6, 6)].

Next, I calculated sum of all combinations. I used.
for n in comb:
    print(sum(n))
This gave me output:
2
3
4
...
10
11
12

Which is kind of okay, as the first combination (1,1) has sum of 2, and so on. But I want to calculate the average value of all the sum of combinations.
For that, I guess I have to first find the total sum of combinations, and then find average. How I can do that?
 
Do you know what the average is?
Mathematically speaking. What the definition is.
 
Like sum of numbers divided by total numbers?
 
total number of numbers, yes
So you have a loop with all the sums. You want to compute the mean of the sums. There are multiple ways to do that.
 
If you have a list of numbers, can you calculate the average?
 
@AndrasDeak Absolutely
thats what i want
 
8:53 PM
I leave you in the capable hands of Aran-Fey
 
waiting :D
 
2 mins ago, by Aran-Fey
If you have a list of numbers, can you calculate the average?
 
Don't wait. Answer.
 
my list have this: [(1, 1), (1, 2), (1, 3), ... (6, 5), (6, 6)] Not single numbers like [1, 1, 1, 2, 1, 3, ... 6, 5, 6, 6] but pair of numbers
 
that's not what he asked
 
8:56 PM
Okay, but what if you had a list of numbers?
 
yes, using
average = sum(list) / len(list)
 
Ok. So then all we have to figure out is how to create that list of numbers. You already have a piece of code that prints the numbers. Can you rewrite it so instead of printing the numbers it adds them to a list?
 
let me try
Done. So the sum of all combinations [2, 3, 4, 5, ... 11, 12] is 252 and the average is 7. Right?
 
Yep, good job
Break the problem down into smaller problems and it gets easier to solve
 
Yayy. Thanks u guys
@Aran-Fey yeah.
 
9:22 PM
side note: statistics.mean
And you need not build a list: you could have summed up the values in your original printing loop. And you could've combined that version with the list version (in a sense) and use a generator expression to sum the values.
 

« first day (4109 days earlier)      last day (833 days later) »