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 5 days ago.
The community is reviewing whether to reopen this question as of 5 days ago.
Improve this question
I am new to programming/python. I have installed python v3.10 and other dependencies and using PyCharm as IDE.
I created new porject from IDE and did pip install backtrader[plotting] from terminal. After that I created new python file and copied code from its documentation. However run button is disabled for the project.
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import backtrader as bt
if __name__ == '__main__':
cerebro = bt.Cerebro()
print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
cerebro.run()
print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
I am following backtrader documentation from https://www.backtrader.com/docu/quickstart/quickstart/
Your help/pointer towards how to get started on this is highly appreciated. Thanks!
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 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I want to print some data from spreadsheet. I decided to use python. How can I call out a "Print preview"? For example like this:
I tried something like this:
os.startfile('test.txt', 'print')
but it doesn't make a print preview.
I am using Python 3.9.
Use this (tested on Windows 10):
import subprocess
subprocess.call(['notepad', '/p', "test.txt"])
On Linux use:
import os
os.system("lp text.txt")
As to previewing the file on screen, just use print function. If you want graphics use tkinter or any other graphics library (PyQt, etc)
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 1 year ago.
This post was edited and submitted for review 10 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I am building an Azure Data Factory pipeline and I would like to know how to get this parameter into the python script.
The python script is located in Databricks (DBFS) and is run from Azure DataFactory. So, in my ADF pipeline, I have some parameters which I'd like to introduce and use them insinde the python script.
Any idea on how does it work?
Post an answer to end this question:
Import argv from sys and then use argv[1] to get the parameter in databricks activity.
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
File "/Users/zineb/.local/lib/python2.7/site-packages/nltk/probability.py", line 333
print("%*s" % (width, samples[i]), end=" ")
^
SyntaxError: invalid syntax
You shouldn't be developing using python 2.7 anymore, 3.xx has been out for a long time and 2.x was EOL'd recently. Mac OS X has python3 installed as /usr/bin/python3.
To fix this error, you'll need to add from future import print_function at the top of /Users/zineb/.local/lib/python2.7/site-packages/nltk/probability.py.
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 3 years ago.
Improve this question
I am working on a Python Project and want to call multiple functions from other python files, but I'm having trouble. Can someone please help me?
Each of your Python file can act as a module, that you can import.
for example for numpy you just type 'import numpy' and then you'll be able to use numpy.sin() function.
by default you can only append modules located in sys.path. So What you can do is:
import sys
if not (<folder_with_your_function> in sys.path):
sys.path.append( <folder_with_your_function> )
import <your_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
It will great help if you can explain with code example or any useful resource.
you can use the in-built pdb library.
import pdb
a = 10
pdb.set_trace()
print(a)
So what it would basically do is, stop the program after line 2 is executed. and from there you would have command line access to the code with is execute above the set_trace() is added.
You can read more about it here.
The breakpoint() method is part of the python language now. See: https://www.python.org/dev/peps/pep-0553/
If you are using an earlier version of python then you can have the same functionality by importing pdb by import pdb at the top of you file and pdb.set_trace() where you want to be able to inspect variables.
When you are dropped into the pdb shell you type h to see what commands are available.