🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: przypisac nieskonczonosc

#21423
From: Marcin Ciura
Date: Tue, 16 Oct 2007 16:07
18 lines
2035 bytes
On Oct 16, 10:34 am, Sulsa <su...@dontmail.me> wrote:
> Jak liczbie zmiennoprzecinkowej w pythonie przypisac wartość
> +nieskonczoność

Jesli potrzebujesz tej nieskonczonosci tylko do porownan
i nie bedziesz na niej wykonywac operacji arytmetycznych, to:

class Infinity(int):
  def __cmp__(self, other):
    if isinstance(other, self.__class__): return self - other
    return self

MinusInf = Infinity(-9999)
PlusInf = Infinity(+9999)

Rozszerzenie klasy o metody __str__() i __repr__()
to cwiczenie dla czytelnika, ktoremu sa one potrzebne.
  Marcin
Technical Details
Message-ID: <1192550823.753950.10200@v29g2000prd.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.stw-bonn.de!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.freenet.de!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!nx01.iad01.newshosting.com!newshosting.com!216.196.98.140.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!v29g2000prd.googlegroups.com!not-for-mail
References: <20071016103416.e69a7bc7.sulsa@dontmail.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.stw-bonn.de!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.freenet.de!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!nx01.iad01.newshosting.com!newshosting.com!216.196.98.140.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!v29g2000prd.googlegroups.com!not-for-mail
From: Marcin Ciura <mciura@gmail.com>
Newsgroups: pl.comp.lang.python
Subject: Re: przypisac nieskonczonosc
Date: Tue, 16 Oct 2007 16:07:03 -0000
Organization: http://groups.google.com
Lines: 19
Message-ID: <1192550823.753950.10200@v29g2000prd.googlegroups.com>
References: <20071016103416.e69a7bc7.sulsa@dontmail.me>
NNTP-Posting-Host: 172.28.16.111
Mime-Version: 1.0
X-Trace: posting.google.com 1192550824 29782 127.0.0.1 (16 Oct 2007 16:07:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 16 Oct 2007 16:07:04 +0000 (UTC)
In-Reply-To: <20071016103416.e69a7bc7.sulsa@dontmail.me>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: v29g2000prd.googlegroups.com; posting-host=172.28.16.111;   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit