On 06/27/2016 09:31 PM, Zachary Ware wrote:
On Mon, Jun 27, 2016 at 7:32 PM, Chris Angelico wrote:
If you're primarily worried about classes and functions, here's a neat
trick you can use:
__all__ = []
def all(thing):
__all__.append(thing.__name__)
return thing
Barry
On Mon, Jun 27, 2016 at 7:32 PM, Chris Angelico wrote:
> If you're primarily worried about classes and functions, here's a neat
> trick you can use:
>
> __all__ = []
> def all(thing):
> __all__.append(thing.__name__)
> return thing
Barry Warsaw has written
On Tue, 28 Jun 2016 12:46 pm, Terry Reedy wrote:
> On 6/27/2016 6:29 PM, Pavel S wrote:
>
>> Frankly, do you always unit-test if __all__ works?
>
> One should. CPython's test suite includes test___all__. I believe it
> imports every stdlib module, looks for __al
On 6/27/2016 6:29 PM, Pavel S wrote:
Frankly, do you always unit-test if __all__ works?
One should. CPython's test suite includes test___all__. I believe it
imports every stdlib module, looks for __all__, and if present, tests
that it works. It probably executes 'from mod
On Mon, Jun 27, 2016, at 20:32, Chris Angelico wrote:
> If you're primarily worried about classes and functions, here's a neat
> trick you can use:
How about just
__all__ = [list of stuff including classes and functions]
__all__ = [x if isinstance(x, str) else x.__name__
On Tue, Jun 28, 2016 at 11:55 AM, MRAB wrote:
> On 2016-06-28 01:32, Chris Angelico wrote:
> [snip]
>
>> If you're primarily worried about classes and functions, here's a neat
>> trick you can use:
>>
>> __all__ = []
>> def all(thing):
>>
On Tue, 28 Jun 2016 06:56 am, Pavel S wrote:
> Hi,
> I today uncovered subtle bug and would like to share it with you.
>
> By a mistake, I forgot to put comma into '__all__' tuple of some module.
> Notice missing comma after 'B'.
>
> # module foo.py
&g
On 2016-06-28 01:32, Chris Angelico wrote:
[snip]
If you're primarily worried about classes and functions, here's a neat
trick you can use:
__all__ = []
def all(thing):
__all__.append(thing.__name__)
return thing
Err... won't that hide the 'all' builtin?
-
On Tue, Jun 28, 2016 at 6:56 AM, Pavel S wrote:
> By a mistake, I forgot to put comma into '__all__' tuple of some module.
> Notice missing comma after 'B'.
>
> # module foo.py
> __all__ = (
> 'A',
> 'B'
> 'C'
On Mon, Jun 27, 2016, at 16:56, Pavel S wrote:
> Porposal: allow putting objects into __all__ directly, so possible
> problems will be found earlier:
Question: What happens if the object in __all__ isn't the same object
that's in the module?
--
https://mail.python.org/mailman
On Tue, Jun 28, 2016 at 8:29 AM, Pavel S wrote:
>> but what about integers or strings?
>
> Can you provide example?
Sure. I'll spare you the wall of text that is os.__all__, but here's the types:
>>> import os
>>> {type(getattr(os, x)).__name__ for x in
> but what about integers or strings?
Can you provide example?
---
No matter if __all__ uses names or objects, I think it should be validated not
only when importing '*', but always.
Frankly, do you always unit-test if __all__ works?
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, Jun 28, 2016 at 6:56 AM, Pavel S wrote:
> Porposal: allow putting objects into __all__ directly, so possible problems
> will be found earlier:
>
> # module foo.py
> class A: pass
> class B: pass
> class C: pass
>
> __all__ = (A, B, C)
>
> Note: this curr
Hi,
I today uncovered subtle bug and would like to share it with you.
By a mistake, I forgot to put comma into '__all__' tuple of some module. Notice
missing comma after 'B'.
# module foo.py
__all__ = (
'A',
'B'
'C',
)
class A: pass
Emile van Sebille wrote:
On 5/11/2012 9:41 AM Ethan Furman said...
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
I would, even if only to alert any future maintainer of the
On 5/11/2012 9:41 AM Ethan Furman said...
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
I would, even if only to alert any future maintainer of the internal vs
exposed nature of
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
, that was the clue I needed. Had to do some thinking since
dbf is back to a single module, and no longer a package... here's what I
came up with:
-
class fake_module(object):
def __init__(self, name, *args):
self.name
than Furman wrote:
>
>> Greetings!
>>
>> Does anyone know/recall the original purpose of __all__?
>
> To customise the names available for `from ... import *`:
>
> http://docs.python.org/whatsnew/2.1.html#other-changes-and-fixes
>
>
>> I had thought it was
Ethan Furman wrote:
> Greetings!
>
> Does anyone know/recall the original purpose of __all__?
To customise the names available for `from ... import *`:
http://docs.python.org/whatsnew/2.1.html#other-changes-and-fixes
> I had thought it was primarily to specify what would be i
Greetings!
Does anyone know/recall the original purpose of __all__?
I had thought it was primarily to specify what would be imported when
`from ... import *` was executed, such as for tk; today, it seems it is
also used to specify the API for the module, and so the help() subsystem
will
Thomas Rachel wrote:
> class AllList(list):
> """list which can be called in order to be used as a
> __all__-adding
> decorator"""
Wow, this is a great idea.
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path
On 07/29/2011 08:37 AM, Thomas Rachel wrote:
Am 28.07.2011 20:01 schrieb Ian Kelly:
The advantage of Thomas's decorator here is that it lets you place the
denotation of whether a function is exported alongside its definition,
whereas simply declaring the __all__ list forces you to sep
Thomas,
A ha! Now I feel all warm and fuzzy inside. It's nice to start the day with
learning something new.
To be honest, the initial problem was that I didn't understand the meaning
of '__all__', again probably from not working in the large with python.
After posting, I wen
Am 28.07.2011 20:01 schrieb Ian Kelly:
The advantage of Thomas's decorator here is that it lets you place the
denotation of whether a function is exported alongside its definition,
whereas simply declaring the __all__ list forces you to separate them.
It also avoids the problem of pos
Thomas Rachel wrote:
Why not? But you could even do
class AllList(list):
"""list which can be called in order to be used as a __all__-adding
decorator"""
def __call__(self, obj):
"""for decorators"""
sel
ace the
denotation of whether a function is exported alongside its definition,
whereas simply declaring the __all__ list forces you to separate them.
It also avoids the problem of possibly mistyping the function's name
in the list.
--
http://mail.python.org/mailman/listinfo/python-list
t decorators solved, such that they became
an additional tool in the their kit bag?
On 28 July 2011 14:00, Karim wrote:
> On 07/28/2011 02:29 PM, Thomas Rachel wrote:
>
>> __all__ = AllList()
>>
>
> Hello Thomas,
>
> Very beautiful and elegant code. Having both at th
On 07/28/2011 02:29 PM, Thomas Rachel wrote:
__all__ = AllList()
Hello Thomas,
Very beautiful and elegant code. Having both at the same time an
instance and a method...
With this 'small' topic, you taught me something today on property
application!
Cheers
Karim
--
http://mail.
Am 28.07.2011 13:32 schrieb Karim:
Hello,
__all__ = 'api db input output tcl'.split()
or
__all__ = """
api
db
input
output
tcl
""".split()
for lazy boy ;o). It is readable as well.
What do you think?
Why not? But you could even do
class AllList(l
Karim writes:
> Hello,
>
> __all__ = 'api db input output tcl'.split()
>
> or
>
> __all__ = """
>api
>db
>input
>output
> tcl
>"&quo
Hello,
__all__ = 'api db input output tcl'.split()
or
__all__ = """
api
db
input
output
tcl
""".split()
for lazy boy ;o). It is readable as well.
>
>
> Andy> I do not know why but getsize2 is not kept priviate?
>
> That's not what __all__ is used for. Try this:
>
> from mm import *
>
> The only name added to your namespace will be getsize1.
>
> Skip
Okay, got it. Thx.
--
http://mail.python.org/mailman/listinfo/python-list
Andy> This a mm.py module:
Andy> _all__=('getsize1',)
Andy> size=85
Andy> def getsize1():
Andy> return size
Andy> def getsize2():
Andy> return 2*size
Andy> I do not know why but getsize2 is not kept priviate?
T
This a mm.py module:
_all__=('getsize1',)
size=85
def getsize1():
return size
def getsize2():
return 2*size
I do not know why but getsize2 is not kept priviate?
$ python
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credi
35 matches
Mail list logo