« first day (3498 days earlier)      last day (1464 days later) » 
02:00 - 22:0022:00 - 00:00

import array
class MyClass(array.array):
    def __init__(self, optionalarg=None):
        array.array.__init__(self, 'q')
        self.append(0)
        if optionalarg is not None:
            self.extend(optionalarg)
 
cbg patch
 
@AndrasDeak aha, thanks.
 
@Wildcard you too
 
so i talked a bit with someone in the wee hours of the evening about this issue with someone a while back
 
10:02 PM
So this class produces an error no matter how I attempt to instantiate it.
 
for some reason my windows python virtualenvs cannot seem to connect with pip
 
@AndrasDeak wow, how'd you pull that up so fast?
 
@Wildcard I searched my chat messages aimed at you, and there was a quote of Marc Gravell's reply to you posted by me here
 
Depending on what arguments I pass, I get one of:

TypeError: array() takes at least 1 argument (0 given)
TypeError: array() argument 1 must be a unicode character, not list
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
 
  Could not fetch URL pypi.org/simple/scipy: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/scipy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement scipy (from versions: )
No matching distribution found for scipy
 
10:04 PM
@AndrasDeak ah. Incidentally, I liked my old gravatar well enough that I kept it. (I had a saved copy somehow and I uploaded it as a new profile image.)
 
I tried several different fixes but havven't really figured out why just the venv is doing this
 
@Wildcard same
@Wildcard array.array might be one of those stdlib types that don't like to be subclassed. Some builtins that do that need you to override __new__ and other gems
 
@AndrasDeak full disclosure: I actually did post a question about this, and it hasn't been 48 hours, only 28. (stackoverflow.com/q/61782053/5419599)
 
class MyClass(array.array):
    def __new__(cls, *args, **kwargs):
        return super().__new__(cls, 'q')

    def __init__(self, optionalarg=None):
        self.append(0)

        if optionalarg is not None:
            self.extend(optionalarg)
^ that works
 
And yeah, I saw digging into the documentation that array.array.__new__ raises an audit event, which is very unusual.
 
10:07 PM
@Wildcard Ah; in that case we'd rather you waited another day. Thanks for the remark.
 
before it retires python outputs:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
And searching that suggests having to do a full reinstall of python which kinda sucks
 
@Aran-Fey aha. That makes sense. I'll dig into the documentation for __new__ methods until I more fully understand it. (I think I would prefer to use return array.array.__new__(cls, 'q') if it will work; I'll play with it.)
Thanks!
 
super() is your friend, don't avoid it for no reason
 
@Aran-Fey interesting...what's your opinion of fuhm.net/super-harmful ? (Note, I'm just learning Python, so I don't have any ax to grind. super() seemed more complex than I need but I'd love to learn the viewpoint of experienced Python programmers.)
 
been a while since I read that... let me refresh my memory real quick
 
wim
10:11 PM
if you don't need cooperative inheritance then no need to use it.
I see you're implementing a max heap. Most users would use a list for that
 
@wim that was what I gathered. Plus I definitely don't understand all the nuanced implications of using it, and I'm loathe to use any function call that I don't thoroughly understand.
 
wim
Since you're new to Python, maybe it's worth mentioning that Python's list is not what most other languages might call a list, it's more like what other languages call an array. And Python's array module is ... well, you might be the first person in the world to use it
 
@wim true, but I'd just found out about array.array and wanted to try it.
:D
 
@wim nah, there's also PM 2Ring. So second.
when people talk about arrays in python they either mean an stdlib list (ugh) or they mean a third-party numpy array (yay)
 
Seems like their main point is "super is complicated"... which is true, if multiple inheritance is involved. So I see 3 different scenarios:
1) single inheritance: super does no harm
2) cooperative inheritance: super is required
3) inheriting from two classes that aren't designed for multiple inheritance: you're gonna have a bad time either way
 
10:16 PM
@wim thanks. I definitely know about lists. Actually, I've gone through almost the entirety of "Learning Python"; I haven't done any major software projects in Python but I've got a decent grip on the language.
 
TL;DR: super is never the worse choice
 
@Aran-Fey thanks, that's useful. I think I'll still avoid it in my "toy" code until I more fully understand it, or until I have a need for cooperative inheritance.
I'm curious if you have an example where cooperative inheritance is required? I have trouble thinking of one.
 
Hmm, I use it all the time, but thinking of an example is hard
 
probably diamond inheritance
 
wim
mixin pattern
 
10:20 PM
I've mostly seen examples when you have to jump in the mro to do things right
 
@wim Incidentally, while I was attempting to find the source code for the array module (I failed), I ran across the "heapq" module and read a lot of it. It was interesting—the author didn't bother to even use OOP, instead taking advantage of the native "list" type to make lists into heaps. Which makes "list.sort" do the right thing also, which is cool.
 
wim
Yeah heapq is a pretty cool module. I like the way it just gives methods to work with a plain old list, kind of reminiscent of the beauty and simplicity that Python used to have.
 
@AndrasDeak yeah, I have trouble thinking with that. I've done a decent amount of coding in various (mostly unusual) languages, but nothing object oriented before Python. I've even played with Go and I found the composition approach very intuitive. The indictment of inheritance hierarchies by one of Go's creators resonated with me. I find OOP very useful, but I can't think of a case where multiple inheritance would really be the best solution for a real-world problem.
 
@wim Will it not break when you meddle with the list outside heapq functions? I always thought that's a fragile point, considering today's users
 
wim
@AndrasDeak if you break the heap invariant, yeah
so don't do that
 
10:25 PM
@AndrasDeak if you keep the list sorted it will still be a proper heap.
 
@wim not very invariant, is it?
 
IMO the heapq module is dumb for not using OOP. Doing heapq.whatever(my_list_representing_a_heap) instead of my_heap.whatever() is like doing os.path.whatever(my_string_representing_a_path) instead of my_path.whatever(), except even worse because lists are mutable
 
Didn't someone (wim?) mention the other day that there's an OOP variant?
 
wim
it has a priority queue class, I probably mentioned that.
 
I just looked it up but heapq doesn't link it
@wim yes!
 
wim
10:29 PM
which is just a simple class that "has a" heap
whoever designed this was doing it right
 
not to be found on the top level of the stdlib docs
 
wim
@Aran-Fey opinions differ.
 
I prefer my heaps to be objects in their own right that maintain their own invariant, but I can see the attraction of the simpler non-OOP approach.
And I definitely thought it was interesting. :)
 
huh, dataclass in an example code block
@Wildcard heaps of fun
 
wim
10:37 PM
simple, easy to understand, works. my favorite kind of code
 
@AndrasDeak LOL.
 
wim
"but it will break if you do the thing that you wouldn't normally do" is one of my least fav arguments
 
11:27 PM
I want to add the proper annotation in my plot. this is what I tried link:https://pastebin.com/W6gW729i and the plot which result is as
https://ibb.co/t89fftL
but the actual one is here:
https://ibb.co/2ZNzxV2

how should I make that round arrow ?
 
@AnilSarode you are passing (2,2) and (0,0) as coordinates, and get an arrow between those two data points
I suggest computing your points in polar coordinates, and then passing those instead
p1 = np.cos(np.pi/4), np.sin(np.pi/4)  # etc.
 
11:52 PM
@AndrasDeak thanks for kind attention. what I understood that the xy=(2,2) and xytext=(0,0) decide the head and tell of the arrow so to get the proper arc we need to pass the accurate co-ordinate.

May you please elaborate on how to use polar co-ordinate?
 
You don't have to use polar coordinates, but since your line seems to be defined in terms of angles that would be my natural choice.
The Cartesian (i.e. usual coordinates) of a point of distance r from the origin in angle phi are (r*cos(phi), r*sin(phi)). Here phi is in radians, phi=0 corresponds to the +x axis, and angles grow in the counter-clockwise direction.
 
so I have to choose the appropriate value of r and phi to get my head and tail co-ordinate
 
Unfortunately yes. But phi is defined by your angles, assuming those are true. If they aren't, you can compute the angle from your line data.
Yeah, it can't be right, because 45 degrees would imply that x and y are the same for one of the points.
 
02:00 - 22:0022:00 - 00:00

« first day (3498 days earlier)      last day (1464 days later) »