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
>
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
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 stdin, line 1, in module
__main__.Foo: None
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
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
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 stdin, line 1, in module
__main__.Foo: None
Inheriting from SyntaxError doesn't work! When I create a new exception, I
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
Timo Vanwynsberghe timo...@gmail.com 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
On Sun, Jan 17, 2010 at 12:47 PM, Robert webtour...@gmail.com wrote:
On Sun, Jan 17, 2010 at 11:25 AM, Alan Gauld alan.ga...@btinternet.com
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
Robert webtour...@gmail.com 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,
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,
On Fri, Jun 19, 2009 at 12:56 AM, bob gailer bgai...@gmail.com 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):
def
On Thu, Jun 18, 2009 at 9:48 PM, Luis Ngloboph...@gmail.com 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,
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 =
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 already
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 Python
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
[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 any other
[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
[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 styles
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
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'
children_query =
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
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
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)
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 =
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,4))
.
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)
. mine
[1,
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
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
31 matches
Mail list logo