Re: [Tutor] dictionaries, objects and scoping...

2008-01-22 Thread Alan Gauld
"John Morris" <[EMAIL PROTECTED]> wrote

> So this seems like it will make scope/namespaces a bit 
> interesting...

namespaces in python are literally that, they are spaces
where *names* are visible. Objects are something else
entirely and assignment only pins a name to an object.

So in Python namespaces contriol where you can use a
name, not where you can use an object.

def f(y): return  y+1

x = 66
print f(x)

y is a name that is only visible inside f.
66 is a number object associated with x
and passed into f where it is associated
with y. The number object inside f is the
same object outside f only the name has
changed.The return value is a new number
object (67 in this case).

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] float_info

2008-01-22 Thread Dick Moores
At 08:59 AM 1/21/2008, Kent Johnson wrote:
>This is probably of interest to Dick Moores at least...
>  From What's New in Python 2.6
>http://docs.python.org/dev/whatsnew/2.6.html
>
>[Note: A release date has not been set for Python 2.6]
>
>A new variable in the sys module, float_info, is an object containing
>information about the platform's floating-point support derived from the
>float.h file. Attributes of this object include mant_dig (number of
>digits in the mantissa), epsilon (smallest difference between 1.0 and
>the next largest value representable), and several others. (Contributed
>by Christian Heimes.)

Yes. Thanks, Kent.

Dick


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Projects

2008-01-22 Thread Damian Archer
Guys and Gals,

Firstly 'Hi'. So I am new to Python have been learning it for about two
months now on and off between working and playing.

Its the first language I have tried to learn, I am taking to it quite well
and enjoying it, which is always good.

The problem I am having is finding project ideas for beginners. I know I
should be looking at things I need, but quite honestly the level I am at I
think these will be beyond me. Plus I want to master the basics I've
learnt before I get ahead of myself.

So anyone have any good project ideas, perhaps projects that people have
undertaken before??

Thanks in advance!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] dictionaries, objects and scoping...

2008-01-22 Thread Tiger12506
Just a thought~

The built-in id() function can be useful in helping to sort out stuff. 
Returns a unique identifier for each object created so you can test whether 
a different name is a different object or just a different name for the same 
object. (This is what the  'is' operator does... Note: the 'is' operator and 
the '==' operator are not the same) 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor