« first day (3618 days earlier)      last day (1555 days later) » 

03:37
@AndrasDeak That's the only sensible option, really
 
4 hours later…
07:12
Hey folks
 
2 hours later…
08:42
@toonarmycaptain heh, and they've sent me an email saying it was all successful. I guess the secret agent that now has my identity did his job already
 
3 hours later…
Closed
12:39
morning cabbages, folks
12:50
what's up doc? :p
A wild Jon appears :)
Hello sahal
it's been a while since I graced you with my 3 legged presence so thought it was about time :p
Puppy! Long time. Potato?
13:10
Double checking room rules, I'm allowed to ask a question here and if that's not fruitful I can post on main? Pretty sure that's a yeah, so I'll ask too. If I have a generic class FooMixin that I'm exposing in a library, can I get the the return types of FooMixin to mean FooMixin and any of its decedents?
def FooMixin(Generic[T]):
    def get_child(self, key: T) -> FooMixin[T]: ...
Type annotations automatically include subtypes.
Not for return types
@Peilonrayz in terms of the rules, that's fine. It's the other way around that's a problem (asking on main and then linking here straight away)
@roganjosh Nice, thanks :)
@Peilonrayz Do you have an example? See e.g.
class Str(str): pass

def bar() -> str: return Str("bar")
13:18
Mypy allows that as it converts the subtype Str to str. I want it to not do this and instead return Str. See here
> "ExampleMixin[str]" has no attribute "value"
You are looking for def get_child(self: S, key: T) -> S: ...
Your original annotation just means the methods returns any FooMixin[T] type. You want to return the same FooMixin[T] type, though.
@inspectorG4dget Sorry - got distracted for a moment... all good here thanks... you?
No, it returns the, not any, FooMixin[T] type which causes the subclasses to lose all their type information if they use the mixin methods. I want to return the descendent's type
13:26
Is there a dupe for this? The comment trail is silly; they just need to replace a hyphen with an empty string
@AndrasDeak 1000$ cupon for Andras :) And a ticket on a cruise to the Caribbean.
@roganjosh Will be hard to find a dupe since it's 2 tiny problems rolled into 1 question. I'd close as too broad
I've already VTC'd as needing more detail, before they told me that month "21" was random
13:47
@JonClements all good. So far so good, on my end. Trying to stay sane, working from home
Meh... staying sane isn't worth it... just give in and embrace your insanity - it's way more fun! :p
hahaha. In other news, I wish more services would expose APIs. I am now scraping a website with a combination of javascript, ctrl-c/v, python, applescript... ew!
oh... tell me more... I seem to be doing a lot of scraping recently... (recently as in the last 2/3 years...)
ugh... now I'm confused... I've added 980 emails to a system to send and Amazon SES says it's sent 1296... that's err... huh?
14:09
A win? Maybe it shipped off the junk emails too
I used JS to list all the HTML elements of the links I want to scrape. I copy/pasted those from the console into a text file. Python read the lines of the text file to instantiate the templated appleScripts to "tell chrome to open the page and save in default location". Zsh then ran all these apple scripts
You mean it added 316 junk emails for me? How nice of it :)
@JonClements I hate it when the binmen come round and just dump it all back on the garden path :'(
@inspectorG4dget sounds like you could have done a very simple scrapy spider and then a batch file to loop over the files in the directory to execute your apple scripts...
@roganjosh I'm jealous you've got ones that come round :)
@JonClements I wish. CloudFlare kicked the yams out of any wget/curl/requests. But if you know of a way that I could do that, I'm all ears
14:14
First thing to do is check you're actually using a user-agent header that's an actual browser...
There's a cloudscraper module which may or may not help
    I'm confused about a simple zipfile.ZipFile run in python. Both paths below are absolute paths -- when I unzip the file below line makes it turns out to be a nested directory of the folder in the path and the extracted file in the last folder.
How do I pass an absolute path to write a zipfile?

zipfile.ZipFile(move_filepath, mode='w').write(filepath)
ooh! thanks
@inspectorG4dget so in scrapy, you'd edit your settings.py to have something like: USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36' instead of having it default to something that obviously isn't a browser :)
@pyeR_biz We have a guide for formatting in chat :) You've had a few valiant goes. You can't mix block formatting with text; you'll need to post as separate messages
14:19
I'll have to give that a try. Thanks much :)
@roganjosh I know that, I've forgotten how to do it :) and I tried as well, and I tried by reading the guide as well, but I couldn't do it :D . I'll repost.
@pyeR_biz no need - it's readable enough for now :)
@pyeR_biz as jon says, it's readable enough. At the bottom of the guide is a link to the sandbox if you need in future
@inspectorG4dget and obviously wget/curl if you don't really need scrapy (eg - you don't need to be too selective in what links to follow to get things) support setting headers...
IIRC the argument to ZipFile's write is always treated as effectively relative to the directory that the zipfile is currently in. If you want to move the zip archive to a different directory, you don't need zipfile. Try shutil.move instead.
14:23
@JonClements I added user agents and cookies to wget, but that didn't seem to work. I kept getting 503s. It's further unhelpful that this website is behind a login.
Ah, the old dilemma of "I could spend the next two hours getting to the bottom of this mystery... Or I could copy the page source into Notepad and take an early lunch"
oh right... then in scrapy, you'd have the first request it makes be a POST to the end point to login, then take the response of that and follow it to the main page so you've got your cookies intact and all that, then filter out what you want to follow, then follow those on that response object...
@roganjosh Thanks, took me 6 more tries
@roganjosh I guess he put your email rather than his down in forms...either sloppy or sticking to cover. Either way, I'd keep some cash and EU/Br passport around, whichever number you didn't give out.
@pyeR_biz welcome to chat
@toonarmycaptain or an Aston Martin turns up and I get the keys first
15:00
Hi there, I'm having problems with django-acitivity-stream. I use python3.7.5
I guess maybe it's a bit outdated for 3.7
In my experience, a version or two doesn't make much difference unless you're using a cutting edge feature
@Kevin the problem is that when I send actions nothing shows up in database or queries. I also get no errors.
Sounds frustrating. If you have an MCVE, I'll play around with it, but otherwise I don't have any ideas
@Kevin Okay I prepare one
@roganjosh Touche, Mr Bond.
15:08
This is a quick one:
>>> p = Port.objects.all()[0]
>>> from usermanager.models import User
>>> u = User.objects.all()[0]
>>> print (p)
Port object (1)
>>> print (u)
adminfiction
>>> action.send(u, verb='was saved',target=p)
[(<function action_handler at 0x7faa4e07f830>, <Action: adminfiction was saved Port object (1) 0 minutes ago>)]
right now it seems it works, but nothing added to the db
I don't use django but in SQLA you'd have to do session.commit()
Indeed a better verb here is has saved
The ORM is usually irrelevant when it comes to the need to commit transactions, unless django turns autocommit on by default
Yeah, autocommit is the default for django
15:17
Hmm, where is send() defined? I don't see it in the Django Activity Stream api.
Hello guys, Is there a tool available to check if many email accounts exist or not?
By many I mean 1000+ email ids
I think the only way to check if an email exists is to send it something and see if that fails
For 1000+ email addresses its goinna be hectic
I searched on youtube and they showed some java code
but not working the way I want
You'll have to ask in the Java room about that.
@rangerboyy there's (paid for) online services that'll do that for you
15:26
@Peilonrayz As said, you want def get_child(self: S, key: T) -> S: .... S is the specific subtype. FooMixin[T] is any subtype, i.e. just what the common supertype FooMixin[T] provides.
@Kevin I'm trying to write a zip to 'move_filepath' from an xml file in 'filepath' with the line: zipfile.ZipFile(move_filepath, mode='w').write(filepath)
@rangerboyy Also, the best you can probably do is 1) validate the email address you have is actually a valid email format, and 2) verify the domain for that email actually has some MX records... it's worth noting that most email servers now even if sending a VERIFY request for a recipient will just say OK even if the mailbox doesn't exist - just to avoid being able to phish the server for valid recipients
@MisterMiyagi How can I pass S as the class I'm defining? class Bar(FooMixin[Bar, T]): ...
class FooMixin(Generic[T]):
    def get_child(self: S, key: T) -> S: ...
