Re: import from question

2008-01-18 Thread Tobiah
>> Ok, I get it. I was locally importing a pointer to an integer > > Really? What language were you using? Python doesn't have pointers. What term do you prefer? Reference? Object id holder? -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailma

Re: import from question

2008-01-16 Thread Steven D'Aprano
On Wed, 16 Jan 2008 15:31:54 -0800, Tobiah wrote: >> Again, those aren't copies. There is only one instance of each value, >> referenced by multiple names. > > > Ok, I get it. I was locally importing a pointer to an integer Really? What language were you using? Python doesn't have pointers.

Re: import from question

2008-01-16 Thread Tobiah
> Again, those aren't copies. There is only one instance of each value, > referenced by multiple names. Ok, I get it. I was locally importing a pointer to an integer which is really the same object as the module name points to, but the assignment changes that. The confusion for me centered aro

Re: import from question

2008-01-16 Thread Ben Finney
Tobiah <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > Tobiah <[EMAIL PROTECTED]> writes: > > > >> This is a little surprising. So "from mod import *" really copies > >> all of the scalars into new variables in the local namespace. > > > > No. Nothing is copied. All the objects (remembering th

Re: import from question

2008-01-16 Thread Tobiah
Ben Finney wrote: > Tobiah <[EMAIL PROTECTED]> writes: > >> This is a little surprising. So "from mod import *" really copies >> all of the scalars into new variables in the local namespace. > > No. Nothing is copied. All the objects (remembering that in Python, > *everything* is an object) creat

Re: import from question

2008-01-16 Thread Terry Reedy
"Ben Finney" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Tobiah <[EMAIL PROTECTED]> writes: | | > This is a little surprising. So "from mod import *" really copies | > all of the scalars into new variables in the local namespace. 'Scalar' is not a Python term. Neither is 'obje

Re: import from question

2008-01-16 Thread Ben Finney
Tobiah <[EMAIL PROTECTED]> writes: > This is a little surprising. So "from mod import *" really copies > all of the scalars into new variables in the local namespace. No. Nothing is copied. All the objects (remembering that in Python, *everything* is an object) created by the code in module 'mod'

Re: import from question

2008-01-15 Thread Tobiah
Duncan Booth wrote: > iu2 <[EMAIL PROTECTED]> wrote: > >> file a3.py: >> >> from a1 import the_number >> import a2 >> > ... >> Why doesn't it work in the first version of a3.py? >> > Think of 'import a2' as being the same as: > > a2 = __import__('a2') > > and 'from a1 import the_number'

Re: import from question

2008-01-15 Thread Duncan Booth
iu2 <[EMAIL PROTECTED]> wrote: > file a3.py: > > from a1 import the_number > import a2 > ... > > Why doesn't it work in the first version of a3.py? > Think of 'import a2' as being the same as: a2 = __import__('a2') and 'from a1 import the_number' as roughly the same as: the_number =

Re: import from question

2008-01-14 Thread George Sakkis
On Jan 14, 4:22 pm, iu2 <[EMAIL PROTECTED]> wrote: > Hi all > > I've got three files: > > file a1.py: > > the_number = None > > file a2.py: > > import a1 > > def init(): > a1.the_number = 100 > > file a3.py: > > from a1 import the_number > import a2 > > a2.init() > pr

import from question

2008-01-14 Thread iu2
Hi all I've got three files: file a1.py: the_number = None file a2.py: import a1 def init(): a1.the_number = 100 file a3.py: from a1 import the_number import a2 a2.init() print the_number, type(the_number) Runninr a3.py I get: None Changing a3.py to: import a