Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71687

Re: PEP 8 : Maximum line Length :

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: PEP 8 : Maximum line Length :
Date 2014-05-17 09:46 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-6B8EE9.09464317052014@news.panix.com> (permalink)
References (1 earlier) <mailman.9952.1399970767.18130.python-list@python.org> <51ad8928-619c-4e9c-b66f-15bd4a2a8124@googlegroups.com> <mailman.10041.1400164039.18130.python-list@python.org> <53775b9c$0$27160$e4fe514c@dreader35.news.xs4all.nl> <mailman.10085.1400333338.18130.python-list@python.org>

Show all headers | View raw


In article <mailman.10085.1400333338.18130.python-list@python.org>,
 Tim Chase <python.list@tim.thechases.com> wrote:

> On 2014-05-17 12:52, Albert van der Horst wrote:
> > Now translate E=mc^2 into Java.
> 
> I suspect it would be something like
> 
> public class Einstein  {
>   private double mass=0, energy=0;
>   public class Relativity implements IEquation {
>     Relativity(double mass) {
>       set_mass(mass);
>     }
>     public double getEnergy() {return energy;}
>     public double setEnergy(double newEnergy) {
>       energy = newEnergy;
>       mass = newEnergy / (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
>     }
>     public double get_mass() {return mass;}
>     public double setMass(double newMass) {
>       mass = newMass;
>       energy = newMass * (units.SPEED_OF_LIGHT * units.SPEED_OF_LIGHT);
>     }
>   }
>   
>   public static void main(String[] args) {
>     Relativity relativity = new Relativity(
>       Integer.parseInt(args[1])
>       );
>     System.out.println(relativity.getEnergy())
>   }
> }
> 
> 
> (untested, as it has been a long time since I've touched any Java code)
> 
> -tkc

Not good enough.  Einstein should really be a singleton, so you need 
something like an AbstractScientistFactory, which implements Singleton.  
And you really should be importing 
SPEED_OF_LIGHT_IN_VACUUM_METERS_PER_SECOND from 
org.universe.physics.constants.  And you need to declare that 
Einstein.getEnergy() raises NumericValueOutOfBoundsError if mass is 
negative (and FlatEarthError if the code is run in certain states south 
of the Mason-Dixie line).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: PEP 8 : Maximum line Length : Peter Otten <__peter__@web.de> - 2014-05-13 10:45 +0200
  Re: PEP 8 : Maximum line Length : Rustom Mody <rustompmody@gmail.com> - 2014-05-13 06:18 -0700
  Re: PEP 8 : Maximum line Length : wxjmfauth@gmail.com - 2014-05-15 07:17 -0700
    Re: PEP 8 : Maximum line Length : Chris Angelico <rosuav@gmail.com> - 2014-05-16 00:27 +1000
      Re: PEP 8 : Maximum line Length : wxjmfauth@gmail.com - 2014-05-15 08:48 -0700
      Re: PEP 8 : Maximum line Length : albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-17 12:52 +0000
        Re: PEP 8 : Maximum line Length : Chris Angelico <rosuav@gmail.com> - 2014-05-17 23:18 +1000
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 09:49 -0400
        Re: PEP 8 : Maximum line Length : Tim Chase <python.list@tim.thechases.com> - 2014-05-17 08:28 -0500
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 09:46 -0400
        Re: PEP 8 : Maximum line Length : Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-17 15:02 +0100
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 10:06 -0400
            Re: PEP 8 : Maximum line Length : Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-17 15:21 +0100
            Re: PEP 8 : Maximum line Length : Rustom Mody <rustompmody@gmail.com> - 2014-05-17 10:46 -0700

csiph-web