On 09/09/2015 14:32, richard kappler wrote:
Yes, many questions today. I'm working on a data feed script that feeds
'events' into our test environment. In production, we monitor a camera that
captures an image as product passes by, gathers information such as
barcodes and package ID from the imag
On 09/09/15 15:29, richard kappler wrote:
Still not sure how to efficiently get the script to keep moving to the next
file in the directory though, in other words, for each iteration in the
loop, I want it to fetch, rename and send/save the next image in line. Hope
that brings better understandi
-0400
> > From: richkapp...@gmail.com
> > To: tutor@python.org
> > Subject: [Tutor] iterating through a directory
>
> >
> > Yes, many questions today. I'm working on a data feed script that feeds
> > 'events' into our test environment. In production,
> Date: Wed, 9 Sep 2015 09:32:34 -0400
> From: richkapp...@gmail.com
> To: tutor@python.org
> Subject: [Tutor] iterating through a directory
>
> Yes, many questions today. I'm working on a data feed script that feeds
> 'events' into our test environment. In
Yes, many questions today. I'm working on a data feed script that feeds
'events' into our test environment. In production, we monitor a camera that
captures an image as product passes by, gathers information such as
barcodes and package ID from the image, and then sends out the data as a
line of xm
Alan, Peter, et al:
Thank you all very much! Staring at this problem for hours was driving
me crazy and I am very appreciative for your guys' time in looking
into my silly error -- I have thoroughly reviewed both the responses
and it makes perfect sense (*sigh of relief*).
On Thu, Oct 2, 2014 a
John Doe wrote:
> Hello List,
> I am in need of your assistance. I have a text file with random words
> in it. I want to write all the lines to a new file. Additionally, I am
> using Python 2.7 on Ubuntu 12.04:
>
> Here is my code:
>
> def loop_extract():
> with open('words.txt', 'r') as f:
On 02/10/14 16:47, John Doe wrote:
def loop_extract():
with open('words.txt', 'r') as f:
for lines in f:
#print lines (I confirmed that each line is successfully printed)
with open('export.txt', 'w') as outf:
This opens and closes the file for each itera
Hello List,
I am in need of your assistance. I have a text file with random words
in it. I want to write all the lines to a new file. Additionally, I am
using Python 2.7 on Ubuntu 12.04:
Here is my code:
def loop_extract():
with open('words.txt', 'r') as f:
for lines in f:
On 05/02/13 22:27, Oscar Benjamin wrote:
On 5 February 2013 03:56, eryksun wrote:
On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel wrote:
Nope, in both Python 2 and 3 iterating over a dict directly just
provides the key. That's also how "if key in dict" works.
A dict implements __contains__ for a
On Tue, Feb 5, 2013 at 6:27 AM, Oscar Benjamin
wrote:
>
> I almost wrote this response but then I realised that Dave probably
> meant that "obj in dict" returns True if the dict has a key equal to
> obj rather than if the dict has a (key, value) pair equal to obj.
Thanks, that's probably what Ste
On 5 February 2013 03:56, eryksun wrote:
> On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel wrote:
>>> Nope, in both Python 2 and 3 iterating over a dict directly just
>>> provides the key. That's also how "if key in dict" works.
>
> A dict implements __contains__ for an efficient "in" test. In general
On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel wrote:
>> Nope, in both Python 2 and 3 iterating over a dict directly just
>> provides the key. That's also how "if key in dict" works.
A dict implements __contains__ for an efficient "in" test. In general,
the interpreter falls back to using iteration i
On 02/04/2013 06:18 PM, Steven D'Aprano wrote:
On 05/02/13 09:26, Dave Angel wrote:
Another point. I don't currently have Python 3.x installed, but I seem to
remember that in Python 3 you can use the dict itself as an iterator
providing both key and value. If I'm right, then it could be simplif
On 05/02/13 09:26, Dave Angel wrote:
Another point. I don't currently have Python 3.x installed, but I seem to
remember that in Python 3 you can use the dict itself as an iterator
providing both key and value. If I'm right, then it could be simplified
further to:
for i, (k, v) in enumerate(dat
On 02/04/2013 12:58 PM, Modulok wrote:
Hmm.. no kidding. Well, at least I knew I was over-complicating it.
Cheers!
-Modulok-
Please don't top-post.
Another point. I don't currently have Python 3.x installed, but I seem
to remember that in Python 3 you can use the dict itself as an iterator
Hmm.. no kidding. Well, at least I knew I was over-complicating it.
Cheers!
-Modulok-
On 2/4/13, Dave Angel wrote:
> On 02/04/2013 12:13 PM, Modulok wrote:
>> List,
>>
>> Simple question: Is there a common pattern for iterating a dict, but also
>> providing access to an iteration counter? Here'
On 02/04/2013 12:13 PM, Modulok wrote:
List,
Simple question: Is there a common pattern for iterating a dict, but also
providing access to an iteration counter? Here's what I usually do (below). I'm
just wondering if there are other, more clever ways::
data = {'a': "apple", 'b': "banana",
List,
Simple question: Is there a common pattern for iterating a dict, but also
providing access to an iteration counter? Here's what I usually do (below). I'm
just wondering if there are other, more clever ways::
data = {'a': "apple", 'b': "banana", 'c': "cherry"}
i = 0
for k,v in da
On 11/10/12 08:49, eryksun wrote:
Also, generally avoid mutating a list while iterating over it.
listiterator is just incrementing an index, so modifying the size of
the list can produce nonsense (e.g. if you remove the current item,
the next item will be skipped). Instead, create an empty list
On Wed, Oct 10, 2012 at 3:52 PM, Ed Owens wrote:
>
> import string
Why are you importing "string"? Most string functions one would need
are methods of str/unicode. Sometimes "string" is still required,
however.
> def add_element(items, point):
> items = items[:point+1][:] + [['new']] + items
On 10/10/2012 03:52 PM, Ed Owens wrote:
> I'm trying to iterate over a list of elements, and make changes to the list
> in front of the element I'm currently working with. I can update the list,
> but the 'for' doesn't see the new element. Here's the code:
>
> import string
>
> def add_element(
On 10/10/2012 20:52, Ed Owens wrote:
I'm trying to iterate over a list of elements, and make changes to the list
in front of the element I'm currently working with. I can update the list,
but the 'for' doesn't see the new element. Here's the code:
import string
def add_element(items, point)
I'm trying to iterate over a list of elements, and make changes to the list
in front of the element I'm currently working with. I can update the list,
but the 'for' doesn't see the new element. Here's the code:
import string
def add_element(items, point):
items = items[:point+1][:] + [['n
On Sat, Sep 4, 2010 at 6:16 AM, Steven D'Aprano wrote:
> On Sat, 4 Sep 2010 11:57:00 am David Hutto wrote:
>> First of all, I'll respond more thoroughly tomorrow, when I can
>> review what you said more clearly, but for now I'll clarify.
>>
>> Here is the whole code that I'm using:
>>
>> http://pa
Bill Allen wrote:
Thanks to everyone who replied. Some of the methods presented where some I
had thought of, others were new to me. Particularly, I did not realize I
could apply a slice to a list. The for x in some_stuff[:value] form worked
very well for my purposes. I can also see I need
Thanks to everyone who replied. Some of the methods presented where some I
had thought of, others were new to me. Particularly, I did not realize I
could apply a slice to a list. The for x in some_stuff[:value] form worked
very well for my purposes. I can also see I need to look into the ite
Bill Allen wrote:
Say I have and iterable called some_stuff which is thousands of items in
length and I am looping thru it as such:
for x in some_stuff
etc...
However, what if I want only to iterate through only the first ten items of
some_stuff, for testing purposes. Is there a concise
On Sun, 5 Sep 2010 03:14:24 am Bill Allen wrote:
> Say I have and iterable called some_stuff which is thousands of items
> in length and I am looping thru it as such:
>
> for x in some_stuff
> etc...
>
> However, what if I want only to iterate through only the first ten
> items of some_stuff,
On 04/09/2010 18:29, Sander Sweers wrote:
On 4 September 2010 19:25, Sander Sweers wrote:
for x in some_stuff:
if x<= 10:
print x
else:
break
Oops, corrected version...
count = 0
for x in some_stuff:
if count< 10:
print x
count +=1
else:
On 4 September 2010 19:25, Sander Sweers wrote:
> for x in some_stuff:
> if x <= 10:
> print x
> else:
> break
Oops, corrected version...
count = 0
for x in some_stuff:
if count < 10:
print x
count +=1
else:
break
Greets
Sander
___
On 4 September 2010 19:14, Bill Allen wrote:
> Say I have and iterable called some_stuff which is thousands of items in
> length and I am looping thru it as such:
>
> for x in some_stuff
> etc...
>
> However, what if I want only to iterate through only the first ten items of
> some_stuff, for
if its a dictionary, then I think you will need to use limit
if its normal array you can use range(0,10) and access some_stuff[i]
On Sat, Sep 4, 2010 at 10:44 PM, Bill Allen wrote:
> Say I have and iterable called some_stuff which is thousands of items in
> length and I am looping thru it as su
Say I have and iterable called some_stuff which is thousands of items in
length and I am looping thru it as such:
for x in some_stuff
etc...
However, what if I want only to iterate through only the first ten items of
some_stuff, for testing purposes. Is there a concise way of specifying tha
On Sat, 4 Sep 2010 11:57:00 am David Hutto wrote:
> First of all, I'll respond more thoroughly tomorrow, when I can
> review what you said more clearly, but for now I'll clarify.
>
> Here is the whole code that I'm using:
>
> http://pastebin.com/Ak8DFjrb
David, in genrandfiles() you say this:
snip
I'll go further with this though, just to get the response.
Hypothetically, if I wanted AI(artificial imagination),
then I would want random thoughts that made sense, every once in a
while. So, I hypothesize that the first step
in Artificial Imagination, is random thoughts, and then they have
On Fri, Sep 3, 2010 at 9:57 PM, David Hutto wrote:
> First of all, I'll respond more thoroughly tomorrow, when I can review
> what you said more clearly, but for now I'll clarify.
>
> Here is the whole code that I'm using:
>
> http://pastebin.com/Ak8DFjrb
>
> On Fri, Sep 3, 2010 at 9:12 PM, Steven
First of all, I'll respond more thoroughly tomorrow, when I can review
what you said more clearly, but for now I'll clarify.
Here is the whole code that I'm using:
http://pastebin.com/Ak8DFjrb
On Fri, Sep 3, 2010 at 9:12 PM, Steven D'Aprano wrote:
> On Fri, 3 Sep 2010 12:24:00 pm David Hutto wr
On Fri, 3 Sep 2010 12:24:00 pm David Hutto wrote:
> In the below function I'm trying to iterate over the lines in a
> textfile, and try to match with a regex pattern that iterates over
> the lines in a dictionary(not {}, but turns a text list of
> alphabetical words into a list using readlines()).
On Fri, Sep 3, 2010 at 2:51 PM, David Hutto wrote:
> On Thu, Sep 2, 2010 at 11:05 PM, David Hutto wrote:
>> I just added +'*' to select in re.search(select+'*', str(readfile[:])),
>> and it now shows the same in both.
>>
>> But if you have any input on modifications let me know.
>>
>> Thanks,
>>
On Thu, Sep 2, 2010 at 11:05 PM, David Hutto wrote:
> I just added +'*' to select in re.search(select+'*', str(readfile[:])),
> and it now shows the same in both.
>
> But if you have any input on modifications let me know.
>
> Thanks,
> David
>
Still a problem. When I use the re.search(select+'*'
I just added +'*' to select in re.search(select+'*', str(readfile[:])),
and it now shows the same in both.
But if you have any input on modifications let me know.
Thanks,
David
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscriptio
In the below function I'm trying to iterate over the lines in a textfile,
and try to match with a regex pattern that iterates over the lines in
a dictionary(not {}, but turns a text list of alphabetical words into a
list using readlines()).
def regexfiles(filename):
textfile = file(filenam
On 03/05/10 06:16, Thomas C. Hicks wrote:
I am using Python 2.6.4 in Ubuntu. Since I use Ubuntu (with its every
6 months updates) and want to learn Python I have been working on a
post-install script that would get my Ubuntu system up and running with
my favorite packages quickly.
As an aside,
Wow, this is great! I appreciate all the pointers, lots to keep
learning here.
thomas
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
> Agreed that
>
> line = line[:line.index('%')]
>
> is slightly more readable than
>
>line = line.split('%', 1)[0]
How about:
line = line.partition('%')[0]
partition() works even if '%' isn't present.
The index() and split() techniques raise exceptions if '%' isn't
present.
Malcolm
__
On Mon, 03 May 2010 13:08:18 +0200
Stefan Behnel wrote:
> > Why aren't strings mutable, or lists immutable?
>
> What would be the use case of an immutable list, as opposed to a tuple? How
> would you use mutable strings in a dictionary?
[I'm not totally sure of the following, take it with so
On Mon, 3 May 2010 08:18:41 pm Luke Paireepinart wrote:
> On Mon, May 3, 2010 at 3:50 AM, Stefan Behnel
wrote:
> > Luke Paireepinart, 03.05.2010 10:27:
> >> What's this bizarre syntax?
> >
> > Look it up in the docs, it's called "with statement". Its purpose
> > here is to make sure the file is c
Luke Paireepinart, 03.05.2010 12:18:
On Mon, May 3, 2010 at 3:50 AM, Stefan Behnel wrote:
Luke Paireepinart, 03.05.2010 10:27:
I thought they changed for loop interations so that if you did
for line in open('packages.txt'):
etc...
it would automatically close the file handle after th
2010/5/3 spir ☣ :
> On Mon, 03 May 2010 10:55:11 +0200
> Stefan Behnel wrote:
>
>> Luke Paireepinart, 03.05.2010 10:27:
>> > On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
>> >> line = line.split('%', 1)[0]
>> >
>> > lines = [line[:line.index('%')] for line in ...
>>
>> Agree
On Mon, 3 May 2010 05:35:52 pm Andre Engels wrote:
> Don't change the list that you are iterating over. As you have found,
> it leads to (to most) unexpected results.
Or if you absolutely have to change the list in place, iterate over it
*backwards* (starting at the end, and moving towards the
On Mon, 03 May 2010 10:55:11 +0200
Stefan Behnel wrote:
> Luke Paireepinart, 03.05.2010 10:27:
> > On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
> >> line = line.split('%', 1)[0]
> >
> > lines = [line[:line.index('%')] for line in ...
>
> Agreed that
>
> line = line[
On Mon, May 3, 2010 at 3:50 AM, Stefan Behnel wrote:
> Luke Paireepinart, 03.05.2010 10:27:
>> What's this bizarre syntax?
>
> Look it up in the docs, it's called "with statement". Its purpose here is to
> make sure the file is closed after the execution of the statement's body,
> regardless of an
Luke Paireepinart, 03.05.2010 10:27:
On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
line = line.split('%', 1)[0]
lines = [line[:line.index('%')] for line in ...
Agreed that
line = line[:line.index('%')]
is slightly more readable than
line = line.split('%', 1)
Luke Paireepinart, 03.05.2010 10:27:
On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
You are modifying the list during iteration, so the size changes and the
iterator gets diverted. Don't remove the line, just skip over it, e.g.
def read_package_names(open_text_file):
"""Read
On Mon, May 3, 2010 at 10:19 AM, Luke Paireepinart
wrote:
> Hmm, why not
> lines = [line for line in lines if not line.strip().startswith('%')]
I knew I missed something
--
André Engels, andreeng...@gmail.com
___
Tutor maillist - Tutor@python.
On Mon, May 3, 2010 at 1:49 AM, Stefan Behnel wrote:
>
> You are modifying the list during iteration, so the size changes and the
> iterator gets diverted. Don't remove the line, just skip over it, e.g.
>
> def read_package_names(open_text_file):
> """Read lines, strip any comments and r
> If that looks a bit clumsy, use a generator expression:
>
> linesToDelete = [x for x in lines if x.startswith('%')]
> for x in linesToDelete:
> lines.remove(x)
>
> which idiomatically should probably become:
>
> for x in [y for y in lines if y.startswith('%')]:
> lines.remove(x)
>
>
Hmm, why
On Mon, May 3, 2010 at 7:16 AM, Thomas C. Hicks wrote:
> I am using Python 2.6.4 in Ubuntu. Since I use Ubuntu (with its every
> 6 months updates) and want to learn Python I have been working on a
> post-install script that would get my Ubuntu system up and running with
> my favorite packages qui
Thomas C. Hicks, 03.05.2010 07:16:
%Comment introducing the next block of packages
%Below are the packages for using Chinese on the system
%Third line of comment because I am a verbose guy!
ibus-pinyin
ibus-table-wubi
language-pack-zh-hans
etc.
I read the lines of the file into a list for proce
I am using Python 2.6.4 in Ubuntu. Since I use Ubuntu (with its every
6 months updates) and want to learn Python I have been working on a
post-install script that would get my Ubuntu system up and running with
my favorite packages quickly. Basically the script reads a text file,
processes the lin
2009/11/28 Wayne Werner :
>
>
> On Sat, Nov 28, 2009 at 6:59 AM, Dave Angel wrote:
>>
>> And if the lists are large, use itertools.izip() which works the same,
>> but produces an iterator.
>>
>> Note that if the lists are not the same length, I think it stops when the
>> shorter one ends.
>
> But
On Sat, Nov 28, 2009 at 6:59 AM, Dave Angel wrote:
>
> And if the lists are large, use itertools.izip() which works the same, but
> produces an iterator.
>
> Note that if the lists are not the same length, I think it stops when the
> shorter one ends.
>
But you can use izip_longest:
import ite
Jose Amoreira wrote:
Hi!
I want to process corresponding elements of two lists, sequentially. Call the
lists list1 and list2, and assume they have equal lengths. I can do something
like
for index in range(len(list1)):
process(list1[index], list2[index])
But I find it somehow rather ugly,
On 11/28/2009 10:03 PM, Jose Amoreira wrote:
Yes, Robert, that does it! Thanks a lot!
Have a nice weekend!
Jose
don't forget zip() built-in function:
for x, y in zip(list1, list2):
print x, y
___
Tutor maillist - Tutor@python.org
To unsubscrib
Hi!
I want to process corresponding elements of two lists, sequentially. Call
the
lists list1 and list2, and assume they have equal lengths. I can do
something
like
for index in range(len(list1)):
process(list1[index], list2[index])
But I find it somehow rather ugly, because we generate yet
Yes, Robert, that does it! Thanks a lot!
Have a nice weekend!
Jose
On Saturday 28 November 2009 10:54:56 am Robert Johansson wrote:
> Hi!
> I want to process corresponding elements of two lists, sequentially. Call
> the
> lists list1 and list2, and assume they have equal lengths. I can do
> someth
Hi!
I want to process corresponding elements of two lists, sequentially. Call the
lists list1 and list2, and assume they have equal lengths. I can do something
like
for index in range(len(list1)):
process(list1[index], list2[index])
But I find it somehow rather ugly, because we generate yet
"GoodPotatoes" wrote
print page1.readlines()
From this excercise, the first time I read page1 I get all of the lines.
The best thing to do is store them in a variable then print them.
That way you can access them at will:
lines = page1.readlines()
print lines # all of them as a list
pr
GoodPotatoes wrote:
I'm not sure if I've been searching using the correct terms. After
I've iterated through an object, such as a cursor or webpage, how do I
get back to the "top"?
e.g.
tutorial from http://www.daniweb.com/code/snippet563.html#
print page1.readlines()
Capture the lines in
I'm not sure if I've been searching using the correct terms. After I've
iterated through an object, such as a cursor or webpage, how do I get back to
the "top"?
e.g.
tutorial from http://www.daniweb.com/code/snippet563.html#
print page1.readlines()
>From this excercise, the first time I read
Robert Berman wrote:
Thank you, Christian. This solution was one I was not expecting and am
glad to receive it. It is one I will explore in greater detail later.
Robert
On Wed, 2009-05-20 at 16:44 +0200, Christian Witts wrote:
Robert Berman wrote:
Hi,
Given a list of options: optio
On Wed, May 20, 2009 at 10:02:22AM -0400, Robert Berman wrote:
>
>Hi,
>Given a list of options: option_1...option_n. For each option I
>have a corresponding function: func_1. func_n. I have all function
>names defined in a list similar to flist = [func_1,
>func_2,..
Hi,
Given a list of options: option_1...option_n. For each option I have
a corresponding function: func_1. func_n. I have all function names
defined in a list similar to flist = [func_1, func_2,...func_n]
which I know is a legitimate construct having found a similar construct
discusse
> understand exactly what you are saying and what you are advocating.
> The 'dictionary of functions' is the 'best' approach because of simplicity
> and because it minimizes chances or errors.
Correct. Maintaining synch of indexes between two arrays of data items
is always going to be a risky b
Le Wed, 20 May 2009 10:25:21 -0400,
Robert Berman s'exprima ainsi:
> What I do not know how to do is to call the selected function.
If you have options and functions "hard-coded" in lists (or if you get them
from outside), you can still let python build a dict for you, using "zip":
l1 = [1,2,3
Alan,
The emphasis of your reply certainly makes me look at the dictionary
solution as the most 'correct' solution to utilize. Before I change the
code I just implemented, let me make sure I understand exactly what you
are saying and what you are advocating. The 'dictionary of functions' is
the 'b
"Robert Berman" wrote
Thank you, Christian. This solution was one I was not expecting and am
glad to receive it. It is one I will explore in greater detail later.
A dictionary of functions is the most common way to tackle
this fairly common requirement. It combines readability with
ease of
Thank you, Christian. This solution was one I was not expecting and am
glad to receive it. It is one I will explore in greater detail later.
Robert
On Wed, 2009-05-20 at 16:44 +0200, Christian Witts wrote:
> Robert Berman wrote:
> > Hi,
> >
> > Given a list of options: option_1...option_n. F
Thank you, Emile.
That is the exact answer I needed.
Robert
On Wed, 2009-05-20 at 07:48 -0700, Emile van Sebille wrote:
> On 5/20/2009 7:25 AM Robert Berman said...
> > Hi,
> >
> > Given a list of options: option_1...option_n. For each option I have
> > a corresponding function: func_1...
On 5/20/2009 7:25 AM Robert Berman said...
Hi,
Given a list of options: option_1...option_n. For each option I have
a corresponding function: func_1. func_n. I have all function names
defined in a list similar to flist = [func_1, func_2,...func_n]
which I know is a legitimate constru
Robert Berman wrote:
Hi,
Given a list of options: option_1...option_n. For each option I have
a corresponding function: func_1. func_n. I have all function names
defined in a list similar to flist = [func_1, func_2,...func_n]
which I know is a legitimate construct having found a simi
Robert Berman wrote:
Hi,
Given a list of options: option_1...option_n. For each option I have
a corresponding function: func_1. func_n. I have all function names
defined in a list similar to flist = [func_1, func_2,...func_n]
which I know is a legitimate construct having found a simi
Hi,
Given a list of options: option_1...option_n. For each option I have
a corresponding function: func_1. func_n. I have all function names
defined in a list similar to flist = [func_1, func_2,...func_n]
which I know is a legitimate construct having found a similar construct
discusse
"Paul McGuire" wrote
For much of my own code, I find lists of string literals to be tedious to
enter, and easy to drop a ' character. This style is a little easier on
the
eyes, and harder to screw up.
'case_def_gen':['case_def gen null'.split()],
'nsuff_fem_pl':['nsuff null null'.split()],
Original:
'case_def_gen':['case_def','gen','null'],
'nsuff_fem_pl':['nsuff','null', 'null'],
'abbrev': ['abbrev, null, null'],
'adj': ['adj, null, null'],
'adv': ['adv, null, null'],}
Note the values for 'abbrev', 'adj' and 'adv' are not lists, but strings
containing comma-separated lists.
S
Le Mon, 4 May 2009 10:15:35 -0400,
Dan Liang s'exprima ainsi:
> Hi Spir and tutors,
>
> Thank you Spir for your response. I went ahead and tried your code after
> adding a couple of dictionary entries, as below:
> ---Code Begins---
> #!usr/bin/python
>
> tags = {
>
>
> 'c
"Dan Liang" wrote
def replaceTagging(source_name, target_name):
source_file = file(source_name, 'r')
source = source_file.read() # not really necessary
this reads the entire file as a string
target_file = open(target_name, "w")
# replacement loop
for li
ine 16, in newlyTaggedWord
(word,tag) = line.split(TAB)# separate parts of line, keeping data
only
ValueError: unpack list of wrong size
---Error Ends---
Any ideas?
Thank you!
--dan
From: Dan Liang
Subject: [Tutor] Iterating over a long list with regular expressions
Le Sun, 3 May 2009 21:59:23 -0400,
Dan Liang s'exprima ainsi:
> Hi tutors,
>
> I am working on a file and need to replace each occurrence of a certain
> label (part of speech tag in this case) by a number of sub-labels. The file
> has the following format:
>
> word1 \tTag1
> word2 \tT
Hi tutors,
I am working on a file and need to replace each occurrence of a certain
label (part of speech tag in this case) by a number of sub-labels. The file
has the following format:
word1 \tTag1
word2 \tTag2
word3 \tTag3
Now the tags are complex and I wanted to split them in a
On Wed, Mar 18, 2009 at 5:26 PM, Alexander Daychilde (Gmail)
wrote:
> exp_list = []
>
> exp_range = exp.split(":")
>
> min_padding = len(exp_range[0])
>
> for i in range(int(exp_range[0]),(int(exp_range[1])+1)):
>
> exp_list.append('%0*d' % (min_padding, i))
This could be a little cleaner usi
2009/3/19 Alexander Daychilde (Gmail) :
> That creates a list of numbers. I also need to do letters. That is, treat
> a-z as base 26, and do the same thing. The three examples I gave from before
> would be:
> 1:9 --> a:z
> 1:99 --> a:zz
> 01:99 -- no "zero" in alpha to worry ab
Title: Signature.html
It looks like you used the wrong thread to post this. It's connected to
questions about linux and Win, and not iterations.
Alexander Daychilde (Gmail) wrote:
If there's an easy way to do this, I'd like to have a pointer to it (i.e.
what functions would deal with this -
If there's an easy way to do this, I'd like to have a pointer to it (i.e.
what functions would deal with this - not wanting my code written for me...)
Right now, I have written code to generate a list of strings that happen to
be a range of numbers. (The fact that they're strings is actually desir
On Fri, Oct 10, 2008 at 10:59 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 10, 2008 at 10:45 PM, S Potter <[EMAIL PROTECTED]> wrote:
>
>> poem ={ ['roses','are red'],
>> ['violets','are blue'],
>> ['sugar','are sweet']
>> ['so','are you'] }
An
On Fri, Oct 10, 2008 at 10:45 PM, S Potter <[EMAIL PROTECTED]> wrote:
> OK I'm still new to the python list / array deal. I'm having problems with
> something very simple that I could accomplish in C++ but
> for some reason I'm not grasping it python.
>
> Here is my example psuedo code:
>
> I have
OK I'm still new to the python list / array deal. I'm having problems with
something very simple that I could accomplish in C++ but
for some reason I'm not grasping it python.
Here is my example psuedo code:
I have two lists:
items = ['roses','violets','sugar','so']
and
attributes = ['red','b
On Thu, Aug 7, 2008 at 12:42 AM, Shrutarshi Basu <[EMAIL PROTECTED]>wrote:
> If you're just going to be using numbers as dictionary keys, it might
> be simpler just to use a list structure. Dictionaries don't preserve
> order, so you'd need to write extra code if you ever need to iterate
> over it
If you're just going to be using numbers as dictionary keys, it might
be simpler just to use a list structure. Dictionaries don't preserve
order, so you'd need to write extra code if you ever need to iterate
over it in order. Since your code increments field everytime it gets a
new record you can j
1 - 100 of 157 matches
Mail list logo