« first day (3303 days earlier)      last day (1637 days later) » 

12:00 AM
plus as the post details there are a lot of differences among the backends, in particular in ease of use
it's not a huge deal to wrap numba but making it easier to cythonize things might be very important
 
the overview of the current landscape to accelerate numerical Python code is pure gold for me.
 
@DemCodeLines how about struct.unpack('>h', bytes([byte_val1, byte_val2]))[0]?
unless the whole thing can be rewritten into something nice
or if by any chance you're using numpy, np.array([byte_val1, byte_val2], dtype='uint8').view('>h')[0] :P
 
 
5 hours later…
4:58 AM
nope, guess not
 
user11867329
5:32 AM
 
6:19 AM
@OakDev What's the purpose of those 2 images? Please don't post random images here with no context.
 
user11867329
6:38 AM
It worked, the thing I've been bothering this room about for a week.
 
6:55 AM
good morning
 
7:53 AM
Can I consider that a global variable (instance of class) in a module that is imported in the app.py is thread safe?
 
8:12 AM
no
class Foo:
    x = 0

    def slow_increment(self):
        x = self.x + 1
        time.sleep(1)
        self.x = x
^ obviously not thread safe. Whether it's global or not is irrelevant
 
8:36 AM
Are class variable shared across threads?
 
Everything except thread-local storage is shared across threads
 
A) when instance is created within thread, B) whne instance is passed into thread.
Any reference article on this topic plesse?
 
I don't know any, sorry
 
Are class variable shared even in Flask? For example: each flask request spins up a new thread. So in the thread can it access variable of instance from another thread?
 
no idea, I don't know how flask and web servers in general work
 
9:38 AM
@IljaEverilä set the bar a bit higher with his new profile picture :D
 
@AnttiHaapala Oh you
 
now I just need to do a reverse blur on the whiteboard to find out what you're working on :P
probably "shopping list: beer, cola..."
 
Pretty much
 
10:30 AM
Hey all! need some help with python scraping.
here's the sample code:

<div class="span6">
<label>PointA</label>
<span class="form-control-abc">
<input type="text" name="FirstName>
</span>
</div>

Task is to display label name if an input tag is used. Now using parent.name I can display span class but not sure how to get the label tag.
This is what I applied:

for form in obj.find_all("form"):
for tag in form.find_all(re.compile("^input")):
@Aran-Fey: Any suggestions?
 
10:44 AM
@MunishGupta @mani it seems same as to find "href" from "a" tag.
simply use find_all("input") and tag.get('name').
 
task is to find label when an input tag is given. Here, I am able to display <inpyt type txt but I have to show PointA as well corresponding to this input tag.
 
@IljaEverilä what creature is that? :D
 
@AndrasDeak Bub
 
@IljaEverilä is that like a modern muumi?
 
10:59 AM
Ilja is a dolphin (or maybe a shark). You can tell by the Finn on his back.
 
@AndrasDeak Aww, I thought that the C= would be a give-away. Bub, from Bubble Bobble.
@PM2Ring Well played.
 
:D Cute kid. I can see the family resemblance.
 
@IljaEverilä sorry, never heard of it
 
@PM2Ring I take it you still see the old profile pic.
 
11:03 AM
@IljaEverilä kid's all grown up into a psychopath who wears his victim's skin as a costume
 
Ah. Now I see a different pic. Some kind of creature, in cyan.
 
@PM2Ring a Bub ;)
@IljaEverilä I googled it and I have seen a video from it
If "googled" is a thing should I say "duckduckwent"?
 
Ducky-ducky-go-search
Btw @AndrasDeak, I love it how you always see the best in people – I think the last time you observed a "sasquatch" :D
 
Haha, I try
 
11:32 AM
snark is strong in us Finno-Ugrians :P
 
Suppose endpoint function creates an instance of class and updates the class varibale value. Then do instance of this class in current thread and all other threads get the new value?
By thread I mean background thread from same requset. And also threads from subsequent endpoint requests
I am referring to Flask in the above lines. Sorry.
 
