Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.112 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'closed,': 0.16; 'descriptor.': 0.16; 'drastic': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pythonic': 0.16; 'roy': 0.16; 'singleton': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'external': 0.29; 'am,': 0.29; 'besides': 0.30; 'message-id:@mail.gmail.com': 0.30; 'bunch': 0.31; 'layer': 0.31; 'file': 0.32; 'fri,': 0.33; "i'd": 0.34; 'common': 0.35; 'created': 0.35; 'beyond': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'there': 0.35; '14,': 0.36; 'instances': 0.36; 'turn': 0.37; 'two': 0.37; 'being': 0.38; 'tell': 0.60; 'effective': 0.61; 'between': 0.67; 'smith': 0.68; 'article': 0.77; 'ethan': 0.84; 'facility.': 0.84; 'furman': 0.84; 'presumably': 0.84; 'to:none': 0.92; 'differences': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=+6+AgudM1SiIzU/xLdxWm4N833D3dxVn3pKMtsGnViY=; b=KHdvUtrYQRIuek8UuddTIS6rP9+/S9uKEnkFaOGQxNaw1eZkh8v8fX/Cc82FUpBpco 00O3X8LG0H6Geogdq/+U2KW1PHJjHBbRrk1NUtmKpfxBp1F5ytXKFZJuiy9iWw40yM73 slgiWyzcFXfyWtiz+x35YiXq74bvwscLyK2hvVjuoYG4DJRIIi8BxpjMvCayjnBDRRoI 2nnOW4NKD0By9Hdbz/g6dasySETT+NTKi19KFANFP0lKNWTncNtTTcdfMjDLR5f1+BcU R0tYZOSA9/lkwGySWo0gMFGXsBfP95ZeRO1f4Xm2QdkVUi/SWSaoZ/J8UVkM71m5+osl jJ6A== MIME-Version: 1.0 X-Received: by 10.68.98.3 with SMTP id ee3mr3854992pbb.31.1392321006383; Thu, 13 Feb 2014 11:50:06 -0800 (PST) In-Reply-To: References: Date: Fri, 14 Feb 2014 06:50:06 +1100 Subject: Re: singleton ... again From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392321009 news.xs4all.nl 2872 [2001:888:2000:d::a6]:56165 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66221 On Fri, Feb 14, 2014 at 6:03 AM, Roy Smith wrote: > In article , > Ethan Furman wrote: >> >> You mean use the Borg pattern instead of the Singleton pattern? As far as I >> can tell they are two shades of the same >> thing. Are there any drastic differences between the two? Besides one >> having many instances that share one __dict__ >> and the other just having one instance and one __dict__? > > I envision SerialPort being a thin layer on top of a bunch of > OS-specific system calls to give them a pythonic interface. Things like > is_shutdown() and set_bit_rate() presumably turn into ioctls. No need > to have any state at all beyond a file descriptor. I'd go a bit further. The SerialPort instance would have its own effective state: the file descriptor. Two of them can be created and one of them closed, and the fd for that one would be closed while the other stays open. It's then two objects dealing with a common external facility. ChrisA