Re: Strings: double versus single quotes

2020-05-24 Thread DL Neil via Python-list
On 24/05/20 8:41 PM, Frank Millman wrote: On 2020-05-24 9:58 AM, DL Neil via Python-list wrote: On 24/05/20 5:43 PM, Frank Millman wrote: On 2020-05-23 9:45 PM, DL Neil via Python-list wrote: My habit with SQL queries is to separate them from other code, cf the usual illustration of having t

Re: Strings: double versus single quotes

2020-05-24 Thread HÜSEYİN KOÇ
Çok fazla mail geliyor abonelik iptal için ne yapmam gerekiyor Android için Outlook<https://aka.ms/ghei36>'u edinin From: Python-list on behalf of Frank Millman Sent: Sunday, May 24, 2020 11:41:36 AM To: python-list@python.org Subject: Re: Stri

Re: Strings: double versus single quotes

2020-05-24 Thread Frank Millman
On 2020-05-24 9:58 AM, DL Neil via Python-list wrote: On 24/05/20 5:43 PM, Frank Millman wrote: On 2020-05-23 9:45 PM, DL Neil via Python-list wrote: My habit with SQL queries is to separate them from other code, cf the usual illustration of having them 'buried' within the code, immediately

Re: Strings: double versus single quotes

2020-05-24 Thread DL Neil via Python-list
On 24/05/20 5:43 PM, Frank Millman wrote: On 2020-05-23 9:45 PM, DL Neil via Python-list wrote: My habit with SQL queries is to separate them from other code, cf the usual illustration of having them 'buried' within the code, immediately before, or even part of, the query call. I like tha

Re: Strings: double versus single quotes

2020-05-23 Thread Frank Millman
On 2020-05-23 9:45 PM, DL Neil via Python-list wrote: My habit with SQL queries is to separate them from other code, cf the usual illustration of having them 'buried' within the code, immediately before, or even part of, the query call. I like that idea, as I find that I am embedding more

Re: Strings: double versus single quotes

2020-05-23 Thread Abdur-Rahmaan Janhangeer
Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy | blog github Mauritius On Sun, May 24, 2020 at 12:03 AM DL Neil via Python-list < python-list@python.org> wrote: > > I'm highly am

Re: Strings: double versus single quotes

2020-05-23 Thread Abdur-Rahmaan Janhangeer
Greetings, Nice idea >>> '''You said "No it doesn't"''' 'You said "No it doesn\'t"' Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy | blog github Mauritius On Sun, May 24, 2020

Re: Strings: double versus single quotes

2020-05-23 Thread Manfred Lotz
On Sat, 23 May 2020 14:46:04 -0400 Dennis Lee Bieber wrote: > On Sat, 23 May 2020 11:03:09 -0500, Tim Chase > declaimed the following: > > > > > >But when a string contains both, it biases towards single quotes: > > > > >>> "You said \"No it doesn't\"" > > 'You said "No it doesn\'t"'

Re: Strings: double versus single quotes

2020-05-23 Thread Souvik Dutta
This seems to be a life long debate... On Sun, 24 May, 2020, 5:25 am Tim Chase, wrote: > On 2020-05-23 14:46, Dennis Lee Bieber wrote: > > On Sat, 23 May 2020 11:03:09 -0500, Tim Chase > > >But when a string contains both, it biases towards single quotes: > > > > > > >>> "You said \"No it does

Re: Strings: double versus single quotes

2020-05-23 Thread Tim Chase
On 2020-05-23 14:46, Dennis Lee Bieber wrote: > On Sat, 23 May 2020 11:03:09 -0500, Tim Chase > >But when a string contains both, it biases towards single quotes: > > > > >>> "You said \"No it doesn't\"" > > 'You said "No it doesn\'t"' > > This is where using triple quotes (or trip

Re: Strings: double versus single quotes

2020-05-23 Thread DL Neil via Python-list
On 24/05/20 8:39 AM, Skip Montanaro wrote: May I ask why not simply like this: stmt = """ select foo from bar where a = 'bag' and c = 'dog' """ Sorry, I don't recall. I wouldn't be at all surprised that it has something to do with Emacs's Python mode behavio

Re: Strings: double versus single quotes

2020-05-23 Thread Skip Montanaro
> > > May I ask why not simply like this: > > stmt = """ > select foo from bar > where a = 'bag' > and c = 'dog' > """ > Sorry, I don't recall. I wouldn't be at all surprised that it has something to do with Emacs's Python mode behavior. Emacs wouldn't know what to do

Re: Strings: double versus single quotes

2020-05-23 Thread Roel Schroeven
Skip Montanaro schreef op 23/05/2020 om 13:03: I also agree about SQL. I found that something like this: stmt = ( """select foo from bar""" """ where a = 'bag'""" """and c = 'dog'""" ) worked pretty well, served to both satisfy my brain's desire for semantic indentation (you

Re: Strings: double versus single quotes

2020-05-23 Thread DL Neil via Python-list
On 24/05/20 4:03 AM, Tim Chase wrote: On 2020-05-24 01:40, Chris Angelico wrote: On Sat, May 23, 2020 at 10:52 PM Abdur-Rahmaan Janhangeer wrote: The interpreter prefers single-quotes "single or double" 'single or double' 'not all that strongly, it doesn\'t' "not all that strongly,

Re: Strings: double versus single quotes

2020-05-23 Thread DL Neil via Python-list
On 23/05/20 11:03 PM, Skip Montanaro wrote: I also agree about SQL. I found that something like this: stmt = ( """select foo from bar""" """ where a = 'bag'""" """and c = 'dog'""" ) worked pretty well, served to both satisfy my brain's desire for semantic indentation (you sh

Re: Strings: double versus single quotes

2020-05-23 Thread Abdur-Rahmaan Janhangeer
Nice one, Was requoting: <>> "hello" 'hello'>> from R Hettinger Kind Regards, Abdur-Rahmaan Janhangeer https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. -- https://mail.python.org/mailman/listinfo/python-list

Re: Strings: double versus single quotes

2020-05-23 Thread Tim Chase
On 2020-05-24 01:40, Chris Angelico wrote: > On Sat, May 23, 2020 at 10:52 PM Abdur-Rahmaan Janhangeer > wrote: > > > > The interpreter prefers single-quotes > > > > >>> "single or double" > > 'single or double' > > > >>> 'not all that strongly, it doesn\'t' > "not all that strongly, it do

Re: Strings: double versus single quotes

2020-05-23 Thread Chris Angelico
On Sat, May 23, 2020 at 10:52 PM Abdur-Rahmaan Janhangeer wrote: > > The interpreter prefers single-quotes > > >>> "single or double" > 'single or double' > >>> 'not all that strongly, it doesn\'t' "not all that strongly, it doesn't" ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Strings: double versus single quotes

2020-05-23 Thread Abdur-Rahmaan Janhangeer
The interpreter prefers single-quotes >>> "single or double" 'single or double' I read a recent quote from Raymond Hettinger saying that the Python world prefers double ones. If Mr Hettinger is around i'd like to ask him where he pulled the theory from https://twitter.com/raymondh/status/12592097

Re: Strings: double versus single quotes

2020-05-23 Thread Rhodri James
On 22/05/2020 20:57, Manfred Lotz wrote: I also believe that transferring habits from C, Rust or whatever to Python doesn't make much sense as Python does not distinguish between a character and string from a type perspective. From a logical perspective, you are correct. From the point of view

Re: Strings: double versus single quotes

2020-05-23 Thread Skip Montanaro
> Nothing strong. I tend to use double quotes because I have a > background in C (where double quotes are for strings, single quotes > for characters), and double quotes are the recommendation for > docstrings (see PEP 258). If you tend to work a lot with SQL, you > might prefer single quotes. Use

Re: Strings: double versus single quotes

2020-05-22 Thread Manfred Lotz
On Sat, 23 May 2020 09:36:13 +1200 DL Neil wrote: > >>> I am asking myself if I should preferably use single or double > >>> quotes for strings? > ... > > > I agree to the following: > > > > 1. Consistency is important. > > 2. Single quotes are less noisy. > > 3. Triple double quotes are to b

Re: Strings: double versus single quotes

2020-05-22 Thread DL Neil via Python-list
I am asking myself if I should preferably use single or double quotes for strings? ... I agree to the following: 1. Consistency is important. 2. Single quotes are less noisy. 3. Triple double quotes are to be preferred over triple single quotes. ... Of course, this is my subjective result,

Re: Strings: double versus single quotes

2020-05-22 Thread Manfred Lotz
On Tue, 19 May 2020 13:36:54 -0500 Tim Chase wrote: > On 2020-05-19 20:10, Manfred Lotz wrote: > > Hi there, > > I am asking myself if I should preferably use single or double > > quotes for strings? > > I'd say your consistency matters more than which one you choose. > First, thanks to all

Re: Strings: double versus single quotes

2020-05-19 Thread Souvik Dutta
I love and use only singel quotes. I think that looks clean... Nothing else. Souvik flutter dev On Tue, May 19, 2020, 11:50 PM Manfred Lotz wrote: > Hi there, > I am asking myself if I should preferably use single or double quotes > for strings? > > If I need a single quote in a string I would

Re: Strings: double versus single quotes

2020-05-19 Thread Terry Reedy
On 5/19/2020 2:10 PM, Manfred Lotz wrote: Hi there, I am asking myself if I should preferably use single or double quotes for strings? If I need a single quote in a string I would use double quotes for the whole string and vice versa. For f-strings I mostly see double quotes but single quotes wo

Re: Strings: double versus single quotes

2020-05-19 Thread Alan Gauld via Python-list
On 19/05/2020 19:10, Manfred Lotz wrote: > Hi there, > I am asking myself if I should preferably use single or double quotes > for strings? Personally laziness wins every time. Single quotes only require one finger from the home position using my right hand, double quotes require two and a big mov

Re: Strings: double versus single quotes

2020-05-19 Thread Cameron Simpson
On 19May2020 22:04, Manfred Lotz wrote: On Tue, 19 May 2020 13:36:54 -0500 Tim Chase wrote: On 2020-05-19 20:10, Manfred Lotz wrote: > I am asking myself if I should preferably use single or double > quotes for strings? I'd say your consistency matters more than which one you choose. [...]

Re: Strings: double versus single quotes

2020-05-19 Thread Manfred Lotz
On Tue, 19 May 2020 13:36:54 -0500 Tim Chase wrote: > On 2020-05-19 20:10, Manfred Lotz wrote: > > Hi there, > > I am asking myself if I should preferably use single or double > > quotes for strings? > > I'd say your consistency matters more than which one you choose. > > According to a recen

Re: Strings: double versus single quotes

2020-05-19 Thread Ethan Furman
On 05/19/2020 11:40 AM, Joel Goldstick wrote: I thought triple quotes are for docstrings? It's the recommendation, but double and single quotes work just fine, too -- at least for docstrings that fit an one line. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Strings: double versus single quotes

2020-05-19 Thread Chris Angelico
On Wed, May 20, 2020 at 4:42 AM Joel Goldstick wrote: > > On Tue, May 19, 2020 at 2:27 PM Chris Angelico wrote: > > > > On Wed, May 20, 2020 at 4:21 AM Manfred Lotz wrote: > > > > > > Hi there, > > > I am asking myself if I should preferably use single or double quotes > > > for strings? > > > >

Re: Strings: double versus single quotes

2020-05-19 Thread Tim Chase
On 2020-05-19 20:10, Manfred Lotz wrote: > Hi there, > I am asking myself if I should preferably use single or double > quotes for strings? I'd say your consistency matters more than which one you choose. According to a recent observation by Raymond H. """ Over time, the #python world has show

Re: Strings: double versus single quotes

2020-05-19 Thread DL Neil via Python-list
On 20/05/20 6:26 AM, Chris Angelico wrote: On Wed, May 20, 2020 at 4:21 AM Manfred Lotz wrote: Hi there, I am asking myself if I should preferably use single or double quotes for strings? If I need a single quote in a string I would use double quotes for the whole string and vice versa. For f

Re: Strings: double versus single quotes

2020-05-19 Thread Joel Goldstick
On Tue, May 19, 2020 at 2:27 PM Chris Angelico wrote: > > On Wed, May 20, 2020 at 4:21 AM Manfred Lotz wrote: > > > > Hi there, > > I am asking myself if I should preferably use single or double quotes > > for strings? > > > > If I need a single quote in a string I would use double quotes for the

Re: Strings: double versus single quotes

2020-05-19 Thread Chris Angelico
On Wed, May 20, 2020 at 4:21 AM Manfred Lotz wrote: > > Hi there, > I am asking myself if I should preferably use single or double quotes > for strings? > > If I need a single quote in a string I would use double quotes for the > whole string and vice versa. For f-strings I mostly see double > quo

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 11:40 pm, Sayth Renshaw wrote: > True it failed, just actually happy to get it to fail or pass successfully > on int input. But it doesn't. It raises ValueError no matter what you enter. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure e

Re: strings and ints consistency - isinstance

2016-09-22 Thread Larry Hudson via Python-list
On 09/22/2016 06:40 AM, Sayth Renshaw wrote: [snip...] True it failed, just actually happy to get it to fail or pass successfully on int input. Just felt it was a clearer and more consistent approach to verifying input, then most of the varied and rather inconsistent approaches I have seen in

Re: strings and ints consistency - isinstance

2016-09-22 Thread Sayth Renshaw
> > This ends being the code I can use to get it to work, seems clear and > > pythonic, open to opinion on that :-) > > Neither clear, nor Pythonic. Sadly imo clearer than the many hack attempts on SO. > > > answer = input("\t >> ") > > Since input() returns a string in Python 3, this will al

Re: strings and ints consistency - isinstance

2016-09-22 Thread Gregory Ewing
On Wednesday, September 21, 2016 at 11:41:42 PM UTC-4, Sayth Renshaw wrote: answer = input("\t >> ") if isinstance(int(answer), int) is True: raise ValueError("Ints aren't valid input") You seem to be trying to check that the user hasn't entered an integer. But that's a backwards way of loo

Re: strings and ints consistency - isinstance

2016-09-22 Thread Steve D'Aprano
On Thu, 22 Sep 2016 01:41 pm, Sayth Renshaw wrote: > This ends being the code I can use to get it to work, seems clear and > pythonic, open to opinion on that :-) Neither clear, nor Pythonic. > answer = input("\t >> ") Since input() returns a string in Python 3, this will always be a string.

Re: strings and ints consistency - isinstance

2016-09-22 Thread Ned Batchelder
On Wednesday, September 21, 2016 at 11:41:42 PM UTC-4, Sayth Renshaw wrote: > This ends being the code I can use to get it to work, seems clear and > pythonic, open to opinion on that :-) > > > answer = input("\t >> ") > if isinstance(int(answer), int) is True: > raise ValueError("Ints aren'

Re: strings and ints consistency - isinstance

2016-09-22 Thread Lawrence D’Oliveiro
On Thursday, September 22, 2016 at 3:41:42 PM UTC+12, Sayth Renshaw wrote: > if isinstance(int(answer), int) is True: Not sure what the point of this is... -- https://mail.python.org/mailman/listinfo/python-list

Re: strings and ints consistency - isinstance

2016-09-21 Thread Sayth Renshaw
This ends being the code I can use to get it to work, seems clear and pythonic, open to opinion on that :-) answer = input("\t >> ") if isinstance(int(answer), int) is True: raise ValueError("Ints aren't valid input") sys.exit() elif isinstance(answer, str) is True: print(v0 * t

Re: strings and ints consistency - isinstance

2016-09-21 Thread Sayth Renshaw
To answer all the good replies. I adapted a simple vector example from the Springer book practical primer on science with python. Having solved the actual problem I thought checking with the user they had the correct entries or would like to ammend them would be a good addition. This leads to

Re: strings and ints consistency - isinstance

2016-09-21 Thread Steve D'Aprano
On Thu, 22 Sep 2016 12:26 am, Sayth Renshaw wrote: > Hi > > Trying to clarify why ints and strings arent treated the same. Because ints and strings are different? :-) > You can get a valuerror from trying to cast a non-int to an int as in > int(3.0) however you cannot do a non string with str(

Re: strings and ints consistency - isinstance

2016-09-21 Thread John Gordon
In Sayth Renshaw writes: > Trying to clarify why ints and strings arent treated the same. Because they are not the same. > You can get a valuerror from trying to cast a non-int to an int as in > int(3.0) however you cannot do a non string with str(a). Anything you type can be represented as

Re: strings and ints consistency - isinstance

2016-09-21 Thread Ned Batchelder
On Wednesday, September 21, 2016 at 10:27:15 AM UTC-4, Sayth Renshaw wrote: > Hi > > Trying to clarify why ints and strings arent treated the same. > > You can get a valuerror from trying to cast a non-int to an int as in > int(3.0) however you cannot do a non string with str(a). > > Which mean

Re: Strings show as brackets with a 'u'.

2011-07-27 Thread goldtech
> Rick gave you some good advice, perhaps worth re-reading. What you need > are investigative skills, and not just bits of data. Totally agree. beginning to see what's going on. I'm not specifically accessing the list element with n (vs. n[0]). Printing n uses repr which gives the unicode "tag".

Re: Strings show as brackets with a 'u'.

2011-07-26 Thread Steven D'Aprano
On Wed, 27 Jul 2011 11:18 am goldtech wrote: > Thank you. So what is happening? Is it that I'm in an environment that > is not unicode and python is telling me the string (ie. n[0]) is > unicode? (I'll do a hatchet-job on this subject if I ask anymore about > unicode). Thanks to posters for their

Re: Strings show as brackets with a 'u'.

2011-07-26 Thread Terry Reedy
On 7/26/2011 9:18 PM, goldtech wrote: Thank you. So what is happening? Is it that I'm in an environment that is not unicode and python is telling me the string (ie. n[0]) is unicode? Yes, n is a list and n[0] is a unicode string and you are using some 2.x, which is ascii/byte string based. Pyt

Re: Strings show as brackets with a 'u'.

2011-07-26 Thread goldtech
Thank you. So what is happening? Is it that I'm in an environment that is not unicode and python is telling me the string (ie. n[0]) is unicode? (I'll do a hatchet-job on this subject if I ask anymore about unicode). Thanks to posters for their patience! -- http://mail.python.org/mailman/listinfo/

Re: Strings show as brackets with a 'u'.

2011-07-26 Thread rantingrick
On Jul 25, 3:00 am, Ulrich Eckhardt wrote: > Chris Angelico wrote: > > > [snip] > > You just gave the OP a fish, he provided a > valuable advise on fishing itself. I always believed the best way to teach someone is not to give them a direct answer. No. Instead i like to offer clues so that the pe

Re: Strings show as brackets with a 'u'.

2011-07-25 Thread Ulrich Eckhardt
Chris Angelico wrote: > On Sun, Jul 24, 2011 at 10:33 AM, goldtech wrote: >> >> I'm using using Idle on winXP, activestate 2.7. Is there a way to >> suppress this and just show 174 in the shell ? >> A script reading data and assigns 174 to n via some regex. Links on >> this appreciated - I've tri

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Thomas Jollans
On 24/07/11 02:52, Dan Stromberg wrote: > > It's probably a list containing a single unicode string. > > You can pull the first element from the list with n[0]. > > To print a unicode string in 2.x without the u stuff: > > print u'174'.encode('ISO-8859-1') just >>> print u'174' will do. Encod

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Chris Angelico
On Sun, Jul 24, 2011 at 10:33 AM, goldtech wrote: > >  I'm using using Idle on winXP, activestate 2.7. Is there a way to > suppress this and just show 174  in the shell ? > A script reading data and assigns 174 to n via some regex. Links on > this appreciated - I've tried to understand unicode bef

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Dan Stromberg
It's probably a list containing a single unicode string. You can pull the first element from the list with n[0]. To print a unicode string in 2.x without the u stuff: print u'174'.encode('ISO-8859-1') On Sat, Jul 23, 2011 at 5:33 PM, goldtech wrote: > > Hi, > > >>> n > [u'174'] > >>> > > Prob

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread rantingrick
On Jul 23, 7:33 pm, goldtech wrote: > > >>> n > [u'174'] > > Probably newbie question but not sure how suppress the brackets and > the 'u' ? I assume pyhon is telling me it's a unicode string in the n > variable. Try type(n) and see what happens. Then report back. :) -- http://mail.python.org/ma

Re: strings getting unnecessarily cut in lstrip

2010-11-21 Thread Steve Holden
On 11/21/2010 10:12 PM, Maxim Mercury wrote: > I was using the lstrip to trim the left occurance of a string, and it > didnt seem to work for some cases. but when i investigated there does > seem to be an issue with some combination of strings > here is one case > p1 = "abcd" > p2 = 'def'

Re: strings for beginers

2009-03-07 Thread Tim Wintle
On Sat, 2009-03-07 at 21:25 +, Tim Wintle wrote: > burn_cmd = "mkisofs -udf -o /home/donkey/discspaniso%d.iso > -graft-points --path-list %s" %(x,temp_list) obviously I meant to say burn_cmd = "mkisofs -udf -o /home/donkey/discspaniso% d.iso-graft-points --path-list %s" %(disc_num,temp_

Re: strings for beginers

2009-03-07 Thread Tim Wintle
On Sat, 2009-03-07 at 12:53 -0800, Sapote wrote: > I have an incrementing variable disc_num that I could insert in the > line below to create discspanisoX.iso where X is incrementing... > > burn_cmd = "mkisofs -udf -o /home/donkey/discspaniso.iso -graft- > points --path-list %s" %(temp_list)

Re: Python newbie question re Strings and integers

2008-09-22 Thread Bruno Desthuilliers
rmac a écrit : Ah! Arghh!!! You are so correct on the usage of the ':' Python syntax is a little different from what I am used to. I don't know what you're used to, but chances are that more than the syntax differs !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python newbie question re Strings and integers

2008-09-20 Thread Bruno Desthuilliers
rmac a écrit : the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) rfind returns an int, so passing it to the int type constructor is useless. filenameStart = int(filename.rfind('/')) idem #print 'Extension Start - ' +

