Tony the Tiger writes:
> radius='10', mass='1'
>
> if radius == '10' ...
>
> if mass == '1' ...
This ignores the problem as stated: The OP wants to distinguish between
a value that was explicitly set by the caller, versus a value that was
set by default because the caller did not specify the par
On Thu, Dec 11, 2014 at 11:03 AM, Ian Kelly wrote:
>
> On Thu, Dec 11, 2014 at 3:02 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> > I would advise to remove the the mass parameter of your Sphere
initialization. It could be inconsistent with the radius.
> > To compute the mass you wo
On Thu, Dec 11, 2014 at 3:02 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> I would advise to remove the the mass parameter of your Sphere
initialization. It could be inconsistent with the radius.
> To compute the mass you would need the radius and the volumetric mass
density.
You a
- Original Message -
> From: "ast"
> >
> >> Note : what is the mass of a circle ?
> >
>
> In fact it's a ball moving in a plan.
> I will change that name.
I would advise to remove the the mass parameter of your Sphere initialization.
It could be inconsistent with the radius.
To compute
- Original Message -
> From: "Chris Angelico"
> > c1 = Circle((0,0), 10, None)
> > print c1.mass
> > 20
> > c1.radius = 20
> > print c1.mass
> > 40
>
> I think that juust might count as scope creep :)
> ChrisA
Here you go :p
c1 = Circle((0,0), 10, None)
print c1.mass
20
c1.gr
"Chris Angelico" a écrit dans le message de
news:mailman.16814.1418228205.18130.python-l...@python.org...
On Thu, Dec 11, 2014 at 3:10 AM, Jean-Michel Pichavant
wrote:
- Original Message -
From: "ast"
But there's an issue with that solution: self.mass being computed
during the i
Jean-Michel Pichavant writes:
> If you like one-liners,
>
> def __init__(self, center=(0,0), radius=10, mass=None):
> self.center = center
> self.radius = radius
> self.mass = (mass is None and radius**2) or mass
That's not a one-liner. That's a one-liner:
def __init__(self, center=
Skip Montanaro :
> On Wed, Dec 10, 2014 at 9:14 AM, ast wrote:
>> I have the idea to write:
>>
>> def __init__(center=(0,0), radius=10, mass=None)):
>>
>>if mass == None:self.mass = radius**2
>>else:
>>self.mass = mass
>>
>> but maybe Python provides something clever.
>
>
On Wed, Dec 10, 2014 at 9:10 AM, Jean-Michel Pichavant <
jeanmic...@sequans.com> wrote:
> If you like one-liners,
>
> def __init__(self, center=(0,0), radius=10, mass=None):
> self.center = center
> self.radius = radius
> self.mass = (mass is None and radius**2) or mass
If mass is None
On 12/10/14 11:10 AM, Jean-Michel Pichavant wrote:
self.mass = (mass is None and radius**2) or mass
When will this idiom die? We've had actual if-expressions for a while now:
self.mass = radius**2 if mass is None else mass
--
Ned Batchelder, http://nedbatchelder.com
--
https://mail
On Thu, Dec 11, 2014 at 3:10 AM, Jean-Michel Pichavant
wrote:
> - Original Message -
>> From: "ast"
>> I have the idea to write:
>>
>> def __init__(center=(0,0), radius=10, mass=None)):
>>
>> if mass == None:
>> self.mass = radius**2
>> else:
>> self.mass = mass
>
- Original Message -
> From: "ast"
> I have the idea to write:
>
> def __init__(center=(0,0), radius=10, mass=None)):
>
> if mass == None:
> self.mass = radius**2
> else:
> self.mass = mass
>
> but maybe Python provides something clever.
>
> Thx
If you like on
"Skip Montanaro" a écrit dans le message de
news:mailman.16809.1418225382.18130.python-l...@python.org...
On Wed, Dec 10, 2014 at 9:14 AM, ast wrote:
thx
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 10, 2014 at 9:14 AM, ast wrote:
> I have the idea to write:
>
> def __init__(center=(0,0), radius=10, mass=None)):
>
>if mass == None:self.mass = radius**2
>else:
>self.mass = mass
>
> but maybe Python provides something clever.
This is almost the correct idio
Hello
Here is what I would like to implement
class Circle:
def __init__(center=(0,0), radius=10, mass=1)):
self.center = center
self.radius = radius
if "mass is the default one": <-
self.mass = radius**2
else:
self.mass = mass
I
15 matches
Mail list logo