« first day (2574 days earlier)      last day (2378 days later) » 
00:00 - 17:0017:00 - 00:00

5:00 PM
@PM2Ring It's actually not a parentclass/subclass problem, it's a class/instance problem. Basically my Crossbowman class has a health attribute (representing how much health crossbowmen have), but I'm also creating instances of the Crossbowman class, which then interpret the health attribute as "the unit's current health"
 
I feel like there are good use cases for circumventing Python's built-in OO system, but darned if I know what those use cases are or if this is one of them
 
@Rawing Oh, ok.
 
Sorry if it's confusing, we all know I'm not the best at expressing myself clearly :D
 
I wonder if some kind of prototyping system would work here? Like, you create a Crossbowman instance, setting his HP to the maximum HP that any crossbowman could have. That instance remains unmutated during its lifetime. You do a deep copy on the instance to get crossbowman whose state you're allowed to mutate.
Maybe give each mutable instance a reference to the prototype, in case you need to access static values such as maximum hp. crossbowman_steve.prototype.hp
 
Crossbowman = functools.partial(UnitType, max_health=10)
 
5:07 PM
@AnttiHaapala wow haha what a double
from telnetlib import EC
 
Maybe if you need additional information, you could throw a typename param in there just for debugging purposes
 
@Marilee coming from PHP is not a sin - quite possibly even an act of repentance. Returning to PHP on the other hand is the one that Dante forgot from the list of eight deadly vices. — Antti Haapala 1 min ago
 
@AnttiHaapala but there is no EC from selenium
which package do I have to import?
 
@Suisse because it is a shorthand
d*rn it wasn't there.
@Suisse EC is a shorthand for a module...
so you import invisibility_of_element_located
 
a module.. hmm what? which module? not sure
aha
 
5:11 PM
@Suisse from selenium.webdriver.support import expected_conditions as EC
 
hmm
ohoo
didn't knew that
 
obligatory "modern PHP is fine"
 
maybe I should read some beginners tutorial in python
 
@Suisse how could you know that? it is not obvious at all to most of the people in this room
 
The guy who wrote "PHP: a fractal of bad design" no longer considers it a very constructive article, and maybe that should inform our own attitudes towards the subject
 
5:15 PM
@Kevin why not?!
it is still bad
 
@Kevin Did eevee ever consider it a constructive article? ;)
 
@Kevin I'm not sure I understand the purpose of the prototype. You're saying the prototype takes the place of the Crossbowman class? So the prototype is an instance of Unit?
 
Now, he never said that he doesn't think PHP is bad any more ;-) I think it's more that he decided that slamming languages for their faults doesn't do much to change anyone's mind
 
selenium.webdriver.support.expected_conditions.visibility_of_element_located Nested is better than flat.
 
@Rawing I hadn't nailed down all the relations between classes, but yeah I think I imagined the prototype as being an instance of Unit. The one detail that I was clear about was that the prototype crossbowman is the same type as all the mutable instance crossbowmen.
the prototype and non-prototype crossbowmen could just as easily be instances of a Crossbowman class, which inherits from Unit, while still maintaining that relation
@AnttiHaapala I'll see if I can dig up a statement.
 
5:19 PM
interesting
> I’ll admit I was surprised to learn that PHP has a package manager with 1900 packages in its main repository. However, the author who pointed that out might be more surprised to know some of the following figures:

> Python:

PyPI has 20,000 packages
over 2,400 are Django related
over 2,000 are Plone related
over 800 are Zope3 related
over 800 are Zope2 related
over 130 are Turbogears related
 
@Kevin Poke has claimed that modern PHP is a lot better than old PHP. But I guess it's a relative matter...
 
@PM2Ring cutting a finger off is better than cutting a leg off, but I wouldn't want to do either of them ;)
 
What the yam? This OP just self-deleted after thanking me for my answer. :( stackoverflow.com/questions/47080849/…
 
Undelete
 
5:26 PM
@Kevin I see, okay. I'm not really sure if that would improve my situation, but I guess it can't hurt to give it a shot
 
DSM
Has anyone tried to call setup twice within a setup.py? It's causing problems on my second call.
 
@AndrasDeak d
 
Welp, I voted to undelete
 
Done and upvoted
 
@DSM uh... no. That sounds dangerous
what are you trying to do?
 
5:27 PM
Hope they'll get in trouble
 
Thanks guys. I almost closed it as a typo, but I felt like he also needed to learn how to do exceptions properly.
 
@PM2Ring That's very often the case when I answer questions that might be kind of lower quality... the OP clearly misunderstands X which manifested as problem Y
So I teach them about X, and show how solving that problem completely obviates the need for fixing Y
 
DSM
@WayneWerner: I'm trying to create a "full" and "client" wheel from the same package set. If I used two setup.pys, they'd be identical in everything except three arguments to setup(). Is setuptools secretly stateful?
 
Oooh. Interesting. That's an approach that I've never taken. Are you changing the behavior or just the dependencies?
because if you're just doing deps you can use.... something. I forget what the thing is I'll have to look it up but then you can do pip install yourpackage[full] and it will get the full install
 
5:31 PM
@WayneWerner True. Another common source of XY problems is "variable variables" questions, and other questions where the OP is trying to use eval or exec.
 
@KevinMGranger Oh wow, I'm so sorry, I completely missed that message D: I guess you may be right about that being the best solution; my only complaint about it is a gut feeling that it violates the Liskov substitution principle...
 
@Rawing might it be that you have a square/rectangle design issue?
 
DSM
@WayneWerner: there are internal dependencies as well. Everything would Just Work(tm) if my second setup wouldn't explode. (Also trying to debug things while doing Actual Work isn't helping..)
 
Minecraft bowman
 
@WayneWerner XY problem?
 
5:34 PM
@KevinMGranger Actually, that would put me in the same spot I am now, it only changes how Crossbowman is defined. I still have to save that max_health argument into an attribute somewhere, so I'd have the same problem I'm having right now
It would certainly be an improvement over an abstract Unit class though, that's for sure
 
waa
I heard ping
 
@WayneWerner Ummm, I'm not sure. I don't think so. It's more of a "I need a 3rd layer in the class->instance hierarchy" (and I don't think making Unit a metaclass is a good idea)
 
@AnttiHaapala c room?
 
it isn't even open
 
@Rawing I'm guessing you explained it before - got a link to whichever message you explained why? :)
 
DSM
@WayneWerner: ahh, life is short, I just hacked in an argument specifying the target to setup.py.
 
@WayneWerner here's my original message, if that helps
 
@wim fantastic
 
@wim the Jon Skeet avatar guys?
 
5:45 PM
I'm starting to think that the real problem is my inability to name my attributes correctly
 
@AndrasDeak ya
 
The dragony comic linked at the bottom looks like that
 
@wim :D
 
lol
this is funny
I've got alarm in my android phone...
at 19:28...
it ran out of power, so what happens is - it shuts down.
then ... after 10 minutes... it powers up to give me the repeat alarm... then promptly shuts down
... and wakes up after 10 minutes at 19:48...
 
Like the last days of Opportunity :'(
 
5:49 PM
@Rawing naming is hard
 
@Rawing you can't violate the liskov substitution principle if you're not actually substituting anything. It's still a Unit. If you concern is that not all Units will have a max_health attribute, then either make a UnitWithLimitedHealth subclass or make health a pluggable attribute
 
I think you just need a Barracks
so you can do Barracks.make_crossbowman() and Barracks.make_crossbowman_squad(5) or whatever
 
@AnttiHaapala that's probably bad for the battery though
 
well it might just be :D
but who'd have thought that it would work like that
 
Take it apart? Plug it in like a decent human being? :P
 
5:52 PM
@KevinMGranger What worries me are the constructor parameters - the Unit constructor expects a max_health attribute, which is provided by Crossbowman. So I can no longer provide a value for max_health when I'm instantiating a crossbowman. Isn't that a contract violation of some sort?
 
Why not?
 
Maybe. Do you think you'll need to occasionally override a Crossbowman's max health?
 
You should be doing super().__init__(max_health=max_health, range=range) anyway, right?
there's nothing wrong with def __init__(self, max_health=50, range=20) or whatever the default max health is going to be
 
Range D:
 
45
Q: Should constructors comply with the Liskov Substitution Principle?

dkubbI usually try to make sure my object instances comply with the Liskov Substitution Principle, but I've always wondered is do people think LSP should apply to constructors too? I've tried googling for this but I haven't been able to find any strong opinions either way. I should note that most of...

 
5:54 PM
it's OK, you're only overriding it in the __init__
 
(short answer: nah)
 
@AndrasDeak Opportunity died? When?
 
Also, you can still override kwargs set with partial. Maybe even positional args, idk
 
@Code-Apprentice last days to come :'(
 
aww, how sad
it has been such a tenacious little robot
 
5:57 PM
Wow, Liskov is a lady! I thought it's a man (proper Slavic should typically have Liskova for females)
@Code-Apprentice I mean AFAIK it's still fine but I've been mourning since that xkcd
 
So, someone substituted a name and violated a contract?
 
Alright, so to summarize, my code should look like this?
 
@AndrasDeak pretty sure I actually knew that from college
 
class Unit:
    def __init__(self, health, max_health):
        self.health = health
        self.max_health = max_health

class Crossbowman(Unit):
    def __init__(self, health=10):
        super().__init__(health=health, max_health=10)

steve = Crossbowman()
 
5:59 PM
@WayneWerner I never went to computer school. Only heard of LSP here
 
That would mean I really need to up my skill of naming things correctly
 
@AndrasDeak refresh my memory
 
@AndrasDeak saddest thing ever. Happy ending version
 
Cbg guys
 
@Code-Apprentice Oooops off-by-rover error xkcd.com/695
 
6:00 PM
@Rawing would you not want health=health, max_health=health?
 
It just looks weird to me, because it's mixing attributes of specific units (like steve's health) with attributes that are the same for all crossbowmen (i.e. max_health)
 
@WayneWerner broken link
 
@AndrasDeak that was spirit =p
 
Well, I mean if you don't set it to that, then Crossbowman(50) or Crossbowman(5) are a little... different
@AndrasDeak huh. Works for me?
 
@Code-Apprentice I know :P
@WayneWerner might be the mobile link
 
6:03 PM
not that I know the difference. I can never keep the rovers straight
 
Not sure if it belongs here, but I got a problem with my python installation, and it's pretty big
Basically my apt command is broken
 
Yup, desktop version loaded
 
Is anybody into that kind of stuff?
 
@AndrasDeak There should be a Barbie Liskov doll... not to be confused with Computer Engineer Barbie
 
Cbg
 
6:06 PM
"Yup, desktop version loaded" - I know that's a common mistake, but this is not this
 
@PM2Ring :D
@MeetTaraviya sorry, wasn't talking to you
Mobile crap
 
I have tried everything on the internet, and the only solution that is likely to work seems to be manually selecting packages to install
 
@MeetTaraviya your problem might be unrelated to python
How is apt "broken"?
 
To be precise:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python : PreDepends: python-minimal (= 2.7.11-2) but 2.7.14-2ubuntu1 is installed
Depends: libpython-stdlib (= 2.7.11-2) but 2.7.14-2ubuntu1 is installed
python-all : Depends: python (= 2.7.14-2ubuntu1) but 2.7.11-2 is installed
python-all-dev : Depends: python (= 2.7.14-2ubuntu1) but 2.7.11-2 is installed
 
Trying everything usually breaks things even more ;)
@MeetTaraviya and what were you trying to install?
 
6:09 PM
Any apt command gives above error
Whenever I try to install/uninstall ANYTHING
 
So your packages ended up in a twist
 
I was updating my ubuntu version, when this error popped up and stopped the update
 
How did that happen and did you try letting apt fix it?
 
Yeah, I tried all sorts of things
I also tried to manually install some packages
 
Your updated system python seems too new for certain packages? (I think?)
@MeetTaraviya but did you try the one thing I asked? And what happened?
 
6:12 PM
The following additional packages will be installed:
python
Suggested packages:
python-doc
The following packages will be upgraded:
python
1 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
9 not fully installed or removed.
Need to get 0 B/140 kB of archives.
After this operation, 21.5 kB disk space will be freed.
Do you want to continue? [Y/n]
Setting up python-minimal (2.7.14-2ubuntu1) ...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/runpy.py", line 174, in _run_module_as_main
On running fix broken install
 
