« first day (3133 days earlier)      last day (1810 days later) » 

3:00 PM
nope
 
str.endswith('str*')
 
go regex (probably)
 
Could you guide me to a solution?
 
what do you even expect that to do?
would s = 'str potato potahtoe' match?
 
yes
 
3:01 PM
then: 'str' in your_string
 
But that doesn't ensure its at the end.
 
neither does your wildcard
 
It does.
 
give me a counterexample, please
 
str*
the * can only ever be after 'str'
I have a list of URL's and want to exclude the ones ending in /page-*
 
3:03 PM
what I wrote matches that
give me one that mine matches and yours doesn't
 
Your 'str' in your_string?
 
yup
 
Doesn't ensure its at the end.
 
Again. Example.
 
example.com/threads/page-2-is-broken/page-3
Rare I know, but...
 
3:04 PM
Yours matches that too, and so does mine
 
no.. it doesn't
example.com/threads/page-2-is-broken
 
it ends with /page-3, and it ends with /page-2-is-broken/page-3, both of which match
 
lol
 
@AshSmith better
that ends with /page-2-is-broken so it matches
 
But it isn't a page file.
It simply contains the thread title.
 
3:05 PM
I don't know what that means and neither does python.
 
are you a bot
 
If you want code, you need to be specific. Vague handwaving can't be implemented.
 
am I talking to a bot
 
Seriously Ash?
 
I want to simply check if a string ends with a string and a wildcard lol
 
3:06 PM
Lol.
 
Your example would return true on example.com/threads/page-2-is-broken when it should return false.
If I'm reading it right.
in != endswith
 
you might be reading it right but you're definitely not saying it right
until you give a proper, algorithmic specification of what behaviour you want we can't help you
 
lmao
okay I'll try this again
 
str.endswith('str*') => str[-4:-3] == 'str'
you want that?
 
please do
@MisterMiyagi sssh, let them explain
 
3:08 PM
I want a way of checking if a string ends with a specific string + anything (wildcard).
 
I could guess in three possible ways, won't help
@AshSmith ugh
that's still just checking it the specific string is inside somewhere
 
that's not what "ends with" means
 
@MisterMiyagi one of us is enough
 
I give up
 
this will end soon and I don't want to have multiple parallel explanations
 
3:10 PM
allright, I still have some popcorn
 
"example.com/threads/page-2-is-broken" matches your specification because it ends with /page- plus anything
 
I've got a bowl of toffee popcorn if you want to dip in mistermiyagi
 
Okay, lets try this again.
One last time.
 
last try
 
I just finished my pringles so this is sad :(
 
3:11 PM
I want a way of checking if a string ends with a specific string + any one letter character, that character having to be a number (wildcard).
 
there you go
that's very different from what you asked earlier
match with a regex pattern of '/page-\d$'
 
@biggi_ I didn't have any pringles to begin with
 
Did you think of what if there's page 10?
 
but now I want some :/
 
Okay scrap the 1 character.
 
3:12 PM
Lol, I've killed 3 cans of BBQ this week so far. Averaging a can/day.
 
Just if its a number will do.
 
@AshSmith then you want '/page-\d+$'
 
Cans of BBQ?
 
wim
no MCVE ...or dupe if you know one for "I'm a n00b and I tried to pip install a stdlib module"
 
3:13 PM
huh, that should be a rare one
 
so if '/page-\d+$' in str ?
 
\o cbg
 
@AshSmith pringles
 
-insert grampa simpson of walking in taking off hat and walking out again after seeing what's going on gif-
 
@AshSmith no. Google how to match a regular expression in python.
@MooingRawr hey, Moo
while you're on your way back read meta.stackoverflow.com/questions/384994/… :D
 
3:15 PM
so I need re.match?
I've only been learning Python for 14 mins and 21 seconds lol
 
you've probably been googling for a longer time
and yes, you need re.match
no, you need re.search
 
I mean I've been reading the python docs
 
these two always trip me up
 
well, you can match with a wildcard at the start...
 
I'd find that weird
that would make search pointless, I mean, so presumbly search might be more efficient
 
3:18 PM
do u have to call some property to fetch it
like .result
why do I feel like its .result
 
I'm certain the re documentation has examples
 
nvm have to cast it as a boolean
 
@AndrasDeak oh mercy....
 
@wim that's a year old, how did you even find it?
 
Badgers are known to dig for things... :D
 
3:23 PM
@AndrasDeak actually I find it weird that match exists at all, seeing how regex includes ^ i.e. "start of line"
 
@MisterMiyagi indeed, I guess that has an optimization compared to search
 
.search sucks
 
@AshSmith really.
 
Traceback (most recent call last):
  File "main.py", line 33, in <module>
    if re.search('/page-\d+$', threadLink).result:
  File "/usr/lib/python3.7/re.py", line 183, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
 
yeah, it sucks that you can only search in a string
if only python was smart enough to divine what you meant to do when you passed it an arbitrary object and asked for a textual search in it
 
3:24 PM
I'm for threadLink in threadLinks:, it doesn't convert threadLink to a string for me?
 
There ain't no telepathy interface
 
@AshSmith nothing converts nothing to a string for you unless you tell it to
 
I mean... I've seen other languages do it so it can't be impossible.
 
what is a threadLink anyways?
it is possible, but generally a bad idea
 
@AshSmith Okay, let's stop now. Please read a python tutorial before continuing here.
 
3:25 PM
just ask the JavaScript folks when weak typing comes up
 
@MisterMiyagi a threadlink is a link to a thread.
Damn, I'm in one of them chat rooms where they all go crazy at you for dissing the topic of the chatroom.
 
you are mistaken
 
continues popping the corn
 
I merely don't want to waste the time of those present trying to explain basic python to you when you don't seem to care to learn yourself. That plus an attitude means you're on your own for a while.
 
@AshSmith as in "an OS thread"? a forum thread?
 
3:28 PM
A forum thread.
 
so a URL?
 
a url yeah
 
@MisterMiyagi yes, but please don't help them
it's not sustainable
 
true that
 
@AndrasDeak I dont intend in learning because I'll probably never use python again, I only used it because its easy to webscrape lol
 
3:29 PM
that's fine
 
I don't have time to master a high level language, no need to throw insults at me for my decision.
 
there are sites like codementor where people help you write code or write it for you
@AshSmith I've yet to insult you
 
look, we cannot guess at what you may or may not know about how Python works
strong typing is a pretty basic feature of Python
 
I really hope they don't try and force the mcve change on us... :\
 
It's the opposite, so chat > google search, if I was being lazy I would google search rather than ask here but I tend to ask here because people go into more detail.
 
3:32 PM
@MooingRawr it's already done
the announcement just informs us of the change
 
@AshSmith well, the detail is "Python does not guess what you mean"
 
@AshSmith maybe you should try Yahoo Answers?
 
Well that's just silly, I guess nothing would stop us for just continually using mcve.
 
except the link is now called /help/reprex etc.
the old [mcve] magic link will keep working...for a while, anyway
 
wait, there was an announcement?
 
3:35 PM
well, the meta post I've linked three times already
 
I'm not sure what changed in the SO employees over the years. I would like to think that before they would propose the change to us before making it... since you know... SO was (is?) driven by the community.
 
it really wasn't
Oct 27 '18 at 20:13, by Andras Deak
Also, read Jon Ericsson's new blog post which kind of explains that things only happen when the company wants something, and any impression that this is due to community demand is just a coincidence
apparently whenever something happened along what community wanted it was just an illusion, because someone at the company wanted to do the same thing
 
something something real life with any hierarchy.
 
I want to see an A/B test measuring how often newbies completely ignore "please provide a (mcve|minreprex)" because they don't know what it means
The amount for MCVE is "a lot". Maybe minreprex will fare better because it's not an acronym?
"Hey, this is more than four characters long, maybe google will know what this is", says the hypothetical half-clueless reader
 
I think a confusing acronym that obviously stands for something is more likely to be googled
minreprex looks like it should mean something and you just don't know what, shrug
 
3:39 PM
but reprex is an r package and a python ported version of said r package isnt it ?
 
At least the port ends with "py"
 
minireprex sound like a light weight version of reprex. but that's coming from someone who knows of reprex... i wonder what it sounds like to someone who doesn't know
 
> You haven't voted on questions in a while; questions need votes too!
 
When I first encountered the term this morning, largely free of context, I thought, "Is this some kind of cool regex alternative?"
 
sounds like some cheesy 90s super hero to me
 
3:41 PM
haven't seen that in a while
 
then again, MCVE always reminded me of Command and Conquer
 
Reprex can match HTML and balanced parentheses. Reprex is always better than O(N^2). Zalgo locks his bedroom door at night in fear of Reprex.
 
@MisterMiyagi hmm, how so?
 
Honestly Regex has ruined any word with 'e-g-ex'
 
@MooingRawr said R package seems to exists precisely to create reproducible example, though
@AndrasDeak they had a Mobile Construction Vehicle
 
3:45 PM
Ah! I played a lot with red alert, but I didn't make the connection.
 
ah good old red alert
that brings back memories
 
wim
@Kevin wow what a joke
 
I'm not terribly optimistic that the new term will be better at prompting newbies to google it than the old term. I think 99% of nongooglers are just chronically uncurious. It's only the last 1% that would say "hmm, I probably won't find anything if I google this, so I won't bother" to MCVE and not to minreprex
 
wim
minreprex sounds like a cute dinosaur
 
huh, reading the /help/reprex page...
they dropped "verifiable" because it was explained with allowing to reproduce the problem, as already covered by complete"
but the replacement is literally called "Reproducible"...
tee-rex and rep-rex?
 
wim
3:52 PM
I was thinking something like a compsognathus
 
Pretty sure that's a pokemon
 
wim
@AndrasDeak "If it ain't broke, break it..."
there seems to be a pattern here
 
For what reason would if re.match('/page-\d+$', str(threadLink.attrs['href'])): return false for all?
 
oh I missed that it's inside an if
 
Oh
 
3:54 PM
did you check what str(threadLink.attrs['href']) actually looks like?
 
It might return None (which is equivalent to False in a boolean context) if the regex failed to match anything.
 
Yeah, I print it out after my if check.
 
please give an example
 
If you're thinking "but that's impossible, there's definitely a "/page-5" inside my string", remember that match only matches against the start of the string.
 
As we've said earlier
like, half an hour ago?
 
3:57 PM
Examples

forums/my-first-forum/: threads/my-gap-year-uni-story.13846/
forums/my-first-forum/: threads/my-gap-year-uni-story.13846/page-9
forums/my-first-forum/: threads/my-gap-year-uni-story.13846/page-10
forums/my-first-forum/: threads/my-gap-year-uni-story.13846/page-11
 
We should search again... maybe re.search
 
btw the first part of them examples are the forum they belong to, threadLink.attrs['href'] is the second string after :
Better put, the examples are...
threads/my-gap-year-uni-story.13846/
threads/my-gap-year-uni-story.13846/page-9
threads/my-gap-year-uni-story.13846/page-10
threads/my-gap-year-uni-story.13846/page-11
 
Ok, cool. So my prediction was accurate - the strings don't start with page-whatever, so match will not match them. Consider using re.search instead.
 
They end with page-whatever, as I said like an hour ago.
 
>>> re.search("/page-\d+", "threads/my-gap-year-uni-story.13846/page-9")
<re.Match object; span=(35, 42), match='/page-9'>
 
4:00 PM
I'm also suspicious of str(....attrs['href']) but whatever
 
I know you had trouble with search() before, but if you got match to run without crashing, then you should be able to swap it out for search without a problem
 
I'll try .search now.why put a ...?
 
... is shorthand for "some code goes here but I don't want to type it out"
 
that
 
It's not something you can actually run. (... most of the time)
 
4:01 PM
An ellipsis (plural ellipses; from the Ancient Greek: ἔλλειψις, élleipsis, 'omission' or 'falling short') is a series of dots (typically three, such as "…") that usually indicates an intentional omission of a word, sentence, or whole section from a text without altering its original meaning.Opinions differ as to how to render ellipses in printed material. According to the Chicago Manual of Style, each dot should be separated from its neighbor by a non-breaking space. Such spaces should be omitted, however, according to the Associated Press. A third option, illustrated in the opening sentence...
for reference
 
trying to convert a string with timezone information to datetime object
{code}from datetime import datetime
print datetime.strptime("2019-05-12 00:04:00 PST","%Y-%m-%d %H:%M:%S %Z"){code}
 
@AndrasDeak Yeah I'm a little concerned about that too. I'm guessing threadLink.attrs['href'] is a list, and converting it to str was the "first thing that worked" solution in order to get match to stop complaining about "str expected".
 
is it wrong to send the timezone information ?
 
It's not inconceivable that running a regex search on a string representation of a list will produce useful data, but it's just as likely that down the line it will turn out that we should have iterated over the list properly, or selected out only one element, or whatever
 
4:16 PM
Is it generally good practice to store a class in a separate file in python?
 
Sometimes I do that, sometimes I don't.
Size is a factor. Huge classes I'm more likely to put in a new file
 
wim
4:34 PM
@AshSmith No.
That's for java weenies
group code by the functionality / domain. class-per-file adds a spurious module namespace per-class.
 
@SusheelJavadi have you seen the top-voted answer here?
Yet another case where pinned accepts are bad
 
To me, it sounds like something you should be embarrassed about when you ask your pharmacist for it. "Less awkward" is not a phrase I would use to describe it. — Nick 15 hours ago
At the risk of sounding silly, what does this mean?
 
"Minreprex" sounds like the name of a butt medication.
Not any specific butt medication, mind you.
 
It does...? :/
It sounds bad for sure, but I wouldn't have immediately drawn a parallelism to that
 
It's blatantly artificial and tongue-twisting. That might be a reason.
 
4:48 PM
Amen
The fella who came up with this must've thought "oh, min-reprex is 1 syllable less than MCVE, everyone's going to love this"
 
I can picture a commercial in my mind's eye. "ask your doctor if minreprex is right for you". A happy family is playing frisbee in a field of flowers.
 
And then the long list of disturbing side effects
 
Do not handle minreprex if you are pregnant. Minreprex may cause tiredness, headache, and the sensation that someone is standing exactly three feet behind you.
 
Fortunately for us, the only side effect of a well-written example is a quick and probably correct answer
 
Brought to you by People For America, a subsidiary of EvilCorp
 
4:52 PM
Do not take reprex if you're trying to print something out, use strex instead
 
Do not taunt reprex.
 
whatever you do, for the love of jimmy christmas don't feed the reprexes
Somebody should post an answer to that featured meta with a user script that automatically substitutes "reprex" with "MCVE"
 
wim
@AndrasDeak in this case, disagree. the OP said they already know it's possible with dateutil and wants to know how to get strptime to play ball.
from the initial revision I have been able to get the date parsed using a third-party Python library, dateutil, however ... Is there any way to get strptime() to play nicely with timezones?
 
It was the first relevant google hit, alas. Then again I did search for datetime
 
wim
why someone went ahead and posted a dateutil answer on that question anyway is a mystery (didn't actually read the question? ... it should probably be downvoted IMO)
 
5:00 PM
A lot of people don't seem to mind
 
wim
I had evidently visited that question earlier, because I have an upvote sitting on the (currently lowest voted) 2015 answer
 
@cs95 But much harder to say, for me, even with putting in a pause where that dash is.
 
is there any way to Typehint that something can be used as a boolean?
like Iterable stands for __iter__ and friends
 
wim
@AnttiHaapala agree. and JFF routinely does this quite liberally on other questions, so I'm not sure what the deal is here. just being contrary, I suspect.
@MisterMiyagi how/why would that be useful? anything can be used in boolean context.
 
5:15 PM
Define "can be used as a boolean". If you mean "can be used like if myobj:, then all objects can be used in this way.
 
wim
kevin'd the kevin
 
ugh right, I keep forgetting that indeed... :/
nevermind
 
"can be used to convey actually useful information about the object" might be a more interesting definition. bool(my_list) tells you whether the list is empty. bool(object()) just always returns True.
I don't think there's an easy way to determine whether a class has "significant truthiness"
 
yeah, I have a bunch of things in the later category
but all via custom exceptions, as in numpy
 
Maybe you could detect whether the class' __bool__ definition is inherited directly from object, or whether it's been overridden... But even then I don't know how you would fold that into the type hint system
Oh and you'd need to check len() too
 
5:25 PM
not sure that would work out
there would basically be "boolean", "not boolean" and "that thing Python does by default which we cannot disable"
 
wim
@roganjosh no but Veedrac is good.
gave them a +500 bounty once: stackoverflow.com/a/30675066/674039
 
@AndrasDeak here's what I came up with for that loop gist.github.com/biggidvs/4debd7c084e32557435ee07a006e6621
I think it looks fairly neat
 
you can skip some arithmetic if you pass a starting index to enumerate, and your second if block looks like an else block
sin(90*(pi/180)) is a bit superflouos ;)
 
I changed to else if :) also, that's what our mechanical whiz gave me for the calcs
 
If the only difference between those two blocks is the theta line, you might move the other two lines outside the conditionals
 
5:34 PM
And are you sure you need to separate the two cases and flip the sign of the sin in between? Isn't that the same formula with a signed sine?
 
Kevin: it won't be. there are other cases going in there later
 
if blocks don't have their own scope so a variable assigned inside an if block can still be accessed outside that block
 
Like each of those will have ~5 different cases. Just got it working with one particular case
Based off how an object is oriented...it's wonky af
 
@wim The answer they gave started off strong and kinda tails out. Tim does mention that they're "shooting at a moving target" but I'm not sure how useful the second half is
 
are the constant sin terms always going to be constant? sin(90*(pi/180)) == 1
 
5:38 PM
The more trigonometry code I write, the less often I find that I need to write switch-cases based on which quadrant an angle lies in or anything of that nature
I guess just keep an eye out for brainwaves that let you collapse your five cases into one
 
That's what I'm working on
Yup, I'm working on it...had to dust my trig book off ><
 
are your polar coordinates actually so, or just angles?
 
Polar coordinates
angle:distance
 
but B is only the angle, or am I mistaken?
 
B is the distance
 
wim
5:44 PM
@AndrasDeak good luck fixing english
 
never give up, never surrender
 
Hello guys, someone knows what metadata could I take from a pandas series?
 
