How to save output files in a folder created within python Add-In?

Discussion created by ibraheem99 on Jan 26, 2013
Latest reply on Jan 28, 2013 by ibraheem99
Output folder is defined during execution of python Add-In and it is required that output should be stored in the created folder. But I am getting an error pertaining to output folder string such as "r'optfile/ras1'" which is also shown below. Any help how to correctly store output file in the created folder would be appreciative.

import arcpy
import os
import pythonaddins

from datetime import datetime

now = datetime.now()
month = now.month
year = now.year

optfile = "C:/temp/"+str(year)+"_"+str(month)

class DrawRectangle(object):
    """Implementation for rectangle_addin.tool (Tool)"""
    def __init__(self):
        self.enabled = True
        self.cursor = 1
        self.shape = 'Rectangle'

    def onRectangle(self, rectangle_geometry):
        """Occurs when the rectangle is drawn and the mouse button is released.
        The rectangle is a extent object."""

        extent = rectangle_geometry
        arcpy.Clip_management(r'D:/test', "%f %f %f %f" %(extent.XMin, extent.YMin, extent.XMax, extent.YMax), r'optfile/ras1', "#", "#", "NONE")