« first day (2476 days earlier)      last day (2458 days later) » 

1:58 AM
cabbage
 
cbg
 
Does anyone know the format specifier for the following date
FullMonthName Day, Year
 
%B%D%Y
 
did you check the formatting already? docs.python.org/3/library/…
are you looking for day as a name, number?
Are you looking for the four digit year? two digit?
 
number 4 digit
my bad I was looking for the docs
didn't know exactly what to google
It's funny cuz like I'm pretty good at python but idk the format specifiers for my life
 
2:04 AM
no problem strftime() and strptime() Behavior isn't really the best title imho
 
I gotta look them up every time lo
 
that shows the converstion table
 
I look them up all the time too
%B is so obvious though
 
yea, because it's the first letter in Month
 
2:05 AM
lmao
Anyway thanks @idjaw
 
no problem @MalikBrahimi
hey Cory! Welcome
 
hi
nice hammer :)
 
😃 thanks. I just got it today. It still has that new smell.
 
@idjaw So a capital in %D removes the zero padding from %d?
 
@MalikBrahimi You mean if you wanted 1,2,3 instead of 01, 02, 03?
 
2:11 AM
Yeah exactly
I'm actually trying to format my dates and times for a DRF endpoint
servdate = DateField('%B %D')

servtime = TimeField('%I:%M %p')
For some reason these are invalid formats, any ideas?
 
hmm I thought I had an example of this lying around and then I looked it up and I'm finding some really funny answers
here and here
lol @ second one with -19 and an accept
 
@MalikBrahimi this is what the DRF docs say for DateField:
DateField(format=api_settings.DATE_FORMAT, input_formats=None)
input_formats - A list of strings representing the input formats which may be used to parse the date. If not specified, the DATE_INPUT_FORMATS setting will be used, which defaults to ['iso-8601'].
 
2:31 AM
@CoryMadden Thank you!
@CoryMadden Wait
it's not working
 
oooh this is a Django thing?
 
Yeah I don't know django things.
 
:D
 
2:35 AM
@CoryMadden It's no longer throwing an error, but it's not returning the data in the correct format
 
haha, I had no idea this thing made noise. I left to go get food and got back and my dog was freaking out
 
lolol
 
@MalikBrahimi what does the data look like? I've admittedly used the DRF very little
did you override the format field, too? I believe that's the one that describes how it's displayed
 
Now I'm explicitly giving the format
servdate = DateField(format = '%B %D')

servtime = TimeField(format = '%I:%M %p')
1
Q: how to format time in django-rest-framework's serializer?

natailathere is my serializer code: serializer.py class StartListSerializer(serializers.Serializer): id = serializer.CharField() time = serializers.DateField(fromat=None, input_formats=None) it will give me this: 'time': '2014-03-14T22:44:16.923000' the input time format is datetime.datetime...

I'm literally following this
 
