Re: [Tutor] Regarding Exceptions

2014-02-21 Thread eryksun
On Fri, Feb 21, 2014 at 8:50 PM, Steven D'Aprano wrote: > The history of __builtins__ with an S is quite old. It's used for > performance reasons, and originally it was supposed to be used for > sandboxing Python, but that turned out to not work. So although it still > exists even in Python 3, it'

Re: [Tutor] Regarding Exceptions

2014-02-21 Thread Steven D'Aprano
On Fri, Feb 21, 2014 at 01:27:55PM -0500, eryksun wrote: > On Fri, Feb 21, 2014 at 12:48 PM, wesley chun wrote: > > in reality, built-ins are part of a magical module called __builtins__ > > that's "automagically" imported for you so that you never have to do it > > yourself. check this out: > > >

Re: [Tutor] Regarding Exceptions

2014-02-21 Thread eryksun
On Fri, Feb 21, 2014 at 12:48 PM, wesley chun wrote: > in reality, built-ins are part of a magical module called __builtins__ > that's "automagically" imported for you so that you never have to do it > yourself. check this out: > __builtins__.Exception > > > you can also find out what all th

Re: [Tutor] Regarding Exceptions

2014-02-21 Thread wesley chun
On Mon, Feb 17, 2014 at 3:29 AM, Khalid Al-Ghamdi wrote: Hi, in the following snippet, why is it I don't need to create an Exception object and I can use the class directly in raise my custom exception? here's a new one... i'm going to try to answer this question without working code since everyo

Re: [Tutor] Regarding Exceptions

2014-02-17 Thread Dave Angel
On 02/17/2014 06:44 AM, Khalid Al-Ghamdi wrote: Hi, Why is it i can use mu custom class exception without creating an exception object first? Thanks 1. class ShortInputException(Exception): def __init__(self, length, atleast): 2. Exception.__init__(self) 3. se

Re: [Tutor] Regarding Exceptions

2014-02-17 Thread Alan Gauld
On 17/02/14 11:44, Khalid Al-Ghamdi wrote: Why is it i can use mu custom class exception without creating an exception object first? There are formatting problems when I try to copy your code. I've tried to fix them below, apologies if I got it wrong. However you do create an instance when you

Re: [Tutor] Regarding Exceptions

2014-02-17 Thread Chris “Kwpolska” Warrick
On Mon, Feb 17, 2014 at 12:44 PM, Khalid Al-Ghamdi wrote: > Hi, > > Why is it i can use mu custom class exception without creating an exception > object first? > > Thanks > > class ShortInputException(Exception): def __init__(self, length, atleast): > Exception.__init__(self) > sel