A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/341946.html below:

Wrapping float

Wrapping floatSybren Stuvel sybren at localhost.localdomain
Sat Sep 17 05:12:34 EDT 2005
Hi all,

I'm trying to make a float-like class (preferably a subclass of
'float') that wraps around. The background: I'm modeling a
multi-dimensional space, and some of those dimensions are circular.

Here is my code so far:

class WrapFloat(float):
    def __init__(self, value, wrap = None):
        float.__init__(self, value)
        self.wrap = wrap

The problem is this:

Python 2.4.1 (#2, Mar 30 2005, 21:51:10) 
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from engine.geometry import WrapFloat
>>> WrapFloat(45)
45.0
>>> WrapFloat(45, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: float() takes at most 1 argument (2 given)

So my question to you is: how can I change my code so I can pass two
values to the WrapFloat constructor?

Thanks in advance,
Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4