indentation

Python: I'm getting an 'indented block' error on the last 3 quotes (“”") of my comments under functions. What's up?

孤者浪人 提交于 2019-11-28 09:03:04
问题 Super odd, no? The offending code: def main(): """ main function """ # Argument handling args = sys.argv[1:] if not args: print "usage is: ... The third quote is where I get the usual indentation error: >>>Import someScript Traceback (most recent call last): File "<stdin>", line 1, in <module> File "someScript.py", line 24 """ ^ If I delete the comments (obviously I don't want to) then the next function to be defined gets the same error, at the same location of its comments. If I delete all

IndentationError expected an indented block

白昼怎懂夜的黑 提交于 2019-11-28 07:35:51
Here is the code.: def myfirst_yoursecond(p,q): a = p.find(" ") b = q.find(" ") str_p = p[0:a] str_q = p[b+1:] if str_p == str_q: result = True else: result = False return result Here is the error: Traceback (most recent call last): File "vm_main.py", line 26, in <module> import main File "/tmp/vmuser_ssgopfskde/main.py", line 22 result = False ^ IndentationError: expected an indented block What's wrong with my code? You've mixed tabs and spaces. This can lead to some confusing errors. I'd suggest using only tabs or only spaces for indentation. Using only spaces is generally the easier choice.

PHP: Using Proper Indentation with Heredocs [duplicate]

主宰稳场 提交于 2019-11-28 07:21:14
问题 This question already has an answer here: HEREDOC interfering with code indentation 6 answers I just read thought php doucmentation for heredocs but I did not see any way to intent the code properly. Is this possible in php? Right now I am doing this, but this is bad for readability. <?php if(something){ ... echo <<< END This is a test. I am writing this text out. END; } # end of if statment I would like to have something like this: <?php if(something){ ... echo <<< END This is a test. I am

Android Studio “This file is indented with tabs instead of 4 spaces”

独自空忆成欢 提交于 2019-11-28 07:13:05
I keep getting a message popping up in Android Studio whenever I edit a file. It says, "This file is indented with tabs instead of 4 spaces." I can click "OK" or "Indent with 4 spaces" and I know there are ways to change to tabs (see this question ), but it is a little annoying to have this message pop up all the time. I even tried clicking "Show Settings" and then "Use tab character" but I still got the message popping up. Why does it always come up? What can I do about it? Note: My Java project was imported from Eclipse. Suragch The JetBrains IntelliJ IDEA Blog states : If you’ve already

How to set HTML Auto Indent format on Sublime Text 3?

◇◆丶佛笑我妖孽 提交于 2019-11-28 06:11:28
I have a question while I'm writing HTML code on Sublime Text 3. I just want to set auto indent format of HTML. For example, when I write p tag like under code, the indentation works like that. <p> Hello world! </p> But I want to write like under code instead of above. <p> Hello world! </p> And not only p tag also ul, ol and etc. How can I set auto indent format of HTML on Sublime Text 3? One option is to type [command] + [shift] + [p] (or the equivalent) and then type 'indentation'. The top result should be 'Indendtation: Reindent Lines'. Press [enter] and it will format the document. Another

Conditional with statement in Python

别来无恙 提交于 2019-11-28 05:12:32
Is there a way to begin a block of code with a with statement, but conditionally? Something like: if needs_with(): with get_stuff() as gs: # do nearly the same large block of stuff, # involving gs or not, depending on needs_with() To clarify, one scenario would have a block encased in the with statement, while another possibility would be the same block, but not encased (i.e., as if it wasn't indented) Initial experiments of course give indentation errors.. If you want to avoid duplicating code and are using a version of Python prior to 3.7 (when contextlib.nullcontext was introduced) or even

Visual Studio, per solution indentation settings

只谈情不闲聊 提交于 2019-11-28 05:09:44
I'm working on a couple of different things and some use tabs, some use 2 spaces for indents, another users 4 spaces for indents etc. The option to set this in Visual Studio is in Tools->Options->Text Editor-><language>->Tabs Is there some way to override these settings on a per solution bases? Here is one (admittedly hacky) way to achieve what you are looking for: 1) create a macro that changes the indentation ( source ) Sub Set-Indent(indent As integer) Dim props As EnvDTE.Properties = DTE.Properties("TextEditor", "C/C++") Dim ts As EnvDTE.Property = props.Item("TabSize") Dim ins As EnvDTE

Proper indentation in Django templates (without monkey-patching)?

女生的网名这么多〃 提交于 2019-11-28 04:48:13
问题 I want to generate human-readable HTML and CSS code (properly indented) preprocessed by the Django template system for my standalone application. I've modified the render method from the NodeList class found in the django.template.base module. My code seems to work properly, but I'm using monkey-patching to replace the old render method. Is there a more elegant way that does not use monkey-patching in this case? Or maybe monkey-patching is the best way here? My code looks like this: ''' This

Xcode: Adjusting indentation of auto-generated braces?

别等时光非礼了梦想. 提交于 2019-11-28 03:49:08
Code auto-generated by Xcode seems to have the opening brace on the same line by default: @interface Controller : NSObject { } I'd like the opening brace on a line of its own, like this: @interface Controller : NSObject { } This applies in general to any method / class auto-generated by Xcode. In Xcode preferences I have "Indent solo { by" set to 0: How can I fix this? For Xcode 3.x, you can use the following: If you open up a terminal session and enter defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }' it will start new blocks of code on a new line.

Emacs version 24.4: New obnoxious loss of indentation on hitting RETURN

谁说胖子不能爱 提交于 2019-11-28 03:38:34
问题 Starting with Emacs 24.4, when I type a line beginning with white space (a typical way to denote a new paragraph) and at the end of it I hit RETURN, the white space disappears. This problem appears also with 'emacs -Q'. My .emacs file uses a rather plain text-mode paragraphing scheme, namely, (setq default-major-mode 'text-mode) (add-hook 'text-mode-hook 'paragraph-indent-minor-mode) which has been working without problems for a dozen years. The bug appeared when I installed the current (24.4