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
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
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 normally do is take them and scale
them d
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
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,
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
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
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
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
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').decode(file.encoding)
file.write(data)
On Fri, Feb 13, 2015 at 6:22 PM, Mark Lawrence wrote:
> On 14/02/2015 00:11, Ian Kelly wrote:
>>
>> On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence
>> wrote:
>>>
>>> I still think it's a bug as the 'p' being referred to in the OP's
>>> original
>>> message is "The precision is a decimal number ind
Mark Lawrence wrote:
I still think it's a bug as the 'p' being referred to in the OP's
original message is "The precision is a decimal number indicating how
many digits should be displayed after the decimal point for a floating
point value formatted with 'f' and 'F', or before and after the dec
On 14/02/2015 00:11, Ian Kelly wrote:
On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence wrote:
I still think it's a bug as the 'p' being referred to in the OP's original
message is "The precision is a decimal number indicating how many digits
should be displayed after the decimal point for a float
On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence wrote:
> I still think it's a bug as the 'p' being referred to in the OP's original
> message is "The precision is a decimal number indicating how many digits
> should be displayed after the decimal point for a floating point value
> formatted with 'f
On 12/02/2015 23:46, Ian Kelly wrote:
On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
from decimal import Decimal as D
x = D(1)/D(999)
'{:.15g}'.format(x)
'0.00100100100100100'
[...]
I'd say it's a bug. P is 15, you've got 17 digits after the decimal place
and two of those are insign
On Fri, Feb 13, 2015 at 2:40 PM, Ian Kelly wrote:
> On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards
> wrote:
>> On 2015-02-13, Dave Angel wrote:
>>> On the other hand, the Decimal package has a way that the programmer
>>> can tell how many digits to use at each stage of the calculation.
>>
>> Th
On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards wrote:
> On 2015-02-13, Dave Angel wrote:
>> On the other hand, the Decimal package has a way that the programmer
>> can tell how many digits to use at each stage of the calculation.
>
> That's what surpised me. From TFM:
>
> https://docs.python.org
On 2015-02-13, Dave Angel wrote:
> On 02/13/2015 03:33 PM, Grant Edwards wrote:
>> On 2015-02-13, Ian Kelly wrote:
>>
>>> Significant digits are within the precision of the calculation.
>>> Writing 1.230 indicates that the fourth digit is known to be zero.
>>> Writing 1.23 outside a context of ex
On 02/13/2015 03:33 PM, Grant Edwards wrote:
On 2015-02-13, Ian Kelly wrote:
Significant digits are within the precision of the calculation.
Writing 1.230 indicates that the fourth digit is known to be zero.
Writing 1.23 outside a context of exact calculation indicates that the
fourth digit i
On Fri, Feb 13, 2015 at 1:33 PM, Grant Edwards wrote:
> On 2015-02-13, Ian Kelly wrote:
>> On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards
>> wrote:
>>> On 2015-02-12, Ian Kelly wrote:
On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
> {:.15g} is supposed to give 15 digits o
On 2015-02-13, Ian Kelly wrote:
> On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards
> wrote:
>> On 2015-02-12, Ian Kelly wrote:
>>> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
>>>
{:.15g} is supposed to give 15 digits of precision, but with trailing
zeros removed.
>>>
>>> The
On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards wrote:
> On 2015-02-12, Ian Kelly wrote:
>> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
>>
>>> {:.15g} is supposed to give 15 digits of precision, but with trailing
>>> zeros removed.
>>
>> The doc says with "insignificant" trailing zeros
On Fri, Feb 13, 2015 at 2:26 AM, Hrvoje Nikšić wrote:
> Ian Kelly writes:
>> When you specify the a precision of 15 in your format string, you're
>> telling it to take the first 15 of those. It doesn't care that the
>> last couple of those are zeros, because as far as it's concerned,
>> those digi
On 2015-02-12, Ian Kelly wrote:
> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
>
>> {:.15g} is supposed to give 15 digits of precision, but with trailing
>> zeros removed.
>
> The doc says with "insignificant" trailing zeros removed, not all
> trailing zeros.
Can somebody explain the di
Ian Kelly writes:
> When you specify the a precision of 15 in your format string, you're
> telling it to take the first 15 of those. It doesn't care that the
> last couple of those are zeros, because as far as it's concerned,
> those digits are significant.
OK, it's a bit surprising, but also cons
On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote:
>> > from decimal import Decimal as D
>> > x = D(1)/D(999)
>> > '{:.15g}'.format(x)
>> >>
>> >> '0.00100100100100100'
> [...]
>> > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place
>> > and two of those are
> > from decimal import Decimal as D
> > x = D(1)/D(999)
> > '{:.15g}'.format(x)
> >>
> >> '0.00100100100100100'
[...]
> > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place
> > and two of those are insignificant trailing zeros.
>
> Actually it's the float versio
On Wed, Feb 11, 2015 at 3:19 PM, Ian Kelly wrote:
> On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence
> wrote:
>> On 11/02/2015 20:02, Hrvoje Nikšić wrote:
>>>
>>> According to the documentation of the "g" floating-point format,
>>> trailing zeros should be stripped from the resulting string:
>>>
>
On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence wrote:
> On 11/02/2015 20:02, Hrvoje Nikšić wrote:
>>
>> According to the documentation of the "g" floating-point format,
>> trailing zeros should be stripped from the resulting string:
>>
>> """
>> General format. For a given precision p >= 1, this r
On 11/02/2015 20:02, Hrvoje Nikšić wrote:
According to the documentation of the "g" floating-point format,
trailing zeros should be stripped from the resulting string:
"""
General format. For a given precision p >= 1, this rounds the number
to p significant digits and then formats the result in
According to the documentation of the "g" floating-point format,
trailing zeros should be stripped from the resulting string:
"""
General format. For a given precision p >= 1, this rounds the number
to p significant digits and then formats the result in either
fixed-point format or in scientific n
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? Sh
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
>
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 used after reading an input in
Python?
Thanks.
--
https://mail.python.org/mailman
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
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
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:
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
While preparing to my gui to the app I made I thought it would be nice
to be able to parse a text file with results using the same tool. So:
I read a result file to a list, and every record gets appended with
"\n" ...
OK, so I look up how to remove it. And this doesn't work
while c >=0:
x
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
>>
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
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_
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
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
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
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)
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:
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
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
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
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
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
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
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
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
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
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
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 use the python 3.3 open command to
read its contents, I only have 80684 characters.
Excel (an
Last week I was surprised to discover that there are Unicode characters that
aren't valid in an XML document. That is regardless of escaping (e.g. �)
and unicode encoding (e.g. UTF-8) - not every Unicode string can be stored in
XML. The valid characters are (as of XML 1.0) #x9 | #xA | #xD | [#x2
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
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
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
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
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
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 =
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
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
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=
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="
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
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="12" >
< cust="tom" pr
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
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
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
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()
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
gt;> dip/dir.
>> (some more lines of garbage)
>> 55/158
>> (some more lines of garbage)
>> 33/156
>> etc.
>>
>> and I'm stripping out the 55/158 values (with error checking
>> removed):
>> --
>> def read_data(fil
e)
33/156
etc.
and I'm stripping out the 55/158 values (with error checking
removed):
--
def read_data(filename):
fh = open(filename, "r", encoding="ascii")
for line in fh:
for word in line.lower().split():
if &qu
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/156
etc.
and I'm stripping out
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
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
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
hings don't work.
Help on built-in function rstrip:
rstrip(...)
S.rstrip([chars]) -> string or unicode
Return a copy of the string S with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
If chars is unicode, S will be converted to uni
ot;The chars argument is not a suffix; rather, all combinations of its values
are stripped"
Thus, since the characters p,o,h, and s are all in the argument you supplied
to rstrip, they are removed, then stripping is stopped at the k because that
is not in the chars arg you supplied.
To do what you really want I think you need to use rfind/rindex to locate
the last occurrence of the substring and then truncate the string yourself.
Karen
--
http://mail.python.org/mailman/listinfo/python-list
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 which caused the pa
shabda raaj wrote:
I want to strip punctuation from text.
So I am trying,
p = re.compile('[a-zA-Z0-9]+')
p.sub('', 'I love tomatoes!! hell yeah! ... Why?')
' !! ! ... ?'
Which gave me all the chars which I want to replace.
So Next I tried by negating the regex,
p = re.compile('^[a-zA-Z0
I want to strip punctuation from text.
So I am trying,
>>> p = re.compile('[a-zA-Z0-9]+')
>>> p.sub('', 'I love tomatoes!! hell yeah! ... Why?')
' !! ! ... ?'
Which gave me all the chars which I want to replace.
So Next I tried by negating the regex,
>>> p = re.compile('^[a-zA-Z0-9]+')
>>> p
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
-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
> -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
>
>
>
;
> greetz
> MFB
This pyparsing-based HTML stripper (http://pyparsing.wikispaces.com/
space/showimage/htmlStripper.py) strips *all* HTML tags, scripts, and
comments. To pare down to just stripping scripts, just change this
line:
firstPass = (htmlComment | scriptBody
PM
> > To: python-list@python.org
> > Subject: Stripping scripts from HTML with regular expressions
> >
> > Hey everyone,
> >
> > I'm trying to strip all script-blocks from a HTML-file using regex.
> >
>
> [Insert obligatory comment abo
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
> -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 ever
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
> -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 ever
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)
result = regex.sub('', blaat)
print result
This strips far more away then just the
> -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
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
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
1 - 100 of 197 matches
Mail list logo