Article View: pl.comp.lang.python
Article #27360Re: Przestrzeń nazw (?)
From: Bart Ogryczak
Date: Mon, 22 Mar 2010 09:44
Date: Mon, 22 Mar 2010 09:44
57 lines
2344 bytes
2344 bytes
On Mar 22, 9:24 am, wysek <piotrwyso...@gmail.com> wrote:
> On 15 Mar, 10:54, Bart Ogryczak <b.ogryc...@gmail.com> wrote:
>
>
>
>
>
> > On Mar 14, 1:06 pm, pr <crico...@gmail.com> wrote:
>
> > > Witam,
>
> > > Czy w Pythonie (3.1) można zrobić coś takiego (jeden plik):
>
> > > class A:
> > > class AA:
> > > obj = B()
>
> > > class B:
> > > class BB:
> > > obj = A()
>
> > > A()
> > > B()
>
> > > ?
>
> > Już pare razy tu o tym było -- jeśli czegoś takiego potrzebujesz, to
> > znaczy, że masz spitolony model.
>
> Czy ja wiem, czasami sie takie cos przydaje.
Podaj przykład rzeczywistego zastosowania.
Bo realnie, to się przydaje coś takiego:
-- a.py --
class A:
def __init__(self):
self.x = X()
-- b1.py --
class B1:
print "cokoliwek bez zależności od A"
-- b2.py --
class B2:
print "cokoliwek innego, ale nadal zależności od A"
-- app.py --
if(costam):
from b1 import B1 as X
else:
from b2 import B2 as X
from a import A
a = A()
Technical Details
Message-ID:
<4268878e-ddb4-4962-913c-30cf1ff13572@t23g2000yqt.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!t23g2000yqt.googlegroups.com!not-for-mailReferences:
ab79855c-4043-4798-b3b2-2ac56d085214@q16g2000yqq.googlegroups.comShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!t23g2000yqt.googlegroups.com!not-for-mail From: Bart Ogryczak <b.ogryczak@gmail.com> Newsgroups: pl.comp.lang.python Subject: Re: Przestrzeń nazw (?) Date: Mon, 22 Mar 2010 02:44:07 -0700 (PDT) Organization: http://groups.google.com Lines: 61 Message-ID: <4268878e-ddb4-4962-913c-30cf1ff13572@t23g2000yqt.googlegroups.com> References: ab79855c-4043-4798-b3b2-2ac56d085214@q16g2000yqq.googlegroups.com NNTP-Posting-Host: 94.100.112.225 Mime-Version: 1.0 X-Trace: posting.google.com 1269251047 2769 127.0.0.1 (22 Mar 2010 09:44:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 22 Mar 2010 09:44:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t23g2000yqt.googlegroups.com; posting-host=94.100.112.225; posting-account=1kG_1AoAAADLEA3eucGvO2J-Uo4aPCW_ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1036 Safari/532.5,gzip(gfe),gzip(gfe) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit