# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1179501950 25200
# Node ID fd752cf47fa18a26519c9a947597b739aca24112
# Parent  50ef7a673c454d20950f6cd50f6eb1ac2b201e19
Improve semantics of __call__ method for polynomial ring.

diff -r 50ef7a673c45 -r fd752cf47fa1 sage/rings/polynomial_ring.py
--- a/sage/rings/polynomial_ring.py	Fri May 18 07:17:35 2007 -0700
+++ b/sage/rings/polynomial_ring.py	Fri May 18 08:25:50 2007 -0700
@@ -48,7 +48,13 @@ We create a polynomial ring over a quate
     sage: f * g
     w^2 + (i + j)*w + k
     sage: g * f
-    w^2 + (i + j)*w + -k    
+    w^2 + (i + j)*w + -k
+
+TESTS:
+    sage: K.<x>=FractionField(QQ['x'])
+    sage: V.<z> = K[]
+    sage: x+z
+    z + x
 """
 
 
@@ -60,6 +66,7 @@ We create a polynomial ring over a quate
 #                  http://www.gnu.org/licenses/
 #*****************************************************************************
 
+from sage.structure.element import is_Element
 import random
 import sage.algebras.algebra
 import commutative_ring
@@ -156,6 +163,8 @@ class PolynomialRing_general(sage.algebr
         C = self.__polynomial_class
         if isinstance(x, C) and x.parent() is self:
             return x
+        elif is_Element(x) and x.parent() == self.base_ring():
+            return self([x])
         elif is_SingularElement(x) and self._has_singular:
             self._singular_().set_ring()
             try:
