« first day (2922 days earlier)      last day (2025 days later) » 

12:00 AM
RIP Paul Allen
wat?
my message disappeared:
"okayish, a bit tired, 3AM here"
 
12:59 AM
cbg
 
1:14 AM
anybody using a Mac that can help me out briefly? I need the output of python -c "import platform; print(platform.system())"
I think it's "Darwin" but I want to make sure
 
You are correct
 
Thanks!
 
 
1 hour later…
2:36 AM
stackoverflow.com/q/5188792/1222951 unclear (all of those characters? at least one of those characters? only those characters and no others?). Answers are all over the place, as you'd expect.
 
 
5 hours later…
7:45 AM
@PM2Ring I don't know if it's me not being suitably caffeinated but that seems like odd control flow in that grouping answer :)
 
@JonClements This one? Could be me: I'm starting to get vague from sleep deprivation. :)
 
No one's introduced: [list(g) for k, g in itertools.groupby(data.splitlines(), bool) if k] yet... :)
 
@JonClements Don't say it too loud, Vash might hear you. :D
 
heh :)
 
The control flow looks ok to me. I don't have any superfluous negations, and I do the normal action in the if part, the level-break in the else part. What more could you ask for? :)
 
7:56 AM
scooby snacks? :)
 
FWIW, the only reason I posted an answer there was that I got annoyed by the 2 regex answers.
 
Also - you're not using recursion... why not!? :p
 
@JonClements Sorry. I don't think they'd make it through 12 time zones & across the equator. ;)
@JonClements I just wrote a recursive generator a little while ago: stackoverflow.com/questions/52827072/…
 
So Kevin hasn't gotten around to inventing working teleporter technology yet... boy - he's slacking recently... the low orbit tea cannon hasn't materialised and we're way behind schedule on terraforming and colonising Mars... sighs
 
I must admit it is a nice feeling when your code is not only more readable than the other guy's 5 line list comp, it's also a dozen or more times faster. :)
 
8:02 AM
cbg
 
Not that I'm immune to writing multi-line list comps myself, mind you.
 
I am using this command
import comtypes.client as cc
cc.GetModule("TaskbarLib.tlb")
But I receive the following error:

Traceback (most recent call last):
File "C:/Users/Nouman/AppData/Local/Programs/Python/Python36/tkinter taskbar progress test.py", line 4, in <module>
cc.GetModule("TaskbarLib.tlb")
File "C:\Users\Nouman\AppData\Local\Programs\Python\Python36\lib\site-packages\comtypes\client\_generate.py", line 95, in GetModule
tlib = comtypes.typeinfo.LoadTypeLibEx(tlib)
File "C:\Users\Nouman\AppData\Local\Programs\Python\Python36\lib\site-packages\comtypes\typeinfo.py", line 485, in LoadTypeLibEx
Any idea how to solve?
 
@BlackThunder Sorry, I don't know much about Windows.
 
Can you give it a tlb or are you supposed to give it a dll? Same as PM2 here - haven't used Windows in umm... quite a while now...
 
8:52 AM
There was some excitement on SE.Physics yesterday. A 1 rep newbie had his basic homework question put on hold (calculate the time for an object thrown straight up to hit the ground, assuming no air resistance). The rules there are very strict re homework: you can't ask for a homework-like exercise to be solved, or even your solution to be checked. You can only ask conceptual questions.
Anyway, an hour or so later he reposted basically the same thing, but with a little less information. I posted a hint in a comment on the closed post, and on the new one I told him he should fix his old question, not ask a dupe. A few others also tried to explain SE.Physics policy on the new one.
He went ballistic: started swearing at everyone, telling us we're idiots, and made a comment to a diamond mod about hitting him in the head with an axe. Needless to say, both the posts are now deleted. And I guess the user is too, but I didn't bother checking, and I can no longer remember his name.
 
Haha... nice... happens many times a day here but must actually be quite "fun" when you don't see it that often :)
 
I'm sorry to hear that. I've never seen anything quite that nasty, with the violent overtones, on the Python tag.
But I'm proud to say that as soon as the OP went nasty everyone refrained from taking the bait, which took the wind out of his sails, if I can change metaphors in mid-stream like that.
 
@PM2Ring that's like every second day in
I am starting to wonder that have all the questions already been asked
 
Hello
 