So I don't know where I got capital D from
(replace it with %d is what I'm saying
I always have to look the codes up, too. but I always think I know them
 
2:47 AM
Lemme try that
It works!
Thanks man
 
sweet. you're welcome
 
Why -inf and nan are floats? I really want to try what happens if I put them in range()... :(
 
3:06 AM
That's probably why they're floats :) I wonder if that might the the reason some guy was having trouble with an apply function he was trying to use earlier converting some strings to floats but it gave an error about floats
 
@EnderLook range only allows integer arguments
 
I got an issue with closing an excel process with win32com, i have an open question on forums, anyone can help me troubleshoot this? or should i wait for reply's on my on going question?
 
Sorry, I am not qualified to answer.
 
3:33 AM
recbg
 
 
1 hour later…
5:01 AM
@PM2Ring yeah but that still hand-makes a list of the 'foods' right? I was trying to find code that would work, if, say, 3 more friends decided to come and bring Cajun dishes, without altering something exciting te original dicta with the data.
 
is there a good way to check time taken by each command in a python script. I have a large script and need to see which command if taking longer time
 
5:22 AM
recbg
 
 
1 hour later…
6:30 AM
cbg
 
 
1 hour later…
7:57 AM
@pythonRcpp Take a look at the profile and timeit modules.
@toonarmycaptain In that case, you probably want DSM's solution that uses Counter.
 
 
1 hour later…
9:02 AM
is there any faster way to convert a datetime string column to datetime (only time) . Format of string is like  `01-FEB-2017 11:12:47` I'm currently using df['ExecutionDateTime']=df.ExecutionDateTime.apply(lambda x: pd.to_datetime(x,infer_datetime_format=True).time())
 
9:29 AM
Cabbage!
 
9:53 AM
TIL
110
Q: Dictionaries are ordered in Python 3.6+

Chris_RandsDictionaries are ordered in Python 3.6 (under the CPython implementation at least) unlike in previous incarnations. This seems like a substantial change, but it's only a short paragraph in the documentation. It is described as a CPython implementation detail rather than a language feature, but al...

 
@AshishNitinPatil It's a nice feature. OTOH, it's slightly annoying because of all the posts we've made telling people that dicts are unordered. :)
 
Yep, I just answered such a question with my half-knowledge on the topic running Py3.5.2 stackoverflow.com/a/45347138/2689986
 
But there's something very weird going on:
@PM2Ring I get the same on 3.6.1. Oddly enough, if I print(dict([...])) in a loop, I get the correct output. I'm under the impression I'm missing something but I can't see what. Maybe IPython is doing something weird because in the normal Python REPL, it's good. — Jim Fasarakis Hilliard 5 mins ago
@AshishNitinPatil Yeah, I saw it when you posted it, and I can still see it because I have >10k rep.
 
That's why I linked it to you :-p
Struggling with time these days, else I would be all onboard getting to that 10k mark.
 
Anyone with ipython & 3.6 who can reproduce this? Maybe check other non-standard environments like PyCharm, too.
 
10:33 AM
@PM2Ring The annoying part about it is that we need to keep telling people that dicts are unordered and they just look like they preserve order…
 
10:48 AM
earned at least 200 reputation on 83 days
wooho 39 upvotes to gold badge in
 
@poke Indeed. Maybe your answer could mention that 3.6 does guarantee to preserve the order of keyword args, so you can safely do OrderedDict(sape=4139, guido=4127, jack=4098)
 
So i've done something stupid and i'm wondering if there's a clever way to fix it...

I've got a whole bunch of data from some instruments that follows a pattern I defined (Label, 64*64bit floats, 64*32bit floats etc...) but I have saved the whole lot as text file... Now a positive number doesn't have the same number of bytes as a negative number...

All the numbers are are less than 10, so I could probably split the list and check if the 2nd character before the decimal place is a minus sign...
 
Not sure how that relates to converting an existing dict though @PM2Ring
 
@jm22b use a regular expression, really
can you give a sample?
 
Sure, this is one data packet

https://pastebin.com/pxmRM5Mr
 
10:54 AM
yeah, use a regex.
a sec
 
@poke Well, it doesn't. :) As you well know, to create an OrderedDict from an existing dict you need to iterate over a list or tuple of keys if you want it to have a specified order. I just figured it would be good to have that info on that page because I get the feeling that it's going to come up in a lot of searches.
 
but not all numebrs are <10, are they?
I see 16?
or is that a label?
 
sorry, the structure is as follows;

9 byte label

64 * 32bit float
64*64 bit float
1 * 32 bit float
1 * 64 bit float

repeated 3 times (without repeating the label)
The problem lies in the sections of 64 single precision floats
the others are time stamps
 
@PM2Ring Not sure, the question already seems very Python 3.6 specific, so creating an ordered dict from a dict will already “work”. And it’s more about dict than OrderedDict. – My answer already feels kind of off-topic since I completely ignore the IPython issue there.
 
10:59 AM
creating an ordered dict with OrderedDict(a=5, b=6, c=7) isn't an implementation detail, it is the official language behaviour now on 3.6
as opposed to dict() retaining ordering.
 
@AnttiHaapala Thanks, that's certainly in the right direction. I will work on it :)
 
at least next time use a space :D
 
Yep, lesson learned!
 
@AnttiHaapala Yeah, I just said that. ;)
@jm22b It's annoying that the label is 9 bytes. If you need that structure to be a proper C struct it should have some padding bytes after the label to ensure that the following floats are properly aligned on 4 byte boundaries. Even better: make it aligned on 8 byte boundaries so the 64 bit floats are nicely aligned too.
 
@PM2Ring Happy now? :P
 
11:10 AM
@PM2Ring I am conforming to an expected TCP template... I have no power to change it.
 
@jm22b Ok. In that case, if it's doing stuff at the C / assembler level it probably already has padding bytes.
@poke Yes. :)
 
11:24 AM
cbg
 
BTW, that dict / OrderedDict question is now in the HNQ.
 
was it that bad?
 
@AndrasDeak The dict / OrderedDict question? It's good. The OP uncovered weird (but well-known) ipython behaviour.
But speaking of bad, check out this one I saw earlier today in Physics: physics.stackexchange.com/questions/348762/… How the yam do you create a vacuum with 35-50 psi of pressure? "I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."
 
the No True Vacuum fallacy
 
@PM2Ring ugh
 
11:38 AM
@poke Why complain? You could score a few more points from it. It's now up to 113 views, 20 of those happened in the last 5 minutes or so.
 
Because it’s always the odd ones that reach HN
 
Sure. Posts discussing unexpected quirks are almost guaranteed HNQ fodder.
 
How does one follow the HNQ?
Link please.
 
yup ^
was just about to link
 
First google search result :|
 
11:42 AM
yup :P
most of the enjoyable HNQ posts are on DnD, most of them are just bad
worldbuilding is 50-50 chance of utter nonsense and something intriguing
 
@poke If anyone should be going "ugh" it's Ashish Nitin Patil - all the 10k+ people visiting the question will see his deleted post. :)
 
lol
 
@AshishNitinPatil You can edit it, if you like...
 
Something to learn from. I thought today I should go all FGITW.
 
11:46 AM
"talking about Bing" <-- we weren't, perhaps you were, and you're not making a good case for yourself ;)
oh I thought you wrote "search" but you actually wrote "google"
so I'm honestly not sure about the whole bing thing
 
No no, I did google and not bing it (using Chrome 59).
I was just mentioning the market size Bing has captured, which was quite surprising to me.
Healthy competition :)
 
ah
microsoft is all about healthy competition
 
@AndrasDeak hehe, *insert snide piracy comment*
 
@PM2Ring umm :D
that's even worse than anything I've seen in this week.
 
@AshishNitinPatil What, that Microsoft don't mind people pirating Windows in Asia & Eastern Europe because it means they aren't using Linux?
 
11:56 AM
yep
 
wow on 33 to C gold hammer
 
Wut, are you doing so much C?
 
he wants to Close All The Things™
 
I should really get my gold badge game going too
 
yeah, make use of that userscript!
I pimped it for our new goldy
 
12:04 PM
The userscript is really gold.
 
I've got >10krep in alone now
 
That’s a lot
Is there a database query for rep by tag?
@BhargavRao Help.
 
12:26 PM
The Tags column in the Posts table is a 250 byte char array, which makes it not so easy to use tags in one's query
 
I found this and this if that helps
the latter is a list of tag score, the former is an approximative list for a given tag, but has a tag hard-wired into it
 
@poke here
 
Hmm, what flavor of sql does the data explorer use? I want to get the length of each tag name but Oracle's LENGTH() isn't recognized as a valid function name
 
Was a bit AFK
 
It's probably LEN, then
 
12:38 PM
@DeathJack2.0 Use json=payload and try to give me the output when myurl='http://httpbin.org/post'
 
@AshishNitinPatil Alright.
 
Oh, there's a PostTags table. That makes things easier.
 
JSON RESPONSE : b'{\n "args": {}, \n "data": "{\\"priority\\": 1, \\"hello_id\\": 207, \\"bye_id\\": 207, \\"s1\\": 1, \\"s2\\": 2, \\"sub\\": \\"CHECK 123\\", \\"t1\\": \\"Leave\\", \\"product_id\\ ............ "
 
Can you do print(r.json()) instead?
 
Can someone find a solution for this? stackoverflow.com/questions/45350227/… Been stuck in this for a while.
 
12:43 PM
And preferably use pastebin.
 
Kinda same reponse.
 
Yes, but it will be better to look at, that's why I asked. Can you put that in a pastebin and mention the link here?
 
@BhargavRao I tried logging on to data.SE, used my Google login (like I always do) and got a new account; tried my SE login and got a new account. Now I have three accounts and have no idea how to login to my original :(
@Kevin T-SQL
 
@poke welp, the same happened to me when I did (perhaps a year back), even I'm not sure how to fix that. (I started to use it anonymously after that).
But, I stopped at 2, didn't go for the 3rd account :p
 
12:50 PM
@DeathJack2.0 It's a valid json. Check on jsonlint.com.
What is the error that you get?
 
meh, I’ll contact support then, maybe they can do something about it :/
 
If I try to post to my url I get 'Validation failed' for every field in the request.
 
@DeathJack2.0 Can you provide an MCVE, or is this one of those "I don't want to reveal the URL I'm posting to" situations?
 
@poke Searched for a solution on MSE, couldn't find one. Perhaps /contact page is the best.
 
I really need another screen to have SO chat on it. Ubuntu workspaces are good, but not enough :/
 
12:54 PM
Hey man it is working now. My bad.
Thanks a lot. Been stuck for a long time on this
 
@Bhargav Just sent the mail, I will keep you updated if I hear anything back.
 
Accepting your answer.
Thanks mate
 
Congrats.
 
Ah the old "it started working as mysteriously as it started not working"
 
The long time classic
This is the case in most practical scenarios.
 
12:56 PM
@poke Thanks, I might need to do that as well. :)
 
People usually call me up, say X is not working. I go do the same thing they did and ask did you do EXACTLY this, they answer YES, confounded.
 
Logical explanation: the owner of the server noticed it was returning a lot of "bad input data" responses, realized there was a bug on their end, and fixed it quietly.
 
Haha
I think we should use "Banana" as pseudonym for Good as well a casual laugh / "HAHA".
 
(spoiler: another bad pun) Add 2 ticks to Banana, and it becomes Bahaha
 
1:00 PM
You can use laurel though
 
Ah, missed laurel, thanks poke
 
@PM2Ring What's wrong with the string concatenation inside the print function?
@DSM @PM2Ring here's what I ended up doing:
food_dict = []
for names in allGuests.keys():
    for food in allGuests[names].keys():
        if food not in food_dict:
            food_dict.append(food)

print('Number of things being brought:')
for food in food_dict:
    print(' - ' + food + ' ' + str(totalBrought(allGuests, food)))
 
is this IRC
 
Nope
 
@TheExorcist No this is Patrick
 
1:11 PM
Personally I avoid concatenation when forming output strings, because I find that all the quote marks and spaces and plus signs make it harder to mentally decode what the final output will look like. str.format is easier to decode for me.
 
(sorry, couldn’t resist)
 
@poke so your function is to poke .Lul
 
When I look at " - {} {}".format(food, totalBrought(allGuests, food)) I can tell how many spaces there will be and where they are, after looking at only 25% of the line. To get the same information from print(' - ' + food + ' ' + str(totalBrought(allGuests, food))) I have to look at 50% of the line
And I can't just count the whitespace in the line itself, I have to ignore the spaces in ... + food + ... and ... + str(
 
Also, not sure if Python optimizes this (doing too much language switching lately), str1 + str2 + str3 + str4 creates 2 intermediary strings
 
Fair enough. I haven't tackled string formatting yet. I just didn't know if there was a particular issue with doing that, since many of the basic tutorials teach it.
I started out doing print(' - '+food+' '+str(totalBrought(allGuests, food))), which is easier for me to parse, but read that apparently you're supposed to leave whitespace around operators?
 
1:17 PM
\o cbg
 
cbg
 
cabbage
 
Marcus, one of my friend gave me a math puzzle and I instantly thought of you.... I was able to solve it since i used a similar trick from one of the PE puzzle. wanted to thank you
 
which trick? (or rather which puzzle did he give you)
 
something along of finding the number of digits before verifying the number ( I dont remember the puzzle from PE). the question was : find the smallest value of x and y where x and y are positive integers (non zero), where x's last digit is the first digit of y and y is exactly double x.
 
1:21 PM
@toonarmycaptain Yes, you should generally have a space either side of an operator. It's more efficient to use format, or for simple stuff, just pass the objects directly to print, eg print('-', food, (totalBrought(allGuests, food)). print & format are written in C so they can concatenate strings faster & more efficiently than explicit Python code can.
 
I'm pretty sure this was an easier puzzle and was asked many times before in some math contest, but still first time I saw it .
 
On the topic of operator whitespace, PEP 8 specifically only cares about comparison operators and a few others: "Always surround these binary operators with a single space on either side: assignment ( = ), augmented assignment ( += , -= etc.), comparisons ( == , < , > , != , <> , <= , >= , in , not in , is , is not ), Booleans ( and , or , not ). "
Arithmetical operators are allowed to have zero or one spaces, according to your own judgment about what works best: "If operators with different priorities are used, consider adding whitespace around the operators with the lowest priority(ies). Use your own judgment; however, never use more than one space, and always have the same amount of whitespace on both sides of a binary operator. "
 
PEP8 is so weird.
 
@MooingRawr If you like that sort of thing, find the only 2 digit number where if you divide it by 3, reverse the digits of the result, and then add 1, you get the number you started with.
 
“consider adding whitespace” combined with “allowed to have zero or one spaces” means that the “default” is no whitespace?!
 
1:23 PM
I usually put spaces around all my operators except when doing complex arithmetic, in which case I use zero spaces to indicate tight precedence
 
@Kevin Yeah, I often do stuff like x = a*b + c*d + e**3
 
So, kind of the opposite of the suggested approach, as poke observes
 
I imagine not having whitespace around booleans would cause "issues"
So I can make my string concatenation look clearer and shorter? Done.

@PM2Ring that formatting choice makes a lot of sense to me
 
@PM2Ring I love random math tricks and patterns, but usually I forget them after reading them, which means I have a vague idea on how stuff works (usually missing the important details), so when I come across the random "fact" again I am pleasantly surprised :D
 
OTOH, if it's just a single operation I normally add the extra space: x = a * b
 
1:25 PM
(it's kinda what I do naturally when writing math out by hand anyway)
 
@PM2Ring I will try your puzzle out during lunch today. My initial thought is the last digit of the double digit number will always correspond with the last digit of the result of division meaning u have to find the sweet spot
 
@toonarmycaptain The interpreter can parse boolean operators without spacess as long as there's no ambiguity as to whether it's an identifier/literal; (True)and(True) works, but TrueandTrue doesn't.
 
print(f' - {food} {totalBrought(allGuests, food)}')
 
@toonarmycaptain Spacing should assist the reader in parsing the expression, but it can be misleading if you don't take precedence into consideration, eg a * b+c * d isn't a * (b+c) * d, its (a*b) + (c*d). It's only a minor annoyance with common operators, since people will generally remember the relative precedence, but with expressions that mix normal arithmetic and bitwise operators it can be tricky, and it may be a good idea to use redundant parentheses to make the precedence unambiguous.
FWIW, that OrderedDict question is now up to 220 views.
 
@PM2Ring Yup. I just meant I generally put a dot (or x sometimes) and little space when multiplying, even less space before an indice/ordinal, but more space around +/- signs, when handwriting.
 
1:32 PM
I wonder how many of those is just you pressing F5 to see the view count xD
 
@MooingRawr Not really sure I can take much ownership of any "trick" involved but glad to hear it helped
 
My "how to compare version strings" answer finally surpassed the lazy answer after 3.5 years.
 
@poke Maybe 5 of them. :)
 
:)
 
@Marcus oh Idk if you wanted to take ownership of anything. I'm just saying I thought of PE which made me think of you, and some of the tricks u sometimes bring into this room :D
 
1:37 PM
But are you sure it does that? I just tried refreshing a less busy page, and it didn't increase the view count. I guess it may not always modify the displayed view count even though it's tracking page fetches.
 
It’s probably some smarter view counter, so it won’t keep counting the same user
 
@toonarmycaptain It's a bit confusing having a list that claims to be a dict: food_dict = []. Are the items in that list dicts? I though they were just plain strings that are being used as dict keys.
@MooingRawr Correct. :)
 
@PM2Ring that's fair.
@PM2Ring Duly altered
@PM2Ring It's now food_encyclopedia
 
CABBAGE!!!!!!!!!!!!
I hope that startled you all and woke you up
 