Re: Python newbie question re Strings and integers

2008-09-18 Thread rmac
Ah! Arghh!!! You are so correct on the usage of the ':' Python syntax is a little different from what I am used to. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python newbie question re Strings and integers

2008-09-18 Thread Miki
>     currentSymbol=filename[int(filenameStart),int(extensionStart)] Should be currentSymbol=filename[int(filenameStart):int(extensionStart)] (change , to :) You don't need to convert to int all the time, rfind will return an integer. Also you can use os.path for this from os.path import

Re: Python newbie question re Strings and integers

2008-09-18 Thread Christian Heimes
rmac wrote: the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) filenameStart = int(filename.rfind('/')) #print 'Extension Start - ' + str(extensionStart) #print 'FileName Start - ' + str(filenameStart) currentSymbol=f

Python newbie question re Strings and integers

2008-09-18 Thread rmac
the following code attempts to extract a symbol name from a string: extensionStart = int(filename.rfind('.')) filenameStart = int(filename.rfind('/')) #print 'Extension Start - ' + str(extensionStart) #print 'FileName Start - ' + str(filenameStart) currentSymbol=filename[int(f

Re: strings (dollar.cents) into floats

2007-08-31 Thread Grant Edwards
On 2007-09-01, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, > sturlamolden wrote: > >> There are fractions that can be exactly represented by floats that >> cannot be exactly represented by decimals. > > There are no such. In that statement does "float" mean fin

Re: strings (dollar.cents) into floats

2007-08-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Wildemar Wildenburger wrote: > But what use is there for floats, then? When is it OK to use > them? Floating-point numbers are useful when you have to deal with very large and very small amounts at the same time. In using them, you must understand something about h

Re: strings (dollar.cents) into floats

2007-08-31 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, sturlamolden wrote: > There are fractions that can be exactly represented by floats that > cannot be exactly represented by decimals. There are no such. -- http://mail.python.org/mailman/listinfo/python-list

Re: strings (dollar.cents) into floats

2007-08-31 Thread John Machin
On Sep 1, 4:58 am, MRAB <[EMAIL PROTECTED]> wrote: > On Aug 31, 5:39 pm, David H Wild <[EMAIL PROTECTED]> wrote:> In article > <[EMAIL PROTECTED]>, > >Chris Mellon <[EMAIL PROTECTED]> wrote: > > > > I believe that to the degree that "real" accounting was done in those > > > currencies it did i

Re: strings (dollar.cents) into floats

2007-08-31 Thread John Machin
On Sep 1, 4:51 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Fri, 31 Aug 2007 12:06:49 -0400, Steve Holden <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > That last sentence is patent nonsense, and completely untrue. Many > > satisfactory financial applications have

Re: strings (dollar.cents) into floats

2007-08-31 Thread David H Wild
In article <[EMAIL PROTECTED]>, MRAB <[EMAIL PROTECTED]> wrote: > > When I worked on the British Railways National Payroll system, about > > 35 years ago, we, in common with many large users, wrote our system to > > deal with integer amounts of pennies, and converted to pounds, > > shillings and

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
MRAB wrote: > On Aug 31, 5:39 pm, David H Wild <[EMAIL PROTECTED]> wrote: >> In article <[EMAIL PROTECTED]>, >>Chris Mellon <[EMAIL PROTECTED]> wrote: >> >>> I believe that to the degree that "real" accounting was done in those >>> currencies it did in fact use non-decimal bases. Just as people

Re: strings (dollar.cents) into floats

2007-08-31 Thread MRAB
On Aug 31, 5:39 pm, David H Wild <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, >Chris Mellon <[EMAIL PROTECTED]> wrote: > > > I believe that to the degree that "real" accounting was done in those > > currencies it did in fact use non-decimal bases. Just as people don't > > use de

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
Chris Mellon wrote: > On 8/31/07, Steve Holden <[EMAIL PROTECTED]> wrote: >> sturlamolden wrote: >>> On 31 Aug, 02:12, Wildemar Wildenburger >>> <[EMAIL PROTECTED]> wrote: >>> I've heard (ok, read) that several times now and I understand the argument. But what use is there for floats, the

Re: strings (dollar.cents) into floats

2007-08-31 Thread David H Wild
In article <[EMAIL PROTECTED]>, Chris Mellon <[EMAIL PROTECTED]> wrote: > I believe that to the degree that "real" accounting was done in those > currencies it did in fact use non-decimal bases. Just as people don't > use decimal time values (except us crazy computer folk), you're write > 1 poun

Re: strings (dollar.cents) into floats

2007-08-31 Thread MRAB
On Aug 31, 5:28 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On 8/31/07, Steve Holden <[EMAIL PROTECTED]> wrote: > > > sturlamolden wrote: > > > On 31 Aug, 02:12, Wildemar Wildenburger > > > <[EMAIL PROTECTED]> wrote: > > > >> I've heard (ok, read) that several times now and I understand the > >

Re: strings (dollar.cents) into floats

2007-08-31 Thread Chris Mellon
On 8/31/07, Steve Holden <[EMAIL PROTECTED]> wrote: > sturlamolden wrote: > > On 31 Aug, 02:12, Wildemar Wildenburger > > <[EMAIL PROTECTED]> wrote: > > > >> I've heard (ok, read) that several times now and I understand the > >> argument. But what use is there for floats, then? When is it OK to use

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
sturlamolden wrote: > On 31 Aug, 02:12, Wildemar Wildenburger > <[EMAIL PROTECTED]> wrote: > >> I've heard (ok, read) that several times now and I understand the >> argument. But what use is there for floats, then? When is it OK to use them? > > There are fractions that can be exactly represented

Re: strings (dollar.cents) into floats

2007-08-31 Thread sturlamolden
On 31 Aug, 02:12, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > I've heard (ok, read) that several times now and I understand the > argument. But what use is there for floats, then? When is it OK to use them? There are fractions that can be exactly represented by floats that cannot be exactl

Re: strings (dollar.cents) into floats

2007-08-31 Thread Steve Holden
Ben Finney wrote: > Wildemar Wildenburger <[EMAIL PROTECTED]> writes: > >> But what use is there for floats, then? When is it OK to use them? > > When one is willing to sacrifice decimal precision for speed of > calculation, and doesn't need the numbers to stay precise. E.g. when > performing mil

Re: strings (dollar.cents) into floats

2007-08-30 Thread Ben Finney
Wildemar Wildenburger <[EMAIL PROTECTED]> writes: > But what use is there for floats, then? When is it OK to use them? When one is willing to sacrifice decimal precision for speed of calculation, and doesn't need the numbers to stay precise. E.g. when performing millions of calculations on real-w

Re: strings (dollar.cents) into floats

2007-08-30 Thread Robert Kern
Wildemar Wildenburger wrote: > Ben Finney wrote: >> You most likely do *not* want floating-point numbers for currency, >> since they rely on the operating system's binary floating point >> support which cannot accurately represent decimal fractions. > > I've heard (ok, read) that several times now

Re: strings (dollar.cents) into floats

2007-08-30 Thread Wildemar Wildenburger
Ben Finney wrote: > You most likely do *not* want floating-point numbers for currency, > since they rely on the operating system's binary floating point > support which cannot accurately represent decimal fractions. > I've heard (ok, read) that several times now and I understand the argument. Bu

Re: strings (dollar.cents) into floats

2007-08-30 Thread Ben Finney
luca bertini <[EMAIL PROTECTED]> writes: > i have strings which look like money values (ie 34.45) > is there a way to convert them into float variables? You most likely do *not* want floating-point numbers for currency, since they rely on the operating system's binary floating point support which

Re: strings (dollar.cents) into floats

2007-08-30 Thread J. Cliff Dyer
Gary Herron wrote: luca bertini wrote: Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: "numb = float(my_line) ValueError: empty string for float()" " here's the code import sys

Re: strings (dollar.cents) into floats