like yesterday there was a really obscure question about why a switch statement in a book is coded in assembly using a jump if above instruction instead of jump if greater even when the switch argument is signed... and it turns out that too was a duplicate.
 
9:04 AM
@AnttiHaapala There's probably more C questions on SO than the character count of the K & R C book. And the ISO C standard docs. :)
 
@PM2Ring oh - you should see some of the comments we have to clear up... and some of the mod message replies we get when we message a user about it and asking them to take a deep breathe and be nice... some of the venting there is actually quite creative about ways you should go die or something like that :p
 
@AnttiHaapala I've never done any assembler coding on Intel chips. The last assembler stuff I did was on the Amiga's Motorola MC68k family. And a little bit of messing around with the Amiga's custom chips, of course. Messing with the graphics coprocessor was fun, doing stuff like changing the colour palette, and even the resolution, on a line by line basis.
@JonClements I figured some people would be unpleasant, but I didn't realise it was that bad. :(
 
@JonClements so if a mod is feeling suicidal and wants to find an unconventional way for ending the misery then just need to go read the deleted comments for some nice new ideas...
 
@AnttiHaapala or just go over the replies to mod messages - they've got a load of room and formatting there they can use :)
 
9:17 AM
those replies must feel very welcoming
 
The love behind them is almost tangible :)
 
I've found that the best way to run python script from a web button is by using ajax. I'm not sure how i feel about python working on the web server. Does anyone have an opinion on using python like this?
 
Hi is there a chat for either databases in general or sqlite3 in python? I couldn't find anything
I was wondering about a db design. Let's say I have 1Million rows and every row has the field "place" and there are 20 places. Or I have 20 tables with the place as table name. Which one would make more sense? I was thinking of having a lookup table for the place field so I would just store an int, but still it has to store the int 1Million times, where with the table it doesn't have to do that. Any thoughts?
 
There's nothing wrong with having a table of placenames and having a foreign key to it in the main table... that's kind of what relational design is for...
 
But I'm just thinking about the memory and retrieval overhead, won't it be faster and use less memory with the table design?
 
9:26 AM
So if you wanted the count of rows you're able to make a simple query like select count(*) from some_table where place_id in (1, 4, 10, 15) or similar, rather than constructing queries such as select count(*) from place_name_table_1 + select count(*) from place_name_table_4 _ ...
@Hakaishin not massively so... and retrieval isn't an issue, you can index the main table...
 
That's true this does look more elegant and I'm leaning towards this solution, I was just wondering about the overhead gained true the better design.
Ok, I think I will try that. Thanks :)
 
Storing 1 million ints isn't a big deal... @Hakaishin - plus you can have the RDMS manage constraints/cascade accordingly... so if you add a new place name you don't have to create a new table and deleting a placename doesn't mean removing a table - you're just removing a row from a small table...
 
True true I'm convinced :D
The thing is it was years ago I learned about how to design a db properly with normalization and stuff. So I'm kinda rusty :P
 
I'm sure it won't take you long to have a read up and it'll come back to you :)
 
9:38 AM
Is this a Pandas question? I'm guessing that it is, but the OP declined to reply to my comment... stackoverflow.com/questions/52831246/…
 
looks like it, and the answer is pandas
 
Thanks. I don't want to tag it incorrectly.
 
@Hakaishin Equi-joins / one-to-one relationships are nearly free. It's the other ones that impact performance.
 
of course it's hard to be sure with all these users calling arrays lists and lists arrays
 
@AndrasDeak Exactly. I figured his "dataframe" might just be a Numpy array.
 
9:41 AM
if you read relational theory, then everything is normalized :P
 
@PM2Ring Yes, but a very basic one on boolean indexing that's covered in the pandas quickstart and has many dupes. Only quirk is this one's about a categorical
 
@smci we can't know that
 
@AndrasDeak I'm not criticizing, just answering you.
 
according to OP's question it's just a string. Who can't filter their dataframe in such a simple scenario is unlikely to even know about the existence of categoricals
@smci I didn't ask a question, and I didn't think you were criticizing me
 
a relation by definition is in 1NF.
 
9:44 AM
@AndrasDeak They didn't say it was a string, just that it contains two values 'Yes' and 'NO'. Could be either string or categorical. The answer's the same
 
> which contains two values 'Yes' and 'NO'.
sounds like two strings to me
 
@AndrasDeak No, the series could be either string or categorical. It's not stated which.
 
so why do you assume it's a categorical?
>>> df = pd.DataFrame({'a':['Yes', 'No', 'Yes']}, dtype='category')
>>> df
     a
0  Yes
1   No
2  Yes
>>> df.a.dtype
CategoricalDtype(categories=['No', 'Yes'], ordered=False)
> I have a column in dataframe [dtype = object]
next
 
It is either a categorical, or a string representing a categorical variable.
 
a string representing a categorical variable is a string
eh, nevermind, I forgot I don't argue with you
 
9:47 AM
Ah yes you're right about the dtype, it must be string then.
@AndrasDeak I just acknowledged I was wrong on this one, and I don't go around sniping at you or your comments, so please knock off the silliness. We've had this conversation too many times before.
 
... wait, I'll get me some popcorn...
 
10:00 AM
That question reveals that there are 397(!) existing questions on [pandas] boolean indexing. Some cleanup needed.
 
10:11 AM
oof i'm trying to get a flask running on ubuntu to show up
gunicorn is Listening at: 127.0.0.1:8000, but this is on a google cloud instance, and connection is always refused to port 80, while port 8000 just loads forever
i think the issue is with setting the permission for inbound network on the ports
 
10:23 AM
dang i'm still stuck
any ideas?
 
10:38 AM
ok i set it to listen at 127.0.0.1:80, and running curl on 127.0.0.1:80 gets the result, and the firewall allows for incoming on that port for all ip
 
jpp
@smci, Re: Boolean indexing, 397 seems a bit low. I expect thousands. It's a bit like merge / pivot_table. It's impossible to stop each of these question in its tracks (in reasonable time, anyway), so you're going to get duplicates.
Not Pandas-specific, mind you, the sql tag gets a lot of this too.
 
@hexicle same as this. you're ports might not be open to inbound requests. check the networking rules section of your instance, and if those look ok, check your instance's internal firewall settings.
 
nice try making us think that they're harmless dancy friends
brilliant :D
 
@shad0w_wa1k3r 0.0.0.0/0 means all ip right
 
10:53 AM
yes (at least that's what AWS says, haven't worked with GCP)
(also we might be getting off-topic here. Since your problem looks entirely network / server related (not flask))
 
ok ok
thanks
i didn't notice
 
11:42 AM
Hi guys, I need some help with python
when I run the following nothing gets printed
def get():
f = open('test.txt', 'r')
for line in f:
asd = f.read()
print(asd)
but when I delete def get(): everything is fine
how can I get it to work without changing def get(): ??
 
please read sopython.com/wiki/… and fix up your indentation
you probably just need to call your function
def get():
    #function definition comes here
    ...

# call the function to make something happen
get()
 
ok gonna try it
 
12:10 PM
@AndrasDeak it worked! I just need to call the function. Thank you!
 
No problem. Do consider reading a python tutorial :)
 
12:40 PM
evening cbg.
 
cbg
 
1:06 PM
Hey
Is there a way I can obtain the generated html page from a flask plotly dash app?
 
1:18 PM
This is why finding dupes is so difficult in pandas. stackoverflow.com/q/52836112/2336654
Something very wrong with this question but I can't find the correct category of wrong
 
1:59 PM
cbg \o
 
I am trying to upload multiple images and store that images in a folder in which the folder name is entered via textbox in the html page. when I run the program I encountered with this error.

ERROR:
IOError: [Errno 13] Permission denied: '/example_14.jpg'

code :

target = os.path.join(UPLOAD_FOLDER, 'dataset/')
folder_name = request.form['folder_name']
path = os.path.join(target, folder_name)
upload = os.path.join(target, folder_name,'/')
if not os.path.isdir(target):
os.mkdir(target)
elif not os.path.isdir(upload):
guys, can you help me
 
os.path.join(target, folder_name,'/') doesn't look right to me. The entire point of os.path.join is that you don't have to specify slashes or backslashes yourself.
In fact, on my machine this causes join to return bogus data:
>>> os.path.join("foo", "bar")
'foo\\bar'
>>> os.path.join("foo", "bar", '/')
'/'
 
what the yam is that last output?!
 
Try changing upload = os.path.join(target, folder_name,'/') to upload = os.path.join(target, folder_name), and for good measure also change target = os.path.join(UPLOAD_FOLDER, 'dataset/') to target = os.path.join(UPLOAD_FOLDER, 'dataset') . See if that helps.
@shad0w_wa1k3r Yeah, it's baffling to me also.
 
that's beyond unexpected :|
 
2:10 PM
@Kevin It worked...
 
but then again, you're on Windows...
rbrb, can't bash Windows so much, else it will queue decades of updates before I get to open it and play some DotA2 :D
 
Is anyone on a non-Windows OS interested in seeing whether this occurs on your machine also? I'm curious.
 
>>> os.path.join("foo", "bar", '/')
'/'
ubuntu 18
python3
 
docs.python.org/3/library/os.path.html#os.path.join implies that a string starting with a slash or backslash is considered an "absolute path component".
 
>>> os.path.join("foo", "bar")
'foo/bar'
 
2:19 PM
So os.path.join("foo", "bar", "/baz", "qux") returns '/baz\\qux' because the arguments are effectively saying "navigate to foo, then navigate to bar, then navigate to absolute path C:/baz, then navigate to qux"
why strings starting with a slash or backslash are considered absolute path components, is not entirely clear to me. It's probably buried ten paragraphs deep in some file path standards document somewhere.
For example docs.microsoft.com/en-us/windows/desktop/fileio/…, which says 'A single backslash, for example, "\directory" or "\file.txt" [is] referred to as an absolute path.'
Presumably Linux has a similar standard.
 
jpp
@piRSquared, I think the main issue is that jezrael (I hate to name names, but this is the obvious "master") instinctively knows what OP usually wants. Well, he should after nearly 12,000 Pandas answers.
However, SO isn't for the guy who has answered 12,000 questions. It's for googlers solving specific queries by adapting generic solutions. Except that's not what's happened over time with .
 
The question I now have is, "is there ever a time when this behavior is useful? When would you actually want to call os.path.join with arguments that have an absolute path component in some position other than the first?"
 
@Kevin vague explanation of why here: stackoverflow.com/a/24296743/7384740
 
Maybe there's some OO principle like "when a function takes any number of arguments, then standards of correctness must be applied equally to all of them". In other words, since the first argument is allowed to be an absolute path component, so must all the other arguments.
@W.Dodge Hmm, "this is necessary so users can break out of the path-restricting sandbox you have specified for them" seems more like a security vulnerability than a feature.
 
2:32 PM
Devil's advocate: in the first place you should not depend on os.path.join to enforce any kind of security. Throw in an if not directory_contains_file(config_path, file_name): raise NaughtyUserInputError if you're worried about that.
 
@jpp said person is good person. I've emailed back and forth. He has a good sense of right and wrong. Family person. All that stuff. I disagree with (some of) his SO tactics. (Also, volume is a function of time and in this case hasn't had the impact on intuition as you might suppose).

That said, I think the issue would exist even without answerers of this sort. I think it is pandas and python users. I've said before that python is turning into the new excel. Meaning that it will become the skill that all entry level office workers will be required to know to some extent. It is al
rbrb
 
jpp
@piRSquared, Oh, I never wanted to imply he's a "bad person". Frankly, he's the best you'll find IMO. He's regularly clocking up 400/day rep, upvotes don't matter to him given the rep-cap is met half way through the day. But I think when we answer these questions we should also sort out the question a little to make it searchable / more generic. If you don't care about upvotes (after all, you reached your cap 5 hours ago), you now only care for the accept.
 
Devil's advocate continued: even if join forbade intermediary absolute path components, the user could still break out of your directory by entering "../../..". So you're doomed anyway.
 
(snaps fingers) crap! ;)
 
They matter. I pointed out this page to him when we was about 50k. At that time I was top of the last 30 day list with a clip of about 800 upvotes per month. His behavior changed after that. When you push past the rep cap, you still get tag score for net up-down votes.
 
jpp
2:44 PM
It's fair to say jezrael has probably topped that chart for several months if not years (on aggregate).
For what it's worth, he also tops , and that's considering he doesn't bother adding the python tag to many (1,701 to be exact) of the questions he answers.
 
What started out as a comment of mine in regards to oddness of a question and how it may generalize to pandas questions in general has morphed into a different conversation.
I've been at the top of the monthly aggregate list as well as the year to date list for a time. I know what it takes to churn out that volume of answers. When I care to be fgitw, I usually can be. I therefore conclude that it would be difficult to generate that kind of volume with much less effort than was required of me.
I mostly use SO as a mental break from my current task. A welcomed distraction when I'm mentally stuck.
 
jpp
3:03 PM
@piRSquared, Sorry, shouldn't have brought up specific people here. I'm not trying to put down FGITW (gamification is here to stay, don't fight it), I use it a lot (jot down a terse answer, then pad it out in next 5 mins). I'm just thinking of ways we can all improve the long-term worth of our answers.
Tagging a pandas question with python is IMO a necessity.
 
And that I agree with. Though sometimes I will blurt out an answer, I try to follow a pattern. I am also thinking of what canonicals would be useful. I think a proper merge canonical would be useful. I got called out by Jeff for my last two. He cited that my efforts would be more useful as a pull request. And I agree with him. So, I've refrained from posting another one until I write some documentation.
Yeah, the tagging would be very appropriate
 
Hey I tried to read this like 5 times and I'm still not sure I get the is_dst param: pytz.sourceforge.net/#localized-times-and-date-arithmetic
 
jpp
Argh, this Q&A is outdated, the transform answer far down should be upvoted / accepted.
 
Is it true that when it is set to true a time let's say 1.30 after dst happend will be counted as 1.3 after dst and false would count it is before dst?
Dst makes my head hurt :(
Like does it matter if I set it to false or true? As I get it it doesn't...
 
3:20 PM
@Hakaishin that parameter just changes the UTC offset for the timezone associated with your location based on whether or not the raw time value in question was taken with dst or not
for the sake of comparison to another time collected in different location i.e. timezone
It matters. You will likely be off by an hour if you are trying to localize and abstract time like datetime(2002, 10, 27, 1, 30, 0) without accounting for that location's use of dst
 
3:41 PM
So I would need to pass true during summer when dst is on and false during winter?
or just true if the zone that i'm in uses dst?
 
@IljaEverilä I have added a section in the question describing the data. It seems to me easy enough to generate the data based on the description. Please note: I have great respect for you as an sqlalchemy expert and have been hoping that my question would cross your path. — malan 49 mins ago
not sure if the feeling was mutual, or was it @IljaEverilä :P
@Kevin of course it is.
it is for "given that we have a default directory foo that is distinct from cwd, what's the full path to the file whose name is x given in the variable bar that is either relative to the directory foo or an absolute path altogether"
 
@Hakaishin Yes, the former. You are trying to localize a time. The flag is to indicate if that localization includes a DST adjustment. Sometime, specifically in science, time will be recorded without DST adjustment to simplify the time series.
 
Hello, quick question about mapping lists to python positional arguments
Lets say I have a function: function(a, b, c, d, e), and a list [a, b, c, d, e]
Is it possible to map those list values as arguments without doing function(list[a], list[b], ...) ?
 
jpp
@J.L.Louis, How about function(*L), where L is your list?
 
3:57 PM
I am not the author of the function, and I can't edit the parameters to unpack the list within the code
I was just wondering if python has some syntactic sugar to do that for me
 
jpp
No, this is how you call function, not how you define it
 
>>> def frob(a,b,c):
...     print(a,b,c)
...
>>> L = [23, 42, 99]
>>>
>>> frob(*L)
23 42 99
 
ah
Thanks @jpp @Kevin!
 
@AnttiHaapala Well, the question would be clearer with the data, but it's not a bad question in itself.
 
Thank you @W.Dodge :)
 
4:07 PM
@Hakaishin No problem
 
wim
4:35 PM
Why doesn't os.path.join() work in this case? was already on my list (of bad accepted answers to popular questions).
The answer from David Wolever is correct, with an honorable mention to the answer from Antony Hatchkins.
previously discussed in chat around here ..
Jun 22 '17 at 18:40, by wim
> Even one slash ruins it.
99% of people are using os.path.join wrong, which is one of the motivators for pathlib existing now. Also, 90% of statistics are made up on the spot.
 
If you interpret Craig's answer as "remove the leading slash. All the other slashes are completely fine, though", then it's bad. If you interpret it as "If you remove the leading slash, the code will work. I have no comment about whether the remaining slashes are good or bad design, since that's beyond the scope of this question", then it's fine.
 
wim
This behavior is not specific to os.path, by the way. url joining has the same behavior with absolute components, and it's useful - you can join a redirect to a relative path (on-site) or an absolute path (offsite resource) in the same way without special casing. If you tried to change this behavior to be more newbie-friendly, a lot of grey beards would be upset.
 
wow...
4.5 years and 8 upvotes... :F
well 9 now
 
I wonder if regular shells support this kind of "relative, then absolute" path? If so, I don't know how you'd actually write it. For example, in the Windows cmd prompt, I can't do cd C:\users\C:\users.
 
4:50 PM
cabbage
 
If relative-then-absolute paths are so great and important, I should be able to do it in a shell script, right?
 
wat, Tim is now suspended?
 
who's tim?
 
@Code-Apprentice you've got to have seen him.
 
wim
>>> from urllib.parse import urljoin
>>> urljoin('api/', 'v2')
'api/v2'
>>> urljoin('api/', '/v2')
'/v2'
IIRC it's part of POSIX that multiple //// get resolved to just one
 
4:56 PM
btw urllib.parse is horrible POS.
my favourite is this:
>>> import urllib.parse
>>> urllib.parse.urlparse({})
ParseResultBytes(scheme=b'', netloc=b'', path=b'', params=b'', query=b'', fragment=b'')
because it just totally makes sense (not)
 
wim
wtf
 
I've submitted a bug
they say "not gonna fix because people can depend on this behaviour"
 
wim
works with any empty iterable?
 
wim
I tried set, list, tuple .. bytestring ..
 
4:59 PM
well ... it is like "if the given thing is false, then find out if it is string and use string as the component, bytestring otherwise"
>>> urllib.parse.urlparse(None)
ParseResultBytes(scheme=b'', netloc=b'', path=b'', params=b'', query=b'', fragment=b'')
 
@AnttiHaapala not aware that I have
 
Consecutive slashes appear to also be resolved as one slash on Windows, although I don't see it documented anywhere. 100% Works-on-my-machine certified.
 
@wim actually... bugs.python.org/issue22234
there is a patch... it is just that no one cares to review it.
 
wim
August 2014 😥
I've had moderate success with recreating old patches as github PRs
 
5:15 PM
stackoverflow.com/questions/12088442/… useless/harmful (parsing csv by splitting on commas...) click magnet
 
@wim it is not my patch but Serhiy's. No one ever reviews anything. He creates too many patches... if he spent all his time reviewing other people's prs I am sure Python would get better faster:D
 
Timeout, first off I don't encounter many downvotes and when I do I'm very attentive to if I made a mistake or improving my answer if something was spotted, again rarely, yet I just got downvoted no comment, which I dont mind... except I cannot find a reason to say my answer was not adequate, and then I also noticed they must have downvoted every answer including jpp
Aside from that if you were in the shoes of the downvoter what is so wrong with my answer to this ? stackoverflow.com/questions/52830212/…
I would like to improve it if thre is cause but in my eyes I see no wrong doing
 
lst = [d1, d2] followed by for i in lst: seems roundabout when you could just do for i in (d1, d2):
Although I don't care much for using i as a variable name except when it's an integer
 
yah, it looks like someone just downvoted all the answers. Perhaps because the question itself isn't very good. @vash_the_stampede
 
Okay but the method using defaultdict there is appropriate correct?
 
It produces the correct output but I'd be more inclined to use prezes48's approach, or jpp's
 
6:05 PM
@Code-Apprentice oh well I just I try to take pride and put a fair amount of consideration into my answers, and if they aren't good enough I just wanted a explanation to improve on
I agree I myself would have used jpp if he didn't already
 
If you see a question and the approach that occurs to you is already there, you shouldn't feel pressured to come up with another way to do it just so you can post that
 
I know but also when it comes to time complexity isnt defaultdict better than counter
I recall that conversation taking place before
 
I wouldn't expect it to be, no. They're both just dictionaries under the hood.
 
no actually just checked your correct
 
@vash_the_stampede many people downvote spoon-feeding answers to effortless lazy questions, probably the case here
 
6:11 PM
@AndrasDeak yeah I could only deduce that was the reason, the shame fell upon me
 
questions that tend to incite comments along the lines of "SO is not a code writing service"
 
def take(n, iterable):
    "Return first n items of the iterable as a list"
    return list(islice(iterable, n))
in itertools recipes , what is special about this that is different then taking lst[:n]
 
Not all iterables can be sliced
>>> import itertools
>>> x = itertools.count()
>>> x[:10]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'itertools.count' object is not subscriptable
>>> list(itertools.islice(x, 10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
hmm very neat
I was going to say I must be oversimplifying or missing something
 
6:27 PM
i.imgur.com/KVfcOgR.jpg (warning: PG 13 language) claims that "Of all real numbers, the golden mean has the worst rational approximation". On what basis does it judge the comparative value of rational approximations of irrational numbers? What makes phi worse than pi or e, for example?
Is it because its infinite series formula is ugly?
 
@vash_the_stampede On the matter of iterables, this article explains the differences in python. The graphics in particular were very useful to me.
 
 
One of those things where I thought "I should have way sooner made an effort to really understand it, but good that I did now"
 
@Arne ty this is much needed, my in depth understanding is limited I need to improve on what things are actually doing behind the scenes etc
 
@Kevin I'd suspect it converges the slowest. For a given finite n the error compared to the exact value is largest
a somewhat bold statement
 
6:31 PM
When it says "all real numbers", does it mean all real numbers, or just all interesting real numbers? Maybe there's a completely pointless irrational number that nobody has bothered to discover, which has really extremely bad convergence.
If phi had the provably worst convergence of all numbers, that would be pretty neat. If such a concept can even be judged objectively.
 
@Arne Nice one! Thanks
 
That first graphic in particular was a real eye opener for me. I used to mix up iterable and iterator all the time =D
 
@Kevin we'd have to see an exact claim to be able to debate it :)
hearsay math is worst math
 
Incidentally, the other day I learned that the Taylor series for log(1+x) gets less accurate the more terms you add to it: see the third image under en.wikipedia.org/wiki/…
 
@Kevin that's not exactly true
it's more about the Taylor series having a finite radius of convergence. Inside it will converge with n; outside nothing is guaranteed
 
6:35 PM
wack
 
it happens to be only convergent for -1 < x < 1
all hell doesn't have to break loose beyond the radius of convergence, but in this case it does
And you could expand the Taylor series of that function around, say, x=2. Then you could map a different (possibly larger) section of a function.
 
Well, I understand the statement, but not why it is the case
 
Which part? Why the radius of convergence is -1 < x <1?
 
radius of convergence calculator
 
On the matter of iterables, should perhaps try and create a patch for this as it seems to be going nowhere without.
 
6:40 PM
another day of yamming documentation.../sigh
 
@AndrasDeak Effectively. Why -1 < x < 1 and not, say, -100 < x < 100?
 
on my lunch break right now and avoiding going back to work
@Kevin Do you mean the convergence of some approximation of an irrational number? It doesn't make any sense to talk about the convergence of an irrational number itself.
numbers don't converge or diverge, series do...and functions
 
I guess I'm kind of presupposing that every irrational number has a "canonical" formula which calculates it in some way that is quantifiably better than any other formula.
 
I'm not sure if that is a valid assumption
 
Which, now that I type it out, I suspect can't exist for all irrationals, no matter what criteria you pick
 
6:46 PM
there are a lot of irrational numbers that are defined as the solution to some polynomial...these are the algebraic numbers.
 
"The formula that takes the fewest characters to express", for example, is inconsistent thanks to the Berry Paradox
 
there are a lot of non-algebraic, irrational numbers
 
"...attributed it to G. G. Berry (1867–1928),[1] a junior librarian at Oxford's Bodleian library." Junior librarian FTW y'all
 
Are there numbers which have been proven to have no generalized continued fraction? Is there a name for this kind of number?
 
How does one get setuptools to run the latest version? It's not in a setup.py requires and it's not in the requirements.txt? Is it included with python or pip?
 
I ran python -m pip install --upgrade pip setuptools wheel to upgrade it. But I still don't understand... Does it come with pip, if not why is it not in my setup.py and how can that import it automatically
 
@Kevin sorry, real life stuff interfered. On the one hand for x < -1 the logarithm is not defined. But for -1 < x you have to look at the Taylor series and assess its convergence. There are strategies to do this, for instance the root test. This tells you in terms of the coefficients as a sequence whether and how a power series converges
 
So I guess this means that irrationals can have a canonical representation, namely their continued fraction representation. Perhaps you could rank them by periodicity.
This is assuming 1) each irrational has exactly one continued fraction, and 2) all continued fractions are periodic. I suspect neither of these are true.
 
7:14 PM
Hmm. Now I'm confused. That page lists two continued fractions for e, but en.wikipedia.org/wiki/Continued_fraction says "The continued fraction representation of an irrational number is unique.". What does "unique" mean, if you can have two of them?
Maybe the second one doesn't count because it has a two in a numerator?
 
@Kevin I think the canonical continued fraction always has 1 in the numerator
that's the first time I've seen something other than 1 in the numerator
> If bi = 1 for all i the expression is called a simple continued fraction
 
> π = [3;7,15,1,292,1,1,1,2,1,3,1,…] (sequence A001203 in the OEIS). The terms in this representation are apparently random.
That's cheating :-I you can't write a formula and say "and, uh, we don't know what numbers come next"
 
so not periodic...
 
This is "Solution left as an exercise to the reader" to the Nth degree
Oh hey, the very next line is "ϕ = [1;1,1,1,1,1,1,1,1,1,1,1,…] (sequence A000012 in the OEIS). The golden ratio, the most difficult irrational number to approximate rationally. See: A property of the golden ratio φ."
I guess we found the citation we were looking for :-D
> the convergents for φ (i.e., the numbers 5/3, 8/5, 13/8, 21/13, etc.) consistently "toe the boundary", keeping a distance of almost exactly 1 n 2 5 {\displaystyle {\scriptstyle {1 \over n^{2}{\sqrt {5}}}}} {\scriptstyle{1 \over n^2 \sqrt 5}} away from φ
 
7:34 PM
Weird starboard formatting bug vis-a-vis tag formatting
 
@jpp Yes, 397 questions just on the exact tag and literal phrase [[pandas] boolean indexing](stackoverflow.com/search?q=%5Bpandas%5D+boolean+indexing+is%3Aq). There will be lots more from users who don't know the right terms, e.g. ask about .loc(), "drop", "index on conditional", "match" ...
 
7:51 PM
@themaster I guess that's a pebkac error there. — Antti Haapala 2 mins ago
How can I resolve this — themaster 1 min ago
 
ironic username is ironic
 
or successful troll is successful
 
By reading the answer very carefully, and comparing to what you just wrote. — Ilja Everilä 3 mins ago
 
I might not have been welcoming.
 
sometimes blunt and direct works the best
the OP seems a little sheepish after realizing the mistake but doesn't seem offended
yay! documentation! </sarcasm>
 
8:01 PM
pebcak could've gone either way... upside is that TIL pebcak
 
 
2 hours later…
9:38 PM
@AnttiHaapala you missed a spot
 
 
1 hour later…
10:55 PM
stackoverflow.com/questions/52836295/… OP stated this question is no longer of use, posted new question
 
close as what?
 
cbg all
 
11:14 PM
Ok so what I'm about to ask is a very noobie question, but to use the accepted answer in here stackoverflow.com/questions/1023038/… I must simply set my code as a def something() and call it with the lowpriority def lowpriority(something), right? Just wanna check before I irreversibly mess up stuff XD
 
For the record, the green checkmark doesn't make it "verified". It just means the asker pushed a button that looked like a checkmark.
 
Ye I corrected it to "accepted" srry XD
 
and in this case the answerer is the asker so they're not a reliable source ;)
 
I mean, maybe the asker found out a method later and wanted to clarify all. Also I have seen similar methods with slight variations elsewhere, but if you do think it is unreliable, I trust you because you seem to know your coding stuff :P
 
I never said it's unreliable
I just said that the green checkmark means nothing
the answer concerns windows so I have no idea
 
11:17 PM
@AndrasDeak touchée, and sorry
@AndrasDeak also thanks anyways, all help is appreciated so I don't blow up my computer XD
 
no problem
 
@AndrasDeak Ok so this is besides the point, but what os do you usually program in? Like, I assume you program on Linux, but I'm curious now XD
 
yup (I mean, yes, linux)
 
@AndrasDeak well good to know, thanks :D
 
and not just usually but always and exclusively
 
11:22 PM
I mean, I get why, I've heard Linux is the programmer's paradise for those who know how to use it
 
11:40 PM
@SaltyHelpVampire my personal opinion is that windows is the user's hell
 

« first day (2922 days earlier)      last day (2025 days later) »