question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I check if an item is of the `bytes` type? Also, how do I test things are an instance of `tuple`?

See original GitHub issue

I’m on python 3, and I need to validate that certain objects are of bytes or bytearray type.

I’ve tried all of the relevant type-names, and none of them appear to work. Additionally, there is apparently nothing in the documentation about either type.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fake-namecommented, Apr 6, 2016

no, the word tuple isn’t mentioned, and there can be no exhausting list that covers all types that are sequences. that is why the doc concerning the abstract class is linked.

Ok, I don’t disagree with that, but you should at least cover the most common python native types. There’s a grand total of maybe 10 types in majorly common use.

0reactions
funkyfuturecommented, Apr 6, 2016

btw, the docs from the master branch are reflected here: http://docs.python-cerberus.org/en/latest/usage.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to know if a variable is a tuple, a string or an integer?
Please note, should you wanted to check your var type in if statement, the construct if type(varname) == "tuple": won't work. But these...
Read more >
Python | Check if variable is tuple - GeeksforGeeks
Method #1: Using type() This inbuilt function can be used as shorthand to perform this task. It checks for the type of variable...
Read more >
Built-in Types — Python 3.11.1 documentation
The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, ...
Read more >
Python Bytes, Bytearray - w3resource
There are six sequence types: strings, byte sequences (bytes objects), byte arrays (bytearray objects), lists, tuples, and range objects.
Read more >
Type hints cheat sheet - mypy 0.991 documentation
See Type inference and type annotations for more details. ... "test" x: bytes = b"test" # For collections on Python 3.9+, the type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found