What do you mean by metadata?
 
@AndrasDeak almost like my profile thingy :p
 
@biggi_ so polar_coordinates is a list of distances? and the index is the angle?
 
5:46 PM
Yessir
 
A pandas series has an index, values (now array), and name.
 
@piRSquared the description of the series.
 
Like stats?
 
pd.Series.describe()
 
5:47 PM
ohhh coool that can help me
@piRSquared thank you
I will try here
 
@piRSquared did you make any progress with your SQL issue?
 
Yes, I ignored the text because I didn't need it >.< Next time I am on that task, I'll learn how to do it properly with sqlalchemy using bulk_insert. I'm guessing it will be slower than what I'm doing (because I think I remember testing this 4 years ago) but I can't be sure, so I'll go through the pain. @roganjosh
 
If it makes you feel better, I'm also learning to use SQLAlchemy properly and crying inside a little when I get it to work, when I look back at my older project
 
lol
@cs95 forever after you'll be known to me as user:4909087. Try changing that (-:
 
I have some major refactoring work to do on the old project it seems. I'll keep going with this one until it's up and running and I've learned a bit more, first
 
5:56 PM
lunch rbrb
 
rbrb
 
wim
Dec 13 '18 at 21:07, by Wayne Werner
@Code-Apprentice The definition of bad code is anything you wrote more than a week ago
 
It's more that my notion of "this doesn't fit into an ORM pattern" kinda falls down now that I see the finished product and understand ORMs better.
 
@AndrasDeak Thanks so much @AndrasDeak. That answer saved the day! :take a bow:
 
no problem
 
6:05 PM
Hi All,

I have a project/package for which I want to generate documentation
using pydoc.

My problem is that when I type "pydoc.py -w MyPackage" it only
generates documentation for the package - no modules, classes or
methods or sub-packages. Just a single HTML file called
"MyPackage.html"

That's strange - is there something here I'm missing. How do you
generate documentation for a whole package?
This "MyPackage.html" contains the lot's of a broken link of files that does not exist
 
wim
 
ha, nice catch
at least they fixed the "usingpydoc" typo
 
wim
line-wrap dead giveaway
 
actually I am searching the result and find out that so though this is good pharsed of my question so put's that
 
@AmanJaiswal fwiw, it's a good idea to cite your sources
 
6:12 PM
I thought it was just PEP8 compliant text
 
what do you mean by cite your sources
 
He means plagiarism is frowned upon in all fields of science and art.
 
see the above imaage
 
Hi
 
hello
 
6:14 PM
links are broken
 
wim
nahh in art it's just called "inspiration"
 
Do you have any solution for his :(
 
6:33 PM
@AndrasDeak woohoo reversal badges :D
 
yeah, Shog handing them out like candy
 
wim
6:45 PM
@AnttiHaapala they aint worth a dime on meta
pop quiz, how much slower do you guess dateutil.parse is vs strptime?
a) 2x b) 5x c) 10x d) 100x
 
