Re: [python-committers] Welcome the 3.8 and 3.9 Release Manager - Łukasz Langa!

2018-01-27 Thread Eric Snow
On Sat, Jan 27, 2018 at 2:02 PM, Barry Warsaw wrote: > please welcome your next release manager… > > Łukasz Langa! Congrats, Łukasz! (or condolences? ) -eric -- https://mail.python.org/mailman/listinfo/python-list

Re: Difference between 'imp' and 'importlib'

2012-04-20 Thread Eric Snow
On Fri, Apr 20, 2012 at 1:30 AM, Frank Millman wrote: > Hi all > > I need the ability to execute a function by parsing a string containing the > full path to the function. The string is multi-dotted. The last element is > the function name, the second-last is the name of the module containing the

Re: Using non-dict namespaces in functions

2012-03-17 Thread Eric Snow
On Sat, Mar 17, 2012 at 4:18 AM, Steven D'Aprano wrote: > Note that it is important for my purposes that MockChainMap does not > inherit from dict. Care to elaborate? > Now I try to create a function that uses a MockChainMap instead of a dict > for its globals: > > function = type(lambda: None)

(Rebooting) Python Usage Statistics

2012-02-13 Thread Eric Snow
The original topic got side-tracked pretty quickly (surprise, surprise). However, I think the question is valuable enough that it's worth broaching again. Notably, the first time around I did get a meaningful response (thanks Stefan!). If you do feel like diverging from the topic of gathering us

Re: Python usage numbers

2012-02-11 Thread Eric Snow
On Sat, Feb 11, 2012 at 6:28 PM, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > wrote: >> However, in at >> least one current thread (on python-ideas) and at a variety of times >> in the past, _some_ people have found Unicode in Python 3 to m

Re: Python usage numbers

2012-02-11 Thread Eric Snow
On Sat, Feb 11, 2012 at 2:51 PM, Andrew Berg wrote: > On 2/11/2012 3:02 PM, Eric Snow wrote: >> I'm thinking about this partly because of the discussion on >> python-ideas about the perceived challenges of Unicode in Python 3. > >> For instance, if frameworks

Python usage numbers

2012-02-11 Thread Eric Snow
Does anyone have (or know of) accurate totals and percentages on how Python is used? I'm particularly interested in the following groupings: - new development vs. stable code-bases - categories (web, scripts, "big data", computation, etc.) - "bare metal" vs. on top of some framework - regional us

speaking at PyCon

2012-01-28 Thread Eric Snow
This is my first year speaking at PyCon, so I solicited speaking/preparation advice from a bunch of folks, particularly focusing on the PyCon speaking experience. I've compiled the results and put them online: http://ref.rtfd.org/speakers This is still rough, and feedback is welcome, as is more

Re: Getting involved

2012-01-07 Thread Eric Snow
On Sat, Jan 7, 2012 at 1:39 PM, Antoine Pitrou wrote: > > Hello, > > Sophie Sperner gmail.com> writes: >> >> Let me ask here please. I'm a first-year PhD student in Ireland. My >> background is in mathematics, though I'm going to stream my career >> into programming with Python, Java and C++ lang

Re: Python powering giant screen in Times Square

2011-12-31 Thread Eric Snow
On Sat, Dec 31, 2011 at 12:05 PM, Jason Ford wrote: > Verizon has a giant HD screen in Times Square today showing a live > feed of social media activity – and it's built entirely in Python. > > Our app, FeedMagnet, aggregates and curates social content and is > powering the screen. It has a Django

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Eric Snow
On Wed, Dec 14, 2011 at 12:14 PM, Lie Ryan wrote: > On 12/15/2011 03:56 AM, Eric Snow wrote: >> >> On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow >>  wrote: >> >> If you want to be more dynamic about it you can do it, but it involves >> black magic.  Chan

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Eric Snow
On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow wrote: > On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote: >> I'm using Python 3.2.2, and the following program gives me an error >> that I don't understand: >> >> class Foo: >>  pass >&g

Re: AttributeError in "with" statement (3.2.2)

2011-12-13 Thread Eric Snow
On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote: > I'm using Python 3.2.2, and the following program gives me an error > that I don't understand: > > class Foo: >  pass > > foo = Foo() > foo.name = "Steve" > > def add_goodbye_function(obj): >  def goodbye(): >    print("goodbye " + obj.name)

