Op Thursday 30 Apr 2015 14:53 CEST schreef Dennis Lee Bieber:
> On Wed, 29 Apr 2015 22:31:13 -0400, Dave Angel
> declaimed the following:
>
>> On 04/29/2015 10:16 AM, Grant Edwards wrote:
>
>>
>>> raise ParameterError, 'Parameter has to be an int'
>>> if n < 0:
>>
>> Better: if length < 0:
On Thu, Apr 30, 2015 at 3:10 PM, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> If you have a Java background, you might find this useful:
>>
>> http://dirtsimple.org/2004/12/python-is-not-java.html
>>
>> http://dirtsimple.org/2004/12/java-is-not-python-either.html
>
> Unfortunately, I didn't find
Steven D'Aprano :
> If you have a Java background, you might find this useful:
>
> http://dirtsimple.org/2004/12/python-is-not-java.html
>
> http://dirtsimple.org/2004/12/java-is-not-python-either.html
Unfortunately, I didn't find those articles all that insightful.
The one big difference betwee
On Wednesday 29 April 2015 16:32, Cecil Westerhof wrote:
>> The convention is, if the caller messes with your private attributes
>> or variables, and their code breaks, they have nobody to blame but
>> themselves, and we are allowed to laugh at them. We're consenting
>> adults here.
>
> Coming fr
On 04/29/2015 12:16 AM, Cecil Westerhof wrote:
>> Prefix those names with a single leading underscore, which is the
>> convention for private variables.
>
> Done.
>
>> This way, if some user (maybe you! ;) has a good reason to change
>> those values in can be done, but it is quite clear that said
On 04/29/2015 10:16 AM, Grant Edwards wrote:
On 2015-04-28, Cecil Westerhof wrote:
If I remember correctly you can not hide variables of a class or make
them read-only?
I want to rewrite my moving average to python. The init is:
def __init__(self, length):
if type(length) != int:
On 2015-04-28, Cecil Westerhof wrote:
> If I remember correctly you can not hide variables of a class or make
> them read-only?
>
> I want to rewrite my moving average to python. The init is:
> def __init__(self, length):
> if type(length) != int:
> raise ParameterError, 'P
On Wed, Apr 29, 2015 at 4:25 PM, Cecil Westerhof wrote:
> Op Tuesday 28 Apr 2015 10:06 CEST schreef Chris Angelico:
>> (note that I'm avoiding the multiple-argument syntax which doesn't
>> work in Python 3;
>
> I already did this with print. Are there other statements I have to
> take care for the
Op Tuesday 28 Apr 2015 10:37 CEST schreef Steven D'Aprano:
> On Tuesday 28 April 2015 17:33, Cecil Westerhof wrote:
>
>> If I remember correctly you can not hide variables of a class or
>> make them read-only?
>
> In Python circles, the preferred terminology for class and instance
> members is "at
Op Tuesday 28 Apr 2015 10:06 CEST schreef Chris Angelico:
> In fact, it's not really your problem if someone gives you a length
> that isn't a simple integer. In the first place, they might give you
> a subclass of int, so a better check would be this:
>
> if not isinstance(length, int):
> raise V
Op Tuesday 28 Apr 2015 09:33 CEST schreef Cecil Westerhof:
> If I remember correctly you can not hide variables of a class or
> make them read-only?
>
> I want to rewrite my moving average to python. The init is:
> def __init__(self, length):
> if type(length) != int:
> raise ParameterError, 'Para
Op Tuesday 28 Apr 2015 09:56 CEST schreef Ethan Furman:
> On 04/28, Cecil Westerhof wrote:
>> If I remember correctly you can not hide variables of a class or
>> make them read-only?
>>
>> I want to rewrite my moving average to python. The init is:
>> def __init__(self, length):
>> if type(length)
Steven D'Aprano :
> The convention is, if the caller messes with your private attributes
> or variables, and their code breaks, they have nobody to blame but
> themselves, and we are allowed to laugh at them. We're consenting
> adults here.
I would take it further: as a rule, user code should not
On Tue, Apr 28, 2015 at 6:37 PM, Steven D'Aprano
wrote:
> The convention is, if the caller messes with your private attributes or
> variables, and their code breaks, they have nobody to blame but themselves,
> and we are allowed to laugh at them. We're consenting adults here.
>
> (The only excepti
On Tuesday 28 April 2015 17:33, Cecil Westerhof wrote:
> If I remember correctly you can not hide variables of a class or make
> them read-only?
In Python circles, the preferred terminology for class and instance members
is "attributes" rather than variables. "Variable" is reserved for module-
On Tue, Apr 28, 2015 at 5:33 PM, Cecil Westerhof wrote:
> If I remember correctly you can not hide variables of a class or make
> them read-only?
>
> I want to rewrite my moving average to python. The init is:
> def __init__(self, length):
> if type(length) != int:
> raise
On 04/28, Cecil Westerhof wrote:
> If I remember correctly you can not hide variables of a class or make
> them read-only?
>
> I want to rewrite my moving average to python. The init is:
> def __init__(self, length):
> if type(length) != int:
> raise ParameterError, 'Parame
If I remember correctly you can not hide variables of a class or make
them read-only?
I want to rewrite my moving average to python. The init is:
def __init__(self, length):
if type(length) != int:
raise ParameterError, 'Parameter has to be an int'
if n < 0:
18 matches
Mail list logo