Skip to content
This repository has been archived by the owner on Nov 12, 2021. It is now read-only.

Accessing only existing data attributes on Node instances #5

Open
anentropic opened this issue Apr 18, 2011 · 0 comments
Open

Accessing only existing data attributes on Node instances #5

anentropic opened this issue Apr 18, 2011 · 0 comments

Comments

@anentropic
Copy link

Node class docstring says:
"...accessing non-existent attributes will still return a Graph... You’ll have to check for the presence of a key first, to make sure what you're trying to access actually exists"

    def user_location(user_id):
        user = graph[user_id]()
        if 'location' in user:
            return user.location
        return False

but in my tests if 'anything' in a_node always returns True.

I thought maybe I could do 'anything' in a_node.as_dict() ...but this throws Http 400 error from Facebook, I guess the unbunchify call unintentionally causes a load of weird API lookups via the getitem machinery of Graph/Node classes.

This works:

if 'location' in user.keys():
    myvar = user.location
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant