def StripNoPrint(self, S):
from string import printable
return .join([ ch for ch in S if ch in printable ])
Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 217
P.O. Box 2 | GSM: +31 6 24 25 17 28
NL-7990 AA Dwingeloo |
Adriaan Renting wrote:
def StripNoPrint(self, S):
from string import printable
return .join([ ch for ch in S if ch in printable ])
Adriaan Renting| Email: [EMAIL PROTECTED]
ASTRON | Phone: +31 521 595 217
P.O. Box 2 | GSM: +31 6 24 25
Steve Holden wrote:
tt = .join([chr(i) for i in range(256)])
Or:
tt = string.maketrans('', '')
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
On 17 Jul 2005 18:32:28 -0700, Raymond Hettinger [EMAIL PROTECTED] wrote:
[George Sakkis]
It's only obvious in the sense that _after_ you see this idiom, you can go
back to the docs and
realize it's not doing something special; OTOH if you haven't seen it, it's
not at all the obvious
On Sat, 16 Jul 2005 23:28:02 -0400, George Sakkis [EMAIL PROTECTED] wrote:
Peter Hansen [EMAIL PROTECTED] wrote:
George Sakkis wrote:
Peter Hansen [EMAIL PROTECTED] wrote:
Where did you learn that, George?
Actually I first read about this in the Cookbook; there are two or three
On Sun, 17 Jul 2005 15:42:08 -0600, Steven Bethard [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
Thanks for the nudge. Actually, I know about generator expressions, but
at some point I must have misinterpreted some bug in my code to mean
that join in particular didn't like generator expression
On 15 Jul 2005 17:33:39 -0700, MKoool [EMAIL PROTECTED] wrote:
I have a file with binary and ascii characters in it. I massage the
data and convert it to a more readable format, however it still comes
up with some binary characters mixed in. I'd like to write something
to just replace all
On Tue, 19 Jul 2005 20:28:31 +1200, Ross wrote:
On 15 Jul 2005 17:33:39 -0700, MKoool [EMAIL PROTECTED] wrote:
I have a file with binary and ascii characters in it. I massage the
data and convert it to a more readable format, however it still comes
up with some binary characters mixed in.
Peter Hansen wrote:
''.join(chr(c) for c in range(65, 91))
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Wouldn't this be a candidate for making the Python language stricter?
Do you remember old Python versions treating l.append(n1,n2) the same
way like l.append((n1,n2)). I'm glad this is forbidden now.
Ciao,
Michael Ströder wrote:
Peter Hansen wrote:
''.join(chr(c) for c in range(65, 91))
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Wouldn't this be a candidate for making the Python language stricter?
Why would that be true? I believe str.join() takes any iterable, and a
generator (as returned by a
Michael Ströder wrote:
Peter Hansen wrote:
''.join(chr(c) for c in range(65, 91))
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Wouldn't this be a candidate for making the Python language stricter?
Do you remember old Python versions treating l.append(n1,n2) the same
way like l.append((n1,n2)). I'm glad
Steven D'Aprano wrote:
On Sat, 16 Jul 2005 16:42:58 -0400, Peter Hansen wrote:
Come on, Steven. Don't tell us you didn't have access to a Python
interpreter to check before you posted:
Er, as I wrote in my post:
Steven
who is still using Python 2.3, and probably will be for quite some
Bengt Richter wrote:
Thanks for the nudge. Actually, I know about generator expressions, but
at some point I must have misinterpreted some bug in my code to mean
that join in particular didn't like generator expression arguments,
and wanted lists.
I suspect this is bug 905389 [1]:
def
[George Sakkis]
It's only obvious in the sense that _after_ you see this idiom, you can go
back to the docs and
realize it's not doing something special; OTOH if you haven't seen it, it's
not at all the obvious
solution to how do I get the first 256 characters. So IMO it should be
Wow, that was the most thorough answer to a comp.lang.python question
since the Martellibot got busy in the search business.
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter wrote:
identity = ''.join([chr(i) for i in xrange(256)])
unprintable = ''.join([c for c in identity if c not in string.printable])
And note that with Python 2.4, in each case the above square brackets
are unnecessary (though harmless), because of the arrival of generator
On Sat, 16 Jul 2005 10:25:29 -0400, Peter Hansen wrote:
Bengt Richter wrote:
identity = ''.join([chr(i) for i in xrange(256)])
unprintable = ''.join([c for c in identity if c not in
string.printable])
And note that with Python 2.4, in each case the above square brackets
are
Steven D'Aprano wrote:
On Sat, 16 Jul 2005 10:25:29 -0400, Peter Hansen wrote:
Bengt Richter wrote:
identity = ''.join([chr(i) for i in xrange(256)])
And note that with Python 2.4, in each case the above square brackets
are unnecessary (though harmless), because of the arrival of generator
On Sat, 16 Jul 2005 10:25:29 -0400, Peter Hansen [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
identity = ''.join([chr(i) for i in xrange(256)])
unprintable = ''.join([c for c in identity if c not in
string.printable])
And note that with Python 2.4, in each case the above square brackets
Bengt Richter [EMAIL PROTECTED] wrote:
identity = ''.join([chr(i) for i in xrange(256)])
unprintable = ''.join([c for c in identity if c not in string.printable])
Or equivalently:
identity = string.maketrans('','')
unprintable = identity.translate(identity, string.printable)
George
On Sat, 16 Jul 2005 19:01:50 -0400, Peter Hansen [EMAIL PROTECTED] wrote:
George Sakkis wrote:
Bengt Richter [EMAIL PROTECTED] wrote:
identity = ''.join([chr(i) for i in xrange(256)])
Or equivalently:
identity = string.maketrans('','')
Wow! That's handy, not to mention undocumented. (At
Jp Calderone wrote:
On Sat, 16 Jul 2005 19:01:50 -0400, Peter Hansen [EMAIL PROTECTED] wrote:
George Sakkis wrote:
identity = string.maketrans('','')
Wow! That's handy, not to mention undocumented. (At least in the
string module docs.) Where did you learn that, George?
Peter Hansen [EMAIL PROTECTED] wrote:
Jp Calderone wrote:
On Sat, 16 Jul 2005 19:01:50 -0400, Peter Hansen [EMAIL PROTECTED] wrote:
George Sakkis wrote:
identity = string.maketrans('','')
Wow! That's handy, not to mention undocumented. (At least in the
string module docs.) Where
George Sakkis wrote:
Peter Hansen [EMAIL PROTECTED] wrote:
Where did you learn that, George?
Actually I first read about this in the Cookbook; there are two or three
recipes related to string.translate. As for string.maketrans, it
doesn't do anything special for empty string arguments:
Peter Hansen [EMAIL PROTECTED] wrote:
George Sakkis wrote:
Peter Hansen [EMAIL PROTECTED] wrote:
Where did you learn that, George?
Actually I first read about this in the Cookbook; there are two or three
recipes related to string.translate. As for string.maketrans, it
doesn't do
On Sat, 16 Jul 2005 16:42:58 -0400, Peter Hansen wrote:
Steven D'Aprano wrote:
On Sat, 16 Jul 2005 10:25:29 -0400, Peter Hansen wrote:
Bengt Richter wrote:
identity = ''.join([chr(i) for i in xrange(256)])
And note that with Python 2.4, in each case the above square brackets
are
26 matches
Mail list logo