Sometimes it could be handy, e.g., cutting short iteration: def raisex(self, *args):
... raise self.__class__(self, *args)
... Exception.raisex = raisex list(i for i in xrange(20) if i<10 or StopIteration().raisex())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list(i for i in xrange(20) if i<15 or StopIteration().raisex())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] list(i for i in xrange(20) if i<25 or StopIteration().raisex())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
a class method could be nicer once we have Exception as a new-style class.
Just a thought.
Regards,
Bengt Richter 0 834 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Miller |
last post by:
Is there any particular good reason to inherit from
exceptions.Exception? I've never seen any code that depends on what
the base class(es) of a raised exception is (are).
My use case is in a...
|
by: Chris S. |
last post by:
Is there a purpose for using trailing and leading double underscores for
built-in method names? My impression was that underscores are supposed
to imply some sort of pseudo-privatization, but would...
|
by: Paul Rubin |
last post by:
I'm trying the super() function as described in Python Cookbook, 1st ed,
p. 172 (Recipe 5.4).
class A(object):
def f(self):
print 'A'
class B(object):
def f(self):
|
by: Jasleen |
last post by:
I want to access the protected member hresult of the Exception class, so I
derived my own class from ApplicationException and SystemException.
public class LoggedException : SystemException
{...
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS...
|
by: jeremito |
last post by:
I am writing a class that is intended to be subclassed. What is the
proper way to indicate that a sub class must override a method?
Thanks,
Jeremy
|
by: Ratko |
last post by:
Hi all,
I was wondering if something like this is possible. Can a base class
somehow know if a certain method has been overridden by the subclass?
I appreciate any ideas.
Thanks,
Ratko
|
by: Michael Hines |
last post by:
Hello,
I have a class factory that supports single inheritance but it is
an error if the base appears twice. e.g
class Foo(hclass(h.Vector), hclass(h.List)):
should raise an exception since...
|
by: Fuzzyman |
last post by:
Hello all,
I may well be being dumb (it has happened before), but I'm struggling
to fix some code breakage with Python 2.6.
I have some code that looks for the '__lt__' method on a class:
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |