0

I can't seem to find a way to break the following lines of code out to multiple lines in compliance with the 79 character limit without breaking my project.

These are taken out of context, but I'm using them within an HTML template in Python 3. I searched quite a bit to find an answer to this, but couldn't find a case where it dealt with HTML inside of a Python file rather than the Python code itself.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<link href="https://fonts.googleapis.com/css?family=Roboto:500|Source+Sans+Pro" rel="stylesheet">

$('.modal').html('<iframe id="ytplayer" type="text/html" src="https://www.youtube.com/embed/' + trailer + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');

Thank you!

Matt Cook
  • 149
  • 1
  • 1
  • 9
  • Possible duplicate of [Pythonic way to create a long multi-line string](https://stackoverflow.com/questions/10660435/pythonic-way-to-create-a-long-multi-line-string) – Robert Moskal Jul 11 '17 at 02:27
  • @RobertMoskal My apologies if it is too similar. I couldn't quite find an answer to this type of case, where the subject is HTML code within a Python file rather than the actual Python code. – Matt Cook Jul 11 '17 at 02:56

1 Answers1

0

PEP8 is a guide not a standard. That said, you're coding in HTML, not Python, so the python style guide doesn't apply.

finally,

For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the nominal line length from 80 to 100 characters.

If you really want you can save each string as a variable based on which template system you're using then use the variable in the script or link lines.

Owen Hempel
  • 434
  • 2
  • 8
  • This is a part of a class project in which they want pretty strict PEP8 compliance. That makes a lot of sense though, that it wouldn't really be applicable to a different language's code within a Python file. This answers my question. Thank you! – Matt Cook Jul 11 '17 at 02:58
  • @shadow I'm assuming he's working with one of Django or Flask, both of which allow what I'm suggesting. – Owen Hempel Jul 11 '17 at 03:06
  • Do you think that saying 'as a variable in the templating language' instead would be clearer? – Shadow Jul 11 '17 at 04:22
  • @shadow just plain old Python for this project. I'll learn those at some point. – Matt Cook Jul 11 '17 at 14:58