12:12 PM
Changing a globally-visible value in one thread will cause the value to be changed in all other threads. This is not specific to class attributes.
But do be careful that you're actually changing the class attribute, and not an instance attribute by the same name
class Fred:
    foo = 23

x = Fred()
y = Fred()
x.foo = 42 #set the attribute on this object only
print(y.foo) #still 23

class Barney:
    qux = 4

a = Barney()
b = Barney()
Barney.qux = 8 #set the attribute for all instances
print(b.qux) #now 8 instead of 4
 
12:41 PM
I know that global variables are shared across thread. I wanted to know whether class variables and module variables behave the same as global variables.
 
If the class is defined at the global scope, then yes
 
@variable in your impatience, please don't overlook the little pitfall that Kevin included in his post. Assigning to the class variable using the class name will update the class variable (and if the class is at global scope will update it for all threads). But when assigning through the instance (where it says x.foo = 42), this makes an instance local copy of the attribute, so not shared across threads unless the instance is also a global.
 
I was not being impatient. Apologies if my message came across that way.
I will be grateful if you guys can point me to a reference article which covers about this topic
 
Here is a small example that demonstrates how a class that is not defined at the global scope will not propagate its changes to other threads
 
@variable if you mean class attributes vs instance attributes, I personally understood the basics from here
this doesn't necessarily cover the monkey-patching of x.foo = 42 though, but it at least sets some confusion straight
 
12:53 PM
@AndrasDeak - thanks, I meant about globals with respect to threads, processes
 
ah, sorry
I thought you knew already that globals are shared across threads
 
I'm not sure what a reference article would accomplish, since "globally accessible values propogate changes across threads" pretty much covers every case I can imagine
 
anything else is not about "globals in threads", it's about how other kinds of name lookup work in python
 
As for processes, "nothing at all propogates across processes, unless you bend over backwards to use the data types explicitly designed for this purpose" just about covers it
 
Fred is a global name, so threads share it. So are x and y as global-scope instances. What happens when you mutate these doesn't depend on threading
 
12:55 PM
@variable Pretty much anything by this guy: nedbatchelder.com/text/names.html
 
Please can you review if my understanding is OK: In python, an application by default runs on 1 process and a single thread within that process. If we use threading, then the application starts on 1 process and 1 thread within that process; then, when it encounters the threading code, it will spin up more threads within the same process.
While a thread encounters an 'import module' statement, python loads the module in the sys.modules and this happens only once across all threads, even if the code encounters another import with same module name on current thread or any other thread.
 
Sounds right to me.
 
But note that these threads are NOT threads in the OS sense. They are Python threads which still run all within a single OS thread, just taking turns internally switching every 100 bytecodes or so.
 
1:10 PM
Ok thanks. In python Flask, does the concepts of globals/access to globals/thread-safety remain the same? I am asking since each request is a new thread, so I though that the thread only runs the endpoint function.
 
I don't know the answer to that for certain, but a lot of these principles are baked directly into the language and it would be very hard for a library built on top of it to change them
Rather than asking "can you tell me all possible situations where scoping rules may behave unusually?", it may be more constructive to ask, "I thought the scoping rules were X Y and Z, but when I run [this code], it seems like it's doing A B and C. Why?"
"this code" being a link to the MCVE demonstrating the surprising behavior
Perhaps I am being uncharitable. "does Flask adhere to Python's normal scoping rules?" is not quite as broad as "when are normal scoping rules not followed?". But still. The more concrete a question is, the better chance we know the answer.
 
1:27 PM
Sure agree that. The thing is its all in my mind and I try to get links to resources where I can read about it.
 
Are there guidelines somewhere on when a function should or shouldn't be a property? I'm looking at a bunch of code changes where a colleague has made properties that "feel wrong".
Thinking getters mostly at this point
 
I am reading that it is not ideal to run flask in production using the server. So I have 2 options: Use docker to containerize the flask application and then using service fabric cluster make it scalable. So each node in cluster will download an image of the flask application container and run it. Option 2 is I read to use nginx and gunicorn. Any suggestion from my guys will be helpful.
By server I mean the default server that comes with flask
 
1:43 PM
Times when you might want to have a property
- If an attribute's value can be deterministically derived from the values of other attributes. (example: make `my_rect.area` a property whose getter returns `self.width * self.height`)
- If setting an attribute should cause a cascade of updates to other attributes. (example: make `my_rect.width` a property so that mutating it also updates `my_rect.area`)
- If calculating the value of an attribute is expensive and the user only rarely needs to access it.
- If an attribute should not be settable by the user.
- If you have a method named `get_<something>` and it has no side effects.
The last one is a big gray area. I have lots of get_somethings in my code and I think they're fine that way.
One design pattern that I unconditionally reject as unPythonic is creating properties whose getter does nothing but return self._value, and whose setter does nothing but update self._value.
YAGNI applies in full force there, and even if it turns out that you do need a property later, changing an attribute to a property without changing the class' public interface is almost completely trivial.
 
@variable You definitely should not use the Flask development server in production. It's not designed for that purpose, and it doesn't have the security features of a proper production server.
 
@PaulMcG I am stuck at a simple python problem. Need your help.
 
@MunishGupta Why are you pinging Paul about that? Just state your problem and if people can help (and want to help) they will do so.
 
@Kevin Many thanks - googling shows only the "hows" of @property but not the "when/when not to"s. I also found a little discussion here groups.google.com/forum/#!topic/django-users/HX_lB2MOy7Q that follows the same vein as your comments
@MunishGupta - I am in a bit of a crunch before a meeting so please just post and let the others address
 
@MunishGupta I know Paul & Aran-Fey have helped you recently. But please don't pester them every time you have a problem.
 
1:55 PM
@PM2Ring I did but did not get any help from anyone and also he helped me with a problem couple of days back and your point is Noted. Can you suggest something for my code?
 
@MunishGupta Is it in reference to this:
3 hours ago, by Munish Gupta
Hey all! need some help with python scraping.
here's the sample code:

<div class="span6">
<label>PointA</label>
<span class="form-control-abc">
<input type="text" name="FirstName>
</span>
</div>

Task is to display label name if an input tag is used. Now using parent.name I can display span class but not sure how to get the label tag.
Are you using Beautiful Soup?
 
yes. I tried using parent.parent and parent then sibling but nothing worked.
 
Sorry, I've never used Beautiful Soup myself, so I can't offer much help. But if you can use .parent to get the span that encloses your input tag, can you use .parent to get the div, which is the span's parent? And then the label is a child of that div.
 
In my experience, navigating the DOM by using explicit parent/sibling/child relationships tend to be a brittle design. Especially since BS will insert, like, RawTextNodeElement instances in between tags when you least expect it.
"Oops, that label's next sibling isn't a span, it's a newline, teehee" says BS
 
Ah. Sneaky.
 
2:07 PM
Parent relationships are probably the most robust of the bunch so it's probably fine to use here
I'm thinking something like the_input.parent.find("label")
 
@PM2Ring It didn't work. If not BeautifulSoup, what would you rather suggest?
@Kevin Exactly. <input> parent is <span> and it's parent is <div>. So here <label> is what. Is it s sibling of <span> or some other relationship
 
I suggest Beautiful Soup, but I can't help you with it. Kevin (or someone else) might be able to, if you show us a little bit of code, ideally a min-reprex.
 
Oops, I misread the html. Give me a second and I'll see if I can write something
from bs4 import BeautifulSoup

s = """<div class="span6">
<label>PointA</label>
<span class="form-control-abc">
<input type="text" name="FirstName">
</span>
</div> """

soup = BeautifulSoup(s, 'html.parser')

for input in soup.find_all("input"):
    label = input.parent.parent.find("label")
    if not label:
        print("Could not find label!")
    else:
        print(input["name"], label.get_text())
Note that I had to change the html by adding a quote mark to the end of "FirstName". Without it, the input tag is interpreted as text
 
