Re: Join strings - very simple Q. ERRATA

2007-03-25 Thread Paulo da Silva
Paulo da Silva escreveu:
> John Machin escreveu:
>> On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>> John Machin escreveu:
> ...
...

> knowledge. If you feel that it is a question that deserves the
> honour of your response, just do it. Write it on the stones and
> send them down to the common people :-) . ...
Should be read *ordinary* people. This is an error caused by language
differeneces where comum (pt) is ordinary (en) and ordinario (pt
relatively ofensive term) is common (en).
...
> 
> Yes, and also, as last resource, I could always consult an oracle
> somewhere in the ancient Greece, *come* back and unsubscribe this NG. :-)
> 

Regards.
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-25 Thread Gabriel Genellina
En Sun, 25 Mar 2007 15:31:46 -0300, Paulo da Silva  
<[EMAIL PROTECTED]> escribió:

> John Machin escreveu:
>> On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>>> John Machin escreveu:

>> [e.g. it's easy to miss the one line in the
>> "official" Python tutorial that refers to them] (3) why you were not
>> using obvious(?) methods to find out for yourself -- much faster than
>> posing a question on the newsgroup, and you don't have to face the
>> possibility of an impertinent response :-)
>
> That's the kind of answer I hate. Of course anyone could find an
> answer to any questions without posting them to this NG.

But knowing why you didn't follow all those "obvious" paths is valuable -  
it can be used to improve the documentation, so the next guy doesn't  
*have* to ask here.

> You could just type ",".join(L).
> Look at the time we are loosing!

It's not a loose at all...

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-25 Thread Paulo da Silva
John Machin escreveu:
> On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> John Machin escreveu:
..

> What was not obvious was (1) if you have been using Python for a
> while, how you managed to be unaware of str methods (2) if you are a
> newbie, how you managed to find out about the string module but not
> find out about str method

> 
This is a nice argument for perhaps a politician ...
I am not exactly a newbie if you talk about the time I have
been using Python but I have used it very few times and
sparsely in time. I have always used 'string' to do the
strings stuff. When I need a method, I just search the python
library manual index. Then I have a page with all string methods
available. This is why I knew 'string' and didn't know str.

>
> [e.g. it's easy to miss the one line in the
> "official" Python tutorial that refers to them] (3) why you were not
> using obvious(?) methods to find out for yourself -- much faster than
> posing a question on the newsgroup, and you don't have to face the
> possibility of an impertinent response :-)

That's the kind of answer I hate. Of course anyone could find an
answer to any questions without posting them to this NG.
Google, Python inumerous manuals, books, etc. So, why the NG existence?
The reason we post here is because sometimes it is easier,
or we wait for any further discussion on the subject or just
because we want it.
There are lots of people in this NG with different levels of
knowledge. If you feel that it is a question that deserves the
honour of your response, just do it. Write it on the stones and
send them down to the common people :-) . If not, just close your eyes
and let others respond. If the question does not deserve any response,
then the people will judge and will leave it unanswered.
...
...
> you could try:
> 
> (1) going to the docs page on the Python website (http://
> www.python.org/doc/), click on the "Search" link about one-third down
> the page, and search for "join". You would get 6 results, one of which
> is "join() (string method)"
This, together with the answer other people here gave, is helpful.
When I posted I thought the subjec was new, do you remember?
...

> (3) Use Google groups, go to comp.lang.python, type "join string" into
> the search box, and click on "Search this group". First result is the
> current thread; most (or maybe all) of the next six or so will give
> you the syntax your were looking for.
> 
> (4) Using Google or any other reasonable web searcher, search for the
> 3 words: Python join string. Any one of the first few hits gives the
> answer you were seeking.


Yes, and also, as last resource, I could always consult an oracle
somewhere in the ancient Greece, came back and unsubscribe this NG. :-)

You could just type ",".join(L).
Look at the time we are loosing!

Best regards.
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-25 Thread Paulo da Silva
Dustan escreveu:
> On Mar 24, 7:16 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Dustan escreveu:
>>
>>
>>
>>> On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
 Mike Kent escreveu:
 ...
> New way:
> l=['a','b','c']
> jl=','.join(l)
 I thank you all.
 Almost there ...
 I tried "".join(l,',') but no success ... :-(
 Paulo
>>> Perhaps you're doing it wrong, despite having an example right in
>>> front of you?
>> Some misunderstanding here ...
>> The post was just to thank. I was refering to what I tried
>> before posting the question here.
> 
> Ah. Sorry; I didn't realize that.

My fault. The post could well be read the way you did.
English is not my 1st language anyway.
Regards.
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Michael Bentley

On Mar 25, 2007, at 6:33 AM, Dennis Lee Bieber wrote:

> On Sat, 24 Mar 2007 10:53:20 +0200, "Hendrik van Rooyen"
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>>
>> What happened in 1850 to make it the demarcation line?
>>
>   Well... The Modified Julian Date zero is 17 November 1858

American Express is founded by Henry Wells & William Fargo on 18  
March 1850?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Alex Martelli
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:

>  "Steven D'Aprano" <[EMAIL PROTECTED]> wrote:
> 
> 
> > On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:
> > 
> > > OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> > > released. Where have you been in the last ~6.5 years?
> > 
> > Western civilization is 6,000 years old. Anything after 1850 is "new".
> > 
> > *wink*
> 
> another nibble:
> 
> What happened in 1850 to make it the demarcation line?

California became a US State.  A pretty good demarcation point, I'd say!


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Hendrik van Rooyen

 "Steven D'Aprano" <[EMAIL PROTECTED]> wrote:


> On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:
> 
> > OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> > released. Where have you been in the last ~6.5 years?
> 
> Western civilization is 6,000 years old. Anything after 1850 is "new".
> 
> *wink*

another nibble:

What happened in 1850 to make it the demarcation line?

I would have thought that the atom bomb round about 1945/6 would
be a crisper marker..

- Hendrik

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread John Machin
On Mar 25, 12:32 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> John Machin escreveu:
> ..
>
>
>
> > Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > | >>> help("".join)
> > Help on built-in function join:
>
> > join(...)
> > S.join(sequence) -> string
>
> > Return a string which is the concatenation of the strings in the
> > sequence.  The separator between elements is S.
>
> > | >>>
>
> > OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> > released. Where have you been in the last ~6.5 years?
>
> In a response to one of my posts I was told 'string' is
> obsolet. 'string' was enough for me, but if it is obsolet
> then there should be a *new* way, isn't it? The *new*
> way I was told to use is "str methods".
> I tried that *new* way to do *old* 'string' job.

So much was obvious from your post.

> Voila
> the reason of my so pertinent question.

What was not obvious was (1) if you have been using Python for a
while, how you managed to be unaware of str methods (2) if you are a
newbie, how you managed to find out about the string module but not
find out about str methods [e.g. it's easy to miss the one line in the
"official" Python tutorial that refers to them] (3) why you were not
using obvious(?) methods to find out for yourself -- much faster than
posing a question on the newsgroup, and you don't have to face the
possibility of an impertinent response :-)

> I am deeply sorry to have disturbed you in your python's heaven.

I wasn't disturbed at all (you would have to try much harder), only
mildly curious.

>
> Next time I'll read all books available, all texts including
> the python formal description before
> posting,

A rather strange way of finding an answer to a simple question. A
focussed search (or an index!) is more appropriate. Why would you
expect the python formal description to have details on the syntax of
individual class methods? Do you always do a serial scan of all tables
for any database query? In addition to approaches I mentioned earlier,
you could try:

(1) going to the docs page on the Python website (http://
www.python.org/doc/), click on the "Search" link about one-third down
the page, and search for "join". You would get 6 results, one of which
is "join() (string method)"

(2) If you are using Windows, use the index tab in the Python-supplied
docs gadget: type in "join" and get the same 6 results. I believe this
facility is available (through a 3rd party) on Linux. [Having the docs
on your PC or USB storage device is very useful if you are working in
an environment where access to the Internet is restricted].

(3) Use Google groups, go to comp.lang.python, type "join string" into
the search box, and click on "Search this group". First result is the
current thread; most (or maybe all) of the next six or so will give
you the syntax your were looking for.

(4) Using Google or any other reasonable web searcher, search for the
3 words: Python join string. Any one of the first few hits gives the
answer you were seeking.

HTH,
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Max Erickson
"7stud" <[EMAIL PROTECTED]> wrote:

> On Mar 24, 8:30 am, Duncan Booth <[EMAIL PROTECTED]>
> wrote: 
>> In case you are feeling that the ','.join(l) looks a bit
>> jarring, be aware that there are alternative ways to write it.
>> You can call the method on the class rather than the instance:
>>
>>jl = str.join(',', l)
>>jl = unicode.join(u'\u00d7', 'l')
>>
>>... the catch is you need to know
>> the type of the separator in advance.
> 
> When I try the latter example, I get an error:
> 
> lst = ["hello", "world"]
> print unicode.join(u"\u00d7", lst)
> 
> Traceback (most recent call last):
>   File "test1.py", line 2, in ?
> print unicode.join(u"\u00d7", lst)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xd7'
> in position 5: ordinal not in range(128)
> 

Your terminal is likely the problem. Get rid of the print:

q=unicode.join(u'\u00d7',['hello','world'])

and you will probably get rid of the exception.

(so I guess the issue is the display, not the logic)


max

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Duncan Booth
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

> 7stud schrieb:
>> When I try the latter example, I get an error:
>> 
>> lst = ["hello", "world"]
>> print unicode.join(u"\u00d7", lst)
>> 
>> Traceback (most recent call last):
>>   File "test1.py", line 2, in ?
>> print unicode.join(u"\u00d7", lst)
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xd7' in
>> position 5: ordinal not in range(128)
> 
> You are mixing unicode with bytestrings here. make "hello" u"hello", 
> same for "world".
> 
Sorry Diez, wrong answer. A unicode separator will cause all the strings 
being joined to be decoded using the default encoding (which could cause 
problems with non-ascii characters in the decoded strings), but the problem 
here is with encoding, not decoding.

7stud: the problem isn't the join, it is printing the string on your 
terminal which is the problem. Try just:

   print u"\u00d7"

and you'll get the same problem. Or:

 lst = ["hello", "world"]
 joined = unicode.join(u"\u00d7", lst)

will work, but you'll still have problems printing the result.

If you try it using a Python interpreter with an appropriate output 
encoding it will work (idle can handle it on my system, but the DOS prompt 
with its default codepage cannot).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Diez B. Roggisch
7stud schrieb:
> On Mar 24, 8:30 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
>> In case you are feeling that the ','.join(l) looks a bit jarring, be aware
>> that there are alternative ways to write it. You can call the method on the
>> class rather than the instance:
>>
>>jl = str.join(',', l)
>>jl = unicode.join(u'\u00d7', 'l')
>>
>> ... the catch is you need to know
>> the type of the separator in advance.
> 
> When I try the latter example, I get an error:
> 
> lst = ["hello", "world"]
> print unicode.join(u"\u00d7", lst)
> 
> Traceback (most recent call last):
>   File "test1.py", line 2, in ?
> print unicode.join(u"\u00d7", lst)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xd7' in
> position 5: ordinal not in range(128)

You are mixing unicode with bytestrings here. make "hello" u"hello", 
same for "world".

Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread 7stud
On Mar 24, 8:30 am, Duncan Booth <[EMAIL PROTECTED]> wrote:
> In case you are feeling that the ','.join(l) looks a bit jarring, be aware
> that there are alternative ways to write it. You can call the method on the
> class rather than the instance:
>
>jl = str.join(',', l)
>jl = unicode.join(u'\u00d7', 'l')
>
>... the catch is you need to know
> the type of the separator in advance.

When I try the latter example, I get an error:

lst = ["hello", "world"]
print unicode.join(u"\u00d7", lst)

Traceback (most recent call last):
  File "test1.py", line 2, in ?
