ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] problem creating a subclass
by Lloyd Kvam other posts by this author
Feb 29 2004 10:37PM messages near this date
Re: [Tutor] problem creating a subclass | Re: [Tutor] problem creating a subclass
You didn't pass the list that came in, you passed None.

Christopher Spears wrote:

>  I am creating a new class based on UserList called
>  UList.  Here is the code:
>  
>  import UserList
>  
>  class UList(UserList.UserList):
>      def __init__(self, initlist=None):
                                  ^^^^^ defines a default value
>          UserList.UserList.__init__(self,
>  initlist=None)
           ^^^^^ passes None

You want (the slightly odd looking) initlist=initlist
which will pass your variable named initlist to the argument that
has the same name, initlist.

>  
>  When I tested the class, the following happened:
>  
>  
> >>>import UList
> >>>list = [1,2,3]
> >>>a = UList.UList(list)
> >>>a
>  
>  []
>  
>  What gives?
>  -Chris
>  
>  =====
>  "I'm the last person to pretend that I'm a radio.  I'd rather go out and be a color televi
sion set."
>  -David Bowie
>  
>  "Who dares wins"
>  -British military motto
>  
>  "The freak is the norm." - "The Infernal Desire Machines of Dr. Hoffman" by Angela Carter
>  
>  _______________________________________________
>  Tutor maillist  -  Tutor@[...].org
>  http://mail.python.org/mailman/listinfo/tutor
>  

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582


_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Christopher Spears
Alan Gauld

Alan Gauld
Lloyd Kvam
Nick Lunt

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved