Some comparison operators gone in Python 3.0?

2008-05-13 Thread wxPythoner
Is that true that this comparison operators are gone in Python 3.0:

<(is less than)
>(is greater than)
<= (is less than or equals)
>= (is greater than or equals)

Is it true?
--
http://mail.python.org/mailman/listinfo/python-list


The 'is' identity operator checking immutable values caution

2008-05-13 Thread wxPythoner
We have to avoid the use of the 'is' identity operator with basic,
immutable values such as numbers and strings. The result is
unpredictable because of the way Python handles these objects
internally.

How is with this issue in Python 3.0? Is it fixed? Does Python handle
this things properly now?
--
http://mail.python.org/mailman/listinfo/python-list


Backslash frowned upon?

2008-05-13 Thread wxPythoner
Why is the  \  backslash character frowned upon? Can I still use it in
Python 3.0 to achieve the same thing it was designed to do?
--
http://mail.python.org/mailman/listinfo/python-list


What is self.file = file for?

2008-05-13 Thread wxPythoner
Hello!

I have trouble understanding something in this code snippet:

class TextReader:
"""Print and number lines in a text file."""
def __init__(self, file):
self.file = file
.
.
.


When would you do a thing like  self.file = file  ? I really don't
find an answer on this. Please help me understand this.
--
http://mail.python.org/mailman/listinfo/python-list


Mathematics in Python are not correct

2008-05-08 Thread wxPythoner
Have a look at this:

>>> -123**0
-1


The result is not correct, because every number (positive or negative)
raised to the power of 0 is ALWAYS 1 (a positive number 1 that is).

The problem is that Python parses -123**0 as -(123**0), not as
(-123)**0.

I suggest making the Python parser omit the negative sign if a
negative number is raised to the power of 0. That way the result will
always be a positive 1, which is the mathematically correct result.

This is a rare case when the parser is fooled, but it must be fixed in
order to produce the correct mathematical result.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Mathematics in Python are not correct

2008-05-10 Thread wxPythoner
I am stunned that this simple misunderstanding of mine ended in a
mathematical clash of a sort. :)  You guys really blew me away wih
your mathematical knowledge. And also the 0**0 is a thing I've never
thought about trying, until now that is. If the mathematical rule is
that EVERYTHING raised to the power of 0 is 1, then we should accept
that, even in the case of 0**0. This is just the way it is.

I have two another interesting things to discuss about, for which I'll
open new posts on this group. Look for "Python doesn't recognize quote
types" and "Python, are you ill?".
--
http://mail.python.org/mailman/listinfo/python-list


Python doesn't recognize quote types

2008-05-10 Thread wxPythoner
There's a thing that bugs me in Python. Look at this...

>>> print "Testing\"
SyntaxError: EOL while scanning single-quoted string


Please focus on the part of the error message that states "while
scanning single-quoted string". How can Python claim it scanned a
single-quoted string when I fed it with a double-quoted string? Is
quote type (single quote and double quote) recognition not implemented
in Python?
--
http://mail.python.org/mailman/listinfo/python-list


Python, are you ill?

2008-05-10 Thread wxPythoner
If you are in the interactive prompt of the Python interpreter and you
do this

print """Testing\"""   or   print '''Testing\'''

you get three dots [...] as if Python expects a code block. If you
press Enter, you get three dots again, and again, and again... You
can't get out of the code block with pressing the Enter key; you have
to press Ctrl+Z (if you're in Linux) in order to get out of that code
block, which then throws you back to the Linux command line, but
before that it prints this line

[1]+  Stopped python


If you do

print "Testing\"   or   print 'Testing\'

you get an error, but not of you use the triple quotes. Is that a bug
in the interpreter perhaps?
--
http://mail.python.org/mailman/listinfo/python-list


Some error messages in Python are ugly

2008-05-11 Thread wxPythoner
This really looks ugly for an error message:

[1]+  Stopped python


Please explain to me the role of the '+' sign. And why is there such a
gap between 'Stopped' and 'python'?
--
http://mail.python.org/mailman/listinfo/python-list


Unimport statement

2008-05-11 Thread wxPythoner
We should have that statement, so that problems, expressed in
http://groups.google.com/group/comp.lang.python/browse_thread/thread/3bda1fc4895ec886/bc5fe40cfbd10124?lnk=raot#bc5fe40cfbd10124,
would not occur.
--
http://mail.python.org/mailman/listinfo/python-list


Make Python create a tuple with one element in a clean way

2008-05-11 Thread wxPythoner
To create a tuple with one element, you need to do this:

>>> my_tuple = (1,)# Note the trailing comma after the value 1
>>> type(my_tuple)



But if you do this

>>> my_tuple = (1)
>>> type(my_tuple)


you don't get a tuple. I thought that just putting a value inside ( )
would make a tuple. Apparently that is not the case. I hate ugly code
so it would be clean if Python would convert anything put into ( ) to
be a tuple, even if just one value was put in (without having to use
that ugly looking comma with no value after it).
--
http://mail.python.org/mailman/listinfo/python-list