how to have more commands on one line ?

1- there is a way with python to add several commands on one line
but how ?

2- how do you extend a line to the next one for a long command ?


  • Use the “;” symbol. For example,
a=4; b=6; c=8
  • Anything inside parentheses, brackets or braces will wrap automatically. Just put a new line after the comma. For example:
def bigfunction(arg1, arg2, arg3,
                arg4, arg5, arg6, arg7):
    return "This function does nothing, it is just an example of wrapping"

it’s ugly and frowned upon to have several ‘commands’ on one line. But! sometimes it helps readability to do so.
you can assign values to multiple variables on one line:

xfloat, yfloat, zfloat = 1.0, 2.0, 3.0    # it's debatable if these are 'nice'
xfloat, yfloat, zfloat = (1.0, 2.0, 3.0) 
(xfloat, yfloat, zfloat) = (1.0, 2.0, 3.0)

multiple functions, again not pretty because this can make the code very dense, so if you write code that you want to have read by other people, avoid things like this

func1("bla");func2(23);func3(1.0002)  # so separated by a semi colon.

now one i do like ‘Packing Arguments’. Let’s have a function that accepts 6 variables.

def funky(ab, ac, ad, no, po, qo): 
    print(ab, ac, ad, no, po, qo)

pack1 = 1, 2, 3
pack2 = 4, 5, 6


i’ll take note of these in my notefile for python


I know that you think that i am not helping you and just whining, but…

Dont do that, that is not good way to write code, especially python…


2- how do you extend a line to the next one for a long command ?
Just use the ‘’ character.

print('wtf'+ \

Ok, so my previous code example could have been covered by skykooler’s example 2.

However… try running:

if \

Thanks for that skykooler, I never knew about the auto-wrapping. :slight_smile:

i don’t really like it to put to much on same line
it’s more difficult to read

but i have to find ways to cut down number of lines in a script
which is beginning to be very long (in thousands of lines)
so anything that can help do that seems a good idea even at the risk of making it a liitle less readable or use friendly

so i’ll try to minimise it but at same time find a good compromise

thanks guys

1000 lines? 1k lines is not a justification to start continuously cramming lines with too much information. It also gets in the way of debugging. Rather get in the habit of structuring your code in such a way that it allows you to have multiple files with function definitions that you can then import from. Without seeing your script i don’t dare to hazard a guess to it’s structure. Will you ever release it?

i’m still addding new functions to it
and hope to release it next week but before needs to clearn up and make certain there is t almost no bug
don’t want to release this with 10 bugs in it this time

but it will be use the multilevel menu like we used in ligthwizard set up
so that should be easy to select things and add or delete last object

but for now trying to finish adding new function and debugging these which is going well for now
nothing very complicated but this need time to make certain it works fine

and as i said i’m thinking of ways to reduce qty of lines as much as possible and keep it simple

for this one don’t think it is necessary to ahve several file
all function are just simple and short and easy to find in one file

and for adding multiple files
well i never did that before and it may be a way to structure it
but don’t really like it cause again you got to go from one file to another
which makes it more difficult to debug
it may be a good way but have to learn how to make it work with the file i guess
have to see a good tut on how to structure these sub folder

is there anything available on this subject like a tut , wiki page or some video showing how to?


get it bug free first, then think about reducing it or optimizing for ‘line quantity’

in a sense i agree, but imagine if blender.c was one big file it would be over a million lines long. Saying it is more difficult to debug by that definition is not really valid. Something is only difficult to debug if you don’t understand the code.

simply look at any of the scripts that uses a folder and an, find the simplest one, and take it apart. Figuring it out by yourself will teach you more than having it regurgitated for you. It’s a worthwhile exercise simply to take the time to do it.