On Wed, Jul 6, 2016 at 1:01 PM, Alex Hall wrote:
> Regarding this project: I've gone ahead and tried a variant of it. I
> wanted to log to an HTML file, since those are much easier to look at with
> a screen reader and so I could get used to the concepts involved. Here's
> what I've come up with
Regarding this project: I've gone ahead and tried a variant of it. I wanted
to log to an HTML file, since those are much easier to look at with a
screen reader and so I could get used to the concepts involved. Here's what
I've come up with so far. I'll ask the question, then paste the code. I'm
get
Hey list,
Another day, another Python experiment. I'm wondering what methods I'd have
to implement in a custom subclass of logger.Handler.
Currently, the recurring jobs I have written log their events to a file
each time they run. That's fine, but it doesn't let me keep
easily-sorted/searched reco
On Friday 06 January 2012, Steven D'Aprano wrote:
> Chris Fuller wrote:
> class Foo(SyntaxError):
> > ... def __init__(self, a,b,c):
> > ... self.args = (a,b,c)
> > ...
> >
> raise Foo(1,2,3)
> >
> > Traceback (most recent call last):
> > File "", line 1, in
> >
> > __main__.Foo:
On 01/07/2012 03:56 PM, Steven D'Aprano wrote:
Chris Fuller wrote:
You probably shouldn't inherit from SyntaxError, since it represents
syntax errors in the Python code being interpreted or compiled. Any
syntax error in your own data structures should be independent of
SyntaxError.
I'd say a s
Devin Jeanpierre wrote:
Inheriting from SyntaxError doesn't work! When I create a new exception, I
generally subclass from the built-in exception it most resembles, in case
there was some reason to also catch it via an ancestor. But I'm not sure if
that is really all that useful an idea in prac
Chris Fuller wrote:
class Foo(SyntaxError):
... def __init__(self, a,b,c):
... self.args = (a,b,c)
...
raise Foo(1,2,3)
Traceback (most recent call last):
File "", line 1, in
__main__.Foo: None
Inheriting from SyntaxError doesn't work! When I create a new exception, I
generally sub
> Inheriting from SyntaxError doesn't work! When I create a new exception, I
> generally subclass from the built-in exception it most resembles, in case
> there was some reason to also catch it via an ancestor. But I'm not sure if
> that is really all that useful an idea in practice. How do you
I had an interesting experience today.
Python 2.7.1 (r271:86832, Nov 28 2010, 19:31:37)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(Exception):
... def __init__(self, a,b,c):
... self.args = (a,b,c)
...
>>> raise Foo(1,2,3)
Traceb
"Robert" wrote
I have been wondering about this "New-style Class" subject along this
line:
so, *theoretically speaking*, in EXISTING, pre-P3K code,
if one changes everywhere where it's coded "class someClass()" to
"class someClass(object)",
it should not break the programs, right ?
More co
On Sun, Jan 17, 2010 at 12:47 PM, Robert wrote:
> On Sun, Jan 17, 2010 at 11:25 AM, Alan Gauld
> wrote:
>> In older versions of Python it made a difference whether you used object
>> or not. Using object gave you a "new style" class which has several extra
>> features, without you got an "old st
"Timo Vanwynsberghe" wrote
I read that it is advised to subclass object.
Is it really necessary? I mean, everything works, why should I add it to
my
code?
In older versions of Python it made a difference whether you used object
or not. Using object gave you a "new style" class which has s
I read that it is advised to subclass object.
Is it really necessary? I mean, everything works, why should I add it to my
code?
Cheers,
Timo
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/ma
On Thu, Jun 18, 2009 at 9:48 PM, Luis N wrote:
>>> I get an error "TypeError: 'rounding' is an invalid keyword argument
>>> for this function" on my list subclass.
>>>
>>> How might I subclass list without this error?
>>>
>>> This is the code:
>>>
>>> class SeriesList(list):
>>> def __new__(cls
On Fri, Jun 19, 2009 at 12:56 AM, bob gailer wrote:
>
> Luis N wrote:
>>
>> I get an error "TypeError: 'rounding' is an invalid keyword argument
>> for this function" on my list subclass.
>>
>> How might I subclass list without this error?
>>
>> This is the code:
>>
>> class SeriesList(list):
>>
Luis N wrote:
I get an error "TypeError: 'rounding' is an invalid keyword argument
for this function" on my list subclass.
How might I subclass list without this error?
This is the code:
class SeriesList(list):
def __new__(cls, *args, **kwargs):
series_list = list.__new__(cls, *arg
I get an error "TypeError: 'rounding' is an invalid keyword argument
for this function" on my list subclass.
How might I subclass list without this error?
This is the code:
class SeriesList(list):
def __new__(cls, *args, **kwargs):
series_list = list.__new__(cls, *args)
serie
Thanks both of you, that cleared a lot of things up.
On Jan 9, 2008, at 11:49 AM, Kent Johnson wrote:
>
> No, you can't access the actual byte array from Python and you can't
> damage it.
I don't know a lick of C and probably never will, but I do like to
know what it is, exactly, that I don't
Tiger12506 wrote:
> PS. Anyone who's interested. A significant study of C has brought me to
> these conclusions.
> immutable -> implemented with static buffer
> mutable -> implemented with linked list
> Anyone know a little more detail?
Certainly not true of Python. I don't know of any standard Py
Eric Abrahamsen wrote:
> When I create a string like so:
>
> x = 'myvalue'
>
> my understanding is that this is equivalent to:
>
> x = str('myvalue')
>
> and that this second form is more fundamental: the first is a
> shorthand for the second.
The second does nothing that the first doesn't
Ahh. Excellent questions.
> I'm playing around with subclassing the built-in string type, and
> realizing there's quite a bit I don't know about what's going on with
> the built-in types. When I create a string like so:
>
> x = 'myvalue'
>
> my understanding is that this is equivalent to:
>
> x =
I'm playing around with subclassing the built-in string type, and
realizing there's quite a bit I don't know about what's going on with
the built-in types. When I create a string like so:
x = 'myvalue'
my understanding is that this is equivalent to:
x = str('myvalue')
and that this second f
Thanks again, this is exactly the kind of info I need to make the jump from
procedural to OO design. I bookmarked your site for reference.
On Saturday, June 16, 2007, at 09:30AM, "Kent Johnson" <[EMAIL PROTECTED]>
wrote:
>[EMAIL PROTECTED] wrote:
>> Hi there,
>>
>> I am new to Python and tryin
[EMAIL PROTECTED] wrote:
> Hi there,
>
> I am new to Python and trying to get my head around the OO stuff. I
> guess my question is - when do you go with subclassing vs. making a
> standalone function?
> Let's say you want to load a dictionary. Do I create a function that
> accepts some argument
<[EMAIL PROTECTED]> wrote
>>Just so you know, my day gig is maintaining a 30 year old COBOL app
>>and
>>writing custom RPGLE - http://en.wikipedia.org/wiki/RPGLE - on an
>>IBM i5.
>>So that's where I am coming from.
Thats probably one of the hardest places to learn OOP from.
COBOL, more than an
I am new to Python and trying to get my head around
the OO stuff. I guess my question is - when do you go
with subclassing vs. making a standalone function?
OK, I'll take a slightly different approach than the other
answers so far.
First: procedural and OO styles of programming are diffrent
<[EMAIL PROTECTED]> wrote
> I am new to Python and trying to get my head around
> the OO stuff. I guess my question is - when do you go
> with subclassing vs. making a standalone function?
OK, I'll take a slightly different approach than the other
answers so far.
First: procedural and OO st
[EMAIL PROTECTED] wrote:
>
> Let's say you want to load a dictionary. Do I create a function that
> accepts some argument (say a file name) and returns a dictionary, or
> do I subclass dict and override the __init__ and __setitem__
> functions to make 'self-loading' dictionary? It seems the end r
Hi,
Basically you write a (sub)class when you want to preserve state
information of your instance. If the functionality in question lives
longer then the scope of the function, and will be called from
different methods to obtain the same information and state of the
functionality at that time, it
Hi there,
I am new to Python and trying to get my head around the OO stuff. I guess my
question is - when do you go with subclassing vs. making a standalone function?
Let's say you want to load a dictionary. Do I create a function that accepts
some argument (say a file name) and returns a dict
Hi Kent,
Kent Johnson wrote on 04.11.2005:
>
>OK I'll try again. I still don't understand why you don't like using
>straight class attributes - is it to keep the size of the class
>namespace smaller?
>
Yes, and to distinguish between different kinds of attributes in the main
script. In the end, i
Jan Eden wrote:
> Not exactly. My current setup bundles all data attributes in a single
> module Data containing a single class for each object. So in my main
> module (Show), I define:>
> class Page(Data.Page):
> ...
>
> and Data contains:
>
> class Base:
> children = 'xyz'
> childr
Jan Eden wrote:
> Hi,
>
> the module Data.py stores a number of data attributes. I'd like to structure
> the storage of these attributes, either in subclasses or in dictionaries.
>
> My first attempt was this:
>
> class A:
> templates['attr1'] = 'string'
> queries['children'] = ...
>
Hi,
the module Data.py stores a number of data attributes. I'd like to structure
the storage of these attributes, either in subclasses or in dictionaries.
My first attempt was this:
class A:
templates['attr1'] = 'string'
queries['children'] = ...
class B(A):
templates['attr2']
Kent Johnson said unto the world upon 2005-03-18 07:35:
Brian van den Broek wrote:
Kent Johnson said unto the world upon 2005-03-17 20:44:
The multiple inheritance from MyNode and Toolkit.NodeX is a smell. I
guess you do this because you want to override methods of
Toolkit.Node as well as Toolki
Brian van den Broek wrote:
Kent Johnson said unto the world upon 2005-03-17 20:44:
The multiple inheritance from MyNode and Toolkit.NodeX is a smell. I
guess you do this because you want to override methods of Toolkit.Node
as well as Toolkit.NodeX, or add methods to both MyNode1 and MyNode2?
I
Kent Johnson said unto the world upon 2005-03-17 20:44:
Brian van den Broek wrote:
A schematic of what I have (with fake names for ease of example) is a
base module Toolkit.py and I want to write a module Application.py
which specializes the behaviour of the Toolkit.py classes. (I'm using
old-st
Brian van den Broek wrote:
A schematic of what I have (with fake names for ease of example) is a
base module Toolkit.py and I want to write a module Application.py which
specializes the behaviour of the Toolkit.py classes. (I'm using
old-style classes, but don't feel committed to that choice.)
You want a method in a base class to parse input and create instances of
certain derived classes. Your sample code looks like:
if some_condition_on_chunk_contents:
node = Node1(chunk_contents)
else:
node = Node2(chunk_contents)
I'd suggest changing the method to use a variable to determ
Hi all,
I'm uncertain of how to make use of OOP design across multiple
modules. (Actually, on reflection, I'm not certain the multiple
modules aspect is central.) I'm also uncertain of how to frame the
question well, so please bear with me :-)
A schematic of what I have (with fake names for eas
On Fri, 25 Feb 2005 05:54:39 -0200, Ismael Garrido
<[EMAIL PROTECTED]> wrote:
> def __init__(self, this, that, new):
> Parent.__init__(self, this, that) #note self
> self.new = new
If the paren's init t has a lot of possible arguments, it may be
easier to do things this way:
class Child(
Ismael Garrido wrote:
Sean Perry wrote:
yep. call 'Parent.__init__(this, that)' then do 'self.new = new'
def __init__(self, this, that, new):
Parent.__init__(this, that)
self.new = new
Thanks.
Though it should be:
def __init__(self, this, that, new):
Parent.__init__(self, this, that) #
Sean Perry wrote:
yep. call 'Parent.__init__(this, that)' then do 'self.new = new'
def __init__(self, this, that, new):
Parent.__init__(this, that)
self.new = new
Thanks.
Though it should be:
def __init__(self, this, that, new):
Parent.__init__(self, this, that) #note self
self.new =
Ismael Garrido wrote:
Hello
My code is like this:
class Parent:
def __init__(self, bunch, of, variables):
self.bunch, self.of, self.variables = bunch, of, variables
class Son(Parent):
def __init__(self, bunch, of, variables, new):
self.bunch, self.of, self.variables, self.new = bu
Hello
My code is like this:
class Parent:
def __init__(self, bunch, of, variables):
self.bunch, self.of, self.variables = bunch, of, variables
class Son(Parent):
def __init__(self, bunch, of, variables, new):
self.bunch, self.of, self.variables, self.new = bunch, of,
variables, n
> > > I'm trying to figure out how to subclass the list built-in.
>
> > You could do it e.g. like that:
> >
> > class Mylist (list):
> > def __init__(self, seq=None):
> > super(self.__class__, self).__init__(seq)
> > def __getslice__(self, start, stop):
> > return self.__cl
> Message: 2
> Date: Tue, 22 Feb 2005 13:53:44 +0100
> From: [EMAIL PROTECTED] (Karl Pfl?sterer )
> Subject: Re: [Tutor] subclassing list -- slicing doesn't preserve type
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; char
Karl Pflästerer said unto the world upon 2005-02-22 07:53:
On 22 Feb 2005, [EMAIL PROTECTED] wrote:
I'm trying to figure out how to subclass the list built-in.
.>>> class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
Brian van den Broek wrote:
Hi all,
I'm trying to figure out how to subclass the list built-in.
.>>> class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
.>>> mine = my_list((1,2,3,4))
.>>> mine.append(42)
.>>>
On 22 Feb 2005, [EMAIL PROTECTED] wrote:
> I'm trying to figure out how to subclass the list built-in.
>
> .>>> class my_list(list):
> def __init__(self, sequence=None):
> list.__init__(self, sequence)
> self.spam = 1
>
> .>>> mine = my_list((1,2,3
Hi all,
I'm trying to figure out how to subclass the list built-in.
.>>> class my_list(list):
def __init__(self, sequence=None):
list.__init__(self, sequence)
self.spam = 1
.>>> mine = my_list((1,2,3,4))
.>>> mine.append(42)
.>>> mine
[1, 2, 3, 4,
51 matches
Mail list logo