got it. Let me try to understand this simple looking code.
 
@Kevin Did you have to shadow input like that?...
 
2:19 PM
Oops.
Real programs don't use input() anyway so it's ok to clobber the builtin function. </half_serious>
 
Hi there. anybody heard of pq-gram algorithm ? :)
 
If it doesn't have a Wikipedia article, then no
 
I was following an implementation but I'm not sure about recursion
 
@Kevin It worked. My mistake was I was doing// if input.parent.sibling == "label"
print(input.name)
 
For example -> pastebin.com/uiDeUFQj
And after third iterration, I think algorithm should stop as it hits return but maybe i dont fully understand recursion in python?
Anyway, following the implementation it shouldnt stop
But the result I get after the third row, is different
 
2:24 PM
@PM2Ring @Kevin: Thank you guys
and @Kevin: for next time I'll remember not to tag anyone specific. Once again thank you guys. I spent my whole day working on this problem.
 
input.parent.previous_sibling might have worked but I'm wary of sibling relationships altogether, as previously established
 
Fourth row should be: ['a', 'b', '', 'c', 'd'] and not ['b', 'c', '', 'c', 'd']
 
Just tried print(input.parent.previous_sibling) and it gave me "\n". Can I call them or what?
<BS teehees in the distance>
 
@MunishGupta Don't worry. Every coder does that sort of thing from time to time. Old coders still make dumb mistakes occasionally, but we tend to spot them pretty quickly. ;) But that's one reason we ask people to post code - fresh eyes may see mistakes that the writer may not notice.
@Kevin Ok. That compensates for shadowing input. :)
 
input.parent.previous_sibling.previous_sibling gives the label, for the record. Who knows whether it would work if the whitespace was different, though
 
2:30 PM
I feel like the more I’ve done programming, I have really improved at not making small typographical error, but I’ve become a lot better at debugging them.
 
Hi guys, do strings in python behave the same as in c# (i.e. are immutable)
 
@MikaelKen I don't see anything obviously wrong, at a glance. What implementation are you following along with? Do you have a link?
 
in particular I'm asking in relation to memory management
 
@erotavlas Python strings are indeed immutable.
 
@PM2Ring One step at a time.
 
2:31 PM
 
It may also interest you to know that short strings are interned, so multiple instances of "foobar" all resolve to the same space in memory
 
so in c# it is recommended to use a stringbuilder to build a string from many small parts, does the same thing apply in python?
 
@erotavlas give this a read, it may be helpful; stackoverflow.com/questions/9097994/…
 
@erotavlas The equivalent recommendation for building strings in Python is to keep a list of small strings, and at the end combine them with "".join(the_list)
 
I use slightly different labels for the graph, but basically if I try to match them, after third row, my result will look different
 
2:33 PM
i see, thank you
 
page 6
 
@MikaelKen I get access denied trying to open the scientific paper btw.
 
scholar.google.com/… here go on first link
 
Hmm, that link takes me to a page that wants me to pay $15.00 for the pdf
 
click on PDF on google page
dont go straight on the link
 
2:36 PM
Ok, I've got the pdf now.
 
nice, my implementation follows it step-by-step, but by matching my mocked data with the one from the paper, something looks wrong
 
@MikaelKen Welcome to reproducing research 101
 
this research will be the pillar for my research once i get it right haha
 
Not entirely sure what some of this algorithm is doing. For instance, on the line anc:=shift(anc;l(r)) I don't know what the function l is. On the line P:=P U (anc o sib), I don't know what the circle operator represents
 
circle is concatanation, l is from label like he noted his graph
I ommited l as I use exact labels as node;s name
 
2:44 PM
I wonder if it matters whether P is being passed by value or by reference. In other words, should changes made to P by the ":=" operator in inner recursive calls mutate the value of P in outer recursive calls
I'm thinking it probably doesn't matter but that's something to look into if no other solution is forthcoming
 
I really wish more papers would publish code with an actual implementation.
 
Basically you would replace all instances of P.append(thing) with P = P + [thing] and see if that changes anything. It's less efficient than append, but if that's what it needs, that's what it needs.
 
If research was peer reviewed by SO, they would be rejected for not providing a MVCE.
 
people publish in journals as its easier
 
2:49 PM
Trying it out myself, the P = P + [thing] approach didn't change the result, so I guess that's a dud
 
I guess we’re going to have to whip out gdb to debug this... sigh :P
I recently got a SEGFAULT running python code and I was like, welp, this is my life now.
 
At least we've got Example 5.1 so we're not totally in the dark about what's supposed to be happening
 
My profile matrix doesnt match properly as I said before, for example on the 4th row: row should be: ['a', 'b', '', 'c', 'd'] and not ['b', 'c', '', 'c', 'd']
 
rbrb need to do some math. Good luck.
 
@Dair the things that get through review are amazing
@Kevin circle is usually function composition
but whether it's anc(sib) or sib(anc) is sometimes up for debate; it's usually the former
 
2:58 PM
I agree that it's usually function composition. In this case, 5.1 defines it as "concatenation of two registers" although I'm unclear on what a register is yet
 
I presumed by default to be a list/array
 
OK, wasn't sure how wide-spread that notation was
 
or maybe is another data structure/
 
@Kevin sounds like a tuple that supports shifting, so basically a deque
 
I might actually try to read this document.
 
3:04 PM
I replaced the initial list [] with deque() from python collections
same output
 
I've gotten through section 1, which is usually where I crash and burn on sciencey pdfs
"It's useful to be able to compare trees by their structure rather than by the contents of their nodes". Yep, I can see that, with you so far
 
@MikaelKen make sure it has the right length so that shifting works the way it should (by kicking out items from the start)
hmm, or maybe that's not size-dependent
I guess if its length might change then you have to append+popleft to implement shift
 
does the shift function contradict with how it's decribed in the paper? just wanted to make sure
 
The only thing I know is the shift function as it's described in the paper
> A shift register reg supports a single operation shift(reg, el), which returns reg with the oldest element dequeued and el enqueued
OK, it's explicitly a deque
 
yeah so for [0, 1, 2] and 3 it should return 1, 2, 3 right?
 
3:11 PM
yup
Ah, I didn't see your code. Yeah, shift looks right. It's just that if reg is a deque rather than a list then it will be much faster.
and instead of .pop(0) you probably need .popleft()
And note that shift mutates the input reg, which might or might not be what you really want!
if you always only have var = shift(var, new_val) (and you don't store these registers in lists or other containers) then this won't lead to bugs
P.append(anc + sib) is safe because the concatenation creates a new list
But if you want to be sure start shift with reg = reg.copy()
 
holy hell
that solved it
most of the time I have this kind of issue
and I always forget this
 
glad to hear that
 
shallow copy to the save
thank you
 
no problem :)
of course what you need is a deep copy, but for containers of immutables a shallow one is also deep
(where "tuple of lists" doesn't count as immutable, before anyone tries to wellactually me)
 
wim
3:36 PM
tail of crap here
 
hello there
 
@wim not going to delvote the pip internal answers
@S.Wasta general Kenobi
 
I dont get it
 
wim
@AndrasDeak why not?
 
@S.Wasta Sorry, it's a pretty active meme, from one of the Star Wars prequels :)
hello
@wim because they are crap, but not dangerous-as-in-eval crap
 
wim
3:44 PM
imo crap should be deleted even if not dangerous
 
Oh. My bad. May I ask for help Selenium + Python? Or is it for StackOverflow i mean the question?
 
@wim there's a lot of room for interpretation for that
 
wim
no problem, we can agree to disagree, was just curious
 
@S.Wasta if you expect it to be reasonably short, or if it's too vague to be asked on Stack Overflow, you can try asking here. But if you've already asked it on main, we prefer to only ask here too if two days have passed with no good answer.
 
@and
 
3:46 PM
@wim for the record here's the privileges page:
> You may vote to delete answers in the following cases:

The answer is extremely low quality: There is little to no scope for improvement
The answer doesn't attempt to answer the question; it may be a comment or a separate question altogether.
we can argue how "extremely" low quality these are :)
(but "very low quality" in the sense of the VLQ flag means borderline gibberish)
 
@AndrasDeak I already did the question a few min ago on main, so
 
wim
using package in a way explicitly discouraged by its documentation counts as extremely low quality in my book
those approaches just break when you change pip version, can screw up your logging configuration and terminal output, it's just a waste of readers time
 
@S.Wasta then you should see if you get answers there first :)
 
wim
I am starting to use this question as a canonical, it's a real shame the accepted answer is totally broken
 
Yeah, I will wait. Thanks.
Didn't know StackOverflow had chats, I'm a newbie here. Regards people.
 
3:51 PM
@wim perhaps that "handle obsolete answers" mechanics will roll out in 6-8 weeks...
@S.Wasta it's very well hidden, unfortunately
In any case, welcome :) You can find our local rules here.
 
@wim I'm inclined to not delete those answers where you said you must not use pip’s internal APIs in this way, to stop people who might want to do that stuff.
 
wim
4:11 PM
for every person it stops there are ten people that ignore it
 
9 out of those 10 people stop at the first answer. the 10th can't really be helped. citation needed
I think, rather than as a comment, im happy to see the first line of an answer itself that advocates "dont do this". I've found those type of answers genuinely useful, and clearly demarcated as bad practices.
But in the absence of such a demarcation on the answer itself, a comment is the next best thing
 
4:36 PM
Just saw two answers to the same question that both do while (true):. Hmmmm
 
now that is very low quality :P
 
Only one of them suggests if (cond) break; though
Earlier in the week we had a conversation about "should example code in a library's documentation be as simple as possible, even if the result doesn't follow best practices?" and I thought of an excellent case study: effbot.org/tkinterbook uses SomeWidget(...).pack() everywhere, and the x = SomeWidget(...).pack() antipattern is responsible for 75% of new tkinter user confusion
The author saves themselves one line of code and burdens me with a dozen dupe hammers a week
 
(x:=SomeWidget(...)).pack() # :'(
 
Concrete example: effbot.org/tkinterbook/grid.htm#patterns shows Label(master, text="First").grid(row=0). Boo, hiss
 
wim
IMO, as simple as possible but no simpler
 
4:49 PM
To their credit, they never actually assign the result of pack/grid to anything, so it's not strictly speaking an antipattern by itself
 
@Kevin are these prone to the "object out of scope gets collected" problems?
 
wim
one that shows bad practice (e.g. dangling open file handler) is falling on the "simpler" side here
 
@AndrasDeak I think Widgets are safe from premature garbage collection. But I did discover just thirty minutes ago that IntVars aren't safe.
import tkinter as tk
root = tk.Tk()
for i in range(3):
    var = tk.IntVar()
    var.trace("w", lambda *args: print("Scale changed value."))
    tk.Scale(root, variable=var, orient=tk.HORIZONTAL).pack()
root.mainloop()
Example. Three IntVars are created to handle the callback that occurs when the Scale widget is manipulated. But only the bottom-most scale triggers its callback, because the first two IntVars have been garbage collected.
Appending each IntVar instance to a list causes all three scales to trigger their callbacks as desired.
 
spooky
 
🎃 Tis the season 🎃
 
4:57 PM
to be jolly...?
oh no wait... too early...
 
golly
 
As an anti-encroachment measure, I refuse to acknowledge the existence of a certain holiday until Dec 1. As a further counterbalance, I'm extending Halloween season to the day before Thanksgiving.
 
Be sure to pray for departed souls then
I recommend only eating sardines for your protein until turkey day
I have put a class of intro programming students in a side competition
Assignments from now on will have extra criteria of idiomaticity and production quality. This won’t effect grades, but whoever wins the most assignments will get an intermediate Python book at semester’s end.
What book should I give them?
 
