quote

Triple-double quote v.s. Double quote

时光怂恿深爱的人放手 提交于 2019-11-30 06:02:05
What is the preferred way to write Python doc string? """ or " In the book Dive Into Python , the author provides the following example: def buildConnectionString(params): """Build a connection string from a dictionary of parameters. Returns string.""" In another chapter , the author provides another example: def stripnulls(data): "strip whitespace and nulls" return data.replace("\00", "").strip() Both syntax work. The only difference to me is that """ allows us to write multi-line doc. Is there any difference other than that? From the PEP8 Style Guide : PEP 257 describes good docstring

C# how to replace Slash Quote \\\"

时光毁灭记忆、已成空白 提交于 2019-11-29 16:40:27
I'm trying to create a search and replace string like this: src=\"/path/file.jpg\" into src=\"http://mysite.com/path/file.jpg\" By searching for the property src and the equals slash quote. The problem is creating the search string, every time I do it, it becomes a search for src=\\"/ instead of src=\"/ if property = "src" in this segment, how can I get it to work? string equalsSlashQuote = "=" + @"\" + "\""; string search = property + equalsSlashQuote + "/"; string replace = property + equalsSlashQuote + SiteURL + "/"; input = input.Replace(search, replace); The problem is the \, I even tried

The #' in common lisp

不想你离开。 提交于 2019-11-28 09:52:32
In chapter 3 of Practical Common Lisp book there's an example of a SQL-like select and where functions. Here's a simplified version of it: (defun where (x) #'(lambda (item) (> item x))) and it is used like this: (remove-if-not (where 2) (list 1 2 3 4)) Earlier in the book it is explained that the #' sequence is used to state that it is followed by a function name, rather than a variable that requires evaluation. I don't understand why it's needed here. I tried implementing the where function without it and it worked as well: (defun where (x) (lambda (item) (> item x))) I tried googling for it,

Lisp, cons and (number . number) difference

*爱你&永不变心* 提交于 2019-11-28 02:04:51
What is the difference between (cons 2 3) and '(2 . 3) in Lisp? '(2 . 3) is a dotted pair. (cons 2 3) creates a dotted pair too. So these should evaluate to the same thing. So one is a literal for a dotted pair, the other one creates a dotted pair. They are not exactly the same, even though they evaluate to the same values in the REPL. Consider these examples, in which cons cells are modified destructively: TEST> (defun literal-cons () (let ((cons '(1 . 2))) (incf (cdr cons)) cons)) LITERAL-CONS TEST> (literal-cons) (1 . 3) TEST> (literal-cons) (1 . 4) TEST> (literal-cons) (1 . 5) Compared to

How can I accommodate a string with both single and double quotes inside of it in Javascript

陌路散爱 提交于 2019-11-27 23:05:32
I have an application, and it is fed some HTML. It then needs to put that HTML into a string. This HTML contains single and double quotes. Is it possible, in javascript, to declare a string with information inside of it, that does not use single or double quotes? Thanks, and I guess if it is not possible, does anyone know a simple and easy way to escape these quotes so I can put it in a string? Keep in mind, part of this string will be javascript that I will later need to execute. Thanks! You need to escape the quotation characters with \ : var someString = 'escape all the quotation marks \"\'

Lisp, cons and (number . number) difference

痴心易碎 提交于 2019-11-27 04:50:53
问题 What is the difference between (cons 2 3) and '(2 . 3) in Lisp? 回答1: '(2 . 3) is a dotted pair. (cons 2 3) creates a dotted pair too. So these should evaluate to the same thing. So one is a literal for a dotted pair, the other one creates a dotted pair. 回答2: They are not exactly the same, even though they evaluate to the same values in the REPL. Consider these examples, in which cons cells are modified destructively: TEST> (defun literal-cons () (let ((cons '(1 . 2))) (incf (cdr cons)) cons))

The #' in common lisp

假如想象 提交于 2019-11-27 03:16:37
问题 In chapter 3 of Practical Common Lisp book there's an example of a SQL-like select and where functions. Here's a simplified version of it: (defun where (x) #'(lambda (item) (> item x))) and it is used like this: (remove-if-not (where 2) (list 1 2 3 4)) Earlier in the book it is explained that the #' sequence is used to state that it is followed by a function name, rather than a variable that requires evaluation. I don't understand why it's needed here. I tried implementing the where function

How to escape single quote in sed?

帅比萌擦擦* 提交于 2019-11-26 03:39:05
问题 How to escape a single quote in a sed expression that is already surrounded by quotes? For example: sed \'s/ones/one\'s/\' <<< \'ones thing\' 回答1: Quote sed codes with double quotes: $ sed "s/ones/one's/"<<<"ones thing" one's thing I don't like escaping codes with hundreds of backslashes – hurts my eyes. Usually I do in this way: $ sed 's/ones/one\x27s/'<<<"ones thing" one's thing 回答2: One trick is to use shell string concatenation of adjacent strings and escape the embedded quote using shell

When to use &#39; (or quote) in Lisp?

六月ゝ 毕业季﹏ 提交于 2019-11-26 01:38:58
问题 After making it through the major parts of an introductory Lisp book, I still couldn\'t understand what the special operator (quote) (or equivalent \' ) function does, yet this has been all over Lisp code that I\'ve seen. What does it do? 回答1: Short answer Bypass the default evaluation rules and do not evaluate the expression (symbol or s-exp), passing it along to the function exactly as typed. Long Answer: The Default Evaluation Rule When a regular (I'll come to that later) function is

What is the difference between quote and list?

梦想与她 提交于 2019-11-26 00:25:42
问题 I know that you can use \' (aka quote ) to create a list, and I use this all the time, like this: > (car \'(1 2 3)) 1 But it doesn’t always work like I’d expect. For example, I tried to create a list of functions, like this, but it didn’t work: > (define math-fns \'(+ - * /)) > (map (lambda (fn) (fn 1)) math-fns) application: not a procedure; expected a procedure that can be applied to arguments given: \'+ When I use list , it works: > (define math-fns (list + - * /)) > (map (lambda (fn) (fn