For completeness I was close this is the working code.
def get_list_of_names(generator_arg):
name_set = set()
for name in generator_arg:
base = os.path.basename(name.name)
filename = os.path.splitext(base)[0]
name_set.add(filename)
return name_set
def data_att
On Wed, 4 Jan 2017 01:09 pm, Sayth Renshaw wrote:
> Untested as i wrote this in notepad at work but, if i first use the
> generator to create a set of filenames and then iterate it then call the
> generator anew to process file may work?
It "may" work. Or it "may not" work. It is hard to tell bec
On 04/01/17 02:10, Deborah Swanson wrote:
> Sayth Renshaw wrote, on January 03, 2017 5:36 PM
>>
>> So can I call the generator twice and receive the same file
>> twice in 2 for loops?
>>
>> Once to get the files name and the second to process?
>>
>> for file in rootobs:
>> base = os.path.b
Erik wrote, on January 03, 2017 5:26 PM
> Hi,
>
> On 04/01/17 01:12, Deborah Swanson wrote:
> > The main reason you might want to catch the StopIteration
> exception is
> > to do something else before your code simply stops running. If all
> > you're doing is run a generator til it's out of gas, an
Sayth Renshaw wrote, on January 03, 2017 5:36 PM
>
> So can I call the generator twice and receive the same file
> twice in 2 for loops?
>
> Once to get the files name and the second to process?
>
> for file in rootobs:
> base = os.path.basename(file.name)
> write_to = os.path.join
Sayth Renshaw wrote, on January 03, 2017 5:55 PM
>
> On Wednesday, 4 January 2017 12:36:10 UTC+11, Sayth Renshaw wrote:
> > So can I call the generator twice and receive the same file
> twice in 2
> > for loops?
> >
> > Once to get the files name and the second to process?
> >
> > for file in roo
Untested as i wrote this in notepad at work but, if i first use the generator
to create a set of filenames and then iterate it then call the generator anew
to process file may work?
Good idea or better available?
def get_list_of_names(generator_arg):
name_set = set()
for name in generat
Chris Angelico wrote, on January 03, 2017 3:35 PM
>
> On Wed, Jan 4, 2017 at 10:05 AM, Deborah Swanson
> wrote:
> > Ok, I learned how to use generators in Python 2.7.8, which may be
> > different from Python 3 for generators. But I learned from MIT's
> > online introduction to python course, and t
So can I call the generator twice and receive the same file twice in 2 for
loops?
Once to get the files name and the second to process?
for file in rootobs:
base = os.path.basename(file.name)
write_to = os.path.join("output", os.path.splitext(base)[0] + ".csv")
with open
Erik wrote, on January 03, 2017 3:53 PM
>
> On 03/01/17 23:05, Deborah Swanson wrote:
> > And yes, we usually used for loops for generators, unless you don't
> > know when the generator will be exhausted. As in this case,
> where the
> > number of files the generator can provide is unknown. Then
>
On Wednesday, 4 January 2017 12:36:10 UTC+11, Sayth Renshaw wrote:
> So can I call the generator twice and receive the same file twice in 2 for
loops?
>
> Once to get the files name and the second to process?
>
> for file in rootobs:
> base = os.path.basename(file.name)
> write_to
Hi,
On 04/01/17 01:12, Deborah Swanson wrote:
> The main reason you might want to catch the StopIteration exception is
> to do something else before your code simply stops running. If all
> you're doing is run a generator til it's out of gas, and that's all you
> want it to do, then there's no nee
Erik wrote, on January 03, 2017 3:45 PM
>
> Hi,
>
> On 03/01/17 22:14, Deborah Swanson wrote:
> > ...you have to create the generator object first and use it to call
> > the next function. And I really don't think you can use a
> generator as
> > your range in a for loop. So I'd use a 'while True',
On 03/01/17 23:05, Deborah Swanson wrote:
> And yes, we usually used for loops for generators, unless you don't know
> when the generator will be exhausted. As in this case, where the number
> of files the generator can provide is unknown. Then we used the while
> True, break on StopIteration metho
Hi,
On 03/01/17 22:14, Deborah Swanson wrote:
> ...you have to create the generator object first and use it to call the
> next function. And I really don't think you can use a generator as your
> range in a for loop. So I'd use a 'while True', and break out of the
> loop when you hit the StopItera
-Original Message-
From: Matt Wheeler [mailto:m...@funkyhat.org]
Sent: Tuesday, January 03, 2017 1:47 PM To: pyt...@deborahswanson.net; Sayth
Renshaw; python-list@python.org
Subject: Re: Screwing Up looping in Generator
On Tue, 3 Jan 2017 at 20:17 Deborah Swanson wrote:
> What
Chris Angelico wrote, on January 03, 2017 2:31 PM
>
> On Wed, Jan 4, 2017 at 8:19 AM, Deborah Swanson
> wrote:
> > while True:
> > try:
> > file = files.next()
> > except StopIteration:
> > break
>
> Small side point: Try to avoid calling a generator object's
> .next() method directly.
Terry Reedy
>
> On 1/3/2017 3:53 PM, Deborah Swanson wrote:
>
> >> I think you're expecting
> >>
> >>for file in rootobs
> >>
> >> to get the next yield for you from rootobs, but unless someone
> >> corrects me, I don't think you can expect a 'for' statement to do
> >> that. You need to have a
On Wed, Jan 4, 2017 at 10:05 AM, Deborah Swanson
wrote:
> Ok, I learned how to use generators in Python 2.7.8, which may be
> different from Python 3 for generators. But I learned from MIT's online
> introduction to python course, and they certainly seem to know python
> well. So what is the corre
On Wed, Jan 4, 2017 at 8:19 AM, Deborah Swanson
wrote:
> while True:
> try:
> file = files.next()
> except StopIteration:
> break
Small side point: Try to avoid calling a generator object's .next() method
directly. Normally, when you _do_ want to do this, you should be calling
next(
On 1/3/2017 3:53 PM, Deborah Swanson wrote:
>> I think you're expecting
>>
>> for file in rootobs
>>
>> to get the next yield for you from rootobs, but unless
>> someone corrects me, I don't think you can expect a 'for'
>> statement to do that. You need to have a 'next' statement
>> inside yo
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler wrote:
> range() is not part of the for syntax at all, it's completely separate, it
> simply returns an iterator which the for loop can use, like any other.
>
*iterable
--
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/pyt
On Tue, 3 Jan 2017 at 20:17 Deborah Swanson wrote:
> > What's the code for your generator? And I don't see where you
> > call 'next'.
>
> I think you're expecting
>
> for file in rootobs
>
> to get the next yield for you from rootobs, but unless someone corrects
> me, I don't think you ca
> > > Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> > > >
> > > > Hi
> > > >
> > > > This is simple, but its getting me confused.
> > > >
> > > > I have a csv writer that opens a file and loops each line of the
> > > > file for each file and then closes, writing one file.
> > > >
> > > > I wa
> > Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> > >
> > > Hi
> > >
> > > This is simple, but its getting me confused.
> > >
> > > I have a csv writer that opens a file and loops each line of the
> > > file for each file and then closes, writing one file.
> > >
> > > I want to alter the behav
Sayth Renshaw wrote, on January 03, 2017 6:54 AM
>
> Hi
>
> This is simple, but its getting me confused.
>
> I have a csv writer that opens a file and loops each line of
> the file for each file and then closes, writing one file.
>
> I want to alter the behaviour to be a written file for each
> inp
> Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> >
> > Hi
> >
> > This is simple, but its getting me confused.
> >
> > I have a csv writer that opens a file and loops each line of
> > the file for each file and then closes, writing one file.
> >
> > I want to alter the behaviour to be a written
For completeness I was close this is the working code.
def get_list_of_names(generator_arg):
name_set = set()
for name in generator_arg:
base = os.path.basename(name.name)
filename = os.path.splitext(base)[0]
name_set.add(filename)
return name_set
def data_att
On 04/01/17 02:10, Deborah Swanson wrote:
Sayth Renshaw wrote, on January 03, 2017 5:36 PM
So can I call the generator twice and receive the same file
twice in 2 for loops?
Once to get the files name and the second to process?
for file in rootobs:
base = os.path.basename(file.name)
On Wed, 4 Jan 2017 01:09 pm, Sayth Renshaw wrote:
> Untested as i wrote this in notepad at work but, if i first use the
> generator to create a set of filenames and then iterate it then call the
> generator anew to process file may work?
It "may" work. Or it "may not" work. It is hard to tell bec
Erik wrote, on January 03, 2017 5:26 PM
> Hi,
>
> On 04/01/17 01:12, Deborah Swanson wrote:
> > The main reason you might want to catch the StopIteration
> exception is
> > to do something else before your code simply stops running. If all
> > you're doing is run a generator til it's out of gas
Sayth Renshaw wrote, on January 03, 2017 5:55 PM
>
> On Wednesday, 4 January 2017 12:36:10 UTC+11, Sayth Renshaw wrote:
> > So can I call the generator twice and receive the same file
> twice in 2
> > for loops?
> >
> > Once to get the files name and the second to process?
> >
> > for file i
Untested as i wrote this in notepad at work but, if i first use the generator
to create a set of filenames and then iterate it then call the generator anew
to process file may work?
Good idea or better available?
def get_list_of_names(generator_arg):
name_set = set()
for name in generat
Sayth Renshaw wrote, on January 03, 2017 5:36 PM
>
> So can I call the generator twice and receive the same file
> twice in 2 for loops?
>
> Once to get the files name and the second to process?
>
> for file in rootobs:
> base = os.path.basename(file.name)
> write_to = os.pat
Chris Angelico wrote, on January 03, 2017 3:35 PM
>
> On Wed, Jan 4, 2017 at 10:05 AM, Deborah Swanson
> wrote:
> > Ok, I learned how to use generators in Python 2.7.8, which may be
> > different from Python 3 for generators. But I learned from MIT's
> > online introduction to python course, a
On Wednesday, 4 January 2017 12:36:10 UTC+11, Sayth Renshaw wrote:
> So can I call the generator twice and receive the same file twice in 2 for
> loops?
>
> Once to get the files name and the second to process?
>
> for file in rootobs:
> base = os.path.basename(file.name)
> w
So can I call the generator twice and receive the same file twice in 2 for
loops?
Once to get the files name and the second to process?
for file in rootobs:
base = os.path.basename(file.name)
write_to = os.path.join("output", os.path.splitext(base)[0] + ".csv")
with o
Hi,
On 04/01/17 01:12, Deborah Swanson wrote:
The main reason you might want to catch the StopIteration exception is
to do something else before your code simply stops running. If all
you're doing is run a generator til it's out of gas, and that's all you
want it to do, then there's no need to c
Erik wrote, on January 03, 2017 3:53 PM
>
> On 03/01/17 23:05, Deborah Swanson wrote:
> > And yes, we usually used for loops for generators, unless you don't
> > know when the generator will be exhausted. As in this case,
> where the
> > number of files the generator can provide is unknown. The
Erik wrote, on January 03, 2017 3:45 PM
>
> Hi,
>
> On 03/01/17 22:14, Deborah Swanson wrote:
> > ...you have to create the generator object first and use it to call
> > the next function. And I really don't think you can use a
> generator as
> > your range in a for loop. So I'd use a 'while T
On 03/01/17 23:05, Deborah Swanson wrote:
And yes, we usually used for loops for generators, unless you don't know
when the generator will be exhausted. As in this case, where the number
of files the generator can provide is unknown. Then we used the while
True, break on StopIteration method.
O
Hi,
On 03/01/17 22:14, Deborah Swanson wrote:
...you have to create the generator object first and use it to call the
next function. And I really don't think you can use a generator as your
range in a for loop. So I'd use a 'while True', and break out of the
loop when you hit the StopIteration e
On Wed, Jan 4, 2017 at 10:05 AM, Deborah Swanson
wrote:
> Ok, I learned how to use generators in Python 2.7.8, which may be
> different from Python 3 for generators. But I learned from MIT's online
> introduction to python course, and they certainly seem to know python
> well. So what is the corre
-Original Message-
From: Matt Wheeler [mailto:m...@funkyhat.org]
Sent: Tuesday, January 03, 2017 1:47 PM
To: pyt...@deborahswanson.net; Sayth Renshaw; python-list@python.org
Subject: Re: Screwing Up looping in Generator
On Tue, 3 Jan 2017 at 20:17 Deborah Swanson
wrote:
> Wha
Chris Angelico wrote, on January 03, 2017 2:31 PM
>
> On Wed, Jan 4, 2017 at 8:19 AM, Deborah Swanson
> wrote:
> > while True:
> > try:
> > file = files.next()
> > except StopIteration:
> > break
>
> Small side point: Try to avoid calling a generator object's
> .next() method direc
On Wed, Jan 4, 2017 at 8:19 AM, Deborah Swanson
wrote:
> while True:
> try:
> file = files.next()
> except StopIteration:
> break
Small side point: Try to avoid calling a generator object's .next()
method directly. Normally, when you _do_ want to do this, you should
be calling next(fi
Terry Reedy
>
> On 1/3/2017 3:53 PM, Deborah Swanson wrote:
>
> >> I think you're expecting
> >>
> >>for file in rootobs
> >>
> >> to get the next yield for you from rootobs, but unless someone
> >> corrects me, I don't think you can expect a 'for' statement to do
> >> that. You need to hav
On 1/3/2017 3:53 PM, Deborah Swanson wrote:
I think you're expecting
for file in rootobs
to get the next yield for you from rootobs, but unless
someone corrects me, I don't think you can expect a 'for'
statement to do that. You need to have a 'next' statement
inside your for loop to ge
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler wrote:
> range() is not part of the for syntax at all, it's completely separate, it
> simply returns an iterator which the for loop can use, like any other.
>
*iterable
--
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/pyt
On Tue, 3 Jan 2017 at 20:17 Deborah Swanson
wrote:
> > What's the code for your generator? And I don't see where you
> > call 'next'.
>
> I think you're expecting
>
> for file in rootobs
>
> to get the next yield for you from rootobs, but unless someone corrects
> me, I don't think you ca
> > > Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> > > >
> > > > Hi
> > > >
> > > > This is simple, but its getting me confused.
> > > >
> > > > I have a csv writer that opens a file and loops each line of the
> > > > file for each file and then closes, writing one file.
> > > >
> > > >
> > Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> > >
> > > Hi
> > >
> > > This is simple, but its getting me confused.
> > >
> > > I have a csv writer that opens a file and loops each line of the
> > > file for each file and then closes, writing one file.
> > >
> > > I want to alter the
> Sayth Renshaw wrote, on January 03, 2017 6:54 AM
> >
> > Hi
> >
> > This is simple, but its getting me confused.
> >
> > I have a csv writer that opens a file and loops each line of
> > the file for each file and then closes, writing one file.
> >
> > I want to alter the behaviour to be a wri
Sayth Renshaw wrote, on January 03, 2017 6:54 AM
>
> Hi
>
> This is simple, but its getting me confused.
>
> I have a csv writer that opens a file and loops each line of
> the file for each file and then closes, writing one file.
>
> I want to alter the behaviour to be a written file for each
Hi
This is simple, but its getting me confused.
I have a csv writer that opens a file and loops each line of the file for each
file and then closes, writing one file.
I want to alter the behaviour to be a written file for each input file. I saw a
roundrobin example however it failed for me as
55 matches
Mail list logo