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

Accessing only existing data attributes on Node instances #5

@anentropic

Description

@anentropic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions