I'm trying to compile a project but I'm getting a invalid syntax error during tests with arrow point at the 'h' in with. I haven't written the code and it is fairly years old.
d = Gnuplot.Data(pnts,title=im_title,with='candlesticks')
I tried changing with
to something else but then I got different errors. What can I do to fix this issue?
Apparently this code was written before with
became one of the reserved keywords .
The (possible) workaround:
d = Gnuplot.Data(pnts, **{'title': im_title, 'with': 'candlesticks'})
Just checked, it won't work - they were using with
as a variable name extensively until Gnuplot.py 1.8 .
The solution for Gnuplot.py 1.8+ is to use with_
argument:
d = Gnuplot.Data(pnts, title=im_title, with_='candlesticks')
In PEP 8 - Style Guide for Python Code, the following guidance appears in the section Descriptive: Naming Styles :
single_trailing_underscore_ : used by convention to avoid conflicts with Python keyword
ie:
d = Gnuplot.Data(pnts,title=im_title,with_='candlesticks')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.