Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd May 2019, 01:30   #1  |  Link
SilSinn9801
Chiptuner & VapourSynther
 
SilSinn9801's Avatar
 
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 31
Breaking a long line of code into many lines without creating intermediate vars?

On C/C++ programming, a single long line of code (ending in the obligatory ';' semicolon) can be split into many short lines separated by newlines and whitespace (as long as the ; is only used at the end of the final split line) and still be treated as a single line of code by the parser.

Is there something similar on Python, the basis for VapourSynth?

Because I have an extremely-long line of code where I need to concatenate 88 video clips like this:
Code:
danmakuseq = danmaku00+danmaku01+danmaku02+danmaku03+danmaku04+danmaku05+(...)+danmaku83+danmaku84+danmaku85+danmaku86+danmaku87
and don't want to create too many intermediate clips or even turn on word-wrapping on my text editor.
SilSinn9801 is offline   Reply With Quote
Old 3rd May 2019, 02:06   #2  |  Link
HolyWu
Registered User
 
HolyWu's Avatar
 
Join Date: Aug 2006
Location: Taiwan
Posts: 619
Method 1: explicit line continuation using the line continuation character.
Code:
danmakuseq = danmaku00 + \
             danmaku01 + \
             danmaku02 + \
             danmaku03 + \
             danmaku04
Method 2: implicit line continuation by parentheses, brackets, or braces.
Code:
danmakuseq = core.std.Splice([danmaku00,
                              danmaku01,
                              danmaku02,
                              danmaku03,
                              danmaku04])
HolyWu is offline   Reply With Quote
Old 4th May 2019, 15:14   #3  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 721
Method 3: construct that with a for loop and eval().
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote
Reply

Tags
python, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.