indentation

Is there an alternative to hyper-indented code?

半城伤御伤魂 提交于 2019-12-18 04:12:07
问题 I often run into code that has to perform lots of checks and ends up being indented at least five or six levels before really doing anything. I am wondering what alternatives exist. Below I've posted an example of what I'm talking about (which isn't actual production code, just something I came up with off the top of my head). public String myFunc(SomeClass input) { Object output = null; if(input != null) { SomeClass2 obj2 = input.getSomeClass2(); if(obj2 != null) { SomeClass3 obj3 = obj2

Custom indent width for BeautifulSoup .prettify()

狂风中的少年 提交于 2019-12-18 03:03:22
问题 Is there any way to define custom indent width for .prettify() function? From what I can get from it's source - def prettify(self, encoding=None, formatter="minimal"): if encoding is None: return self.decode(True, formatter=formatter) else: return self.encode(encoding, True, formatter=formatter) There is no way to specify indent width. I think it's because of this line in the decode_contents() function - s.append(" " * (indent_level - 1)) Which has a fixed length of 1 space! (WHY!!) I tried

Indent starting from the second line of a paragraph with CSS

坚强是说给别人听的谎言 提交于 2019-12-17 22:05:02
问题 How can I indent starting from the second line of a paragraph? I've tried p { text-indent: 200px; } p:first-line { text-indent: 0; } and p { margin-left: 200px; } p:first-line { margin-left: 0; } and (with position:relative;) p { left: 200px; } p:first-line { left: 0; } 回答1: Is it literally just the second line you want to indent, or is it from the second line (ie. a hanging indent )? If it is the latter, something along the lines of this JSFiddle would be appropriate. div { padding-left: 1

How to add indentation on bullet list?

你。 提交于 2019-12-17 20:52:19
问题 I want to add some indentation to my text field. I've already added a bullet style (adding the <li> tag to the text) but it seems that JasperSoft Studio doesn't automatically indentate the text. Even if setting the "styled" markup and adding a <ul> tag at the top of the paragraph like this: "<ul><li> Example text 1... </li><li> Example text 2... </li></ul>" JasperSoft is still not able to manage the <ul> tag (looking at the documentation, unfortunately, also other HTML tags..) so the result

IndentationError expected an indented block

此生再无相见时 提交于 2019-12-17 18:29:42
问题 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? 回答1: You've mixed tabs and spaces. This can lead to some confusing errors. I

stopping vim from removing indentation on empty lines

让人想犯罪 __ 提交于 2019-12-17 16:06:43
问题 When the cursor is placed at the end of a line containing nothing but withspace characters, vim will, when i press enter, remove that whitespace. I find this irritating, as it breaks my script for selecting code that are indented to the same level. How can I prevent vim from doing this? In my .vimrc (http://bjuhn.com/randomstuff/vimrc) I have the following: filetype plugin on set copyindent that is, I am not using any syntax-aware auto-indention, as I have yet to find one that does everything

Why does vim not obey my expandtab in python files?

天涯浪子 提交于 2019-12-17 06:38:36
问题 After I installed Vundle, my vim no longer obeys the expandtab settings I had. My tabs were set to 2 spaces, but now in python files it no longer does that. The problem is being called by this line: filetype plugin on What does this line do (It is required by vundle)? Also, what can I do to make sure my settings are obeyed? Thanks! VIMRC: pastebin.com/tGmfCi78 回答1: The problem is that your settings are being overridden by a filetype plugin that's part of Vim. The issue is in ftplugin/python

Turning off auto indent when pasting text into vim

ε祈祈猫儿з 提交于 2019-12-17 02:39:05
问题 I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra spaces at the start of each new line: line line line I know you can turn off auto indent but I can't get it to work because I have some other settings conflicting or something (which look pretty obvious in my .vimrc but don't seem to matter when I take them out). How do I turn off auto indenting when I paste code but still have vim auto indent when I am writing code? Here is my .vimrc file:

Why shouldn't I mix tabs and spaces?

我的未来我决定 提交于 2019-12-16 19:58:10
问题 I often read that I shouldn't mix tabs and spaces in Haskell, or that I shouldn't use tabs at all. Why? 回答1: The problem is twofold. First of all, Haskell is indentation sensitive, e.g. the following code isn't valid: example = (a, b) where a = "Hello" b = "World" Both bindings need to be indented with the same number of spaces/tabs (see off-side rule). While it's obvious in this case, it's rather hidden in the following one, where I denote a space by · and a tab by » : example = (a, b) ·

Why shouldn't I mix tabs and spaces?

雨燕双飞 提交于 2019-12-16 19:57:57
问题 I often read that I shouldn't mix tabs and spaces in Haskell, or that I shouldn't use tabs at all. Why? 回答1: The problem is twofold. First of all, Haskell is indentation sensitive, e.g. the following code isn't valid: example = (a, b) where a = "Hello" b = "World" Both bindings need to be indented with the same number of spaces/tabs (see off-side rule). While it's obvious in this case, it's rather hidden in the following one, where I denote a space by · and a tab by » : example = (a, b) ·