Re: Stripping sRGB profile from PNGs in python

2015-07-23 Thread Laura Creighton
To scale images, you should get Pillow, which can construct new images based on old ones for arbitrary size. see: http://pillow.readthedocs.org/en/latest/reference/Image.html Pillow is a fork of PIL. PIL isn't being maintained, Pillow is. Note that reading this is a good idea: http://united-code

Re: Stripping sRGB profile from PNGs in python

2015-07-23 Thread Emile van Sebille
On 7/23/2015 10:31 AM, Ryan Holmes wrote: We're getting this error when trying to load some of out projects images: libpng warning: iCCP: known incorrect sRGB profile The source files that we have some with incorrect sRGB profiles. We don't have control over the source files, but what we

Re: Stripping unencodable characters from a string

2015-05-08 Thread Serhiy Storchaka
On 05.05.15 21:19, Paul Moore wrote: I want to write a string to an already-open file (sys.stdout, typically). However, I *don't* want encoding errors, and the string could be arbitrary Unicode (in theory). The best way I've found is data = data.encode(file.encoding, errors='replace').dec

Re: Stripping unencodable characters from a string

2015-05-05 Thread Chris Angelico
On Wed, May 6, 2015 at 4:19 AM, Paul Moore wrote: > I want to write a string to an already-open file (sys.stdout, typically). > However, I *don't* want encoding errors, and the string could be arbitrary > Unicode (in theory). The best way I've found is > > data = data.encode(file.encoding,

Re: Stripping unencodable characters from a string

2015-05-05 Thread Marko Rauhamaa
Paul Moore : > Nor can I - that's my point. But if all I have is an open text-mode > file with the "strict" error mode, I have to incur one encode, and I > have to make sure that no characters are passed to that encode which > can't be encoded. The file-like object you are given carries some bag

Re: Stripping unencodable characters from a string

2015-05-05 Thread Jon Ribbens
On 2015-05-05, Paul Moore wrote: > I want to write a string to an already-open file (sys.stdout, > typically). However, I *don't* want encoding errors, and the string > could be arbitrary Unicode (in theory). The best way I've found is > > data = data.encode(file.encoding, errors='replace').de

Re: Stripping unencodable characters from a string

2015-05-05 Thread Paul Moore
On Tuesday, 5 May 2015 20:01:04 UTC+1, Dave Angel wrote: > On 05/05/2015 02:19 PM, Paul Moore wrote: > > You need to specify that you're using Python 3.4 (or whichever) when > starting a new thread. Sorry. 2.6, 2.7, and 3.3+. It's for use in a cross-version library. > If you're going to take c

Re: Stripping unencodable characters from a string

2015-05-05 Thread Dave Angel
On 05/05/2015 02:19 PM, Paul Moore wrote: You need to specify that you're using Python 3.4 (or whichever) when starting a new thread. I want to write a string to an already-open file (sys.stdout, typically). However, I *don't* want encoding errors, and the string could be arbitrary Unicode

Re: Stripping in Python

2015-01-15 Thread ronnyma
On Thursday, January 15, 2015 at 11:35:11 AM UTC+1, Abdul Abdul wrote: > Hello, > > I have a program where I read a line input from the keyboard. > > If I remove this portion of code after reading the line, I get an error: > > line = line.rstrip() > > Why is that? Should stripping be always be

Re: Stripping in Python

2015-01-15 Thread Peter Otten
Abdul Abdul wrote: > I have a program where I read a line input from the keyboard. > > If I remove this portion of code after reading the line, I get an error: > > line = line.rstrip() > > Why is that? Should stripping be always be used after reading an input in > Python? What version of Pytho

Re: stripping (from item in list)

2014-07-20 Thread Terry Reedy
On 7/20/2014 5:40 AM, Martin S wrote: while c >=0: x=games[c][0] if x=="#": del games[c] #This removes the comments from the file parsed else: games[c].rstrip('\n') #This does nothing, expected to remove \n Chris already pointed out error he

Re: stripping (from item in list)

2014-07-20 Thread Chris Angelico
On Sun, Jul 20, 2014 at 8:06 PM, Martin S wrote: > And yes, definately should be able to build a better parser ... I want > it to work first. Fair enough. That's why I answered your actual question before mentioning that as a tacked-on almost postscript. :) ChrisA -- https://mail.python.org/mai

Re: stripping (from item in list)

2014-07-20 Thread Martin S
Craps should have guessed that was the problem. Must have misunderstood the examples. But thanks =) And yes, definately should be able to build a better parser ... I want it to work first. /Martin S 2014-07-20 11:57 GMT+02:00 Chris Angelico : > On Sun, Jul 20, 2014 at 7:40 PM, Martin S wrote:

Re: stripping (from item in list)

2014-07-20 Thread Chris Angelico
On Sun, Jul 20, 2014 at 7:40 PM, Martin S wrote: > games[c].rstrip('\n') #This does nothing, expected to remove \n > > While all records in the remaining list now are valid, all also still > have "\n" at the end. What did I miss here? Strings don't change. When you call rstrip(), it r

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Dave Angel
On 19/9/2013 11:53, Neil Cerutti wrote: > On 2013-09-18, Dave Angel wrote: >> On 18/9/2013 17:40, Neil Hodgson wrote: >> >>> Dave Angel: >>> So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at >>

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Neil Cerutti
On 2013-09-18, Dave Angel wrote: > On 18/9/2013 17:40, Neil Hodgson wrote: > >> Dave Angel: >> >>> So is the bug in Excel, in Windows, or in the Python library? Somebody >>> is falling down on the job; if Windows defines the string as ending at >>> the first null, then the Python interface shoul

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread random832
On Wed, Sep 18, 2013, at 16:13, Dave Angel wrote: > So is the bug in Excel, in Windows, or in the Python library? Somebody > is falling down on the job; if Windows defines the string as ending at > the first null, then the Python interface should use that when defining > the text defined with CF_

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 17:40, Neil Hodgson wrote: > Dave Angel: > >> So is the bug in Excel, in Windows, or in the Python library? Somebody >> is falling down on the job; if Windows defines the string as ending at >> the first null, then the Python interface should use that when defining >> the text defin

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Neil Hodgson
Dave Angel: So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at the first null, then the Python interface should use that when defining the text defined with CF_UNICODETEXT. Everything is performing

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 15:40, MRAB wrote: > On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: >> Thanks to everyone for their help. Using everyone's suggestions, this seems >> to work: >> >> import win32clipboard, win32con >> >> def getclipboard(): >> win32clipboard.OpenClipboard() >> s = win3

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread MRAB
On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: Thanks to everyone for their help. Using everyone's suggestions, this seems to work: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread stephen . boulet
Thanks to everyone for their help. Using everyone's suggestions, this seems to work: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) win32clipboard.CloseClipboard() if '\0' in s:

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread random832
On Fri, Sep 13, 2013, at 12:09, random...@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

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-17 Thread stephen . boulet
On Thursday, September 12, 2013 6:01:20 PM UTC-5, stephen...@gmail.com wrote: > I have an excel file. When I select cells, copy from excel, and then use > win32clipboard to get the contents of the clipboard, I have a 131071 > character string. > > > > When I save the file as a text file, and u

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread random832
On Fri, Sep 13, 2013, at 10:38, stephen.bou...@gmail.com wrote: > > Hm, that gives me a "Type str doesn't support the buffer API" message. > > Aha, I need to use str(s, encoding='utf8').rstrip('\0'). It's not a solution to your problem, but why aren't you using CF_UNICODETEXT, particularly if you

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread Neil Cerutti
On 2013-09-13, stephen.bou...@gmail.com wrote: > On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: >> Stephen Boulet: >> >> >> >> > From the clipboard contents copied from the spreadsheet, the characters >> > s[:80684] were the visible cell contents, and s[80684:] all sta

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Friday, September 13, 2013 9:31:45 AM UTC-5, stephen...@gmail.com wrote: > On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: > > > Stephen Boulet: > > > > > > > > > > > > > From the clipboard contents copied from the spreadsheet, the characters > > > s[:80684] were

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: > Stephen Boulet: > > > > > From the clipboard contents copied from the spreadsheet, the characters > > s[:80684] were the visible cell contents, and s[80684:] all started with > > "b'\x0" and lack any useful info for what

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread Neil Hodgson
Stephen Boulet: From the clipboard contents copied from the spreadsheet, the characters s[:80684] were the visible cell contents, and s[80684:] all started with "b'\x0" and lack any useful info for what I'm trying to accomplish. Looks like Excel is rounding up its clipboard allocation to

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread MRAB
On 13/09/2013 01:58, stephen.bou...@gmail.com wrote: Hi Steven. Here is my code: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return s I use this help

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread stephen . boulet
Hi Steven. Here is my code: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return s I use this helper function to grab the text on the clipboard and do useful

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread Steven D'Aprano
On Thu, 12 Sep 2013 16:01:20 -0700, stephen.boulet wrote: > I have an excel file. When I select cells, copy from excel, and then use > win32clipboard to get the contents of the clipboard, I have a 131071 > character string. How exactly are you using win32clipboard, and what exact result are you

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 01.03.2010 00:15: > Stefan, I was happy to see such concise code. > Your python worked with only very minor modifications. > > Hai's test xml data *without* the first and last line is close enough > to the data I am using: > > > > > > > > ... quirky. > > I get a large file given

Re: stripping fields from xml file into a csv

2010-02-28 Thread Hal Styli
On 28 Feb, 19:20, Stefan Behnel wrote: > Hai Vu, 28.02.2010 17:41: > > > By the way, Stefan, I am using Python 2.6. Do you know the differences > > between ElementTree and cElementTree? > > Use cElementTree, it's implemented in C and a lot faster and more memory > friendly. > > http://effbot.org/z

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hai Vu, 28.02.2010 17:41: > By the way, Stefan, I am using Python 2.6. Do you know the differences > between ElementTree and cElementTree? Use cElementTree, it's implemented in C and a lot faster and more memory friendly. http://effbot.org/zone/celementtree.htm#benchmarks http://codespeak.net/lxm

Re: stripping fields from xml file into a csv

2010-02-28 Thread Hai Vu
On Feb 28, 12:05 am, Stefan Behnel wrote: > Hal Styli, 27.02.2010 21:50: > > > I have a sed solution to the problems below but would like to rewrite > > in python... > > Note that sed (or any other line based or text based tool) is not a > sensible way to handle XML. If you want to read XML, use a

Re: stripping fields from xml file into a csv

2010-02-28 Thread Roland Mueller
2010/2/28 Stefan Behnel > Roland Mueller, 28.02.2010 13:01: > > The stylesheet is test.xsl and the insput data test.xml. The following > > Python code the applies the stylesheet on the input data and puts the > output > > into foo. > > > > Python code: > > #!/usr/bin/python > > import sys > > imp

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Roland Mueller, 28.02.2010 13:01: > The stylesheet is test.xsl and the insput data test.xml. The following > Python code the applies the stylesheet on the input data and puts the output > into foo. > > Python code: > #!/usr/bin/python > import sys > import libxml2 > import libxslt > > styledoc =

Re: stripping fields from xml file into a csv

2010-02-28 Thread Roland Mueller
Hello, 2010/2/28 Stefan Behnel > Hal Styli, 27.02.2010 21:50: > > I have a sed solution to the problems below but would like to rewrite > > in python... > > Note that sed (or any other line based or text based tool) is not a > sensible way to handle XML. If you want to read XML, use an XML parse

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 27.02.2010 21:50: > I have a sed solution to the problems below but would like to rewrite > in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you w

Re: stripping fields from xml file into a csv

2010-02-27 Thread Hai Vu
On Feb 27, 12:50 pm, Hal Styli wrote: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite > in python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="dick" product=

Re: stripping fields from xml file into a csv

2010-02-27 Thread Zaphod
On Sat, 27 Feb 2010 12:50:38 -0800, Hal Styli wrote: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite in > python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="

Re: stripping fields from xml file into a csv

2010-02-27 Thread John Bokma
Hal Styli writes: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite > in python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="dick" product="eggs" ... quantity

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread daku9999
On Apr 1, 8:10 am, jay logan wrote: > On Apr 1, 11:05 am, jay logan wrote: > > > > > On Apr 1, 2:35 am, daku9...@gmail.com wrote: > > > > On Mar 31, 6:47 pm, "Rhodri James" > > > wrote: > > > > > What you're doing (pace error checking) seems fine for the data > > > > structures that you're using

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread jay logan
On Apr 1, 11:05 am, jay logan wrote: > On Apr 1, 2:35 am, daku9...@gmail.com wrote: > > > > > On Mar 31, 6:47 pm, "Rhodri James" > > wrote: > > > > What you're doing (pace error checking) seems fine for the data > > > structures that you're using.  I'm not entirely clear what your usage > > > pat

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread jay logan
On Apr 1, 2:35 am, daku9...@gmail.com wrote: > On Mar 31, 6:47 pm, "Rhodri James" > wrote: > > > What you're doing (pace error checking) seems fine for the data > > structures that you're using.  I'm not entirely clear what your usage > > pattern for "dip" and "dir" is once you've got them, so I c

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread Lorenzo
Maybe you can try a regex, something like -- import re pattern = re.compile('^(\d+)/(\d+).*') def read_data(filename): fh = open(filename, "r", encoding="ascii") for line in fh: if pattern.match(line): dip_,dir_ = pattern.match(line).groups()

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread daku9999
On Mar 31, 6:47 pm, "Rhodri James" wrote: > What you're doing (pace error checking) seems fine for the data > structures that you're using.  I'm not entirely clear what your usage > pattern for "dip" and "dir" is once you've got them, so I can't say > whether there's a more appropriate shape for

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread andrew cooke
Rhodri James wrote: > On Tue, 31 Mar 2009 06:51:33 +0100, wrote: > >> There has got to be a better way of doing this: >> >> I'm reading in a file that has a lot of garbage, but eventually has >> something that looks similar to: >> (some lines of garbage) >> dip/dir. >> (some more lines of garbage)

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread Rhodri James
On Tue, 31 Mar 2009 06:51:33 +0100, wrote: There has got to be a better way of doing this: I'm reading in a file that has a lot of garbage, but eventually has something that looks similar to: (some lines of garbage) dip/dir. (some more lines of garbage) 55/158 (some more lines of garbage) 33/1

Re: Stripping parts of a path

2008-07-27 Thread Tim Cook
On Sun, 2008-07-27 at 04:32 +, Tim Roberts wrote: > This doesn't do what you think it does. The parameter to rstrip is a set: > as long as the last character is in the set 'abcdhiloprs/', it will remove > it and check the next one. All of the characters in "shop" are in that > set. Thanks

Re: Stripping parts of a path

2008-07-26 Thread Tim Roberts
Tim Cook <[EMAIL PROTECTED]> wrote: > >I just ran into an issue with the rstrip method when using it on path >strings. > >When executing a function I have a need to strip off a portion of the >current working directory and add on a path to a log file. Initially >this worked great but then I added

Re: Stripping parts of a path

2008-07-26 Thread Dan Stromberg
On Sat, 26 Jul 2008 08:59:15 -0300, Tim Cook wrote: > Hi All, > > I just ran into an issue with the rstrip method when using it on path > strings. > > When executing a function I have a need to strip off a portion of the > current working directory and add on a path to a log file. Initially > t

Re: Stripping parts of a path

2008-07-26 Thread Larry Bates
Tim Cook wrote: Hi All, I just ran into an issue with the rstrip method when using it on path strings. When executing a function I have a need to strip off a portion of the current working directory and add on a path to a log file. Initially this worked great but then I added a branch in SVN w

Re: Stripping parts of a path

2008-07-26 Thread Karen Tracey
On Sat, Jul 26, 2008 at 7:59 AM, Tim Cook <[EMAIL PROTECTED]>wrote: > Hi All, > > I just ran into an issue with the rstrip method when using it on path > strings. > > When executing a function I have a need to strip off a portion of the > current working directory and add on a path to a log file.

Re: Stripping scripts from HTML with regular expressions

2008-04-11 Thread Stefan Behnel
Michel Bouwmans wrote: > I don't think HTMLParser was doing anything wrong here. I needed to parse a > HTML document, but it contained script-blocks with document.write's in > them. I only care for the content outside these blocks but HTMLParser will > choke on such a block when it isn't encapsulat

RE: Stripping scripts from HTML with regular expressions

2008-04-10 Thread Michel Bouwmans
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Reedick, Andrew wrote: >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:python- >> [EMAIL PROTECTED] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 5:44 PM >> To: python-list@python

RE: Stripping scripts from HTML with regular expressions

2008-04-10 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 5:44 PM > To: python-list@python.org > Subject: RE: Stripping scripts from HTML with regular expressions > > >

Re: Stripping scripts from HTML with regular expressions

2008-04-10 Thread Paul McGuire
On Apr 9, 2:38 pm, Michel Bouwmans <[EMAIL PROTECTED]> wrote: > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) > resul

Re: Stripping scripts from HTML with regular expressions

2008-04-10 Thread Nikita the Spider
In article <[EMAIL PROTECTED]>, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of Michel Bouwmans > > Sent: Wednesday, April 09, 2008 3:38 PM > > To: python-list@python.org > > Subject: Stripp

RE: Stripping scripts from HTML with regular expressions

2008-04-09 Thread Michel Bouwmans
Reedick, Andrew wrote: > > >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:python- >> [EMAIL PROTECTED] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 3:38 PM >> To: python-list@python.org >> Subject: Stripping scripts from HTML with regular expressions >> >> H

RE: Stripping scripts from HTML with regular expressions

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list@python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to stri

Re: Stripping scripts from HTML with regular expressions

2008-04-09 Thread Stefan Behnel
Michel Bouwmans wrote: > I'm trying to strip all script-blocks from a HTML-file using regex. You might want to take a look at lxml.html instead, which comes with an HTML cleaner module: http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html Stefan -- http://mail.python.org/mailman/listinfo/py

RE: Stripping scripts from HTML with regular expressions

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list@python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to stri

RE: Stripping whitespace

2008-01-24 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of John Machin > Sent: Wednesday, January 23, 2008 5:48 PM > To: python-list@python.org > Subject: Re: Stripping whitespace > > On Jan 24, 7:57 am, "Reedick, Andr

Re: Stripping whitespace

2008-01-24 Thread cokofreedom
On Jan 24, 8:21 am, ryan k <[EMAIL PROTECTED]> wrote: > On Jan 23, 6:30 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > On Jan 24, 9:50 am, ryan k <[EMAIL PROTECTED]> wrote: > > > > Steven D'Aprano, you are a prick. > > > And your reasons for coming to that stridently expressed conclusion > > afte

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 6:30 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 9:50 am, ryan k <[EMAIL PROTECTED]> wrote: > > > Steven D'Aprano, you are a prick. > > And your reasons for coming to that stridently expressed conclusion > after reading a posting that was *not* addressed to you are .? Be

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 9:50 am, ryan k <[EMAIL PROTECTED]> wrote: > Steven D'Aprano, you are a prick. And your reasons for coming to that stridently expressed conclusion after reading a posting that was *not* addressed to you are .? -- http://mail.python.org/mailman/listinfo/python-list

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > ryan k <[EMAIL PROTECTED]> writes: > >> Hello. I have a string like 'LNAME > >> PASTA ZONE'. I want to create a list of those words and > >> ba

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 9:47 am, ryan k <[EMAIL PROTECTED]> wrote: > On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] > > > > cybersource.com.au> wrote: > > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > > ryan k <[EMAIL PROTECTED]> writes: > > >> Hello. I have a string like 'LNAME > > >> PASTA

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 7:57 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > Why is it that so many Python people are regex adverse? Use the dashed > line as a regex. Convert the dashes to dots. Wrap the dots in > parentheses. Convert the whitespace chars to '\s'. Presto! Simpler, > cleaner code. Wo

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > ryan k <[EMAIL PROTECTED]> writes: > >> Hello. I have a string like 'LNAME > >> PASTA ZONE'. I want to create a list of those words and > >> ba

Re: Stripping whitespace

2008-01-23 Thread Steven D'Aprano
On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > ryan k <[EMAIL PROTECTED]> writes: >> Hello. I have a string like 'LNAME >> PASTA ZONE'. I want to create a list of those words and >> basically replace all the whitespace between them with one space so i >> could just do lala.s

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 7:23 am, ryan k <[EMAIL PROTECTED]> wrote: > On Jan 23, 3:02 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > > > > So yea i will just have to count dashes. > > > Read my lips: *you* counting dashes is dumb. Writing your code so tha

RE: Stripping whitespace

2008-01-23 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of ryan k > Sent: Wednesday, January 23, 2008 3:24 PM > To: python-list@python.org > Subject: Re: Stripping whitespace > > On Jan 23, 3:02 pm, John Machin <[EMAIL PROTE

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 3:02 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > > > So yea i will just have to count dashes. > > Read my lips: *you* counting dashes is dumb. Writing your code so that > *code* is counting dashes each time it opens the file is sma

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:57 am, ryan k <[EMAIL PROTECTED]> wrote: > So yea i will just have to count dashes. Read my lips: *you* counting dashes is dumb. Writing your code so that *code* is counting dashes each time it opens the file is smart. -- http://mail.python.org/mailman/listinfo/python-list

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 2:53 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 24, 6:17 am, ryan k <[EMAIL PROTECTED]> wrote: > > > I am taking a database class so I'm not asking for specific answers. > > Well I have this text tile: > > >http://www.cs.tufts.edu/comp/115/projects/proj0/customer.txt > > Uh-huh,

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:17 am, ryan k <[EMAIL PROTECTED]> wrote: > I am taking a database class so I'm not asking for specific answers. > Well I have this text tile: > > http://www.cs.tufts.edu/comp/115/projects/proj0/customer.txt Uh-huh, "column-aligned" output. > > And this code: > [snip] > > Because the

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 6:05 am, Paul Rubin wrote: > ryan k <[EMAIL PROTECTED]> writes: > > Hello. I have a string like 'LNAME > > PASTA ZONE'. I want to create a list of those words and > > basically replace all the whitespace between them with one space so i > > could

Re: Stripping whitespace

2008-01-23 Thread ryan k
I am taking a database class so I'm not asking for specific answers. Well I have this text tile: http://www.cs.tufts.edu/comp/115/projects/proj0/customer.txt And this code: # Table and row classes used for queries class Row(object): def __init__(self, column_list, row_vals): print l

Re: Stripping whitespace

2008-01-23 Thread ryan k
On Jan 23, 2:04 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 23 Jan 2008 10:50:02 -0800, ryan k wrote: > > Hello. I have a string like 'LNAME > > PASTA ZONE'. I want to create a list of those words and > > basically replace all the whitespace between them with one

Re: Stripping whitespace

2008-01-23 Thread John Machin
On Jan 24, 5:50 am, ryan k <[EMAIL PROTECTED]> wrote: > Hello. I have a string like 'LNAME > PASTA ZONE'. I want to create a list of those words and > basically replace all the whitespace between them with one space so i > could just do lala.split(). Thank you! > > Ryan Kaskel So whe

Re: Stripping whitespace

2008-01-23 Thread James Matthews
Using the split method is the easiest! On 23 Jan 2008 19:04:38 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 23 Jan 2008 10:50:02 -0800, ryan k wrote: > > > Hello. I have a string like 'LNAME > > PASTA ZONE'. I want to create a list of those words and > > basical

Re: Stripping whitespace

2008-01-23 Thread Paul Rubin
ryan k <[EMAIL PROTECTED]> writes: > Hello. I have a string like 'LNAME > PASTA ZONE'. I want to create a list of those words and > basically replace all the whitespace between them with one space so i > could just do lala.split(). Thank you! import re s = 'LNAME PASTAZONE'

Re: Stripping whitespace

2008-01-23 Thread Marc 'BlackJack' Rintsch
On Wed, 23 Jan 2008 10:50:02 -0800, ryan k wrote: > Hello. I have a string like 'LNAME > PASTA ZONE'. I want to create a list of those words and > basically replace all the whitespace between them with one space so i > could just do lala.split(). Thank you! You *can* just do ``lala.

Re: stripping the first byte from a binary file

2007-07-11 Thread Alex Popescu
On Jul 11, 7:45 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Alex Popescu wrote: > > On Jul 11, 4:15 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> > Forgive my newbie ignorance, but I am wondering why the other method > >> > would not work? I mean it may not be very safe, > >> > but

Re: stripping the first byte from a binary file

2007-07-11 Thread Diez B. Roggisch
Alex Popescu wrote: > On Jul 11, 4:15 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> > Forgive my newbie ignorance, but I am wondering why the other method >> > would not work? I mean it may not be very safe, >> > but I guess it may perform a lot better, than having to read the whole >> > fi

Re: stripping the first byte from a binary file

2007-07-11 Thread Alex Popescu
On Jul 11, 4:15 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Forgive my newbie ignorance, but I am wondering why the other method > > would not work? I mean it may not be very safe, > > but I guess it may perform a lot better, than having to read the whole > > file just to cut out the firs

Re: stripping the first byte from a binary file

2007-07-11 Thread Stefan Behnel
Alex Popescu wrote: > Forgive my newbie ignorance, but I am wondering why the other method > would not work? I mean it may not be very safe, > but I guess it may perform a lot better, than having to read the whole > file just to cut out the first byte. Why would you expect that? It *might* perform

Re: stripping the first byte from a binary file

2007-07-11 Thread Diez B. Roggisch
> > Forgive my newbie ignorance, but I am wondering why the other method > would not work? I mean it may not be very safe, > but I guess it may perform a lot better, than having to read the whole > file just to cut out the first byte. Because seeking is not moving? Shifting data bytewise isn't so

Re: stripping the first byte from a binary file

2007-07-11 Thread Alex Popescu
On Jul 11, 1:25 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > rvr wrote: > > On Jul 11, 1:28 pm, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > >> On Wed, 11 Jul 2007 01:06:04 +, rvr wrote: > >>> Is there a way to edit the file in place? The best I seem to be able to > >>> do is to use your

Re: stripping the first byte from a binary file

2007-07-11 Thread Stefan Behnel
rvr wrote: > On Jul 11, 1:28 pm, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> On Wed, 11 Jul 2007 01:06:04 +, rvr wrote: >>> Is there a way to edit the file in place? The best I seem to be able to >>> do is to use your second solution to read the file into the string, then >>> re-open the fi

Re: stripping the first byte from a binary file

2007-07-11 Thread rvr
On Jul 11, 1:28 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 11 Jul 2007 01:06:04 +, rvr wrote: > > Is there a way to edit the file in place? The best I seem to be able to > > do is to use your second solution to read the file into the string, then > > re-open the file for writing a

Re: stripping the first byte from a binary file

2007-07-10 Thread Steven D'Aprano
On Wed, 11 Jul 2007 01:06:04 +, rvr wrote: > Is there a way to edit the file in place? The best I seem to be able to > do is to use your second solution to read the file into the string, then > re-open the file for writing and put the whole thing back (minus the > first byte). Thanks. I don't

Re: stripping the first byte from a binary file

2007-07-10 Thread rvr
On Jul 10, 6:37 pm, Jeremy Sanders wrote: > rvr wrote: > > Would someone mind showing me how to strip the first byte from a > > binary file? For some reason I can't figure this out from the binary > > file editing examples I've read. Thanks. > > Do you mean something like this? > > f = open('test.

Re: stripping the first byte from a binary file

2007-07-10 Thread Jeremy Sanders
rvr wrote: > Would someone mind showing me how to strip the first byte from a > binary file? For some reason I can't figure this out from the binary > file editing examples I've read. Thanks. Do you mean something like this? f = open('test.dat', 'rb') f.read(1) # read 1st byte and ignore it res

Re: stripping parts of elements in a list

2006-10-30 Thread Bruno Desthuilliers
CSUIDL PROGRAMMEr wrote: > folks, > I am new to python. > > I have a list made of elements > > ['amjad\n', 'kiki\n', 'jijiji\n'] > I am trying to get rid of '\n' after each name. > to get list as > ['amjad','kiki','jijiji'] > > But list does not have a strip function as string does have. Wha

Re: stripping parts of elements in a list

2006-10-28 Thread Paul Rubin
"CSUIDL PROGRAMMEr" <[EMAIL PROTECTED]> writes: > ['amjad\n', 'kiki\n', 'jijiji\n'] > I am trying to get rid of '\n' after each name. > to get list as > ['amjad','kiki','jijiji'] > > But list does not have a strip function as string does have. > > is there any solutions a = ['amjad\n', 'kiki\n

Re: stripping unwanted chars from string

2006-05-04 Thread Alex Martelli
Edward Elliott <[EMAIL PROTECTED]> wrote: > I'm looking for the "best" way to strip a large set of chars from a filename > string (my definition of best usually means succinct and readable). I > only want to allow alphanumeric chars, dashes, and periods. This is what I > would write in Perl (bl

  1   2   >