Eclipse: Open ressource on folder - python

Is it possible in Eclipse (pydev) to include folder (names) in the Open Ressource file navigation?
When opening specific files in one of my projects I often use the Open Ressource (see the Eclipse help) dialog (Navigate -> Open Ressource). This way I don't have to remember (or keep track in a multi-developer project), where a specific file is placed, but only the file name.
This only seems to filter through file names. I would rather like to
(optionally) include the folder name
open python package file __init__.py in the editor
(or any other configurable custom file like __custom_module__.py)
How can I achieve this?

For finding any file, Ctrl+Shift+R (open resource) is good, but to find a Python package/module/class/method, Ctrl+Shift+T (Python tokens browser) is better -- you can filter by the module name as you want -- see the docs on the dialog when you open the tokens browser.
Note: you need to focus some PyDev editor for it to become active (such as the PyDev package explorer or a PyDev editor).
Note 2: You may still use a filter with folders in the open resource if you filter with the path (i.e.: *package/file*.py)

Related

Python files created do not save as python file

https://drive.google.com/file/d/0BwR0ium7uufRWnhXWWNFcVJ3S2c/edit?usp=sharing
The files that are blank and say "Credit Card Balance" and "mine" are the files which I created by opening up a new document in IDLE and creating a file. The ones with the little pictures and say ps2_newton are programs which I downloaded off of the internet. I can't open my files which I created like they are regular programs and have to open them under notepad to see the code. Why is this? How can I change my files to look and act like the ones I downloaded?
The files you downloaded have an extension of ".py", which tells Windows to open them with the Python launcher, while the ones you created have no extension, or an extension of ".txt", which tells Windows to open them in Notepad.
Since ".py" and ".txt" are both "known extensions", and you have Explorer configured to hide known extensions (which I believe is the default in all versions of Windows), it doesn't show them to you. However, you can see the difference in the icons.
You can configure Explorer to show all extensions, but this site is not the place to ask about that—try SuperUser.
Meanwhile, when you save your scripts, make sure you save them with a .py extension (or, if they're Tkinter or other GUI apps, with a .pyw extension).
I had the same problem. But I just deleted all of the é's and á's etc. And it worked! So try that IF it is an .py file. Otherwise I understand if it does not work becouse it isn't a python file. You change that by doing this: Save as. Just simply type .py after the file name.
PS Sorry for my bad english...

How to work within individual files rather than projects in PyCharm

Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects.
Is there a way to configure Pycharm to be used to open single files and not use projects?
Similarly, is it possible to just run a single page/file?
On Pycharm 5.0.4...
Open the file (i.e. by double clicking in explorer)
Navigate to File->Settings...
Expand the Project tab on the left and select 'project interpreter' from the options that appear beneath
Set your project interpreter from the dropdown menu, and you should be able now to run your file without creating a project
You can always open a single file (File > Open) but to actually run or debug the code from within Pycharm, or use most of its other features, it needs a correctly configured project.
What you can do is create a single project to hold all of your "assorted" code. I usually recommend creating a virtualenv for this project as well and using that as your Pycharm project interpreter. You can further divide this project into different packages to keep things organized.
Update: PyCharm 4.5 now provide Scratch Files which seem relevant to this question.
You have to work with a configured project (indicated by folders) but there is a work around... In Pycharm when you create a project you will have a default file in .py or any other format.
Just follow the steps to work with individual files..
right click on the folder (in left hand side project tree) and add new python file
double click on the newly added file ,it will now be open in a new tab
(BUT..if you try to run this new file pycharm will still compile the previous file ...so to change that..)
right click on the tab of your file and click run "file name" or you can press CTRL+shift+F10
done :)
From the command line
pycharm [path_to_your_file]
where pycharm on my machine is aliased to /opt/pycharm-community-3.1.1/bin/pycharm.sh in file ~/.bash_aliases.
As Preston mentioned, not all features seem to work: for example, navigation between files does not seem to work.
You can also create a .py file and implement it within a PyCharm project by dragging it into the editor. This method also allows you to use a separate text editor to create your .py file.

Setting up default pylint config.rc file in Windows

I'm using Pylint under Windows, and it's not reading my pylint-config.rc file.
Is there a way to set up a default .rc file for Python within windows so that I don't have to keep typing it into the command line?
Thanks.
I don't have a windows box at hand to test, but the code uses os.path.expanduser('~') to find the current user's home directory, and looks for a file calle .pylintrc in that directory.
According to the python documentation, on Windows, expanduser uses HOME and USERPROFILE if set, otherwise a combination of HOMEPATH and HOMEDRIVE. So my advice is to check in a Python interactive session what the following script outputs:
import os
print os.path.expanduser('~')
and put the configuration file as .pylintrc in that folder.
Alternatively, if you want to use different configuration files on a per project basis, you should know that if there is a file called pylintrc (without a leading dot) in the current working directory, then Pylint will use this one. If there is a file called __init__.py in the current working directory, Pylint will look in the parent directory until there is no such file and then look for a pylintrc configuration file. This is done so that you can maintain a per project config file together with you source code, and lauch Pylint from any directory in your source tree.
Since creating a file beginning with a dot is not allowed from Windows file explorer, you can create a template using:
pylint --generate-rcfile > .pylintrc
There are two possible ways to do this. One way is to edit the file C:\Python\Scripts\pylint.bat changing the line
python "%~dpn0" %*
to
python "%~dpn0" %* --rcfile="C:\path\to\pylint.rc"
Another way is to go to add an environment variable. Do this by going to Start->Control Panel->System then going to the Advanced tab and clicking Environment Variables. Then click New and create a variable named PYLINTRC with the value of C:\path\to\pylint.rc.

Don't display .pyc files in the Xcode 4 project navigator

I'm working on a fairly large django-project in Xcode 4. I prefer not to see all the automatically generated .pyc files in the project navigator.
Does anyone know a way to hide the .pyc files from the interface?
I don't necessarily want to remove them from disk.
Thanks.
-
What fails:
Checking "Show only files with source-control status" hides all files except the .pyc files... If only there is a way to invert this selection.
Showing files with matching name will also only give me a solution for solely showing the .pyc files. Typing ".py" also yields .pyc files...
The best I can come with is the way I do it: By dragging only the .py files into the XCode project at the start. It's not ideal; there should be a way to filter out build files. This method also isn't great for sub-folders, since you have to create each folder and then drag the .py files in for each folder by hand. But it works, and now I have no .pyc files in my project. Also, irritatingly, I can't delete .pyc files from the project once they're in there, so controlling things from the outset is the only solution I found.
given that this has not been answered directly here is an alternative solution using another programming software which is Coda 2.
You can create a rule that will hide those files, here is how to proceed :
First open your preferences from the main menu
Second go to the rules tab and create a new rule using the lower left "+" button
Give the rule a name, such as "Python compiled Files"
Select "Hide" from the right menu instead of "Skip"
Edit the first rule as showed to apply it to files which "Name" ends with "pyc"
Close the preferences pane and voilà, you are all set to keep being an efficient Coda user
This is taken from this website for sourcing purpose. It contains images illustrating this.

new to mac and textmate, can someone explain these shortcuts?

I'm using textmate for the first time basically, and I am lost as to what keys map to these funny symbols.
using python bundles, what keys do I press for:
run
run with tests
run project unit tests
Also, with textmate, do I actually define a project in textmate or do I just work on the files and textmate doesn't create its own .project type file ?
Check out this link for some of the translations to some of the keyboard symbols. This should help you out :)
Also here is a link from the Apple site for an exhaustive list of shortcuts.
(source: osxkeyboardshortcuts.com)
Also, with textmate, do I actually define a project in textmate or do I just work on the files and textmate doesn't create its own .project type file ?
You can do both. You can create a new project in TextMate by going to File -> New Project and add your files manually, or you can drag a folder into TextMate and it will create a project from those files (you can add other files later). Note that the second method will not create a .tmproj file, though, so if you want to "keep" that project, you'll have to save it (File -> Save Project).

Categories

Resources