This is just a follow up from your help Chris. Everything worked
out beautifully. The method you suggested really cut down on the
script time and allowed me to reduce a lot of redundant areas.
Thanks again.
-DerekOn 6/9/05, Chris Lambacher <[EMAIL PROTECTED]> wrote:
You are probably going about
You are probably going about solving the problem from the wrong direction:
Try something like this, overly verbose variable names used on purpose:
regHours = context.getMainPrint();
#let a dictionary do the grouping for us
hours_to_libraries_dic = {}
for lib in regHours:
key = lib.Monday + l
Sorry for not being more clear. I'm using Zope to store the hours
of each library on the campus. The hours of each library will be
set on a basis of Monday - Friday. i.e. Monday for a specific library,
let's say Downtown Campus Library will stored as an attribute of 8am
- 9pm, in Zope, and each d
It is very unclear what you are trying to do. Why not explain what
you want the output to be. You will get better answers.
As a first stab at what you are doing wrong:
collect = item.Monday + item.Tuesday + item.Wednesday + item.Thursday
+ item.Friday + item.Saturday + item.Sunday
The above is
I've been un-triumphantly trying to get a list of mine to have no
repeats in it. First, I'm pulling attributes from Zope and forming a
list. Next, I'm pulling those same values and comparing them against
the same list and if the values equal each other and are not already in
the list, they appe
Steven Bethard <[EMAIL PROTECTED]> wrote:
...
> I have a list[1] of objects from which I need to remove duplicates. I
> have to maintain the list order though, so solutions like set(lst), etc.
> will not work for me. What are my options? So far, I can see:
I think the recipe by that subject
John Machin wrote:
So, just to remove ambiguity, WHICH one of the bunch should be
retained? Short answer: "the first seen" is what the proverbial "man in
the street" would expect
For my purposes, it doesn't matter which instance is retained and which
are removed, so yes, retaining the first one is
Francis Girard wrote:
> Hi,
>
> I think your last solution is not good unless your "list" is sorted
(in which
> case the solution is trivial) since you certainly do have to see all
the
> elements in the list before deciding that a given element is not a
duplicate.
> You have to exhaust the iterata
Francis Girard wrote:
I think your last solution is not good unless your "list" is sorted (in which
case the solution is trivial) since you certainly do have to see all the
elements in the list before deciding that a given element is not a duplicate.
You have to exhaust the iteratable before yie
Hi,
I think your last solution is not good unless your "list" is sorted (in which
case the solution is trivial) since you certainly do have to see all the
elements in the list before deciding that a given element is not a duplicate.
You have to exhaust the iteratable before yielding anything.
Steven Bethard wrote:
I'm sorry, I assume this has been discussed somewhere already, but I
found only a few hits in Google Groups... If you know where there's a
good summary, please feel free to direct me there.
I have a list[1] of objects from which I need to remove duplicates. I
have to mai
You could create a class based on a list which takes a list as
argument, like this:
-class uniquelist(list):
-def __init__(self, l):
-for item in l:
-self.append(item)
-
-def append(self, item):
-if item not in self:
-list.append(self, item)
-
-l = [1
Carl Banks wrote:
from itertools import *
[ x for (x,s) in izip(iterable,repeat(set()))
if (x not in s,s.add(x))[0] ]
Wow, that's evil! Pretty cool, but for the sake of readers of my code,
I think I'll have to opt against it. ;)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
Take a look at this recipe on ASPN:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297
I think it might help.
Larry Bates
Steven Bethard wrote:
I'm sorry, I assume this has been discussed somewhere already, but I
found only a few hits in Google Groups... If you know where there's a
g
You could do it with a class, like this, I guess it is a bit faster
than option 1, although I'm no connaisseur of python internals.
-class uniquelist(list):
-def __init__(self, l):
-for item in l:
-self.append(item)
-def append(self, item):
-if item not in s
Steven Bethard wrote:
> I'm sorry, I assume this has been discussed somewhere already, but I
> found only a few hits in Google Groups... If you know where there's
a
> good summary, please feel free to direct me there.
>
>
> I have a list[1] of objects from which I need to remove duplicates.
I
> h
I'm sorry, I assume this has been discussed somewhere already, but I
found only a few hits in Google Groups... If you know where there's a
good summary, please feel free to direct me there.
I have a list[1] of objects from which I need to remove duplicates. I
have to maintain the list order t
17 matches
Mail list logo