comments

How to remove '#' comments from a string?

旧街凉风 提交于 2020-01-01 19:00:57
问题 The problem: Implement a Python function called stripComments(code) where code is a parameter that takes a string containing the Python code. The function stripComments() returns the code with all comments removed. I have: def stripComments(code): code = str(code) for line in code: comments = [word[1:] for word in code.split() if word[0] == '#'] del(comments) stripComments(code) I'm not sure how to specifically tell python to search through each line of the string and when it finds a hashtag,

How can I include user profile's images/logos on django comments

别来无恙 提交于 2020-01-01 15:05:14
问题 I've posted this on django-users but haven't received a reply! So I have my own profile objects for users (subclass of User). One of the fields is imagefield, which is (obviously) used for users to upload their logo/thumbnail. The question is how I can include this on their comments? Any ideas? Thanks in advance! 回答1: Subclassing User is not recommended in Django. Instead, create a separate profile model. Let's assume you have your app, foo . In foo's models.py , add: class FooUserProfile

How can I include user profile's images/logos on django comments

六眼飞鱼酱① 提交于 2020-01-01 15:04:57
问题 I've posted this on django-users but haven't received a reply! So I have my own profile objects for users (subclass of User). One of the fields is imagefield, which is (obviously) used for users to upload their logo/thumbnail. The question is how I can include this on their comments? Any ideas? Thanks in advance! 回答1: Subclassing User is not recommended in Django. Instead, create a separate profile model. Let's assume you have your app, foo . In foo's models.py , add: class FooUserProfile

How can I include user profile's images/logos on django comments

主宰稳场 提交于 2020-01-01 15:04:08
问题 I've posted this on django-users but haven't received a reply! So I have my own profile objects for users (subclass of User). One of the fields is imagefield, which is (obviously) used for users to upload their logo/thumbnail. The question is how I can include this on their comments? Any ideas? Thanks in advance! 回答1: Subclassing User is not recommended in Django. Instead, create a separate profile model. Let's assume you have your app, foo . In foo's models.py , add: class FooUserProfile

Is it possible to use the Google Spreadsheet API to add a comment in a cell?

别说谁变了你拦得住时间么 提交于 2020-01-01 10:28:35
问题 I am looking at the CellEntry API (https://developers.google.com/gdata/javadoc/com/google/gdata/data/spreadsheet/CellEntry) to see how I could add comments (and ideally notes as well) to a cell, but don't see anything obvious like "addComment()". Anyone have an idea? Thanks 回答1: With google sheet API v4 you can set a note using spreadsheets.batchUpdate. Example javascript sdk: var requests = []; requests.push({ "repeatCell": { "range": { "sheetId": yourSheetId, "startRowIndex": 1,

Embed comments within JavaScript regex like in Perl

拈花ヽ惹草 提交于 2020-01-01 10:01:57
问题 Is there any way to embed a comment in a JavaScript regex, like you can do in Perl? I'm guessing there is not, but my searching didn't find anything stating you can or can't. 回答1: You can't embed a comment in a regex literal. You may insert comments in a string construction that you pass to the RegExp constructor : var r = new RegExp( "\\b" + // word boundary "A=" + // A= "(\\d+)"+ // what is captured : some digits "\\b" // word boundary again , 'i'); // case insensitive But a regex literal

Embed comments within JavaScript regex like in Perl

南笙酒味 提交于 2020-01-01 10:01:53
问题 Is there any way to embed a comment in a JavaScript regex, like you can do in Perl? I'm guessing there is not, but my searching didn't find anything stating you can or can't. 回答1: You can't embed a comment in a regex literal. You may insert comments in a string construction that you pass to the RegExp constructor : var r = new RegExp( "\\b" + // word boundary "A=" + // A= "(\\d+)"+ // what is captured : some digits "\\b" // word boundary again , 'i'); // case insensitive But a regex literal

How to make inline comments in Org-mode?

二次信任 提交于 2020-01-01 07:58:47
问题 In Org-mode there are several ways to make comments. But I do not know of any way to make inline comments. According to the manual regions surrounded by ‘#+BEGIN_COMMENT’ ... ‘#+END_COMMENT’ will not be exported. But this is only true if the said region starts a line. In the following #+TITLE: Test text #+BEGIN_COMMENT comment 1 #+END_COMMENT text text #+BEGIN_COMMENT comment 2 #+END_COMMENT text only comment 2 is treated as a comment. It exports (e.g. C-e A ) as text #+BEGIN_COMMENT comment

how to remove html comments in php

浪子不回头ぞ 提交于 2020-01-01 06:26:47
问题 I am trying to remove any comments embedded with the html file $data= file_get_contents($stream); <br> $data = preg_replace('<!--*-->', '', $data); <br> echo $data; I am still ending up with all the comments < !- bla bla bla --> What am I doing wrong? 回答1: The below regex will remove HTML comments, but will keep conditional comments. <!--(?!<!)[^\[>].*?--> 回答2: You could do it without using regular expression: function strip_comments($html) { $html = str_replace(array("\r\n<!--", "\n<!--"), "

Visual Studio C++ Multiline comments

一个人想着一个人 提交于 2020-01-01 02:59:05
问题 In VS C++ code, if i haven't selected anything or full line selected and press comment selection (Ctrl+K + Ctrl+C) then it will comment the whole line with // int x = 5; After Pressing Ctrl+K + Ctrl+C without anything selected or full line selected. // int x = 5; Now if I select some part of the line and press comments button again only selected text will be commented (bold means selected) int x = 5 ; After Pressing Ctrl+K + Ctrl+C with x = 5 selected. int /*x = 5*/; Incase of multiple lines