473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Very weird bug!

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)
Jul 6 '08 #1
3 1607
ssecorp wrote:
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
wtf was this in the middle!?
>>>def build(a,b):
return a+b
>>>build(5,4)
(5, 4)
I have exactly the same build on Windows and get the expected 9.

Try it again.

Jul 7 '08 #2
i know, idid try it again and it works as expected. but how the h***
did it not work that one time?
Jul 7 '08 #3
Maybe the interpreter remembered the values of some objects you used?
If you type in the interpreter, the objects you create have a lifetime
as long as the interpreter is active, which means it can get a state
behaviour that otherwise is not present if you start a new interpreter
instance. To be safe you should always try it with a script and run it
from the commandline to get the same 'state' everytime your script
runs.

- Jorgen
On Mon, Jul 7, 2008 at 7:36 PM, ssecorp <ci**********@gmail.comwrote:
i know, idid try it again and it works as expected. but how the h***
did it not work that one time?
--
http://mail.python.org/mailman/listinfo/python-list
Jul 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Shi | last post by:
Hi all, Please take a look at following very simple script; #!/usr/bin/php -q <? echo "Hello, world!\n"; if (!$tty) { $tty = fopen('php://stdin', 'r'); }
8
by: Alan Little | last post by:
I started with the following code in an included file: $CompanyBlock = "$Company (Booth#: $Booth)\n". "$Address\n". "$City, $State $PostalCode\n". "$Website\n". "$Contact1, $Title1\n"....
1
by: petdoc | last post by:
Hi Folks, I am trying to find the most perplexing bug I have had in a vb.net app to date. Here is some code: Dim Data as Short Data = Me.ReadPMAPDigits(pmOffsets.APIAS)
9
by: ZorpiedoMan | last post by:
This is so weird, and I cannot even isolate the cause enough to give any clues as to how to reproduce the error, so this is probably a real shot in the dark... BUT, has anyone ever run into a...
9
by: Elliot Rodriguez | last post by:
WinXP Pro Let me preface this by saying I have developed with the .NET IDE since its release, and I consider myself reasonably savvy with it. I have a medium sized form with about 120 controls...
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
9
by: fabio.bizzetti | last post by:
Hello all, I went across what seems possibly a bug of the compiler (VisualC 2005, just for the record) or a very strange and non-expected (by me at least) behaviour of the C++ ISO standard. Thus...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
4
by: jlhsgcib | last post by:
Hello, I have the following snippet of code: sub getPasswordStatus { my ($login, $password) = @_; my$quotedLogin = quotemeta($login);
1
antonopn
by: antonopn | last post by:
Hello there, I have just faced a really weird problem with a query in SQL SERVER 2000. I had a database with collation SQL_Latin1_General_CP1_CI_AS and converted it in a new database with...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.