Re: [Tutor] Inheritance, superclass, ‘super’ (was: __repr__ and __str__)

2015-07-02 Thread Steven D'Aprano
I mostly agree with what Ben says, comments below. On Wed, Jul 01, 2015 at 12:48:47PM +1000, Ben Finney wrote: > Alan Gauld writes: > > > Whilst I agree with the general use of super I'm not sure what > > the MRO resolution has to do with this case? > > When accessing the superclass, the MRO is

Re: [Tutor] Inheritance, superclass, ‘super’

2015-07-02 Thread Steven D'Aprano
On Wed, Jul 01, 2015 at 10:40:20PM +0100, Alan Gauld wrote: > >Multiple inheitance is a fact in Python, and good practice is to not > >arbitrarily write classes that break it. > > That depends on what you mean by break it., MI should allow the > inheriting class to specify which, if any, of its

Re: [Tutor] memory error

2015-07-02 Thread Danny Yoo
On Thu, Jul 2, 2015 at 9:57 AM, Joshua Valdez wrote: > > Hi so I figured out my problem, with this code and its working great but its > still taking a very long time to process...I was wondering if there was a way > to do this with just regular expressions instead of parsing the text with > lxm

Re: [Tutor] memory error

2015-07-02 Thread Danny Yoo
> > So I got my code working now and it looks like this > > TAG = '{http://www.mediawiki.org/xml/export-0.10/}page' > doc = etree.iterparse(wiki) > > for _, node in doc: > if node.tag == TAG: > title = > node.find("{http://www.mediawiki.org/xml/export-0.10/}title";).text > if t

Re: [Tutor] memory error

2015-07-02 Thread Joshua Valdez
Hi so I figured out my problem, with this code and its working great but its still taking a very long time to process...I was wondering if there was a way to do this with just regular expressions instead of parsing the text with lxml... the idea would be to identify a tag and then move to the nex

[Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Jim Mooney Py3.4.3winXP
When an instance uses a class method, does it actually use the method that is in the class object's memory space, or is the method copied to the instance? -- Jim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Danny Yoo
On Thu, Jul 2, 2015 at 12:30 PM, Jim Mooney Py3.4.3winXP wrote: > When an instance uses a class method, does it actually use the method that > is in the class object's memory space, or is the method copied to the > instance? Unsure. How would it be observable? [The following is not beginner

Re: [Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Peter Otten
Danny Yoo wrote: > On Thu, Jul 2, 2015 at 12:30 PM, Jim Mooney Py3.4.3winXP > wrote: >> When an instance uses a class method, does it actually use the method >> that is in the class object's memory space, or is the method copied to >> the instance? > Unsure. How would it be observable? [snip i

Re: [Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Alan Gauld
On 02/07/15 20:30, Jim Mooney Py3.4.3winXP wrote: When an instance uses a class method, does it actually use the method that is in the class object's memory space, or is the method copied to the instance? As soon as you mention memory space in relation to how something works in Python you know

Re: [Tutor] Inheritance, superclass, ‘super’

2015-07-02 Thread Ben Finney
Steven D'Aprano writes: > I mostly agree with what Ben says, comments below. > > On Wed, Jul 01, 2015 at 12:48:47PM +1000, Ben Finney wrote: > > So please use `super`, even in single inheritance. Otherwise you are > > restricting the usefulness of your class: it can never be used with > >

Re: [Tutor] Inheritance, superclass, ‘super’

2015-07-02 Thread Ben Finney
Alan Gauld writes: > On 01/07/15 03:48, Ben Finney wrote: > > Alan Gauld writes: > > > >> Whilst I agree with the general use of super I'm not sure what > >> the MRO resolution has to do with this case? > > > > When accessing the superclass, the MRO is always relevant > > Can you explain that? >

[Tutor] method conflict?

2015-07-02 Thread Jim Mooney Py3.4.3winXP
Okay, it appears the method in a class has its own ID, but all instantiations of that method have identical IDs. But what happens if we have a huge number of instantiations trying to access the identical method at the same time? class MyClass: def setdata(self, data): self.data = data

Re: [Tutor] Are the methods in a class copied or just linked to?

2015-07-02 Thread Steven D'Aprano
On Thu, Jul 02, 2015 at 12:30:23PM -0700, Jim Mooney Py3.4.3winXP wrote: > When an instance uses a class method, does it actually use the method that > is in the class object's memory space, or is the method copied to the > instance? The first. And it is not just an implementation detail, it is p

Re: [Tutor] method conflict?

2015-07-02 Thread Cameron Simpson
On 02Jul2015 17:39, Jim Mooney Py3.4.3winXP wrote: Okay, it appears the method in a class has its own ID, but all instantiations of that method have identical IDs. But what happens if we have a huge number of instantiations trying to access the identical method at the same time? Um, they all g

Re: [Tutor] method conflict?

2015-07-02 Thread Steven D'Aprano
On Thu, Jul 02, 2015 at 05:39:12PM -0700, Jim Mooney Py3.4.3winXP wrote: > Okay, it appears the method in a class has its own ID, but all > instantiations of that method have identical IDs. I'm not sure what you mean by this. *All* objects have their own ID, and instantiations of methods *don't*

Re: [Tutor] method conflict?

2015-07-02 Thread Mark Lawrence
On 03/07/2015 01:39, Jim Mooney Py3.4.3winXP wrote: Okay, it appears the method in a class has its own ID, but all instantiations of that method have identical IDs. But what happens if we have a huge number of instantiations trying to access the identical method at the same time? I understand t