« first day (4309 days earlier)      last day (639 days later) » 

12:59 AM
while falling down a rabbit hole of questions about any and all, I determined that stackoverflow.com/questions/1342601 is a good canonical, and applies in this case
the other one is specifically about the for-else syntax which I guess is one way to approach the problem, but usually you don't want imperative code at all
it also seems that the canonical there is stackoverflow.com/questions/9979970
(again a case of steamrolling: OP just wanted to know why the keyword used is else, which is not a good question anyway [POB]; but we ended up with answers about how and why to use the construct.
stackoverflow.com/questions/19104760 Do we have something better for "how do I approach the task of writing a list comprehension to address a problem?" - Is that too unfocused?
 
 
2 hours later…
3:02 AM
duplicate (formerly 3.x tag) stackoverflow.com/questions/41129913
 
 
4 hours later…
7:33 AM
@einpoklum You might be looking for sys.base_prefix or one of its brethren.
 
 
3 hours later…
10:08 AM
Is it normal that the python launcher for Windows (py) regularly stops working if the PC (or the user) is part of a Domain? Python installs itself into AppData\Roaming and shows up in the Start Menu as you would expect. But running py crashes with "Can't find a default Python"
Not 100% sure about this, but I think it goes kaboom every time you log out and back in. Even if it's the same PC
I think python doesn't work either, even though I ticked the "add python to PATH" checkbox during setup
 
10:25 AM
I was playing around with domains and such the other day, and my Python did not go kaboom. I acknowledge that this isn't super concrete information.
 
i dont even know, what is a domain, or what does pc as part of domain mean?
 
Basically, user accounts are stored on a server, instead of locally on your PC. So every employee can log into any PC and still access their stuff
 
I would be happy to stress-test Python on my domain-configured machine, but I think I bricked it by deallocating a seemingly useless zero byte Q:/ drive.
 
I don't really have a clue how the python launcher gets its list of installed python executables from, so I guess the easiest solution is to bypass it entirely and make my bat file search for the python executable in a handful of hard-coded locations...
 
10:34 AM
Right click -> "unmap drive" gave me Access Denied, so I went to about a 3.5 on this scale
@Aran-Fey I did something similar on a computer that refused to update its default file association for .py files from python36/bin/python.exe to python37/bin/python.exe, presumably because the executables had the same name. Associate .py files to "is_this_a_different_enough_name_now.exe", and make that exe pass its arguments to python37/bin/python.exe
 
Not using Domains here, but noticed the same problem on a win10 installation with python3.8.
 
@Aran-Fey according to best Python traditions
 
Had to search manually using everything since it's faster than explorer.exe, then just went and updated file associations with .py extensions
 
py -0 will list all of the python executables that the launcher can find, if that helps
 
nice, didn't know
 
10:45 AM
I guess there's a non-zero chance that py -0 will output something... but if it does, I'm gonna be mad
 
Going by github.com/python/cpython/blob/main/PC/launcher2.c#L1547, I suspect that the py.exe launcher is looking in the registry under the "Software\Python" section.
Shouldn't be too hard to put that in using regedit if this is a one-off task
 
yeah, I recall there even a module that handle windows registry on pip. Might be worth inspiring yourself from it's code
 
The thing is, it works fine after installing python. But then it breaks when you log out. So I guess our domain isn't configured to synchronize the registry?
 
It might also be looking in... The windows app store? Among other places.
 
maybe the domains change because of some arcane reasons when you log out. You could take a snapshot of the registry just after installing python and then logging out, and comparing the last one to the current registry
 
10:50 AM
I bet this is documented in a human language somewhere
 
I had a registry key change on me once after a couple reboot, so this isn't impossible.
 
Ooh, you get more information out of py -0 if you first do set PYLAUNCH_DEBUG=whatever. Here is what it looks like on my computer. Of particular note: it's searching for py.ini files before it looks in the registry.
The .ini behavior is defined in human words at docs.python.org/3/using/…
 
I've heard something about that, but I don't think you can use the ini file to tell it where python is installed?
 
I'm 75% confident that you can use it to tell py.exe where python.exe is installed
 
I see you can create custom shebangs, but I suspect those probably won't work if you run it like py -m some_module. Guess I can try it tomorrow
 
11:11 AM
The internet archive has it. It didn't have the information I wanted, sadly.
 
 
4 hours later…
3:01 PM
What was the name of that module I pip-installed the other day, that lets you print nice ascii tables and boxes and such...
It wasn't tabulate, but it might be built on top of tabulate
 
Was it Rich?
 
That's it, thanks
 
 
5 hours later…
8:02 PM
hi, I don't nkow much python, (Though I have some programming background), but am i am trying this tutorial playwright.dev/python/docs/intro but am getting this error gist.github.com/gartha1/2d8da245e62ec6abc22c113e8cef58e4 Any idea what I should do? thanks
 
Hi @barlop, can you just leave foo out of the signature? from the example, I don't see why it's there and what it does.
 
that's what I concluded too
there's a pytest plugin with fixtures but unsurprisingly there's no foo
 
thanks that looks better.. gist.github.com/gartha1/e71611d5979d5593fa4a7dbda2a3a23c though not sure what the code does? It doesn't seem to start any graphical browser, and it doesn't seem to produce any files
 
FYI your gists are all public. You can also link to secret gists, but public gists also get indexed by search engines and stuff. You probably already know this, just making sure.
 
ok, thanks
 
8:14 PM
the example test does what its name says: test_homepage_has_Playwright_in_title_and_get_started_link_linking_to_the_intro_page
it tests that the Playwright homepage has Playwright in the title and the "get started" link links to the intro page
the fact that the test passes means the assertions in the test are all correct
you have 244 warnings that seem to be suppressed, you can follow the pytest link to see how you can change how they are handled
 
ok, thanks
ok, thanks
when it comes to playwright, it says "Playwright was created specifically to accommodate the needs of end-to-end testing. ". Is that different to Selenium then?
I had heard that Playwright was like Selenium
i'm wondering if there's a tutorial that covers Playwright with less emphasis on its usage for "end to end testing", and more for, browser automation?
 
8:36 PM
You can see how to launch a browser here, and from that point on it should be no different than writing tests
 
Yen
9:12 PM
hi
 
Yen
can anyone help me to solve this validation rule
But with my below code it is not checking the validation rule and allowing the positive start and positive end values in the conjunction.
 
short version: edit your message, press the "fixed font" button and submit the edit
 
Yen
i am sorry if the formatting is wrong
 
you somehow removed all indentation which is not supposed to happen with code blocks
you can practice in the sandbox room which is linked at the end of the formatting guide I linked
 
9:26 PM
@Yen you don't need access to Ouroboros. You need to read the formatting guide as suggested
 
Yen
sorry i can not edit the message in ouroboards
 
You're not supposed to, it's fine. Just practice code formatting in the sandbox, and when you have it figured out, ask your question again with fixed formatting.
It's mainly chat's fault, code formatting is weird. But with a little practice it's easy to get it to format a code block properly.
 
@Yen Chat rooms have different ways of removing messages from the main feed. This happens to be ours. As Andras says, you don't need to edit it there - we've moved it there to die. You have a chance to try again in this room
 
Yen
d=[]
b=[]
my_tuple = []
for i in range(count):
    start_new = int(self.data.get(f'applicationruntime_set-{i}-start_new') or 0)
    start_old = int(self.data.get(f'applicationruntime_set-{i}-start_old') or 0)
    end_new = int(self.data.get(f'applicationruntime_set-{i}-end_new') or 0)
    end_old = int(self.data.get(f'applicationruntime_set-{i}-end_old') or 0)
    d.append((start_new,start_old))
    b.append((end_new,end_old))
    my_tuple.append((d))
    for i in my_tuple:
       my_result = [sub for sub in i if all(element >= 0 for element in sub)]
please tell me this is the right way formatting
 
9:38 PM
it is :)
 
Yen
thanks for confirming that
 
my_tuple.append((d)) those extra brackets aren't doing anything
 
Yen
with this code i have to validations check the positive start and end value can not happend in conjuction,
 
I'm trying to understand your issue but my spidey sense is telling me that it's something to do with tuple definitions somewhere
 
@roganjosh you should wait for the second part of the question
 
Yen
9:41 PM
the problem self.data.get will give also none value , so i am giving optional zero to avoid nonetype, but then i am zero values and i can not do positive checking with zero.
 
@AndrasDeak--СлаваУкраїні I don't remember that part of the spidey sense
 
@Yen can't you keep the None in case of None, and use that in the check later?
 
Can we rewind a bit @Yen? my_tuple = [] is incorrect because that's a list not a tuple
Do you know the difference between them? Because this sets us off on shakey foundations
 
Yen
ok,but how i can deal with none type
 
No, I specifically tried to rewind
 
Yen
9:45 PM
yes i know the difference between list and tuple
 
We're having two discussions in parallel. Let me stop and let roganjosh discuss.
 
I don't care about a NoneType until we establish you know the difference between lists and tuples
@Yen Then can you explain why you're aliasing a list with my_tuple?
 
Yen
sory for that that was a mistake in writing
 
There's no need to apologise, I just want to know what foundations we have here
It goes back to my observation of my_tuple.append((d)) where the additional brackets don't do anything - they don't make it a tuple, they're just ignored
So I'm actually not sure you do know what a tuple is. There's no shame in that, but you would be better-helped if you at least explain that part
 
