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-list
python-list
Re: exception due to NoneType
by Asit other posts by this author
Nov 7 2009 11:11AM messages near this date
Re: exception due to NoneType | Re: exception due to NoneType
On Nov 7, 10:36 pm, Bruno Desthuilliers
<bdesth.quelquech...@[...].fr>  wrote:
>  asit a écrit :
> 
>  > In my program I want to catch exception which is caused by accessing
>  > NoneType object.
> 
>  > Can anyone suggest me how this can be done ??
> 
>  Not without the minimal working code exposing your problem, or the full
>  traceback you got. Merely "accessing NoneType object" doesn't by itself
>  raise any exception... I suspect you get the None object where you
>  expected something else and try to access an attribute of this
>  'something else', and ends up getting an AttributeError, but there are
>  other possible scenarii that might fit your (very poor) description of
>  the problem, so no way too help you without more informations. As a
>  general rule, remember that the traceback is actually meant to *help*
>  finding out what went wring.

I could have described the error, but the problem is that it's
dependent of a third party library..

Let me write the code here...

import twitter

api = twitter.Api('asitdhal','swordfish')
users = api.GetFriends()
for s in users:
    print
    print "##########################################"
    try:
        print "user id : " + str(s.id)
        print "user name : " + s.name
        print "user location : " + s.location
        print "user description : " + s.description
        print "user profile image url : " + s.profile_image_url
        print "user url : " + s.url
        print "user status : " + str(s.status)
    except TypeError:
        pass


look at the except TypeError. This is supposed to catch only exception
thrown by NoneType.

please help me.
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Asit
Bruno Desthuilliers
Ben Finney
Asit
Bruno Desthuilliers
Diez B. Roggisch

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