Now that I read the documentation for ZipFile.write again, I've decided that i don't know what it does.
15:30
S is a typevar of get_child, not of FooMixin
@JonClements Thank you so much I'll try that
Ah, that may work I'll test it out now
@pyeR_biz Have you tried supplying the arcname argument? Try zipfile.ZipFile(move_filepath, mode='w').write(filepath, "filename_goes_here.xml")
With a very short look it doesn't work but I'll see if I can hack something together. Didn't know you could pass strings to bound that'll make things so much simpler. Thanks MisterMiyagi
15:37
Sigh, another vacation day spent in my home office... I got the Very Important Email I was waiting for, but I need to send back the TPS report that only my coworker has access to, and they're taking their time finding it.
@Peilonrayz Let me know if it doesn't work anymore. Annotations are a moving target for these kind of things.
Usually I don't mind bureaucratic gridlock, but usually it doesn't prevent me from playing videogames
15:52
@Kevin :(
waiting for a TPS report rather than playing a TPS
I'm 500 lines into a prototype to generate a CSV, and now thinking I should have just hard-coded the 16-line CSV...
Relatable
Your inspirational message for the day is "never give up! Unless a rational cost-benefit analysis, free from the sunk cost fallacy, reveals that giving up is superior to not giving up"
@MisterMiyagi I figured out the problems. Obviously attribute annotations don't work and that with a couple other issues were making mypy complain a lot. I can skirt around that and hide all the silencing of mypy in the mixin so the consumer doesn't notice. Whilst not optimal, this is better than running around without any typing. Thanks
16:09
@PaulMcG it is always like that, you spend 20+ hours automating something that requires 2 mins, but it does help.
I have just spent an hour on a script to automatically create a sqlite db and tables in it and still solving issues lol.
16:27
@AshwinPhadke Life of a programmer :D
16:59
@AshwinPhadke Yes, I know - I'm actually leveraging an 1800-line prototype I wrote 10 years ago (now released as littletable).
17:55
Hey guys! I've been making a pong clone in python. I've done it before, and could totally whip something up in literally a few hours, but I'm doing it more as an excersize in good programming practices and OOP.
I have a main Game class, a Paddle class, a Player class, an Enemy (AI) class, and a Ball class. So the problem is with collision detection between the ball and the paddles. I don't know whether to put the function/method that handels this in the Game class, the Paddle class, or the Ball class. Any suggestions?
@ThaddaeusMarkle Paddle/Ball locations might be in their classes, but I'd put the game mechanic in the Game class.
Hello
@toonarmycaptain So like a check_for_collisions() function in the class Game?
header = self.table.horizontalHeader()
header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
I have a question:

How can i do this:
In QtDesigner?
@ThaddaeusMarkle Depends how you organise it, but that's where I'd put it. I don't know any Qt though, sorry.
17:59
@toonarmycaptain Thanks, that's kinda what I was leaning towards, but I wasn't sure. I guess that's what I'll go with.
@Kevin Thanks, that got me closer, I'm making a similar mistake in zipfile.extract -- will figure it out
@ThaddaeusMarkle I mean, depends how modular you want to go, you could have the mechanics in a separate class that's an attr on your Game class (eg Engine), which shrinks down the size of you game class.
@toonarmycaptain So like a Collider class?
Name it whatever you want! As long as it makes sense.
I don't think that's necessary for Pong ;-). Plus, in that case, I'd still have to have a function somewhere (probably still in the Game class) called check_for_collisions or something like that, the only difference would be that the actual logic would reside with the Collider class
right?
18:08
I don't see why you'd need a function like that. You must have some code that moves the ball and paddles around, why not just check for collisions there?
@Aran-Fey Functions are supposed to do "one thing, and one thing very well". Moving is one thing, collision detection is another, therefore they should be in separate functions.
Of course, many people don't do it that way, and for smaller projects (like pong) it doesn't matter too much. But I'm doing it as a "practice" for larger projects, so I want to do it the same way i would there
You might be interested in the Entity–Component–System architecture: en.m.wikipedia.org/wiki/Entity_component_system
So the plan is to create a move() function and a collide() function, and then every time you call move(), you also call collide() afterwards?
Will you ever, under any circumstances, call only one of those two functions without calling the other one as well?
Unity uses a component system, IIRC. Anything that needs to do collision detection possesses a Collidable component, which will call onCollide callbacks at the appropriate time
18:13
I have about a dozen games in my project graveyard that have painfully taught me that conventional OOP design isn't all that great for video games
@Aran-Fey Not exactly. I have a Ball class, a Paddle class, and a Game class, each of which has a move function. The Game class will call the move function for each of the two paddles and the ball, and will call its own collider function.
video games are hard
...and also common beginner projects, unfortunately
@Aran-Fey lol
Ok, that design sounds reasonable then
@Aran-Fey reminded me to go check epicgames... for what their freebies
18:16
@deltab Just quickly reading over the intro, this looks like exactly what I'm doing, I just didn't know what it was called ;-).
re-cbg.
18:31
hi
@user3019375 please don't ask for help here with fresh questions on the main site as per our rules
 
2 hours later…
20:44
hi everyone
if I have a dataframe, like this:
+----+-----+-----+-----+
| | A | B | C |
|----+-----+-----+-----|
| 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 |
| 2 | 0 | 0 | 1 |
| 3 | 0 | 1 | 0 |
| 4 | 0 | 1 | 0 |
| 5 | 0 | 0 | 1 |
+----+-----+-----+-----+
how can I get a column like this?

1
1
2
3
3
4
(ie enumerating the columns which are different than their immediate neighbours)
Looks like you're after pandas.factorize
thanks!
21:00
I don't get the question nor how that's the answer :)
... pandas
It looks to me like it's a groupby followed by a factorize but I'll be honest that I've been too lazy to test
Factorize sounds like [0, 0, 2, 1, 1, 2]
It'll number entries top-to-bottom
this doesn't answer the question I have posted above
but it solves the original question I had (& I thought the way forward is to solve the question I had posted above) - turns out, there is an easier way.
I don't get the requirement unless it's something like (df.iloc[1, :] == df.iloc[:-1, :]).all(1).cumsum() + 1 or similar
@zabop XY problem
21:05
@AndrasDeak that wouldn't give the repeated 1 value for the first two entries?
@AndrasDeak oh ok, sorry :/
@roganjosh oh yeah, some work needed
The linked answer does what I meant correctly
(df.a != df.a.shift()).cumsum()
I can't argue with that (I don't think)
I guess != is enough to change
And I forgot a : in [1:, :]. Oh well, mobile problems
So much effort to avoid cuddly pandas

« first day (3618 days earlier)      last day (1555 days later) »