@WayneWerner Probably, but that's a detail :p The values aside, that's the basic code structure we seem to have arrived at
 
Yeah, it seems like that, I allowed downgrades in apt as suggested in one answer
If you can read the error, and tell what packages I need, I can manually force install them
 
Hmm. I'll go out on a limb here and say that _struct should be a part of core python
Anyway, I'm not sure this problem is python-specific. Have you tried asking around on linux-related rooms of chat.SE?
 
that vaguely looks like something I've seen before but I don't remember what it is.
@MeetTaraviya definitely not python specific but... sounds like you may have borked your system python install
 
6:28 PM
Python is working to be clear, apt is broken
 
Hi guys, quick question.

switch = ("rt52f-sc.test.com",)

What is the best way to getting first 3 words from the name without converting list into string? I need RT5 for this example.
 split_name = [word[:3] for word in switch]
 
words or characters?
 
Do you mean the first three letters?
 
character .. sorry
so RT5 in this case
 
>>> switch = ("rt52f-sc.test.com",)
>>> switch[0]
'rt52f-sc.test.com'
>>> switch[0][:3]
'rt5'
 
6:30 PM
u dont have a list you have a tuple... :\
but kevin'd
 
TypeError: cannot concatenate 'str' and 'list' objects
let me try kevin's code
 
None of the code posted here would give a TypeError like that
If your code is crashing with that error, it's not because of the parts you shared with us
 
Thats what I am currently getting
I will try your code
 
Indeed, you've just posted a random error instead of figuring out what the code should be
 
split_name = [word[:3] for word in switch] is already the best way
 
6:32 PM
Maybe if you were doing something like s = "hello" + split_name, you'd get that error. But of course that would crash because split_name is a list and you can't add a list to a string
 
beware the temptation to cargo cult
 
MOM would let me add a list to a string!
 
stop, look, understand, incorporate
3
 
>>> split_name = [word[:3] for word in switch]
>>> type(split_name)
<class 'list'>
>>> len(split_name)
1
 
Site + "/"
 
6:34 PM
@wim I like the toggl guys
 
@MeetTaraviya so it's definitely not a python problem :P
@Damon your code will create a list of strings (presumably), so you can't append '/' to your strings inside; you need to do it one by one (possibly inside the list comprehension)
 
You never mentioned a Site variable before. Hmm, haven't we had several lectures at this point about the importance of MCVEs?
Being drip-fed single lines of code is pretty much the least efficient and most frustrating way to solve a problem
 
whats MCVE
 
Site = "".join(split_name)
Sorry, I did this. Forgot to mention
I guess I do need to change it to string due to concat
 
6:39 PM
Change what to string? Site? But Site is already a string. join() returns a string.
 
yes, site
 
@AndrasDeak does not hurt to help though?
 
Well, good luck with that. If you have any further questions, make sure to provide an MCVE first
 
Cabbage!
I didn't know I could call it MCVE
 
you could and you should ;)
@MeetTaraviya beg your pardon?
 
6:44 PM
@Simon On the main SO site you can even do [mcve] and it'll magically turn into a proper link that says Minimal, Complete, and Verifiable example
 
@AndrasDeak I learn something new every day
 
on tex.SE they call it MWE
 
@PM2Ring I did not know that.
from JavaScript import Simon
 
6:46 PM
that's probably more complete ^
 
@AndrasDeak I'll bookmark that page
 
@AndrasDeak I am asking this question here, because it requires conversation. SO itself prohibits long discussions on comments. So, I will be glad if you can help
 
@Simon if you start writing a comment, there's a small "help" link -> "formatting help"
@MeetTaraviya yeah, sure, but I can't. But as I already said, the kind people on chat.SE in relevant rooms are probably more versed in solving your problem, considering how we're centered around python and they are centered around linux/ubuntu
 
@MeetTaraviya I don't think people are refusing to help you with your installation problem on principle because it's not strictly Python-related. I think people aren't helping because we don't know much about troubleshooting Ubuntu installation problems, because we aren't an Ubuntu-related room. The problem is not motivation, but ability.
 
I checked and there's both a unix&linux and an ask ubuntu chatroom on chat.SE. But make sure your asking around is welcome wherever you go ask about it
 
6:50 PM
Phew it's quietened down.
@AndrasDeak I always have problems formatting and links here
 
@WayneWerner I just realized that out of context that message looks like an entry from Famous Last Words ;)
@Simon there are help/faq links in the bottom right corner (in desktop mode)
they are actually helpful, and there's the sandbox for practice
and our own Kevin wrote up a handy guide to formatting code sopython.com/wiki/…
 
@AndrasDeak Thank's I've been told already
 
okie dokie
 
@Kevin I understand. I have been trying since long and was desperate for help.
 
Boy howdy have I ever been there
 
6:57 PM
Is anyone familiar with the pyresample library? Specifically with using pyresample.geometry.SwathDefinition
 
@Kevin with that PHP reticulator problem?
 
@AndrasDeak Not in this incarnation, but in August I did terrorize the C# room with the eight-headed Heisenbug from Hell that caused it.
 
Wow, like people post random stuff in chats and everyone stars it
3
 
too broad stackoverflow.com/questions/47082518/… Another kid who wants to get a GCSE in programming but who hasn't learned the first thing about coding.
 
@cᴏʟᴅsᴘᴇᴇᴅ That accurately describes my creative process, yes
 
7:02 PM
@PM2Ring I'm so desperate, if only there was a way to obtain the ability to produce program code autonomously!
 
Lol, somebody posted an answer to that question
 
yamming hell, 1-rep idiot, can't even demotivate them
 
pwn
I'm going to delvote that answer as soon as -3.
 
OK it's not a proper answer
changed my comment to a less (differently?) grumpy one
 
@AndrasDeak It'd be bad enough if it were just normal homework.
 
7:06 PM
meh, I don't care much for where the user is trying to cheat; the more serious it is, the more likely it'll bite them in the butt eventually
my concern is the signal-to-noise of SO
 
Oh wow, that answer's at -5. Time to delvote.
 
Oh I wanted to share an interesting post (not in the usual sense). posted at 7:59:05, deleted by deceze at 7:59:34. I like the tag.
@cᴏʟᴅsᴘᴇᴇᴅ it's not actually harmful; doesn't give the answerer rep, doesn't hinder roomba, doesn't answer the question
not that I'm going to shed any tears
 
Hmm, okay, voting to delete the question then.
 
yeah that's fine
zero chance of OP editing it into shape
"OH WAIT, I realized I can try doing it myself" <-- not going to happen
 
wim
People with good google-fu, I'm trying to find a quote
It was about accepting *args and doing different things depending on whether you had 1, 2, or 3 args ..
 
7:21 PM
> computing is like the only thing I'm any good at
 
Should I hammer this question with the target I linked? stackoverflow.com/questions/47082994/…
@wim I think we're looking at the same question. ;)
 
@wim what kind of quote? Python Powers That Be quote? Or SO post?
 
In my hour of darkness, I call upon Bob Ross and Mister Rogers, to remind me that people are basically good and anyone may be fighting a hard battle
Let my faith in humanity stand firm, regardless of how many low-quality questions about the GCSE buffet against it
 
wait, there's a buffet?!
 
@PM2Ring I vote "yes". The question's title is a bit misleading, but the question itself is pretty much a perfect duplicate
 
wim
7:25 PM
Guido or Hettinger or someone answered a PEP or mailing thread saying not to copy his design mistakes by doing that kind of interface
 
@Rawing I just noticed that the OP was happy with my link.
 
easy choice then :)
 
@wim That rings a bell. range (and its relatives) is kinda convenient, but I agree that it is a bit ugly.
 
I like their cartoon about rescuing the princess.
 
7:29 PM
that's the one with Skeet, right?
 
@AndrasDeak yeah, that's the one. Jon Skeet rescues all the (I think) C# princesses.
 
:)
definitely C#
 
7:52 PM
the comments are hilarious
 
@AndrasDeak Did you watch all the other dance sorts?
 
