case
ADM Blog
23Jun/100

How to run python code in Windows batch (bat) files

Here’s the bit of tricky batch file magic that does it:

1
2
3
@setlocal enabledelayedexpansion && python -x "%~f0" %* & exit /b !ERRORLEVEL!
#start python code here
print "hello world"

The way it works is that the first line of the file does two different things.

1. starts python interpreter passing the name of the file in, and the -x option will tell it to skip the first line (containing .bat file code)
2. When python finishes the script exits.

This nifty trick makes it much nicer for writing admin scripts with python on Windows.

20Feb/090

Code Formating for Flex

This is one thing flex and flash are missing. Code formating.
I've tested few eclipse plugins but none of them worked like this one. You can download it from http://sourceforge.net/projects/flexformatter/

Just copy it in your ecplise/plugins folder and restart. You can also import/export your settings in a .properties file

prettyformating

Ctrl-Shift-F is the default shortcut key to format the selected code. Also it's possible to assign another shortcut combination or using the red circled button on the image above.