« first day (3146 days earlier)      last day (1805 days later) » 
00:00 - 15:0015:00 - 00:00

12:07 AM
So please do your homework on this topic, then if you find any useful Python-vs-Golang comparisons/benchmarks/stats, share them here.
 
I don't even insist on sharing
 
@AndrasDeak I was just about to share some stats but, I saw your comment and decided against it.
 
@Rick Please do share stats, if they relate to Python in any way, e.g. "What % of storefront startups in 2018 used Golang-stack vs Python-stack vs PHP-stack?"
 
@smci I'm going to respect @AndrasDeak wishes on this.
 
@Rick Also, there is no Golang chatroom on chat.stackoverflow.com. You might like to start one and invite any Golang fullstack types on SO. And Reddit seems to be a good language-agnostic discussion site.
@AndrasDeak Would a fact-based post like "What % of storefront startups in 2018 used Golang-stack vs Python-stack vs PHP-stack vs JS-stack?" be welcome? Me personally I'd like to see it.
 
12:50 AM
All, how kosher is the advice in Saving 9 GB of RAM with Python’s slots? and how up-to-date in 3.7/2.8?
 
 
3 hours later…
3:27 AM
golang yourself
 
 
1 hour later…
4:33 AM
@smci Looks ok, although dicts are a little more compact in 3.6+.
 
4:57 AM
This answer enables the worst anti-pattern in the history of pandas, and has 1.7k upvotes. I wonder how many people have seen this answer and been mislead into thinking "using iter* functions are the right way to go" just because of the sheer upvotes there.
4
 
5:31 AM
@cs95 Yeah I know, iterrows considered harmful, those answers need a makeover with a blow-torch, but the wrong answer is so highly-upvoted (and one of those was me, years ago) that the best way to displace it is to ask a new "What is the best-performance (CPU and memory) method to iterate over a large dataframe in pandas 0.23+ / Python 3.7+?", and give a sample random-seeded dataframe with (say) 1M rows and 1000+ cols. If you do that I will upvote any decent answers.
@cs95 on exactly that topic, same FYI link I posted yesterday: Sofia Heisler's PyCon 2017 talk: "No More Sad Pandas: Optimizing Pandas Code for Speed and Efficiency" and YouTube video are excellent. Invoking df.iterrows really should trigger with a (suppressable) warning on performance and bad habits. I mean that as a serious enhance request...
... Kidzthesedays don't learn how to vectorize early, they just learn the bad habit of using iterrows as a crutch on toy-size dataframes, then wet their pants when it breaks/isn't performant on real dataframes. Also, groupby() and agg() are often what people are really looking for.
 
user10984358
5:54 AM
anyone on here??
 
user10984358
I am leaving this out here if anyone sees this then let me know of a solution
 
user10984358
what module should I be looking at if I want to simulate "left click", "right click", is there a python module or should I be looking at calling apple script via python??
 
@TheNamesAlc there are toolkits for GUI automation but they tend to be platform-dependent; for example pywinauto as the name implies is specific to Windows
e.g. AutoPy is cross-platform apparently, but I'm just reporting what I'm googing
pyatomac seems to be Mac-specific
 
user10984358
can those simulate keystrokes as well??
 
here are some Stack Overflow questions google.com/…
@TheNamesAlc of course
 
user10984358
6:03 AM
also one more thing
 
user10984358
is selenium the only way of grabbing options from a drop down, say the google suggestions thing on the homepage or is there a much simpler library ??
 
Selenium is for browser automation, it's about selecting dropdowns on a web site, not from a system menu
any decent GUI automation should be able to handle menus fine as well
 
user10984358
yeah I am aware of that, I just wanted to know if there are alternatives (simple) to that of selenium
 
user10984358
https://selenium-python.readthedocs.io

Is this like the only official selenium docs?? I was expecting something more like python docs site
 
@TheNamesAlc what do you think is missing? this looks like a fairly typical third-party module with decent documentation
though as it says it's not the official Selenium documentation
the official doco is at seleniumhq.org/docs
 
6:48 AM
Hi guys I have a question regarding VS Code
Is this the right place to ask about that ?
 
i dont think so
 
Where should I ask ?
 
depends on the question, ask and if someone can reply they will, or if its non trivial and doesn't fit here someone will say so.
 
I am trying to set up Git internally in VS Code
I tried that doing one of the answered questions here on stack overflow
However its not working
184
Q: How do I use Bash on Windows from the Visual Studio Code integrated terminal?

Walid OmonosVisual Studio Code on Windows uses PowerShell by default as the integrated terminal. If you want to use Bash from Visual Studio Code, what steps should be followed?

After following the steps when I click on + its opening a new terminal in git bash instead of VS Code itself
 
7:10 AM
this is a Python chat room, you are in completely the wrong place
 
Where should I ask it?
 
7:23 AM
can't find a Windows or VScode room here, maybe try chat.stackexchange.com/rooms/118/root-access over on Super User ... but it looks really like the instruction you are trying to follow is not for the problem you are trying to solve if I am reading you correctly, so maybe check that first
 
Hi Guys
 
I am trying to create a user function in python for deleting rows in my data frame by using this code def remove: df.dropna(subset=['column name']) df.reset_index(drop=True) df = df['column name'].apply(remove)
but it's not wokring.. can please help?
 
What exactly is not working? Please show the code you're running properly formatted and explain the issue beyond "not working"
 
@Jason dropna(..., inplace=True) Otherwise you're throwing away the result
 
7:30 AM
I'm not sure you can apply a function to a column to drop that very same column, actually
 
In general always do pandas stuff inplace, if a command has that option.
 
Why does this process need to be packaged as a function?
 
I have 40 columns which has NAN value. I need to remove the rows which has NAN value in the column. It is working if I use this code df = dfa.dropna(subset = ['column name']). But I want to create a function and pass it to other columns too
I created a function : def remove(x):
df1.dropna(subset=[x], inplace = True)
df1.reset_index(drop=True)
 
@Jason Beware that dropna() will drop ALL rows that have ANY NAs in any of the columns, at least for the default behavior how='any'. Is that what you want?
 
@smci no I want to remove the particular rows.
only
 
7:34 AM
@Jason Right you mean you want to drop ALL rows that have ANY NAs in any of the columns specified in subset?
 
@smci yes
I want to create a function for that as I have 40 columns
 
@Jason Ok then your function will have to take df1 as a parameter, won't it?! (Please no globals)
 
def drop_col(df, col_name):
    return df.dropna(subset=[col_name])

df = pd.DataFrame({'a': [1, 2, np.nan], 'b': [3, np.nan, 4]})

df = drop_col(df, 'a')
 
@Jason But as roganjosh says, why declare a function for a one-line call to dropna(subset=..., inplace=True) ? Just write it directly. Make sure not to forget inplace :)
 
Although, you probably want a better name like drop_by_column or something
 
7:37 AM
thank @roganjosh it's working.. i didn't declare the dataframe name..
@smci i have 40 columns hence want to create a function
 
@Jason Your function wasn't taking any df as input arg... :) sentient function huh...
 
just for easy to type
 
@Jason Raise your right hand and say "I swear my code has no globals..." :D
 
yes
 
J/teasing...
 
7:41 AM
it's ok.
 
7:54 AM
I want to loop through approximately 100.000 websites, and extract two numbers, both on line 63 in the source of the website. The website address is of the form: website.com/statistic/stat.php?id=94231. It starts at id=1 and increments up to approx. id=120000.
Do you have any suggestions for what tool / approach I should use in Python?
 
requests to get the source code and beautifulsoup to parse it?
 
It's not really parsing html, since I know exactly where the info I want is, so it's basically the fastest / most robust / least memory intensive way to load and read the files.
 
beautifulsoup is possibly overkill if you know exactly where the code you want is, you just need a custom parser for that line
 
requests fits the bill for the actual requests just fine
run it on a couple webpages, and then decide if a simple line splitted string is easy enough to work with directly or not
if it is, then you're done.
 
requests-futures is a super-simple way to make async requests, so that will probably be faster
 
7:57 AM
@roganjosh beautifulsoup is probably a bit overkill since I know exactly where the information I want is, don't you think?
 
Umm, I think I just said that?
 
aye, he said as much.
 
@roganjosh I hadn't read that message yet, and thought I replied to the one above that one...
Well, we agree at least :)
 
:) I think you could probably get your parser code into a callback on requests-futures considering it's probably pretty simple. That's probably the route I'd try first
I said "probably" 3 times in 2 lines. Time to put the kettle on for tea, I don't think my brain is firing on all cylinders yet
 
@roganjosh You're probably right :)
Thanks all :) I'll give it a try!
 
8:10 AM
@StewieGriffin One thing, though. That's quite a lot of requests and async requests with a simple callback will hammer the site. Are you likely to cause disruption to the site itself?
 
@roganjosh @StewieGriffin this is an important consideration, you will probably need to scale back so you don't nuke the site with 100,000 concurrent requests
 
I hadn't woken up properly so I was thinking in terms of speed when I was hammering an endpoint on a self-hosted server. I wish I'd thought of it before they left the room. Hopefully the 15 min delay in notifications is sufficient for them to see before they unleash a monster :/
 
also the server might automatically start rejecting results when they see so many requests coming from an ip. and perhaps ban the end point for some time
 
recbg
 
8:23 AM
cbg
 
guys i am using rank to calculate my score for my datasets.. I am using this code : df["score"] = df.groupby("Critics_rating")["Imdb_rating"].rank(ascending=0, method='dense')
Getting this error message : 'NoneType' object is not callable
 
Please get into the habit of posting an MCVE. I don't mind helping where I can but you're dropping half-problems on us and leaving us to try work them out. Have you done any debugging?
 
No
sorry
 
fyi, mcve A self contained code snippet which we can copy paste and use. And also, a better read regarding mcve for pandas
 
Hello, I'm trying to find something about return statements usage in functions. The idea is that I'm quite new to coding and now it looks that I'm doing not the way I should do it. I found lots of comments about that single return statement is preferred and etc, but can't find what Python pep is saying, maybe some one knows is there any PEP that writes about this question? :) thank you
 
8:37 AM
if someone preaches "single returns only" as a rule, whack them on the head.
 
@simkus python does not have goto.
 
as always, it depends on readability and ease of logic. multiple returns can be okay.
 
the single returns make sense in context of code that have goto which allows multiple epilogues
 
ahh, that sounds fair :)
thanks for quick answer
 
@simkus also...
 
8:41 AM
thanks for now :)\
 
the PEP8 says:
> Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable).
@simkus you can read between the lines there that it does not say anything about preferability of single returns whereas it does discuss multiple return statements
 
yes it looks like that, because I was trying now to write with single return statement and for me it felt like if I'm leaving single return statement and many result = '' then I gave to do lots of nesting if function is big and it's harder to read, at-least it felt like that :)
but thanks for the tips, going to re-read pep8 once more :D
 
8:58 AM
@roganjosh I'll keep this in mind. I'm not in a rush, so I can do it in bulks.
I'm curious to see how much time e.g. 100 requests take.
 
@StewieGriffin <wipes brow> I was getting slightly restless about that
 
@tripleee I'll keep it in mind :) It's a fairly small website, so I'll be careful :)
@roganjosh :)
 
Though, blasting the site out of existence probably wouldn't be at odds with your character. Handing all the right tools to Stewie Griffin; not the best start to my morning.
 
I might just attack their office and get them to do it for me... Simpler!
 
Kinda on that note; have you considered just asking them for the data if you have a legitimate use? I don't know the context, but it might actually be possible to solve this with an email
 
9:39 AM
Hey, Stewie
 
@roganjosh Where's the fun in that? :P
I don't have a legitimate use actually, but it's not illegitimate either. I'm curious about a few things about the statistics, and want to do some simple analyses, for personal use.
 
@StewieGriffin Apologies, I don't know what I was thinking. Reminds me of a scene in Shameless (UK version) where the main character gets his benefits cut. Cut to scene - petrol can in one hand, lighter in the other in the benefits office. Pretty effective diplomacy, it seems
 
@AndrasDeak Hi Andras... :)
The purpose is a bit embarrassing to be honest; The website contains results from a competition dating back to 1983, whereas my own results dates back to 2003. I want to compare my own results in the competition to that of the other 100.000 people.
It's a bit egocentric, so it's not something I want to tell anyone about, except strangers on the internet :P
 
I think it's fine
 
@AndrasDeak Thanks :)
 
9:54 AM
So what's your situation now? Trying to figure out how not to throttle the server? Requests+grabbing and parsing a line of html should be straightforward enough
 
so then aggressive async is probably completely the wrong approach, just let the crawler take its time and make sure you don't tax their bandwidth too much
 
Things like this has always made me curious: How long would it take someone to find my true identity if they tried. A few minutes, or are we talking hours..?
 
do you need to log in to view the stats?
 
