« first day (2865 days earlier)      last day (2083 days later) » 
00:00 - 19:0019:00 - 00:00

12:15 AM
Did they change how links look on SO recently?
 
@user3483203 ?
 
Yes, everything has a <u></u> now
I think it was an a11y change
 
I dislike it, everything's underlined on my machine now, just making sure it wasn't just me
 
45
Q: Underline in [`code`](links)

ImportanceOfBeingErnestApparently links are now underlined. While I'm personally not a big fan of this, this seems to be a design decision. However, code in links is underlined as well. This makes it rather hard to read. Use this command or use this_command Use [`this command`](https://stackoverflow.com/) or u...

 
it doesn't look nice, granted, but it makes the site more accessible to people with partial color blindness, I think, so I don't really know if I want to complain
 
12:33 AM
no it does not @coldspeed (oddly enough)
there is an overall lack of high contrast on SE/SO, so userscripts and extensions have to be used to use it at all and it breaks those (mine at least)
 
12:48 AM
@JGreenwell did you see this implementation of the fibonacci sequence in Haskell?
fib@(0:tfib) = 0:1: zipWith (+) fib tfib
I think this is the same in Python:
from itertools import tee

def fib():
    yield 0
    yield 1
    # tee required, else with two fib()'s algorithm becomes quadratic
    f, tf = tee(fib())
    next(tf)
    for a, b in zip(f, tf):
        yield a + b

[f for _, f in zip(range(999), fib())]
 
Moral of the story: python makes it harder to write unreadable code than haskell does
 
Haskell can do the recursion indefinitely: length $ take 1000000 fib
Python runs out of memory for frames on its frame stack...
 
I know very little about Haskell, but the infinite length data structures definitely are interesting
 
that was too many zeros I think...
 
1:11 AM
yep that was one of them :)
 
1:27 AM
stackoverflow.com/questions/51923001/… tired duplicate, 4 answers all upvoted + accept
 
that's like the 4th or 5th question like that I've seen this week...summer vacation is definitely over.
 
Oops, that was an answer, I meant stackoverflow.com/q/51923001/4909087
3 starred comments on Haskell... guys this is the python room :p
 
we takes all kinds
@coldspeed the comments on that question and the answers are interesting
should probably flag the comment that calls all the established users jerks but I bet it would be ignored
 
 
1 hour later…
2:50 AM
if anyone is interested, I'm streaming on twitch: twitch.tv/codeguur42
 
Says channel doesn't exist :S
 
I can't spell apparently
if anyone is interested, I'm streaming on twitch: twitch.tv/codeguru42
 
@Code-Apprentice haha, awesome
 
 
1 hour later…
4:15 AM
@EnderLook I used defaultdict before and that's how I'm getting that piece of code running 16 hours to get results
 
 
3 hours later…
7:11 AM
cbg
 
cbg @AndyK
 
@ReblochonMasque o\ Sir
 
You started at your new job already?
 
@ReblochonMasque not yet, mid-September
 
ok, cool, enjoy your holiday then :)
 
7:17 AM
@ReblochonMasque nah. still working at the current company until mid september too. Relax for a few days and next gig is coming
 
ah, ok, I thought you had moved to Paris already.
 
seems that this "be nice" has now transferred to Github too... :F
 
@ReblochonMasque still in my town in province
 
haha, you are missing out on Paris in August... the best of times there while everyone else is away @AndyK :D
 
@ReblochonMasque ha ha. tell me about it. I was raised and lived most of my adult life in Paris. Paris is the best in August
 
7:25 AM
@WendyVelasquez wat, how big is your dataset? :D
 
Not that I'd understand what exactly those numbers mean
 
well I don't yet either
still, even for 51k * 250(avg) I'd doubt it would take 16 hours, unless, "it's pandas"
 
 
2 hours later…
10:00 AM
@coldspeed probably just some haskell fanboy being excited
 
cbg
 
cbg
 
Minor niggle: is there a reason that dupe flaggers don't get acknowledged when a question gets dupe closed?
 
yes
because even more reasonable and supported feature requests have historically been ignored by the powers that be, because we're so community except they don't give a yam
 
