« first day (3304 days earlier)      last day (1645 days later) » 
03:00 - 21:0021:00 - 00:00

3:04 AM
Hello guys good morning Im bit puzzled when I read that local variables defined in function are thread safe. Assuming that in a function a local variable = modulevariable. Now, mutating the local variable will affect the modulevariable. So how is it thread safe?
 
4:01 AM
Flask framework being inherently multi threaded, in the sense that each request spins up a new thread, is it bad practice then to use global variables, module variables and class variables in a flask application? What are Your suggestions?
 
4:20 AM
You are not correct - a variable defined in a function is not a module variable (unless you have declared it as 'global'). Where did you read that a local variable is a module variable?
And you need to get your terminology correct too, if you want to delve into the details of threaded access to data within a multi-threaded program.
Generally, "thread safe" means that two threads can access some shared data structure without the need for any synchronizing locks, or that one thread can safely update the structure without locks. When you describe a local variable in a function, this is more commonly called "thread local", created within a thread and visible only to that one thread.
Since it is visible only to one thread, there is no "safety" issue to it.
Python emulates threads within its interpreter by switching between Python threaded code every 100 bytecodes. Many instructions in Python require multiple bytecodes to be performed, so those instructions aren't thread safe - the interpreter could interrupt things in the middle of processing the higher-level code. But some instructions or methods in Python are either done with a single bytecode, or below the bytecode level in the compiled C.
Since they can't be interrupted in the middle, those operations would be considered "thread safe"
 
 
2 hours later…
6:40 AM
I meant that -> Assuming that in a function, a local variable is set as follows: x= module.variable Where module is the name of module imported using import module. Now, mutating the local variable will affect the modulevariable. So how is it thread safe?
Is my concern making more sense now please?
So in multithreaded program, is it bad practice to use class variables, module variables (and global variables) in the function?
 
7:18 AM
the trick is recognizing that it was the "mutation" that caused issues.
So, mutation of shared variables would be a "potentially bad" practice in multithreaded environment
But as always, it depends on the case and specifics. Note that i did not focus on the earlier statements you wrote, but only specifically your last statement/question
 
jie
7:40 AM
class MyPoint(QPointF):
    def __init__(self, *args):
        super().__init__(*args)

    def set_name(self, name):
        self.name = name
this not work ?
can anyone one know, this is pyqt
 
Wooooooow, unpickling a method requires access to getattr. And access to getattr basically equals arbitrary code execution. Pickle tried to be more secure by adding the find_class method and failed spectacularly
class RestrictedUnpickler(pickle.Unpickler):
    def find_class(self, module, name):
        if module == 'builtins':
            raise pickle.UnpicklingError("forbidden: {} {}".format(module, name))
        return super().find_class(module, name)

data = pickle.dumps(RestrictedUnpickler.find_class)
RestrictedUnpickler(io.BytesIO(data)).load()
# UnpicklingError: forbidden: builtins getattr
@jie Define "does not work"
I wonder if "how do I need to implement Unpickler.find_class to be safe from arbitrary code execution" would be a suitable question for SO
 
jie
@Aran-Fey you have good method?
 
not sure what you mean
 
jie
good method to subclass QPointF
 
I don't know pyqt
 
jie
7:49 AM
i think need to write a post
好吧
 
Make sure you can elaborate what is the actual issue with the way you're trying to do it
A "does not work" is too vague. Does it crash? Do something unexpected? Give an error? Specific information is needed
 
jie
it's not me say
 
im sorry, i could not understand you.
 
8:17 AM
@ParitoshSingh@PaulMcG, my concern is not when I am writing a multi threaded application. I am worried that applications like flask are multi threaded in the sense each request starts a new thread. So is it right to say that we must not use global variables, class variables and module variables in flask?
 
It isn't right to say that. note again, its not reading a shared resource that causes issues. "mutation/updation" is where things get mucky.
 
@erotavlas Perhaps this question I answered a while back is what you wanted: stackoverflow.com/q/46230895/4909087
 
 
1 hour later…
9:24 AM
@variable a local variable is set as follows: x= module.variable This is not a local variable then. It becomes a shared variable because the module is a shared instance. And "must not use" is also overstating things - many times multiple threads must have a shared variable, perhaps a work queue, or a read-only dict for configuration.
If this is the case, it is perfectly acceptable to have such a thing, as long as the threads synchronize their access to it through locks, or limit themselves to thread-safe or read-only operations.
 
