En Sat, 29 Nov 2008 04:51:59 -0200, Carl Banks <[EMAIL PROTECTED]>
escribió:
On Nov 28, 11:51 pm, Carl Banks
Absolute versus relative imports don't have anything to do with the
issue here. PEP 328 concerns itself with imports relative to the
executing module in package space. It has nothing
On Nov 28, 11:51 pm, Carl Banks
> Absolute versus relative imports don't have anything to do with the
> issue here. PEP 328 concerns itself with imports relative to the
> executing module in package space. It has nothing to do with imports
> relative to the current directory in filename space.
On Nov 28, 2:59 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > On Nov 28, 3:15 am, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> > > This is resolved in the Python 2.x series by implementing PEP 328
> > > http://www.python.org/dev/peps/pep-0328/>, such that the
Carl Banks <[EMAIL PROTECTED]> writes:
> On Nov 28, 3:15 am, Ben Finney <[EMAIL PROTECTED]>
> wrote:
> > This is resolved in the Python 2.x series by implementing PEP 328
> > http://www.python.org/dev/peps/pep-0328/>, such that the
> > search path for ‘import’ does *not* contain the current direct
On Nov 28, 3:24 am, Viktor Kerkez <[EMAIL PROTECTED]> wrote:
> On Nov 28, 9:35 am, Carl Banks <[EMAIL PROTECTED]> wrote:
>
> > However, I'm not so sure the effect of os.chdir() on the import path
> > is a good idea.
>
> I'm not actually using os.chidir(), I just used it here to create a
> clearer e
On Nov 28, 3:15 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > I like to think that "import abc" always does the same thing
> > regardless of any seemingly unrelated state changes of my program,
> > especially since, as the OP pointed out, import is used as a
On Nov 28, 9:35 am, Carl Banks <[EMAIL PROTECTED]> wrote:
> However, I'm not so sure the effect of os.chdir() on the import path
> is a good idea.
I'm not actually using os.chidir(), I just used it here to create a
clearer example.
Here is the simplest representation of the problem:
http://www.n
Carl Banks <[EMAIL PROTECTED]> writes:
> I like to think that "import abc" always does the same thing
> regardless of any seemingly unrelated state changes of my program,
> especially since, as the OP pointed out, import is used as a means
> to ensure singleness. Thus, if I were designing the lang
On Nov 27, 11:42 am, Viktor Kerkez <[EMAIL PROTECTED]> wrote:
> Here is the situation:
>
> $ ls
> test
> $ cd test
> $ ls
> __init__.py data.py
> $ cat __init__.py
>
> $ cat data.py
> DATA = {}
>
> $ cd ..
> $ python>>> import os
> >>> from test.data import DATA
> >>> DATA['something'] = 33
> >>> o
On Nov 28, 12:32 am, "Chris Rebert" <[EMAIL PROTECTED]> wrote:
> The Python position on singletons is generally to just use a module
> instead (preferred), or apply the Borg
> pattern:http://code.activestate.com/recipes/66531/
The same problem appears if I use the module (as I pointed in the
firs
On Thu, Nov 27, 2008 at 2:36 PM, Viktor Kerkez <[EMAIL PROTECTED]> wrote:
> A better way to do this was http://pastebin.com/m1130d1fe :)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
The Python position on singletons is generally to just use a module
instead (preferred), or apply th
A better way to do this was http://pastebin.com/m1130d1fe :)
--
http://mail.python.org/mailman/listinfo/python-list
But this means that there is no way to create a safe Singleton in
python, because the classes are also created twice.
This is the problem that I encountered. I created a complex
implementation of a Singleton pattern using metaclasses because I
needed the __init__ method to be called just once and
Viktor Kerkez <[EMAIL PROTECTED]> writes:
> Here is the situation:
>
> $ ls
> test
> $ cd test
> $ ls
> __init__.py data.py
> $ cat __init__.py
>
> $ cat data.py
> DATA = {}
>
> $ cd ..
> $ python
import os
from test.data import DATA
DATA['something'] = 33
os.chdir('test')
On Nov 27, 6:42 pm, Viktor Kerkez <[EMAIL PROTECTED]> wrote:
> Is this a bug?
It is not a bug: the dictionaries are different because they are
loaded from different modules.
>>> import os
>>> import test.data
>>> test.data
>>> os.chdir('test')
>>> import data
>>> data
>>> test.data is data
Fals
Viktor Kerkez wrote:
> Here is the situation:
>
> $ ls
> test
> $ cd test
> $ ls
> __init__.py data.py
> $ cat __init__.py
>
> $ cat data.py
> DATA = {}
>
> $ cd ..
> $ python
import os
from test.data import DATA
DATA['something'] = 33
os.chdir('test')
from data import
Here is the situation:
$ ls
test
$ cd test
$ ls
__init__.py data.py
$ cat __init__.py
$ cat data.py
DATA = {}
$ cd ..
$ python
>>> import os
>>> from test.data import DATA
>>> DATA['something'] = 33
>>> os.chdir('test')
>>> from data import DATA as NEW_DATA
>>> DATA
{'something': 33}
>>> NEW_DAT
17 matches
Mail list logo