What is this u appended to arguments of functions?

1 view
Skip to first unread message

Francis E Reyes

unread,
Sep 19, 2007, 5:10:22 PM9/19/07
to py...@googlegroups.com
Help on method addTask in module xg:

addTask(self, cmd, args=u'', env={}, inputStream=u'', dependsOnTasks=[]) unbound xg.JobSpecification method
    Adds a task to the jobSpecification.
   
    @arg cmd: 
        The command the execute as a string.  The executable is not
        copied if the full path is given, otherwise it is.
    @type cmd: str           
    @arg args: 
        The command line arguments to be passed to the command. 
    @type args: list or str
    @arg env:
        A Python dictionary of environment variables to use on the agents.
    @type env: unicode or str
    @arg inputStream:
        A local file to send to the agents that will be used a stdin for the
        task
    @type inputStream: unicode or str
    @arg dependsOnTasks:
        A list of task ids that must complete before this one begins
    @type dependsOnTasks: list


specifically the argument 'args' in addTask. 

Is this intentional ?

Thanks

FR

---------------------------------------------
Francis Reyes M.Sc.
215 UCB
University of Colorado at Boulder

gpg --keyserver pgp.mit.edu --recv-keys 67BA8D5D

8AE2 F2F4 90F7 9640 28BC  686F 78FD 6669 67BA 8D5D



Barry Wark

unread,
Sep 19, 2007, 5:16:51 PM9/19/07
to py...@googlegroups.com
Francis,

I believe the arguments to addTask (and any other Python function)
with an assignment in the function are keyword arguments. The
expression on the right side of the expression defines the default
value for that keyword argument. In this case, the default value for
args and inputStream are empty strings. the "u" prefix on a string
literal defines it as a Unicode string in python[1].

Barry

[1] As a general rule, any strings that are going to end up in native
code on OS X should generally be Unicode strings (i.e. with an
explicit encoding) in python.

Francis E Reyes

unread,
Sep 19, 2007, 5:25:19 PM9/19/07
to py...@googlegroups.com
Thanks for the quick reply.

I have a question also about batch submission: appending a file via JobSpecification.addFile.

My syntax is

JobSpecification.addfile('/foo/bar', os.path.basename('/foo/bar')) (this may seem redundant but I'm iterating over a list of files)
args = ' ' + arguments + ' ' + os.path.basename('/foo/bar')
specification.addTask(command,args)

Now my command is returning that it can't find the file.

How do I access an appended file with addFile ? Where is the file stored?

Thanks!

FR


---------------------------------------------
Francis Reyes M.Sc.
215 UCB
University of Colorado at Boulder

gpg --keyserver pgp.mit.edu --recv-keys 67BA8D5D

8AE2 F2F4 90F7 9640 28BC 686F 78FD 6669 67BA 8D5D



Francis E Reyes

unread,
Sep 19, 2007, 5:58:18 PM9/19/07
to py...@googlegroups.com
Ahh nevermind!

I wasn't passing my arguments as a list.

FR

---------------------------------------------
Francis Reyes M.Sc.
215 UCB
University of Colorado at Boulder

gpg --keyserver pgp.mit.edu --recv-keys 67BA8D5D

8AE2 F2F4 90F7 9640 28BC 686F 78FD 6669 67BA 8D5D



Reply all
Reply to author
Forward
0 new messages