[triangle-zpug] static list in python
josh_johnson at unc.edu
Fri Mar 14 18:05:08 UTC 2008
I agree, but there is the style guide and "convention" which I have a
hard time ignoring. I know the language is flexible and programmers are
free to do what works best for them, but conventions, if their sane and
logical language-wise, are very good things. And most of them aren't
really apparent to people who haven't sought them out.
I think your example might be a bit flawed, from what I understand there
are specific consequences to using underscores in names (I'm looking at
the style guide... I don't know from first hand experience).
But I know what you mean. Maybe a better example would be the convention
that "constants" are named in upper case? It's definitely an idiom
(python doesn't have constants in the C sense)... but then again, even
though variable naming is a matter of preference, there is a (weekly)
Maybe "definitive" wasn't such a good word? :) I think I meant it in the
sense of "complete" as opposed to "canonical" ...."well thought out"
instead of "final"...
Philip Semanchuk wrote:
> On Mar 14, 2008, at 12:39 PM, Josh Johnson wrote:
>> I guess a global isn't so bad, it's only really global to your
> I agree; that's the rationalization I use for using globals as
> statics. =)
>> There has to be some definitive answer.
> I don't mean to be argumentative, but I'm not sure there is. Some
> features clearly defined in other languages become a matter of idiom
> in Python. Idiom is often a matter of taste, and therefore not
> definitive. A good example is the use of _foo and __foo as rough
> analogs to "protected" and "private" in classes. Some people think it
> is a bad idea, some like it, some (like Yours Truly) don't apply it
> as consistently as they might. In that example there's no definitive
> answer despite a lot of discussion on the topic.
> Just a different perspective.
>> Joseph Mack NA3T wrote:
>>> On Fri, 14 Mar 2008, Josh Johnson wrote:
>>>> I recall two meanings for static in programming. Static can mean a
>>>> persistent value, like an internal counter in a list (I think that's
>>>> what you want),
>>>> but I've also heard the term mean "a class method that
>>>> is accessed like a library instead of an instance method".
>>> sorry, forgot about this (I guess "static" is overloaded).
>>>> I'm not sure if python supports the sort of persistent variable I
>>>> you want (anybody else know?). If not, you may have to start with
>>>> a list
>>>> and have that list be returned by your function and then
>>>> passed to it again:
>>> This doesn't seem a whole lot different to just having l being
>>> which is what I'm doing for the moment.
>>> Thanks Joe
>> triangle-zpug mailing list
>> triangle-zpug at starship.python.net
> triangle-zpug mailing list
> triangle-zpug at starship.python.net
More information about the triangle-zpug