« first day (3452 days earlier)      last day (1503 days later) » 

12:31 AM
cbg!
 
1:01 AM
ugh, daylight saving
 
 
3 hours later…
4:00 AM
cbg patch
 
Can anyone please help with my python project question?
 
im positively confused about how this scikit fit_transform works guys
fit/fit_transform, I've been working with a bipartite network that has 51+91 nodes (142 input nodes as a biadjacency) but I have no idea why it returns 284 results on a fit transform
 
 
2 hours later…
5:37 AM
just implemented in python CFFI a linux filesystem that I can mount to the os filesystem
 
6:14 AM
Anyone can help me to provide detailed steps how to deploy flask application in any free hosting provider
 
 
2 hours later…
8:34 AM
How could I distinguish between a URL and a local file path? I thought urlparse would do it, but that can actually parse linux-style paths
similarly, Path(an_url) doesn't crash either
 
that answer is killing, he just go from the main issue.
 
ah, isn't it great when you post a solution and the OP follows up with "that doesn't help, now my code fails because of this other mistake I made"
 
he directed the OP in the wrong direction and ending up with asking him to try encoding="utf-8"
 
user10984358
This answer stackoverflow.com/a/36943813/10984358 tells me what ever I was "taught" in my supposed python training is all wrong
 
user10984358
they had this automated code checker that wanted to you write "getter" and "setter" else your code would fail and you wont clear the course
 
user10984358
8:49 AM
beginning to wonder how much of what I picked up there is anti-pattern
 
@αԋɱҽԃαмєяιcαη The wrong direction? Are you saying soup = BeautifulSoup(page.text,'html.parser').encode("utf-8") is not a bug? There's no way that works, right?
@TheNamesAlc The two usual antipatterns come from java: 1) pointless getters and setters and 2) pointless classes
 
user10984358
we were the first group of students to which they thought python, till then they were teaching java, so they just changed the syntax I guess, you are right, they had me write classes for everything
 
user10984358
I have been looking into decorators, see if I can incorporate them more into my code
 
if i do

apple = orange = new Fruit()
orange = new Vegetable()

does the value of apple change to Vegetable?
 
user10984358
what do you think it does?
 
8:56 AM
i think apple is still a Fruit, so it isn't a pointer to orange
 
user10984358
is new legal python?
 
or in other words, when apple is initialized, it creates a clone of orange
so changes to orange don't affect apple.
i'm seeing this syntax in leetcode solutions so it must be the case, however i'm having a hard time wrapping my head around it
 
@Aran-Fey encode and decode functions is working with bs4. but bs4 by itself is actually getting the encoding when you passing the content
 
You're correct. Each variable is independent of all other variables. Assigning a new value to a variable doesn't affect any other variables
It's a different story if you're mutating the value stored in a variable though
 
it's hard to wrap my head around this because this is used in a linked list programing problem
they do something like head = dummy = Node()
then they change dummy, but head still points to the head node of the linked list
 
9:01 AM
yup
 
so head doesn't point to dummy per se
head and dummy point to the same instantiation of Node()
and as dummy is changed, head still points to that same instantiation
 
Hello
 
it's just weird because it feels like head should follow where dummy goes
so i guess this syntax is supposed to allow for 2 variables to point to the same object essentially
 
Is there a chatroom where I could find experts to deal with my windows booting problem? (I know this is not quite the right place to ask, but please help if you can)
 
Yes. Variables can only point to values, not to other variables.
@UmeshKonduru You'll probably have more luck on superuser rather than SO
 
9:05 AM
Ok thanks, I'll check it our
 
well i run into issues when i try to do date modifications in PHP, so i'm always having to clone the objects
 
out* and sorry for the interruption
 
i'm unsure if that's language-specific
for example, if i do now = new DateTime()
start = now.format("XXX")
now.modify("+1 day")
my start gets modified
maybe not if i call format, but if i do start = now. but it may be language-specific.
 
It is language-specific, but as far as I know most high-level languages behave the same way in that regard. I'd honestly be surprised if PHP really did that
(high-level imperative languages, at least)
 
so i just did a test on phpfiddle
if i do

$now = new \DateTime();
$start = $now;
$now->modify("+1 day");

they are both identical
however, if i redeclare the value of $now
$now = new \DateTime();
$start = $now;
$now = (new \DateTime())->modify("+1 day");
they are 1 day apart
so i guess it has to do with the redeclare. it won't follow the new reference even though the variable name is technically the same.
and i think that's the same behavior in python.
 
9:12 AM
Yeah, that's the difference between changing the value of a variable and changing the value itself
 
yeah i think it's because my brain just assumes that calling a class method which modifies the class == changing what the variable points to
clearly not the case
appreciate the response!
 
10:01 AM
@RobertCalove Don't say 'class method' when you mean (instance) method.
 
@smci common mistake
 
10:34 AM
in your opinions guys, is that considered as an answer ?
 
11:43 AM
@SatyaVejus as per our rules please don't ask for help here with fresh questions on SO main
@αԋɱҽԃαмєяιcαη yes
 
12:00 PM
@Aran-Fey with file path, do you mean something like /var/log/foo (or even C:\...), or a file://... URL?
 
the former
anything you could pass to open, basically
 
as a first step, I'd use urlsplit and check whether it has a scheme.
in principle, a file path is a valid (albeit not complete) url, so "is it a URL or a path" is a bit like "is it a car or a porsche"
 
Sunday cabbages!
 
cbg
 
checking for the scheme works, thanks
 
12:57 PM
@Aran-Fey seems that's the only way though solved
 
1:20 PM
r = requests.get(
    'https://en.wikipedia.org/w/api.php',
    params={
        'action': 'parse',
        'prop': 'text',
        'format': 'json',
        'section': 3,
        'page': '2020_coronavirus_pandemic_in_the_Philippines'
    }
).json()
df = pd.read_html(r['parse']['text']['*'])[0]
@αԋɱҽԃαмєяιcαη What's wrong with ^^^ ?
Ahh... status doesn't look like it comes out... umm... okay
 
do you think i will miss that :D
status + recent travel history
 
@αԋɱҽԃαмєяιcαη you never know - we all have our "blonde moments" :p
Umm... wonder if it's in the original markdown
 
it's in the content of pseudo element yes
::after and ::before
 
1:35 PM
Umm... why would wiki do that...? You'd have thought they'd put it as actual content in the table but then just do the actual styling in the css... weird
 
I've a note on my internal dashboard from google that wiki masked some columns within tables due to privacy. specially with trend things. the real reason behind the scene that some science is based on that info which is still unconfirmed 100% such as recent travel history and status
 
umm... seems rather pointless even if that is the case
 
if you going to track the HTML page, you will see that some values is keep changed during the day. such as recovered got died. and has travel history from no to yes. and so on
 
okay... but if people are doing that, then the best that's achieved is just making it slightly annoying
 
wiki is under a mess nowadays. because it's keep receive a bulk of spam edits with invalid/wrong info.
 
1:44 PM
@Gog lol no
 
i think that they really need to increase time edit.
 
Gog
@AndrasDeak :(
 
Gog
:48974141 sorry
 
for reference, @Gog please see our room rules
 
1:53 PM
@DebkantaMondal See, .e.g., deployment on Heroku
 
Hi, I'm trying to draw a star on the screen, writing the following text:

    self.screen.blit(self.image, self.rect)
Why do I need self.image and also self.rect ? isn't self.rect enough?
 
2:13 PM
You'd have to check how self.screen.blit is defined...?
once you have a function in a library you have to play by its rules
 
2:23 PM
actually this text is written inside a function:

def blitme(self):
    self.screen.blit(self.image, self.rect)
 
Okay?
 
ooo hello... there's a "follow" on posts now...
 
@YoelZajac I googled for pygame blitting and in the first three SO questions I saw an image arg first passed as .blit...so it seems business as usual. I'm not sure what you're asking.
@JonClements what I really need is a "remind me in 2 days" ;)
 
it's the same as favorite but here the notification will be on :P
 
and favourites are renamed as bookmarks, or they will be
 
2:30 PM
Hi all, I tried searching online but can't find an answer, therefore thought I ask here. If I have a nested dictionary and I instantiate one of its child dictionary to a variable, is there a method call to return the parent of the child dictionary. For example, in JavaScript object.parent always returns the parent value, so wondering if there is a similar thing for python dictionary?
 
If you're talking about something like; {'a': {'b': 'c'}} then no... {'b': 'c'} has no idea what it's referred to by
 
I thought that
    self.image
is unnecessary since I already converted the picture to a rectagle... Why not writing only
self.rect ?
 
@YoelZajac do you know how the blit method works? I don't, because I'm not familiar with pygame, but I'm not certain you do.
 
@JonClements Oh okay thanks, yes thats exactly what I was asking about
 
2:56 PM
cbg
 
3:15 PM
hello
 
I have a question: on tio.run/##K6gsycjPM/r/… is it easy to make the Footer section receive multiple lines from the Input section?
Input here simulates the keyboard stdin console
 
@sergiol you'd have to ask the admins of TiO
 
This is a Python question, not a TIO question!
 
it is?
OK, sorry, I misunderstood your phrasing
 
3:18 PM
what change should I do in the footer code to make it process multiple input lines?
 
use multiple calls to input()
 
thank you
 
I suspect your current code doesn't do what you want it to do
ah, nevermind, you're on python 2...
I hope you're only using python 2 for code golf :P
 
Now I should replace the True in the while by what, to not get EOF error?
 
your code didn't update on that link
 
3:29 PM
sorry. real link is
https://tio.run/##K6gsycjPM/r/P60oP1chOT8nv6i4slghM7cgv6hEy7ooPSm@JD8@I6eYCyKkAJT9X56RmZOqEFJUmmrFxVlQlJlXooBQqKGVmVdQWqKhqfnfoMLYWEfBoMLMDERaWnLBmDABAA
 
Did you actually google "read multiple lines" or something like that? This is bound to have a lot of duplicates.
 
I achieved it using exceptions, but not a solution which I enjoy much: tio.run/##RYzBCoMwEETP5iv2qNKDKAjas7320ru0kjaBmF02K02@PrYF6RyGx/…
 
3:45 PM
Is this for code golf?
 
4:00 PM
not, but also not serious programming
and BTW I was not expecting to receive a negative on the S values
OK, now I know why
21
A: Converting RGB to HLS and back

abarnertYour values are way, way outside the bounds of the colorspace. From the docs: Coordinates in all of these color spaces are floating point values. In the YIQ space, the Y coordinate is between 0 and 1, but the I and Q coordinates can be positive or negative. In all other spaces, the coordinat...

I was expecting RGB input to be in the range 0..255
 
@sergiol OK, so 1. start using python 3, 2. don't squeeze the input() call inside the other function call. Read the input on a separate line, and protect only that with the check for EOFError (if you can't decide in advance how many lines there will be).
 
4:20 PM
Ummm... interesting effort
It's an "inspired" approach but... it's one of the first questions I've seen today where they've actually tried printing stuff to work out what's going on instead of just going "what's happening here!? helpz!"
 
4:44 PM
Yay! We can now Follow questions & answers. meta.stackexchange.com/q/345661/334566 I've been wanting something like this for years.
5
 
@PM2Ring that was my reaction as well :p
 
IMHO, this could have a big impact on getting improved questions reopened. I'm a little sceptical of the new proposals here: Upcoming Feature: New Question Close Experience, particularly allowing a "substantial" edit by the OP to single-handedly reopen a closed hidden question.
 
Wow... have gotten bored of depressing news on the radio so having a jump about in music collections... Can't believe Eminem's Marshall Mathers album is coming up 20 years old!
 
user11585758
5:10 PM
Guys
 
wim
5:23 PM
most overrated rapper in history
 
@wim so are a lot of 'em :)
 
wim
I did liked the catchy hook in "my name is" until I learned it was wholesale ripped off from Labi Siffre 1975
 
 
1 hour later…
6:40 PM
at least he isn't entirely reliant on autotune like 90% of the others
 
@ParitoshSingh when you froze your Flask app into an exe, what was the database you were using?
 
hey, it was just sqlite i think?
 
Sorry, I was rude; cbg :)
 
Come to think of it, im not a 100% sure we even had a database for that task. What database are you planning to use though?
@roganjosh oh nah nah! i never took it that way :)
but cbg indeed!
 
I don't know. I was curious whether you had a config file outside of the exe that could configure the database connection
 
6:43 PM
So, funnily enough, this is one of the things which i don't actually forsee being difficult with making exes
(and i hope i don't have to eat my words :P)
 
... Kinda hoping you won't, either :P
 
As long as the library itself packages fine, figuring out paths is a "solved" problem
Essentially, there's a sys._meipass or something similarly named
make sure you actually "construct" full paths, and you can set it to use that as root, and you'll be fine. Any config files, you have a -add-data flag
This way, both paths and the "non py" files become non issues.
At least that's my recommendation on how to go about it
 
Ok, so you could distribute an editable config file with an exe?
 
yeah, sure
though if you want to let someone else edit it too, i'd suggest not bundling it as a one-file
 
provided the relative path is the same (e.g. in the same directory)
 
6:46 PM
just zip the whole folder, that way someone isn't exposed to the sys._meipass issues at all
and that way, you don't have to deal with the cwd changes either
But yes, if you wish to do it the hard way, and keep it as a one-file option, it's definitely possible. no issues that i can think of
just, simplest approach: even if you're tempted to use relative paths, just name a global variable called ROOT, set to your cwd during development, and construct the full paths from this ROOT
when it comes time to making this exe, switch out the ROOT for the sys._meipass dynamically, and you;re done.
because otherwise relative paths with one-file will point to the wrong directory.
 
I'd really prefer not to, but this keeps flashing in my mind as an option and your name is associated with the idea, sorry! :P
 
haha, no worries! yep, can be done. easier: don't use the one-file flag, code normally. slightly harder: if you wish to use one-file flag, make a ROOT global folder variable*, construct all paths (that would have otherwise been relative) from it. That's the tl;dr
 
Ok, thanks for that mate :)
 
7:08 PM
@ParitoshSingh Might be an antipattern, but an insurance I've used before is early in execution I have a line changing the cwd to where I want it to be, and have a handler generating abs paths from rel paths where that's needed.
 
That is bundled into an exe?
 
I've never bundled into an .exe, but I don't know how having os.chdir(sys.path[0]) or whatever you want the ROOT set to, early on in execution, then having a handler for key paths, would go wrong when bundled to an exe?
 
cbg
 
The issue is, your cwd doesn't point to where you think it should when bundled as an exe in onefile flag
So, the paths during development and the paths during exe-bundling mismatch if you rely on cwd
 
7:14 PM
if you guys want to configure your programs and need to have a user config, why not let appdirs handle the pathes? That's what I usually do
bundle a default config into the program that will populate the config file on init, and after that read user settings from there
 
@ParitoshSingh Oh ok. So more or less if you pin down at runtime what the cwd is (when bundled as exe), you should be ok configuring the paths relative to that?
 
indeed
so in that sense, your approach is quite similar to mine
except, im relying on a ROOT variable to manipulate, while you'd be using chdir i think iiuc
 
wim
@Arne huh, I did not know this project. nice.
 
@Arne ok, that looks like it fixes my worries. Would you get the app to write a default config to that directory instead?
Rather than having an internal default; wouldn't it be better to write the default out and have it easily editable?
 
sounds like a good idea to me
 
7:20 PM
@roganjosh yeah, that was what I was trying to say. The internal default is never used directly
 
@Arne Indeed you did; "that will populate the config file on init". Sorry, I misread the message. Makes sense
 
wim
@Arne I usually do differently - make the config file optional, and defaults are hardcoded
 
@ParitoshSingh Yes.
 
wim
if you write out a config file at install time then you're obliged to figure out what to do at reinstall/upgrade time (overwrite it? preserve it? what if there were backwards incompat changes or deprecations)
 
@wim if I can get away with it, I try to only have the config file, so that the answer to "where is that setting from" is always "from the config"
 
7:26 PM
thats a fair point, but at the same time, its easier for someone to modify a config rather than make it from scratch
 
@roganjosh I had that in an answer recently stackoverflow.com/questions/60406272/…
 
7:38 PM
@wim That seems like a problem for internal defaults as well. If an internal default changes, do we just silently run with an old configuration that didn't use it, even though it results in different behaviour?
Not writing out the config file doesn't free one from making such decisions, it just silently makes some of them implicitly, no matter if they are correct or not.
 
7:53 PM
optimally, you'd just never introduce changes that break backwards compatibility. and if you do, create a new config (with the version in it's filename) that picks up valid non-default settings from the next oldest one.
 
I like the way the povray raytracer handles configs. It's a CLI program with a huge number of settings, which can be given via plain text config files or command line args, and almost all of them have sensible internal defaults. The priority is internal < config_file < command_line. And one of the command line args tells it to write a config file with the current settings.
 
ah, that sounds like the best of both worlds
 
wim
@Arne in practice you often need to override config from CLI and/or environment variables
@MisterMiyagi so what I do is I still parse and use it in one minor point release, but I'll warnings.warn that it is deprecated and will be ignored in the next point release (along with a short description of the replacement, if any).
 
@wim yeah, in particular secrets that need to be read from env mess up my config-only wishes =)
 
What's the benefit of storing secrets as envvars?
 
8:07 PM
1) it's common 2) having them send via command line means they are visible in the process list 3) having them in a file feels more risky - an env is more user/session bound
there might be a better way to phrase the last point
 
@Aran-Fey you don't distribute them with git
 
wim
I don't like secrets in env vars
the env has a habit of getting slurped up by crash reporters and monitoring tools
and child processes will inherit your secrets by default
 
8:23 PM
what then, a well protected file?
 
wim
yes, correctly permissioned file (owner and mode)
or use dedicated software such as vault
Feb 11 '19 at 22:04, by wim
I recommend not to use environment variables for secrets.
 
8:44 PM
worth a thought, maybe I should adapt
 

« first day (3452 days earlier)      last day (1503 days later) »