[issue10438] list an example for calling static methods from WITHIN classes

2017-07-12 Thread R. David Murray

R. David Murray added the comment:

It is documented how to call a static method when you don't have an instance.  
So when you don't (for example, inside a static method on the same class) you 
use that form (call the method on the class name).

I realize you don't find this clear, but as Raymond says it is time to stop 
arguing about it; our rule is that the status quo wins when agreement is not 
reached for a change.

Closing.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-12 Thread Ian

Ian added the comment:

As indicated earlier, I would prefer to see clear instructions on how to call a 
class's static method from another static method within the same class.  
Currently, it's only clear how to call from outside the class.

If that's not going to happen, then I agree that this issue should be closed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-11 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Ian, the docs mostly serve to tell what a tool does.  Best practices then 
emerge from actual practices and are determined by users.

I don't see any bug here that needs to be solved and think it is time to close 
this tracker item.  It has been consuming developer clock cycles without 
addressing any real, known issue.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-11 Thread R. David Murray

R. David Murray added the comment:

I'm not sure there's a "best practice" choice between the two calling forms 
that are documented.  Although obviously when you don't have an instance you 
can't use the instance calling form.  I think it is *common* practice to use 
the instance form when you can, but I'm not sure it is either superior or 
inferior to using the class form.  It partly depends on how you have structured 
your code and why you are using static methods in the first place.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-11 Thread Ian

Ian added the comment:

I would hope that the docs would cater to people who aren't sure how the 
language works (and who want to confirm that they are using proper patterns).  
If people already know how the language works, they won't need the docs.

Whether or not you refer to Java and C++, you should state the best practices 
for both internal and external calling of static methods in Python.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-11 Thread R. David Murray

R. David Murray added the comment:

Given a choice between catering for Python programmers and catering for 
Java/C++ programmers, the Python docs obviously ought to chose to cater to 
Python programmers.  To a python programmer, calling C.f() is intuitive.

I would myself definitely *not* encourage the __class__.f() idiom.

Maybe we should just drop the reference to Java and C++ static methods.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-09 Thread Ian

Ian added the comment:

I agree that the use case is probably rare.

I agree that to someone intimately familiar with the "self-consistent rules" of 
Python, the correctness of the C.f() approach is probably obvious.

However, your documentation says:

Static methods in Python are similar to those found in Java or C++.

I feel that it's a mistake to purposefully avoid saying where that similarity 
ends.  In those languages (and in many others), fully qualified function calls 
from within the same class are redundant and border on "code smell".  We agree 
that this aspect of Python is not mentioned in the documentation, and we 
disagree on whether it should be.  For myself, even in the 7 years and 
thousands of lines of Python since I opened this issue, I still don't find it 
intuitive or obvious that a method would need to know the name of the class 
that contains it.  That doesn't make the language "wrong" in any way; it makes 
the documentation incomplete for not addressing it.  

The __class__.f() usage in Python 3 seems excellent.  If that's the preferred 
way to do it, then that might be a way to approach the documentation.  "To call 
one static method from another within the same class, as of Python 3 you may 
use __class__.f() instead of C.f().  For Python 2.x, you must still use the 
name of the class itself, C.f(), as if you were calling from outside the 
class."  (My wording is still less than ideal, but you get the idea.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I also don't think this is worth it.  The extra wording will likely cause more 
confusion that it clears up.

Also, calling a staticmethod from within a class isn't a common thing to do.  
The principal use case for Python's static methods is to attach a function to a 
class for the sole purpose of making it findable by someone using that class.

--
nosy: +rhettinger
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2013-04-14 Thread R. David Murray

R. David Murray added the comment:

After a discussion (at the Boston Python sprint, unfortunately I forget with 
who) of how difficult this could be to explain succinctly without confusing 
either java/C++ programmers on the one hand or Python programmers on the other 
hand, this, the wording in the attached patch occurred to me.  I'm not certain 
that adding the extra words is worth it, but if so this might do.

--
keywords: +patch
Added file: 
http://bugs.python.org/file29854/static_method_call_examples_10438.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2013-04-14 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2013-04-14 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Note that in Python 3 you can also do __class__.f() in a staticmethod.  Not 
sure if that is encouraged though.

--
nosy: +sbt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread Ian

New submission from Ian ifreeca...@gmail.com:

Concerning this section of the docs:
http://docs.python.org/library/functions.html#staticmethod

There is no example for calling a static method from another static method 
within the same class.

As I discovered later, it's simple: C.f() -- from inside the class or outside 
it.

A total newbie will accept this and move on... but in other programming 
languages, it's frowned upon to the class name from within the class.  For 
example, in PHP you use the self:: prefix and Java you don't need a prefix at 
all.  

So, even though I had it right the first time, it didn't SEEM right... so I 
went on a wild goose chase, for nothing.  Googling java call static method 
will get you java documentation that lists both cases, as does c++ call static 
method and php call static method.  

I feel that by adding Note: you must also use the C.f() syntax when calling 
from within the class, the documentation will be more complete.

--
assignee: d...@python
components: Documentation
messages: 121314
nosy: d...@python, ifreecarve
priority: normal
severity: normal
status: open
title: list an example for calling static methods from WITHIN classes
type: feature request

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

IMO this follows logically from Python's self-consistent rules.  I'm not 
convinced that the amount of extra verbiage required to detail this particular 
case would make the docs clearer, but you are welcome to suggest a wording for 
us to consider.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Woops, I see you did suggest a wording.  However, what you wrote is imprecise 
and confused me when I first read it (I thought you meant that self.f() didn't 
work!).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

I tend to agree with David.  Especially since calling base class methods also 
uses the explicit class name.

--
nosy: +georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

 However, what you wrote is imprecise and confused me when I first read
 it (I thought you meant that self.f() didn't work!).

Well, it doesn't work in the specific case he mentioned of calling from another 
static method :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Only because you don't *have* self.  Which is why I said imprecise and not 
incorrect :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread Ian

Ian ifreeca...@gmail.com added the comment:

Am I to understand that self.f() is a valid way to call a static method?  Can 
you see how that would run counter to intuition for someone who is familiar 
with other languages?

Given that, I would make the following (more precise) change:

 It can be called either on the class (such as C.f()) or on an instance (such 
as C().f()). 
---
 It can be called either on the class (such as C.f()) or on an instance (such 
 as C().f() or self.f()).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10438] list an example for calling static methods from WITHIN classes

2010-11-16 Thread Ian

Ian ifreeca...@gmail.com added the comment:

Disregard my previous comment; calling self.f() does not work from a static 
method.

I stand by my previous suggestion, but I'll clarify it like this:

Note: you must also use the C.f() syntax when calling from a static method 
within the C class

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com