0

I have a template file: 'template.txt' like below:

class Core_Model_DbTable_{table_name} extends YouNet_Db_Table
{
    const TYPE_PRINTED      = 1;
    const TYPE_DIGITAL      = 2;

    protected $_name = '{table_name}';
    protected $_rowClass = 'Core_Model_{table_name:short}';
}

And I use Python 3.2 to read that file and try to replace:

  • {table_name} => Coupons
  • {table_name:short} => Coupon

and here my code:

in_file = open("template.txt","r")
text    = in_file.read()
in_file.close()
txt = text.replace("{table_name}","Coupons")
txt = text.replace("{table_name:short}","Coupon")

But the output only shows the result:

c:\Python32\python.exe builder.py

<?php

class Core_Model_DbTable_{table_name} extends YouNet_Db_Table
{
        const TYPE_PRINTED      = 1;
        const TYPE_DIGITAL      = 2;

        protected $_name = '{table_name}';
        protected $_rowClass = 'Core_Model_Coupon';
}

Could you please tell me anything is wrong here?

1 Answer 1

4

You seem to have misspelled the name of your variable: "txt" vs "text".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.