1:41 PM
\o cbg bud, how goes it? (nope you aren't waving your lego hammer like a maniac)
 
yoyo
 
@davidism This is a cool visualization. The biggest obstacle I have when creating fancy visualizations of the hilbert curve is: it's hard to embed higher generations of the curve inside lower generations, because their dimensions aren't nice multiples of one another. If a generation 3 curve is 7 units wide, then a generation 4 curve is 15 units wide.
The practical consequence of this is that when you stitch different generations together, you have to use a diagonal line. This puts an additional constraint about which methods are viable to render the curve. Like, you can no longer use a simple L-system, which would have been possible if you stayed in one generation.
That visualization uses diagonals. You can see one fairly easily at the highest point where the circle crosses the lime-magenta border
 
@idjaw ahhhhh
 
Hello everyone, I just have a quick question about Python.
https://stackoverflow.com/a/40798144/2291710
Is the call to `super()` inside the class usefull or is it a mistake? I have never seen `super()` in such a context, I have only seen it used inside methods.
 
It doesn't do anything.
 
1:44 PM
that is quite odd
why would that be at the class level like that
 
Not even sure what that does
 
Yeah I'm pretty sure super by itself has no side effects
 
Speaking of fractals, I saw a nice JavaScript rendering of Hofstadter's Butterfly today via a link on SE.Physics: huttar.net/lars-kathy/misc/hofstadter-butterfly/…
 
I'd be quite interested to be proven wrong on that though
 
Thanks for the answers!
 
1:46 PM
hehe....our confusion matched yours. therefore you are not insane.
proceed
 
That warm camaraderie when all of your peers also say "wtf?" at some code you were puzzling over
4
 
it's reassuring
we are all at the same level of insanity
 
A package for building Linux, Mac, Windows wheels on Travis and Appveyor: cibuildwheel
 
oh. this looks really interesting.
 
2:11 PM
Hey. So, I want to improve this
this was just duped (rightfully so). I answered it with a pathlib answer, but the dupe target does not have pathlib as an answer.
Does that answer seem canon/good enough to add the pathlib as a candidate to then use in the future?
I want to put the effort in to the question that is worth it to improve
 
Move the answer to the dupe?
 
yeah. I'm actually drafting an answer now
In progress.
 
There's also a "possible dupe" link on that dupe, so maybe it needs to be hammered again?
Actually, I think that question isn't a dupe.
It's more asking how to manipulate one name into another, not just do an arbitrary rename.
 
OK, that works too.
 
2:23 PM
cool :)
thanks for taking a look
 
Closed the "possible duplicate" in the comments as a dupe of that one, since it has less noise in the answers.
 
right
 
Stupid “A question with that title already exists” when fixing old questions…
>_<
 
haha
"sorry for trying to make you better with my edits"
"you deserve to be wrong"
 
DSM
2:34 PM
Thursday cabbage for all.
 
o/
 
cbg
 
DSM
@toonarmycaptain: your food_dict is a list, so it's not very well named. :-) Also, if food not in food_dict: is a bad idea. Membership testing in lists is slow, because it needs to scan over the whole list (in the worst case, anyhow.)
 
lol I just switched back to this screen and the first thing I saw was "Also, if food not in food_dict:is a bad idea" and was going "whaaaaaaaat"
 
2:38 PM
Did anyone suggest using a set yet? I suggest using a set.
 
DSM
@Kevin: welcome to yesterday. ;-)
 
Whenever you write code like if x not in y: y.append(x), that's a huge red flag that you should use a set
 
what if there are duplicates....p-p-precious?
oh wait...it's a list o' dicts
 
@Kevin The version yesterday used a list so that the output was in alphabetical order.
 
Order is for chumps, embrace chaos
 
2:40 PM
^^
it's the one truth
 
Why would you use a set for food? There can never be enough food. Let’s keep all duplicates so we can keep eating stuff.
4
 
And I was just watching the SV episode about Not Hot Dog. What a happy coincidence.
 
