Home Download Buy Blog Forum Support

Is there a tutorial for sublime?

Is there a tutorial for sublime?

Postby adabo on Sat Feb 12, 2011 4:57 pm

Hello,
I'd like to start learning python, so I chose Sublime text editor. Are there any tutorials available to get python working with Sublime? Thanks for any suggestions.

Win7 32
-adabo
adabo
 
Posts: 6
Joined: Sat Feb 12, 2011 4:47 pm

Re: Is there a tutorial for sublime?

Postby adabo on Sun Feb 13, 2011 9:04 am

I installed IDLE python 2.7 and it works great. So now I'm curious if there is a way to use sublime the same way IDLE works? It would be nice to work only in sublime using the console at the bottom of the screen (ctrl + `).
adabo
 
Posts: 6
Joined: Sat Feb 12, 2011 4:47 pm

Re: Is there a tutorial for sublime?

Postby guillermooo on Sun Feb 13, 2011 10:15 am

If you want to see your script's output in Sublime's output panel, you need to use a .sublime-build file. Sublime ships with one for Python and you can create your own too if you want. To run a script, it should be a matter of pressing F7.

More info:

sublimetext.info/docs/
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Is there a tutorial for sublime?

Postby adabo on Sun Feb 13, 2011 11:53 am

Thanks for the response, guillermooo. Well I can see that it's just a bit beyond my skill level. I'll see what I can do.
adabo
 
Posts: 6
Joined: Sat Feb 12, 2011 4:47 pm

Re: Is there a tutorial for sublime?

Postby guillermooo on Sun Feb 13, 2011 1:47 pm

Do you want to use Sublime's python console as a python interactive interpreter? If that's so, it's very limited for general purpose usage... You're going to be much better served with IPython.

What I was referring to is a way tu run the code you're writing in Sublime Text without leaving the editor.

HTH
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Is there a tutorial for sublime?

Postby adabo on Sun Feb 13, 2011 2:12 pm

I successfully added "C:\Python27" to the Path environment variable.

In the "Tools-->Build System" menu I chose "mypython_test" (arbitrary name for testing). I can write a simple script:
Code: Select all
x = 1
def func():
   print 'Function works.'

if x == 1:
   print 'If statement works.'
   func()

And that works fine. But when I try to use:
Code: Select all
raw_input('This is raw_input text')

, the "output panel" is blank and the console displays this:
Code: Select all
Writing file C:\Python27\My Projects\pytest.py with encoding UTF-8
running command python from directory C:\Python27\My Projects
exec: trying C:\Windows\system32\cmd.exe /A /S /C "python"


Using this custom build system:
Code: Select all
# See http://www.sublimetext.com/docs/build for details
build python
lineNumberRegex ^(...*?):([0-9]*):?([0-9]*)
showWhenFinished true
workingDir $ProjectDir
adabo
 
Posts: 6
Joined: Sat Feb 12, 2011 4:47 pm

Re: Is there a tutorial for sublime?

Postby guillermooo on Sun Feb 13, 2011 4:17 pm

It seems that you're using Sublime Text 1.

In any case, build systems are not meant to be used interactively, so I think you can't use "raw_input". You're basically asking for input you can't provide, so your script will wait forever and the ouput panel will remain empty.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Is there a tutorial for sublime?

Postby adabo on Sun Feb 13, 2011 8:13 pm

Oh I see what you're saying. Too bad :( The truth is I am using Sublime Text 1.4. Is there a newer one available? I've only just heard of Sublime recently, so I wouldn't know.

In regards to interactive development, am I restricted to environments such as IDLE and IPython (another program I haven't heard of) to handle such things?

Again, thanks for the consideration and support. I appreciate it very much :)
adabo
 
Posts: 6
Joined: Sat Feb 12, 2011 4:47 pm

Re: Is there a tutorial for sublime?

Postby tstrokes on Mon Feb 14, 2011 4:35 pm

There is a new version. It can be found here: http://www.sublimetext.com/2
It is an alpha but it is very stable. However, the build system is the same so same
issues as 1.4. ST2 is awesome so it is still worth looking at.
tstrokes
 
Posts: 17
Joined: Wed Dec 03, 2008 6:39 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 19 guests