and maybe even stop crawling once you have enough data to form a conclusion (I'm guessing 1k or 10k would be quite sufficient)
 
9:54 AM
is it considered fine if I think a question can be a duplicate of another question I myself answered, and then mark the new question as such
 
@StewieGriffin depends on practice and resources
@DeveshKumarSingh yes
 
@AndrasDeak okay cool :)
 
@StewieGriffin depends on what sort of tracks you are leaving, on average it would be fairly quick, if you are conscious but not completely methodical it's probably possible with some effort
 
@DeveshKumarSingh if there are other dupe targets you or someone else can add them later
 
Since you're not in any major rush, I assume, just do batches of say 50 requests, then sleep the code for a little. It's something that can run in the background while you do other stuff
 
9:57 AM
@tripleee this could be a valid approach, but the id's are chronological. The first contestant in 1983 has id=1, whereas first time participants in 2019 gets id=120000. I want to compare my results to others that have competed +10 times.
 
@AndrasDeak Okay but I can only add one dupe target right and not multiple
 
@AndrasDeak No, they are open :)
 
@DeveshKumarSingh you can edit the dupe target list once it's closed
 
@StewieGriffin Perhaps use a fake user-agent and a proxy middleware to fake your requests
 
Not you, sorry. A gold badger.
 
9:58 AM
@DeveshKumarSingh if they get a small amount of visitors they can probably identify you because of that if they are paying attention
 
@AndrasDeak Aah okay, got it
 
@StewieGriffin I'm not saying you absolutely don't need all of the samples, but that it's quite possible that you can get by with a smaller number and you should consider that ... but thanks for clarifying the requirements
 
@tripleee True, I could have some conditionals that makes it stop when I have enough data.
@tripleee it would definitely be possible with some effort, there are enough clues spread around on the SE network...
@tripleee I'm not that concerned about keeping my interest in myself hidden :P If they bother trying to trace me down, then that's ok with me.
@roganjosh yes, I'll probably do this :)
 
<reference to Stewie Griffin's arch enemy but I don't watch Family Guy>
 
did you just... reply to four messages in a row?
oh my
talk about pings
 
10:05 AM
@connectyourcharger I'm a bot!
 
it's like with any security question, you can articulate a probability which usually increases over time but if they are lucky their first wild guess will be your password and there is ultimately no defense against dumb luck
 
are you really a bot?
 
yes, he is
 
@connectyourcharger why are you saying are you really a bot?
3
 
Bots are smart but not that smart to be making such smart responses :)
 
10:06 AM
lol right
 
Not the best attempt at the Turing Test IMO
 
Somebody should make a bot that just sends random stewie quotes every now and then
 
M-x psychoanalyze-pinhead
 
@connectyourcharger WEAR IT IN SILENCE, OR I'LL HONOR YOU AGAIN!
^ Anyone take the reference?
 
:)
do I need to get my bot in here?
 
@AndrasDeak game of thrones + dislike + reddit + random-quote-bot = YOU GOT FAT!
 
I like this bot
 
@DeveshKumarSingh please stop requesting access to the knives room
 
@AndrasDeak Got it, only room owners has access to moving messages then, not everyone can do it?
 
yup
room owners of the source room can move messages anywhere
 
10:28 AM
cbg
 
I missed the bot :P
 
which bot? the stewie one?
 
@connectyourcharger By all means, turn me into a child star.
 
@connectyourcharger FunBot...
 
10:31 AM
Oh wait
He's active in another room
 
Oh, i still have Stewie tho...
 
If you wanna see FunBot, search for a room called "Test My Bot"
 
The only amusing thing I saw was how quickly the objections came in for it running
 
stewie
 
@U9-Forward Damn you, vile woman!
 
10:54 AM
stewie, good bot man
 
Am I the only one that misunderstands the * operator? I always think of it as unpacking, but this does not work. Is there another simpler way to achieve this?
a = [1,2,3]
b,c,d = *a
 
Drop the asterisk
 
... wow, thanks
 
* unpacks a sequence into another sequence
in *a there is no sequence to unpack into
*a, works, because the , creates a sequence
b, c, d = *a,
 
how come then that function args are consideres sequences but assingments not?
def bla(a,b,c):
    print(a,b,c)
because this works
bla(*a)
 
11:00 AM
a,b,c is a sequence
Python's full call interface is (*args, **kwargs) -> r
as opposed to, say, Haskell's a -> r
Python always takes a sequence and mapping of parameters
even if that sequence is of length 1 or 0
so, for example the following two are equivalent:
def bla(a): ...
def bla(a,): ...
 
i see
 
as far as I can tell, assignment is the part that confuses most people
because there one can easily mix up individual and sequence assignment
but I have rarely seen *-assignment in the wild
 
11:15 AM
stackoverflow.com/questions/56338730/… unclear. The OP's intent is polarized; they want the result of a dropdown menu that they've disabled.
 
11:28 AM
I'm looking for a nice way to do this: I have a stream of timestamps, two datasets always match together and have similar timestamps. Now I thought of simply taking all timestamps in an interval, sort them according the timestamp and then take a timestamp t and take either t-1 or t+1 depending what is closer. And then do the same for the second point and so on. in case t-1 is actually closer to t-2 instead of t
It sounds kinda ugly and I wonder what would be a better way to do this
 
define "similar" ;)
 
"two timestamps always match together and have similar timestamps"?
 
close to each other
 
closer than any others?
 
yes
 
11:29 AM
note that sorting a stream is generally a bad idea, by the way
 
well that's what it is. but why? and how would you do it better?
 
a stream is generally of arbitrary size
sorting requires knowing all data
 
Is there no threshold for similarity?
 
yeah, i just cut it periodically and sort that slice
 
so a time window is fine?
 
11:31 AM
no not really
yeah i apply a time window on the stream in a loop
atleast that's what i'm thinking of doing
but as said the whole thing feels fishy
 
do you have any estiamate on how far apart two similar timestamps are in the stream?
 
no
 
do you have an upper limit on that?
 
I can think of an approach but data at either end of the slice will always be ambiguous
 
do you know how close similar timestamps are, and how far apart dissimilar ones are at least?
 
11:33 AM
once the stream is sorted the limit for matching for one point is always t-1 and t+1 in case that both t-1 match to t-2 and t+1 matches to t+2, t does not get matched at all
 
Since you can never know whether your slice interrupted a pair
 
hmmm yeah, i see what you mean now
 
can you have something like t-1, t, t+1, t+2, t+3, t+4?
 
In fact, interrupting a pair will possibly cascade the issue
 
if you do not know how far apart members of a pair are, you need a buffer
not a window
a simple set might do if you know the distance between pair elements
or a dict, if the elements carry additional data
basically if you get a timestamp t, try buffer.pop(t+1) and buffer.pop(t-1)
 
11:36 AM
ok, wait i understand you questions about the upper limit now. I think I will only do slices in the past. There is no strict upper limit, but something like a few seconds like 5-10s. So this should solve the boundary problem
 
if one succeeds, you have a pair
if not, put them all back into the buffer
is your stream reliable? or can you miss timestamps? e.g. TCP versus UDP
 
udp
 
then you should clear your buffer regularly anyways
 
'morning cabbage
 
if you have few elements in your time window, a sorted list of items is probably the most efficient, though
 
11:54 AM
sometimes I wish there was only one single clock in the world and all other clocks sync perfectly with that one...
 
nah, that'd make all us physicists obsolete :/
 
^^
 
@MisterMiyagi What is going on here, so much messages...
@Hakaishin Same with you
 
12:11 PM
I don't think there's anything unusual about a two page long technical conversation. No need to discourage this kind of thing.
 
12:22 PM
I've got a set of points in 2d space and I want to plan a not-optimal-but-efficient route that travels over all of them. I could model this as the Traveling Salesman problem, but to turn the plane into a graph I'd have to calculate all N^2 distances between points.
Right now I'm just doing "locate the unvisited point closest to this one, and travel to it" and it works ok but I'm wondering if I can do better, even without a PHD-level algorithm
 
How many points?
 
900.
 
Is there a required runtime?
 
that's basically travelling salesman no? I think you'd have to decide how much of a runtime you can tolerate in "finding" a decent path
 
There's no hard deadline but if it takes more than a day to run, I'll probably lose interest.
 
12:25 PM
Oh wow, that's a pretty big timeframe
In that case, let's see if I can find one of my old simulated annealing algos and repurpose it a little
 
in that kind of window, i think you can approach close to brute force methods. Do a greedy path, let a bruteforce path run, and on the side perhaps opt for a genetic algo
i think the genetic algo would serve your purposes just fine
annealing algo, is that same as genetic? not familiar with that phrase
 
No, but all of them come down to guesses and some acceptance criteria
SA is just an acceptance profile to avoid local minima. Always accept the better solution, maybe accept a worse solution but decrease the tolerance of the worse solution as time goes on
 
i like annealing approached, they are fun
 
Just saying the words "simulated annealing" have given me a nice nudge in a productive direction, thanks
 
@Kevin The algorithm is very simple. It's also something that industry uses a lot; it's also the basis of my machine scheduling problem, and 2 routing systems I've worked on. Don't get distracted by the literature, the only trick is the speed at which you can generate and evaluate solutions. The tuning of the params is a bit of a guessing game
Also, a 900*900 matrix is trivial unless you have memory constraints
 
12:34 PM
I dabbled in this a while ago (ptmcg.com/geo/drill and ptmcg.com/geo/drill/moreExamples.html), eventually settled on a C lib that I believe uses Lin-Kernighan and was quite fast. I'm surprised that there is no Python wrapper on a TSP solver in PyPI - wait, searching pypi.org for "tsp" turns up several options.
oh, and cbg
 
cbg :)
 
A while back, someone mentioned "ruin and recreate" for optimization, this sounds like just another name for simulated annealing though - isn't that basically what SA does?
 
That was me
The acceptance profile is basically the same, but you use different strategies to determine which nodes to remove from a solution
 
rbrb
 
R&R is more suited to constrained problems, though. Finding the shortest distance is trivial. Real vans, though, have capacity constraints, and you also have time slots to visit each node. That's all taken into account in the recreate phase
Oh no, the link I posted on Jsprit mailing list is dead but it had a great summary I was going to link for you. Problem is, I don't remember the name of the paper and there are just so many :'(
 
12:55 PM
The consequences of me not finding an efficient solution are... What's a word for the exact polar opposite of "dire"?
 
"fortunate" and "lucky" are listed as antonyms
Sure, there were more appropriate ones too, but I like cherry-picking
 
"inconsequential" perhaps?
 
The consequences are inconsequential! [lightning flashes, a horse startles]
 
The images in my links were from a Tkinter animation I wrote that plotted the best path from each successive generation - fun to watch.
 
1:10 PM
Hold your horses...
 
@PaulMcG Found it. If you're actually interested in reading on this: limo.libis.be/primo-explore/…
 
melon
 
I suppose "summary" was a stretch. I guess it made more sense to me than all the other papers I was reading at the time, but a summary, it is not
 
1:26 PM
@Kevin When you say 'calculate distance', I presume you mean Euclidean (or great-circle, or whatever). A faster heuristic is to only calculate distances for those subset of neighboring points that occur within a bounding-box, and set other ('further') distances to +Inf. This should be equivalent to A*-search with a somewhat pessimistic heuristic. Obviously you tweak the bounding-box size so that each point has several neighbors with finite distances. (i.e. Juneau, Honolulu must be reachable)
 
Good idea. My O(N^2) nearest neighbor search takes like a minute to run so it's annoying to experiment in that design space.
 
To be pedantic... the exact opposite of "dire", I believe, is "not dire".
 
1:43 PM
Also "erid", "qver", "ǝɹᴉp", and "dire [but as white text on black background]"
Here's the route as calculated by nearest neighbor search.
 
Mmmm, yeah, you could probably squeak out another 5% or so, maybe as much as 10%
Every time the path crosses itself, there is a likely reorder that will reduce the path.
 
1:59 PM
How about... [I slide you $20]... a 90% improvement
 
2:12 PM
@cs95 And here's another antipattern in pandas, see this undervoted correct answer. Pandas to_string() now supports a column-specific dict of formatters, e.g. for custom currency columns. Also since Pandas 0.17 (2015) there is now a CSS styling system.
...That question's highest-voted answer is now 4+ years out of date and woefully wrong. Think of all the memory people will waste creating crappy custom-formatted strings on a large df. Ouch.
 
cbg \o
 
Lol, the curl off-topic made it into an SO newsletter. Flagship question.
 
2:28 PM
Nothing conveys "advertise with me" as well as "This question exists because it has historical significance, but it is not considered a good, on-topic question for this site"
 
@Kevin how about tears the $20 bill in half a $10 dollar improvement? looks down at the half torn bill ...o wait.
Perhaps, do a clustering, and a bruteforce of best paths within each cluster, and just join them all up?
 
in some (most?) places you can exchange partial banknotes for partial value
 
@Andras yeah... a mod noticed that earlier and pointed it out to the CM's :)
 
I hope the obvious solution will not be to unlock it :P
 
Common Internet Wisdom is that American banks will exchange 51% of a mangled dollar for a fresh dollar of the same denomination.
Like all Common Internet Wisdom, it has about a 50% chance of being true
 
2:41 PM
hmm, that would sound like a system that can be abused
the remaining 49% can be made part of another 51%
From 3 banknotes you can put together 4*3/4 banknotes, each 75% converted into a full dollar. Profit!
 
Hmm, true. What if the bank only accepts pieces where the serial number is still intact? Then you can't combine partial banknotes.
 
That could work, but an average 51% part might not contain it at all. Unless there are a lot of serial numbers on a banknote, but that would also defeat the purpose a bit
 
I've actually returned a mangled dollar for a new one when I was a kid. But the note has to obviously contain more than half of the original note.
 
A random person on the Internet says: "You must have MORE THAN 50% of The bill so in other words it must be at LEAST 3/4ths of the bill intact for a bank to accept it." You heard it here, folks: there are no real numbers between 1/2 and 3/4.
 
When I was a kid, the local supermarket ran some bizarre promo where you could get 10p off any tinned food if the tin was dented.
 
2:47 PM
10 pound off tinned food ? how much is a tin can ?
 
p is pence
 
@roganjosh did they suddenly end up with a load of dented tins coming to the counter? :p
 
@Kevin ouch
 
But you can imagine, I assume, the result. Everyone bashing tinned food on their trolleys
 
5/8ths is a myth invented by the lizard person shadow government, don't believe their lies
 
2:48 PM
@roganjosh reminds me of Twoflower on the Discworld, betting innkeeps in Ankh-Morpork that their establishment will not burn down
 
-mental image of canned food exploding when being bashed too hard-
 
@JonClements My grandfather was amazing at finding these tins. I can't tell you how many times I was sent to the counter
 
@AndrasDeak after selling them "in sewer once" or whatever it was in the books...? :p
 
yup :P
maybe ants, or something
 
I'm not familiar with the books but I can imagine :)
 
2:51 PM
Ok, the Common Internet Wisdom is actually true. I don't see any provisos about serial numbers or anything, so I guess you could get infinite money this way, but claims can take 36 months to be resolved so you're not going to be able to double your investment too many times before you die of old age.
 
I'm going to apply Banach-Tarski to dollars and profit.
 
perhaps monster-of-Frankenstein-esque patched abominations are forbidden
@piRSquared ha!
but for that you may have...to choose D:
 
On second read, "sufficient remnants of any relevant security feature" might be bureaucrat-speak for "serial number or equivalent"
 
Sam
I've got a custom class in which I've overridden the _add_ method to handle class + class addition. Suppose I have a list variable store = [] which holds an arbitrary number of these custom class instances. How should I add them all up to obtain a result? My initial thought was to use the sum() function but I'm greeted with a TypeError
I assume sum() starts with an int
 
@Sam does it work if you add a start?
sum(iterable, start=0, /)
    Return the sum of a 'start' value (default: 0) plus an iterable of numbers
otherwise you probably need functools.reduce?
yeah
if initializer is None:
    value = next(it)
^ from reduce docs
 
2:55 PM
Does it make logical sense to support class + int addition, even in contexts other than sum()? If so, you could implement that and I would expect sum() to start working even without a start parameter.
 
Sam
@AndrasDeak I was unaware of this, looks like it does the job! Thanks. Specifying the start parameter fixed this
 
good, good
 
@Kevin I do this very hack in pyparsing, implementing __radd__ to support int + class (not class + int), if the int is 0, just return self
 
class Thing:
    def __init__(self, x):
        self.x = x
    def __add__(self, other):
        return Thing(self.x + other.x)
    def __radd__(self, other):
        if isinstance(other, int):
            return Thing(self.x)
        else:
            raise NotImplementedException

seq = [Thing("Hello, "), Thing("World"), Thing("!")]
print(sum(seq).x)
#result:
#Hello, World!
 
should it not return NotImplemented?
 
2:59 PM
shrug
 
Probably raise TypeError - also, narrow it to only accept int value of 0
 
00:00 - 15:0015:00 - 00:00

« first day (3146 days earlier)      last day (1805 days later) »