On Dec 3, 2007, at 9:45 PM, Ed Leafe wrote:

>       Here's another example that will usually trip up Python n00bs who
> expect names to work as variables in other languages do:

        Here's an even simpler one:

x = 1
y = x
# Affirm that x and y are the same
print y is x    # True
x += 1
# Make sure they're still the same
print y is x    # False!
print x # 2
print y # 1

        x and y were the same object, and then we incremented x. Why didn't  
y also get incremented?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to