Copying Ops in python

Hello all,

Currently learning python in td and going through the basic commands.

I tried the copy op command, but keep getting a traceback error.
My code follows the example almost exactly so I’m confused as to why this is happening.

[code]n = op(‘/project1’)

#n.create(outCHOP)

n.copy(op(‘out1’), ‘out2’ )[/code]

Is this happening for anyone else?

Thanks in advance!

1 Like

Check out the documentation for using that command - [url]https://www.derivative.ca/wiki099/index.php?title=COMP_Class[/url]
You need to use the keyword argument “name”.

So the code should look like this:

n = op('/project1') n.create(outCHOP) n.copy(op('out1'), name= 'out2')

Thanks for your reply ishelanskey, but even with your code I still get a traceback error!

python >>> n = op(‘/project1’)
python >>> n.create(outCHOP)
type:outCHOP path:/project1/out1
python >>> n.copy(op(‘out1’), name= ‘out2’)
Traceback (most recent call last):
File “”, line 1, in
td.Error: OP object expected. <class ‘NoneType’>
python >>>

This seems like such a simple thing I don’t know what I’m doing wrong!

I assumed you are running this script from inside of project1.
If you are running it from somewhere else you should use an absolute path to out1 in the copy command.

N.copy(op(‘/project1/out1’), name=‘out2’)