Le Mon, 04 May 2009 16:08:38 -0700,
Emile van Sebille s'exprima ainsi:
> On 5/4/2009 3:37 PM Tim Michelsen said...
> > Dear Tutors and fellow pythonistas,
> > I would like to get access to the private methods of my function.
> >
> > For instance:
> > Who can I reference the docstring of a functi
Le Tue, 5 May 2009 00:52:11 +0100,
"Alan Gauld" s'exprima ainsi:
> > Is there a way in Python to say this is a string of HEX characters like
> > Perl's pack? Right now I have to take the string and add a \x to every
> > two
> > values i.e. \x41\x42...
>
> Assuming you actually want to send t
"Emile van Sebille" wrote
"414243440d0a"
Is there a way in Python to say this is a string of HEX characters like
Perl's pack? Right now I have to take the string and add a \x to every
two values i.e. \x41\x42...
import binascii
binascii.a2b_hex('41424344')
I hadn't come across binascii
"Dan Liang" wrote
And I put together the code below based on your suggestions, with minor
changes and it does work.
Good, now your question is?
-Begin code
#!usr/bin/python
tags = {
'noun-prop': 'noun_prop null null'.split(),
'case_def_gen': 'case_d
Please use a sensible subject and don;t reporst the whole digest.
"Dan Liang" wrote in message
Thank you for your help. I have been working on the file, but I still
have a
problem doing what I wanted. As a reminder,
Can you tell us what exactly the problem is? It's easier than us
trying to
My turn to apologise for premature sending of email...
For some reason I didn't notice the section of mail after
the code snippet!
Alan G
"Dan Liang" wrote in message
Now since I have to work on different data format as follows:
-Begin data
w1\t
Le Tue, 5 May 2009 00:22:45 -0400,
Dan Liang s'exprima ainsi:
> -Begin data
>
> w1\t case_def_acc \t yes
> w2\t noun_prop \t no
> w3\t case_def_gen \t
> w4\t dem_pron_f \t no
> w3\t
Thanks everyone for your replies. This reason for the long string is
sometimes I have to pass a 32 byte key (MD5 hash value) to the socket. The
data I am sending is the hex values i.e. 41=A. I believe the binascii will
work.
Mike
On Mon, May 4, 2009 at 7:52 PM, Alan Gauld wrote:
>
> "Tom Gree
On Tue, May 5, 2009 at 1:14 AM, Mark Tolonen wrote:
> The below works. ConfigParser isn't written to support Unicode correctly. I
> was able to get Unicode sections to write out, but it was just luck. Unicode
> keys and values break as the OP discovered. So treat everything as byte
> strings:
Le Tue, 5 May 2009 00:41:39 +0100,
"Alan Gauld" s'exprima ainsi:
> > Backwards compatibility. The file type was introduced in python 2.2,
> > before which there was open.
>
> And file has been removed again in Python v3
> In fact open is now an alias for io.open and no longer simply retu
On Tue, May 5, 2009 at 5:41 AM, spir wrote:
> Le Tue, 5 May 2009 00:41:39 +0100,
> "Alan Gauld" s'exprima ainsi:
>
> > > Backwards compatibility. The file type was introduced in python 2.2,
> > > before which there was open.
> >
> > And file has been removed again in Python v3
> > In fact o
Alex Feddor wrote:
Hi
I am looking for method enables advanced text string search. Method
string.find() or re module seems no supporting what I am looking for.
The idea is as follows:
Text ="FDA meeting was successful. New drug is approved for whole sale
distribution!"
I would like to sc
On Tue, May 5, 2009 at 8:11 AM, Lie Ryan wrote:
> Bring on your hardest searches...
Nice!
> The Suite class is only there to turn the NotFound sentinel from len(text)
> to -1 (used len(text) since it simplifies the code a lot...)
How does this simplify the code? Why not use the 'in' operator a
Le Tue, 05 May 2009 22:11:22 +1000,
Lie Ryan s'exprima ainsi:
> Idea:
> Overrides the operator on Pattern class so we could write it like:
> P("Hello") & P("World") instead of AND(P("Hello"), P("World"))
You could also override directly all python logical ops to allow direct
expression of logi
Kent Johnson wrote:
On Tue, May 5, 2009 at 8:11 AM, Lie Ryan wrote:
Bring on your hardest searches...
Nice!
The Suite class is only there to turn the NotFound sentinel from len(text)
to -1 (used len(text) since it simplifies the code a lot...)
How does this simplify the code? Why not use
"Kent Johnson" wrote in message
news:1c2a2c590905050337j1afc177ene64f800dcc3a7...@mail.gmail.com...
On Tue, May 5, 2009 at 1:14 AM, Mark Tolonen
wrote:
> The below works. ConfigParser isn't written to support Unicode
> correctly. I
> was able to get Unicode sections to write out, but it wa
"W W" wrote in message
news:333efb450905050408m48246dd8wc90b94880898e...@mail.gmail.com...
On Tue, May 5, 2009 at 5:41 AM, spir wrote:
Le Tue, 5 May 2009 00:41:39 +0100,
"Alan Gauld" s'exprima ainsi:
> > Backwards compatibility. The file type was introduced in python 2.2,
> > before whic
Hello, I found interesting today, as I was playing with this code in the shell:
>>> arq = open('c:/myscripts/simple2.ttt', 'w')
>>> len(a)
9
>>> arq.write('The length is %d' % len(a))
>>> res = arq.read()
>>> print res
The print doesn't print the text I had written, but some thing else I
c
"Eduardo Vieira" wrote
arq = open('c:/myscripts/simple2.ttt', 'w')
arq.write('The length is %d' % len(a))
res = arq.read()
print res
The print doesn't print the text I had written,
That's because of two things:
a) You opened the file for write only not reading
b) You had moved the file curs
> It seems that open(filename, 'r') and file(filename, 'r') are
> used interchangeably, and I wonder what this is all about.
as alan and others have pointed out, file() was added in 2.2. this was
part of the unification of types and classes. every object now has a
factory function, i.e., list() c
Thanks a lot!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
It may not be a good reason, but I like that "open"
is preferred, because in Java a "File" object is not
a stream for the content in the file, just its directory
entry, and simply creating a File object does not
open the file at all.
Larry
___
Tutor mai
for root, dirs, files in os.walk('./'):
for f in files:
if f.endswith('.txt'):
allfiles.append(os.path.join(root, f))
This returns a list of the *.txt files. Of course now I am stuck on
how to apply the delimiter and search function to the items in the
list..? Any clues/ex
forgot to add this at the top,
allfiles = []
On Tue, May 5, 2009 at 6:15 PM, Nick Burgess wrote:
> for root, dirs, files in os.walk('./'):
> for f in files:
> if f.endswith('.txt'):
> allfiles.append(os.path.join(root, f))
>
> This returns a list of the *.txt files. Of cours
"Nick Burgess" wrote
for root, dirs, files in os.walk('./'):
for f in files:
if f.endswith('.txt'):
allfiles.append(os.path.join(root, f))
myFunction( os.path.join(root,f) )
This returns a list of the *.txt files. Of course now I am stuck on
how to appl
"wesley chun" wrote
does anyone have the idiom for the above isinstance() check for 3.x?
Test for io.stream (or a derivative) - which is what open now returns.
files are no more...
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.pyth
"Larry Riedel" wrote
It may not be a good reason, but I like that "open"
is preferred, because in Java a "File" object is not
a stream for the content in the file, just its directory
entry, and simply creating a File object does not
open the file at all.
I'm not sure citing anything Java does
> I'm not sure citing anything Java does is a good rationale in Python!
I find the languages/platforms complementary, so I appreciate
when they are not arbitrarily inconsistent with each other.
Larry
___
Tutor maillist - Tutor@python.org
http://mail.
Hi, not even sure if I can ask this very smartly but we shall try:
I was playing around with trying to create a python program like tail -f
as discussed on the list. i came up with this;
def tail_it(bufsize=8192, linesep=__import__('os').linesep):
f = None
if f == None:
f = open
29 matches
Mail list logo