Re: resolving module name conflicts.

2011-11-11 Thread Eric Snow
On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow wrote: > The problem is that the empty string is still added to the from of > sys.path.  I'm going to have to find out more about that one. Okay, don't know how I missed it but the docs for sys.path[1] spell it out: "As ini

Re: resolving module name conflicts.

2011-11-11 Thread Eric Snow
On Fri, Nov 11, 2011 at 1:27 PM, Gelonida N wrote: > > > Hi, > > I got some code. > - This code contains a package named tests > - there are at least 100 references in different python files >        importing from above mentioned tests package. > - the code also imports pytz at one place > > I ge

Re: Python advanced course (preferably in NA)

2011-11-03 Thread Eric Snow
On Thu, Nov 3, 2011 at 12:13 PM, Behnam wrote: > Anybody is aware of any advanced course in Python preferably in north > america? > > I've been partly coding in Python for couple of years now and have > used PyQt. What I'd like to learn more is a kind of advance OOP in > python. Any idea? While I

Re: "IX" as shorthand for "Interface"

2011-10-08 Thread Eric Snow
On Sat, Oct 8, 2011 at 10:31 PM, Chris Rebert wrote: > On Sat, Oct 8, 2011 at 9:21 PM, Eric Snow wrote: >> I'm writing a bunch of classes that have "Interface" in the name and >> find that the length of the subsequent names is starting to get in the >> way

"IX" as shorthand for "Interface"

2011-10-08 Thread Eric Snow
I'm writing a bunch of classes that have "Interface" in the name and find that the length of the subsequent names is starting to get in the way of readability (I don't really care about saving keystrokes). Is "IX" conventional enough to use in place of "Interface" in a class name? Thanks! -eric

Re: lower-case names for builtin types

2011-10-01 Thread Eric Snow
Thanks, Steven. On Sat, Oct 1, 2011 at 10:11 PM, Steven D'Aprano wrote: > Eric Snow wrote: > >> Anyone know the story behind the lower-case names for the >> non-exception built-in types (like list and type)?  I am guessing that >> they were originally factory

lower-case names for builtin types

2011-10-01 Thread Eric Snow
Anyone know the story behind the lower-case names for the non-exception built-in types (like list and type)? I am guessing that they were originally factory functions that, at some point, graduated to full types; and the names were kept lower-case for backward compatibility. However, if we were t

Re: Unittest testing assert*() calls rather than methods?

2011-09-28 Thread Eric Snow
On Wed, Sep 28, 2011 at 6:50 PM, Devin Jeanpierre wrote: >> I used to ask the same question, but then I decided that if I wanted each >> data point to get its own tick, I should bite the bullet and write an >> individual test for each. > > Nearly the entire re module test suite is a list of tuples

Re: syntactic sugar for def?

2011-09-28 Thread Eric Snow
On Wed, Sep 28, 2011 at 3:26 PM, Ethan Furman wrote: > I remember that 'class' is sugar for type(). > > I don't remember if 'def' is sugar for something besides lambda. This is something I have thought about a lot since PyCon this year. I apologize in advance. Since 3.0, class statements

Re: static statements and thread safety

2011-09-22 Thread Eric Snow
On Thu, Sep 22, 2011 at 2:06 AM, Chris Angelico wrote: > On Thu, Sep 22, 2011 at 5:45 PM, Eric Snow > wrote: >> I would expect that static variables would work pretty much the same >> way as default arguments > > Could you just abuse default arguments to accomplish th

static statements and thread safety

2011-09-22 Thread Eric Snow
A recent thread on the python-ideas list got me thinking about the possibility of a static statement (akin to global and nonlocal). I am wondering if an implementation would have to address thread safety concerns. I would expect that static variables would work pretty much the same way as default

Re: About MAKE_FUNCTION opcode in Python 3

2011-09-20 Thread Eric Snow
On Tue, Sep 20, 2011 at 1:59 PM, Arnaud Delobelle wrote: > Since Python 3.0 we have keyword only arguments in functions (see PEP > 3102).  Looking at the documentation for the dis module (where opcodes > are documented), I see the following for MAKE_FUNCTION [1] > > """ > MAKE_FUNCTION(argc) > Pus

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-12 Thread Eric Snow
On Mon, Sep 12, 2011 at 1:49 AM, Alec Taylor wrote: > Good evening, > > I have converted ODT to HTML using LibreOffice Writer, because I want > to convert from HTML to Creole using python-creole. Unfortunately I > get this error: "File "Convert to Creole.py", line 17 > SyntaxError: Non-ASCII chara

Re: DRY and class variables

2011-09-08 Thread Eric Snow
On Thu, Sep 8, 2011 at 3:55 AM, egbert wrote: > My classes correspond to sql tables. > In these classes I want to have several class variables > that refer to data that are common to all instances. > > The assignment statements for the class variables are the same > in all classes, except that of

Re: Looking for open-source Python projects to help out with

2011-09-07 Thread Eric Snow
On Tue, Sep 6, 2011 at 8:19 PM, Littlefield, Tyler wrote: > Hello: > I've got a bit of time on my hands, so I'm curious what sorts of projects > there are that people needs help with. I'd like to choose something that > doesn't have a ton of red tape, but is stable, which is why I ask here > inste

Re: PEP 20 - Silly Question?

2011-09-06 Thread Eric Snow
On Tue, Sep 6, 2011 at 10:17 AM, Joseph Armbruster wrote: > I have used Python for some time and ran a windows build-bot for a bit. >  This morning, I told a fellow developer "There should be only one obvious > way to do it." and then I proceeded to forward him to the Zen of Python and > sent him

Re: Why do class methods always need 'self' as the first parameter?

2011-08-31 Thread Eric Snow
On Wed, Aug 31, 2011 at 7:47 PM, Chris Angelico wrote: > On Thu, Sep 1, 2011 at 10:48 AM, Steven D'Aprano > wrote: >> Python classes have a lot of dynamism made possible by the fact that methods >> are just wrappers around functions with an explicitly declared "self". That >> dynamism is rarely u

Re: 'super' object has no attribute '__setitem__'

2011-08-18 Thread Eric Snow
On Thu, Aug 18, 2011 at 7:44 PM, luvspython wrote: > I'm using Python 2.7 and the code below fails at the 'super' statement > in the __setitem__ function in the HistoryKeeper class.  The error is: >   'super' object has no attribute '_setitem__' > > Can anyone please tell me why and how to fix it?

code object differences between 2.7 and 3.3a

2011-08-10 Thread Eric Snow
Specifically, I am wondering why there is a difference for co_names. Here is a function that exercises the different code object pieces[1]: def g(y=5): a = 7 def f(x, w=y, z=4, *args, **kwargs): b = a c = global_x return f f1 = g() Here are the results for 2.7: >>> for nam

Re: how to dynamically generate __name__ for an object?

2011-08-10 Thread Eric Snow
On Wed, Aug 10, 2011 at 8:48 AM, Fuzzyman wrote: > On Aug 7, 4:06 am, Eric Snow wrote: >> Thought I knew how to provide a dynamic __name__ on instances of a >> class.  My first try was to use a non-data descriptor: >> >> # module base.py >> >> class _Name

Re: __set__ method is not called for class attribute access

2011-08-10 Thread Eric Snow
On Wed, Aug 10, 2011 at 8:33 AM, Fuzzyman wrote: > On Aug 5, 12:29 pm, Ryan wrote: >> In the context of descriptors, the __set__ method is not called for >> class attribute access. __set__ is only >> called to set the attribute on an instance instance of the owner class >> to a new value, value.

Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 1:05 PM, Steven D'Aprano wrote: > Ethan Furman wrote: > >> So if property docstrings are so hard to get to, what's the point in >> having them? > > Hard to get, not impossible. But I have no idea really -- they don't seem > very useful to me. They do show up in help(), but

Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 6:37 AM, Nick wrote: > Is it possible to put a doc string on a class attribute? Something > like this You can put a docstring on a property (which is a function): class Test(object): @property def fred(self): "attribute" return 10 Python syntax sup

Re: how to dynamically generate __name__ for an object?

2011-08-07 Thread Eric Snow
On Sat, Aug 6, 2011 at 10:47 PM, Steven D'Aprano wrote: > Eric Snow wrote: > >> Thought I knew how to provide a dynamic __name__ on instances of a >> class.  My first try was to use a non-data descriptor: > > Perhaps you should explain what you are trying to do. If

how to dynamically generate __name__ for an object?

2011-08-06 Thread Eric Snow
Thought I knew how to provide a dynamic __name__ on instances of a class. My first try was to use a non-data descriptor: # module base.py class _NameProxy(object): def __init__(self, oldname): self.oldname = oldname def __get__(self, obj, cls): if obj is None:

Re: Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
On Fri, Aug 5, 2011 at 11:29 AM, Steven D'Aprano wrote: > Eric Snow wrote: > >> On Fri, Aug 5, 2011 at 8:36 AM, Steven D'Aprano >> wrote: >>> Eric Snow wrote: >>> >>>> In Python, three types of objects have special syntax and mechanics &

Re: Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
On Fri, Aug 5, 2011 at 8:36 AM, Steven D'Aprano wrote: > Eric Snow wrote: > >> In Python, three types of objects have special syntax and mechanics >> for their instantiation, during which a code object is generated: >> modules, classes, and functions. > >

Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
In Python, three types of objects have special syntax and mechanics for their instantiation, during which a code object is generated: modules, classes, and functions. Each has its own role to play and the differences between them mostly reflect that. Here are some observations (based on default b

Re: Community Involvement

2011-08-04 Thread Eric Snow
On Wed, Aug 3, 2011 at 9:14 PM, Steve Holden wrote: > [Ccs appreciated] > After some three years labor I (@holdenweb) at last find myself approaching > the completion of the Python Certificate Series with O'Reilly School of > Technology (@OReillySchool). > At OSCON last week the team fell to talki

finding the object corresponding to a stack frame

2011-08-04 Thread Eric Snow
For any given stack frame, the corresponding code object is derived most immediately from either a module [definition], a class definition, or function definition. I want to be able to determine the specific module, class, or function object for any arbitrary code/frame object. For modules it is

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Eric Snow
On Thu, Jul 14, 2011 at 11:28 PM, Steven D'Aprano wrote: > Hello folks, > > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: > > mean([1, 2,

Re: Code hosting services

2011-07-13 Thread Eric Snow
On Wed, Jul 13, 2011 at 4:23 AM, Adam Tauno Williams wrote: > On Wed, 2011-07-13 at 01:54 -0500, Andrew Berg wrote: >> What can you guys recommend? > > SourceForge;  it is a comprehensive platform [in addition to being an > Open Source platform: Allura].  It is a much improved platform over > seve

Re: Python Contribution

2011-07-13 Thread Eric Snow
On Wed, Jul 13, 2011 at 4:31 AM, Shankar Raman wrote: >  Hello everyone, >      My name is Shankarraman and I have been working with Python for past 5 > months.I find it really interesting and cool and would like to know > different ways I can contribute to it. Though I went through the bug lists,

Re: What makes functions special?

2011-07-09 Thread Eric Snow
On Sat, Jul 9, 2011 at 7:34 PM, Steven D'Aprano wrote: > Eric Snow wrote: > >> Mostly I am just >> trying to put together more pieces of the Python puzzle.  In this case >> I was trying to find out if the optimized execution of code objects >> for functions i

Re: What makes functions special?

2011-07-09 Thread Eric Snow
On Sat, Jul 9, 2011 at 6:38 PM, Ben Finney wrote: > Eric Snow writes: > >> On Sat, Jul 9, 2011 at 4:41 PM, Ben Finney >> wrote: >> > Eric Snow writes: >> >> No other objects have code objects. No other objects in Python have >> >> this spe

Re: What makes functions special?

2011-07-09 Thread Eric Snow
On Sat, Jul 9, 2011 at 6:21 PM, Terry Reedy wrote: > On 7/9/2011 2:28 PM, Eric Snow wrote: >> >> A tracker issue [1] recently got me thinking about what makes >> functions special.  The discussion there was regarding the distinction >> between compile time (generatio

Re: What makes functions special?

2011-07-09 Thread Eric Snow
On Sat, Jul 9, 2011 at 4:41 PM, Ben Finney wrote: > Eric Snow writes: > >> A tracker issue [1] recently got me thinking about what makes >> functions special. > > As you describe, functions are special for your scenario because a > function definition needs to resu

What makes functions special?

2011-07-09 Thread Eric Snow
A tracker issue [1] recently got me thinking about what makes functions special. The discussion there was regarding the distinction between compile time (generation of .pyc files for modules and execution of code blocks), [function] definition time, and [function] execution time. Definition time

Re: imp.find_module don't found my module but standard import statement can import this module… why ?

2011-07-05 Thread Eric Snow
On Tue, Jul 5, 2011 at 1:36 AM, Stéphane Klein wrote: > Hi, > > I would like import some module dynamically. > To import a module dynamically, you can use the built-in __import__ function: module = __import__("js") Even better, use importlib's import_module, which is available in 2.7/3.2. A

Re: Using __abstractmethod__ with non-methods

2011-06-23 Thread Eric Snow
Just a follow up on the longer post I made [1]: Is it bad to set __abstractmethod__ on non-functions in order to trigger the ABC abstractness checks? If not, are __isabstractmethod__ on objects and __abstractmethods__ on classes misleading names? Like I said before, I don't mean to imply that Py

performance critical Python features

2011-06-23 Thread Eric Snow
I was thinking about the different features of Python that have an impact on performance. Here are the obvious ones I could think of: Features most impactful on performance: - function calls - loops Features least impactful on performance: - imports - function definitions - class definitions

Re: break in a module

2011-06-16 Thread Eric Snow
On Thu, Jun 16, 2011 at 11:56 PM, Chris Angelico wrote: > On Fri, Jun 17, 2011 at 3:20 PM, Erik Max Francis wrote: >> Yes, which could be rephrased as the fact that `break` and `continue` are >> restricted to looping control structures, so reusing `break` in this context >> would be a bad idea. >

Re: break in a module

2011-06-16 Thread Eric Snow
On Thu, Jun 16, 2011 at 5:29 PM, Erik Max Francis wrote: > Chris Angelico wrote: >> >> On Fri, Jun 17, 2011 at 8:07 AM, Erik Max Francis wrote: >>> >>> It's quite consistent on which control structures you can break out of -- >>> it's the looping ones. >> >> Plus functions. > > No: > def f()

Using __abstractmethod__ with non-methods

2011-06-16 Thread Eric Snow
This is a long post, so to sum up: Is it bad to set __abstractmethod__ on non-functions in order to trigger the ABC abstractness checks? If not, are __isabstractmethod__ on objects and __abstractmethods__ on classes misleading names? I don't mean to imply that Python has it wrong. On the cont

Re: os.path and Path

2011-06-16 Thread Eric Snow
On Thu, Jun 16, 2011 at 10:41 AM, Steven D'Aprano wrote: > > On a Linux or OS X box, you could have a file e inside a directory c:d > inside b inside a. It can't be treated as platform independent, because > c:d is not a legal path component under classic Mac or Windows. > > On a classic Mac (does

Re: break in a module

2011-06-14 Thread Eric Snow
On Tue, Jun 14, 2011 at 7:33 PM, Ben Finney wrote: > > I have never seen code that needs this, and can't imagine why the above > would be a good design for a module. Is there real code online somewhere > that we can see which serves as a real example for your use case? > Unfortunately not. Most

Re: break in a module

2011-06-14 Thread Eric Snow
On Tue, Jun 14, 2011 at 5:51 PM, Erik Max Francis wrote: > Ethan Furman wrote: >> >> To me, too -- too bad it doesn't work: >> >> c:\temp>\python32\python early_abort.py >>  File "early_abort.py", line 7 >>    return >>       ^ >> SyntaxError: 'return' outside function > > Nor should it.  There's

break in a module

2011-06-14 Thread Eric Snow
When you want to stop execution of a statement body early, for flow control, there is a variety ways you can go, depending on the context. Loops have break and continue. Functions have return. Generators have yield (which temporarily stops execution). Exceptions sort of work for everything, but

Re: how to inherit docstrings?

2011-06-10 Thread Eric Snow
On Thu, Jun 9, 2011 at 12:22 AM, Eric Snow wrote: > Sometimes when using class inheritance, I want the overriding methods > of the subclass to get the docstring of the matching method in the > base class.  You can do this with decorators (after the class > definition), with class dec

Re: how to inherit docstrings?

2011-06-10 Thread Eric Snow
On Fri, Jun 10, 2011 at 11:26 AM, Ian Kelly wrote: > Everybody always focuses so much on properties and forgets that you > can also just write your own descriptors. > I'm so glad that you pointed this out. I totally forgot that properties simply returned themselves if not called on the instance.

Re: how to inherit docstrings?

2011-06-10 Thread Eric Snow
FYI, I started this topic up on python-ideas, as it seemed valid enough from the responses I've gotten here [1]. -eric [1] http://mail.python.org/pipermail/python-ideas/2011-June/010473.html -- http://mail.python.org/mailman/listinfo/python-list

Re: how to inherit docstrings?

2011-06-10 Thread Eric Snow
On Fri, Jun 10, 2011 at 10:47 AM, Steven D'Aprano wrote: > Here's some Python 3 code that uses a factory function as a metaclass to > inherit docstrings. Give the class a docstring of an empty string, and it > will be inherited from the first superclass found with a non-empty > docstring. > > Yea

Re: how to inherit docstrings?

2011-06-10 Thread Eric Snow
On Fri, Jun 10, 2011 at 5:05 AM, Tim Chase wrote: > On 06/09/2011 01:22 AM, Eric Snow wrote: >> >> Sometimes when using class inheritance, I want the overriding methods >> of the subclass to get the docstring of the matching method in the >> base class.  You can do this

Re: how to inherit docstrings?

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 9:59 PM, Terry Reedy wrote: > On 6/9/2011 9:12 PM, Carl Banks wrote: > >> Presumably, the reason you are overriding a method in a subclass is to >> change its behavior; I'd expect an inherited docstring to be inaccurate more >> often than not.  So I'd be -1 on automatically

Re: how to inherit docstrings?

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 7:12 PM, Carl Banks wrote: > On Thursday, June 9, 2011 3:27:36 PM UTC-7, Gregory Ewing wrote: >> IMO, it shouldn't be necessary to explicitly copy docstrings >> around like this in the first place. Either it should happen >> automatically, or help() should be smart enough to

Re: how to inherit docstrings?

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 5:23 PM, Ben Finney wrote: > Gregory Ewing writes: > >> IMO, it shouldn't be necessary to explicitly copy docstrings around >> like this in the first place. Either it should happen automatically, >> or help() should be smart enough to look up the inheritance hierarchy >> wh

__doc__ immutable for classes (was: Re: how to inherit docstrings?)

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 10:10 AM, Ethan Furman wrote: > Eric Snow wrote: >> >> p.s. Am I missing something or can you really not change the docstring >> of a class?  I was thinking about the idea of inheriting class >

Re: how to inherit docstrings?

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 4:27 PM, Gregory Ewing wrote: > IMO, it shouldn't be necessary to explicitly copy docstrings > around like this in the first place. Either it should happen > automatically, or help() should be smart enough to look up > the inheritance hierarchy when given a method that doesn

Re: how to inherit docstrings?

2011-06-09 Thread Eric Snow
On Thu, Jun 9, 2011 at 12:37 AM, Ben Finney wrote: > Eric Snow writes: > >> p.s. Am I missing something or can you really not change the docstring >> of a class? I was thinking about the idea of inheriting class >> docstrings too. > > The docstring of an object

how to inherit docstrings?

2011-06-08 Thread Eric Snow
Sometimes when using class inheritance, I want the overriding methods of the subclass to get the docstring of the matching method in the base class. You can do this with decorators (after the class definition), with class decorators, and with metaclasses [1]. However, I was hoping for a way to do

Re: new string formatting with local variables

2011-06-06 Thread Eric Snow
On Mon, Jun 6, 2011 at 10:15 AM, Jabba Laci wrote: > Hi, > > I'd like to simplify the following string formatting: > > solo = 'Han Solo' > jabba = 'Jabba the Hutt' > print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba) > # Han Solo was captured by Jabba the Hutt > > What I don't l

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 6:30 PM, Ethan Furman wrote: > Eric Snow wrote: > >> Guido indicates earlier in the thread that NotImplemented is used so that >> you know that it came from the function that you directly called, and not >> from another call inside that function.

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 4:18 PM, Ethan Furman wrote: > Eric Snow wrote: > >> Looking at the ABC code [1], I noticed that Mapping's __eq__ method can >> return NotImplemented. This got me curious as to why you would return >> NotImplemented and not raise a TypeE

Re: returning NotImplemented

2011-05-31 Thread Eric Snow
On Tue, May 31, 2011 at 3:46 PM, Eric Snow wrote: > Looking at the ABC code [1], I noticed that Mapping's __eq__ method can > return NotImplemented. This got me curious as to why you would return > NotImplemented and not raise a TypeError or a NotImplementedError. > >

returning NotImplemented

2011-05-31 Thread Eric Snow
Looking at the ABC code [1], I noticed that Mapping's __eq__ method can return NotImplemented. This got me curious as to why you would return NotImplemented and not raise a TypeError or a NotImplementedError. There was an issue regarding this last year [2] that indicated the reason for Mapping's

Re: Python's super() considered super!

2011-05-27 Thread Eric Snow
On Fri, May 27, 2011 at 4:37 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Fri, 27 May 2011 18:49:52 +1000, Ben Finney wrote: > > > Raymond Hettinger writes: > > > >> Hope you enjoyed the post. > > > > I certainly did. > > > > But I'm not better enlightened on why ‘super

Re: super() in class defs?

2011-05-25 Thread Eric Snow
On Wed, May 25, 2011 at 12:31 PM, Ian Kelly wrote: > On Wed, May 25, 2011 at 11:54 AM, Jess Austin > wrote: > > So I guess that when super() is called in the context of a class def > > rather than that of a method def, it doesn't have the information it > > needs. Now I'll probably just say: > >

Re: validating a class against an ABC at definition time

2011-05-20 Thread Eric Snow
On Fri, May 20, 2011 at 4:55 PM, Eric Snow wrote: > > I have revised this and made a recipe for it: > > > http://code.activestate.com/recipes/577711-validating-classes-and-objects-against-an-abstract/ > > I also added this: http://code.activestate.com/recipes/577712-add

Re: validating a class against an ABC at definition time

2011-05-20 Thread Eric Snow
On Thu, May 19, 2011 at 11:33 PM, Eric Snow wrote: > Thinking about class APIs and validating a class against an API. The abc > module provides the tools to do some of this. One thing I realized, that I > hadn't noticed before, is that the abstractness of a class is measured when

ABC validation strictly on an instance

2011-05-20 Thread Eric Snow
The current ABC implementation in Python implies that the class of a conformant instance complies with the ABC. The implication does not carry down to the compliance of the instance itself. This means that if you inherit from an ABC that has an abstract property, your subclass must have a matchin

validating a class against an ABC at definition time

2011-05-19 Thread Eric Snow
Thinking about class APIs and validating a class against an API. The abc module provides the tools to do some of this. One thing I realized, that I hadn't noticed before, is that the abstractness of a class is measured when instances of the class are created. This happens in object.__new__ (pyob

Re: Python 3 vs Python 2.7 dilemma

2011-05-17 Thread Eric Snow
On Mon, May 16, 2011 at 10:48 PM, Navkirat Singh wrote: > Hi Guys, > > I have been trying to fight this issue for sometime now. I know that a > large part of the python 3rd party software base has not been ported to > python 3 yet. I am trying to build a web-based enterprise solution for my > clie

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Eric Snow
On Fri, May 13, 2011 at 11:15 AM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list. I came up with below. In > the name of learning how to do things properly, do you experts have a > better way of doing it? > > Thanks fo

Re: list equal to subclass of list?

2011-05-12 Thread Eric Snow
On Thu, May 12, 2011 at 6:23 AM, Roy Smith wrote: > I have a vague feeling this may have been discussed a long time ago, but > I can't find the thread, so I'll bring it up again. > > I recently observed in the "checking if a list is empty" thread that a > list and a subclass of list can compare e

Re: checking if a list is empty

2011-05-11 Thread Eric Snow
All of this just boils down to Python providing an implicit bool cast in syntactic situations that expect conditional expressions, including if [1]. So "if x:" is equivalent to "if bool(x)". Perhaps that is the part that is not immediately obvious, being implicit to Python conditional syntax. Py

Re: checking if a list is empty

2011-05-06 Thread Eric Snow
On Fri, May 6, 2011 at 1:31 PM, Terry Reedy wrote: > On 5/6/2011 7:34 AM, James Mills wrote: > >> On Fri, May 6, 2011 at 4:36 PM, Jabba Laci wrote: >> >>> If I want to check if a list is empty, which is the more pythonic way? >>> >> >> [...] >> >> (2) if not li: >>> >> >> This is fine. >> > > T

Re: Composition instead of inheritance

2011-04-28 Thread Eric Snow
On Thu, Apr 28, 2011 at 11:15 AM, Ethan Furman wrote: > For anybody interested in composition instead of multiple inheritance, I > have posted this recipe on ActiveState (for python 2.6/7, not 3.x): > > > http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inheri

Re: NaN

2011-04-28 Thread Eric Snow
On Thu, Apr 28, 2011 at 11:01 AM, Chris Rebert wrote: > On Thu, Apr 28, 2011 at 9:21 AM, Eric Snow > wrote: > > There's a big discussion going on at python-dev and python-ideas about > NaN > > (not-a-number, from IEEE 754). I haven't really gotten into any > s

NaN

2011-04-28 Thread Eric Snow
There's a big discussion going on at python-dev and python-ideas about NaN (not-a-number, from IEEE 754). I haven't really gotten into any scientific computing or numeric programming so I have never knowingly dealt with NaN. However, I have read the discussions and several things are not clear:

PEP index by topic

2011-04-14 Thread Eric Snow
Reading the PEPs is a great way to get a look at how Python has developed and at some of its subtle nuances. It's a great way to compare your great new idea to what the community has seriously considered before. Most of them have information that you won't find consolidated anywhere else. Quite

Re: Nested inner classes and inheritance -> namespace problem

2011-04-13 Thread Eric Snow
On Wed, Apr 13, 2011 at 3:12 AM, Larry Hastings wrote: > > The problem: if you're currently in a nested class, you can't look up > variables in the outer "class scope". > > For example, this code fails in Python 3: > > class Outer: > class Inner: > class Worker: > pass > > class Inn

Re: python on iPad (PyPad)

2011-04-09 Thread Eric Snow
On Fri, Apr 8, 2011 at 11:13 PM, Jon Dowdall wrote: > Hi All, > > Sorry for the blatant advertising but hope some of you may be interested > to know that I've created an iPad application containing the python > interpreter and a simple execution environment. It's available in iTunes > at http://it

Re: python on iPad (PyPad)

2011-04-08 Thread Eric Snow
On Fri, Apr 8, 2011 at 11:13 PM, Jon Dowdall wrote: > Hi All, > > Sorry for the blatant advertising but hope some of you may be interested > to know that I've created an iPad application containing the python > interpreter and a simple execution environment. It's available in iTunes > at http://it

Re: TypeError: iterable argument required

2011-04-06 Thread Eric Snow
Hi, The "or" expression will return the first element that evaluates to True, or the last element if they all evaluate to False. Positive integers evaluate to True. None evaluates to False. See: http://docs.python.org/library/stdtypes.html#truth-value-testing

Re: type enforcement in _ssl.sslwrap

2010-08-11 Thread Eric Snow
On Aug 11, 5:34 am, Steven D'Aprano wrote: > On Tue, 10 Aug 2010 10:40:54 -0700, Eric Snow wrote: > > ssl.SSLSocket.__init__ makes a call to _ssl.sslwrap (in the C module). > > That in turn makes a call to PyArg_ParseTuple, which casts the first arg > &

type enforcement in _ssl.sslwrap

2010-08-10 Thread Eric Snow
ssl.SSLSocket.__init__ makes a call to _ssl.sslwrap (in the C module). That in turn makes a call to PyArg_ParseTuple, which casts the first arg of _ssl.sslwrap into a PySocketModule.Sock_Type object. My problem is that I am trying to pass in an object that implements the Socket interface, but doe

Re: doctests and decorators

2009-06-16 Thread Eric Snow
On Jun 16, 11:24 am, Michele Simionato wrote: > On Jun 16, 6:39 pm, Eric Snow wrote: > > > > > On Jun 16, 10:31 am, Christian Heimes wrote: > > > > Eric Snow schrieb: > > > > > Apparently there is a known issue with doctests, in which tests

  1   2   >