Deutsch   English   Français   Italiano  
<v5j68n$2ks7o$7@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.os.linux.advocacy
Subject: Re: Need Assistance -- Network Programming
Date: Thu, 27 Jun 2024 08:01:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <v5j68n$2ks7o$7@dont-email.me>
References: <17da6bead1f52684$159717$3694546$802601b3@news.usenetexpress.com>
	<17da7b2e072f80b8$336$3510362$802601b3@news.usenetexpress.com>
	<MoednQePt4STte77nZ2dnZfqnPSdnZ2d@supernews.com>
	<ldgtitFirtiU1@mid.individual.net>
	<17da83b880511303$1242$4081608$802601b3@news.usenetexpress.com>
	<ldh5e8FirtiU8@mid.individual.net> <v5g02q$1ut7v$3@dont-email.me>
	<667c48fd$0$2385533$882e4bbb@reader.netnews.com>
	<le3o96Fh0sfU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 27 Jun 2024 10:01:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="080a009ffce1dc4f5355e621231567e1";
	logging-data="2781432"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+KvS4xsNyNrvVf/jt9bMNc"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:6qGrm+f/1ho66wuno0yrism7WMM=
Bytes: 2634

On 26 Jun 2024 23:58:30 GMT, rbowman wrote:

> Similarly while Python has math.degrees() and math.radians() ...

I’ve long felt those conversion functions are an unnecessarily roundabout 
way of doing things. After all, you need two for every angle unit, 
assuming you stick with radians as the common basis among all of them. 
Otherwise you need even more.

Better to have a single conversion factor for each unit, e.g.

    class ANGLE_UNITS(float, enum.Enum) :
        "standard values for Context.angle_units."
        RADIANS = 1.0
        DEGREES = math.pi / 180
        GRADIANS = math.pi / 200
        CIRCLE = 2 * math.pi
    #end ANGLE_UNITS

so you multiply by the factor to convert the units to radians, and divide 
by the same factor to convert radians to those units.

Then all your trig functions can operate exclusively in radians:

    units = ANGLE_UNITS.DEGREES
    θ = float(input("Angle in degrees? "))
    x = math.sin(θ * units)
    print("Angle: ", math.asin(x) / units, "°")

And yes, Python does full multiple inheritance. And yes, you can subclass 
from builtin types like float as well. And further yes, enums are not a 
built-in language feature, they are provided in a library module that is 
written in pure Python.