![]() |
splitting a long token across lines
Hi all,
Say, I have a very long integer constant , how can I split across lines ? I tried something like MODULUS = 7567567567567567567567567567567\ 7567507546546986094860986094860\ 2345646986598695869548498698989\ ... but it doesn't compile. Is there another way to write a long numeric constant besides writing it as a string and then converting to long? I also wouldn't like to put it all on one very long line. Thanks! |
Re: splitting a long token across lines
> MODULUS = 7567567567567567567567567567567\
> 7567507546546986094860986094860\ > 2345646986598695869548498698989\ > ... Seems that you cannot use line continuation for integers. Unfortunate. However, using strings to store the value, then later converting it doesn't incur a significant overhead, as long as you are only initializing MODULUS once. MODULUS = '7567567567567567567567567567567'\ '7567507546546986094860986094860'\ '2345646986598695869548498698989'\ ... MODULUS = int(MODULUS) - Josiah |
Re: splitting a long token across lines
why can't you just write it like this:
MODULUS = A*pow(10,a) + \ B*pow(10,b) + \ C "Nakamura" <lambajan@yahoo.com> wrote in message news:ef0c9173.0404032349.742f59e6@posting.google.c om... | Hi all, | | Say, I have a very long integer constant , how can | I split across lines ? | I tried something like | MODULUS = 7567567567567567567567567567567\ | 7567507546546986094860986094860\ | 2345646986598695869548498698989\ | ... | but it doesn't compile. | Is there another way to write a long numeric constant besides writing | it as a string and then converting to long? I also wouldn't like to put | it all on one very long line. | | Thanks! |
Re: splitting a long token across lines
Nakamura wrote:
> Hi all, > > Say, I have a very long integer constant , how can > I split across lines ? > I tried something like > MODULUS = 7567567567567567567567567567567\ > 7567507546546986094860986094860\ > 2345646986598695869548498698989\ > ... > but it doesn't compile. > Is there another way to write a long numeric constant besides writing > it as a string and then converting to long? I also wouldn't like to put > it all on one very long line. > > Thanks! Well, I _suppose_ you could do this: MODULUS = "7567567567567567567567567567567"\ 7567507546546986094860986094860"\ 2345646986598695869548498698989"\ ... MODULUS = int(MODULUS) I'm sure I'm going to have to take some flak for this, though. I wouldn't do it. What's wrong with really long lines? Anything you do that I can see is going to obscure your code. -D |
Re: splitting a long token across lines
djw wrote:
> Nakamura wrote: > >> Hi all, >> >> Say, I have a very long integer constant , how can >> I split across lines ? >> I tried something like >> MODULUS = 7567567567567567567567567567567\ >> 7567507546546986094860986094860\ >> 2345646986598695869548498698989\ >> ... >> but it doesn't compile. >> Is there another way to write a long numeric constant besides writing >> it as a string and then converting to long? I also wouldn't like to put >> it all on one very long line. >> >> Thanks! > > > Well, I _suppose_ you could do this: > > > MODULUS = "7567567567567567567567567567567"\ > 7567507546546986094860986094860"\ > 2345646986598695869548498698989"\ > ... > > MODULUS = int(MODULUS) > > I'm sure I'm going to have to take some flak for this, though. I > wouldn't do it. What's wrong with really long lines? Anything you do > that I can see is going to obscure your code. > > -D Oops, I forgot some quotation marks there, but you get the idea. -D |
| All times are GMT. The time now is 06:14 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.