print unicode.join(u"\u00d7", lst)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xd7' in
position 5: ordinal not in range(128)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Dustan
On Mar 24, 7:16 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Dustan escreveu:
>
>
>
> > On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> >> Mike Kent escreveu:
> >> ...
>
> >>> New way:
> >>> l=['a','b','c']
> >>> jl=','.join(l)
> >> I thank you all.
>
> >> Almost there ...
> >> I tried "".join(l,',') but no success ... :-(
>
> >> Paulo
>
> > Perhaps you're doing it wrong, despite having an example right in
> > front of you?
>
> Some misunderstanding here ...
> The post was just to thank. I was refering to what I tried
> before posting the question here.

Ah. Sorry; I didn't realize that.

> Regards
> Paulo


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Paulo da Silva
Steven D'Aprano escreveu:
> On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:
> 


> 
> Western civilization is 6,000 years old. 

After reading that post I wouldn't talk about
civilization, western or any other :-)

Regards.
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Paulo da Silva
Dustan escreveu:
> On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>> Mike Kent escreveu:
>> ...
>>
>>> New way:
>>> l=['a','b','c']
>>> jl=','.join(l)
>> I thank you all.
>>
>> Almost there ...
>> I tried "".join(l,',') but no success ... :-(
>>
>> Paulo
> 
> Perhaps you're doing it wrong, despite having an example right in
> front of you?

Some misunderstanding here ...
The post was just to thank. I was refering to what I tried
before posting the question here.

Regards
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Paulo da Silva
John Machin escreveu:
..

> Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> | >>> help("".join)
> Help on built-in function join:
> 
> join(...)
> S.join(sequence) -> string
> 
> Return a string which is the concatenation of the strings in the
> sequence.  The separator between elements is S.
> 
> | >>>
> 
> OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> released. Where have you been in the last ~6.5 years?

In a response to one of my posts I was told 'string' is
obsolet. 'string' was enough for me, but if it is obsolet
then there should be a *new* way, isn't it? The *new*
way I was told to use is "str methods".
I tried that *new* way to do *old* 'string' job. Voila
the reason of my so pertinent question.

I am deeply sorry to have disturbed you in your python's heaven.

Next time I'll read all books available, all texts including
the python formal description before
posting, or perhaps it would be better and more simple if you
just ignore my posts.

Bye.
Paulo

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Duncan Booth
"Dustan" <[EMAIL PROTECTED]> wrote:
> Perhaps you're doing it wrong, despite having an example right in
> front of you?
> 
> Side by side comparison:
> jl=string.join(l,',')
> jl=','.join(l)
> 
> The sequence is passed as an argument to the join method, and the
> delimiter is the string whose method is being called.
> 

In case you are feeling that the ','.join(l) looks a bit jarring, be aware 
that there are alternative ways to write it. You can call the method on the 
class rather than the instance:

   jl = str.join(',', l)
   jl = unicode.join(u'\u00d7', 'l')

has the advantage of looking almost the same as the string function except 
that the order of the arguments is reversed, the catch is you need to know 
the type of the separator in advance. If you have a lot of calls with the 
same separator then you can also save the method in an appropriately named 
variable:

   commaseparated = ','.join
   ...
   jl = commaseparated(l)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Shane Geiger

import string

def test_join(l):
   print "Joining with commas: ",  string.join(l,',')
   print "Joining with empty string:   ",  string.join(l,'')
   print "Joining same way, using another syntax:  ",  ''.join(l)
   print "Joining with the letter X:   ",  'X'.join(l)
   print "Joining with <-> ",  '<->'.join(l)

l = ['a','b','c']

test_join(l)


"""
Example output:

Joining with commas:  a,b,c
Joining with empty string:abc
Joining same way, using another syntax:   abc
Joining with the letter X:aXbXc
Joining with <->  a<->b<->c

"""






Dustan wrote:

On Mar 24, 5:59 am, "Dustan" <[EMAIL PROTECTED]> wrote:
  

On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:



Mike Kent escreveu:
...
  

New way:
l=['a','b','c']
jl=','.join(l)


I thank you all.
  
Almost there ...

I tried "".join(l,',') but no success ... :-(
  
Paulo
  

Perhaps you're doing it wrong, despite having an example right in
front of you?

Side by side comparison:
jl=string.join(l,',')
jl=','.join(l)

The sequence is passed as an argument to the join method, and the
delimiter is the string whose method is being called.



To further demonstrate (because I got a weird email that seemed to
think that my code didn't work):

  

import string
l = ['a','b','c']
string.join(l,',')


'a,b,c'
  

','.join(l)


'a,b,c'

  


--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Join strings - very simple Q.

2007-03-24 Thread Dustan
On Mar 24, 5:59 am, "Dustan" <[EMAIL PROTECTED]> wrote:
> On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
>
> > Mike Kent escreveu:
> > ...
>
> > > New way:
> > > l=['a','b','c']
> > > jl=','.join(l)
>
> > I thank you all.
>
> > Almost there ...
> > I tried "".join(l,',') but no success ... :-(
>
> > Paulo
>
> Perhaps you're doing it wrong, despite having an example right in
> front of you?
>
> Side by side comparison:
> jl=string.join(l,',')
> jl=','.join(l)
>
> The sequence is passed as an argument to the join method, and the
> delimiter is the string whose method is being called.

To further demonstrate (because I got a weird email that seemed to
think that my code didn't work):

>>> import string
>>> l = ['a','b','c']
>>> string.join(l,',')
'a,b,c'
>>> ','.join(l)
'a,b,c'

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-24 Thread Dustan
On Mar 23, 1:30 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Mike Kent escreveu:
> ...
>
> > New way:
> > l=['a','b','c']
> > jl=','.join(l)
>
> I thank you all.
>
> Almost there ...
> I tried "".join(l,',') but no success ... :-(
>
> Paulo

Perhaps you're doing it wrong, despite having an example right in
front of you?

Side by side comparison:
jl=string.join(l,',')
jl=','.join(l)

The sequence is passed as an argument to the join method, and the
delimiter is the string whose method is being called.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2007 13:15:29 -0700, John Machin wrote:

> OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
> released. Where have you been in the last ~6.5 years?

Western civilization is 6,000 years old. Anything after 1850 is "new".

*wink*



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread John Machin
On Mar 24, 5:37 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?
>

Self-help #1: reading the documentation: 
http://www.python.org/doc/2.0/lib/string-methods.html
?
Change "0" to "5" to get the latest released version -- which hasn't
changed the description of the join method AFAICT.

Self-help #2: help() at the interactive prompt:

Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
| >>> help("".join)
Help on built-in function join:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence.  The separator between elements is S.

| >>>

OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
released. Where have you been in the last ~6.5 years?

HTH,
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paulo da Silva
Mike Kent escreveu:
...

> New way:
> l=['a','b','c']
> jl=','.join(l)
> 

I thank you all.

Almost there ...
I tried "".join(l,',') but no success ... :-(

Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Daniel Nogradi
> > I was told in this NG that string is obsolet. I should use
> > str methods.
> >
> > So, how do I join a list of strings delimited by a given
> > char, let's say ','?
> >
> > Old way:
> >
> > l=['a','b','c']
> > jl=string.join(l,',')
> >
> > New way?
>
> Dunno if it's the "new way", but you can do: ''.join(l)

The OP wants the strings to be comma delimited:

jl=','.join(l)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paul Rudin
Paul Rudin <[EMAIL PROTECTED]> writes:

> Paulo da Silva <[EMAIL PROTECTED]> writes:
>
>> Hi!
>>
>> I was told in this NG that string is obsolet. I should use
>> str methods.
>>
>> So, how do I join a list of strings delimited by a given
>> char, let's say ','?
>>
>> Old way:
>>
>> l=['a','b','c']
>> jl=string.join(l,',')
>>
>> New way?
>
> Dunno if it's the "new way", but you can do: ''.join(l)

Err, sorry - missed the comma out - it should be: ','.join(l)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Mike Kent
On Mar 23, 2:37 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?
>
> Thanks
> Paulo

New way:
l=['a','b','c']
jl=','.join(l)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paul Rudin
Paulo da Silva <[EMAIL PROTECTED]> writes:

> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?

Dunno if it's the "new way", but you can do: ''.join(l)

-- 
http://mail.python.org/mailman/listinfo/python-list


Join strings - very simple Q.

2007-03-23 Thread Paulo da Silva
Hi!

I was told in this NG that string is obsolet. I should use
str methods.

So, how do I join a list of strings delimited by a given
char, let's say ','?

Old way:

l=['a','b','c']
jl=string.join(l,',')

New way?

Thanks
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list