Piet van Oostrum wrote:
[snip]
Thanks for your detailed reply!
- Fencer
--
http://mail.python.org/mailman/listinfo/python-list
> Fencer (F) wrote:
>F> Also, notice the code I've commented out. If I can get the join above to
>F> work (with your help) my next question is how to present the known experts
>F> in a comma separated list with only expert_id and name? I can't use the
>F> normal __str__() method (the one I'm
MRAB wrote:
Try printing self.topics. It should always be a list of topics.
Ah, yes, that made me find a bug when I was creating the Expert objects:
the lists of known topics were not created properly. I should have
posted more code I suppose! Thanks for the help, this problem has now
been s
Fencer wrote:
jon rascal wrote:
You're turning your list into a string -- try this:
', '.join([str(x) for x in self.topics])
Thanks for your quick reply, unfortunately it didn't quite work for me.
Say topics contain two topics: polemics, and the parthenon I get this
output:
e2:Carla
Known t
>
> only the first topic is printed. If topics only contain a single topic I
> get this error:
> Traceback (most recent call last):
> File "C:\Users\fencer\workspace\Find Expert\src\find_expert.py", line 57,
> in
>print experts[1]
> File "C:\Users\fencer\workspace\Find Expert\src\find_expert
jon rascal wrote:
You're turning your list into a string -- try this:
', '.join([str(x) for x in self.topics])
Thanks for your quick reply, unfortunately it didn't quite work for me.
Say topics contain two topics: polemics, and the parthenon I get this
output:
e2:Carla
Known topics: t5:Polem
output += '\nKnown topics: %s' % (', '.join(str(self.topics)))
Your problem is here.
self.topics is a list of topic instances: but you're calling str() on the
list itself to turn the LIST itself into a string. Compare:
>>> x = [1,2,3]
>>> x
[1, 2, 3]
>>> str(x)
'[1, 2, 3]'
Now, after str(se
> def __str__(self):
> output = '%s:%s' % (self.expert_id, self.name)
> output += '\nKnown topics: %s' % (', '.join(str(self.topics)))
You're turning your list into a string -- try this:
', '.join([str(x) for x in self.topics])
--
http://mail.python.org/mailman/listinfo/python-list
Hello, I've written two classes. One class describes experts: experts
has a unique ID and a name. An expert knows topics and other experts. A
topic is described by my other class and includes a unique ID and a
name. Now I have a problem with the __str__ method in my Expert class:
def __str__(s
> If the string is only used to open a file, and never shown to the user,
> what you prefer is irrelevant, isn't it?
guess thats right..
> Back to your code, try this:
>
> from os.path import join, normpath
> folder = 'F:/brown/code/python/fgrp1'
> names = ['amber1.jpg', 'amber3.jpg', 'amy1.jpg
On Mar 7, 9:33 am, [EMAIL PROTECTED] wrote:
> On Mar 7, 9:12 am, nodrogbrown <[EMAIL PROTECTED]> wrote:
>
>
>
> > hi
> > i am using python on WinXP..i have a string 'folder ' that i want to
> > join to a set of imagefile names to create complete qualified names so
> > that i can create objects out
En Fri, 07 Mar 2008 13:12:13 -0200, nodrogbrown <[EMAIL PROTECTED]>
escribi�:
> i am using python on WinXP..i have a string 'folder ' that i want to
> join to a set of imagefile names to create complete qualified names so
> that i can create objects out of them
>
> folder='F:/brown/code/python/f
nodrogbrown wrote:
> hi
> i am using python on WinXP..i have a string 'folder ' that i want to
> join to a set of imagefile names to create complete qualified names so
> that i can create objects out of them
>
> folder='F:/brown/code/python/fgrp1'
> filenms=['amber1.jpg', 'amber3.jpg', 'amy1.jpg',
nodrogbrown wrote:
> hi
> i am using python on WinXP..i have a string 'folder ' that i want to
> join to a set of imagefile names to create complete qualified names so
> that i can create objects out of them
>
> folder='F:/brown/code/python/fgrp1'
> filenms=['amber1.jpg', 'amber3.jpg', 'amy1.jpg',
On Mar 7, 9:12 am, nodrogbrown <[EMAIL PROTECTED]> wrote:
> hi
> i am using python on WinXP..i have a string 'folder ' that i want to
> join to a set of imagefile names to create complete qualified names so
> that i can create objects out of them
>
> folder='F:/brown/code/python/fgrp1'
> filenms=['
hi
i am using python on WinXP..i have a string 'folder ' that i want to
join to a set of imagefile names to create complete qualified names so
that i can create objects out of them
folder='F:/brown/code/python/fgrp1'
filenms=['amber1.jpg', 'amber3.jpg', 'amy1.jpg', 'amy2.jpg']
filenameslist=[]
for
16 matches
Mail list logo