Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
80
#1
trying to limit all code lines to fit in 80 characters is hard to do

    if opt_instance == None:
        instances_sortedby_launchtime = [j[0] for j in sorted([(i['LaunchTime'],i) for i in instances])]
        instances_sortedby_launchtime_sr = []
        for instance in instances_sortedby_launchtime:
            tagd = {d['Key']:d['Value'] for d in instance['Tags']}
            tagb = True
            for tag in valid_sr_tags:
                if tag not in tagd:
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
    if opt_instance == None:
        instances_sortedby_launchtime = [j[0] for j in sorted([(i['LaunchTime'],i) 
                                                  for i in instances])]
        instances_sortedby_launchtime_sr = []
        for instance in instances_sortedby_launchtime:
            tagd = {d['Key']:d['Value'] for d in instance['Tags']}
            tagb = True
            for tag in valid_sr_tags:
                if tag not in tagd:
Does this work? I feel it right but not sure
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Don't try to explain to much in a variable name.
If more explaining is needed have this first in function/method eg in a docstring.
90'ish is okay as Ray-man suggests  here.
if opt_instance == None:
    launch_time = [j[0] for j in sorted([(i['LaunchTime'],i) for i in instances])]
    launch_sr = []
    for instance in launch_time:
        tagd = {d['Key']:d['Value'] for d in instance['Tags']}
        tagb = True
        for tag in valid_sr_tags:
            if tag not in tagd:
Reply
#4
(Jan-30-2017, 05:52 AM)snippsat Wrote: 90'ish is okay as Ray-man suggests  here.
TL;DV 52:04

there is an advantage to me:  code side by side, but my limit is 83 when i do that.  otherwise my maximum terminal window width is 168.

is doing side by side very useful?

i've done it ... once.  could i have worked it different?  if the was wide, sure.

so, i am not so sure that ** I ** need to do the 79/80 limit.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
(Jan-30-2017, 07:29 AM)Skaperen Wrote: is doing side by side very useful?

Only you can answer that question. Is that how you feel more comfortable coding? I would let the answer to your question inform you line length. In fact, the reason we have the line length limits in PEP 8 is because of a setting for side by side coding in Guido's emacs.

Me, I'm not into side by side coding, so I use a longer line length of 108. But that's me, not you.

As to variable names, Code Complete suggests 7 to 12 characters as optimal, IIRC. I never worry about lengthening variable names to 7 characters, but if I get into the 12-15 range I consider the possibility of being more concise.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
(Jan-30-2017, 07:29 AM)Skaperen Wrote: is doing side by side very useful?
I mix all time from 1 window/side by side or up/down Atom.io which is the editor i use make this easy.
Here some screenshot side by side,
usually don't work with 4 windows but can be okay as overview for web-development work.
Reply
#7
in BP (Before Python) times coding mostly in C (some Pike, some awk, lots of bash) my line length was 144. now it can be as much as 166.  i used to operate in raw text mode (switching to X as needed) with slackware. now i am in X all the time with ubuntu, having given up deeply customizing the OS and kernel.  i found the font size i like in a terminal window under X and at nearly full screen i get 166x46.  in side by side i do 80x46 times 2.  i have Workspace Switcher running at 3x3 and 12 concurrent users (one dedicated to accessing forums) i can switch to (so 108 total desktops).  systems (CPUs, GPUsm and so on) these days a fast enough to handle all this.  faster disks would be nice for my 10M file setup (mostly encrypted).

so i could go to 166 wide if needed.  but at some point (assuming i can go as wide as i want ... i did 240 for while on slackware text mode ... it is hard to keep a line lined-up in my field of view.   166 is pushing the limits on that so i don't expect to go beyond it.

yeah, i could make simpler variable names.  but i am mixing a lot of similar names so names this long help separate them.

i'm also looking at where to put spaces and where not to (still undecided and looking at other code).  doing 79 wide puts pressure on that, too.

i'd like to see other code that exceeds PEP8.

in the mean time i'll just keep experimenting with 80(79) vs 166.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020