Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:19:32+00:00 2026-05-18T04:19:32+00:00

I have a codebase which uses StringType and NoneType(types module) in the python2.x codebase.

  • 0

I have a codebase which uses StringType and NoneType(types module) in the python2.x codebase. On porting to Python3, tests failed as the types module in Python3.x does not have the above mentioned two types.

I solved the problem by replacing them with “str” and “None” respectively. I was wondering if there is another (right)way of doing this. What I’m doing currently definitely seems to work, but I’m doubtful.

Should I stick to the approach I have followed or is there something wrong in what I have done? If so, how do I correct it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:19:32+00:00Added an answer on May 18, 2026 at 4:19 am

    Checking None is usually done by calling obj is None, while checking for string usually is isinstance(obj, str). In Python 2.x to detect both string and unicode, you could use isinstance(obj, basestring).

    If you use 2to3, it’s enough, but if you need to have single piece of code working in both Py2 and Py3, you may end up with something like that:

    try:
        return isinstance(obj, basestring)
    except NameError:
        return isinstance(obj, str)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on fixing a c# codebase which does not have a
At the team with which I work, we have an old codebase using PHP's
I'm working on a code base in which we have several configurable types. One
I have an ASP.net WebService which uses a Library, this has a dependency on
I have a setup project for a .NET Service Application which uses a .NET
I've got a hibernate-based application which uses DBUnit for unit testing. We have an
I have a mercurial repository which uses Mercurial queues. Assume the following scenario. I
I have a large codebase (written by me) that uses the Stack data structure.
I have inherited a code-base which uses a compiled logging library. I cannot update
I have a large codebase that targetted Flash 7, with a lot of AS2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.