no!
awesome!
 
they have ones for bubble sort, heap sort, and just about every other sorting algo
 
that's amazing
 
Bogosort is, of course, a mosh pit
 
7:57 PM
Frankly I'm surprised that my homies are involved in something this cool. And frankly I'm doubting that this can actually be considered "cool" by any conventional measure.
 
I don't see how that's supposed to be a quicksort. It's not clear who's the pivot or how the pivot is involved in any of that.
 
wim
@PM2Ring Yes, it was the same Q.
 
wim
That's a shame I couldn't find the quote. All the answers in the dupe say "this is how you do it" but don't mention that "you probably shouldn't do it"
 
I gave up after ten minutes of googling
 
8:03 PM
@user2357112 how is the pivot not clear?
 
I don't see a "pivot hat" or anything like that.
 
new idea for winter bash
 
@user2357112 the person with the black hat is the pivot
 
anyone here do OWASP training at all?
 
or alternatively, the person who stands in front and compares with everyone else...
granted, it could be made more obvious with the word "PIVOT" pinned to the hat...
@AndrasDeak talking about which...that is coming soon...get excited!
 
8:09 PM
I see it now. That's a different way to perform the partitioning than the quicksorts I've seen before.
 
yes, the implementation is different than what I typically do...probably because it is "in place"
 
I prefer in-place quicksorts, but the pivot moves a lot more in this one, always staying on the edge of the unpartitioned region as it shrinks instead of staying outside as the other elements swap with each other.
 
wim
Huh. Apparently, Java 7 SDK implements Timsort
 
oooo...yes, that is the difference.
 
@corvid I did practice on the OWASP wiki example site but no formal training
The self-hosted thing you try to attack, I mean
 
8:47 PM
cbg
 
9:06 PM
cbg
I was wondering how to escape a filename. Ie. something that will be passed to open()
 
thanks! unfortunately this project is stuck on 2.7 :(
 
okay fix that first then
kidding. I think there's probably an alternative in pypi
 
Oh wow, when chat loaded the second message of Rainer was lost :|
 
9:09 PM
Yep, and it supports 2.7 pypi.python.org/pypi/pathlib
 
had to reload again and now my original response is somewhat out of context
 
thanks Kevin, I'll check that out
 
sorry if I'm dense, but what's there to escape in a file name?
 
path traversal attacks
and I dunno if something else
it's probably not 100% necessary in this specific case but I'd rather play it safe
 
ah, makes sense now
 
9:12 PM
It is such a great feeling when you make a fairly major change and it actually works. What's more, it doesn't seem to have broken anything, either!
 
it's a trap
 
emphasis on "seem"? ;)
 
pathlib is just overall nicer than manipulating strings anyway.
 
@RainerKoirikivi I will double-check at a later time when I run the entire test suite. It takes about 30 mins, so cannot run it multiple times a day.
 
at least you have a test suite to run :)
 
9:22 PM
I need to provide a requirements.txt or an environment.yml that handles installing from a local gitlab server. when I pass the file to conda in order to create a new environment. Anyone know how to specify that a requirement comes from a gitlab server?
 
@RainerKoirikivi albeit a very fragile one
 
There should be a way to specify a source checkout in requirements.txt, no?
 
@RainerKoirikivi thx. Looking into it now
 
9:53 PM
crap, incorrectly dupehammered a bad question, and now reopening it wipes the valid close votes
 
you must atone by posting a and reciting 3 ave marias
 
I have 9 million website links(of news article) in a list, I need to extract a tag from each of the links. So right now what I am doing is request.get(url) -> BeautifulSoup -> find tag -> append to taglist. Running this the script catches 5 tags in 1 second that means it will take about 20.8 days to complete the 9 million list. What do I do? Can I increase the speed of the request.get? Parallel processing? If there's already a question like this on stackoverflow that can help as well.
 
Adding some form of parallelism would likely help, yes
 
10:33 PM
is it possible to build a web api without the django rest framework?
just normal django
 
11:30 PM
@Permian definitely
I am doing so right now
 
00:00 - 17:0017:00 - 00:00

« first day (2574 days earlier)      last day (2378 days later) »