Python Comment Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us which of the following is invalid commenting style in python mcq Learn more about Stack Overflow the company Business Learn more about hiring developers
Which Of The Following Is Invalid Commenting Style In Python A) /* */ B) # C) ''' ''' D)
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack python invalid syntax in comment Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error: invalid syntax when trying to
The Code Inside Comments Be Executed At Some Situations
comment up vote 0 down vote favorite I am a total beginner here, not familiar with any type of code at all and I thought python would be a good start. So when I try commenting multiple lines I get a syntax error. I added in the code, please help me and forgive me for obvious mistakes. I apologise for my action. print ("no comment") ''' print to have a block of code in python what we should do to that code ("this is a comment") print ("so is this") ''' print (" not a comment") python comments share|improve this question edited Feb 28 '14 at 22:37 Maxime Lorant 14.7k103661 asked Oct 21 '13 at 17:26 Thijs Vollebregt 611 3 That's not commenting. –kindall Oct 21 '13 at 17:28 1 Are you sure? I tried running your code (after removing the indents), and it ran fine. Try posting the rest of your code, and the specific error you have. (You can add info to your post by pressing "edit" in the lower-left of the question) –Michael0x2a Oct 21 '13 at 17:28 2 @kindall It is effectively a comment. (See reference) –ford Oct 21 '13 at 17:30 Please show actual code that causes the error, and the actual error with traceback instead of just a description of it. –abarnert Oct 21 '13 at 17:46 Depending on the context, such a "comment" may be treated as a docstring. Take some time to learn how to use your text editor to comment out multiple lines at once. –chepner Oct 21 '13 at 18:01 add a comment| 7 Answers 7 active oldest votes up vote 3
Gallery Downloads TUTORIALS Activity Awards All Activity My Activity Streams Unread Content Content I Started Search More Support More Welcome Guest! Welcome to C4D Cafe forum, largest CINEMA 4D
The Code Inside Comments Be Executed At Some Situations In Python
forum and best place to learn CINEMA 4D and 3D in general. We are
How To Comment In Python
friendly group of hobby and professional artists all over the world, join and share your work and knowledge! Sign In Sign python triple quote Up All Activity Home Forums Questions / Tips / Techniques XPresso / Python Scripting Python - Syntax Error In Comments, Also Line 4 Sign in to follow this Followers 0 Python - Syntax Error http://stackoverflow.com/questions/19500953/syntax-error-invalid-syntax-when-trying-to-comment In Comments, Also Line 4 Started by tkstorm, March 28, 2012 4 posts in this topic tkstorm 0 Joined: Oct 2010 Regular Member 0 36 posts C4D Ver:13 Studio Posted March 28, 2012 Hey all - I'm having a heck of a time using cinema's python editor. For starters, when I open a script someone else started, if I hit the delete key I always delete 3-4 http://www.c4dcafe.com/ipb/forums/topic/67375-python-syntax-error-in-comments-also-line-4/ characters at a time instead of one. Now, when I've written my own script, I'm getting syntax errors in commented lines (specifically mid way through the last line, 27). I can't imagine why this is happening. If I don't get them on commented lines, I get them on line 4 (always line 4) at some random point. Attached is my code import c4d #Welcome to the world of Python def main(): obj_spline = doc.SearchObject("egypt_spline") obj_dest = doc.SearchObject("egypt_target") obj_dest_tan = doc.SearchObject("egypt_target_tangent") #obj_mid = doc.SearchObject("egypt_midpoint") #obj_mid_tan1 = doc.SearchObject("egypt_midpoint_tangent1") #obj_mid_tan2 = doc.SearchObject("egypt_midpoint_tangent2") p1 = obj_dest.GetMg().off p2 = obj_dest_tan.GetMg().off dist = p2-p1 obj_spline.SetTangent(2,dist,-dist) #pmid = obj_mid.GetMg().off #pmidtan1 = obj_mid_tan1.GetMg().off #pmidtan2 = obj_mid_tan2.GetMg().off #middist1 = pmidtan2-pmid #middist2 = pmidtan1-pmid #obj_spline.SetTangent(1,middist1,middist2) [/CODE] Go to top Share this post Link to post Share on other sites UngaBunga 0 Joined: Aug 2011 Regular Member 0 141 posts C4D Ver:12 (or older) Location: Munich Posted March 29, 2012 Hi, i had similar strange syntax errors when i was using c.o.f.f.e.e. in my last project. this can happen when there are some left over "tab stops" (indentions) in the code (see picture). At least it worked for me after cleaning them up. Hope this helps you too. Greetings Unga Go to top Shar
Syntax Forum View Course 18 points Submitted by Tanner Semerad about 4 years ago Shouldn't this lesson also be "solved" using three single quotes? Isn't this: ''' https://www.codecademy.com/en/forum_questions/508186b293ac6f020000172a I'm a multiline comment! ''' The same as this: """ I'm a multiline comment! """ The lesson only accepts the double quotes. 3 votes permalink Both are used for creating multi-line https://www.tutorialspoint.com/python/python_basic_syntax.htm strings. The use of quotes (double or otherwise) to create a multi-line comment comes from its use in creating a docstring, when placed right after a function definition. But really, you're just in python creating a string that doesn't get used within the program. Try it yourself... >>> """ this is not a comment """ ' this is not a comment ' >>> type(""" this is not a comment """)
Python - Basic Syntax Python - Variable Types Python - Basic Operators Python - Decision Making Python - Loops Python - Numbers Python - Strings Python - Lists Python - Tuples Python - Dictionary Python - Date & Time Python - Functions Python - Modules Python - Files I/O Python - Exceptions Python Advanced Tutorial Python - Classes/Objects Python - Reg Expressions Python - CGI Programming Python - Database Access Python - Networking Python - Sending Email Python - Multithreading Python - XML Processing Python - GUI Programming Python - Further Extensions Python Useful Resources Python - Questions and Answers Python - Quick Guide Python - Tools/Utilities Python - Useful Resources Python - Discussion Selected Reading Developer's Best Practices Questions and Answers Effective Resume Writing HR Interview Questions Computer Glossary Who is Who Python Basic Syntax Advertisements Previous Page Next Page The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages. First Python Program Let us execute programs in different modes of programming. Interactive Mode Programming Invoking the interpreter without passing a script file as a parameter brings up the following prompt − $ python Python 2.4.3 (#1, Nov 11 2010, 13:34:43) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> Type the following text at the Python prompt and press the Enter: >>> print "Hello, Python!" If you are running new version of Python, then you would need to use print statement with parenthesis as in print ("Hello, Python!");. However in Python version 2.4.3, this produces the following result: Hello, Python! Script Mode Programming Invoking the interpreter with a script parameter begins execution of the script and continues until the script is finished. When the script is finished, the interpreter is no longer active. Let us write a simple Python program in a script. Python files have extension .py. Type the following source code in a test.py file: print "Hello, Python!" We assume that you have Python interpreter set in PATH variable. Now, try to run this program as follows − $ python test.py This produces the following result: Hello, Python! Let us try another way to execute a Python script. Here is the modified test.py file − #!/usr/bin/python print "Hello, Python!" We assume that you have Python interpreter available in /usr/bin directory. Now, try to run this program as follows