I am not new to web automation with selenium but I am very new to python I am trying to create my own dynamic structure. With a little bit effort I can do the BE coding with python but when it comes to behave feature file I don't get the problem I am having. Basically my code works fine evet step that I have is implemented and it runs but when I am on PyCharm ide and open feature file my feature file looks like this
feature file
I couldn't find a solution online can anyone help me with this so steps can look normal and I can navigate to them by clicking ctrl + LMC
The problem is that PyCharm does not find the step definition.
Could you attach the directory tree of your project? It's possible that you don't follow Behave standards and that's why PyCharm is not able to find where the steps are defined.
Related
I am wondering if there is a way to to navigate Python(Django) code in Emacs similar to how one can M-. for Common Lisp code when using SLIME.
I have installed ELPY and a mode called python-django. However, they do not seem to provide this functionality.
I am particularly interested in doing this why developing using Django. However, even navigation for standalone Python projects would be nice.
I will give dumb-jump a chance.
It is not as fancy as other go-to-definition methods, as it only searchs for some predefined regex in your project. But it simply works most of the time, and you can add your own regex if you need them.
I made my own game in python using turtle graphics and I want to convert it to an executable file to run in HTML, is there any additional information I should know
Edit: An executable is not likely what you're looking for per Chris' answer. He also provides info about making an installer, if you do want to accomplish that. My answer addresses getting your Python game running in the browser.
When I initially saw this question, I thought it wasn't a thing. However, Python is just a language. Anything can interpret and run Python logic. It's just a matter if someone has built something that works in the browser and interprets Python.
After some Google searching, I found Skulpt: http://www.skulpt.org/. It appears to be a Javascript implementation of a Python interpreter. This is important because browsers only understand Javascript, not Python.
Something worth noting is that Skulpt appears to only have partial support for Python 3. It mostly focuses on Python 2. This could be a major concern because Python 2 is scheduled for end of life January 1st, 2020 (at least, that's what pip told me).
There are examples of using Skulpt on its page. Heads up that you'll likely need to learn some amount of Javascript, but if you're comfortable with Python already, that shouldn't be terrible.
Edit:
There also appears to be Brython: https://brython.info/. This is a Python 3-focused implementation. At first glance, it looks a little easier to use, too.
Hope this helps!
Please know that executables (.exe) & browsers tend not to work together.
See this stackoverflow question referring to .exe's & html The long & short of it is that you can setup .exe's so they can be downloaded, but not rendered in the browser.
If you want to convert your script to a .exe file, you'll need something like pyinstaller. Here's a link to some info about installing & using it.
TheBeege's answer is on point with rendering in the browser with python when you already have code written with turtle. I just wanted to make sure anyone coming here looking for info on python with executables could find it.
I am writing a script to log into web pages (I know it's a bad idea, and I don't care), but I need to run it with a bookmark from Firefox. Does anyone know how to help me?
There is no pre-made solution and as it stands, you left part of your question ambiguous.
But here is one possible outline on how you could accomplish what you want from completely inside firefox.
First off you need to get python in the browser, but it is normally compiled into machine code. The solution is the Transcrypt project, which is Python is transcompiled into javascript and that script is then loaded into your browser. This allows you to run python code.
Extensions to python are made so it can access the DOM in a similiar way you can from javascript.
The transcrypt website has some examples, and some more can be found at a draft page at Mozilla.
Your bookmarklet would be to load a script to load transcrypt and feed it your python code, something like
javascript:(function(){var el=document.createElement('script');el.src='file:///something/something/transcript_loader_and_my_python_code.js';document.body.appendChild(el);})();
But the exact bookmarklet would depend on how you go about things. Writing transcript_loader_and_my_python_code.js is on your own, but if you get the examples from the links above working it should be trivial.
I have searched for a basic tutorial regarding workspaces and projects in the Spyder IDE. What I want to understand is the basic concepts of how to use the workspace and projects to organize my code. It seems that this is perhaps basic programming skills and that is the reason why I have issues finding any kind of overview. This page seems to be related, but is actually about Eclipse and rather sparse. The Pythonxy tutorial and the documentation for Spyder does not go into any detail. Neither does the Anaconda documentation.
The questions I have are:
When should I set up a new workspace (if ever)?
When do I create a new project?
How does the PYTHONPATH depend on my workspace and project settings? Is it the same in all cases or can I customize it per workspace/project?
Are there other settings apart from the PYTHONPATH that I should configure?
How specific are the answers above to Spyder? Would it be the same for other IDEs, like Eclipse?
I am running Spyder on 64-bit Windows 7, as part of the Anaconda package.
Update Oct 2016: Spyder 3 now has project facilities similar to that of other IDEs (especially Rstudio).
Now you if you have a folder with scripts, you can go to
Projects > New Projects > Existing Directory
to import it. The selected directory will be set as the base directory for the project.
I use spyder for data analysis and I have just started using the project workspace. I believe that it allows you to write better code due to the organization. As a previous post stated that "This can be helpful in web development", which is true because web development requires good software engineering due to the complexity of the files and how they interact with each other. This organization/structure can be used in data analysis as well.
Often, data analysts that use Anaconda have an engineering or science background, not necessarily software engineering or computer science. This means that good software engineering principles may be missing (myself included). Setting up a workspace does one critical thing that I believe is missing from the discussion. It adds the workspace to the system path. Set up a project and then try
import sys
print sys.path
You will see your project's directory added to the PYTHONPATH . This means I can break up my project and import functions from different files within my project. This is highly beneficial when analysis becomes complex or you want to create some type of larger model that will be used on a regular basis. I can create all of my functions in one file, maybe functions for plots in another and then import them in a separate script file.
in myScript.py
from myFunctions import func1
from myFunctions import func2
from myPlots import histPlot
This is a much cleaner approach to data analysis and allows you to focus on one specific task at a time.
In python 3 there is the %autoreload capability so you can work on your functions and then go back to your script file and it will reload them each time if you find errors. I haven't tried this yet bc the majority of my work is in 2.7, but this would seem to add even greater flexibility when developing.
So when should you do this? I think it is always a good idea, I just started using this setup and I will never go back!
In my experience, setting up a workspace in Spyder is not always necessary.
A workspace is a space on your computer where you create and save all the files you work in. Workspaces usually help in managing your project files.
Once you create a workspace in Spyder, a pane called "Project Explorer" opens up inside Spyder. There you see in real-time the files of your project. For instance, if you generate a file with Python, it will show in that pane.
The pane let's you keep the files organized, filter them etc. This can be useful for web development for example because helps you keep your content organized.
I use Python to handle files (e.g. csv) and work with data (data analysis), and I find no use in the workspace feature.
Moreover, if you delete a file in the Project Explorer pane, the file cannot be found in the Windows recycle bin.
One critical piece of information that appears to be missing from the Spyder documentation is how to create a new workspace in the first place. When no workspace exists after installing Spyder, creating your first project automatically initiates the creation of a workspace (at least in the Anaconda 3 distribution). However, it is not as obvious how to create a new workspace when a workspace already exists.
This is the only method I have found for creating a new workspace:
(1) Select the Project explorer window in Spyder. If this window or tab doesn't appear anywhere in the Spyder application, use View > Panes > Project explorer to enable the window.
(2) Click on the folder icon in the upper-right corner of the Project explorer window. This icon brings up a dialog that can create a new workspace. The dialog allows selection of a directory for the .spyderworkspace file.
Are there any IDEs for Python that support automatic error highlighting (like the Eclipse IDE for Java?) I think it would be a useful feature for a Python IDE, since it would make it easier to find syntax errors. Even if such an editor did not exist, it still might be possible to implement this by automatically running the Python script every few seconds, and then parsing the console output for error messages.
eclipse+pydev
pycharm
many others ....
If you use VIM or don't have a problem with it, try this extension. https://github.com/klen/python-mode
This is for Emacs as well: https://github.com/gabrielelanaro/emacs-for-python
Also pycharm and eclipse with pydev work fine.
If I don't use vim I really enjoy spyder. It is easy to use and has some really nice features, like integrated debugging and profiling, graphical variable explorer and object inspector. The latter shows, e.g., the integrated documentation for every function of class you use.
I built an extension to Eclipse and PyDev that does what you describe, it runs the Python code as you're typing, and displays all the variable values and any exceptions that occur. It's called Live Coding in Python, and the web site has a tutorial and a demo video.
PyDev can highlight some problems in your code by analysing it, and Live Coding in Python can show you problems that happen when you run it.