2007-08-30 Thread Gary Herron
luca bertini wrote: > Hi, > > i have strings which look like money values (ie 34.45) > is there a way to convert them into float variables? > everytime i try I get this error: "numb = float(my_line) ValueError: > empty string for float()" > " > here's the code > > > > import sys > im

Re: strings (dollar.cents) into floats

2007-08-30 Thread Marshall T. Vandegrift
luca bertini <[EMAIL PROTECTED]> writes: > i have strings which look like money values (ie 34.45) > is there a way to convert them into float variables? > everytime i try I get this error: "numb = float(my_line) ValueError: > empty string for float()" > " You actually have problems here -- the

Re: Strings in Python

2007-02-09 Thread Johny
Thanks ALL for help and ideas L -- http://mail.python.org/mailman/listinfo/python-list

Re: Strings in Python

2007-02-08 Thread MRAB
On Feb 8, 6:32 pm, [EMAIL PROTECTED] wrote: > On Feb 8, 8:28 am, "Johny" <[EMAIL PROTECTED]> wrote: > > > > > Playing a little more with strings, I found out that string.find > > function provides the position of > > the first occurance of the substring in the string. > > Is there a way how to find

Re: Strings in Python

2007-02-08 Thread attn . steven . kuo
On Feb 8, 8:28 am, "Johny" <[EMAIL PROTECTED]> wrote: > Playing a little more with strings, I found out that string.find > function provides the position of > the first occurance of the substring in the string. > Is there a way how to find out all substring's position ? > To explain more, > let's s

Re: Strings in Python

2007-02-08 Thread Shawn Milo
On 2/8/07, Gary Herron <[EMAIL PROTECTED]> wrote: > Johny wrote: > > Playing a little more with strings, I found out that string.find > > function provides the position of > > the first occurance of the substring in the string. > > Is there a way how to find out all substring's position ? > > To ex

Re: Strings in Python

2007-02-08 Thread Shawn Milo
On 8 Feb 2007 08:28:25 -0800, Johny <[EMAIL PROTECTED]> wrote: > Playing a little more with strings, I found out that string.find > function provides the position of > the first occurance of the substring in the string. > Is there a way how to find out all substring's position ? > To explain more,

Re: Strings in Python

2007-02-08 Thread Gary Herron
Johny wrote: > Playing a little more with strings, I found out that string.find > function provides the position of > the first occurance of the substring in the string. > Is there a way how to find out all substring's position ? > To explain more, > let's suppose > > mystring='12341' > import stri

Re: strings in the global section

2006-10-12 Thread Bjoern Schliessmann
Tim Chase wrote: > Sounded like the OP wanted a behavior similar to "auto-globals" > that has been a long-cursed aspect of PHP. That, without > specifying it, local-variables should be global if their name > exists in the global namespace. Sounds like a source of many hard to track down bugs.

Re: strings in the global section

2006-10-12 Thread Tim Chase
>> Works, but something different ? > > Excuse me, what do you mean? Sounded like the OP wanted a behavior similar to "auto-globals" that has been a long-cursed aspect of PHP. That, without specifying it, local-variables should be global if their name exists in the global namespace. Python s

Re: strings in the global section

2006-10-12 Thread Bjoern Schliessmann
Phoe6 wrote: > #!/usr/bin/python > global astring > astring = "This is a String" A global declaration just says "look for this name in the module namespace". Since you /are/ in the module namespace here, there's no need to put "global" here. > Works, but something different ? Excuse me, what d

Re: strings in the global section

2006-10-12 Thread Phoe6
Bjoern Schliessmann wrote: > If you assign "astring" inside the function body, it's a local name. > > > - What should I do to overwrite the string variable in the global > > section within functions? > > Put a "global astring" in the function to access the global name > instead. #!/usr/bin/python

Re: strings in the global section

2006-10-12 Thread Tim Chase
Phoe6 wrote: > I write a script: > #!/usr/bin/python > astring = "This is a String" > > def fun1(): > astring = "I modify it in fun1" > def fun2(): > astring = "I modify it in fun2" > def main(): > print astring > fun1() > print astring > fun2() >

Re: strings in the global section

2006-10-12 Thread Bjoern Schliessmann
Phoe6 wrote: > But it is not so. It always prints This is a String. astring > declared outside all the functions, is not in global section and > values be overwritten by functions accessing it? > > - How is this working? If you assign "astring" inside the function body, it's a local name. > -

  1   2   >