DSM
(Should I admit that I just used random.shuffle to find 'hraacceo mebs!'? Probably not, that's awfully nerdy.)
 
emcbrae coahs
 
DSM
"brae" always makes me think of Skara Brae, beloved of Scots and Ultima fans.
 
DSM
historian badge awarded to PM 2Ring
 
Nothing wrong with repeating what's already been said :-) If you think otherwise, educating an endless stream of new users about the same ten problems is an odd hobby to have
 
Ok so I updated what I had to use a set. It's a nice functionality to have something like that not throw an error when you try to add a duplicate value to it.
Why doesn't SO use sets for questions to avoid dupes? :p
 
Questions can be edited and sets don't behave nicely when they contain mutable objects :-P
 
3:13 PM
its just not moving forward! im not getting any kind of error! — Alok Bhakat 2 mins ago
I'm looking at your screenshot and I can see the error. Three times in fact. See all that red text? — Kevin 1 min ago
People see what they want to see.
Incidentally on that question, it's a typo
 
@Kevin Closed
 
Enough dictionaries for me for today, on to algorithmic thinking
 
But I think this OP is worse: he refuses to answer questions, and insists that his question is clear. stackoverflow.com/questions/45354259/…
 
@davidism Oh really? Then why do I lose my data when I do migration? Try it yourself before downvoting me. — Nurzhan 4 mins ago
"Try it yourself" about a table migration to the author of Flask-Alembic. Gold.
 
DSM
@PM2Ring: did that user account just vanish? I guess it could have been migrated but I'm pretty sure I saw a name the first time. :-/
Yeah, it used to be this guy. Huh.
 
3:22 PM
@DSM They have the name Ehsan here. But I haven't refreshed the page for a few minutes.
 
Poll: when is it appropriate to use sys.exit rather than throwing an exception?
 
@DSM Page not found. I wonder if they self-deleted, or a mod got them for some reason.
 
@Kevin you can change exit code with sys.exit
 
hi
 
3:34 PM
cabbage
 
What's the exit code when you raise an uncaught exception? 1? If so, is there ever a time when you would want to do exit(1) instead of raising an exception?
 
Welcome @John
Take a look at our room rules here
 
@Kevin if the goal is to terminate your app immediately, I would use sys.exit. I know that it throws an exception but its just an implementation detail
 
@marxin And you can do raise SystemExit(1) to pass an error code back to the shell.
OTOH, I'm much more likely to call sys.exit than to raise SystemExit
 
I was just going to say-- sys.exit is raising an exception ;)
 
3:47 PM
I ask because I'm trying to decide whether I should chide the answerer of stackoverflow.com/questions/45354330/… because he suggested exit over something like raise IOError("Path not found")
 
@KevinMGranger yeah we know, but then the question is if it makes any difference? for me, sys.exit has better semantic
 
And both of those options are superior to calling plain exit() in a script; plain exit() should only be used in an interactive session.
 
even if it does the same thing
 
If the error encountered is indeed supposed to be a program-ending event, then sys.exit() is probably good
@marxin of course there's no difference, I just like being pedantic ___----*
 
yup
 
I finally got to playing around with python bytecode last night. It's interesting, to say the least. I didn't know the VM was stack based-- it almost felt forth-y.
 
What I'm hearing is "if you want to be able to recover from an error, use exceptions. If you want the program to end without recourse, use exit". But I feel that there are very few use cases for ending the program without recourse.
 
@Kevin consider the implementation of something like cat in python. failing to open a file is indeed an error, but it's also a definite end-of-the-program condition.
 
Ending without recourse is appropriate for cli tools. Fix the error and try again.
Here's an answer that is both suboptimal as well as wrong, but it received plenty of up-votes (apparently by people who couldn't tell it was suboptimal as well as wrong). Please down-vote to zero so future visitors aren't misinformed as well: stackoverflow.com/a/45341561/208880
 
3:55 PM
@KevinMGranger I know what you mean. If you consider how dumb this technically is, it’s kind of suprising how well the language actually works.
 
Ok, so what I'm hearing is "use exit in a script that you don't expect will ever be used as a component of a larger script"
If you end up turning your script into a module, you would prefer your users to be able to catch IOErrors and handle them at their own discretion
 
I think we should differentiate between a script that is a library, and a script that is a command line tool
 
If your users exclusively use your script on the command line, they can't catch anything, so there's no benefit to raising a catchable error
 
A command line tool will only be consumed by executing its process, so it makes sense to exit there. A library is used on a language level, so it should not take control over the hosting application.
 
I think we're on the same page here, then
 
3:58 PM
If you have a script that does both, then exiting should only happen within the if-name-main block
 
My stance is: it requires a lot of foresight to know that your code will never be modularized, so if you're erring on the side of caution, you'll probably throw exceptions much more often than you exit()
 
Just like you wouldn’t just randomly print stuff in a properly designed library, you wouldn’t have anything that controls the application flow.
 

« first day (2476 days earlier)      last day (2458 days later) »