Hi Steven,
On Thu, Dec 23, 2010 at 11:51 AM, Steven D'Aprano wrote:
> Note also that \w means alphanumeric, not just alpha, so it will also match
> digits.
I'm sorry you didn't get to read my next message because in there I
said that you yourself had already solved my problem a few weeks ago.
u, Dec 23, 2010 at 10:25 AM, Josep M. Fontana
wrote:
> I am working with texts that are encoded as ISO-8859-1. I have
> included the following two lines at the beginning of my python script:
>
> !/usr/bin/env python
> # -*- coding: iso-8859-1 -*-
>
> If I'm not mistak
I am working with texts that are encoded as ISO-8859-1. I have
included the following two lines at the beginning of my python script:
!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
If I'm not mistaken, this should tell Python that accented characters
such as 'á', 'Á', 'ö' or 'è' should be cons
On Sun, Nov 28, 2010 at 6:14 PM, Steven D'Aprano wrote:
> Have you considered just using the isalnum() method?
>
'¿de'.isalnum()
> False
Mmm. No, I didn't consider it because I didn't even know such a method
existed. This can turn out to be very handy but I don't think it would
help me at t
Sorry, something went wrong and my message got sent before I could
finish it. I'll try again.
On Tue, Nov 30, 2010 at 2:19 PM, Josep M. Fontana
wrote:
> On Sun, Nov 28, 2010 at 6:03 PM, Evert Rol wrote:
>
>> -
>> with open('output_tokens.txt',
I'm trying to use regular expressions to extract strings that match
certain patterns in a collection of texts. Basically these texts are
edited versions of medieval manuscripts that use certain symbols to
mark information that is useful for filologists.
I'm interested in isolating words that have
On Wed, Nov 24, 2010 at 3:00 PM, Evert Rol wrote:
> Then you haven't read my previous response carefully enough, or I haven't
> phrased it properly. The example I gave was:
>
import mymodule
mymodule.X
>
> where X is defined in a file called mymodule.py
> In your case, replace mymodul
Thanks Evert and Steve,
Both of you are right when you say:
> You're not really showing what exactly you type. That's often more clearer
> than describing what you do, although in this case we can get a pretty good
> picture anyway.
OK, here's what I do:
>>>import test
I know the shell is im
Hi,
When a thread gets too long and new subtopics appear it gets pretty
hard to keep track of what has been said by whom and what has been
answered. Anyway, in one of the threads I started, Steven d'Aprano
gave me a very nice response telling me what his preferred working
environment was. This pro
Great. Thanks Eike and Alan.
Josep M.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Hi Steven,
> Also, I'm a big believer in test-driven development. I must admit though I'm
> not so pedantic to write the tests first, but for anything except
> quick-and-dirty scripts, I make sure that *every* function in my program,
> without exception, has a test to ensure that it works correctl
Great. Thanks Marc, Steven and Alan for the enlightening answers. I
will certainly take your advice into account.
I work in many different computers and while I do most of my coding
(sounds as if I did a lot of coding, but I don't) on my desktop
computer at home I wanted to start doing it on my la
Alan gave me this piece of advice in his response to another message I
sent to the list. Since the topic is a bit different from the one in
the original message, I think it is better to start a different
thread.
> Don;t run your code inside the IDE except for testing. IDEs are
> Development Enviro
Thanks Alan and Emile,
>> By the way, I know what a lambda function is and I read about the key
>> parameter in sorted() but I don't understand very well what
>> "key=lambda item: item[1]" does.
...
>> What I don't understand is the syntax of "item : item[1]".
>
...
Alan says:
> So reverse eng
Martin, Alan, col speed and everybody that helped: I think I'm going
to stop because I'm repeating myself but it is difficult for me not to
be profuse in my thanks because you guys really go beyond the call of
duty. I love this list. The responses in this list most of the times
don't just address t
Thanks Alan, Peter and Steve,
Instead of answering each one of you independently let me try to use
my response to Steve's message as the basis for an answer to all of
you.
It turns out that matters of efficiency appear to be VERY important in
this case. The example in my message was a very short
Hi,
I'm trying to do something that should be very simple. I want to
generate a list of the words that appear in a document according to
their frequencies. So, the list generated by the script should be
something like this:
the : 3
book: 2
was : 2
read: 1
by: 1
[...]
This would be obtained from
>> Again, thanks a lot. Too bad you and Kushal don't live close. I would
>> like to invite you to a beer or a coffe or something.
>
> Thanks for the offer. Some time ever in the far, far future perhaps ;-).
Well, if you or the other people who have been so helpful to me in
this list ever happen to
Thanks Alan,
why is it better to open the output file outside the entire
>> loop.
>
> Because you only need to open it once and leave it open.
> You are opening it each and every time which is wasteful.
> It could on some OSDS also lead to problems. And if you
> were writing a new file rather tha
Hi Evert,
Again, thanks a lot. Too bad you and Kushal don't live close. I would
like to invite you to a beer or a coffe or something.
>>
>> - code
>> import os
>> path = '/Volumes/DATA/MyPath'
>> os.chdir(path)
>> file_names = glob.glob('*.txt')
>
> You don't use file_nam
Hi Kushal,
First of all, thanks a lot for your help.
>
> Your current code adds the marker line to the original files. Is that
> intended?
Well, no, this wasn't intended. The part of the code that did that was
introduced in one of the many attempts to solve the problem. I knew
that this was an
Hi,
I'm trying to create a script to do the following. I have a directory
containing hundreds of text files. I need to create a single file with
the contents of all the files in the directory. Within that file,
though, I need to create marks that indicate the division between the
contents of each
> The only time year is bound is in the previous loop, as I said. It's the
> line that goes:
> name, year = line.strip.
>
> So year is whatever it was the last time through that loop.
OK, this makes sense. Indeed that is the value in the last entry for
the dictionary. Thanks a lot again.
Hi Dave,
On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel wrote:
> (You top-posted, so I had to remove the out-of-order earlier portion.)
>
> I've not tried to run the code, but I think I can see the problem. Since
> you never assign 'year' inside the loop(s), it's always the same. And it's
> whatev
;. '1499' is not
even the value that would correspond to key 'A-01' which is the first
file in the directory according to the alphabetical order ('A-02', the
second file in the directory does correspond to value '1499', though).
So besides being able to expl
Hi,
As I said in another message with the heading "Using contents of a
document to change file names", I'm trying to learn Python "by doing"
and I was working on a little project where I had to change the names
of the files in a directory according to some codes contained in a CSV
file. With the h
Thanks Chris and Alan,
OK, I see. Now that I managed to build the dictionary, I did a print to
confirm that indeed the dictionary was created and it had the intended
contents and I was surprised to see that the order of the items in it was
totally changed. So the text file from which the dictionar
\n', 'A-02,1499\n', 'A-05,1449\n', 'A-06,1374\n', 'A-09,1449\n',
'B-01,1299\n', 'B-02,1299\n', 'B-06,1349\n'...]
That is, now I do get a list but as you can see I get the newline character
as part of each one of the stri
#x27;.txt'?
As you see, I am very green. My embarrassment at realizing how basic my
problems were made me delay writing another message but I decided that if I
don't do it, I will never learn.
Again, thanks so much for all your help.
Josep M.
> Message: 2
> Date: Sat, 2 Oct 201
Hi,
This is my first posting to this list. Perhaps this has a very easy answer
but before deciding to post this message I consulted a bunch of Python
manuals and on-line reference documents to no avail. I would be very
grateful if someone could lend me a hand with this.
Here's the problem I want
30 matches
Mail list logo