Very weird bug!

ssecorp circularfunc at gmail.com
Sun Jul 6 17:47:40 EDT 2008


I was looking into currying and

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.2.2
>>> h = "aja baja"
>>> h += 'e'
>>> h
'aja bajae'
>>> h = h+'a'
>>> h
'aja bajaea'
>>> a = b = "foo"
>>> a
'foo'
>>> b
'foo'
>>> a==b
True
>>> id(a)
35018400
>>> id(b)
35018400
>>> a += "bar"
>>> id(a),a
(35110112, 'foobar')
>>> id(b),b
(35018400, 'foo')
>>> fac

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    fac
NameError: name 'fac' is not defined
>>> factorial

Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    factorial
NameError: name 'factorial' is not defined
>>> import math
>>> math
<module 'math' (built-in)>
>>> math.factorial

Traceback (most recent call last):
  File "<pyshell#18>", line 1, in <module>
    math.factorial
AttributeError: 'module' object has no attribute 'factorial'
>>> math.fac

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    math.fac
AttributeError: 'module' object has no attribute 'fac'
>>> dir(math)
['__doc__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil',
'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod',
'frexp', 'hypot', 'ldexp', 'log', 'log10', 'modf', 'pi', 'pow',
'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']
>>> pow
<built-in function pow>
>>> tan

Traceback (most recent call last):
  File "<pyshell#22>", line 1, in <module>
    tan
NameError: name 'tan' is not defined
>>> math.tan
<built-in function tan>
>>> def build(a,b):
	return a+b

>>> build(5,4)
(5, 4)
>>> def build(x,y):
	a=x+y
	return a

>>> build(5,4)
9
>>> def b(n, p):
	return n + p

>>> b(1, 10)
11
>>> def b(n,p):
	return n+p

>>> b(5,2)
7
>>> def build(x,y):
	return a+b

>>> build(5,4)

Traceback (most recent call last):
  File "<pyshell#44>", line 1, in <module>
    build(5,4)
  File "<pyshell#43>", line 2, in build
    return a+b
TypeError: cannot concatenate 'str' and 'function' objects
>>> def build(x,y):
	yreturn x+

SyntaxError: invalid syntax
>>> def build(x,y):
	return x+y

>>> build(5,4)
9
>>> def build(a,b):
	return a+b

>>> build(5,4)
9
>>>




wtf was this in the middle!?

>>> def build(a,b):
	return a+b

>>> build(5,4)
(5, 4)



More information about the Python-list mailing list