Re: More questions on Python strings

2014-08-31 Thread Peter Otten
MRAB wrote: > On 2014-08-31 18:37, Dennis E. Evans wrote: >> >>Hi >> >> I have a function that reads some meta data from a database and builds a >> default order by and where clause for a table. >>Is the a way to build the strings with out using the intermediate >>list? >> >>the e

Re: More questions on Python strings

2014-08-31 Thread MRAB
On 2014-08-31 18:37, Dennis E. Evans wrote: Hi I have a function that reads some meta data from a database and builds a default order by and where clause for a table. some details, rows is a list of pyOdbc.Row and will look like this [1, 'ColumnName', 3, 5] there will be one to n el

More questions on Python strings

2014-08-31 Thread Dennis E. Evans
Hi I have a function that reads some meta data from a database and builds a default order by and where clause for a table. some details, rows is a list of pyOdbc.Row and will look like this [1, 'ColumnName', 3, 5] there will be one to n elements EmptyString, defaultColumn, default

Re: python strings and {} in Tkinter entry widgets

2010-08-16 Thread Chris Hare
On Aug 16, 2010, at 11:40 AM, Jeff Hobbs wrote: > On Aug 15, 4:41 pm, Chris Hare wrote: >> I have some code that pulls a value from a database. In this case, it is >> three space delimited words. When I display the value in a Tkinter.Entry >> widget, the text has curly braces around it, even

Re: python strings and {} in Tkinter entry widgets

2010-08-16 Thread Jeff Hobbs
On Aug 15, 4:41 pm, Chris Hare wrote: > I have some code that pulls a value from a database.  In this case, it is > three space delimited words.  When I display the value in a Tkinter.Entry > widget, the text has curly braces around it, even when there are none in the > surrounding the text in

python strings and {} in Tkinter entry widgets

2010-08-15 Thread Chris Hare
I have some code that pulls a value from a database. In this case, it is three space delimited words. When I display the value in a Tkinter.Entry widget, the text has curly braces around it, even when there are none in the surrounding the text in the database. Is this normal, and how do I pr

Re: Python strings and coding conventions

2009-01-11 Thread John Machin
On Jan 12, 8:23 am, Mensanator wrote: > On Jan 11, 2:37 pm, John Machin wrote: > > > > > > > On Jan 12, 5:34 am, Mensanator wrote: > > > > On Jan 11, 12:12 pm, Roy Smith wrote: > > > > > In article > > > > <5db6181f-d6f6-4bdc-88c8-e12ad228c...@r41g2000prr.googlegroups.com>, > > > > > Mensanator

Re: Python strings and coding conventions

2009-01-11 Thread Mensanator
On Jan 11, 2:37�pm, John Machin wrote: > On Jan 12, 5:34�am, Mensanator wrote: > > > > > > > On Jan 11, 12:12 pm, Roy Smith wrote: > > > > In article > > > <5db6181f-d6f6-4bdc-88c8-e12ad228c...@r41g2000prr.googlegroups.com>, > > > > Mensanator wrote: > > > > > What are all those line continuati

Re: Python strings and coding conventions

2009-01-11 Thread John Machin
On Jan 12, 5:34 am, Mensanator wrote: > On Jan 11, 12:12 pm, Roy Smith wrote: > > > > > > > In article > > <5db6181f-d6f6-4bdc-88c8-e12ad228c...@r41g2000prr.googlegroups.com>, > > > Mensanator wrote: > > > > What are all those line continuation characters ('\') for? ?You are > > > > aware > > >

Re: Python strings and coding conventions

2009-01-11 Thread Mensanator
On Jan 11, 12:12�pm, Roy Smith wrote: > In article > <5db6181f-d6f6-4bdc-88c8-e12ad228c...@r41g2000prr.googlegroups.com>, > > �Mensanator wrote: > > > What are all those line continuation characters ('\') for? ?You are aware > > > that they are unnecessary here? > > > Actually, I wasn't aware of

Re: Python strings and coding conventions

2009-01-11 Thread Roy Smith
In article <5db6181f-d6f6-4bdc-88c8-e12ad228c...@r41g2000prr.googlegroups.com>, Mensanator wrote: > > What are all those line continuation characters ('\') for? ?You are aware > > that they are unnecessary here? > > Actually, I wasn't aware of that. A quick review shows > why. In the old manua

Re: Python strings and coding conventions

2009-01-11 Thread Mensanator
On Jan 11, 3:56�am, Marc 'BlackJack' Rintsch wrote: > On Sat, 10 Jan 2009 20:48:21 -0800, Mensanator wrote: > > Damn! I didn't know you could do that! And if I saw it in a program > > listing, such would never occur to me. I was going to suggest the stupid > > way: > > ga = ['four score and s

Re: Python strings and coding conventions

2009-01-11 Thread MRAB
koranth...@gmail.com wrote: On Jan 11, 9:26 am, Robert Kern wrote: koranth...@gmail.com wrote: Hi, Python Coding Convention (PEP 8) suggests : Maximum Line Length Limit all lines to a maximum of 79 characters. I have a string which is ~110 char long. It is a string which I am going

Re: Python strings and coding conventions

2009-01-11 Thread Steve Holden
Mensanator wrote: > On Jan 10, 10:26�pm, Robert Kern wrote: >> koranth...@gmail.com wrote: >>> Hi, >>> � �Python Coding Convention (PEP 8) suggests : >>> � Maximum Line Length >>> � � Limit all lines to a maximum of 79 characters. >>> � I have a string which is ~110 char long. It is a string which

Re: Python strings and coding conventions

2009-01-11 Thread Ben Finney
Robert Kern writes: > I usually use implicit concatenation: > > s = ('some long text that ' > 'needs to be split') I do something very similar: fleebnorg.spam = ( 'some long text that' ' needs to be split') The differences are: I prefer to have indents as 4 spaces no

Re: Python strings and coding conventions

2009-01-11 Thread Marc 'BlackJack' Rintsch
On Sat, 10 Jan 2009 20:48:21 -0800, Mensanator wrote: > Damn! I didn't know you could do that! And if I saw it in a program > listing, such would never occur to me. I was going to suggest the stupid > way: > ga = ['four score and seven years ago ', \ > 'our fathers brought forth ',

Re: Python strings and coding conventions

2009-01-10 Thread koranthala
On Jan 11, 9:26 am, Robert Kern wrote: > koranth...@gmail.com wrote: > > Hi, > >    Python Coding Convention (PEP 8) suggests : > >   Maximum Line Length > > >     Limit all lines to a maximum of 79 characters. > > >   I have a string which is ~110 char long. It is a string which I am > > going to

Re: Python strings and coding conventions

2009-01-10 Thread Mensanator
On Jan 10, 10:26�pm, Robert Kern wrote: > koranth...@gmail.com wrote: > > Hi, > > � �Python Coding Convention (PEP 8) suggests : > > � Maximum Line Length > > > � � Limit all lines to a maximum of 79 characters. > > > � I have a string which is ~110 char long. It is a string which I am > > going t

Re: Python strings and coding conventions

2009-01-10 Thread Robert Kern
koranth...@gmail.com wrote: Hi, Python Coding Convention (PEP 8) suggests : Maximum Line Length Limit all lines to a maximum of 79 characters. I have a string which is ~110 char long. It is a string which I am going to print in a text file as a single string. i.e. in that text file

Python strings and coding conventions

2009-01-10 Thread koranthala
Hi, Python Coding Convention (PEP 8) suggests : Maximum Line Length Limit all lines to a maximum of 79 characters. I have a string which is ~110 char long. It is a string which I am going to print in a text file as a single string. i.e. in that text file, each line is taken as a diff

Re: Python strings question (vertical stack)

2007-11-20 Thread J. Clifford Dyer
On Tue, 2007-11-20 at 13:59 -0800, John Machin wrote: > On Nov 21, 7:15 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote: > > J. Clifford Dyer wrote: > > > I think you mean '\n'.join([string1,string2,string3]) > > > > > You actually do want the \ to do its thing in this case. > > > > Yeah, my brain m

Re: Python strings question (vertical stack)

2007-11-20 Thread Diez B. Roggisch
dmitrey schrieb: > Thanks all, I have solved the problem: > > a=""" > %s > %s > %s > """ % ('asdf', 'asdf2', 'asdf3') > > print a This is more expensive and not as flexible as the join method. At least for growing string-lengths and number of arguments. Diez -- http://mail.python.org/mailman/

Re: Python strings question (vertical stack)

2007-11-20 Thread John Machin
James Matthews top-posted: > I would say to split it by the newline! Split what by which newline? The OP appeared to be wanting some kind of UNsplit ... > > On Nov 20, 2007 10:59 PM, John Machin <[EMAIL PROTECTED] > > wrote: > > On Nov 21, 7:15 am, Farshid Lashkari

Re: Python strings question (vertical stack)

2007-11-20 Thread James Matthews
I would say to split it by the newline! On Nov 20, 2007 10:59 PM, John Machin <[EMAIL PROTECTED]> wrote: > On Nov 21, 7:15 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote: > > J. Clifford Dyer wrote: > > > I think you mean '\n'.join([string1,string2,string3]) > > > > > You actually do want the \ t

Re: Python strings question (vertical stack)

2007-11-20 Thread John Machin
On Nov 21, 7:15 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote: > J. Clifford Dyer wrote: > > I think you mean '\n'.join([string1,string2,string3]) > > > You actually do want the \ to do its thing in this case. > > Yeah, my brain must still be asleep. Thanks for waking it up :) You're not alone :-

Re: Python strings question (vertical stack)

2007-11-20 Thread Farshid Lashkari
J. Clifford Dyer wrote: > I think you mean '\n'.join([string1,string2,string3]) > > You actually do want the \ to do its thing in this case. Yeah, my brain must still be asleep. Thanks for waking it up :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python strings question (vertical stack)

2007-11-20 Thread J. Clifford Dyer
On Tue, Nov 20, 2007 at 11:40:59AM -0800, Farshid Lashkari wrote regarding Re: Python strings question (vertical stack): > > dmitrey wrote: > > Hi all, > > I have some strings, let it be string1, string2, string3. > > > > So how could String= > > &qu

Re: Python strings question (vertical stack)

2007-11-20 Thread dmitrey
Thanks all, I have solved the problem: a=""" %s %s %s """ % ('asdf', 'asdf2', 'asdf3') print a D. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python strings question (vertical stack)

2007-11-20 Thread Farshid Lashkari
dmitrey wrote: > Hi all, > I have some strings, let it be string1, string2, string3. > > So how could String= > """ > string1 > string2 > string3 > """ > > be obtained? > > Thank you in advance, D. If you just want the to add newlines between the strings then you can do the following: String

Python strings question (vertical stack)

2007-11-20 Thread dmitrey
Hi all, I have some strings, let it be string1, string2, string3. So how could String= """ string1 string2 string3 """ be obtained? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-17 Piet van Oostrum <[EMAIL PROTECTED]> wrote: That might be a good heuristic - but on my Mac no LANG is set. So I should paraphrase my statement to "There is no reliable and cross-platform way figuring out which encoding the console uses". > >>> If LANG is not set, it's

Re: Python strings outside the 128 range

2006-07-17 Thread Piet van Oostrum
> Michael Piotrowski <[EMAIL PROTECTED]> (MP) wrote: >MP> On 2006-07-14 "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >>> Sybren Stuvel schrieb: Diez B. Roggisch enlightened us with: > Of course not. AFAIK there is no way figuring out which encoding the > target console supports.

Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-14 "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Sybren Stuvel schrieb: >> Diez B. Roggisch enlightened us with: >>> Of course not. AFAIK there is no way figuring out which encoding the >>> target console supports. The best you can do is to offer an option >>> that allwos selection of

Re: Python strings outside the 128 range

2006-07-14 Thread Gerhard Fiedler
On 2006-07-14 12:07:12, Fredrik Lundh wrote: > umm. what are we talking about here, really ? Aha! You took a big load off my chest -- this is pretty much what I thought should be there :) What I was talking about is that Diez responded with a clear "no" to my question whether print would do the

Re: Python strings outside the 128 range

2006-07-14 Thread Fredrik Lundh
Gerhard Fiedler wrote: > Anyway, it seems that anything non-ASCII is a bit problematic and needs > "manual" handling of the runtime environment encoding. Seems a bit odd, > given the worldwide distribution of Python... I would have thought that > such a rather basic task like printing an accented

Re: Python strings outside the 128 range

2006-07-14 Thread Gerhard Fiedler
On 2006-07-14 10:52:22, Diez B. Roggisch wrote: Will print take care of encoding translation according to the encoding used in the target console? >>> >>> Of course not. AFAIK there is no way figuring out which encoding the >>> target console supports. The best you can do is to offer an

Re: Python strings outside the 128 range

2006-07-14 Thread Diez B. Roggisch
Sybren Stuvel schrieb: > Diez B. Roggisch enlightened us with: >> Of course not. AFAIK there is no way figuring out which encoding the >> target console supports. The best you can do is to offer an option >> that allwos selection of the output encoding. > > You can use the LANG environment variabl

Re: Python strings outside the 128 range

2006-07-14 Thread Diez B. Roggisch
Gerhard Fiedler schrieb: > On 2006-07-13 12:04:58, Richard Brodie wrote: > >>> s = "é" >>> print s > >>> Is there a standard way to do this? >> Use Unicode strings, with an explicit encoding. Say no to ISO-8859-1 >> centrism. >> See: http://www.amk.ca/python/howto/unicode particularly the >>

Re: Python strings outside the 128 range

2006-07-13 Thread Gerhard Fiedler
On 2006-07-13 12:04:58, Richard Brodie wrote: >> s = "é" >> print s >> Is there a standard way to do this? > > Use Unicode strings, with an explicit encoding. Say no to ISO-8859-1 > centrism. > See: http://www.amk.ca/python/howto/unicode particularly the > "Unicode Literals in Python Source

Re: Python strings outside the 128 range

2006-07-13 Thread Richard Brodie
"Gerhard Fiedler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I understand you correctly, you are saying that if I distribute a file > with the following lines: > > s = "é" > print s > > I basically need to distribute also the information how the file is encoded > and ever

Re: Python strings outside the 128 range

2006-07-13 Thread Fredrik Lundh
Gerhard Fiedler wrote: > If I understand you correctly, you are saying that if I distribute a file > with the following lines: > > s = "é" > print s > > I basically need to distribute also the information how the file is encoded > and every user needs to use the same (or a compatible) encoding

Re: Python strings outside the 128 range

2006-07-13 Thread Gerhard Fiedler
On 2006-07-13 07:42:51, Fredrik Lundh wrote: >> Could anyone explain me how the python string "é" is mapped to >> the binary code "\xe9" in my python interpreter ? > > in the iso-8859-1 character set, the character é is represented by the code > 0xE9 (233 in decimal). there's no mapping going on

Re: Python strings outside the 128 range

2006-07-13 Thread Piet van Oostrum
> "Sébastien Boisgérault" <[EMAIL PROTECTED]> (SB) wrote: >SB> Hi, >SB> Could anyone explain me how the python string "é" is mapped to >SB> the binary code "\xe9" in my python interpreter ? That is not done in the python interpreter. It is done in the editor in which you prepare your python

Re: Python strings outside the 128 range

2006-07-13 Thread Sébastien Boisgérault
Fredrik Lundh wrote: > in the iso-8859-1 character set, the character é is represented by the code > 0xE9 (233 in decimal). there's no mapping going on here; there's only one > character in the string. how it appears on your screen depends on how you > print it, and what encoding your terminal

Re: Python strings outside the 128 range

2006-07-13 Thread Fredrik Lundh
Sébastien Boisgérault wrote: > Could anyone explain me how the python string "é" is mapped to > the binary code "\xe9" in my python interpreter ? in the iso-8859-1 character set, the character é is represented by the code 0xE9 (233 in decimal). there's no mapping going on here; there's only one

Re: Python strings outside the 128 range

2006-07-13 Thread Diez B. Roggisch
Sébastien Boisgérault schrieb: > Hi, > > Could anyone explain me how the python string "é" is mapped to > the binary code "\xe9" in my python interpreter ? > > "é" is not present in the 7-bit ASCII table that is the default > encoding, right ? So is the mapping "é" -> "\xe9" portable ? > (site-)c

Python strings outside the 128 range

2006-07-13 Thread Sébastien Boisgérault
Hi, Could anyone explain me how the python string "é" is mapped to the binary code "\xe9" in my python interpreter ? "é" is not present in the 7-bit ASCII table that is the default encoding, right ? So is the mapping "é" -> "\xe9" portable ? (site-)configuration dependent ? Can anyone have somet

Re: python strings

2006-05-04 Thread Sion Arrowsmith
Bryan <[EMAIL PROTECTED]> wrote: > >>> s = '\x00' > >>> s[0] == chr(0) >True That's a little excessive when: >>> s = '\0' >>> s[0] == chr(0) True Oh, and to reassure the OP that that null really is *in* the string: >>> len(s) 1 -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ _

Re: python strings

2006-05-03 Thread Bryan
Gerhard Häring wrote: > Python 2.4.2 (#2, Sep 30 2005, 21:19:01) > [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. s = "\x000" s[0] == chr(0) > True > > - -- Gerhard this works too :) >>> s =

Re: python strings

2006-05-03 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [EMAIL PROTECTED] wrote: > Is it possible for python strings to contain a zero byte? Yes. Here's how to produce one: [EMAIL PROTECTED]:~$ python Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubun

Re: python strings

2006-05-03 Thread Grant Edwards
On 2006-05-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is it possible for python strings to contain a zero byte? Yes. -- Grant Edwards grante Yow! Actually, what at I'd like i

python strings

2006-05-03 Thread mike7411
Is it possible for python strings to contain a zero byte? -- http://mail.python.org/mailman/listinfo/python-list