Steve D'Aprano writes:
> Good way:
>
> Foreigner speaking English as their second language:
> "Who is the father of this class?"
>
> Native English speaker:
> "The father is 'object', but in English we would normally ask
> 'what is the parent?' instead."
Of the three scenario
On Fri, 8 Sep 2017 07:03 pm, Ben Finney wrote:
>> Who is the father of ExampleClass1 ?
>
> No-one, since classes do not have gender. (The convention is to use the
> gender-neutral “parent” to refer to that relationship.)
Possibly not the case in Russia. Besides, words have gender in many langua
Andrej Viktorovich writes:
> I found several class creation samples:
>
> class ExampleClass1:
>
> class ExampleClass2(object):
>
>
> What is difference between them?
Very little difference.
In Python 3, both create classes that inherit from one other class,
‘object’.
In Python 2, the first cre
On 2017-09-08 10:17, Andrej Viktorovich wrote:
> Hello
>
> I found several class creation samples:
>
> class ExampleClass1:
>
> class ExampleClass2(object):
>
>
> What is difference between them? Who is the father of ExampleClass1 ?
>
In Python 3, unless you've redefined "object", these are
Hello
I found several class creation samples:
class ExampleClass1:
class ExampleClass2(object):
What is difference between them? Who is the father of ExampleClass1 ?
--
https://mail.python.org/mailman/listinfo/python-list
Hello,
I need to code up a table class, which will be based on numpy
arrays. Essentially it needs to behave like a numpy array, but with a
variable associated with each array dimension. It must (at least
partially) satisfy the API of an existing class. The main reason for the
new class is to
- Original Message -
> From: "Jean-Michel Pichavant"
> To: "Juan Christian"
> Cc: "Python"
> Sent: Monday, 22 September, 2014 1:37:41 PM
> Subject: Re: Class Inheritance from different module
>
>
> > cl
> class User(Inheritance from API):
> def __init__(self, ID):
> steamapi.core.APIConnection(api_key = KEY)
> super( " Inheritance SteamUser" (ID)) # creates the user using the
> API
>
>
> [...]
>
>
> So that in my code when I need to create a new user, I just call 'usr
> = User("XXX")' ins
Juan Christian wrote:
> I have the following structure:
>
> Third-party API installed via pip:
> steamapi /
> app.py
> consts.py
> core.py
> users.py
> [...]
>
> My script:
> test.py
>
>
> In the API, the module users.py has a class 'SteamUser' and I want to
> mimic it's usage on my code, like
Juan Christian wrote:
[...]
> In the API, the module users.py has a class 'SteamUser' and I want to
> mimic it's usage on my code, like this:
>
> import steamapi
>
> [...]
>
> class User(Inheritance from API):
What do you mean, "Inheritance from API"? You can't inherit from an API,
only from c
I have the following structure:
Third-party API installed via pip:
steamapi /
app.py
consts.py
core.py
users.py
[...]
My script:
test.py
In the API, the module users.py has a class 'SteamUser' and I want to mimic
it's usage on my code, like this:
import steamapi
[...]
class User(Inheritance
On Monday, 6 January 2014 18:14:08 UTC+1, jwe.va...@gmail.com wrote:
> I have problems with these two classes:
>
>
>
> class LPU1():
>
> def __init__(self, formula):
>
> """
>
> formula is a string that is parsed into a SymPy function
>
> and several derived func
jwe.van.d...@gmail.com wrote:
> I have problems with these two classes:
>
> class LPU1():
> def __init__(self, formula):
> """
> formula is a string that is parsed into a SymPy function
> and several derived functions
> """
> self.formula = formula
>
On Mon, 6 Jan 2014 09:14:08 -0800 (PST), jwe.van.d...@gmail.com wrote:
I have problems with these two classes:
class LPU1() :
You forgot to derive from object. That's implied on 3.x, but you say
you're also running on 2.7 Without naming your base class you're
asking for an old style clas
On Tue, Jan 7, 2014 at 4:14 AM, wrote:
> class LPU3(LPU1):
> def __new__(self):
> """
> the same functions as LPU1 but some added functions
> and some functions redefined
> """
You probably don't want to be using __new__ here. Try using __init__
instead, o
I have problems with these two classes:
class LPU1():
def __init__(self, formula):
"""
formula is a string that is parsed into a SymPy function
and several derived functions
"""
self.formula = formula
... ...
class LPU3(LPU1):
def __new_
On Oct 15, 2:20 am, aaabb...@hotmail.com wrote:
> Test.py
> ---
> #!/usr/bin/python
>
> from my_lib import my_function
>
> class MyClass(my_function): # usually class names start capital
>
> """We know you're not forgetting to document."""
>
> def __init__(self, name):
> sup
:
> def __initial__(self, name):
> pass
> def test(self):
> print "this is a test"
>
> If __name__ == '__main__':
> my_class.main()
> -------
> my_lib.py
> class p_test()
>
this call will fail.
how to do it?
> > ---
> > my_lib.py
> > class my_function()
>
> You're missing a colon after the parentheses. Also, you're writing a
> class, not a function, so please rename the class something le
On Sat, Oct 15, 2011 at 12:09 AM, Jason Swails wrote:
> For instance, let's say you want to deal with shapes. You can define a
> shape via a class
>
> class Shape(object):
> """ Base shape class """
> Now we get into inheritance. Let's suppose that we want a specific type of
> shape. For i
if your my_class has a main() attribute function to
it. Note that the typical way of dealing with classes is to instantiate
different classes.
>
> Can anyone finish above code and let me try to understand
> Class inheritance?
>
You appear to be confusing functions and classes. Funct
> my_lib.py
> class my_function()
You're missing a colon after the parentheses. Also, you're writing a
class, not a function, so please rename the class something less
confusing.
> Can anyone finish above code and let me try to understand
> Class inheritanc
--
my_lib.py
class my_function()
...
Can anyone finish above code and let me try to understand
Class inheritance?
TIA.
-david
--
http://mail.python.org/mailman/listinfo/python-list
That's nice, Ethan, especially in that it saves having to explicitly find and
list all the methods being covered. It's perhaps not quite so critical for a
Fraction-based class, since the set of methods to be covered is fairly well
contained, but that's not always going to be the case.
The appro
JLundell wrote:
On Saturday, March 13, 2010 9:03:36 AM UTC-8, Jonathan Lundell wrote:
I've got a subclass of fractions.Fraction called Value; it's a mostly
trivial class, except that it overrides __eq__ to mean 'nearly equal'.
However, since Fraction's operations result in a Fraction, not a
Valu
On Saturday, March 13, 2010 9:03:36 AM UTC-8, Jonathan Lundell wrote:
> I've got a subclass of fractions.Fraction called Value; it's a mostly
> trivial class, except that it overrides __eq__ to mean 'nearly equal'.
> However, since Fraction's operations result in a Fraction, not a
> Value, I end up
On Wed, 21 Jul 2010 19:45:24 -0700, John Nagle wrote:
> Did class inheritance from "dict" work in early Python? Or did that
> only start working when "new objects" came in?
Only with the introduction of new-style classes and "object" in version
2.2.
htt
On 7/21/10 7:45 PM, John Nagle wrote:
>Did class inheritance from "dict" work in early Python? Or did
> that only start working when "new objects" came in?
The latter, that's why UserDict (and UserList) was added.
--
Stephen Hansen
... Also: Ixokai
Did class inheritance from "dict" work in early Python? Or did
that only start working when "new objects" came in?
John Nagle
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 17, 5:12 pm, Steven D'Aprano
wrote:
> On Mon, 15 Mar 2010 16:34:35 -0700,JLundellwrote:
> > It's also unfortunate that Python doesn't have an approximately-equal
> > operator; it'd come in handy for floating-point applications while
> > preserving hash. If only there were a ~= or ≈ operator
On Mon, 15 Mar 2010 16:34:35 -0700, JLundell wrote:
> It's also unfortunate that Python doesn't have an approximately-equal
> operator; it'd come in handy for floating-point applications while
> preserving hash. If only there were a ~= or ≈ operator I could overload.
> And ~ is unary, so no joy.
On 2010-03-16 17:55 PM, JLundell wrote:
On Mar 16, 8:06 am, Robert Kern wrote:
On 2010-03-16 07:35 AM, Dave Angel wrote:
Carl Banks wrote:
On Mar 15, 4:34 pm, JLundell wrote:
It's also unfortunate that Python doesn't have an approximately-equal
operator; it'd come in handy for floating-poi
On Mar 16, 8:06 am, Robert Kern wrote:
> On 2010-03-16 07:35 AM, Dave Angel wrote:
>
>
>
>
>
>
>
> > Carl Banks wrote:
> >> On Mar 15, 4:34 pm, JLundell wrote:
> >>> It's also unfortunate that Python doesn't have an approximately-equal
> >>> operator; it'd come in handy for floating-point applica
On 2010-03-16 07:35 AM, Dave Angel wrote:
Carl Banks wrote:
On Mar 15, 4:34 pm, JLundell wrote:
It's also unfortunate that Python doesn't have an approximately-equal
operator; it'd come in handy for floating-point applications while
preserving hash. If only there were a ~=r ≈ operator I coul
Carl Banks wrote:
On Mar 15, 4:34 pm, JLundell wrote:
It's also unfortunate that Python doesn't have an approximately-equal
operator; it'd come in handy for floating-point applications while
preserving hash. If only there were a ~=r ≈ operator I could
overload. And ~ is unary, so no joy.
On Mar 15, 4:34 pm, JLundell wrote:
> It's also unfortunate that Python doesn't have an approximately-equal
> operator; it'd come in handy for floating-point applications while
> preserving hash. If only there were a ~= or ≈ operator I could
> overload. And ~ is unary, so no joy.
One problem with
On Mar 13, 1:26 pm, Carl Banks wrote:
> It's a tad unfortunately Python doesn't make this easier. If I had to
> do it more than once I'd probably write a mixin to do it:
>
> class ArithmeticSelfCastMixin(object):
> def __add__(self,other):
> return
> self.__class__(super(ArithmeticSel
JLundell wrote:
I've got a subclass of fractions.Fraction called Value; it's a mostly
trivial class, except that it overrides __eq__ to mean 'nearly equal'.
However, since Fraction's operations result in a Fraction, not a
Value, I end up with stuff like this:
x = Value(1) + Value(2)
where x is
On Mar 13, 9:03 am, JLundell wrote:
> I've got a subclass of fractions.Fraction called Value; it's a mostly
> trivial class, except that it overrides __eq__ to mean 'nearly equal'.
> However, since Fraction's operations result in a Fraction, not a
> Value, I end up with stuff like this:
>
> x = Va
On Mar 13, 9:37 am, Jack Diederich wrote:
> If Fraction.__add__ returns a new object but the subclass Value is
> compatible (as I would except since it is a sublcass) then just change
> all references in Franction.__add__ to be more generic, ex/
>
> class Franction():
> def __add__(self, other):
On Mar 13, 11:37 am, Jack Diederich wrote:
> If Fraction.__add__ returns a new object but the subclass Value is
> compatible (as I would except since it is a sublcass) then just change
> all references in Franction.__add__ to be more generic, ex/
>
> class Franction():
> def __add__(self, other)
On Sat, Mar 13, 2010 at 12:03 PM, JLundell wrote:
> I've got a subclass of fractions.Fraction called Value; it's a mostly
> trivial class, except that it overrides __eq__ to mean 'nearly equal'.
> However, since Fraction's operations result in a Fraction, not a
> Value, I end up with stuff like th
On Mar 13, 11:03 am, JLundell wrote:
> I've got a subclass of fractions.Fraction called Value; it's a mostly
> trivial class, except that it overrides __eq__ to mean 'nearly equal'.
> However, since Fraction's operations result in a Fraction, not a
> Value, I end up with stuff like this:
>
> x = V
I've got a subclass of fractions.Fraction called Value; it's a mostly
trivial class, except that it overrides __eq__ to mean 'nearly equal'.
However, since Fraction's operations result in a Fraction, not a
Value, I end up with stuff like this:
x = Value(1) + Value(2)
where x is now a Fraction, no
On Sep 9, 9:00 pm, Steven D'Aprano
wrote:
> On Wed, 09 Sep 2009 20:14:33 -0700, gizli wrote:
> > I do not want to force the consumers of this framework to write this
> > obscure line of code. I was wondering if it is possible (at class
> > definition time) to capture the fact that MyTask extends T
On Wed, 09 Sep 2009 20:14:33 -0700, gizli wrote:
> I do not want to force the consumers of this framework to write this
> obscure line of code. I was wondering if it is possible (at class
> definition time) to capture the fact that MyTask extends Task and
> automatically insert the polymorphic_ide
Hi all,
I have been trying to do a programming trick with python and so far I
failed. I am using sqlalchemy in my code and writing a framework with
it. This framework uses something called polymorphic identity
attribute to define the do single table inheritance. Here's roughly
how it works:
1. De
On Sep 23, 4:58 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Rob Kirkpatrick wrote:
> > I'm assuming this has been discussed before, but I'm lacking any
> > Google keywords that bring up the appropriate discussion.
>
> You are looking for "mro" aka method resolution order. The inspect
> module
On Sep 23, 5:53 pm, Rob Kirkpatrick <[EMAIL PROTECTED]>
wrote:
> Hi All,
>
> I just finished debugging some code where I needed to determine why
> one subclass had a bound method and another did not. They had
> different pedigree's but I didn't know immediately what the
> differences were.
>
> I e
On Sep 23, 5:53 pm, Rob Kirkpatrick <[EMAIL PROTECTED]>
wrote:
> Hi All,
>
> I just finished debugging some code where I needed to determine why
> one subclass had a bound method and another did not. They had
> different pedigree's but I didn't know immediately what the
> differences were.
>
> I e
Rob Kirkpatrick wrote:
I'm assuming this has been discussed before, but I'm lacking any
Google keywords that bring up the appropriate discussion.
You are looking for "mro" aka method resolution order. The inspect
module contains several helper functions to inspect a class hierarchy.
The foll
Hi All,
I just finished debugging some code where I needed to determine why
one subclass had a bound method and another did not. They had
different pedigree's but I didn't know immediately what the
differences were.
I ended up walking the hierarchy, going back one class at a time
through the cod
On Apr 24, 10:11 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> In python, use attributes starting with a single underscore (such as
> _name). It tells users that they shouldn't mess with them. By
> design, python doesn't include mechanisms equivalent to the Java / C++
> 'private'.
Arnaud, G
Brian Munroe a écrit :
Ok, so thanks everyone for the helpful hints. That *was* a typo on my
part (should've been super(B...) not super(A..), but I digress)
I'm building a public API. Along with the API I have a few custom
types that I'm expecting API users to extend, if they need too. If I
d
Brian Munroe <[EMAIL PROTECTED]> writes:
> Ok, so thanks everyone for the helpful hints. That *was* a typo on my
> part (should've been super(B...) not super(A..), but I digress)
>
> I'm building a public API. Along with the API I have a few custom
> types that I'm expecting API users to extend,
En Thu, 24 Apr 2008 18:18:01 -0300, Brian Munroe
<[EMAIL PROTECTED]> escribió:
Ok, so thanks everyone for the helpful hints. That *was* a typo on my
part (should've been super(B...) not super(A..), but I digress)
I'm building a public API. Along with the API I have a few custom
types that I
Ok, so thanks everyone for the helpful hints. That *was* a typo on my
part (should've been super(B...) not super(A..), but I digress)
I'm building a public API. Along with the API I have a few custom
types that I'm expecting API users to extend, if they need too. If I
don't use name mangling, i
Brian Munroe wrote:
My example:
class A(object):
def __init__(self, name):
self.__name = name
def getName(self):
return self.__name
class B(A):
def __init__(self,name=None):
super(A,self).__init__()
def setName(
Arnaud Delobelle <[EMAIL PROTECTED]> writes:
> That is, if you also pass the name parameter to super(A,self).__init__
> in B's __init__ method
Oops. should be super(B, self).__init__(name), of course.
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
Brian Munroe <[EMAIL PROTECTED]> writes:
> My example:
>
> class A(object):
>
> def __init__(self, name):
> self.__name = name
>
> def getName(self):
> return self.__name
>
> class B(A):
>
> def __init__(self,name=None):
> super(A,self)._
On Apr 24, 10:22 pm, Brian Munroe <[EMAIL PROTECTED]> wrote:
> My example:
>
> class A(object):
>
> def __init__(self, name):
> self.__name = name
>
> def getName(self):
> return self.__name
>
> class B(A):
>
> def __init__(self,name=None):
>
My example:
class A(object):
def __init__(self, name):
self.__name = name
def getName(self):
return self.__name
class B(A):
def __init__(self,name=None):
super(A,self).__init__()
def setName(self, name):
[EMAIL PROTECTED] a écrit :
> so I’m trying to create a class that inherits from str, but I want to
> run some code on the value on object init. this is what I have:
Others already gave you the technical solution (use __new__, not
__init__). A couple remarks still:
1/
>
> class Path(str):
>
On Apr 16, 1:43 pm, [EMAIL PROTECTED] wrote:
> so I’m trying to create a class that inherits from str, but I want to
> run some code on the value on object init. this is what I have:
>
> class Path(str):
> def __init__( self, path ):
> clean = str(path).replace(
On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie
<[EMAIL PROTECTED]> wrote:
> so I'm trying to create a class that inherits from str, but I want to run
> some code on the value on object init. this is what I have:
You actually want to run your code when creating the new object, not
when initializ
so I'm trying to create a class that inherits from str, but I want to
run some code on the value on object init. this is what I have:
class Path(str):
def __init__( self, path ):
clean = str(path).replace('\\','/')
while clean.f
so I’m trying to create a class that inherits from str, but I want to
run some code on the value on object init. this is what I have:
class Path(str):
def __init__( self, path ):
clean = str(path).replace('\\','/')
while clean.find('//'
Andrew Rekdal < a écrit :
> I am trying to bring functions to a class by inheritance... for instance in
> layout_ext I have..
>
>
> --- layout_ext.py-
> class Layout()
> def...some function that rely on css in Layout.py
It shouldn't, definitively. The Layout instance should have a r
On Thu, 13 Mar 2008 00:06:52 -0500, "Andrew Rekdal" < wrote:
> Problem is layout_ext and Layout code is dependant on a Class instance
> 'css'.
Then pass that instance to the `Layout` class in the `__init__()` so both,
the base class and the subclass use the same `CSS` instance.
Ciao,
Ma
I am trying to bring functions to a class by inheritance... for instance in
layout_ext I have..
--- layout_ext.py-
class Layout()
def...some function that rely on css in Layout.py
def...
---EOF--
in the main application file I have...
Layout.py---
from layout_ext import Lay
On Aug 2, 7:05 am, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] a écrit :
> (snip)
>
> > Last post -- I swear.
>
> > I failed to realize that it's all part of an extremely well defined
> > attribute resolution protocol, and handled via the descriptor
> > specification. Discuss
[EMAIL PROTECTED] a écrit :
(snip)
> Last post -- I swear.
>
> I failed to realize that it's all part of an extremely well defined
> attribute resolution protocol, and handled via the descriptor
> specification. Discussing descriptors was on the TODO list for the
> type/class unification document,
[EMAIL PROTECTED] wrote:
> On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote:
>> On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
>>
>>
>>
>>> Hi all,
>>> It's possible that I'm missing the obvious -- I've been up for over 24
>>> hours and I'm most likely dehydrated from mass coffee intake, but I
>>> figure ma
On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote:
> On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi all,
>
> > It's possible that I'm missing the obvious -- I've been up for over 24
> > hours and I'm most likely dehydrated from mass coffee intake, but I
> > figure many people in similar circumst
On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote:
> Hi all,
>
> It's possible that I'm missing the obvious -- I've been up for over 24
> hours and I'm most likely dehydrated from mass coffee intake, but I
> figure many people in similar circumstances will be searching
> comp.lang.python one day, so here
Hi all,
It's possible that I'm missing the obvious -- I've been up for over 24
hours and I'm most likely dehydrated from mass coffee intake, but I
figure many people in similar circumstances will be searching
comp.lang.python one day, so here goes!
class LibraryClass(object):
"""
A clas
On 29 Maj, 22:45, Steve Holden <[EMAIL PROTECTED]> wrote:
> glomde wrote:
> > Hi I wonder if you can set what subclass a class should
> > have at instance creation.
>
> > The problem is that I have something like:
>
> > class CoreLang():
> > def AssignVar(self, var, value):
> > pass
>
glomde wrote:
> Hi I wonder if you can set what subclass a class should
> have at instance creation.
>
> The problem is that I have something like:
>
> class CoreLang():
> def AssignVar(self, var, value):
> pass
>
> class Lang1(CoreLang):
> def AssignVar(self, var, value):
>
glomde schrieb:
> Hi I wonder if you can set what subclass a class should
> have at instance creation.
>
> The problem is that I have something like:
>
> class CoreLang():
> def AssignVar(self, var, value):
> pass
>
> class Lang1(CoreLang):
> def AssignVar(self, var, value):
>
On May 29, 8:52 pm, glomde <[EMAIL PROTECTED]> wrote:
> Hi I wonder if you can set what subclass a class should
> have at instance creation.
>
> The problem is that I have something like:
>
> class CoreLang():
> def AssignVar(self, var, value):
> pass
>
> class Lang1(CoreLang):
>
On 29 Maj, 19:20, Ramashish Baranwal <[EMAIL PROTECTED]>
wrote:
> On May 29, 8:52 pm, glomde <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi I wonder if you can set what subclass a class should
> > have at instance creation.
>
> > The problem is that I have something like:
>
> > class CoreLang():
> > d
On 29 Maj, 19:27, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Why not just have Lang1 and Lang2 inherit from WriteStruct as well?
This wont work I think since if add antoher Class:
class WriteStruct():
def func1(self);
print "Hello2"
def Generate(self):
self.func1()
class
Why not just have Lang1 and Lang2 inherit from WriteStruct as well?
On May 29, 8:52 am, glomde <[EMAIL PROTECTED]> wrote:
> Hi I wonder if you can set what subclass a class should
> have at instance creation.
>
> The problem is that I have something like:
>
> class CoreLang():
> def AssignVar(
On May 29, 8:52 pm, glomde <[EMAIL PROTECTED]> wrote:
> Hi I wonder if you can set what subclass a class should
> have at instance creation.
>
> The problem is that I have something like:
>
> class CoreLang():
> def AssignVar(self, var, value):
> pass
>
> class Lang1(CoreLang):
>
Hi I wonder if you can set what subclass a class should
have at instance creation.
The problem is that I have something like:
class CoreLang():
def AssignVar(self, var, value):
pass
class Lang1(CoreLang):
def AssignVar(self, var, value):
return var, "=", value
class
On Tue, 14 Jun 2005 12:39:09 -0400, Vero wrote
(in article <[EMAIL PROTECTED]>):
> Hi. My name is Veronica, I am a master student at UNAM. I am working on
> something related to Artificial Inteligence and I have been looking for the
> most appropriated programming language to implement my algo
Hi. My name is Veronica, I am a master student at UNAM. I am working on something related to Artificial Inteligence and I have been looking for the most appropriated programming language to implement my algorithms. I found python to be very close to what I need, but there are still a couple of
87 matches
Mail list logo