« first day (4061 days earlier)      last day (1102 days later) » 

07:55
hi
can any one help me
08:15
We'll find out once you tell us your problem
 
2 hours later…
09:51
cbg!
what is the best wat to filter x,y in given coordinates, Sidings.objects.filter(
# Q(siding_coordinates__topLeft__x__lte =x)&
# Q(siding_coordinates__topRight__x__gte =x)&
# Q(siding_coordinates__botLeft__x__lt =x)&
# Q(siding_coordinates__botRight__x__gte =x)&
# Q(siding_coordinates__topLeft__y__lte =y)&
# Q(siding_coordinates__topRight__y__lte =y)&
# Q(siding_coordinates__botLeft__y__gt =y)&
# Q(siding_coordinates__botRight__y__gte =y)).values('siding_coordinates')
 
2 hours later…
12:09
hey guys, does anyone know how I can refer a "self" variable in dataclass default facotry?
if I have a variable a: int in my dataclass, I want to create b: str, I tried b: str = fields(default_factory=lambda:str(a)) does not work
12:21
The first downside of playing around with Rust is that installing its packages in VSCode seems to have broken the Python plugin so now I can't select an environment or run my scripts :'( My Python days are unceremoniously over
That, or the docker extension. It's probably easier to blame Docker since it's usually the source of my woes
12:33
Huh, it's the latest release of the Python extension itself that's borked. Downgrading one version has fixed the issue. If anyone else uses VSCode, this is the error: "Cannot activate the 'Pylance' extension because it depends on the 'Python' extension, which is not loaded."
12:48
@roganjosh iirc, this error is not new. I had it myself a while back, see here: github.com/microsoft/vscode-python/issues/16614
It's not new, but the most common searches suggest it could be due to other extensions such as the Jupyter extension. These issues will occur from time to time, but it's handy to know that it's from the Python extension itself in this case
@Jake Pretty sure you can't
Speaking of VSCode, does anyone use the open-source version? I can't seem to install pylance there, and the jedi language server is... terrible
@Aran-Fey I thought VSCode was already open source?
unless you're talking about the community edition, but that's like the "default" version in my head
It calls itself "Code - OSS", idk
12:56
oh, right
that explain why the community edition is written as Code when you look at the executable
and here I thought this was just a common abbreviation for the editor itself
related: vscodium.com
I never used it but I guess this is just a chromium version of VSCode, since, you know, the usual one is just using google chrome
it's weird though that the jedi lang server isn't as good on VSCode, as it is on other editor, (eg: Vim). Granted, I only tried it 4 times so maybe I'm just biased
 
2 hours later…
Yeah, but I'm not getting an error. I googled and found out that Microsoft deliberately prevents installation of pylance on unofficial vscode builds
So either I have to get my hands on a microsoft build (which apparently contains tracking/telemetry?) or make do with jedi
If you try to use the server version (I forget which is bundled into our web-based workspaces at work, there's a couple) then certain plugins aren't listed in the library e.g. python-indent which drives me mad
I means that to code to my indentation OCD on the work platform means manual indentation for every line. Ain't nobody got time for that (I could use black but it and I have different ideas)
15:31
Server version? What's that for?
Our platform is all web-based and so you can launch VSCode server which will work inside the browser
Sounds like a strange idea to me, but ok
It's along the lines of this but I think it can get vendored by multiple different projects. I don't know a whole lot about it, but I do know that "fully featured" definitely isn't true for whatever we have. Linting and indentation is off, so I have a lot of broken attempts at code just from typos
@Aran-Fey The idea is that we are a Data Science platform, so everything is dockerised, including our workspaces. So you create a workspace, which is really just a restricted version of linux running in a container, that's accessed through the browser, and inside that container there is a VSCode server that gets launched in another tab. Make of that what you will
I would've thought it'd be easier to mount the remote file system and then use your local IDE
We're Data Scientists so we don't understand these new-fangled thingy-bobs. This is great. It's really, really great. Just great.
15:46
Ah I see, it lets you conveniently run your code inside the container. That's an upside for sure
Craziest code I've written this month: self.__repr__.__self__. Here, self is a weakref.Proxy, and this little hack lets me get the actual object referenced by the proxy.
 
1 hour later…
17:04
cbg
17:29
suprisingly much going on here on a sunday
It's permanent homeoffice here again. Super wibbly wobbly, timey wimey stuff...
17:45
@MisterMiyagi I'm so jelly
Well not entirely because teaching would be difficult that way, but tomorrow I have to take the bus and the number of new cases looks like this i.sstatic.net/cgIpA.png
@roganjosh I used vscode as a server myself, but I don't recall it having any limitation, aside from a couple crashes from time to time... Although I was using this.
@AndrasDeak It's similar here. :/ The teaching staff's mailing list has been... fun.
I can imagine...
@NordineLotfi Can you install python-indent? Our marketplace doesn't even find it
@roganjosh That's a good question :) I'll check real quick since I had it installed on an android tablet I use
18:04
I seemingly constantly see questions like stackoverflow.com/questions/70145724/… - the underlying idea is that OP expects return x in a function to make x usable as a name in the calling context, as if the name were returned (rather than the value). Is there a canonical duplicate for this? I can never seem to find a good one.
The one you used seems good to me
oddly, people who have this question don't ever seem to tag it [nameerror], which gets used for every other possible cause of a NameError x.x
these questions are so wrong they probably get downvoted and deleted usually, so it's reasonable to expect there's no 300-upvote question somewhere from 2008
idk, it sounds like exactly the kind of thing I recall rushing to answer in 2008... well, 2011, but.
@KarlKnechtel another one for you stackoverflow.com/questions/51370082/…
I couldn't find a better dupe target with the amount of effort I was willing to expend :P
18:12
@roganjosh just tried searching for python-indent on latest version of code-server (the link I previously posted earlier) and it seems I can't find it there either :/ I did find it on the online marketplace though (outside vscode on the browser/code-server)
I didn't try directly installing the extension using the .vsix extension though. Kinda curious to see how it would works
Oh, I know it exists, I use it every day :P But it doesn't seem possible to get it into the server version. I could try harder in figuring it out... or I could just keep doing local development that's worked fine for me for years without this new method of working
yeah...I don't always use the server version myself, although it's mostly because of the occasional crashes that happened to me (on both android and pc). But I guess it does help to have on the side, just in case
I'm guessing that maybe the extensions authors have a flag or something set in their profile/extensions that prevent non-microsoft version of vscode to install/search for their extension/or even install it (didn't try to force installation with the vsix bundle though)
I know this happened in some other nodejs community app that I can't remember the name of, so this wouldn't surprise me if that was the case
I don't think I really understand the reasons for that, but it seems like a reasonable explanation nonetheless
indeed. I guess either building with microsoft stuff enabled or rewriting the extension so it work would be a solution, but probably a lot of effort just for a single extension :D
coincidentally, there seems to be some python version of the vscode's extension api: github.com/CodeWithSwastik/vscode-ext and another one that I can't seem to find anymore...
18:39
@KarlKnechtel looks like someone coming from javascript makes this kind of error
 
3 hours later…
user15071942
21:47
Hi, Im very very stuck.
im basically doing something like this:
def A(dict b):
c = b.copy()
B(c)
----------
def B(c):
#I change c here, but b is being changed as well
@Roman you probably need a copy.deepcopy
user15071942
Im gonna use and see if it works
sounds good
user15071942
the strange thing is that b and c in my code has different ids
obj.copy() gives you shallow copies in the standard library
the dicts are different, but they contain the same (mutable) objects, e.g. list-valued items
d1 = {'foo': ['bar']}
d2 = d1.copy()
print(d2 is d1)  # False
print(d2['foo'] is d1['foo'])  # True
this is what a shallow copy means
user15071942
21:52
because the element is a list, this is the problem?
In this case yes, but anything mutable will be able to trip you up.
Shallow copies always refer to the same objects inside, but this is irrelevant for immutable contents.
(I'm just trying to say that mutable contents are not special-cased in any way)
user15071942
Man
This is a different, but potentially surprising thing when a container contains something mutable:
user15071942
I love you
lst = ['bar']
tup = 2, 43, lst
print(tup)  # (2, 43, ['bar'])
lst.append('quux')
print(tup)  # (2, 43, ['bar', 'quux'])
tuples are immutabe but if they have mutable contents then those can change
user15071942
21:55
I literally spend 20 hours, almost in a row,I just discovered the error and thought would be a mess to reconstruct. Thank you
@Roman 'tis the season
@Roman I strongly recommend this blog post that explains how references work in Python, in case that's not completely clear for you. Excellent resource.
no problem
TIL __copy__ and __deepcopy__, I'm somewhat surprised that copy.deepcopy has no issue copying custom classes that lack these.
22:26
Copying python objects is easy, (almost) everything is stored in the __dict__
Yeah, I figure it copies the vars, and if you want any side-effects you can implement those dunders
The presence of __slots__ makes things more difficult, but who uses those?
I'd have thought that deepcopy(Foo(*args)) not having the same semantics as Foo(*args) is enough for python not to guess.
Bypassing the constructor is kind of a feature when it comes to copying
from vague C++ things I thought one would need (the equivalent of) a copy constructor to be able to copy
I can see how the current behaviour is what 99% of use cases need, just musing
22:32
Hi
any idea how to debug when subprocess.run gets stuck?
its some git command, which works in my bash, but for some reason get stuck when running it thought python
it's probably waiting for user input, would be my guess
no input is needed
is there a way to get more info on the root cause?
Look at its output, if there's no useful information add --verbose flags until there is
22:40
based on bash experience, you could just get the stdout and see what happen there? (maybe some error that aren't part of stderr). here an example with stdout:
var = subprocess.Popen(['python3', 'tcpServer3.py'], stdout=subprocess.DEVNULL, shell=False)
then var would contain the stdout/output of whatever you want to run
you can do the same for stderr, etc
ok in my case shell true
as it runs on linux
you don't always need shell=true though...(I'm on linux and I don't always use it myself)
some don't even recommend it for a lot of reasons, but depending on your use-case, you can always use it
subprocess.Popen(cmd, cwd='/home/demo', stdout=subprocess.DEVNULL, shell=True)
Do you know what the shell is? Unless you're the only person who ever runs that code, no you don't. So don't use shell=True.
uhm, if you use DEVNULL here, you wouldn't know the output of the command(s) you're running.
and ^
22:46
@NordineLotfi You're the one who recommended sending stdout to devnull :P
if I'm removingshell=True I get bash: No such file or directory
@Aran-Fey ah right x) But I only did that as an example, thinking that it would be obvious (especially since they ended up mentioning using linux) to just replace devnull with eg: stdout, etc
@A.Man it might have that error if what you're trying to run is a shell script
its an internal git command
that's weird then...do you mind showing what the full command is? maybe it call on something that need a shell running
also look on here and search for DEVNULL, you should find other constants to use, such as STDOUT, etc
I can't post the full command... I just can say that thought regular terminal it works, and only thought python run it doesn't
22:56
hmm, that's hard to reproduce. I don't think I know of any git commands that might have that error
perhaps cmd.startswith('bash') :P
I think it would also need the -c flag iirc. Some commands sometimes fail without it, either because of quoting or some other reason, so: cmd.startswith('bash -c') would work if the other doesn't, maybe
talking about things not working: I only noticed today that pip now removed the bundle command ;-; (and I finally ended up finding a good use for it too)
I already vaguely know how to make-do without it, but it's still sad nonetheless

« first day (4061 days earlier)      last day (1102 days later) »