Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Quick question, is there any difference between these two following bits of code?
Example 1
print("hello,", end='')
print(" world")
Example 2
print ("hello, world")
I don't see a difference in output, why would I use one over the other?
Thanks in advance for any answers
You would only really use the first one in cases where you may want to keep outputting things onto the same line (think logging something onto one line in a loop for some reason).
Otherwise use the simpler option.
If you use end='' it avoids the newline that python normally inserts in a print statement.
In practice, there's no reason to do it the first way with a short string like that, but if you wanted to put other variables in the output, it could be useful.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
As an exercise we need to explain what happens when we leave an open paranthesesis in a print statement.
Doing so does not give us an error nor a value, the resulting line gives us a prompt consisting of dots instead of arrows. Does this situation/prompt have a name and can someone explain?
for example:
>>>print('Hello'
...
The official name is secondary prompt. It is used when inputting incomplete constructs, for example not closing any set of parentheses or when defining a function.
The three greater-than signs (>>>) prompts for the next command, which the interpreter can process at once. The three dots (...), in its turn, prompts the continuation lines, such as print(: interpreter can't process your command at once, because it, in this case, doesn't know the arguments you want to pass to the function.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to create, via VBA, an "IF" command which would sound an specifc sentence when a pre determined condition is reached. Could you help me, please?
The only thing I know is that I need to use the "application.speech.speak" command. That is it.
PS: dear forum friends, as I am testing a suggested sent solution I ask you to wait a little while to see if it will work, avoiding taking your time. Thank you all.
Something like this maybe? You can use other conditions, of course.
Sub test()
If 1 = 1 Then
Application.Speech.Speak ("hello world")
End If
End Sub
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am trying to run a program via its CLI. The command is something like this:
./Program -t -s -variables Param1=Value1,Param2="Value2=SubValue"
However, the Param2 is not accepted by the program. How can I pass in the "Value2=Subvalue" as is?
It depends on how the program is parsing the command line arguments. My guess is that the program is setting Param1 equal to Value1,Param2=Value2=SubValue. Try a space between Param1 and Param2. What program is this? What does the documentation say?
Without knowing which command it's a bit difficult to know how it expects its parameters, but generally they are not separated by commas. Try removing that and putting a space there instead.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am not fully satisfied with the format of GHC error messages. How can I make a custom print function?
You want to modify GHC? well, it's open-source so you can change it however you wish and recompile but that would probably be a gigantic overkill.
If I really really wanted to, I'd make a program that calls GHC with the arguments it receives, read back the output, process it, then print it.
You can do it with System.Process.readProcessWithExitCode, specifically.
You might be tempted to use readProcess for its easier API, but it will only read from stdout and you're almost certainly want stderr too.
Plus the exit-code in the former function could be very helpful too: you could know if compilation succeeded or not without even parsing, but by just seeing if the exit code = 0.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
the parsing of user name has a ' inside of the user name
and i think that is causing the code to break
when i set it with this
tempUsername=Request.Form("UserName")
if (Request.Form("Action") = "Login") then
tempUsername=Request.Form("UserName")
tempPassword=Request.Form("UserPassword")
is that assumption right?
if so what is a solution to this?
Jumping onto the comment by James, as well as answering this question:
Input sanitization is an issue in every language. Even if there weren't ' characters in usernames, this code is danger++
At the very least, run all the data you get from Request.form through a function that escapes/sanitizes dangerous characters in the context of what the data is getting passed on to (such as data stores or dir-resolving code).
As for the code using <%, that's a sign this is an ASP script, and the syntax looks like it's VB. The (Request.Form("Action") = "Login") in particular is a dead give-away, because no sane programming language since the 80s uses "=" as an equality testing operator =)