Under my system, it's possible for it to be Halloween and Friday the 13th simultaneously, allowing unprecedented levels of spookiness
 
I didn’t say what book I’d get them, just “an intermediate Python book”
 
5:04 PM
hey guys what CI/CD tools are you using?
 
The only Python book I've read is Monty Python and the Holy Grail, but that's pretty intro-level
 
Purchase the top ten most popular Python books on Amazon, and give out whichever one is closest to the medium weight
 
@Kevin to be fair any system that has the 13th fall on the 31st is pretty darn spooky to me already :p
 
Under my system, the order of digits is arbitrary, so 13 == 31
 
@JohnnyApplesauce expect ties
 
5:07 PM
@Kevin a compulsory "why do programmers confuse Halloween and Christmas"... because dec(25) == oct(31) thing...
 
Remind me to respond to the above message on December first
 
Sure... I'm just going to extend your system somewhat... will make sure you to let you know on Feb 11th :p
 
@Kevin I do that all the time, if I don't need to assign the widget. But I agree that Fredrik Lundh really needs to emphasize why you cannot call .pack, .grid, or .place on a widget that you are assigning.
 
(maybe sometime in 2901 if that's okay?)
 
While I'm changing things around, I'm moving January and February to the end of the year, so sept/oct/nov/dec refer to the 7th/8th/9th/10th month like they're supposed to
Yes, I know that July and August are responsible, but I want to maintain the cyclic order we've got now
 
5:18 PM
Can't we just use unix based timestamps and watch the world collapse in 2038 like it did in 2000?
 
@Kevin Wise. It makes leapyear handling a lot easier too. In fact, several efficient daynumber & day-of-week algorithms do exactly that.
 
@PM2Ring sounds like history's undoing
 
happy 1572628799.485818 everyone? :p
 
@JonClements obligatory "There is a theory that if ever anyone discovers what the Universe is for and why it is here, it will instantly disappear and be replaced with something even more bizarre and inexplicable. There is another theory that this has already happened."
 
So, about that book?
 
wim
5:21 PM
Why do windows python installers create a py command instead of a python command?
 
Say I have a virtual env in a folder named venv. If I run venv/bin/pip install without first activating the virtualenv will it still install the packages in the virtual env?
 
wim
Is there actually any reason, other than to be annoying and different?
@Code-Apprentice yes
 
@AndrasDeak :)
 
@wim because python3.7.exe doesn't fit into 11 characters
 
@wim do you have a documentation source to back that up?
 
wim
5:23 PM
@Code-Apprentice yes
 
You get a nice repeating (31, 30, 31, 30, 31) pattern. So each month has 30.6 days on average. And with February at the end of the year you don't need to worry that it's a bit short because there isn't a month after it. :)
 
Observation: on a Windows system with multiple Python installs, there are multiple files by the name "python.exe", in their respective install directories. But there's exactly one py.exe, in C:\Windows.
 
wim
venv "activate" is a path heuristic hack.
the verb "activate" is too strong for how crude the actual thing is
> A virtual environment is a directory tree which contains Python executable files and other files which indicate that it is a virtual environment.
it makes people think they are going into or out of a venv by "activating" or "deactivating" it, but that's not really a good way to think about it.
 
If you run python in a Windows shell, you don't know what version will run, unless you know how the entries are ordered in your PATH. If you run py, you can be reasonably sure that it will start up the most up-to-date version you have installed.
 
wim
5:27 PM
Also
> When a virtual environment is active (i.e., the virtual environment’s Python interpreter is running)
 
@wim it is, in the sense that "python" and "pip" suddenly correspond to those of the env
 
@wim so what about when the virtual environment is not active?
 
@Code-Apprentice I think he's saying that you needn't source bin/activate, it's enough to run the interpreter there
 
Just having a look at what's going on the table for the Q4 meeting... err... Hold a meeting one quarter after this one, around Nov 19 2018? Has Kevin's system already been applied there? :p
 
