« first day (3489 days earlier)      last day (1462 days later) » 

2:05 AM
Hmm semantic question - if I in a method docstring reference another method, do I refer to the second method as using other_method to xyz or using self.other_method to xyz. That method isn't a name elsewhere, but I presume if it was the convention should be the same.
 
 
3 hours later…
4:39 AM
I figured out the answer, so didnt ask you guys here.
The question was that a global variable not affected by changes within .apply function. I had used %timeit before the function to understand efficiency, turns out it was the culprit, didnt know this before.
 
4:53 AM
Finally crossed 500 rep :D
 
 
3 hours later…
7:34 AM
Hi did anyone hosted a django website in pythonanywhere here??
 
8:19 AM
@vevekseetharaman you did ask us here. I asked for an MCVE.
 
8:34 AM
once i increase the max_workers than 1 worker within ThreadPoolExecutor, i miss some of the results. but if i run under one thread, the result is accurate ! repl.it/@AmericanY/ThreadIssue , what am missing here?
 
the part of the license that forbids using their content without express permission?
 
^ Oh okay, i figured it out. just solved by assigning steam
@MisterMiyagi i don't want to go on the part of forbids using their content without express permission but I'm aware of that.
 
9:05 AM
@AndrasDeak While creating the MCVE i understood the problem, so didnt bother you guys here.
 
9:55 AM
@vevekseetharaman sounds like the MCVE worked ;)
@αԋɱҽԃαмєяιcαη being aware of that is enough to hold up in court in most US jurisdictions
 
10:15 AM
@AndrasDeak It sure did. gave me perspective
 
Dec 17 '16 at 14:58, by Andras Deak
well, coming up with an MCVE solves 90% of debugging issues
 
10:35 AM
why is print a wrong function call with flake8?
 
It would be helpful to know the code that was flagged
 
@MisterMiyagi print(f"{turnOrder[winnerIdx].name} wins the trick\n{'*'*17}")
@MisterMiyagi It flags ALL prints regardless of the usage
 
Does it use the default settings of flake8?
and do all your prints contain weird f-strings?
I could imagine a codebase where prints are categorically forbidden in favour of logging, but I would expect that to need special settings
 
10:50 AM
@AndrasDeak yes
 
flake8 just doesn't want you to use some functions like print, vars, staticmethod, etc
 
then what instead? logging?
 
seems pedantic, though in a library I would indeed not expect to see any print
 
@MisterMiyagi right, that's probably the case
 
Depends on who you want to talk to. You want to talk to your future self? Logging. You want to talk to the user? print is just fine.
 
10:53 AM
I can't remember default flake8 complaining about print, though. The link above is to some plugin.
 
Yes it's with a plugin
@Aran-Fey thanks for the tip \0
 
there are some really weird rules in there, like not using f-strings.
 
@MisterMiyagi That made me scratch my head as well. There's an issue on the GH where they discuss .format vs f"
 
11:08 AM
maybe it's for backwards compatibility
 
Hi guys, I have a Django rest framework question. If this room is not suitable for questioning about Django, I am really sorry. Is it good practice to change that data in def validate_field_name methods in Django serializer? So If the answer is No as I expected (because the method's name is so clear we define this method for validating the field, not to change it) why we have to return value at the end of method?
 
 
1 hour later…
12:42 PM
wow this sopy page got nearly 5k clicks last month apparently...
 
must be pretty high up in the google results
 
1:09 PM
Seems like it... apparently up a 1k clicks from last month...
 
1:35 PM
"f strings are bad because f"{x+y}" crashes if you move it above the assignment statements for x and y" is not a very convincing argument, given the same thing happens for "{}".format(x+y)
"f strings are bad because it's hard to lint them because our parser has never needed to look inside string literals befoere" may or may not elicit sympathy in me, depending on whether the complainant is being paid to maintain their linter
 
last time I looked, tools for AST inspections are surprisingly unportable between Python versions.
 
I was just about to say, "ast shows you the expression tree of any to-be-evaluated code in an f string, so how hard could it possibly be to inspect?". "hard, because the interface changes between versions" is a reasonable answer.
 
there are some very nice tools such as baron, but every time I finally get around to using them they are abandoned. :/
My Magic-8-Ball predicts that the Python ecosystem could be over 9000% more productive if the janitors got more recognition.
 
They're heroes in these uncertain times
I'm still mad that there's no way to distinguish between 1.0 and 1.00 just by looking at their respective ASTs
 
Why?!? Why do they parse 1.00 to 1.0? shakes fist at the heavens
 
1:49 PM
I had a very good reason for caring about this at one time, which I can no longer remember
It may have been "because I'll get 15 rep if I figure it out"
 
As long as you remember that you once had a reason, that seems legit to me.
@Kevin 'Tis a good cause to fight for, lad.
 
I for one welcome semantically correct parsing
 
Perhaps KevinScript should take a page out of JS by having an unconventional type as the basis of its number system. Proposal: 1.0 and 1.00 in KS are distinct numbers that do not compare equal.
 
yeah, it's frustrating how one of the most used JavaScript parsers written in Python does parsing subtly semantically incorrect...
 
Best practice recommends the ===== operator if you need to compare numbers with different decimal places
 
1:55 PM
I ended up spending 3 months to fork and release a new package with most of that fixed, because the original maintainer stopped caring
 
You're a hero in these uncertain times
 
weaker souls would have just given up on javascript
 
I wish I had that option.
I felt I lost a part of my being that I am never seeing again
at the very least I found the cause for the broken JavaScript behavior if compression was enabled for one of my add-ons on Plone 4
 
@Kevin don't forget a walrus and an egg man operator... :)
 
@Kevin that's your chance to propose the isclose operator a =n:m= b.
 
2:07 PM
nohup python app.py --port=9009 nohup.out &
i am executing this command using
cant find my nohup.out ffile anywhere
subprocess.Popen(cmd.split(" "), cwd=repo_dir)
 
Can you actually pass nohup.out as a command-line arg?
How does it know not to pass it on?
Isn't nohup.out the default target?
 
the default target for what?
 
Default target for nohup to send stdout to
Maybe even stderr
 
@AndrasDeak i tried something like that as well, still lost
 
Something like what?
 
2:12 PM
p = subprocess.Popen(['gphoto2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
Are you trying to start a daemon process?
 
@AndrasDeak yes i want to laucnh my tornado app in backgroup
app works fine, but nohup files missing
I have done this million times, its behaving weird since now
ok this works fine with my local
but when I launch to use this cmd it screws up
/home/the_user_whom_i_blame_all_my_problems_on/anaconda3/bin/python app.py
 
Naz
2:37 PM
cbg. what is a nil value for a float type in Python? When returning float('nan') from a function whose return type I set to float, mypy says that I shouldn't be returning Any in a function that is supposed to return float
looking at type(float('nan')) gives me <class 'float'>
 
can you clarify what you mean by "nil value for a float type"?
Do you mean Optional[float]?
A function that returns float('nan'), float('inf'), -float('inf'), or any float value such as 3.2 only has the concrete return type float.
 
Naz
nil == absence of a value
so 0 is a valid value, -1 is valid value, so they can't be "nil"
but I reasoned that float('NaN') could be used as such
or maybe it is better to use None and then type it as Optional[float]
wondering what the conventional way of doing this is
my use case is decoding some values, but if I can't, I want them to have "nil" float values
 
The conventional way is to throw an exception if no valid value can be produced.
If you need a sentinel value for "no value", use None.
 
Naz
awesome. thanks. I think I have tried that but had other issues. Let's see :)
hmm
this is a scraper and these decoded objects will later go into a db, so None is a valid value, but if transformations are done in between I would need to check for not None
 
That's usually why exceptions are preferred. It sparse the need to separate valid from invalid values.
 
Naz
2:49 PM
But I know for sure that a lot of the values won't decode because a lot of the data is missing. So unfortunately, I have to use None
 
I don't see what the former has to do with the latter.
 
Naz
the data is sparse, it is still useful even if some of the data is missing. i don't want to be dropping all of it if just some single value is missing. but in such a case i cannot use a valid float value for the missing spot, like a -1 or whatever, i have to use something like None
btw, was TypedDict ever implemented in mypy
i can see it in PEPs
 
RCA: seems to be nohup running inside nohup
any alternative?
 
@Naz throwing an exception doesn't mean you skip all values, only the one for which an exception is thrown
@Naz typing.TypedDict is a thing since 3.8, possibly earlier with typing_extensions
@Aqua4 is there a reason why you don't run it as a proper deamon, e.g. via systemd?
 
@MisterMiyagi never heard of that, checking that approach now
will killing the ssh session kill systemd app as well?
 
2:59 PM
systemd is is the init service, it runs as long as the machine lives
 
Naz
@MisterMiyagi I am catching those exceptions, i.e. they are in try / except block. I log them, and in their place will now put None instead of the float('nan')
 
circling back to "When returning float('nan') [...] mypy says that I shouldn't be returning Any", I can't replicate that message
C:\Users\Kevin\Desktop>type test.py
def foo() -> float:
    return float("nan")

C:\Users\Kevin\Desktop>mypy test.py
Success: no issues found in 1 source file
 
@Naz why do you give back anything? If there is no value, putting one there is usually not good.
 
Naz
@Kevin whaaa. let me try to reproduce
 
This is an independent problem from the question of "is it a good idea to return NaN in this case?", but I think it's worthwhile to investigate
 
Naz
3:02 PM
@MisterMiyagi not quite putting. this implementation uses dataclasses_json and so I can define the decoders per field. And so when I fail to decode a value for a particular field, I have to use some value
by this, I mean mine
I define an API something like this
@datacls
class PriceObj:
    pricePeriodType: PricePeriodDesc = field(default=MeasureType.empty_instance())
    measureType: MeasureType = field(default=MeasureType.empty_instance())
    asOfDate: datetime = Fields.date_field()
    price: Optional[float] = Fields.float_field()
where those Fields.float_field() etc are the decoders
and these decoders look like this
sec
I am confusing you
and within those fields I am specifying the decoders
 
Seeing that class helps.
I was under the impression you were interested in just the values, e.g. a list of prices.
 
Naz
a field looks like this
class Fields(VanillaFields):
    @staticmethod
    def float_field(field_name: str = None):
        return VanillaFields.float_field(field_name, decoder=Codecs.float_decoder)
and then the decoder looks like this
class Codecs:
    @staticmethod
    def float_decoder(v: Any) -> Optional[float]:
        try:
            if isinstance(v, (int, float)):
                return v
            else:
                return float(
                    re.sub(r"([$€£])|(\sM)|(,)|(MXN\s)|(CHF\s)|(%)|(JPY\s¥)", "", v)
                )
        except Exception:
            return None
and you can see that None ^ above there now
back to float('nan'). will try to repro. sec
erm can't do it. When I come across it again, I will post an example here :)
 
Ah, the old "can't reproduce strange behavior even after reverting". I think we all know that feeling.
 
python app.py & disown
solved my problem
 
3:48 PM
Hi All
am facing None value when selecting attribute from id
this is the question i posted : How to get $0 value in Webbot using python
 
Sounds like you're referring to the question in this comment which was asked yesterday. A little close to the "no solicitation of recent questions" deadline, but I'll allow it
So the question is effectively, how to get "62.07" from the string "<div class="hiddenBox" id="afn-selling-fees">62.07</div>"
I don't know anything about webbot, but most html-handling projects have a method or attribute for extracting text from an element
Or, hmm, am I misunderstanding the question? It seems like your answer, "Got the value using text in place of get_attribute('outerHTML')
web.find_elements(id="afn-selling-fees")[0].text", ought to get the text
 
4:09 PM
If the element object is a Selenium element, I wonder if using .getText() instead of .text would help?
Oh, I guess you're asking about stackoverflow.com/questions/61613379/…, actually
Since that's only from three hours ago, let's let it sit for a while and see if anyone picks up on it... Come back on Thursday if you're still lost
 
wim
4:53 PM
@MisterMiyagi wow
"loses context" is silly, that's gonna happen with any string formatting syntax
I could agree that it further enables putting logic into template (bad) but that's only a potential for misuse
 
5:18 PM
I have a pair of sqlalchemy queries that looks like:
device_id = 14
device = Device.query.filter(Device.id==device_id).one_or_none()
# ... Something that checks if device is None, returns if it is
user = User.query.filter(User.id==device.user_id).one_or_none()
and I'd like to combine them into one query. i uh... kind of suck at SQL (I'm using SQLAlchemy)
i think I'd use a JOIN, something like:
device, user = Session.query(Device, User).filter(Device.id==device_id).outerjoin(Device).filter(User.id==Device.id)
from what I've read, this should give me all the results in the Device table, and only the matching results in the User table. is that correct?
i mean, i know i'm doing something incorrectly because it's not working :D
perhaps this is better as a standalone question?
 
Is user_id a ForeignKey in Device?
 
Is this a many-to-many, actually?
It seems from the model names that multiple users might have multiple devices, and perhaps each device has multiple users
 
each device only has one user. multiple users might have multiple devices, though
 
5:34 PM
Ok. And finally, why do you use one_or_none? My best guess is that you want all users of a particular device?
 
well, there should only ever be one user associated to a particular device
 
So what is the end result of the query?
Just the one user that uses a device?
 
something like:
[
    Device with ID device_id,
    User with ID Device.user_id OR None (if no users have this ID)
]
 
Then pass this off to the ORM. Set a relationship on the Device to the User
 
ah, i don't want to change the models just to accommodate this one query if it can be helped
 
5:40 PM
hmmm, but this is pretty standard stuff. Is the model part of another library?
 
no, but it's currently in production so i want to minimize changing the db itself. i think there's a way of accomplishing what i need to with joins
 
Maybe user = Session.query(Device).filter(Device.id==device_id).outerjoin(User).all()
Do you have an MCVE? I'm going off guessword, but it's much easier if I have a couple of models to play with
 
hah! that was it!
the mistake i was making was putting the ON clause in another filter statement
instead of within the "outerjoin" call
 
Not gonna lie, I totally winged that :P Huzzah
 
hahaha, well, it worked. ;D thanks very much
 
wim
5:50 PM
oh boy
https://github.com/AceLewis/my_first_calculator.py/blob/master/my_first_calculator.py
 
Repetitive strain injury just waiting to happen with the c/p. My god.
 
LOL that can't be real
 
They're asking for Docker support in the Issues; I think it's safe to say it's not :P
 
wim
# TODO: Make it work for floating point numbers too 😆
 
5:54 PM
PR: "New value added to calculator"
 
It's all worth it for this comment :P
 
i feel like people's ability to detect sarcasm has decreased drastically
 
wim
6:11 PM
ahhhh this is cool. starlink satellite train. youtube.com/… hack the sky!!
 
@roganjosh nobody has noted how it's safer than eval
 
I think that's totally valid feedback. Weigh in on the debate :P
That comment has really tickled me in its context. Sometimes it'd be nice to have that freedom to speak :)
 
wim
Think of how stupid the average person is, and then imagine that 50% of them are even dumber than that
 
6:36 PM
@wim said no astronomer ever
 
What do light themes look like nowadays? #000 text on #fff background?
 
look at SO chat?
 
The pinnacle of web design
 
^
I'm thinking of maybe going for a light blue background, but the problem is that even if it looks good to me, that doesn't mean it's a good light theme
 
I thought you were looking for bad examples :P
 
6:50 PM
@Aran-Fey screenshot?
 
because a theme that looks good to me is a good dark theme
 
@Aran-Fey I bet there are "guidelines for UIs" out there with consideration for people with visual impairment and whatnot
might as well use something that's along best practices if you don't have a personal choice
 
I think they specify more text-on-background kind of things, while the website as-a-whole may need 5 or 6 colours. You can google colour palettes that gives you this for a theme, but I'm not sure whether they consider screen readers etc
 
I've found stuff like ux.stackexchange.com/questions/551/… searching ux.SE
 
6:54 PM
I'm pretty happy with my 3-color setup, just need to find the right 3 :D
 
@Aran-Fey I think the background might be a bit heavy for blocks of text. I'd lighten the background a bit but otherwise it looks about right to me
 
(although I guess the CSS automagically creates some lighter/darker shades of those 3 colors)
@AndrasDeak huh, interesting. Seems they prefer large/bold text in dark themes, but I personally prefer the opposite...
 
It probably doesn't matter if you have 20/20 vision (which I don't, but I see just fine up close. And I use a blue light filter so colours change anyway.)
 
Welp, the code that generates dark/light shades of my 3 colors needs a major overhaul. Inline code looks completely black, no trace of purple
 
wim
@AndrasDeak pfff, astronomers and their dark themes
they can take their horoscope and gtfo
 
7:09 PM
I'm a fiery Scorpio and I find such comments as blustering. I can't help it; Jupiter is in its second quarter and Mercury is just around the corner. Duel. At dawn.
 
wim
oh, happy birthday to X Æ A-12 Musk (Taurus)
 
Was it decyphered? Or disclosed?
oh, we're talking zodiacs
astrology doesn't even deserve my snark
 
(not sure how astronomy and astrology got conflated but I just ran with it)
 
it was a joke
 
7:29 PM
ha, I've just seen a profile on LinkenIn with "Mancunian" as a language skill, and others have endorsed it. Yes, I'll accept that connection request
 
heh
 
@roganjosh I so want to check now if there's people that have put Cockney / Brummie or something :p
 
@JonClements There was a study (I'm really not gonna look it up) and I'm pretty sure they said that the Brummie accent was the most trustworthy re: telesales
 
"British scientists have discovered..." used to be a running joke in our media. Not sure whether that was a global phenomenon.
as in "British scientists have discovered why socks start to smell bad after two weeks"
 
We'd be none-the-wiser because we'd just see "scientists have discovered" :P
 
7:36 PM
wait... "used to be"... Brits aren't even worth mocking now... that can't be good :p
those kind of things are normally desperate "oh beep... we've still got funding to spend - think of something to research before we lose it!"
Think there was one uni here that spent something like £90k to come to the conclusion that people go to coffee shops to buy coffee and meet people... Now, my approach might not have been quite as scientific, but bloomin' sure I could have done it drastically cheaper :)
 
Eh, I could justify it. Silver nanoparticles are incredible in washing machines to prevent damp clothes going mouldy. Samsung uses them in their washing machines. 20 years down the line we may find that they accumulate in x and do y to z
So, smelly socks no more!
 
Darn... I was going for something like: "because they haven't been taken off in 336 hours..."
 
Eventually they may petrify on your feet. I guess you could burn the gases off once a day and everything would be good...
 
I wonder what insight Dave Lister could offer here... :)
 
I'll defer to the physicists in the room ;)
 
8:00 PM
Surely given the former conflation - you meant to say Psychics there? :p
 
Astrologers aren't psychic. It's a common misconception. They only read what the planets tell them is patently true.
 
there is that but they share a significant amount of common letters - so that's good enough for me!
 
:P
@AmagicalFishy I've just re-read this. A relationship doesn't alter the database
 
hello
 
hi
 
8:07 PM
hello
 
does anyone know how to create function graphs?
 
anyway... early night for this puppy... catch ya'll tomorrow at some point
 
rbrb Jon
 
@NickVen function graphs? You mean figures from y(x) or z(x,y) functions?
@JonClements rbrb
 
dupe, seeking target: converting dataframe column from numeric to string label, for plotting: stackoverflow.com/questions/61620167/… (I searched on stuff like [matplotlib] text labels numeric but can't see a good one. This is about labels for the actual data series, not about tick labels)
 
8:22 PM
done
 
@AndrasDeak Thanks but that's not exactly the same. That one keeps the data as numeric, but overrides the xticks with text labels. The one I cited has alternative answers tht actually transforms the series from integer to string with df.sex.apply(lambda x: 'Male' if x == 0 else 'Female') or np.where(df['sex'] == 0, 'male', 'female'), like a poor-man's categorical.. These each have subtly different implications.
 
good enough for me
the answer in both cases is "use p.set_ticklabels to set the tick labels to what you want"
 
So uhh if that one had the biggest diversity in answers, it might have been its own target.
 
really it's just "take the return value of df.plot and use matplotlib"
 
@AndrasDeak Not necessarily. Best practice is to convert a series that's essentially categorical to categoricals with string labels, or else string (from the days before pandas had a useable categorical). That way the label also shows up in tables, pivot tables groupbys etc. Anyway, no worries. But yes that's a wider context than that OP asked for.
 
8:33 PM
What's the canonical way to simply consume an infinite generator?
I could use tuple(generator) or list(generator) but will that waste time/memory in actually trying to construct a tuple or list?
 
What do you consider to be "wasted" time?
 
I want to do something like for x in generator: pass, but you can't have a for loop inside an expression.
 
@user76284 0-length deque
that's the official recommendation, it's somehow optimized I think
 
well, it's C code
 
@AndrasDeak Thanks, I'll try that.
Do you have a link to the official recommendation?
I see this question
 
8:42 PM
Dec 16 '16 at 18:44, by Antti Haapala
@wim the biggest wtf is that the itertools does not have consume... instead the deque has a fast-path for maxlen=0, whose sole use is to consume an iterator.
 
9:13 PM
@AndrasDeak That's worthy of being added to the canon. But that question as currently phrases doesn't say 'could be infinite'. or 'consume'. or 'without wasting any memory'
 
consuming infinite generators is a valiant effort
 
@PM2Ring That prime-sieve code is seriously cryptic and tricky, it would be well worth posting a fully annotated version as an answer that explains all the speedups and memory tricks.
@AndrasDeak Is that better than doing all(it) and not assigning it to anything?
 
Off the top of my head, it might yield a falsy value
 
9:32 PM
Maybe all(it or True)
 
huh?
am I missing a joke? :)
 
Am I mixing convos here? I though @smci was proposing a shorter version of the 0-length deque
 
yes, they are
it or True is probably just it, is it not?
 
all(it) won't necessarily consume everything, once it hits a falsey value. But what about all(it or True)?
 
you'd want the "or True" to go inside the iterator
 
9:34 PM
all(x or True for x in it)
 
yes, that works as an expression, but it's probably "slow"
 
There’s an itertools recipe called “consume”
 
all(True for x in it) or anything
 
Oh sure
 
@user76284 which uses a 0-length deque, doesn't it?
 
9:35 PM
Yep
 
 
2 hours later…
wim
11:25 PM
quick poll, do you have both /usr/bin/python3.6 and /usr/bin/python3.6m executables and they are same inode (hardlink)?
(modulo whatever minor version you have)
 
wim
11:54 PM
is Wayne Werner still with saltstack? haven't seen them around for a few months
 

« first day (3489 days earlier)      last day (1462 days later) »