« first day (3842 days earlier)      last day (1331 days later) » 
00:00 - 17:0017:00 - 00:00

17:00
Is the issue that there's no stable commonality between book entries? If that really is the case then mongo might not be a bad shout
so basically all it does is query data from the Db and do nothing with it
just to open session
update function is being called every 1 second
I expect the average ORM would require one class per table. If you're comfortable with metaclasses, that could maybe let you churn out a lot of slightly different classes without too much typing.
and all it does is send a useless json object just to trigger the update function
why are you registering a teardown handler? I said twice that it was handled for you. I can't run it now, I'm out, but I wouldn't be surprised if that borks the natural behaviour
the error was occurring even with it, but I could remove it and test it out again
17:03
@roganjosh Pretty much. If I only had 3 classes in my project, I wouldn't mind writing a bit of boilerplate for an ORM. But I have like a dozen, and describing the layout of each class in ORM syntax feels like a waste when I've already described it in @dataclass syntax
i know its working because u can see this and it keeps going
You're not helping my mental debugger
use your local postgresql or you can get a free one from Heroku.com puts this a bit short of an A+ MCVE by my reckoning... But I knew all along that db/flask-y MCVEs are dang hard to make, so don't feel too bad about not meeting my high expectations
the "give A+ mcve, get troubleshooting" offer still stands indefinitely
oh thank you ^^
17:07
My question of why you have a teardown handler still stands in the meantime
I removed them
and still there is no issues
just ignore them , let me see if i can edit the link
So what does cause the issue?
oh btw, kevin. I don't think i'm going to allow the user to go back into the cottage.
I tried the dictionary version, but `in` didn't work...
@Kevin the ORM will do the joins for you. You get one class per table but it doesn't mean that you need to pack everything in that class?
That's why you set a relationship
@roganjosh not sure yet, that is why i called a failed attempt ..
17:10
I agree with your statements, although I worry I'm missing the overall point
Tbh I think I am missing it too now
Although in my original setup the models were in a different file and db were defined there, Not sure if that could be the cause of all piling up of the connections
@12944qwerty Oh, strange. Maybe repl does something strange to user input that breaks membership testing? In any case, you don't have to use a dictionary if you find it frustrating. Just one potential design.
nvm it was working I just had wrong outputs lol
I don't see how it's easier to handle an arbitrary number of metadata fields than try create some structure to the db
17:16
Making it so the user can't backtrack is rather un-zork-like, but that's OK because it doesn't necessarily mean you can't make a good game. As long as you're continually thinking of interesting new things you can make your engine do, then you're still gaining useful design experience
i might, i might not.. it mostly depends on how the story lays out
imma add achievements though
For example. Your first version had bullets, so I'm guessing you were already interested in having the ability to remove items from your inventory, not just add them. Make a gun that costs one bullet every time you fire it, that kind of thing
yeah, i'm going to do that
I'm very confused right now...
i'm also gonna do an inventory and achievements command
17:18
everything seems to be working fine.
but that will be a bit hard
@LoopingDev for?
LoopingDev has had a database problem all day, we think it might be a bug in the engine. All very mysterious.
@LoopingDev did you downgrade sqlalchemy?
which db type?
@roganjosh nope.
17:19
Suspicatus est
@12944qwerty postgresql
ooh
i can try helping in an hour or two when i get home
i gtg now so
:thumbs up:
Appreciated , cya , gl
I will go back to the system and try to mess it up again and see what I could pull out of it
but Now we know Sql alchemy is not the issue
engine is not the issue either
17:21
unless they're the issue but they only manifest under certain conditions. that's always fun
17:37
cabbage :D
ok I stopped it from crashing
still need to go back few steps to see what was really causing it
i dumped all the class file into the main file and that fixed it for whatever reason ( yet to find out )
maybe it has something to do with the order of importing things ;)
OK i really don't know...

having the models away from the main python was causing it
Python is usually good at handling imports in whatever order, but I'd be lying if I said I had never had problems with it
@LoopingDev This is your django project?
yeah I expected to be no an issue clearly its
@Code-Apprentice no i'm using flask
oh...nvm then =p
or maybe there is something that we dont know
17:50
with django, I found that the most common problems with imports are circular imports
maybe it needs to be setup in a certain way otherwise it wont know how to close the sessions ..
but I think the problems I encountered are specific to django
i could be very close in resolving this honestly .. but it took quite long to get here I dont wanna ruine it xD
my file is a little bit over 1000 lines now after dumping all the modals
Nothing wrong with being paranoid that you'll wreck your own program. Just make backups and/or use source control.
wow, that's a big file
17:52
Also very good for diagnosing "this was broken, but now it's working" mysteries
Or the other way around
@Kevin I do have plenty of backups, I've only tested that on the back , its yet to apply it to the Master version
do you use git?
u mean the test version that I shared ?
it had only 1 modal with 2 lines in it , maybe that is why it worked ?
@Code-Apprentice nope
I strongly encourage you to add it to your list of things to learn. It's a great tool that, when used right, allows you to recover from borking your code.
Then I'll come along, get a merge conflict, and probably delete both our code in a cloud of confusion :P
17:56
@roganjosh Unless you do something that borks the history, even that is easy to recover from.
and borking the entire history is very hard to do
@Code-Apprentice I'll think about it, thanks
"What's this .git directory? I never created it. And it's taking up so much space!"
@Code-Apprentice You can testify for me in the case of merge-gate Feb 2021. We still suffer some effects of that
@AndrasDeak Yah, rm -rf .git is one of the ways to bork your history.
That's why I copy my repo as backup. project_repo_v3_final_tmpbranch_final.
17:58
All I can say is that I clicked a lot of buttons in IntelliJ and stuff happened. That's all I remember, Your Honour
alternatively, push it to github
@roganjosh that's part of the problem. You need to know what all of those buttons do!
Well, some were green and some were red-ish. I mean, that's all I needed to know in terms of clicking?
I'm not using a GUI to learn all the buttons!
If it's red, pressing is rad.
you know , its such a relieved, for long time I thought socket Io and flask_login was a part of it so the first thing I did was removing the socketIO from the app