:(
 
10:12 AM
such as "inform hammerers that their closure has been unhammered" or "inform close voters that the post has been edited"
 
Just seems a little unfair because it was a new user that did the work in finding the dupe, I just converted it to a close and their contribution is lost
 
It's not a contribution per se. Nobody gets a pat on the back for throwing out the trash (this is not to say that dupes are trash)
there have been multiple suggestions for incentivising dupe closure, like giving rep for finding dupes or denying rep for answering dupes
 
Denying rep would be a tough one, some dupes do not translate cleanly (like, easy to miss with reasonable searches) but I don't think it's a bad idea to reward low-rep users for finding dupes
 
I advise you to look at meta feature requests that are status-completed and see how many high-scoring ones are substantial when it comes to site moderation
retracting flags is one of the few exceptions
and that also doesn't change site mechanics at all
 
Cabbage.
 
10:16 AM
cbg
 
"unstick new nav bar" was first rejected but then we were finally graced by the stack angels
 
@PM2Ring I don't think you could have made a more balanced and persuasive argument than you did, so I guess it's just not going to happen
 
then there's the puppy's request for the room owner kickban feature, probably the first real feature implemented that I've seen in the list of questions sorted by votes (that was in 2014)
 
10:33 AM
The focus really does seem to have gone more wonky than normal recently
I'm not sure my minor niggle would be much more difficult to solve than all the UI changes. Now the upvote button on comments is irritating me, plus the perfectly valid criticism of underlining links
I can only imagine it would take an extra query to link the flag to the close votes - the flagged dupe is already in the suggested dupe list when you go to close
 
Not giving low-rep users any recognition for dupe-flagging is a little unkind to newbies, IMO. ;) OTOH, being mentioned in the dupe-close box is a dubious privilege, since the OP may not be happy that you've helped to close their question. And rep-farmers have just lost an opportunity to score upvotes, so they aren't happy either.
 
mmm, that's an interesting perspective. But does that imply that the purpose of naming people in the close box is to give the OP someone to argue with?
It makes sense with hammerings, but not so much when it's just 5 normal close votes
 
it's all about accountability
 
10:49 AM
Yeah, I think I've been looking at it through a distorted lens.
Ok, I settle on giving rep to low rep users for finding dupes on my never-to-be-realised wish list :)
 
awesome, thanks
must be hard to implement something this horrendous
 
I just wonder why it was even included in the pep if it doesn't work..
well, the whole pep does a mediocre job of selling the feature
 
it's the other way around: the PEP is the specification...
the reference implementation is buggy
 
 
2 hours later…
1:15 PM
I actually like when my name appears on a "on hold" or "closed" box due to flagging as I did vote something and like to stand by my decisions (whereas if I flag but it is closed due to close-votes I just get a hard to find helpful notice in my profile)
Note, if they did dup finding like editing (can only suggest and give rep only up to 2k) then I would easily be at 2k by now but I'm not in it for the rep
 
I think dupe hunting deserves more reward than suggesting an edit. And the rewards should be given to all dupe hunters, since we want to give rep-farmers an incentive to dupe-hunt instead of answering obvious dupes.
 
Question for regulars: Do we have anything linking to "how do I post long bits of code in chat/SO?" - besides the link to dpaste on the chatroom tab
@PM2Ring I agree, just last night there was a duplicate which was FGITW answered by 4 people (including 2 1k+ users) and then when downvotes and dup flagged started complaining in the comments about it
 
Of course, we don't want to reward people who post bad dupe suggestions, but I think the usual dupe close-voting process can handle that. Or maybe that would need to be expanded a little so we can give up & down votes to the the various suggestions, and with the people who found the dupe target(s) that are finally selected getting the most reward. But I guess we don't want to make it too complicated. ;)
 
@JGreenwell as you said, dpaste
 
1K+ is nothing. There are plenty of people with over 10K and even 100k who regularly answer dupes and who get indignant when criticised for doing so.
 
1:30 PM
Last week I remember 1 dup target which I sorta didn't agree with (was okay just thought there could be a better one, had three targets, and that just required comment and discussion to fix). I saw more than 50, I swear 10 of them were the same question
yeah, I've seen that too (heck, I do it sometimes when I see a question that is at least well-written but I don't complain when downvoted and try to remember to delete answers which just repeat the dup)
@AndyK Thanks, I didn't think I was missing a link anywhere but wanted to check
Also, if I added Visual Studios to best Python IDEs would I be hanged at dawn or just firing squad? (seriously, using it now and its actually good)
 
\o cbg
 
cbg
 
1:48 PM
I can't help but be erked by this comment /shakeshead
Good effort! I will keep jezrael's approach who is the geek of Python in every of my question :P — Apolo Radomer 1 min ago
 
brb work tower finally started to cause issue. time to restart in over a few months of sleeping. maybe I'll call it a mini vacation for the tower
 
@piRSquared Speaking of high-rep users that have a track record of answering obvious dupes. ;)
 
2:02 PM
Yet another satisfied dupe-hammer customer:
Got it up and working! Thank you all for your help!!!! — Jason 56 mins ago
 
@PM2Ring more importantly, that user is fooled by the rep # and volume of answers as a proxy for authority. And whomever else comes along and reads that and is swayed to think the same.
 
import urllib.request, json

with urllib.request.urlopen("http://youtube-scrape.herokuapp.com/api/search?q=taylor+swift") as url:
  json_results = json.loads(url.read().decode())

print(json_results["results"]["0"]["video"]["title"])
I have a question about this program
All the examples say I can use string values in the list indices (I am trying to find nested values in json code)
But I always get ValueError
Can anyone help me with this issue?
 
You can use string values with dictionaries not with lists
 
So where am I going wrong?
 
That's unusual. If you were indexing a list with a string, I'd expect TypeError. If you were indexing a dict with a string and the string wasn't a key in the dict, I'd expect KeyError. It's curious that you're getting a ValueError.
 
2:09 PM
Oh yes typeerror
Sorry I mistyped
This is the program for your reference: repl.it/@xMikee/YouTube-Search-Results
Any suggestions?
 
print(json_results["results"][0]["video"]["title"])
 
morning cabbage
 
Ok I will try that
 
json_results["results"] evaluates to a list. Lists can only be indexed using integers. "0" is not an integer, but 0 is.
 
It worked! Thank you!
I feel stupid for not figuring that out
 
2:13 PM
Understandable. Working with json can be a bit overwhelming if you're receiving a large and complicated object.
 
Oh, interesting. The way Firefox renders that json data, there's no way to tell whether any particular level is a list or a dictionary that just happens to use only digits in their keys.
Lesson: examine the data in a format that eliminates any possibility of ambiguity. Like json.dump()ing it to a local file and reading it with a text editor.
 
@Code-Apprentice i enjoyed the twitch stream last night, have never used that site before but have heard tons about it
 
Yes, I noticed that Chrome does not format like Firefox does.
 
@W.Dodge thanks. I'm trying to stream at least once a week
for now it will be all Android and Java, but I might find some python project to work on in the future.
 
2:17 PM
@Kevin I just used the pprint module.
 
@Kevin you can guess from the fact that it is sorted numerically, not lexicographically ;)
 
^ not always
 
well, yes, "is 0, 1, 2, 3, 4 sorted numerically or lexicographically" => "yes"
 
@Kevin firefox doesn't render a list with [] and a dictionary with {}?
 
@Code-Apprentice in the json view
 
2:19 PM
nope
 
@AnttiHaapala lol
 
I don't have FF installed to check it out myself.
 
@Code-Apprentice it renders, unlike chromium which blurbs line noise...
 
@Kevin Weird. In my ancient Firefox, it uses [] and {} appropriately. But maybe that's because of the JSON plugin I use.
 
2:21 PM
That's a screenshot
 
@connectyourcharger add ?.jpg
at the end
 
it automatically redirects
 
ha :D
@connectyourcharger just use the upload button, it will upload to imgur
 
This is my program so far, I'm going to add a search functionality soon: i.snag.gy/a4eqsd.jpg
 
Take a look at JSONView
 
2:25 PM
Is there a module that will convert a string to its "url version"?
 
urllib
 
DSM
Monday cabbage for all.
Did I miss the "I'm using exec because of X" part of the conversation?
 
cbg, DSM
 
Nope, the exec is a surprise to us all
 
exectly
 
2:27 PM
@connectyourcharger well in Python there is no "url version" :F
 
url encoding?
I guess
I don't know how to word it
 
As Taylor herself would say, haters gonna hate
 
urllib.parse more specifically is what you might need
 
@connectyourcharger You could skip using exec and just do print("{}. {}".format(item+1, json_results["results"][item]["video"]["title"]))
 
but it produces silly namedtuples instead of something semiopaque
 
2:29 PM
Or perhaps print(f'{item+1}. {json_results["results"][item]["video"]["title"]'), if you're using an up-to-date Python version
 
really? last time I used this I used urllib.quote: python -c "import urllib, sys; print(urllib.quote(sys.argv[1]))" foobar
but then I just wanted something quick so I didn't really look around in the library
 
DSM
I suspect it'll be easier for cyc to give an example of what he's looking for rather than for us to guess what 'convert a string to its "url version"' means, given that apparently we can't even agree on which direction he wants to go. ;-)
 
So for example a user inputs "taylor swift" and it's stored in foo
Convert foo to "taylor+swift" so I can append it to the url of the YouTube parser and get the json data
Am I being confusing?
 
>>> import urllib.parse
>>> urllib.parse.quote_plus("Taylor Swift")
'Taylor+Swift'
(the exact module you need to import will vary depending on what version you're using)
 
Thanks! Actually just found that on another stackoverflow question
 
2:41 PM
@connectyourcharger pprint is ok, and its output is compact, but I think json.dumps with indent=4 gives nicer looking output.
 
You can search for anything and it will give you search results from youtube
 
@connectyourcharger BTW, you might find my code here useful when you need to explore deeply nested JSON: stackoverflow.com/a/41778581/4014959
 
Rule of thumb: 99.999% of the time, you don't need to use exec for anything. If you're thinking "how can I tell whether I'm in the 0.001%?", you aren't.
 
@connectyourcharger Even better, use the 3rd-party Requests library, and let it build the query URL for you. ;)
 
wim
3:04 PM
@AaronHall what is the point of the tee there, I don't understand?
def fib():
    yield 0
    a, b = 0, 1
    while True:
        yield b
        a, b = b, b + a
I thought a Python fib would be like that ^
 
@wim not recursive
 
wim
ohhh ok
 
And NameError ;)
 
Now there's a new one - a recent question posts its code not as an image, but as a youtube video.
Incidentally I always feel vaguely guilty when I post a comment telling OP how they should change their post, when I know full well that even adhering to all my suggestions will probably not improve the likelihood of them getting an answer
e.g. posting "please supply your code as text, not as a youtube video" when the problem involves curses and a raspberry pi library, which means the number of people that could reliably replicate the problem is approximately zero anyway
 
Ideally such a request would involve [mcve] from which they should suspect that posting all 5000 lines would be insufficient
ah, I thought you meant the size of the code
 
3:19 PM
Even good questions go unanswered sometimes. So it goes.
 
cabbage
 
cbg
 
cbg
 
Is an answer technically wrong if it does not include an import statement for a library not included in the question?
 
I don't downvote if that's the only problem in an answer, but it's a big factor when deciding whether to downvote an already questionable answer.
 
3:29 PM
not really, and you can add that yourself (or someone with 2k rep)
 
If it's a part of the standard library, I don't think a DV is warranted. If it's some third party library there should at least be an explanation.
 
That makes sense
 
DSM
Certainly in the numpy and pandas tags we don't always add import numpy as np and import pandas as pd, esp. when the original post was already using them.
I think we'd have to mention the imports if they weren't used, though.
 
unless it's something esoteric like import pandas as big_black_and_white_balls_of_fur
 
ok, I saw chain.blahblahblah the other day and it took a sec to figure out where chain came from
@AndrasDeak LOL
 
3:33 PM
the reason for that is probably stdlib
I might skip the import but then use itertools.chain to be explicit in that situation
(but I mostly always include imports)
 
DSM
chain is a borderline case. Everybody who regularly does Python will recognize which stdlib module it's coming from but I wouldn't necessarily expect a beginner to. I'd probably add the import if the question wasn't already in an itertools context.
For example, if I want to borrow some networkx functionality because a problem has a graphy solution, I can't just do nx.whatever.
 
I'd know that one!
 
It seems like when the youtube scraper scrapes the search results, it returns undefined values if a result shows a channel instead of a video
 
"undefined"?
 
Trying to figure out how to emit that, but I'm having trouble because it's in json, not a python list or dict
 
3:35 PM
Is this JS now? :P
 
hang on lemme show you
 
Or literally "undefined" perhaps. JSON has "none" or something, right?
oops, "null"
 
Look at entry 16
See how there is no value?
 
there is
it's an empty string
 
That (I think) is where a channel card would come up
 
3:37 PM
rb folks
 
rbrb, Andy
 
It is still displaying on my program
 
oh you mean the url
there's even a slash missing from the url...are you sure that's not a bug someplace (JS) else?
 
Look at number 17
 
@connectyourcharger one more screenshot and I'll burst an artery in my brain
 
3:38 PM
lol
 
you still have exec in that monster
 
Yeah I'm still cleaning it up
 
I'm not sure I see the problem. If the title can be empty signalling a problem, handle an empty title separately.
 
lemme go back to work, see what I can come up with
 
sure thing
 
3:44 PM
@AnttiHaapala I was using a list of lists of lists and that took me 16 hours to ran it. with pandas I cannot get all the data together, and it takes 7-8 hours to run it
 
DSM
Often when people say their code takes a day to run and their dataset isn't at the terabyte level it's a sign they're using the wrong algorithm.
 
@Wendy to move forward you'd have to come up with a proper MCVE: a small example that looks just like your problem. Few items along each dimension, complete with ordered stuff you're missing, complete with raggedness which breaks numpy. And an expected output or other requirement you want to do. It won't be quick nor easy, but you have to do this.
 
indeed, that's my thinking
 
and by proper I also mean something I can copy-paste into my python shell to play with
 
well, you don't have to but if you'd like to get anything more specific than "you're probably using a wrong algo"
 
3:46 PM
I started with "to move forward" :P
 
well, yes.
 
granted it is fun when you're proud of your code only taking hours to run
 
at this point I'm really not sure why it the youtube parser returns blank values
There were three in a search for "jake paul", but only one channel card on the first page
 
@connectyourcharger the question is: do you have all the legit hits? Because you can always ignore overnumerous empty hits
or look at it this way: if the title is empty and the url is https://www.youtube.comundefined [sic], you're not going to do anything with it anyway, so skip
 
I put an if statement in the range loop that prevents blank values from being printed
But I have run into another problem
Now the numbering is off wherever I skip an empty value
 
3:53 PM
use enumerate over an appropriate container, probably json_results["results"]
 
example?
 
also that naming of json_results["results"] suggests that your naming is off a bit
 
I'm not following...
 
for item,result in enumerate(json_results["results"]):
    title = result["video"]["title"]
    if not title:
        continue
    print(f"{item+1}. {title}")
 
Might make sense to create a new list, which you append non-empty titles to. Then you can iterate through that and print them and their numbers.
 
3:56 PM
(done, I think)
 
@AndrasDeak Yes, but then there's still the possibility of nonconsecutive numbers. Ex. if the titles are "foo", "", and "bar", then the output is "1. foo" and "3. bar" when the desired output is "1. foo" and "2. bar"
 
but yeah, doing the filtering in a separate step might prove useful
@Kevin oh, I see, I misunderstood/misthought
in that case just loop over the results and increment a counter...
 
Yeah I'm still getting the breaks in numbers where the empty values were
 
