Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.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.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'received:internal': 0.09; 'subject:characters': 0.09; 'suggest': 0.14; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'subject: \n ': 0.16; 'subject:windows': 0.16; 'wrote:': 0.18; '(but': 0.19; 'bytes': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'testing': 0.29; 'to:no real name:2**1': 0.29; '13,': 0.31; 'sep': 0.31; 'fri,': 0.33; 'subject:from': 0.34; 'received:66': 0.35; 'subject:with': 0.35; 'received:10': 0.37; 'clear': 0.37; 'confirmed': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'remove': 0.60; 'from:no real name:2**0': 0.61; 'first': 0.61; 'header:Message-Id:1': 0.63; 'to:addr:gmail.com': 0.65; 'behavior': 0.77; 'excel,': 0.84; 'pasting': 0.84; '2013,': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:subject:date:in-reply-to:references; s=mesmtp; bh= BhCi5dwesW7/o7kbbH7RJRrgKos=; b=Pm4V1+26NDkQR1KoG495TGvWeDgVcOWp HkZCD8W1FwtoS29rcfGL/W9nwKl8leDXP6IHQ332myT9QXLm1VNuXTxmfrAjEsbu vWu7jOetNEk8en2TX+qiUNSs2ONLKlsLffNn5o1aGwAF6lpR/4e4ZlPX4jRthuk2 cFOYYxakEKI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=smtpout; bh=BhCi5dwesW7/o7kbbH7RJRrgKos=; b=tzHGi Z6xm6ywwUhTZ9WygjXudMptaDAlhxWI9OKopnPrE/S2QeQFNoO86ApgHkiO29MAY Gw5Ll92/yFJnqFwEoKVehUUkolw7Riu+kFFeio/9QOcggjqlwwQ+GLfd5xUHHWPi S0CE4QlY2vjanH0+i/xy8IPJbBWFTW35P10pK4= X-Sasl-Enc: lmcYh0OKWROYHRHYFj6JQKZ1uSglfl3xYtFIqHUKdHFx 1379531978 From: random832@fastmail.us To: stephen.boulet@gmail.com, python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-d310b333 Subject: Re: Stripping characters from windows clipboard with win32clipboard from excel Date: Wed, 18 Sep 2013 15:19:38 -0400 In-Reply-To: <1379088569.32542.21628745.0F1856DA@webmail.messagingengine.com> References: <13c19665-6dc9-49fe-88c8-52c643892eba@googlegroups.com> <74479771-2726-4a34-8fd6-531d64c5b7a5@googlegroups.com> <3PKdndBR7KeRF6_PnZ2dnUVZ_u6dnZ2d@westnet.com.au> <12ce40fd-bb6e-4249-a38d-7521c27a2825@googlegroups.com> <1379088569.32542.21628745.0F1856DA@webmail.messagingengine.com> 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: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379531986 news.xs4all.nl 15930 [2001:888:2000:d::a6]:47009 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54394 On Fri, Sep 13, 2013, at 12:09, random832@fastmail.us wrote: > Anyway, to match behavior found in other applications when pasting from > the clipboard, I would suggest using: > > if s.contains('\0'): s = s[:s.index('\0')] > > Which will also remove non-null bytes after the first null (but if the > clipboard contains these, it won't be pasted into e.g. notepad). I did some testing and confirmed you MUST do this - if you copy multiple things from Excel, it may reuse this buffer and not clear the end of it.