@variable A better angle might be: what is it you're trying to do, specifically?
 
Why are you trying to be so extreme in this question? People write multi-threaded applications, either with Flask or their own explicit threading, all the time, including access to shared global variables when necessary. The point is to know what you are doing, and recognize when synchronization is necessary to keep threads from stepping on each other.
So I'd say "no, it is not right to say that we must not use global vars, etc. in flask", because many times this is exactly what is required by an application.
 
I'm putting my money on a global dictionary to do something that's addressed by sessions. We shall see :)
 
9:40 AM
@jie I've tried this using a slotted class for QPointF and a namedtuple for QPointF, and in both cases, adding a .name attribute to an instance of the derived class MyPoint works just fine. What exactly is not working? And what version Python?
 
I have tried to explain here request your advise stackoverflow.com/questions/58669710/…
 
The advice is exactly the same as you got here. I'm not sure why you converted it to a question on main after people already explained here but, eh
 
9:57 AM
Honestly these pagefuls of vague concerns are completely unclear to me, and it seems the first actionable question is
> I am worried that applications like flask are multi threaded in the sense each request starts a new thread. So is it right to say that we must not use global variables, class variables and module variables in flask?
The rest sounds like academic angst
 
jie
@PaulMcG i am use QPoint to write a gui app, i am use pyqt5 and python3.7. I had post a question here stackoverflow.com/questions/58669428/…
 
In which case, the answer was no, and was already said by others. You couldn't really start a flask application without a config.py module, or similar.
 
Ugh, pyqt
series << pt
"Cute tricks"
 
Verify that the type of item you are looking at is a MyPoint. It may be that pointsVector() returns copies as QPointF instances. Not very efficient, when that method is supposed to be super-efficient, but...
@AndrasDeak Probably trying to retain it's C++ coding feel.
@jie Also, try accessing info and name immediately after assigning them. Put your print statement right before the '<<' insertion into the series. It's also possible that the insertion bit is converting your input MyPoint back to a QPointF, again stripping off your extra attribs
 
@variable If you import a class from a module and change one of the class variables, do you think that it changes for others?
I've voted to close your question as unclear, but I suspect you have a misconception
 
10:11 AM
@variable I am confused by this question. What does it have to do with flask at all? Stripping away all the fluff, it seems to boil down "are shared variables thread-safe", which you have answered yourself already.
Just because a shared variable lives on a module or class or happens to be used with flask doesn't make it any less shared.
 
My suspicion is that they think something like ImportedClass.x = 'something' changes the class for other users that import that class
When I was really fresh to programming, I actually couldn't understand why my changes to a class were not reflected in the file I was importing from
 
@PaulMcG yes, ew
 
@variable - and there is nothing special about Flask. It is very commendable that you are designing your class with threading in mind, so go ahead and implement your class, and where there is data that may be shared across threads, guard it with synchronization when it must be accessed. (Kevin'd by MM.)
 
@variable And let that be the bottom line. This discussion would go nowhere beyond this. Thanks.
 
@roganjosh Yes i thought so that changing class variable will affect it across all threads
What am I missing please guide me thanks
I thought class variable is shared with all instances
 
10:26 AM
@variable Then you need to look at the thread-local aspect of Flask
 
@variable - Have you looked at this related question: stackoverflow.com/questions/37806858/…
 
note that a regular class is not thread local. one has to explicitly define it as such.
 
Sure, but they are talking specifically about Flask and it gets quite complicated in that case. I need to dig up the answer I was reading when wim brought this up
 
Oof, I'm out
 
@PaulMcG Yes this example is about class variable being globally shared and instance variable not being so.
 
10:31 AM
just out of experience, it is dangerous to imply classes in general are thread-local in Flask.
 
Not necessarily. How flask spawns new processes shouldn't really impact a normal person's workflow. It's only when you start doing weird things that you need to concern yourselves with it
 
Ultimately, I think What is the purpose of Flask's context stacks? is what explains it for them, but it's perhaps a bit too detailed
 
The key thing to note here would be that it's the person writing the flask code then who has that responsibility.
 
rbrb
 
Taking flask out of picture for a moment, am I right that global variable, class variable and module variable are shared amongst all threads?
 
10:36 AM
If we take Flask out of the picture then we just go full circle and Andras already suggested that discussion should end
 
@variable yes.
note that global classes and global variables are module variables.
 
Lol, I just realised that you already saw my first link so you've got Martijn talking about the thread-local aspects of Flask already
 
So when designing a package containing helper functions, (and assuming I dont need global variables), with end goal being this package will be used by flask application, then, in the package, is it wise to write a module with the functions or write a module with class that contains the functions? My thinking is that class approach is not efficient as it requires users to instantiate it.
 
define "efficient"
 
Thanks
 
10:42 AM
Like, what does your package or library need to do? Because, at this point i suspect, you've created a phantom issue in your head, and are wrestling with it, when no issue exists. You dont need to write special code just to make your code be consumable when used normally vs when used by flask, UNLESS you've actually synchronizing some kind of shared information or data.
 
@variable Have you timed the instantiation?
 
When someone "uses" your library/module to "create outputs", they are consuming your logics only, and the storage of those outputs is on them.
 
This room was placed in timeout for 1 minute; Please stop discussing an imaginary problem. What can be said have been said multiple times already.
I suggest discussing on variable's question in comments, or in chat elsewhere
 
Oh, that's a nifty feature
 
I'm torn between feeling guilty and being in awe.
 
10:45 AM
haha
 
then it's working :P
 
I suppose curious, were timeouts added later or always planned when chatrooms were conceptualized?
 
it was a mod feature (probably not from the start), and became a RO feature after years
 
11:07 AM
cbg
 
cbg
 
I don't know when I can let go of this laptop. It got me through uni, went to Dubai and London with me, where I bust the screen so it only works when connected to my TV, but I just want it to live... The 10-minute freezes are getting to me, though :/ I guess I'll have to suck it up and cope with Windows 10
 
I thought I was too critical with modern windows, but if 10-minute freezes are what it takes to switch, well... :P
Have you considered using linux? You don't even need a screen ;)
 
:P
 
11:14 AM
unfortunately SO chat will probably not load through links
 
Oh, my hatred of Windows 10 runs deep. Very deep. But it does come with Linux support these days
 
trojans are everywhere
 
unclear, unreproducible (see self-"answer") stackoverflow.com/questions/58669295/…
 
Maybe I'll embrace the new generation. I'll be tapping away on my touch screen being super-productive with all my bloatware apps
You'll see a new me
 
@roganjosh Cortana will be your bff
 
11:20 AM
If Cortana learns from user input then it's probably going to be a blow to all the other users, but oh well
 
What stops you from using an older OS on a new system?
 
I suspect new laptops come with win 10
 
(apart from the fact that it's probably not a great idea to hold on too long)
 
Licenses
 
oh, those things. nervous laughter
 
11:21 AM
I looked at dell laptops a few months ago, and every single one that was nice had windows :(
 
I'd have to torrent Windows 7 and it probably would throw the warranty down the drain
 
the worst part about windows being pre-installed is that I pay more for something I'm never going to use
 
fwiw, windows 10 can give a win 7 like experience, if you're careful about the setup up front, and then you dont really notice
i was also an unwilling win10 user, had to switch since the new laptop came with it
 
@AndrasDeak actually, what do you do there? Do you wipe Windows off the system as step 1?
 
@ParitoshSingh "careful about setup" == spend 2 hours disabling every single spyware option?
@roganjosh I probably will. My laptops so far have come without it
 
11:23 AM
@AndrasDeak ..yeah :D it's about 15 min or so at most for the basic setup
 
might make some kind of backup of the original should the need arise to restore it
 
the setup process is a lot better with prompts though about things that could be spyware equivalent in all honesty
 
mainly because if the hardware breaks the level one support will have no idea what to do if the machine doesn't have Windows installed
 
win10 got a bad rep at launch because they deserved it
 
but better buy one with a proper OS preinstalled and competent support ... if you can afford it
 
11:24 AM
now, they at least have made the opt out options easy to access
 
@tripleee if hardware repairs need knowledge of my OS then they're already off the mark...
 
(at least the ones that i know of anyways. perhaps theres some hard to access ones that i myself missed? in which case, im sorry CIA)
 
yeah but try to tell the drone at the reception desk he has to abandon his script
 
Just send an eagle/hawk
 
windows or not I wouldn't give them login access anyway
let alone run some shady script :P
 
11:26 AM
Apple support tends to absolutely require login access so they can check that it works properly when they are done
 
heh, apple
let me shed a tear
 
that seems to be the popular way to avoid paying for Windows these days
 
good thing I'm the hipsteriest hipster
 
and by "done" they mean- let me replace the whole thing for a new thing for the price of twice a new thing
 
Fair play to them that they market standard tech so well, but I just don't get the hype to justify twice the price
 
11:29 AM
rbrb
 
Anyway, I'm interested that you looked at Dell. This laptop is Samsung and I really like their stuff for longevity. It comes with bloatware but that can be removed. Is there a favourite brand outside of Apple?
Sony was the bees-knees at one point but I think they're also overpriced these days
 
with laptop, i have a simple rule
don't worry about brand too much, look at specs and reviews.
 
@roganjosh I'm definitely a dell fan. All the laptops in my close family have been dells, and they're great. The newer inspiron series are built quite crappily, alas. I'm on my second base cover for my current laptop (after 6 years) and it's also broken in several places. But the wife's Latitude is amazingly sturdy. So the next one will probably be a Latitude for me. But they are unsurprisingly much more expensive...
 
sometimes you get really bad laptops from really good names, and vice versa
 
11:39 AM
@ParitoshSingh disagree to some extent: the hardware might have the same technical specs but its reliability can differ wildly
 
My only long-standing issue with Dells is that for many years the fans have not been accessible via panels. You have to dismantle the whole machine to clean the fan.
 
@roganjosh amusingly enough, i use that same argument for not worrying about the brand name too much :P
 
As I found out when buying this TV... the lower end of the market all buy from the same source and just slap their brand on it.
 
With the implication that, even a branded laptop can be "the rotten egg off of the assembly line" if you're unlucky
 
"rotten egg of the assembly line" is what warranties are for
 
11:41 AM
I suppose, all that aside. I can say i've had really positive experiences with 1 lenovo, and 1 acer laptop so far.
 
(and Dell has 3-year warranty on principle)
 
@AndrasDeak ok. maybe "slightly off but not quite rotten, tough to tell" eggs off of the assembly line
 
Acer is another that I think overcharges for their specs
 
But maybe I need to get my own perceptions in order if I'm suggesting a premium on quality hardware
 
11:42 AM
I feel that way about hp and dell. Acer, the one i have honestly was a steal in my eyes
and i also feel that hp can't justify the premium. dell could "once".
But i suppose that shows the cracks in my "brand name doesnt matter" analogy :P
 
We're both falling apart on opposite ends of the argument :P
 
With Dell there's the Inspiron (and maybe Vostro?) line which is the cheap one. It has decent hardware inside, but the plastic is crap. Anecdata, but I haven't had any kind of hardware issue in the 8 or 9 years that I've owned a dell
 
"Anecdata" --> tucks that one away in memory
 
the business product lines (Latitude, XPS) are way more expensive, but are much better built and have better warranty
PSA: whoever wants to help variable break out from the circle they are welcome to do so in this chatroom I guess
 
11:54 AM
I can't even at this point. Time to make lunch
 
Hi there again. Maybe someone knows a good method or library for labeling? For example I iterrate over a list and isnteaf of "0x2rf23g12321g332geeeeqdf213gb" i want to have "a", "b" etc.
 
hello
> isnteaf of "0x2rf23g12321g332geeeeqdf213gb" i want to have "a", "b" etc.
please elaborate
what are your input types, what output do you expect and how
@MisterMiyagi in case you were losing sleep over this: I've finally contacted the hpc admins and we could get the python 3.6.1 module to work with two envvars. One fixes a missing libreadline link and another limits the number of openblas threads, which is why numpy was borked
so the two days I spent building my own ecosystem is only valuable experience :D
 
12:30 PM
6 rashers of bacon in my 5 pack (yey!) --> breaks yolk on putting egg in frying pan. One simply cannot win in this universe.
 
12:52 PM
@AndrasDeak Please ditch the link mate, I can't see anything productive going on there
 
People can easily not click it, or choose not to engage
Now that there's a link to there I don't have to fear (tolerate) someone continuing here
 
Ooooh, I misread the link. I got invited to another room for me and variable and conflated the two
 
1:38 PM
recbg
@roganjosh I sometimes go weigh the "prepacked veggies" in a grocery store. Was wondering what's it with the 250 gram celery bags, I took the smallest one of them and weighed it, it was 400 grams :P so I guess you always win when buying celery.
 
I don't actually know how celery is processed, but I guess the machine screwed up a bit there. Although, I don't think people would buy celery if there were loose stalks so maybe it's just a minimum weight and biology does the rest
Still, somewhere you will have had a misfortune in proportion to your extra 150g of celery that you got free :P Maybe your laces became untied or something
 
2:14 PM
If I want to use @functools.lru_cache to cache some output for a function inside a class then how to do it?
Suppose I have a class Solution and inside it I have a function func(self, n).
 
The doc for lru_cache (docs.python.org/3/library/…) shows how to decorate a function using it.
 
caching a method is different from caching a function though
does the result depend on self? Is self hashable? etc
 
2:33 PM
Actually solving this problem from leetcode.
Here is the code.
I'm not sure if it's caching the function's input to output value(as a dictionary) or not, it's showing TLE for 22222222
 
You're caching the class, not the method.
 
Ok, then how I can cache the method?
 
slight tangent, can i just say this is a new low in my eyes, when a class is being force fed into a solution template.
 
I'm sure you can figure it out
 
For a problem where there really was no need for a class.
 
2:40 PM
lots of these programing challenge websites do it, it's crazy
 
^ closed, thanks
Also, it appears I have the new banners at home (whereas the speculation was that it was IP-based or something to only give them to me on work's laptop)
 
@ParitoshSingh Something a Java person would do
 
@ParitoshSingh This happens all the time on codereview.
 
2:55 PM
I guess i was lucky enough to have been sheltered from this trend till now. But now the illusion is broken
I'd like my blue pill please
 
Denied
 
in luke style nooo...
 
It's even worse when some student is given Java first and is convinced by some prof somewhere the OOP is the savior of mankind and decides to use OOP whenever possible. Their posts on codereview will usually be a "How can I better utilize OOP to ..."
 
The red pill gives me one of my favourite lines. "Not like this..." when the woman with white hair gets killed
 
the answer (for every one of my answers at least) always: The amount of OOP you have is too much.
 
2:59 PM
Im surprised at myself for being able to actually visualize that scene perfectly
 
I was reading about the Russian spy whale (he's super cute, btw). Then I found out the US uses/used dolphin in warfare. Imagine standing on the deck of the ship as a pod of dolphins comes at you, leaping through the water with their explosive jackets, chattering away. Perfect time for a "not like this..." comment
 
"That's dolphinitly going to leave a mark"
 
Dang this is amazing: punpedia.org
3
i don't need to be creative with puns anymore, it's a solved problem.
Ok, seriously, last night I was just thinking about how I wish the app for SO had a dark theme and then I saw this question and was like, how did they know?
I was going to ask about this, but then I remembered 1. I don't have a meta account, 2. Almost nobody likes the app lol.
 
3:15 PM
I know Aran has been tinkering around with dark theme for browsers, but im not sure whether it translates to mobile well or not.
 
@ParitoshSingh I actually use the app and not the mobile site lol.
 
As for the app, yeah i really don't know anyone else who uses it. Sounds like you do though? How is it?
 
I see why people don't like it, the functionality is missing, but it is a lot smoother IMHO.
 
Ah, i see i see
 
Usually I just want to really see some trending stuff tho so it doesn't bother me, I don't actually expect to answer stuff. It would be nice, however, if they allowed up/down vote counts and the ability to view deleted questions.
Most of the community has been like: Just improve the mobile site, but I don't think it is exactly feasible. Their mobile app uses hybrid native/web framework (I think ionic), therefore, I suspect, it is a lot easier to get a smoother experience with the app.
 
3:21 PM
I don't buy that at all. That's (potentially) a poor design decision, but it in no way leaves the product salvageable
They just don't care. That's the only reasonable argument, surely
 
I observe a "chicken and egg" situation in some sense here as well
If there exists a feature-lacking/less than desirable mobile app, then people are not happy or excited about it. And since people are not excited about a mobile app, it doesn't make sense on paper to invest the resources in fixing it.
Maybe im overthinking this, i dont know. But i can imagine that being a thing too.
 
@ParitoshSingh The mobile app isn't buggy, it just lacks features.
 
Whether it's a chicken and egg thing, or a self fulfilling prophecy, im not quite sure how to phrase it
 
I would be excited about a functional mobile app
 
@Dair fixed. i misspoke
 
3:25 PM
I need to find the original post, a lot of things may have changed since then too.
 
*unsalvageable. I also misspoke
 
Oh, i didn't even notice and ended up reading it the way you intended it
 
:P
 
amused
 
we just need to wait for those PWAs
 
3:27 PM
At the risk of sounding silly, "PWA"?
 
Lol, I raised that about a month ago in here
I don't think anyone has a proper understanding of how they work
something something offline functionality
 
I'm keeping my eye on it, but I don't do app development lol.
 
Survey - which code would rather work with?
print("{} {:0{}d}".format(name, i, width))
print("{} {}".format(name, pad_leading_zeroes(i, width)))
 
It's not really an app, though
@PaulMcG the latter for me
 
3:32 PM
@PaulMcG Former for me lol.
 
@Dair I considered it for my needs but now I'm looking into Kivy. I just didn't quite get PWA but maybe that's my failing
 
I was looking at an instance of the second in our code base, thinking "psh, why bother with a function to do that when there is defined formatting that does that?" But when I replaced it with the former, I didn't feel like I'd actually made a Change for Good.
 
@PaulMcG Have you tried profiling it? Which one is faster? That's always a good justification if they both seem stylistically almost equivalent and a small change.
 
I wouldn't break the deadlock over %timeit here. I flat-out wouldn't know from first glance what the first version did
 
@roganjosh You might not break the deadlock, but I would. :P
 
3:40 PM
I'm actively resisting looking at performance here - not a perf-critical bit of code, and the code base needs to be usable/maintainable by novice-ish Pythoners
 
@Dair Sure, we're disagreeing. There aren't rules against that :P
 
@PaulMcG Novice pythonistas? Are they trying to get better at the language? If not go with later, if they are, go with former.
 
what about things like zfill and stuff?
 
The current implementation of pad_leading_zeroes uses str.zfill. I think I'll replace that with my str.format style - if they want to learn how to pad with leading zeroes, then when they dig into pad_leading_zeroes at least they'll see a more modern idiom. (That might be worth profiling)
 
@roganjosh Are you liking Kivy btw? Do you think the resulting app looks decent?
 
3:46 PM
timeit.timeit('"{} {}".format("bob", str(3).zfill(4))')
0.6653338210016955
timeit.timeit('"{} {:0{}d}".format("bob", 3, 4)')
0.7152471840090584
 
@Dair nowhere near having an app atm. I need an app for what I'm trying to do, so I'll see.
 
i just cant seem to make myself mentally parse the {:0{}d} version
 
@roganjosh Alright, if you don't mind, lemme know, I'm always curious to see how the desktop application development field is changing and what works and doesn't.
 
Sure
 
Thanks.
@PaulMcG Dang it python, if you're going to add syntax for a preferred way to do something, make it fast.
 
3:49 PM
is this a new addition or something? i've never had to face this thing before.
 
So far, the survey is 2:1 against you, @Dair
 
@ParitoshSingh The nested braces consume two args passed to format. The outer braces take the first arg (3), the inner braces take the 4, so it becomes "{:04d}" or 'a 4-digit zero-padded integer'
 
ah i see
ty
 
@roganjosh It shouldn't be in theory. :P It just is in practice. Although, use str(3).zfill(4) instead of the longer method.
 
You used to be able to do this in the C-style % formatting too - %0*d would consume two args - the width and the actual integer value, and zero pad to the width. (I first picked this up doing tabular output in C with printf.)
 
3:53 PM
does the f string version f"{i:0{pad_width}d}" make it better?
 
I certainly like that better than using zfill
timeit.timeit('f"{name} {i:0{width}d}"', 'name="bob";i=3;width=4')
0.5783046770084184
My guess is that much of the savings is in avoiding the str and zfill function calls
I've been wary of jumping onto the f-string bandwagon, but I guess all the cool kids are doing it
 
4:26 PM
Good evening
 
rbrb - I was just leaving, but there are others here to chat with too
 
4:39 PM
hey paul
@PaulMcG would you happen to the maintainer of aiomysql
 
5:37 PM
@objectiveME No, I'm not - pyparsing and littletable are my projects, and they are plenty!
 
@PaulMcG okay thanks for clearing that up.
 
5:59 PM
cbg
 
hi everyone! okay so i have a neural network question. If I have a dataset with a lot of features will I face the vanishing gradient pproblem?
 
They are pushing the responsive mobile version instead
 
if gradient goes to zero during the first epoch of training then you know yes, the data does have many features
 
6:19 PM
so my best guess is that it would happen. would lstm help?
 
6:55 PM
I had a weird flashback. I remembered the days when Friday's newspaper had the TV programme supplement, and if you missed the paper you had no idea for a week what the programme was. Gave me chills to remember :D
On a more informative note, I ended up being able to create a venv at an hpc cluster in such a way that I need two envvars to be set for everything to work. I only need the envvars for python, but I always need them for python. How weird is it to edit them into the activate script of the env (which I intend to use every time)? Or is there perhaps something more idiomatic?
 
7:33 PM
Today's new entry in the "list of function names that make more sense if you're a programmer": snake_to_camel
 
user10984358
hey guys, stackoverflow.com/q/36564260/10984358 do the docs explain the "Solution 2" in this, I ran into this and this helped me
 
@TheNamesAlc do you understand why 1 doesn't work?
 
user10984358
I had a gut feeling \1 would be usable only within regex before I tried, I dont know how it can be used with a lambda instead
 
@TheNamesAlc the problem with 1 is that dict1[r'\1'] gets evaluated before the call to sub
 
user10984358
ohh, how does one know the order of evaluation?
 
user10984358
7:40 PM
I am missing out on some rudimentary concepts I guess
 
function arguments are always evaluated before they're passed to the function
 
cbg folks
 
a function's inputs have to be determined before you can pass them :)
python needs to know what potato is in foo(potato)
 
anybody ever come across a dataset of all english words and definitions, webster dictionary style
 
user10984358
that makes it clear, I was getting bytes some 0x some hexadecimal I believe
 
7:41 PM
this is the closest i found but the lack of structure is dissapointing gutenberg.org/ebooks/29765
 
@TheNamesAlc you should've gotten a KeyError, probably
 
user10984358
yeah I did, i printed the value to see what I was getting as key, it was some hex
 
you probably weren't using raw string literals
So what 2 does is explained at docs.python.org/3/library/re.html#re.sub
 
user10984358
I only had the practice of using r-string on the pattern, guess now I know
 
If passed a callable, each match is passed
@TheNamesAlc they are always useful when you want literal backslashes in a string, rather than python-level control characters
(By which I just mean that '\n' is special in python, '\1' and '\s' are not)
 
user10984358
7:46 PM
>>> print("\1")

never tried with numbers
 
user10984358
repr of the same gave me "'\\x02'", I get it now
 
8:02 PM
@TheNamesAlc that's an octal escape, see docs.python.org/3/reference/lexical_analysis.html#strings
> \ooo: Character with octal value ooo (1,3)
> As in Standard C, up to three octal digits are accepted.
so '\1' == '\01' == '\001'
this also explains this:
>>> "\7"
'\x07'

>>> "\8"
'\\8'
\7 is a valid octal 007 == 7, but \8 can't be interpreted in base-8, so the parser falls back to ignoring the escape and taking the backslash literally
The former is what you don't want to accidentally happen with backslashes, which is why you should use raw string literals when you have literal backslashes
 
@user5444075 absolutely
 
(either that or escape your backslashes as \\, but that's less readable)
 
8:42 PM
@AndrasDeak oh and obviously that was wrong, \1 is special too (I just didn't know that)
 
03:00 - 21:0021:00 - 00:00

« first day (3304 days earlier)      last day (1645 days later) »