vscode won't let me put double quotes either.I can double quotes in Ternimale, but nowhere else. What should I do? I'm learning to code for the first time
kodum çalışmıtryekjfd
Related
I am a beginner of web scripting.
I was following a tutorial on Edureka: A Beginner’s Guide to learn web scraping with python!.
There is a syntax error shown inside the URL of my script:
driver.get('<a href='https://www.jbhifi.com.au/products/lenovo-ideapad-slim-5i-15-6-full-hd-laptop-512gb-intel-i5'>https://www.jbhifi.com.au/collections/computers-tablets/windows-laptops?page=4')
The invalid syntax seems under com, which is very confusing to me.
I have no idea how to solve it.
The syntax error is because you are enclosing your string with single quotes, and you also have single quotes inside the string. So Python thinks that everything after '<a href=' is not a string, but it can't interpret that other stuff as Python code, so Python gives up and raises an error.
Normally you would deal with this by enclosing the string with double quotes, or by escaping the single quotes. However, with driver.get, you don't use the <a href="..."> part; you just give it the URL. So you can do this:
driver.get('https://www.jbhifi.com.au/collections/computers-tablets/windows-laptops?page=4')
You cannot use same type of quotes inside and out within the same string. You can either use single and double quotes together or you can escape it. Modify your script as follows:
driver.get('<a href="https://www.jbhifi.com.au/products/lenovo-ideapad-slim-5i-15-6-full-hd-laptop-512gb-intel-i5">)
I am trying to wrap the following code with the markdown code block backticks:
users_pipeline = ["$match":{"created.user":{"$exists":True}}},
{"$group":{"_id":"$created.user",
"count":{"$sum":1}}},
{"$sort":{"count":-1}},
{"$limit":10}]
results = [doc for doc in db.Houston.aggregate(users_pipeline)]
But I think the quotes and special characters (like dollar sign and quotes) are getting in the way. I'm not sure how to work around this. I've tried using escape characters but it doesn't seem to improve
This is what it looks like when I run the cell:
I think you are missing an opening brace, (note the [{" before $match)
users_pipeline = [{"$match":{"created.user":{"$exists":True}}},
{"$group":{"_id":"$created.user",
"count":{"$sum":1}}},
{"$sort":{"count":-1}},
{"$limit":10}]
results = [doc for doc in db.Houston.aggregate(users_pipeline)]
would make much more sense?
I'm writing a python plugin for vim and it's looking like the only way to call a specific command is with the vim.command function. However, just substituting values into the function seems like a bad idea. How would I escape values so that I can pass untrusted data as an argument into a vim function? As a simple example, let's say I want to echo out untrusted input (I know I could just use print, but this is just an example). I would do something like:
value = get_data_from_untrusted_source()
vim.command("echo %s" % value)
However, if that untrusted data has a | in it, the command is ended and a new one is executed which is bad. Even if I use quotes, we end up with sql injection like attacks where an attacker can just put an apostrophe in their response to end the string. Then if we double quote, it could be possible to put a backslash somewhere to end the quote. For example if we just double quotes we would go from \' to \'' which escapes the first quote.
Basically what I'm asking is if there's a safe way to call vim functions from a python plugin and would appreciate any help.
I noticed this code:
os.system("'{0}'".format(path))
and saw that some one had change it to this:
os.system("\"{0}\"".format(path))
I was wondering by changing it from single to double quotes what advantages does it give you?
Here is the original commit I pulled it from: https://github.com/mattn/legit/commit/84bd1b1796b749a7fb40e0b734d2de29ddc9d3d9
Not much really but rule of thumb use single quotes for literal assignments and prints. That way you will avoid printing things that shouldn't be there in the first place.
Single quotes are often useful because they are literal, and contain exactly the characters you type e.g. 'Hi there/' will actually print Hi there/
However, if you need something like 'Hi there /n', if you put it in single quotes it will give you literally 'Hi there /n' whereas double quotes will give you the result you need "Hi there" and then break line.
On windows, command line arguments are parsed by the program it-self, not shell or cmd.exe. And most of windows programs parse quoted strings with double quote in generally. python.exe is the same. On unix OSs, command line arguments are parsed by shell. And most of shells parse single/double quote both. of course, double quote expand $ or something which the shell can treat. However, path will not contains $.
This change is workaround to be possible to work legit on many OSs.
In Vim, it's a quick 3-character command to change what's inside the current quoted string (e.g., ci"), but is there a simple way to change what type of quotes are currently surrounding the cursor?
Sometimes I need to go from "blah" to """blah""" or "blah" to 'blah' (in Python source code) and I'd ideally like to do it quickly using default key bindings.
Try the surround.vim plugin. I find it an essential addition to any vim installation.
Surround.vim is great, but I don't think it'll handle your triple-quoted needs directly.
The way I've done stuff along these lines (when surround wasn't appropriate) was to use %, make the change, then double-backtick to go back to the starting point. E.g. if the cursor is somewhere in a single-quoted string, do f'%, make the change, then double-backtick and ..