On Thu, Nov 8, 2012 at 11:05 PM, Ulrich Eckhardt
<ulrich.eckha...@dominolaser.com> wrote:Can you use the inverted check "isinstance(p, str)"? It's more likely
> Firstly, I have code that allows either a file or a string representing its
> content as parameter. If the parameter is a file, the content is read from
> the file. In Python 2, I used "isinstance(p, file)" to determine whether the
> parameter p is a file...
that you'll want to pass a file-like object than a string-like object.
This would work on Python 2 as well, though it's semantically
different; to safely check for both Unicode and bytes strings on both
Py2 and Py3, this may work:
# Is p a string?
It abuses the fact that isinstance will happily accept the
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.