In most, but not all cases, it is entirely possible to write programs to be compatible with both python 2.7 and 3.x. The caveat of this is library availability however. If you use a library for your application that is not available for the other version of Python then you are fairly out of luck. This is actually the primary reason 2.x is still around. Many of the modules people rely on simply haven't been converted.
So if you are certain that the libraries you use are available in both versions then you will probably be fine. You of course still need to confirm for yourself that it runs on both however as there are many tiny stupid things that can stop the program from working on both cleanly.
Most common silly reasons for compatibility failing between 2.x and 3.x:
print statement vs print() function
raw_input vs input
xrange vs range
integer division default vs true division default
All of those are easily handled though and don't pose a problem.
On the commercial side here, if you are actually selling an app you probably aren't going to distribute as plain source code anyway though. You would use some program like py2exe or cxfreeze or py2app or whatever to package the program for whatever platform you were targeting (if people wanted to extract your source code they probably would succeed though but it would be a deterrent). This case would also require you to test and confirm functonality.
New Users, Read This
- Use code tags when posting code.
- Include any errors with your post (in code tags).
- Describe your problem; not your chosen solution.
- Make examples the minimum length to demonstrate your issue.