« first day (4218 days earlier)      last day (953 days later) » 

00:10
@roganjosh I did not understand you.
 
4 hours later…
04:15
@Kevin Thanks this helped
def get_path(task, graph, child_list=[]):
    child_list
    for child in graph[task]:
        if child not in child_list:
            child_list.append(child)
            get_path(child, graph, child_list=child_list)
    return child_list
Ended up with this
Although now that I have a list of the children nodes the order is still not too clear. Since even the children of the children will be in the same list. The only ways I can visualize more properly is maybe draw an actual graph using data visualization packages or create lots of nested lists to bunch them together (although it will be unreadable if the nests become large)
 
5 hours later…
09:07
I am new to python, so my question can i able to do something like this inside a class ? My class looks like this ?

class Xxx(object):
def __init__():
....

def _something():
.....
.....
send_message("success")

return ..

def _first():
.....
try:
'''
except Exception as ex:
return ex



and all i want is if _something() failed then it send_message("failed") with the proper error message how can i add a functionality inside _something() and catch the error from _first()
def _something(self):
.....
.....
send_message("success")

if not self._somethig():
send_mmessage("failed", errors)

return ..
First of all, how can you tell whether _something() succeeded or failed? Does it throw an exception if it fails?
hey guys, how to unit test my class "Stack" which has a "push" function, I want to be able to check if my push succeeded
push returns None, and I am not exposing the list I am using as a stack publicly
yes if it fails then it throws errors
Then just use a try ... except to catch the exception
can i able to do this inside _somethig()
09:16
Sure
@Jake push the item on the stack, then test that pop'ing returns the item.
ok thanks
ok, then my push unit test would depend on my pop right?
okay i will do that
09:20
@Jake I would make that one unittest.
ohh ok, isn't the point of unit test to just test one function?
A stack means that whatever you push on it gets popped in LIFO order. There is really no way to test each in isolation.
but your idea makes sense and test is easier, it just does not resonate with what I know
@Jake I would say one functionality. That can well span several functions/methods/attributes.
is accessing the "private" list ok for a test? my_stack._Stack__stack
09:22
No. Don't couple your tests to implementation details.
Anybody used github.com/bartdag/pylinkvalidator when the website is mostly hidden behind a login? And it's not a simple http login, but the django one
got it, thanks a lot
@Hakaishin Won't be pretty, but it should work if you make it send the appropriate headers. Probably a cookie that contains your session token
@Aran-Fey darn, I was hoping for an easier solution :P
Wes
Wes
09:44
pastebin.com/raw/Pr461PaZ thoughts folks? double queue based off aran's suggestion from yesterday
it seems to work but it still feels more complicated than it should be
Are you sure you need the requests queue? If you have a fixed schedule like "1 request every second" you might as well implement it directly in push_updates
The requests queue is sensible if you also use it for shutdown. If you just use it as a trigger, a lock or event might be more sensible.
Wes
Wes
@Aran-Fey the rate of messages should be determined from the parent process, not the child
it's user configurable, and there will be a button for refreshing manually
because pysimplegui is heavy af and it destroys my cpu if i set a low refresh rate
wat
That's one more GUI framework I'm crossing off my list...
Wes
Wes
10:00
it works fine as long refreshes are triggered by an user event
if you want to continuously refresh a treeview for example, it's gonna destroy your cpu, unless you set it to high refresh rates
That's it. Time is officially shaped like a Klein bottle, and we live at the part where the 21st century overlaps with technology from the 1800s
Wes
Wes
:B i am a bit too negative maybe. i have a ton of widgets that need continuous re-render so that's problematic for me. overall pysimplegui is ok. it has a ton of bugs but you can manage to build things if you don't give up
Well, there's also the fact that I tried to use tkinter again yesterday (even though it's the first entry on the aforementioned list of GUI frameworks), and had to pick something else because I couldn't figure out how to make a Frame with a scrollbar.
I might have to learn PyQt now...
Wes
Wes
iirc scrollbars in tkinter are separate elements you can put in arbitrary places
so you have a frame here and then a scrollbar element somewhere else that targets that frame
it's not they come as a single widget
Yeah. Then you connect them to the widget you want to scroll, but only if that widget actually supports scrolling... which approximately 3 widgets do
I found some hacks with a Canvas on google, but those didn't work properly either
Wes
Wes
10:10
the problem with tkinter is that there is no documentation available
otherwise i suppose it would work fine
There isn't? I didn't have much of a problem with documentation yesterday
Wes
Wes
all the documentation i'd find was outdated, didn't work. same goes for answers on stackoverflow
it's like every single version of tkinter is 100% incompatible with the previous
qt and gtk are surely higher quality, but they are like 500mb each
that's the main reason i didn't pursue that route
5mb program with 500mb gui toolkit is comical
I'm pretty sure tkinter doesn't receive particularly many updates, and especially not any compatibility-breaking ones...
Wes
Wes
consider i am a python learner, so that might have contributed to it
10:26
Is the tkinter backend actually decent?
backend?
That _tkinter thingy?
Ok, that raises some new questions... 1) Decent for what? 2) Why even ask that about an undocumented module?
Wes
Wes
should i bother to terminate a thread before i terminate its process?
10:42
No, there's no nice way to shut down a thread anyway
I don't understand why people still bother with tkinter or any other python gui program. Just use flask, fastapi or django and you get a gui plus it can be accessed over the network plus you can even make it into a website if you want
tbf js and css are not the nicest things, but still better than fighting the weird tkinter ecosystem
When it comes to development is it easier also to use web based guis or do you need to know more?
Like html, css, and etc. I have no clue about the stuff I need to know
You need to know completely different things
I have only used plotly and it was quite simple but I always felt web based GUIs to be more difficult and less responsive
I really hate the loading times generally
But maybe if it's local maybe it's the same i don't know
10:48
@Hakaishin Call me old-fashioned, but I want my apps to have their own windows, and not browser tabs
If I was going to develop apps to help me on my daily life and not really share to others is it still better to go web based/
@Aran-Fey high price to pay for a small stylistic choice
Plus, I don't like programming in JS
@AndrasDeak--СлаваУкраїні for users like me all I care about is how much simpler and faster I can get what I need running so if different means going out of my way to learn other stuff then it's probably not the best choice for me
@Pherdindy I do all my apps as websites that run locally, very convenient. Because when I make something I find useful, it's usually just as useful to use from mobile. Sure it might be a bit annoying, but so is getting up from the sofa :D
10:51
@Hakaishin I would learn more stuff if I had time but programming for me is a huge opportunity cost since i've actually slowed down my progress in my business to learn and develop scripts
Ah for sure, if you didn't have prior experience with website than tkinter might be easier, especially if programming is just a side activity
I just really believed the scripts would pay me back so I took the risk
Yes just to help me on my decision making generally
@Pherdindy fun fact: web apps are great if you know how to make web apps
For sure I have created one using plotly and it was much simpler than PyQt5 and maybe I can access in the web once I learn how to which is convenient
PyQt5 seems to be real annoying to work with
My only issue with web apps are the latency maybe. I used to work at Bosch when I was in highschool and the SAP system had like 3-5 second loadings time per button
Or more and I just remember the drag waiting for each page to finish loading
@AndrasDeak--СлаваУкраїні underrated :D
11:05
@Aran-Fey Just asking out of pure naivety. It seems the tkinter API is pretty horrible, but people still use it. Surely that's because it's lightning fast and super efficient, no?
Ah. Well, it's certainly fast and efficient in the sense that it's (usually) pre-installed, but that's about it...
@AndrasDeak--СлаваУкраїні "lead–acid batteries included"?
11:19
@Pherdindy I'm glad to assist :-). Incidentally, your child_list=[] in your function parameters, will cause a bug if you call the function more than once. Mutable objects should (almost) never be used as a default value; that's why I did seen=None in my prototype rather than seen = set().
hi, I'm currently working on a CLI based event management system program. I was wondering if my style of file structuring is correct. Since I'll be working with files alot, I have created a folder called "data" that stores those files. Currently, the file structure of this project goes like this:

- event_management_system(root folder)
    - data
        - sample.txt
    - src
        - admin.py
        - customers.py
        - main.py (is this needed?)
    - README.md
looks fine
you might want to use pyscaffold, but that might be overkill
only you know if main is needed, what is in it? Do you use it? Otherwise there is no reason why it would be needed
May I get some inputs on this kind of file structure on this size of a project? The ones I see online were mostly about "packaging", the thing is that I'm creating a package...or did I misunderstand the meaning..
@Hakaishin I'm thinking of using main.py as a module that calls the other modules. I have a feeling it's wrong to do that
@CoreVisional not really no
@CoreVisional it's python who cares about size of projects
def get_path(task, graph, child_list=[]):
    for child in graph[task]:
        if child not in child_list:
            child_list.append(child)
            get_path(child, graph, child_list=child_list)
    return child_list
graph = {"A": ["B"], "B": ["C"], "C": ["D"], "D": []}
print(get_path("A", graph)) #output: ['B', 'C', 'D']. So far so good.
print(get_path("C", graph)) #output: ['B', 'C', 'D']. Strange, we expected ['D'].
11:24
@CoreVisional about packaging I'm not sure how to do that correctly without pyscaffold, but pyscaffold works reasonably well
@Hakaishin my bad, I missed out a word. I'm not creating a package but a simple CLI program.
@CoreVisional ok, and?
@Hakaishin so I'm wondering if having a directory called "src" is needed. Like, should I just throw all the modules under the root directory or it's more "structured" by containerizing those modules in another directory
@CoreVisional You should try to organize this as a (source code) package instead of a bunch of modules and files in folders. There should be a parent package (folder with __init__.py) that contains the source code and data.
that depends on your taste and the size of the project and the taste of other people, the bigger the more folders you would want to have. You can also start out flat and then start grouping things if you have too many files in the same directory, like this the organization grows organically
11:29
@Hakaishin Partially agree; it depends on what you're trying to accomplish. A lot of my GUI-related projects need to update the window contents thirty times a second. I could do that inside a web browser, but then 99% of my project's code would be JS. With all the pros and cons that entails.
Well yes, if you have a demanding gui app then don't make it a website, but then don't make it tkinter either, use something better, I assume C# is decent for apps together with the .NET stuff for linux I think going straight to QT is the best
Python's "unit" of code that belongs together is a package. Trying to duct-tape together individual files is possible but a lot of hurt.
That also gets you half-way to the benefits of having a src directory – it's effectively trading convenience of a flat layout versus robustness of isolation.
:54490094 so something like this maybe?

- event_management_system(root folder)
    - data
        - sample.txt
    - src
        - myproj
              - __init__.py
              - admin.py
              - customers.py
              - main.py
    - tests
      - test_main.py
    - README.md
I would move the data into myproj, but other than that it looks good.
Might want to change main.py into a __main__.py so that the entire package is the executable.
i thought src should only be storing the source code. The data folder will mainly be storing like text files
11:36
@MisterMiyagi _tkinter is effectively a thin wrapper over Tk/Tcl. Tk/Tcl itself does not have a lot of WTFs. But it does use a command-based framework that can seem a bit strange when _tkinter fold/spindle/mutilates it into the shape of an OOP framework.
@Hakaishin I think I might want to use this, though it might be an overkill like u said. Still, it seems pretty handy
@Kevin Hm, interesting. Inquiring for a friend, of course.
"tkinter is not documented" is technically true, but many of its mysteries can be solved by reading the Tk/Tcl documentation. But I don't begrudge anyone who says "no thanks, I'd rather not learn this entire other mini-language just so I can figure out what tkinter.bind() can do"
Incidentally I'm currently trying to determine whether Button.command can take a callback that has more than zero parameters. bind can do it pretty easily, but I don't think command works the same way.
That whole section on percent substitutions for bind is a great example of something that basically makes sense as a feature in a command-based framework, and very little sense in an OOP-based framework
12:29
@Kevin Hate to admit it, but that is a super interesting read. Admitting for a friend, of course.
@Kevin I don't think it works like that. Tk only receives the name of a "command" (or "script") to execute. Creating a script from your function and arguments is tkinter's job. Here's the relevant code
12:58
In truth, I'm only really interested in getting the name of the widget that triggered the callback. I can see in tk's source code that tk::ButtonInvoke receives %W as an argument, so in principle it should be available to tkinter. Maybe.
Anyone familiar with threading in Qt? I can't figure out how to (safely) update the GUI from a thread. Here's my attempt - there's no exception or anything, the label is just never updated. If possible, I'd like to keep the architecture the same (in other words, only call_in_thread and call_in_mainloop should be changed, not the other code)
 
1 hour later…
13:59
Possibly an apples-and-oranges comparison, but I usually go with message passing when I need to do threaded stuff with tkinter. The worker thread puts strings onto the queue, and an on_idle callback in the main thread gets strings from the queue and fiddles with the UI as required
Since this would require a change to your architecture and might not even be applicable to your UI framework, feel free to ignore me
14:20
Good idea actually. If I can just find a way to the mainloop (I think Qt can have more than one?), the architecture might even stay the same
I would have expected Qt to have something like that built-in. It's basically how the async frameworks handle foreign-thread requests.
stackoverflow.com/a/36989567/953482 proposes a Timer object, although a commenter complains about something something threads something something
If a tkinter user had the same objection, I would tell him to simply not do the thing that would cause the problem
I have also heard whispers of a "Qt Concurrent" module that can do many things. I can speak no more of it.
14:37
QtConcurrent doesn't seem to have a complete python wrapper. It generally seems a bit too high-level for my purposes, except for the run function, but that doesn't exist in PySide6...
I really don't get what's wrong with the Timer. If you try to use it from a non-QThread, it throws an error. But I don't get an error. It just doesn't do anything.
Doesn't matter if I subclass QThread or if I throw something into the global QThreadPool, nothing happens
anyone have any opinions on mixing yields with returns? I'm very interested in /why/ it's a bad idea aside from "it confuses the heck out of people who don't understand yield"
If you're using the return to exit the function, I don't see a problem. If you're returning a value, it gets confusing
I don't mind seeing yields and returns in the same function
Since post-yield statements are executed after the yield, I was using return to early-stop the function, while also returning the value. In this specific case, the returned value had some error information, whereas normal function execution continually yields sane values
what I turned out to be wrong about is that the returned value doesn't actually return the value. The return has the same effect as raising a StopIteration, and the value is lost
The value is actually an argument for the StopIteration exception
14:50
iiinteresting. Thanks. I wonder if there's an intended usecase for this
I'm fairly sure coroutines use that for something, but other than that...
The value attribute was added as a feature not too long ago, so maybe you could track down discussion regarding its merits
 > Changed in version 3.3: Added value attribute and the ability for generator functions to use it to return a value.
that's really cool. Thanks folks
15:18
Here is the culprit that gave StopIteration a value attribute. PEP 380 explicitly proposes the feature. Apparently it makes whatever = yield from expr easier to implement?
The final two paragraphs of criticisms discusses the sins and virtues of StopIteration.value
@Kevin , the imposter.
long time no see
Hail and well met
Quick question. Refamiliarizing myself, probably haven't touched python since 2.6/2.7. I feel like this could be turned into a one-liner, but don't know what that would look like, any input?
    address = 0x1000
    for byte in data_bytearray:
        ih[address] = byte
        address += 1
Something like ih[0x1000:0x1000 + len(data_bytearray)] = data_bytearray
Depending on the type of ih, of course
15:31
@vaultah wonderful. you're right, depends on the type of ih. ih __setitem__ performs this if using slice, if not isinstance(byte, (list, tuple)):
so it fails because bytearray isn't list or tuple. easy fix would be list(data_bytearray), right?
No, I don't see how that would help
@inspectorG4dget It's used for yield from and await return values. Basically custom and proper coroutine frameworks.
Actually, I'm confused. "I feel like this could be turned into a one liner" implies that your code works, albeit in a wordy fashion. But "It fails" implies that it does not work.
@Kevin well it does lol. I'm not sure if you're familiar with intl hex file format but this is what i'm referring to, github.com/python-intelhex/intelhex/blob/master/intelhex/…
@MisterMiyagi Iiinteresting. I think I'm going to spend a good chunk of the afternoon looking up custom coroutine frameworks
15:37
@Kevin "It fails" was directed at the proposed one-liner. And yes, the code works as is, but I wanted to see how it would look as a one liner simply to expose myself to that thought process.
Well, alright then. It's silly that __setitem__ doesn't accept a bytes, but if it wants a list, then give it a list
I hereby retract my statement of "I don't see how [list(data_bytearray)] would help"
FWIW, I vaguely remember that I once had a tree traversal function that yield'ed individual results and return'ed aggregates. Been a long time, though.
@Kevin I simply did list(data_bytearray). Are the brackets meant to be `, or is there is a reason you added them?
I added them to indicate that I altered the exact phrasing of the original quote. To give a nonprogramming example, the quote "my neighbor steve is noisy. He mows his lawn every day" may be changed to "[Steve Steveson] mows his lawn every day"
Right, proper English.
[list(data_bytearray)] might've made it more clear ;)
15:47
Do we have an imposter...
Yes, the other guy.
Just light reflecting off a weather balloon, citizen. Go about your business.
Laurel, could've gotten matching PFP too :P
Our SO birthdays are 4 months apart as well. I'm the younger Kevin, I'm much more fun at parties. I use my KVM switch to chat from my imposter account and have conversations with myself, as you can see. Some call it MPD.
16:13
stackoverflow.com/questions/50821312/meaning-of-python-m-flag Is there a more specific version of this answer that focuses on the semantics of python -m pip vs. pip directly (similarly for other popular packages that provide entry points, such as flask)?
Wes
Wes
16:25
i did it \o/ thank you folks for the help. i have managed to unleash the full multiprocessing power
I have a jupyter notebook on remote server and need to access it on local machine, I am on windows on my local machine, so far none of the tutorials seem to help. Remote is ubuntu
I am using this command : jupyter notebook --no-browser --ip="localIPaddress" --port=8080
I tried putting remote IP too, the same IP as of my server where I am running this command, still doesnt work
Is the server configured to be visible from outside?
16:46
yes
ssh -i C:\id_rsa\priv_key.ppk -N -f -l localhost:8080:localhost8080 ubuntu@IP is also what I tried from one other tutorial it keeps saying permission denied public key, does it mean I have to add my local public key to remote first?
This is a different machine than the usual of which the key pair was generated.
I wonder if I should change my handle to totallyNotKevin and start a movement in which we are all Kevin
we could have a Kevout, Kelvin, Kalvin, KevinAndHobbs,... it kinda writes itself
Is the Kevin we think as the original the "actual" Kevin though, he could be you know, Josh
This room aint big enough for two Josh's
@AshwinPhadke how have you configured this to be visible from the outside?
Wes
Wes
17:08
def worker():
    telemetry = ...
    configuration = ...

    def thread():
        nonlocal telemetry
        nonlocal configuration
        telemetry = ...

    t.Thread(target=thread, args=(), daemon=True).start()
is this a bad idea?
read and reassign variables from the outer scope
Not necessarily
Wes
Wes
it appears to be working correctly
mostly i am trying to avoid passing a ton of variables via Thread(args=)
thought to try lexical scope and that worked
sounds like a recipe for race conditions, if any other threads (particularly, the main thread that called worker in the first place) will also modify the values
to "avoid passing tons of variables", the standard solution (not just in Python) is to create an appropriate data structure and just pass an instance ofthat
though as it stands, it seems like you only have two
17:24
The GIL prevents some of the nastier kinds of race conditions when two threads access the same object. That just leaves the merely moderately nasty race conditions.
When it comes to testing threaded programs, "it appears to be working correctly" is not the last step, it's the first
Wes
Wes
you are sounding scary
pls stop
do i risk stuff like deadlocks, memory corruption?
In my experience, it's very hard to corrupt memory. I would only expect deadlocks to occur if I inadvertently created one myself using Locks and other such synchronization objects.
I reckon you're more likely to see code that runs but produces seemingly impossible output; or code that crashes (with an ordinary stack trace) on seemingly valid input.
For example, you might discover that if len(my_list) > 0: print(my_list) ocassionally prints an empty list. Similarly, if len(my_list) > 0: print(my_list[0]) might crash with IndexError: list index out of range
Wes
Wes
i see
(I agree with that assessment)
Wes
Wes
i should be fine because it's all immutable objects, or objects i am no longer changing once they are "shared"
but we'll see
thanks again for the help
17:39
Immutability is good, not changing things is good. These will work in your favor.
Wes
Wes
17:59
yeah i figured mutable stuff would make stuff a lot more complicated if not impossible
Complicated yes, impossible rarely
Wes
Wes
18:19
so process forking is not an insult
all the state from the parent process gets copied to the child process, isn't that wasteful?
Depends on how the OS does it, I guess? It might only copy individual memory pages on demand, when they're first modified
Wes
Wes
i see
I thought windows didn't do fork
just skipped everything and went the way of WSL and now it works, thanks everyone.
Windows might have experimental forking, but whenever I use multiprocessing, it seems to just open up an entirely new python executable for each worker
I know this because only "entirely new executable" mode throws a fit if you don't have if __name__ == "__main__":
It's "spawn" mode, apparently. The only mode formally supported for Windows. docs.python.org/3/library/…
Oh, spawn mode doesn't work with frozen programs. Let @Wes beware. I recall some freeze-related code in his MCVEs the other day.
I think threading plays nicely with freezing, though. No spawned processes required.
Wes
Wes
18:44
ah. i have no clue of what's going on either way
nonlocal self
A little cluelessness is good, it means you're trying new things
Wes
Wes
so the process callback is executed in its actual lexical scope, but on a copy of the process
meaning that if it's a method, self. will work inside it
it's super odd tbh
i mean that the new process is not a clean environment, but it inherits everything from its parent
If we're talking about threading, I believe there's only one process. If we're talking about multiprocessing, I think its behavior depends on your OS. For example, I'd expect Linux's "fork" mode to copy everything, and Windows' "spawn" would copy only the objects you provide via args
If you prefer "spawn" mode because it's cleaner, it's supported on Linux too. Just gotta use set_start_method
18:59
the 'common questions' page on sopython is currently 502'ing.
Wes
Wes
from what i can see, also on windows you get an entire copy of the original process
@KarlKnechtel yeah, it's a known issue, sorry
Wes
Wes
class Boom:
	def __init__(self, to_child: m.Queue, to_parent: m.Queue):
		self.__to_child: m.Queue = to_child
		self.__to_parent: m.Queue = to_parent
		self.__process: m.Process = m.Process(target=self._run, daemon=True)

	def start(self):
		self.__process.start()

	def stop(self):
		self.__process.terminate()

	def _run(self):
		# ...
		def update():
			# ...
			self.__to_parent.put("hello")
			# ...
			self.__to_child.get()
			# ...
		t.Thread(target=update, daemon=True).start()
this works, for example
@KarlKnechtel it's been like that for a while and the maintainer is aware. I don't have access to the storage so I can't run anything locally. I can only think that it was a recent edit that crashed it because there have been no pushes to the repo for ages
19:03
Actually, I should clarify "a while". Like, since 29th April. It's not neglected
The person that maintains it is at PyCon I think so they just haven't got round to it yet
Although a 502 on one specific page here does seem weird since it's all one application. I wonder if there are clues in the code: github.com/sopython/sopython-site/tree/main/sopy/canon
I hazily recall there being a 404/502/etc error before, and it turned out to be the web host changing some configuration options without telling anybody.
Odds that this was only a dream I had: 30%
everything in that repository is at least 3 years old, so either there are live unpushed changes, or the problem results from data not present in the repository (although it might be that the code should be able to handle that data).
or the problem is somehow network infra related, despite only affecting the specific page.
Yeah, that's why I'm now having a "huh" moment because I don't think any aspect of the site is backed by a db/service that is distinct from other parts of the site
perhaps the specific page depends on a configuration option in a way that others don't?
I think the Common Questions pages have a pretty distinct code path compared to the wiki-like pages. Different tables, perhaps. But probably not different DBs.
Let's see... Yep, one's in sopy/canon, the other's in sopy/wiki. Different tables.
19:24
One good thing to come from this is how many people have noticed the downtime. At least the resource is being used a lot! Also, given that the code hasn't changed for ages and I never delete anything, I might actually be able to get something running locally. I just need to remember how to Windows and Postgres
Wes
Wes
i suppose that works because self is captured from the lexical scope
kinda cool tho
no actually, also global variables are copied to the child process
The whole namespace is copied
Here's what spawn mode's documentation has to say, for the record:
> The child process will only inherit those resources necessary to run the process object’s run() method. In particular, unnecessary file descriptors and handles from the parent process will not be inherited.
If "unnecessary file descriptors and handles" is the complete exhaustive list of things that are not copied, then yeah, it copies basically everything
Apart from those things. I probably should have checked the docs first
Nobody should feel bad for not being able to predict Windows' silly design decisions
It's a sign that you're successfully clinging to your sanity
19:32
cabbage
I've just fired up my old Windows laptop, it immediately updated and restarted... and when it came back online I just had some weird flash of cmd windows firing across the screen in a split second, like when you complete solitaire. Everything about that makes me feel uncomfortable
I wonder if it's possible to monkeypatch cmd so that it logs the owner and output of every split second window that opens at startup
you mean, the actual executable?
I rather strongly suspect that Windows would actively resist that.
Yeah :-)
Maybe I could install a benevolent rootkit that distracts windows with something shiny until it can get me some logs
(On my personal computer only, of course)
Hmm, pgadmin won't let me build the db from a .db file. I guess it'll have to be from the command line but remembering just what I needed to point and click at was already a bit of a stretch :/
20:02
cbg
I was wondering why different variables with same value have the same identifier, and after searching I found out that it is for optimizing reasons for strings less than 20 characters or integers between the range of -5 and 256. So shouldnt this example give different output for the id? but it does not. Can you guys let me know what I misinterpretted? Thanks :D
a = 300
b = 300

print(id(a))
print(id(b))
stackoverflow.com/questions/72107971/… there's a canonical for this, isn't there? The problem where OP expects reassigning an iteration variable to modify the original iterable?
@DelriusEuphoria it may or may not give the same id; it's an implementation detail. Python may or may not pre-allocate an object for the integer 300 (although -5..256 is the "standard" range), and it may or may not be able to notice that the two successive assignments of the same immutable literal can use the same object.
While you can in principle do all sorts of digging around in the implementation source code to determine what happens in which cases, there is not a good reason for almost anyone to care. Properly written code only cares about object identity in cases where it carefully manages that identity explicitly.
(with the notable exception of None, which is idiomatically detected with is since it is a true singleton guarded by the implementation.)
>>> a = 300
... b = 300
...
... print(id(a))
... print(id(b))
139931292539600
139931292537008
But as Karl said, id is more often than not a red herring. Looking at a is b is better, but even then you're looking at implementation details you shouldn't rely on. Just don't assume that various literals are singletons.
oh okay okay, what does implementation detail mean though?
That it's not a guarantee by the language specification, just something that happens to be true on CPython.
Oh I see, thanks for the explanation @KarlKnechtel and @AndrasDeak--СлаваУкраїні
20:13
see pypy
then again I get True on tio too with python 3
and I think the string has to be a valid identifier to be cached (interned?)
How to fix the following error?
>>> x = "not an identifier"
... y = "not an identifier"
... x is y
False
dp = list("abc")
out = map(lambda c: chr(ord(c) - 1) if ord(c) != 32 else chr(c), dp)
print(''.join(out))
@vtfs271232 if you mean the semantic error, just omit the call to list because strings are already iterable
@AndrasDeak--СлаваУкраїні: Sorry, the correct string literal is as follows:
dp =  "abc d e"
out = map(lambda c: chr(ord(c) - 1) if ord(c) != 32 else chr(c), dp)
print(''.join(out))
line 2, in <lambda>
    out = map(lambda c: chr(ord(c) - 1) if ord(c) != 32 else chr(c), dp)
TypeError: 'str' object cannot be interpreted as an integer
20:18
don't call chr() on a string
chr(c) <- c is a string
What do you want to happen to space? You could just use c or ' ' if you want to keep it intact.
Caesar cipher.
I want to keep the space unchanged.
so you need c a.k.a. ' '
side note: you could use str.maketrans for that
OK. THank you!
Why is there a backtick at the beginning output?
`ab c d
dp = "abc d e"
out = map(lambda c: chr(ord(c) - 1) if ord(c) != 32 else ' ', dp)
print(''.join(out))
I see. Thanks.
20:27
I'd probably also explicitly check for c != ' ' for readability. If you're sticking with that map.
Good point, thanks!
@AndrasDeak--СлаваУкраїні (Pedantically, at a Unicode chart.)
Well, goodness knows what the snapshot of sopython I have is, but I couldn't get it into postgres or into sqlite3. Still, was fun to revisit postgres after a few years. I can get the site running locally with no data, from which I've learned almost precisely nothing I didn't know before - I can't fix the issue
21:19
@Kevin are there any particular resources that you used to design the implementation of KevinScript? I've only really gone through the README until now, but just poking around in the implementation shows that it was a lot more involved than I imagined
 
2 hours later…
23:30
Any good resources for understanding pandas dataframe size? If I pickle a dataframe and then load it, the size of the dataframe is like at least 6x the size of the pickle. What gives? I thought pickle more or less writes the data as its laid out in memory
I've searched around on SO and can find random tidbits suggesting that it's expected to have 5-10x size blowup from a CSV (since text may be more efficient for certain encodings). But I'm also just having trouble understanding how to even measure my dataframe.
Most of the memory should be the raw data
Figure out the size of each column type and multiply by number of rows
Strings can probably get tricky
All I know is that when I view the memory from my activity monitor, I'm using way more than expected. Like, sum(df.memory_usage(deep=True)) shows 27 MB, and yet activity monitor shows that I'm using hundreds of megs
I definitely have lots of strings, but as far as my dumb calculations go, it seems to not be anywhere near as much size blowup as I actually have
Well that's more likely about stray references
Is this in jupyter?
Yeah, but I'm observing it before and after executing single line cells
23:35
E.g. I calculated the size of a text column like so: sum(df["text"].str.len()) + len(df) * sys.getsizeof("")
which is pretty close in agreement to: df["text"].memory_usage(deep=True)
I looped over globals() and used getsizeof on everything and am coming up with only 20% of the amount of memory or so
so I think I'm just miscounting my dataframes, but I dunno how
getsizeof doesn't account for container contents I think
You could try using an actual memory profiler but I have no experience with that
I mean that's what I thought too but df.memory_usage(deep=True).sum() is nearly equal to sys.getsizeof(df)
(which makes me think that method is maybe not accurate but, couldn't provide that by manually counting it)
23:57
Surprised coldspeed doesn't have a good canonical here :(

« first day (4218 days earlier)      last day (953 days later) »