apparently, socketIO was actually very good at preventing it. after I removed it I got the error exactly on the 10th update, before, I could stay for hours before it occurs.
I learned git from the command line before using integrated tools such as IntelliJ. I don't think that path is 100% necessary, but in my case, I think it helped me form the correct mental model for what git is doing.
18:00
I thought IntelliJ (well, Java IDEs) were complicated. Then I found out a whole new arena of right clicking on some things and getting a nested dropdown of further options. At that point, I'm out
Before I even started my current job, I asked (well, damn near demanded) my boss to buy me a IntelliJ Ultimate license. I won't code without it.
Ctrl+Shift+A is the only thing you need...no searching through nested dropdowns.
I'm impressed by anyone who can navigate that properly. It's not the fault of IntelliJ but, oh my, it's so complicated to work with Java
I've done very little Java with it, but I can't imagine using it for Python is any less complicated. The key is to learn how to search for commands efficiently. I never click on menus or submenus.
You're joking, right? I haven't touched it since it last broke. I just need to scan to see if I have confidential info in the window
is it too bad if the python file was as big ass 1200 lines ?
18:16
I think a file can be as long as you want as long as you're very good at organizing
user13727121
How do I concatenate the result of maketrans() to an empty string before using translate() on it. Example: dpaste.com/D3M2MW7BM (I know it seems unnecessary, just wanna know if it's possible)
I dont know what is your definition for "Very good" but my file look like this

1- definitions
2 - classes
3 - routing
4 - functions
@CoreVisional res += encrypt seems like it would work fine to me.
user13727121
yeah that's what I thought when I tried that, I got a TypeError, unable to concat str to dict
Hmm, I think I misread the code.
How about res += str(encrypt), then?
user13727121
18:24
didn't work, the output is 17, , : : 890:, - the expected output: jxyi yi qd unqcfbu.
Strange, jxyi yi qd unqcfbu. is exactly the output I'm getting. I don't see "17," or anything similar
@LoopingDev that seems like a good system. Personally, I don't like large code files and will break them up.
@LoopingDev When it comes to solo personal projects, really the only thing you need to consider is, "do I know where everything is?", or at least "do I know how to find everything efficiently?"
user13727121
the argument given to translate() is supposed to be res, right? If so, my output is incorrect. print(plain_text.translate(res))
It doesn't matter if your organizational system is unusual if it works for you
@CoreVisional you had print(plain_text.translate(encrypt)) originally, I recommend sticking with that
18:29
@roganjosh joking about what? about not clicking on menus...nope, not joking. I use the mouse as little as possible. Ctrl+Shift+A is the most useful shortcut in intellij. And I use a lot of other keyboard shortcuts.
what does that shortcut do? curious
It's "search for action"...basically searches all of the menu items and settings for whatever you type.
ah gotcha
very...meta
For example ^
and like most searches in intellij, it matches on word boundaries. You can type the first letter or two of each word in a command and it will match
I should get a commission from JetBrains. I sold my last company to convert entirely to IntelliJ. Every new dev automatically gets a license.
I guess they can opt out if they want...they hired a lot of new peeps after I left 2 months ago.
user13727121
@Kevin thanks but I found a way to do that, I had res as an empty string instead of an empty dictionary, changed that and update it using .update(), res.update(encrypt) and I finally got the output correct
18:41
I still don't really understand why you need to copy encrypt into an empty anything to begin with, but if you're getting the results that you want, more power to you
It's fun to talk about maintainability and efficiency and elegance and all that, but at the end of the day I sleep soundly as long as my code just works
user13727121
@Kevin nah it was nothing, just...curiosity.
Well alright then. I'm quite familiar with having "I just wanted to see if I could" as my one motivating factor
user13727121
yeah apparently, I asked Google the wrong question because there wasn't a single solution about concatenating result from maketrans() to an empty string and use it on translate(), only to realize maketrans() returns a dict and dict has a way to update the value, or "concatenate" it into an empty dict...
user13727121
well that was dumb, but anyway, I appreciate the help
Any time
19:05
ohh ? no I dont have any issues with that

I was worried about the application ( webapp ) performance
Performance shouldn't be a problem, the parser can read one long file just as efficiently as it can read a handful of medium files
As long as it doesn't crash with a MemoryError because you tried writing a 10 GB program, you're probably good
Thank you!
my app is less than 2mb so far lol
application.py ( the main file ) 20kb xD
Yeah that's within acceptable limits :-)
19:23
that great to know ^^
20:00
Python is not showing runtime errors in threads other than main thread. What should I do?
I am using Python version 3.8
@Abhijeet.py I'd first check if that's supposed to happen
That is happening, I need not suppose. My program was hanging for quite sometime.When I checked it line by line, I found an error in the function assigned to the thread. But, Python never reported it, though, it was making my program halt from the point of error.
Now that I have removed the error, my program is working fine.
20:21
@Abhijeet.py please see our code formatting guide to chat and practice in the sandbox if necessary
that works too, thanks
@Abhijeet.py Since tkinter is part of the MCVE: does the issue go away if you remove tkinter?
I tried it on anaconda and it is working. But, it is not working on cpython version that I am using.
Tkinter isn't thread-safe. Modifying your tkinter GUI outside of the mainloop results in undefined behavior.
@Aran
Thats what I was expecting
UNPREDICTABLE BEHAVIOUR
20:23
Although, looking at it more closely, it crashes before ever doing any tkinter stuff
@Abhijeet.py do you have to shout?
Is there any way I can resolve thread safety issues while working with tkinter?
Actually that code crashes just trying to start up the 2nd thread. Are you 100% sure that code doesn't produce an error message?
Ok, then I have no clue
20:27
But, this is a minimal example. I have a more complicated project involving around 12 threads that moniter and draw/destruct things on the tkinter canvas. Can I do something to make my program thread safe while working with tkinter?
The common "solution" is to use root.after(0, some_function). This will arrange for some_function to be called by the tkinter mainloop. But I'm not 100% sure if root.after itself is thread-safe, so...
That isn't safe! I have tried using root.after(..) and also <canvas_instance>.after(...), but, they halt the process of drawing even by threads that have not called the .after function.
That sounds like you're making the mainloop execute a long-running function
Obviously the GUI can't update itself while the mainloop is busy doing something else
The mainloop should only update the GUI, nothing else. Or as little else as possible. Definitely not anything that takes a while to complete.
20:37
@Aran-Fey After the mainloop is called, other threads in my program successfully use the time.sleep(..) to successfully invoke any required delays. The only problem occurs when an eventual thread safety issue or runtime error halts one of the threads and the program fails to pause.
gui interactions in the main thread, long running tasks in the other threads, communicate via queues. i imagine that should be fine, as long as youre not trying to run gui operations from the other threads. make every gui interaction on the main thread.
anyways, sounds like a lot of pain.
I have a class with an attribute that is a tuple. When I iterate through an instance of the class, I want to iterate through the attribute that is a tuple. I've done the following but I'm not sure if this is "good".
from dataclasses import dataclass

@dataclass
class A:
    a: tuple

    def __iter__(self):
        self._i = 0
        return self

    def __next__(self):
        i = self._i
        self._i += 1
        try:
            return self.a[i]
        except IndexError as e:
            raise StopIteration

list(A((1, 2, 3, 4)))
# [1, 2, 3, 4]
That is painful :( . The program is foundationally designed to use different threads to draw and destruct from several different threads.
sounds like the program is foundationally a bad idea with tkinter
@piRSquared is that tuple actually an immutable list?
20:43
Maybe, because, initially, I didn't knew that tkinter isn't thread safe!
@piRSquared if there's one thing i've learnt, getitem and len dunders are enough to make an object iterable.
doesn't matter. I just want to iterate through my object by passing the iterating responsibility to an iterable attribute.
@piRSquared Are you sure you want the instance to be its own iterator? If so, I don't see a better way to implement it
If not, just return iter(self.a)
@Aran-Fey that's perfect
Actually, setting self._i = 0 inside __iter__ would be a violation of the iterator protocol. Calling iter() on an iterator is supposed to be a no-op, but your iterator would rewind instead (another thing iterators aren't supposed to do)
20:50
@Aran-Fey w3schools ftw
ha, nice
Anyway, my bed is cold and lonely, so I'm gonna go keep it company for a couple hours. Rhubarb
@piRSquared w3schools now? That's low :P
/shakes_head_in_shame
21:11
@piRSquared What would happen if two nested loops both iterated over the instance? Wouldn't they fight over the i attribute's value?
@holdenweb not anymore
from dataclasses import dataclass

@dataclass
class A:
    a: tuple

    def __iter__(self):
        return iter(self.a)

list(A((1, 2, 3, 4)))
# [1, 2, 3, 4]
There was something fundamental that I didn't understand about implementing an iterator and that helped clear some of it up.
I'd have thought it was easier just to have the __iter__ method return iter(self.tuple_attr) - you can then have as many concurrent iterations as you like.
Ah, I see you got that already!
I was getting confused with the__next__ dunder. Now that I see it, it should've been obvious /-:
I'm sure someone else has already done a better job of this but I got enamoured with making a simple single variable Polynomial class after messing with project euler. So I whipped this up.
Each position represents the coefficient of a term in the polynomial. You can do this
print(Poly((1, 2, 3)))
print(Poly((1, 2, 3)) ** 2)
print([*map(Poly((0, 0, 0, 1)), range(1, 5))])

# 1 + 2n + 3n²
# 1 + 4n + 10n² + 12n³ + 9n⁴
# [1, 8, 27, 64]
there are at least two polynomial classes in numpy
not sure about rich arithmetic operators and whatnot
@Code-Apprentice I found myself with this. Turns out that it compiles to a JAR.
I... don't find that to be a workable IDE
The extra windows obviously don't exist in normal use, but when something goes wrong, it just explodes with windows and options
21:29
@AndrasDeak go figure ;-) Well it was fun to write. Now that I'm looking at Numpy's I'll try to subclass it.
Everything in the left panel can take a right-click with another nested list of options but I'm not going through the exercise of trying to edit again on a mac to scribble things
@piRSquared go for numpy.polynomial.polynomial.Polynomial stackoverflow.com/a/58664645/5067311
although it's possible that the legacy thing is not even a class, just helpers that return arrays/lists
21:57
@Aran-Fey genuine C-style undefined behaviour?
Not that I think I'll find myself using tkinter, I'm just curious about that particular point
I noticed some unexpected weirdness in **computing intersection of key views on dicts, the naive approach is not insertion-order-preserving**. When you dig into the Python spec closely, this is implied but it's unexpected gotcha to the spirit but not the letter of the spec. The one-line summary seems to be "Dict keys views are hybrid set-like objects which preserve insertion order, but the moment you use set operations on them that order goes out the window".
- dicts preserve insertion order
- Keys views are set-like, yet they also preserve insertion order: https://docs.python.org/3/library
d1 = dict.fromkeys([*'ECBAXYZ'])
d2 = dict.fromkeys([*'EBFXZ'])
d1.keys()
dict_keys(['E', 'C', 'B', 'A', 'X', 'Y', 'Z'])
d2.keys()
dict_keys(['E', 'B', 'F', 'X', 'Z'])
d1.keys() & d2.keys()
{'B', 'X', 'Z', 'E'}
I don't think I follow the shocker on this? Why would you rely on ordering here (I could be totally off - it's a genuine question)?
22:12
Yeah, what if d1 and d2 have keys in reverse order? How should the result be ordered?
It can't work in general so it shouldn't work for the specific
My point is that the gotcha is implied by all the spec laboring about guaranteeing "dict keys views are hybrid set-like objects which also preserve insertion order".... But the moment you actually use set operations on them that order goes out the window. So, dict (keys) views are semantically very weird hybrid objects: something like an OrderedSet that implements the set() interface... and stops being ordered if you call those.
The keys objects are ordered. The result of set operations on keys objects are sets. Which aren't ordered.
My point is to draw attention to the gotcha, that's all. It just bit me. Next, how would I compute keys intersection in a (performant) order-aware way, without iterating over one dict's keys() and test each key is in d2.keys()?
I'm saying it's not a gotcha.
I mean yeah, someone might not think about it at all and be bitten, but that's mostly their fault. If it's trivial in hindsight it's not a gotcha in my book.
I'm not sure on the gotcha either, Andras just types faster than me
I'm curious about what blew up for you
22:17
@AndrasDeak As a 21-year user of Python who's thought about these things plenty, I'm stating my opinion that this is a gotcha, IMO. There's a lot of laboring in the spec about what dict views do guarantee.
@smci and they do
d1.keys() & d2.keys() is not a dict view
But this is not something we'll agree on. I say brain fart, you say gotcha, we'll agree to disagree.
@AndrasDeak I know that and I never claimed it did. It's an expression using set operations on keys views. Which throws away the ordering that the keys views labor the point that they guarantee.
Do we agree that sets are known not to be ordered?
I'm not sure this is going to be constructive at this point?
@roganjosh But my examples above points it out! The insertion-order-aware intersection would be E,B,X,Z. But using set operations d1.keys() & d2.keys() gives {'B', 'X', 'Z', 'E'}. Insertion order got thrown away the moment we started using set operations.
22:22
d2 = dict.fromkeys([*'EBFXZ'][::-1]) # what now?
@AndrasDeak Yes, I posted that above at the top, that's what I'm pointing out. But the spec doesn't say that "keys views objects are hybrid objects that do implement the set interface, but don't implement set operations in an order-preserving way". To prove the point, one could implement keys views objects that did implement set operations in an order-preserving way, yet implemented(/kludged) order-awareness on the result. Those would also be compliant with the Python spec.
@smci it points out a behaviour but not one I'd rely on, nor something I'd expect others would. Since you've raised it, I sensed that something blew up for you
OK
> one could implement keys views objects that did implement set operations in an order-preserving way,
No.
and that's my bottom line :P
@roganjosh Syllogism: a) "dicts respect insertion order" b) "dict keys views respect insertion order" c) keys intersection can be computed from keys views. Yet if you do it naively using set operations, it throws away insertion-order. And to do it in an order-aware way, I reckon you'd have to sacrifice performance. (I'm working on a project with multiple dicts, some will eventually be nested and get very large. Obviously you'd have to flatten the dicts before computing keys intersection).
@AndrasDeak If when you reverse d2's keys, you're asking "what is d1.keys() & d2.keys() then?" it's {'X', 'Z', 'B', 'E'} It doesn't follow either dict's insertion order.
I'm getting confused. I don't think python ever promised anything of this sort (apologies). Sets are still unordered and python is unambiguous about that. "Yet if you do it naively using set operations" - well that's not a dict operation, is it?
22:38
@roganjosh I've already explicitly said that in my original post. "When you dig into the Python spec closely, this [behavior] is implied but it's unexpected gotcha to the spirit but not the letter of the spec." Ok? That's why it's a gotcha. It's annoying and misleading reading tons of posts about how magical dict views are in preserving order, without one caveat about "...but be careful about using them set operations". As said, I want to compute insertion-order aware intersection.
Conversely, what do you guys think are genuine Python gotchas?
Well, I failed yesterday with .readlines() and writelines() because they don't handle newlines correctly and I went back to being a noob
No, I mean actual genuine Python gotchas, from where the spec is unclear or conflciting, on something important?
22:43
You mean to say that writelines() doesn't actually write lines is not a gotcha?
I think the most "fun" I've had with python is with Futures that just keep going. As I relayed it to my colleagues - it's like those vids where you stomp on a spider and suddely all the baby spiders burst out. Everything else is generally me being dumb
@roganjosh To parody Andras :) , if the method name happens to be buy_puppy() but a close literal inspection of the spec doesn't say it buys you a puppy (even if the class description waxes on about puppy-buying and the implied intent to support it), then no puppy(/newline) you get. Anyway, OS conventions on CR/LF were a known issue back in the 1970s already.
@roganjosh "vids where you stomp on a spider" Funny I was just independently thinking of Tron earlier.
23:09
cbg
23:19
cbg
23:37
I just reported this unattributed clone site: https:// www.javaer101.com /en/article/18783067.html (SO original was this). The scary thing is it had #2 SEO ranking for a Google query with specific keywords.
00:00 - 17:0017:00 - 00:00

« first day (3842 days earlier)      last day (1331 days later) »