« first day (2175 days earlier)      last day (2777 days later) » 

6:00 PM
I got a response, but I'm on mobile, someone onebox it.
 
Zed never really bothered me before because... whatever, bad books are out there. But the fact that he's charging $30 for this and it's so deficient 'elevates' him to bad-guy level. This isn't about being a poor educator, it's just lazy charlatanism.
 
you made him very angry
 
And then come up with the best way to point out how awful the py3 statement he links is.
 
@zedshaw on learning: read my book about learning Python a hard way, but don't learn Python 3 because it changed and learning is hard.
 
@davidism Oh hey look at this https://learnpythonthehardway.org/python3/ It's a giant bag if STFU. 🖕
 
6:03 PM
And if STFU is false, then what is it?
 
uhh then it's NOT a giant bag
 
Heya, playing with threading a bit and I am slowly working a couple functions I have into being threads ( makes what I am doing SOOO much faster ) ... Thing is a couple of these functions return some variable to then let another function manipulate it... When I run the function as a thread does the "return" still happen after the thread is done executing?
 
I might just go with "actually just paraphrasing from that page you linked."
 
Might want to throw on a ", but ok" for good measure
 
Maybe throw in a friendly emoji.
 
user559633
6:08 PM
lol at twitter and the likes being the hivemind of SO
 
user559633
@davidism And what I actually said is nobody uses Python 3 because the transition was a disaster so learn 2. Now piss off.
 
wim
You should ask why the python3 version writes "For example, are you trying to use Python 3 for this book? I said in Exercise 0 to not use Python 3, so you should not use Python 3."
what a pile of shit, zedshaw seems like douchebag #1
 
Nah, it's alpha, that's an easy one to dismiss.
 
user559633
when did he write that nobody uses python 3?
 
user559633
i could see if that was originally penned 4 years ago
 
user559633
6:11 PM
not a single place that i've worked that is built on ruby on rails uses python. nobody uses python.
 
wim
someone hack his domain
selling this shite is abominable
 
hey, c'mon
 
@tristan lol:D
that almost looks like one of those fixed xkcds. fixedshaw
 
user559633
@wim official stance and my opinion: no no no. no. also, no. did I mention no? don't do this. breaking someone's shit because you disagree with their opinion/stance is not something allowed here.
 
hello, can someone please give me an idea to detect and redirect user's language (/en/, or /ru/) just like LocaleMiddleware from Django does? I'm new to Flask
 
6:20 PM
@ezdookie I know how to do it in WebOb/Pyramid :/
 
user559633
@ezdookie having not used localemiddleware, does it just rely on HTTP_ACCEPT_LANG?
 
@ezdookie Flask-Babel
 
@tristan yes
 
@davidism does it do tha?T
@wim WOW I am not the #1 any longer :D
 
user559633
Sorry, ostensibly it's HTTP_ACCEPT_LANGUAGE. You can use some plugin or just look at the headers with request.headers.get('HTTP_ACCEPT_LANG') and redirect (there is probably a convenience function for this specific case though)
 
6:21 PM
party!
@tristan does werkzeug really call them those hideous HTTP_foobarbaz?
 
user559633
@AnttiHaapala idk, i assume it's just the name of the header key. it's been a while since i've done anything with flask besides just having it work in the background
 
.@zedshaw actually referring to that link; statement at top seemed contradictory to subject. Thanks for responding, that cleared it up. 🌈
There's my one response. No more.
 
DSM
In [39]: unicodedata.name("🌈")
Out[39]: 'RAINBOW'
TIL!
 
user559633
from twitter import drama
 
@davidism you're my hero now :D :D
I will build an altar for worshipping davidism...
 
@AndrasDeak @MartijnPieters did write that as well ;)
Sep 14 at 11:36, by Antti Haapala
inhale, exhale, go... breath first search
 
oops, smiting imminent
 
user559633
 
@tristan how did you know :D:D:D
I am on couch though
 
@davidism Winning
does anyone know of a nice way to write...
 
user559633
6:30 PM
@WayneWerner calligraphy.
 
user559633
don't act like you're not impressed
 
with long_named_thing_i_cant_change(thing) as new_thing, another_thing(stuff) as new_stuff, cool_things(blargle) as new blargle:
I don't like the `` approach
 
@WayneWerner
vietnamese calligraphy is like chinese, but using latin letters <3
 
with long_named_thing_i_cant_change(thing) as new_thing, \
       another_thing(stuff) as new_stuff,\
       cool_things(blargle) as new blargle:
 
I see the latter as perfectly readable. It's obviously too long for one line.
 
6:33 PM
@WayneWerner no.
 
user559633
And Caligula is like calligraphy, but instead of fancy writing, is a nickname given to Gaius Julius Caesar Augustus Germanicus, the Roman emperor.
 
there is no other...
and the `\` needs double \
 
user559633
What a world we live in. What a world.
 
ah...
 
user559633
x = long_named_thing_i_cant_change
with x(....)
 
6:34 PM
@tristan though it was with one L.
 
well.. there is that approach
 
@WayneWerner something like:
 
user559633
Chilligula would be a good name for a bro-version of the story of his life.
 
with m(
     long_named_thing_i_cant_change(thing),
     foo,
     bar) as (a, b,c)
could be possible :/
@WayneWerner how about you just use the stack
 
6:36 PM
Lol he responded again.
 
I just wish you could do with (...) as (...):
 
user559633
just leave a comment at the top and move on? unless this is a part of the codebase you need to see every day, i've never been happy with the time i spent trying to rename things
 
a sec...
 
nah, but it's a pattern I've had been annoyed with more than 3 times now :P
 
There's a user in who FGITWs all sorts of shit, including blatant brain farts and discussed-to-death dupes
 
6:38 PM
@davidism No, it's not. I'm pointing out defects in the design that will change and which are broken for everyone.
 
Zed is mah hero
 
Hehe... his other tweet is pretty impressive, too
 
user559633
@AndrasDeak spidey sense went off that i'd be mentioned around there. ./api/v1/user/methods_old.py:this module is a fucking garbage fire
 
I'm curious who has ever used Python3 and gone, "Nah, I'm gonna use Python2, because I like not knowing the difference between binary and text"
 
I learned on 3 and have never once intentionally used 2.
 
6:41 PM
@tristan ?:D
 
Like... who was that person? Was that Zed? Does he have and afro? Is he the angry Bob Ross?
 
Hello! is anyone familiar with the knapsack algorithm? I'm building up the dynamic matrix for each subset where each row has a fixed weight, and this does not generate the maximum value to schedule the intervals, I tought knapsack would always generate the maximum value?
 
user559633
@AndrasDeak grepped for "rough language" in my codebase. amusingly, that's like the only negative comment in there
 
regarding his other tweet, "davidism But, go ahead and keep pushing the party line that Python 3 is ready. I'll keep helping beginners recover from it.": beginners wouldn't need recovery if he wouldn't push them down into the pit
@tristan oooh, I see:D
 
@WayneWerner
from contextlib import ExitStack

class MultiWith(ExitStack):
    def __enter__(self):
        super().__enter__()
        return self.enter_context

with MultiWith() as w:
    a = w(open('/etc/issue'))
    c = w(open('/etc/passwd'))
    b = w(open('/etc/group'))
 
DSM
6:42 PM
One of the reasons I like 3 so much is that when I first started using it, a bunch of my code broke. Python 2 never pushed back against my coding mistakes, and so I picked up some bad habits.
 
That would actually be a hilarious show to watch - the angry Bob Ross.
Just some guy cursing and swearing and painting with oils the whole time
 
> @zedshaw But, go ahead and keep pushing the party line that Python 2 is the only sane option. I'll keep promoting a language that everything's switching to.
 
Woah, Zed replied? Damn, I should have paid attention.
 
It's gold
 
DSM
He did serve in the Air Force. I don't think of them like they're as angry as people in the Navy, but @JGreenwell would be able to say for sure..
 
6:43 PM
yay internet is returned.
 
@AnttiHaapala Not bad
 
DSM
@ToddLewden: a whole world of cute kittens is once again open to you.
 
In more lighthearted stuff,
 
I appreciate that Python 3 breaks Python 2 programs which only worked because I wasn't getting Unicode input.
 
6:45 PM
@davidism And what I actually said is nobody uses Python 3 because the transition was a disaster so learn 2. Now piss off.
 
Zed's got a bad mouth. The replies could have been more civil.
 
Glad to hear I'm nobody. I mean, I always knew that. But now I learned the hard way.
 
I have a question about text and what happens when it is stored as a variable... The particular scenario is using win32api to open Outlook collect email data and print it to the screen for now. When I just outright do print(item.Body) , it displays in a way that I'd call "Normal" ... If I do "foo=item.Body" then "print(foo)" , it replaces the normal formatting with the formatting tabs like \n \r and \t which I know are returns/new lines and tabs but... Why or rather how does one avoid this?
 
you want to see 'foo\nbar\tthing' instead of the multiline version?
i.e.
 
6:47 PM
@WayneWerner he's referring to that poem by e e cummings
 
foo
bar    thing
 
you could escape the escape delimiter with another delimiter
 
@AnttiHaapala e e cummings or Shel Silverstein?
 
Yes. In this circumstance it'd be best as I am just in the end going to be popping that email text into another email that the script is generating with other info to then be sent to me. So keeping the format would be beneficial , ya know?
Oh @WayneWerner , vice versa to what you said. I want the formatting visible not the formatting tags to be visible.
 
@WayneWerner sorry it was anyone/noone :D:D my bad
 
DSM
6:48 PM
Maybe I'm misreading this. It seems very surprising to me that print(item.Body) does something different than foo = item.Body; print(foo). Are you saying that really happens?
 
yeah that would work
 
@DSM , strangely enough yes lol
 
@ToddLewden If you're sticking the text in another email then just do it
 
@ToddLewden but does it start with b'', eg bytes
 
DSM
@KevinMGranger: the temptation to hand-scribble "Python" over "snake" is hard to resist..
 
6:49 PM
@WayneWerner , lol aye aye
@AnttiHaapala , I don't see any b'' at the start of this
 
@ToddLewden That behavior doesn't sound possible. What is type(item.Body) and type(foo)?
 
But I am going to just forge forward and see what I get.
@QuestionC OHH i forgot about type()! Brilliant!
 
+1 for finding out the type
 
new_email.Body = 'BLah blah blah\nOld email:\n{}'.format(old_email.Body) should work just fine
If not, something odd has happened
 
Wait. Nope. Nope I am just very very very dumb.
*cone of shames himself*
 
6:52 PM
I strongly suspect this is not a problem with python, but rather a problem with the code. You may be going through the 'denial' stage of debugging.
 
@QuestionC , I love finding things I did wrong to improve. I absolutely agree and have evidence to support your claim. I had popped the "foo" into a list "bar" then printed "bar" with "foo" being the only content within it... I have NO idea why I did this a week ago but had you not suggested "Type" I wouldn't have seen it.
So, thank you. I still feel great shame though lol
 
Believing that you have come face to face with logical impossibility is a step in debugging.
I think "Duck Debugging" largely revolves around it in fact.
 
@ToddLewden MCVE :P
 
@AnttiHaapala , I am not familiar with MCVE and when I google it I get multiple meanings for it.
 
DSM
 
6:59 PM
Ahhh yes yes
 
wim
Now that's actually a fun programming puzzle
create an object "item" which satisfies this: print(item.Body) does something different than foo = item.Body; print(foo)
 
How is that possible? I know you can make foo = item.Body; print(item.Body) different
 
@wim is exactly why I like programmer computer types. Have a problem? make a game of it.
 
If you really wanted to, you could look at the reference count. I suspect this is possible (but undocumented) with the C API, not sure if you can do it in Python.
 
wim
it's possible.
@QuestionC got it :)
well, that was my idea anyway! maybe there are other ways too.
 
7:07 PM
@davidism But, go ahead and keep pushing the party line that Python 3 is ready. I'll keep helping beginners recover from it.
Another reply :|
 
That was a while ago. I responded once then he got the last word.
 
yup
'{what}y mc{what}face'.format(what='turd')
 
@AndrasDeak not only that, but... now in Python 3.6... yet another way
 
Err, I am bad with the twitterz. I thought that was the latest tweet.
 
 what = 'turd'; f'{what}y mc{what}face'
 
7:10 PM
no wonder nobody uses it
 
F-strings are called so for a reason.
 
22:05·05 < nick> antti: i've had several people recommend lpthw to me ... it seems to be ok so far. Almost halfway through
 
> the coming use of THREE different ways to format strings
there's actually four
 
in IRC someone is going through lpthw2 as we speak...
 
10
Q: How to indicate you are going straight?

fedorquiSay I am riding my bike like this: - main road vvvv vvvv - narrow path vvvv vv \ \ | | \ \ |* | <-- I want to get here \ \ | | \ \|P | <-- pedestrians crossing \ | \ | | | | ...

I was very confused about that question until I realized it was on Bicycling
 
7:12 PM
@AnttiHaapala kickban
 
hmm
 
@AndrasDeak IANACO
 
wim
uck_you_zedshaw = "LPTHW is a turd"
template that!!
 
DSM
Now, now. Probably time to shake our heads and walk away in sorrow, not in anger.
 
@WayneWerner wtf this tshi
 
7:16 PM
Let's not badger badger badger badger the issue.
 
oh go eat a mushroom
 
@WayneWerner either the biker needs to stop, or the pedestrians should be killed
I wish I could downvote that question
 
lol. Not sure if the OP was from the US but we're a lot dumber here
 
I don't know if that's accurate from your perspective, but yep.
that's us americans ;)
 
7:22 PM
it is accurate from my perspective...
> I've been watching a lot of videos by Americans in Scandinavian countries, and > something they often bring up is that Scandinavians rarely jaywalk.The Americans then jaywalk less too because they're afraid Scandinavians know something they don't.
>
> The reason is simple though; pedestrians and drivers have an unofficial agreement to follow the rules.
> "I don't jaywalk and in return please respect the traffic lights"
>
> And it really is smartest to follow the traffic laws in Scandinavia because the drivers aren't used to people crossing the street at random and therefore aren't prepar
 
Theory: In America, pedestrians reason "go ahead and disobey the traffic lights. If you hit me I can get a nice fat settlement"
 
wim
from random import choice
from gc import get_referrers

class Thing(object):
    def __getattr__(self, k):
        return Thing()
    def __str__(self):
        return {4: 'spam'}.get(len(get_referrers(self)), 'eggs')

item = Thing()

if choice([0, 1]):
    foo = item.Body
    print(foo)
else:
    print(item.Body)
 
back here @WayneWerner when I said "nothing is predefined" I meant I dont know before hand formation of objects I will get. But as I already said, currently we are thinking that we can get tuple, list, maps nested with each other (that is tuple inside list or map which further is nested inside something else) while any of them containing pandas type
 
I'm gonna have to save that one for later. Phew
 
@Kevin no such thing in Finland :P no punitive damages
no settlements...
 
7:27 PM
That's because you have that thing called healthcare, so there's no having to prove someone should pay for your medical bills
 
That's so shocking to me I'm going to sue Finland for emotional distress
 
@KevinMGranger well, that's not true either... but it is not like "OMG I want to be hit by a car so that I can become rich"
Liebeck v. McDonald's Restaurants, also known as the McDonald's coffee case and the hot coffee lawsuit, was a 1994 product liability lawsuit that became a flashpoint in the debate in the United States over tort reform. A New Mexico civil jury awarded $2.86 million to plaintiff Stella Liebeck, a 79-year-old woman who suffered third-degree burns in her pelvic region when she accidentally spilled hot coffee in her lap after purchasing it from a McDonald's restaurant. Liebeck was hospitalized for eight days while she underwent skin grafting, followed by two years of medical treatment. Liebeck's attorneys...
 
^ $2.7 M in punitive damages, like wtf.
 
@Mahesha999 So make a MCVE containing the most complicated dataset you can think of, and your attempt to solve it.
 
in Finland the maximum you'd get is like you'd say "I was unable to work for 2 years", you're lucky to get 5 % of that .
 
Well keep in mind that 2.7 mil is like fifteen minutes worth of profit for McDonald's
 
even so.
 
It's about as punitive as making them sit in the corner and think about what they've done
 
so people do not drop coffee on their laps to get money.
 
7:32 PM
@AnttiHaapala Ironically, that was a pretty valid case, even though "Stella awards" have become synonymous with frivolous lawsuits
 
> third-degree burns
> requiring skin graft
> provable negligence
> company earned 308.9 mil that year
 
the case is valid, the verdict is really... well...
 
> Liebeck's attorneys argued that at 180–190 °F (82–88 °C) McDonald's coffee was defective
 
Hmm so much for my "fifteen minutes worth" argument. only a third of a billion a year? Some megacorp.
 
That's almost boiling
 
7:33 PM
They knowlingly bumped the temperature up past safe levels to avoid having to clean the machine
 
Ok, it's more like being sent to bed without supper and not being allowed to hang out with your friends that weekend.
 
Wait I was wrong, that was only one quarter.
 
also, skin grafting on your naughty bits. That's just painful.
 
in Finland it is implied that coffee is hot
 
@WayneWerner I dont think there can be really any superset/most complex type I can define for our application...

should I try to write a recursive function that will iterate through every value determining its type and serializing it accordingly and adding it to the final serialized object...something roughly like that...
 
7:34 PM
> 82–88 °C
 
Hot, or lava? ;)
 
no one would expect to get cold coffee...
mcdonalds has probably the coldest coffee here :P
 
Here's almost-boiling liquid in a paper cup with a questionably placed lid, have fun!
 
@Mahesha999 You're still trying to weasel out of taking a stand about your requirements. Quit that.
 
7:36 PM
https://youtu.be/MShbP3OpASA 37:30
Linus partially attributes his scating personality to being Finnish.
 
Rhubarb all, Time to leave
 
Will all of python's standard types be valid? int, float, string, dict, list, tuple, bool?
 
What a fitting conversation for National Coffee Day.
 
water should be 92-96 C when brewed
 
its not fixing requirement...we are developing sort of generic framework atop of which several things will lay...so cant really make assumptions about input types
 
7:37 PM
I rather have my coffee freshly brewed than let it sit in a pot for it to cool down
 
> Liebeck sought to settle with McDonald's for $20,000 to cover her actual and anticipated expenses. Her past medical expenses were $10,500; her anticipated future medical expenses were approximately $2,500; and her daughter's[12] loss of income was approximately $5,000 for a total of approximately $18,000.[15] Instead, the company offered only $800
 
@KevinMGranger so court in Finland would award her 20k.
 
wim
someone here told me about a stdlib way to do open('README.rst').read() with a context manager with a one-line expression, but I forgot what it was - could you remind me?
 
A company in Finland would also learn its lesson. But this is the US, where they have no souls.
 
wim
think it was you @DSM ?
 
DSM
7:40 PM
Sep 16 at 19:39, by vaultah
@wim pathlib.Path('README.rst').read_text() in python 3.5 or newer
Nope. :-)
 
wim
pathlib, thanks
is there a py2 backport ..
 
No, in py2 you can only do things the hard way
 
There's a backport, but remember that introducing new features is one of the worst things you can do.
 
wim
7:42 PM
@davidism not sure if trolling ...
 
:-|
 
wim
imo backports are the best way to ease transition to 3 ... more carrot less stick
 
And you'll never know with my expert poker face.
 
(lambda x: [x.read(), x.close()][0])(open("README.rst"))
 
That doesn't guarantee closure if there's a read error
 
wim
7:44 PM
-doesn't close if exception
-1 we downvote your chat message
 
But just look at it. Does it really matter if that beauty stays open forever?
 
@QuestionC you should listen from 36:30 -
 
@davidism if they're backports of py3, it's fine imo
 
I'm curious what kind of errors can be raised during a read call.
 
it actually eases the transition, since you'll have less code to change
 
7:46 PM
@FlorianMargaine I know, I was making a reference to certain complaints from a tutorial earlier. ;-)
 
Maybe if you unplug the external hard drive the file is on while it's halfway loaded...
 
Underlying transport / medium errors.
 
I played that too straight, no one got it.
 
If it's a networked filesystem, the network goes out. Fully reasonable
 
ah, what tutorial?
 
7:46 PM
Check the statement at the top of this: learnpythonthehardway.org/python3 then read this lovely defense: twitter.com/davidism/status/781521934999625728
 
wim
more like POOtorial amirite
 
@davidism I did
 
@AnttiHaapala I'm currently listening to the whole thing actually.
 
This demo music is great. (The whole thing is great.)
 
@davidism fun
 
7:55 PM
Cbg
 
DSM
For those following along at home: today's interview went better than the last two -- probably because he used Python 3 -- but still far below our needs. 0/3 this week.
 
@DSM what do you have them do? Would I need to know data science to pass?
(Not planning to move to Canada, just interested.)
 
I'll move to Canada but only if you can convince me of its merits through a lively musical number
 
davidism. Canada is great. Join us. You don't need those crazy high temperatures.
I'll get you a winter coat as a welcoming gift
 
Hard mode: you can't mention hockey or the United States presidential election.
 
DSM
7:58 PM
@davidism: not at all. I've been helping a different team here at NumberFirm interview internship candidates, where I handle the tech side and handle the numberish side. My first coding question is literally "how many names are there?" and I give them a multiline string.
@Kevin: if the lumberjack song didn't sway you I don't know what more I can do.
 
Water's freezing point is still a crazy high temperature if measured in Kelvin.
Well over two hundred degrees.
 
> Measured in Kevin
3
 
DSM
Guess we need to figure out how much water Kevin is. You know, for science.
 
I imagine that's the scale that contains cosmic horror at one end and the light of a thousand stars at the other.
 
I'm a fine metric for distance, mass, and calories, but not heat.
 
8:03 PM
@idjaw my ex-boss, Alabaman, said that he preferred F over C because "F is more precise"
 
Because today is the day of Morgan's Unpopular Opinions, I completely agree.
Plus, 100F sounds hot, 37.7C doesn't.
 
@MorganThrapp it isn't, in sauna.
in Finland I know 0 is freezing, 100 is too hot,
in between is nice. That for degrees Celsius.
 
"in between is nice"
err...
>40 is not really nice
 
"This boiling–point difference of 16.1 millikelvins between the Celsius scale's original definition and the current one (based on absolute zero and the triple point) has little practical meaning in real life because water's boiling point is extremely sensitive to variations in barometric pressure. For example, an altitude change of only 28 cm (11 in) causes water's boiling point to change by one millikelvin."
TIL^
 
8:21 PM
Lmao see it kicked off with Zed. Will read transcript tomorrow
 
I'm trying to determine what makes this question downvotable: stackoverflow.com/questions/39778978/…
The OP provided a proper MCVE, showed what they are trying to do, what they tried, and their understanding thus far.
 
Welcome, please read our room rules. Don't post recent questions.
 
@Britto Please don't post questions that have just been asked. Please refer to the chat rules
 
@all Sorry will Wait
 
DSM
@Britto: you might spend some of that time working on your "question" -- right now it's not really a question, it's just a picture, and you want someone to write code for you to reproduce it. It sounds like you want to hire a freelance programmer.
 
8:33 PM
Floats are super irritating
 
They're useful for avoiding quake though.
 
DSM
I like root beer and I like ice cream, so I'm primed to like them.
 
One of my favourite things at dairy queen was a slushie float
those were so good
 
@idjaw There's nothing. Probably just people who think that Python3 is too hard ;)
 
^^ glad I'm not the only one and it seems to have received a few more up votes.
We see a lot of crap. So, when something comes up that really stands far from the crap, it's a shame to see it treated like crap.
crap
 
8:42 PM
1
Q: How to get lineno of "end-of-statement" in Python ast

xisI am trying to work on a script that manipulates another script in Python, the script to be modified has structure like: class SomethingRecord(Record): description = 'This records something' author = 'john smith' I use ast to locate the description line number, and I use some code to c...

this one's pretty interesting too
 
@idjaw QFT. Especially when most crap isn't treated like the crap it is :P
 
amen brother
 
I'm more than happy to upvote questions that deserve upvotes because it's so rare to actually find any
 
is it just me, or does anyone else feel like a nice bash solution would work out well for that question davidism posted
 
DSM
Why can't you just take the end-of-line of the next statement-1?
 
8:47 PM
did you read the question or was that sarcasm?
 
@DSM whitespace maybe?
 
DSM
Hmm, let me see.
In [162]:
     ...: s = """
     ...: class SomethingRecord(Record):
     ...:     description = ('line 1'
     ...:                    'line 2'
     ...:                    'line 3')
     ...:     author = 'john smith'
     ...: """
     ...:
     ...: m = ast.parse(s)
     ...: print(m.body[0].body[0].lineno)
     ...: print(m.body[0].body[1].lineno)
     ...:
3
6
Seems to work, but it was a really long day and I'm not thinking too clearly.
 
put some empty lines before author
 
does anybody have used Flask Babel?
 
DSM
8:52 PM
@davidism: oh, I see what you mean. But isn't that a pretty shallow problem? You can just drop whitespace-only lines from the end. Maybe I'm still misunderstanding the issue.
 
Oh, I see, find the next line, traverse up to the first non-empty line before it.
 
DSM
Yeah.
(And earlier I wrote "end of line of the next statement" when I mean "start of the next statement", so clearly I'm being careless. But I think something like this should get the OP most of the way there.)
 
I don't really know the AST, but it seems like it should know where each token ends.
 
@WayneWerner A bit of both. But now I'm messing around with wanting to do it in both. However, I'm curious to know what the scenario is in wanting to do this.
 
DSM
Inspecting the _ast.Assign element and the _ast.Str itself, nothing leaps out at me.
 
8:58 PM
If they didn't need the file I'd say just replace the node.
 
I didn't read this carefully at all...I'm a moron.
 
@davidism they have a pretty similar avatar, too
 
DSM
I seem to remember there was a third-party module which preserved more information to make it easier to do code transformations and hackery, but for all I know it was python 1.5-only. ;-)
 
Darn changes and new features
 
vaultah has provided an answer
 
DSM
9:14 PM
Okay, that's enough for this frustrating (and depressingly grey) day. Evening rhubarb for all.l
 
^^ Mine is on going. Today was not fun. Later @DSM
 
@DSM rhubarb
 
=/ today is not a fun day. <rant> <rant> <rant>
 
9:32 PM
(I deleted my answer)
Feel free to reuse the code
 
@vaultah why? You technically already answered it, just could have improved it.
 
Because of the last comment
I don't know a nice and reliable way to detect a comment
 
I didn't a chance to read the last comment.
Did the OP add a requirement post answer?
 
> you should (at least consider) traversing backwards over the lines until you reach a non-blank non comment line to get the ending line number to make sure you don't accidentally delete a block comment that may be immediately proceeding the definition that is being searched for.
 
If unassigned string literals produce a node, then you'd just look at line.lstrip()[0] == '#'.
If they don't, then you'd have to get smarter.
Anyway, I'll think about this on the way home. Rhubarb!
 
9:37 PM
rbrb davidism
 
hey guys, try to guess how php calls its regex function.
 
real_regex_safe_mode_on?
 
Aw, now you make the actual function look good.
 
PHP function look good? I think the fumes are getting to you.
 
preg_match
 
9:43 PM
snicker
 
Wanna guess how you call join in php?
 
Reminds me of all the trlr_cnt and frt_line variable I saw at my first job in the Cobol code
 
It's one word. You can't come up with a worse one word to name it.
 
break?
 
Implode
You were close
 
9:51 PM
mildly interesting geometry question, no programming stackoverflow.com/questions/39780512/…
 

« first day (2175 days earlier)      last day (2777 days later) »