@Kevin Do you know how that plays with Anaconda? IIRC during installation it says "do you want to make this your default Python?" but I don't know exactly what that does because it seems to invariably fail to even add python to PATH (but that's probably due to IT restrictions on the machine)
 
wim
5:27 PM
there is no such thing as active or not active venv
it's dumb terminology
 
the activate script is a thin layer of sugar
 
ok, so by running the binaries in venv/bin the venv is automatically "active"?
 
wim
yes
 
@AndrasDeak ok, that makes sense...and not at all what I assumed
 
Yup... I generally use the path to the venv python in cron tabs for instance...
 
wim
5:29 PM
@Code-Apprentice but there are other reasons you shouldn't do that
 
such as?
 
wim
the stuff in bin might rely on environment variables set by "activate"
 
@JonClements Since that bullet point was proposed on Q3 2018, I think it makes sense in context
 
if it helps, I'm asking because I'm writing a bash script to automate deployments. Similar scripts that my boss wrote use explicit venv/bin/pip install and venv/bin/python pathing. I've only ever sourced venv/bin/activate and then do pip and python relying on the updated PATH. So I'm wondering what the differences are.
 
@roganjosh Hmm, can't say I know anything about Anaconda.
 
wim
5:33 PM
@Code-Apprentice not much difference here, just different ways of doing the same thing
good on you for asking for a documentation source though
 
@wim @AndrasDeak Thanks for for the help and clarifications.
@wim yah, my bit of googling failed to find anything definitive. I'll read those docs a more thoroughly as I have some time.
 
wim
there is a funny bit on this from pythonrants
> I forgot to mention bin/activate
> Sets PATH and changes your prompt. If you find this exciting, you’ve been living under a rock. Same goes for virtualenv wrapper. .NET developers on Windows are mocking you.
 
@Kevin ahh okay... if I read it in a different way than I was... then yeah. Also the Can we petition SO to implement a “invite user even though they’d normally not have enough reputation to talk” feature? - of course yes, was insisting on it since this post even when not mod, and even when I was mod I kept bugging the staff about it, and apart from the mentorship program...
... (cont) which did actually have rooms/permission differences for some things, it's just not going to be implemented... at the best of times it wouldn't have been and right now - there's more stuff going on, I think we should probably remove that as a discussion point if no-one objects too strongly about it?
 
I was looking at that point, and... Did they implement it and just not tell anyone? Because I'm looking at chat.stackoverflow.com/rooms/info/6/python?tab=access and there's an option for "Even when this room is read-only or their reputation is too low, these users will be able to talk in this room." Or is that something different?
 
@Kevin mod-only feature
 
5:37 PM
You can't give write access to a room if the user is less < 20 rep... there's a quirk whereby if you have a diamond you can do the same thing and it sticks though... (never quite worked that one out...)
 
Ok
 
Mod-only bug...
 
I can't see how much difficulty there'd be in in a conditional statement that's along the lines of changing: if granting_user.is_mod to if granting_user.is_mod or granting_user.is_owner or something... but hasn't happened in 5 years... I kept pushing it and afaik - it's not going to happen... so while it should... I can't see anything but "yes" come from the discussion and err... nothing happening again anyway
 
@Kevin Yeah, I don't really know what it does in that regard, I was just curious whether it messes around with py so that you don't actually get the latest version of vanilla python (if you also had those installed)
 
In any case I'm reluctant to remove anything from the agenda without the blessing of the proposer. Let's see if I can dig up who brought it up in the transcript...
> There have been numerous proposals (eg by @JonClements) to make it possible for such users to talk in chat if invited by a high-rep user / room owner, but nothing has ever come of it.
Ah, so I guess I have the blessing already... Ok, let's remove that part
As soon as this "application login failure" stops happening :>
 
5:48 PM
XY Problem, OP refuses to explain what they are actually trying to accomplish stackoverflow.com/questions/58657112/…
 
wim
SO chat should be burned to the ground and we all move to slack
 
Too newfangled. Let's all move to a BBS.
 

« first day (3303 days earlier)      last day (1637 days later) »