🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27359

Re: Przestrzeń nazw (?)

#27359
From: wysek
Date: Mon, 22 Mar 2010 08:24
46 lines
2011 bytes
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.
Nie znam sie, ale czy nie ma na to czasem jakiegos wzorca?;)

class A:
    B = None
    def b(self):
        return A.B()

class B:
    A = None
    def a(self):
        return B.A()

A.B = B
B.A = A

#####

A().b()
B().a()
A().b().a().b()
Technical Details
Message-ID: <ab79855c-4043-4798-b3b2-2ac56d085214@q16g2000yqq.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!q16g2000yqq.googlegroups.com!not-for-mail
References: <9100aa5e-8f93-493a-8e57-23dd86779de2@o3g2000yqb.googlegroups.com> <37685a2c-ec66-4da7-99b2-d1431c9a2226@u9g2000yqb.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!q16g2000yqq.googlegroups.com!not-for-mail
From: wysek <piotrwysocki@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Re: Przestrzeń nazw (?)
Date: Mon, 22 Mar 2010 01:24:18 -0700 (PDT)
Organization: http://groups.google.com
Lines: 47
Message-ID: <ab79855c-4043-4798-b3b2-2ac56d085214@q16g2000yqq.googlegroups.com>
References: <9100aa5e-8f93-493a-8e57-23dd86779de2@o3g2000yqb.googlegroups.com>  <37685a2c-ec66-4da7-99b2-d1431c9a2226@u9g2000yqb.googlegroups.com>
NNTP-Posting-Host: 150.254.24.80
Mime-Version: 1.0
X-Trace: posting.google.com 1269246258 5149 127.0.0.1 (22 Mar 2010 08:24:18 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 22 Mar 2010 08:24:18 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: q16g2000yqq.googlegroups.com; posting-host=150.254.24.80;  posting-account=reP9-QkAAAAWiM6tVL630VLharryHqF3
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8)  Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8,gzip(gfe),gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit