views:

195

answers:

5

This is somehow related to question about big strings and PEP8.

How can I make my script that has the following line PEP8 compliant ("Maximum Line Length" rule)?

pub_key = {
   'e': 3226833362680126101036263622033066816222202666130162062116461326212012222403311326222666622610430466620224662364142L,
   'n': 226421003861041248462826226103022608220328242204422684232640331238220232226321616266146243302342688266846281802662666622213868114632268211186223606846623310006662260110460620201618186828411322260686632603226636226662262862212140221422102106336342228236361106240226122644614266186283436228208626640846820224661642086022346422443282224682686612228404266842316822624342226666622264826123822122031361242246432886612624262663222232331438863220022020826266366016100422L
}
+1  A: 

I don't think you can. The guidelines in PEP8 are guidelines, there are situations where it's just not possible to follow the guideline.

James Polley
+9  A: 

But most importantly: know when to be inconsistent -- sometimes the style guide just doesn't apply. When in doubt, use your best judgment.

source

In this case, I would just leave the big integers as is.

GmonC
+2  A: 

import this

... Special cases aren't special enough to break the rules. Although practicality beats purity. ...

Ipsquiggle
+2  A: 
'e': 3226833362680126101036263622033066816222202666130162062116461326212012L \
     * 10**45 \
     + 222403311326222666622610430466620224662364142L

I in no way endorse this.

danben
+2  A: 

best way I can think of is

pub_key = {
   'e': long('3226833362680126101036263622033066816222202666130162062116461326'
             '212012222403311326222666622610430466620224662364142'),
   'n': long('2264210038610412484628262261030226082203282422044226842326403312'
             '3822023222632161626614624330234268826684628180266266662221386811'
             '4632268211186223606846623310006662260110460620201618186828411322'
             '2606866326032266362266622628622121402214221021063363422282363611'
             '0624022612264461426618628343622820862664084682022466164208602234'
             '6422443282224682686612228404266842316822624342226666622264826123'
             '8221220313612422464328866126242626632222323314388632200220208262'
             '66366016100422'),
}

exactly 80 chars.

nosklo
Calling and additional function just to follow a style guide is overkill IMHO. Interesting solution though.
GmonC