e
 
because it actually does stuff.
 
he ded
 
wim
6:47 PM
hah..he's ded jim
 
But not as we know it
 
@roganjosh it is your fault. you should have gone for a
 
wim
@piRSquared ding ding
 
@AnttiHaapala You guys got badges, I'll take credit for this
 
6:48 PM
that is surprising.
 
I am never going to use Python for a website again.
 
@NiNisanNijackle good to know, thanks
 
wim
welp better log out of yr instagram then
 
I am going to try golang and use Python for machine learning if I ever need it.
 
wim
go is a nice language but you better get one of these keyboards
 
6:51 PM
I often find myself writing some functions that do a rather specific aggregation, but should be flexible enough to work with additional cuts of the data. I've typically adopted something like:
def calc_yearly(df, oth_gps=None):
    if oth_gps is None:
        oth_gps = []

    df.groupby(['year']+oth_gps)...
 
@wim yea, I definitely do, or I could just write a function for it that takes in an inline function else it does a default panice behavior .
 
but it seems weird to put ['year'] in a list just so I can add it. And then oth_gps should be specified as a list, even if it's only one element. Am I missing something fairly obvious to make it a bit less meh?
 
Personally, I'm not sure there's a better way
 
I want a function composition operator: Something like ∘ = lambda f, g: lambda x: f(g(x))
I guess if functions had a pipe method... I'll be back
 
Yeah, I was thinking perhaps I could check if oth_gps was a string, then make it a list that way it's a bit less weird to be like oth_gps = ['gender'] when just one thing is specified.
rbrb
 

« first day (3133 days earlier)      last day (1810 days later) »