Yen
i was checking the length both ( d,b) at a same time ,but it did not helped me at all,
i remove the b from the append and did not remove the brackets
 
9:54 PM
But not the comma, so you actually removed the tuple with it
 
Yen
yes
 
a = 2,
print(type(a))
Once you remove the comma, you don't have a tuple. You don't need the brackets
 
Yen
ok,yes,you are right
 
Does that help re-frame what you're asking in any way?
 
that doesn't seem to have anything to do with the issue
 
Yen
9:57 PM
unfortunately no,
 
@AndrasDeak--СлаваУкраїні Fair enough, I hand over to you
 
Yen
i mean the cod eis simple , the problem is when i am checking above or equal to zero then the validation not working
 
@Yen just so I understand correctly: your issue is that you can't have int(None) when self.data.get() returns None, so you default to 0 in this case, but this interferes with your validation check later. Correct?
 
Yen
somehow i have to pass a value that is not zero and validation will work hopefully
yes you are correct
 
OK. Minor side note: if self.data is dict-like then you can pass the "default in case of missing key" as a second argument: int(self.data.get(..., 0)). Just FYI. But my recommendation is to change this part of the code anyway.
So I would recommend keeping None. Then handling None cases in the validation check. Unless you can use a better default at the start.
 
Yen
10:01 PM
ok, how i can do that
 
The problem is that it's not clear to us (me) what your validation is really doing, so it's hard to tell you how to change your validation in a way that works with the None case.
E.g. your error message says "Positive Start values and Positive End values are not allowed to be used in conjunction", but what your code seems to check is something very different
Another, more important note: if you do my_list.append(d) in a loop without changing what d is, you will keep accumulating the same list in my_list. This is never what you want.
 
Yen
i have d= (start_new,start_old) field and b= (end_new ,end_old) field , the d and b can be positive value,
 
>>> lst = []
... d = []
... for i in range(3):
...     d.append(i)
...     lst.append(d)
...

>>> lst
[[0, 1, 2], [0, 1, 2], [0, 1, 2]]

>>> lst[0] is lst[1] is lst[2]
True
@Yen I get that my_result seems to check if there are any items where both starts are non-negative. The end_new/end_old check is surprising to me. And there doesn't seem to be a simultaneous check for "positive start, positive end" which the error mentions. My point is that the code might not do what you want it to do to begin with.
 
Yen
ok
 
But to come back to your question: you'll have to define what behaviour you expect when a start/end value is missing. Do you want to ignore that in the check?
 
Yen
10:07 PM
but will that raise none type error
 
It will raise NoneType error if you do things to a None that is not supported.
E.g. when you do int(None): that will have to be avoided
Instead what you can do (question is if this is what you want to do) is all(int(element) >= 0 for element in sub if element is not None)
So move the int conversion inside the check. Or, you could convert non-None cases to int manually, earlier. Then you know you either have an int or a None. Then you can do all(element >= 0 for element in sub if element is not None)
Again, whether this will do what you want it to do depends on what you want the code to do, which is not clear to me. This is general guidance in this situation.
 
Yen
i just tried to int(none); i am getting this error, ValueError: invalid literal for int() with base 10: 'None'
 
you passed a string with the value 'None' which is equally unsupported
 
Right, so I was right. I was trying to take a step back because this is cargo-culted
 
Yen
10:12 PM
can you please tell me how i can pass non values
 
@AndrasDeak--СлаваУкраїні Not really. I don't know how foundational it needs to be now
 
@Yen I already told you what to do. Why are you typing in completely different, random things?
If you don't understand what I mean, say so and we'll discuss further to reach a common understanding. Ignoring what I say and doing something random and wrong doesn't benefit either of us at all.
 
Yen
sure,i did not understand about passing the none values
 
I didn't start talking about "passing None values" until you said chat.stackoverflow.com/transcript/message/55015603#55015603
I told you what to do before you did that
 
Yen
may i ask what you meant by manually, "So move the int conversion inside the check. Or, you could convert non-None cases to int manually, earlier."
 
10:22 PM
@Yen of course! What I meant was something like this:
start_new = self.data.get(f'applicationruntime_set-{i}-start_new')
if start_new is not None:
    start_new = int(start_new)
# now start_new is either None or an int
this ^ is "convert non-None cases to int manually, earlier"
whereas "move the int conversion inside the check" would just have start_new = self.data.get(f'applicationruntime_set-{i}-start_new') at the top
In that case start_new is either None, or whatever the type of the object is that's in that dict-like object. Probably a string.
 
Yen
ok
this is really simple,
thank you very much
 

« first day (4309 days earlier)      last day (639 days later) »