« first day (3021 days earlier)      last day (2151 days later) » 

00:32
hey, i have a really weird problem, im still at the beginner level in python and when i couldnt sleep i found an exercize page. i am writing a script to check if a given input number is equal or not: dpaste.com/3J0WAES
You mean "even", right? Divisible by 2.
but i get an error message for invalid syntax on the first if statement when i run it in my console. the pointer is on the colon
What does the syntax error tell you?
of course, sorry
just to make sure you didn't miss it: I also asked a question ^
(If you're just not here right now that's fine)
00:36
the "of course, sorry" was responding to your question if i meant even, not equal ^^
I know :)
oh right, I meant I asked another question afterward :D
{ if number % 2 == 0:
^
SyntaxError: invalid syntax]
OK. So that's the point where the parser realized that something's wrong. Here's the catch: the error is usually on that line or the previous (non-empty) line.
if the line reported by the syntax error seemingly has absolutely no chance of having a syntax error, look at the previous line real carefully
oooooooooooooooooohhhhhhh
00:40
thank you ^^
No problem. +-1 line is always suspicious, though I'm not sure if +1 is possible (probably not)
and of course if you still can't find a syntax error it often helps to have a pair of independent eyes on the code
yeah, sometimes its the stupidest mistakes that go unnoticed
yet, its always a little embarassing :(
Nah, typos for instance are only obvious in retrospect. The errors like the one you had are easier to spot with a little experience. Some esoteric syntax errors are much harder to find.
the other day there was a post on main where someone couldn't import BeatifulSoup, then later tried to use Beautifulsoup...neither of which are BeautifulSoup which they meant
if you use an editor or IDE that handles automatic indentation it's easier to spot some of these errors. For instance in vim which I use if I see that no indentation is added after a colon I know I missed a closing parentheses or bracket somewhere. Or in your case starting that new line without the closing parentheses would have indented your code which is easy to notice if you expect it.
Even veteran coders still make silly mistakes from time to time. But we tend to catch those mistakes pretty quickly because we recognise the symptoms through past experience. ;)
Mar 9 '17 at 8:43, by PM 2Ring
@AshishNitinPatil Old programmer saying: "Nothing is so smiple that you can't screw it up." :)
01:14
cbg
How to install a new dishwasher: Step 1. Sprain your back trying to remove the old one. No, wait...
Hire someone with your comfortable SE salary
Step 2: Spend the next 20 years of your life treating a slip disc
*rolling in fake internet points*
@coldspeed fortunately it was upper back. I watch my lower...
ah, did that really happen? My bad, sorry bout that!
01:18
Yeah, just now. I was being an idiot.
Nothing serious I think. More news at 8 :P
Hah, I like how the first thing you did after throwing your back out was to whip out your phone and send a meme on chat
Well, I did finish removing the machine first and the new one only arrives tomorrow :P
That supernova question hit the HNQ. At this rate, it won't be long before I can cast close votes on Physics. I can already do so on Astronomy, even though I have fewer points there, I guess that's because it's a beta site, though oddly I still need approval for edits there.
@AndrasDeak Ouch. Put a cold pack on it. That'll numb the pain & reduce the inflamation.
thanks, though I can even walk upright and everything (hmm, or perhaps that's specifically a lower back thing)
 
2 hours later…
wim
wim
03:10
LOL, pip v19.0 now has a nag for python 2 users
> $ pip install -U pytest
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
kind of annoying for maintainers of cross-compat libs, hope there is an easy way to suppress this
Also, it looks like this pip v19.0 release finally implements build system support in pyproject.toml. Hooray for setup.py-less packaging! 🎉
 
1 hour later…
 
2 hours later…
06:07
cbg
06:40
@coldspeed 1 vote to go.
brief mid-week cbg folks, have a nice day!
07:36
MHC
@wim does pyproject.toml support entry points yet?!
ah it does, yay!
ah no
wim
wim
08:11
Well, it doesn't really need to, does it? The build system can support that if it chooses to, or not.
08:25
i am making my new website in django & the previous one was in php & all the data was stored in mysql database. now i want to actually transfer all the user data from the user table to the auth_user table so that django can verify it but i am failing in doing so ?
how to transfer the user data to auth_user so that django can authenticate the user's id & passwords. I even tried to do so manually but there are more than 1lakh users in database making it difficult and since user object isn't creating when doing manually it is unsuccessfull.
pl. suggest a way ?
08:41
Hey guys, just a quick question not worth to ask on the forum.
I have a string which will contain "value" and special characters. What is the correct regex to replace the special characters with their simple forms? (replace è by e , ô by o)
@coldspeed reckon you could weigh in on meta.stackoverflow.com/q/379244/1709587? The controversial editor discussed there seems to have been acting on guidance that you added to the pandas tag excerpt. I've just removed that guidance entirely, since the Meta commentators seem to thing it's silly, but I've barely ever touched pandas and wonder if I'm missing something.
@ChiPlusPlus answers at stackoverflow.com/q/517923/1709587 might be relevant to you
@gadia-aayush hello. This is just a heads-up that most users won't know that 1 lakh == 1e5.
@ChiPlusPlus what Mark said. Definitely not regex.
@MarkAmery Hello and thank you for bringing that to my attention. I have added my 2c there.
09:00
@MarkAmery +1. They aren't meta-tags but definitely shouldn't automatically be used.
I think the problem here is more with the editor than the tag guidance. The advice was meant for OPs to ensure good, hygienic tagging practices. Not a green light for users to farm edits for rep.
@coldspeed If the tags are genuinely useful, why does it matter if the person adding them is trying to "farm edits for rep"?
@MarkAmery Thank you!
@MarkAmery because the edits themselves were not substantial enough.
If the edits were good and fixed more than just the tags, I'm not sure anyone would be complaining right now.
But they weren't...
Editor is definitely off. But I can see how the tag wiki excerpt was misleading. Plus "IMPORTANT" is just noise. People either open the excerpt and read it or they don't.
 
1 hour later…
i dont really get one thing. if pandas actually uses numpy arrays internally (apparently. correct me if im wrong), why does it feel so sluggish many times? Do dataframe level "apply" calls fail to utilize the underlying arrays?
background: i have used pandas a couple times, and have always resorted to either dictionaries/lists/sqlite eventually out of sheer frustration. (one aspect being it doesnt feel intuitive to me. but thats another issue entirely.)
If you are using pandas with apply, you are doing it wrong. If you are using pandas dataframea for operations that cannot inherently be vectorised, you should look at other alternatives. Some examples in this post, for example
So, i should treat apply as a trap?
Also, jeebus that is a very thorough answer there. Thanks
yes
it is a pandas antipattern in a single function, and has very very few use cases. For example, today I found that apply + map can be faster than replace.
But besides broadcasting series operations across columns, not much good use for it.
10:32
I'll revisit pandas if i ever again find myself in a situation where it may be appropriate. For now, im still scarred by pandas, and i dont think that will ever really change. I just dont know what exactly it would have taken to make pandas more entry-friendly
@ParitoshSingh df.apply is as good as np.vectorize.
"Sounds good, doesn't work"
11:17
recbg
 
2 hours later…
13:06
Is there a way to wait until a threading.Lock is released without using while lock.locked() or the likes? I need it in this code:
lock = threading.Lock()

def wrapper():
    try:
        return worker()
    except ExternalProblem:
        if lock.acquire(blocking=False):
            fix_external_problem_exactly_once_on_first_error()
            lock.release()
        else:
            # Just wait until the lock is released
            # (i.e. until the external problem is fixed)
            pass
        # Re-run the affected workers
        return worker()
Each wrapper is running in its own thread
I guess this is as ~pretty~ as it can get:
else:
    # Just wait until the lock is released
    # (i.e. until the external problem is fixed)
    with lock:
        pass
13:57
@vaultah I don't know threading very well, but I have found this.
wait(timeout=None)
Wait until notified or until a timeout occurs.
14:35
wow, I had a totally awful idea :D
python does have f-strings but not i strings...
so I had an idea of making them with a lambda that contains the f-string
... then the bytecode for that lambda can be decoded...
10 cm of snow cbg \o
@AnttiHaapala I'm trying to appreciate your idea but my ignorance is preventing me.
@MooingRawr canadian problems
at 10cm it's not a problem, it's a gentle morning snow ;)
@MooingRawr is it 10 cm more?
I thought it was 10 cm in total :D
In France, 5cm of snow and the country is falling appart.
15:10
When I was in Seattle, the city was a mess when it snowed. The hills + ice turned it into sliding bumper cars
15:23
Synopsis: pseudo-physics model. Friction-less blocks, perfectly elastic collisions, and immovable wall. Count the collisions, both block-block and block-wall.
║                     ←
║     ▉▉
║  ▉ ▉▉
╚══════════
10 more, we had like 4 cm before, but agreed, it's not an issue until we have to bring in the army to help shovel.
@piRSquared I see you also are a 3Blue1Brown fan. ;)
@piRSquared I like the animation
good morning
15:25
@MooingRawr Edmonton took out the trash
@vaultah lol. Unexpected formatting ;-)
Oh, he released the solution.
@idjaw bwahahaha, not really their fault that the oilers are still "slipping". Tbh, my team is in a slump too and the all star exhibition needs to come quicker, I hope the festival will reset the team :\
how to import things.py from tests.py
15:26
@MooingRawr yeah...but....42 million for lucic I will never understand and will never make sense.
things like that...
taylor hall...
hurgh
Nylander, 7 mill 6 year deal...... is giving me nightmare
Please post a question on the main site @Self and show us what you've tried.
should have pay that for Mariner :\
omg yes, hockey
To add onto IMCoins, or you can explain what you've tried. Or use an external pastebin service to show us your code.
15:29
Just because I felt bad for my last unicode diagram...
║      ←
║     ███
║ ██  ███
╚══════════
Still not happy with the vertical spacing on chat... oh well
@Self not enough information to answer that
@vaultah what shoud I include??
@vaultah Using relative imports, you can deduce what he could do. But for absolute imports in the package, not enough information indeed.
in my tests.py I imported like thisfrom .api import things
from .api import things
but it throws errorrs
@IMCoins they could also use pytest, which has its own quirks
15:33
@piRSquared nothing pseudo about that
what word would you use when the model is unrealistic?
physical models are always unrealistic, the question is whether they are applicable to a given problem
The point of a model is abstraction, i.e. ignoring things to get a simplified description. Some models are simpler than others.
fair. I'll consider myself partially enlightened
sorry, physicist nitpick :P
I appreciate it, sincerely
15:35
you're always welcome ;)
I'm so put off by last year's (?) survey that was pretty much about marketing and ads that I'm not sure I want to take it. Especially with a guaranteed welcoming questionnaire.
There were only 1-2 pages related to job search things, most of it was the usual tech stack/workplace stuff
I just remember I stopped before tech questions started...
might give it a shot then
Though unfortunately still strongly tailored towards full-time developers
No love for us lowly engineers
howdy folks! many cabbages all around
@excaza or scientists! Boo!
Cbg, inspector. Long time without an inspection
15:46
> Compared to last year, how welcome do you feel on Stack Overflow?
That wording feels kinda awkward
@AndrasDeak working on that ever lovin' thesis
"Bored" wasn't an option :'(
@vaultah much like ever year, it feels like walking back into my childhood room after a long year at school
15:47
> Do you think people born today will have a better life than their parents?
Ats weird
> Have you tried turning it off and on again?
Look, we're funneh!
> Which of the following do you currently identify as? Do you identify as transgender?
<cue other-country accent> sir, the attitude isn't helping one bit at all. Now, I'm going to ask you to move your phone closer to your face and speak clearly into the microphone
They're also asking about your sexual preferences. Good job, Stack Overflow!
wait what?! where?
I thought you were joking... didn't realize this was an actual thing
I didn't have the question "Compared to last year, how welcome do you feel on Stack Overflow?"
15:52
@IMCoins if you weren't here last year?!
@AndrasDeak this year the survey was pretty good
I think I was. :P
they did ask only about jobs on one page IIRC.
rbrb. Meeting
@vaultah identity crisis
I answered honestly which makes it really boring.
straight white male that doesn't have any significant disorders or disabilities (being a Finn does not count)
🧄 <= this doesn't work :(
Did anyone else take the 2019 survey ?
15:56
@MooingRawr no. You're alone
Do you think people born today will have a better life than their parents? threw me off....
oh. It's just for me :D * - *
@vaultah Have you tried the lock with the threading.Condition class ?
I couldn't get it to work properly, likely because the wait method does something to the underlying lock by itself
> This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() [...] Once awakened or timed out, it re-acquires the lock and returns.
Maybe it can be implemented with threading.Condition, but I don't know how
FWIW, the with lock: pass solution feels acceptable to me now
@AnttiHaapala I guess the data scientists at SO are just as bored from reading/processing honest answers :P
The less sense the dataset makes, the more fun the data scientists have -- or so I've heard
16:14
Any dataset can be construed as interesting
late to the game
> Do you think people born today will have a better life than their parents?
wat?
Yeah
ok woah
> What individual person do you think will have the most influence in tech in the coming year?
come on.....how did this pass the "QA" phase of "this is ready to send"
:D
@idjaw it is in the "fun" dept
I'm putting Ja Rule
I have high hopes for Ja in the coming year. 2019 is his year
more fyre
16:27
@idjaw is there anything wrong with it? I don't get it :(
@vaultah There is nothing wrong with it no. I think I was looking it way too contextually in to the SO world
in that...what does it have to do with SO
Which...this could be completely my own terrible misinterpretation
any tech
technology as defined in "could be a recipient of the Millennium Technology Prize" for example
@idjaw ah. Did they already ask you about your identity and sexuality? :D
16:29
not sure some Ja Rule would count. But what you think I have no idea about
@vaultah spoiler alert bro. :P
Haha, I'm sorry
2019 life goal - Answer "I don't use social media" for the 2020 survey
8
@idjaw even better: I only use a- and antisocial media"
alright. that's taken care of
16:44
@idjaw I consider SO social media... amiwrong?
yes
the people taking the survey are users of either SO or twitter (or both), so if SO were a social media the question would make no sense
@piRSquared I'm not wrong. You're wrong. (yes you're right though :P)
SO aside. I only use Linkedin and only for an online resume. I have twitter but never use it.
> This information will be kept private.
so why ask?
They said it on the first page
16:51
ah, must have ignored that
This annotation means that this information specifically will be linked to YOU directly in their PRIVATE database
But it will be kept private
Ah, right, I forgot that, thanks.
sneaky "how old are you" question
700
wim
wim
@MarkAmery good call. adding dataframe to each and every pandas question is really dumb advice
note that the excerpt meant to say something like this "use / (optional)"
wim
wim
17:09
no, the optional is referring to the stuff following.
@wim That's my interpretation too
17:25
Hey all, I am trying to do some research on how to best handle this so I can have a plan for deploy. I have a program that is a few files together that I compile to an exe with cx_freeze. I would like to get this program to a point where I can have it hosted on a website and downloadable. But I would like to have the ability to have a "Check for update" bit of code. So it would then reach out to the server and get the new src code. Is it as simple as having another exe that comes with the main
program?
Im not sure how to research this to get some ideas of how to handle the clean up of old src code and to re compile. Any tips would be neat!
@MarkAmery ah, you're both right, I misread the first time I took a look
@Code-Apprentice I went with "sigh"
@piRSquared that's my general feeling, too. In some ways, I'm fortunate that my mom is tech-averse so I'm not asked to do tech support for her.
Now with job, commute, kids, I don't have time to keep up with many aspects of ios/osx and my wife keeps asking me how the printer works even though I didn't even buy it. So my default answer is "/shrug, go to the genius bar" knowing full well that they will muck it up as much as I will but at least I don't get the blame.
I'm confident in my ability to figure it out... if given the time (-:
yah, I don't do printers...
17:36
hplip FTW
17:50
Hello guys
@TheRainbow cbg
What is cbg?
lol
short for cabbage
Ohhhgee
17:51
Welcome to the room :-) To get a feel for what we're like (and to know what cbg means) go here
I'm not a green bean
You catch on quickly, young padawan! =p
I am sure all of you check the dict when one of those words come out :d
other than cbg and rbrb, yes
yam/tomato/green bean/garlic/cabbage/rhubarb/pineapple/melon are in ram and I do not have to go to disk
18:14
cbg
cbd
is anyone here familiar with pytorch and cuda?
Have you read a good basic tutorial yet?
What is esoteric python?
do I have to answer that :)
18:24
@TheRainbow I don't think that's a thing. Depends on context I mean. Someone is talking about something esoteric relating to python.
I'm back folks! How's everyone doing?
Is there a way to write a decorator such that it surrounds each line of the decorated function with a try/except?
that...sounds like an XY problem :)
each line? good god haha. is this going to be an except: pass ? :P
if not, you can just log the error somewhere perhaps on the entire function level.
it's part of my debugging strategy. Typically, if something doesn't work a line causes an error, I do try: line // except: raise and put a breakpoint on the raise. That way, I can get the debugger to show me the stack at the time of the error. This is especially useful when (say) the first ~10k elements of a list don't cause an error but the next one does
So you need that to inspect the variables?
18:32
yes
Which debugger doesn't support that out of the box?
post-mortems should be basic debugger functionality
if you could show me this on my pycharm debugger, you will have blown my mind... and I will be forever grateful
You don't even need to wrap each line in try/except, because you can already do that with just the traceback object
18:36
the traceback object holds the stack?
wim
wim
this guy used to hammer whatever to whatever. then took a lot of criticism and disappeared for a year
@wim eek! that sounds terrible. Any way I can help?
@inspectorG4dget It contains frames, frames contain references to their locals and globals
that's fantastic! How do I access the traceback object? I've literally never done this before :\
exception_instance.__traceback__
18:40
so much thanks
now I go away and hammer away at that pesky thesis
but I'd expect a debugger to give direct access to the variables...
19:13
@inspectorG4dget it seems pycharm can do all that jetbrains.com/help/pycharm/part-1-debugging-python-code.html
@MartijnPieters saw your answer about not using setup.py in your Flask projects. I've actually been on the fence lately. The types of deployments you talk about are probably more common. Maybe the setup.py stuff in the tutorial isn't as relevant or is confusing. What do you think?
I love setup.py
or ... well I don't love it but...
I love entry points, pkg_resources and so on
and I hate implicit import directories
the setup.py doesn't help if you run from there
but given that most of the wsgi deployments should be about "import this module from this venv and get the object, and that's like the app"
@AnttiHaapala since you're here, I have a question for you
Why is the timing for these two statements different:
 %timeit set.intersection(set(), a, a, a, a, a, a, a)
937 ns ± 5.88 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

In [121]: %timeit set.intersection(a, a, set(), a, a, a, a, a)
18.3 ms ± 588 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
a being?
Granted, sets are processed sequentially, but I would've thought python optimises this by searching to see if there are any empty sets to begin with.
Ah sorry, a = set(range(1000000))
19:20
so how's the timeit for set.intersection(a, a)
%timeit set.intersection(a, a)
19.3 ms ± 674 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
So which question are you answering?
ok so there you go
@coldspeed of course it cannot optimize anything because the sets could have side effects so it needs to evaluate the intersection strictly from left to right
I'm not answering anything this time, I just was curious to know why python doesn't check for empty sets up-front
Oh, I see. Gah, side effects.
also:
how many times will you actually run the intersection with empty sets?
why optimize for the degenerate case.
19:22
perhaps there is some performance critical code that intersects sets in a loop (eg frequent itemset algorithms)
but I understand the rationale
even though it baffles me why allowances are made for bad practices such as side effects :D
how kewl would python be with all the undefined, unspecified behaviour of C
it would be slow
and for no reason :D
"sets could have side effects": what does that mean?
Custom iter stuff?
perhaps the first two arguments could instead be some sort of function call or expression that updates another set further down the line.
perhaps that's what he meant. That's how I understood it at least
since sets are mutable
@AndrasDeak Yep. The .intersection method & its siblings accept any iterables as their args. The operator versions only work on sets, or set-like objects.
set.intersection seems to be picky
first arg should be a set-like
19:36
@coldspeed Those timings imply that intersection is optimised to short-circuit if it gets an empty set intermediate result. It just can't do that pre-emptively.
wim
wim
@davidism The answer doesn't say he doesn't use setup.py. It says he doesn't build & publish packages. Using pipenv is not mutually exclusive with setup.py.
@AnttiHaapala sounds like you love setuptools because it monkeypatches distutils/setup.py for those features.
Yes, I noticed that too.
it = map(set, iterables); next(it).intersection(*it)
@AndrasDeak I guess that means that although it looks like a classmethod it's probably merely a wrapper around the instance method. But it"s weird that the wrapper doesn't convert the 1st arg to a set, if required. Subsequent args don't need to be converted, they're just iterated over directly.
wim
wim
@AndrasDeak that's because it's self!
@wim that was my guess
wim
wim
19:43
for the same reason, set.intersection() is an error and not the empty set.
other ways to make side effects include custom __eq__ or custom __hash__
you can do this
%timeit set.intersection(*sorted((a, a, set(), a, a, a, a, a), key=len))
"but what if I have million sets!"
/shrug idk yet
@piRSquared actually faster...
wim
wim
don't optimize edge cases unless you can prove they're a problem
19:45
t = (a, a, set(), a, a, a, a, a)
set.intersection(min(t, key=len), *t)
wim
wim
in fact don't optimize anything unless you have evidence that part of the code needs it.
I've explicitly said above that...
this is rather pointless
because most of the time the intersection will be used with non-empty sets.
because, duh.
@coldspeed given the following:
wim
wim
b.t.w. antii have you seen entrypoints.readthedocs.io ?
I'm going to write a canonical Q&A with the answer being "Because, Duh!"
5
wim
wim
it's the good bits of setuptools without all the fat of pkg_resources
19:48
a = set(range(10000))
b = set(range(10000, 30000))
and
x = (b, a, a, a, a, a, a)
wim
wim
this + flit + importlib.resources has replaced almost any need for setuptools for me.
the problem is backwards compatibility ofc
I'd like that yes :D
wim
wim
pkg_resources is really bad btw. tries to do way too much at import time, and significantly slows down any python program that imports it.
@AnttiHaapala Oh, this is neat, if you know you have to worry about that edge case.
19:51
@AnttiHaapala @coldspeed even more bullet proofing set.intersection(min(t, key=len, default=set()), *t)
@wim "wät"
:puke:
🤮
This decorator is genious.
20:13
@piRSquared Using the default arg... nice!
wim
wim
20:25
@piRSquared That will make the best dupe target !
(-: I was just mulling over how I could make that a reality while actually being useful. I can't get around the overwhelming snark though.
need to wait until hat season
Now we're talking
wim
wim
@IMCoins I particularly like the globals().update(locals())
because namespaces are one honking great idea, or something? 😒
Let's do more of those
20:31
Because namespaces are honking in my way... let's pollute more of those!
I like the Raymond Hettinger reference
wim
wim
Anything to do about this answer which is directly contrary to the advice in the docs, but still highly upvoted?
normally I would edit it, but in that case it would just make it duplicating the info in another existing answer.
Is it harmful? There are two massively upvoted answers before it, one accepted
wim
wim
I mean, well, it's the first one talking about import. So if a user got there looking for dynamic import that's the one they're going to.
Arguably, it's not actually answering the question, and the two before it are. But still evidently "helped" hundreds of users
Probably importlib didn't exist in 2008. We really need a better way than downvotes to get rid of outdated info that perhaps used to be helpful but is now just stale or even harmful. There are not enough knowledgeable DVers around to counteract those votes, and flags aren't the right way either
20:47
I'd argue downvotes aren't the right way either but we've discussed this before and there's not much left to say
wim
wim
Maybe this could be a new superpower like the Mjölnir! Ability to mark an answer as deprecated
I'm pretty sure there are feature-requests for that. That would be the right solution.
it's normal for tech content to become obsolete, there should be a straightforward way to handle that without harming anyone in the process
wim
wim
Anytime I had a free form text box in the developer survey, I wrote for them to fix bugs and implement useful features that people actually want 😄
 
2 hours later…
22:25
I like the idea of the deprecated flag. It might even become standard at some point

« first day (3021 days earlier)      last day (2151 days later) »