Can anyone give this a try?

'''print_error_python33.py
there are times when a print() trailing newline disappears with Python 3.3.0
this does not happen with Python 3.2.3 or Python 2.7.3
'''

size = 180000
print("creating long string of %d sevens" % size)

# create a long string of digits
s2 = '7' * size

# looks like this print() loses its trailing newline at times 
print("start converting ...")

n = int(s2)

print("converted string to integer")

#print("Int converted            : {}".format(timenow()))

'''my result (Windows7 OS, Python 3.3.0)
print() newline is swallowed with 180000 or more digits >>>

creating a long string of 180000 sevens
start converting ...converted string to integer


print() behaves normal with 170000 or less digits>>>

creating a long string of 170000 sevens
start converting ...
converted string to integer
'''

Recommended Answers

All 3 Replies

Print sys.maxint to see what it says. You are probably going beyond the computer's limit. It depends on your OS: 32 bit or 64 bit. For more precision take a look at the decimal module. If you want to actually do anything with a number than contains 180,000 digits, decimal is the only way to go.

In my experience this error is not the fault of Python 3.3.0 but the fault of your IDE.
I have run into a similar problem (prime number function) with the EDITRA IDE, any other IDE like IDLE, PyScripter or ConTEXT does not have a problem.

I agree, this seems to be an IDE problem at times, since IDEs have their own output area.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.