(I'm OK with obsolete as I expected the word to be non-existent)
 
Although this time I got more values
Probably something with my numbering being off before
 
3:58 PM
i = 1
for item in json_results["results"]:
    title = item["video"]["title"]
    if title:
        print("f{i}. {title}")
        i += 1
Here's the "manually increment a counter" approach
 
"f => f"
 
It didn't format anything
 
Oops, misplaced the f
 
It just repeated "f{i}. {title}"
 
@connectyourcharger you need to read, understand and try rather than just copy-paste typos
 
4:01 PM
Mm hmm, self experimentation is very important in programming
 
That's odd, that string should format
 
did you fix the f-string syntax?
 
The strength of coding is that the cost for screwing up is very minimal. As compared to, say, carpentry, where you lose out on a nice birdhouse and/or a thumb
 
@connectyourcharger It will, if you do it like this: f"{i}. {title}"
 
Ah, yes
Sorry, I've actually never used that type of formatting before
I always just do "foo {}".format("bar")
 
4:03 PM
Feel free to use what you're comfortable with. The f string isn't really central to the idea I'm trying to impart anyway
 
F-string formatting only came in with Python 3.6, so it still seems new to those of us who've been writing Python for years. And because it's new, we're more likely to do little typos like that.
 
Ok, it worked now
Thank you all!
I wish that you could hyperlink in the console
I know you can't, but it would be a nice feature
 
@connectyourcharger You can, if you have a good console.
 
Time to write your own shell that can ;-)
 
In KDE's console (which is named konsole), URLs get underlined. If you click them, they open in the default browser.
 
4:05 PM
haha
 
@connectyourcharger how about i.snag.gy/dZIK3W.jpg?
 
cabbage
 
cbg
 
no, the online console does not
and it now properly numbers
 
s/never/never before today/
 
4:07 PM
@Kevin oh, that came from a regular here too? Figures. My "read and only then use" suggestion was too late it seems
@connectyourcharger seriously, stop with the code screenshots
 
alright alright
 
I was never able to make much conversation with tensors... they're always so tense
 
@wim Or get rid of the yield 0 and do yield a in the loop. Ifyou want to see fast recursive Fibonacci, check out my fast_fib. It's slower than the standard iteration for small numbers, but it's great for n>1000. And of course the cache makes it very fast if you need lots of big Fibonacci numbers.
 
Is raising a NotImplementedError still the best (quick) way to emulate an abstract or virtual method?
 
@JGreenwell From the docs In user defined base classes, abstract methods should raise this exception when they require derived classes to override the method, or while the class is being developed to indicate that the real implementation still needs to be added.
 
4:20 PM
Thanks, I knew that was somewhere but couldn't for the life of me find it.
 
@AndrasDeak I might be a bit new, but what is MCVE? the structure is very similar to what I posted stackoverflow.com/questions/51888101/… the only part is the length of parameters and Values that is longer and an uneven number. in the example I have 12,
@AndrasDeak but in my case is 19 to say a number so 19 has to be divided so all parts have equal number of lines (parameter and value), I just realized that if I take it as an even number I either will have to leave one group/part with more lines than the others or truncate a couple of lines (so that gets more complicated).
@AndrasDeak As I said before I can merge values and parameters easily as they both correspond in size (51K =51k) but not the part as they must be alternated every 200+ lines just like in the example in the post.
 
@WendyVelasquez See MCVE
 
and your example in your question seems confusing to me to say the least
And honestly your last 2.5 messages don't help clarifying. That's why I suggest an actual runnable example.
 
@WendyVelasquez an MCVE should enable me to copy and paste into my environment and have the variable names you are working with.
 
@AndrasDeak I'll edit the example then. so it will be clearer (hopefully)
 
4:30 PM
If I can't copy and paste your code and immediately see what you are talking about then it is not an MCVE. Let us know when it is edited.
 
Don't rush, make it a proper MCVE as I suggested, otherwise we'll be none the wiser.
 
sure, will do :)
is for my own good anyway
 
if you make your question answerable everybody wins ;)
 
wim
Nice site, drop in your Python2 project's requirements.txt and it tells you what's blocking an upgrade (if any)
 
4:32 PM
@wim sounds like a good tool to handle out paddlin's
 
Wendy, you are familiar with your data, and the processes that you want to perform on it. We are not. And although we've written lots of code, and processed lots of data, it can be hard to understand someone else's problem when you just have an abstract partial description of it. So if you can give us an MCVE then we'll have something tangible we can play with and modify. And then we will be much more likely to understand what you're talking about. :)
 
@AndrasDeak @ PM 2Ring this is a really nice way to start my week :) ... very encouraging I'll work on that
 
you're welcome ;)
 
@PM2Ring done
 
4:48 PM
huh, congrats on 20k Chris ;)
 
Thank you! :)
 
and you nicely hit exactly 20k
 
I was at 19,999 when PM posted, so I undownvoted some answer from a year ago :P
 
lol :D
+1 for the badge
 
Classic. :)
 
4:54 PM
wait I thought undownvotes of answers > 1 day don't actually result in rep gain
 
sure they do
rep is only stuck after 60 days on high-scoring posts
it's that you can't unvote something after an hour or so unless it's edited in the meantime
 
I've undownvoted things in the past only to see that +1 disappear into the void
 
did you wait enough for caching to kick in out?
 
must be some weird circumstances that I can't repro
 
takes a few minutes for things like that to show up
 
4:58 PM
yeah, possibly that
 
or perhaps you downvoted something at +3 or higher which may make the rep stick, I'm not sure
 
I blame caching for everything I can't explain
 
5:47 PM
My coworker is chuckling at something on their monitor. I am annoyed that he's having a better time slacking off than I am.
I think it would be poor office politics if I asked him to send me a link
I bet it's a humorous cat picture of the highest quality
 
@Kevin not if you ask them nicely, like "What's so funny?"
 
"Care to share so the whole class can have a laugh?"
 
@Kevin just start LOLing as payback, test co-worker response in the process
 
I'm not sure that's the game-theoretically optimal choice because if I was chuckling at my monitor I'd prefer that everybody else pretend that they didn't notice so I can enjoy my cat memes in peace
 
6:23 PM
WTH... I keep getting 'return' outside function error on this... Do I have a function here? Literally nothing is even indented here. What am I missing?

import pandas as pd
from lxml import html

myDir = 'c:/Users/Chenry/Desktop/Temp/JPMCC14-DSTY/'

url = myDir + 'Data/' + 'Loan_PhaseI.htm'
xpath = "//*[@id=\"PropertyFinancials\"]/table"

tree = html.parse(url)
table = tree.xpath(xpath)[0]
raw_html = html.tostring(table)

dta = pd.read_html(raw_html, header=0)[0]
ret = [x.split(',') for x in dta.to_csv().split('\n')]
Loathe to open a question for this
 
You are correct that you don't have a function. That's the problem; return can only exist inside a function.
So... Either stick all of that inside a def, or delete that last line, or change it to print(ret) or something
 
DSM
Since you also don't call the function you don't have, I'm not sure what you want return ret to do.
 
sorry, thanks Kevin. indeed, I'm just trying to print it
 
DSM
It's also a little strange to read an HTML table into a dataframe, then write that into a csv, then split that csv using string methods to get the values as a list of lists.
 
I'm using this inside some org-mode source block to pass to another source block later... I think I inadvertently mentally identified this as returning something to org-mode... clearly that's not what my "return" meant
I assumed that was out of necessity, again because I'm using python in org-mode. I lifted that code from this post: emacs.stackexchange.com/questions/28715/…
 
wim
6:29 PM
Worth a read: HTTP/2 explained. From author of curl.
 
Some languages let you use return to specify the exit code of the process when it terminates, so it's not too crazy to think that Python would do the same
 
In fact, that emacs post I linked uses return... and I'm fairly certain that the code worked at some time, but prefer to use print for best practice
Thanks again!
 
DSM
Using org-babel for code stuff is a little unlike usual Python because of the preprocessing it does. Probably return did work originally, in a non-session environment.
> :return: Value to return (only when result-type is value, and not in session mode; not commonly used). Default is None; in non-session mode use return() to return a value.
> Also, in non-session mode, the python code block will be wrapped in a function, so to return a value (in :results value mode) you have to use a return statemen
 
All bets are off for weird environments
 
00:00 - 19:0019:00 - 00:00

« first day (2865 days earlier)      last day (2083 days later) »