Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute Errors #159

Closed
ghost opened this issue May 20, 2023 · 2 comments
Closed

Attribute Errors #159

ghost opened this issue May 20, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented May 20, 2023

In python when I parse the message and I want the longitude, it says attribute error, I use msg.longitude

@Alperencode
Copy link

That message might not have the longitude attribute. I recommend looping through message fields and finding its attributes using getattr().

Example:

msg = pynmea2.parse(sentence)
dict = {}
for key in msg.fields:
    dict[key[0]] = getattr(msg, str(key[1]))

In this example key[0] is attribute like "longitude" and key[1] is its parsed value.

You can check my implementation for complete example:

@kamiccolo
Copy link
Contributor

In python when I parse the message and I want the longitude, it says attribute error, I use msg.longitude

And this is expected, due to not all the messages carrying this kind of importation. I'd rather check the type of the message first.

@Knio Knio closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants