Initializing help system before first use

# xpressinsight.AppInterface.put_scen_attach

Purpose
Uploads a scenario attachment to the Insight server.
Synopsis
`xpressinsight.AppInterface.put_scen_attach(self, filename: str, overwrite: bool = True, *, source_filename: str = None, source: str | TextIO | BinaryIO = None, encoding: Optional[str] = 'utf-8') -> None`
Arguments

filename | The filename of the attachment to be uploaded
overwrite | If True, will overwrite attachment if it already exists. If False and attachment already exists, will fail. Defaults to True if not given.
source_filename | The local filename from which to read the attachment content; may be an absolute path or relative to the Python working directory. If neither source nor source_filename are given, the attachment will be read from a file in the working directory.
source | Where to read the attachment content. May be a local filename (in which case this parameter behaves the same as source_filename) or any file-like object. source and source_filename must not both be set.
encoding | The character encoding to use when source is of type TextIO. Defaults to utf-8.

Return value

This function may raise the following errors:

ValueError

  if both source and source_filename arguments are set.

AttachFilenameInvalidError

  If the given filename is not valid for an attachment

AttachAlreadyExistsError

  If an attachment with this name already exists and the overwrite flag was not passed as True

AttachTooLargeError

  If the file is too large to add as an attachment

TooManyAttachError

  If the scenario already has too many attachments

AttachError

  If there is some other error adding the attachment

Example
Example of taking a file my_attach.dat in the working directory, and saving it as a new scenario attachment called my_attach.dat.

    >>> try:
    ...     insight.put_scen_attach('my_attach.dat', False)
    ...     print("Attachment added ok")
    ....except AttachAlreadyExistsError:
    ...     print("Attachment already exists")

Further information
1. The method put_scen_attach is part of the class xpressinsight.AppInterface.
2. To maintain backwards compatibility, attachment operations will only raise exceptions on error if the raise_attach_exceptions attribute of either the AppConfig or AppInterface class is set to True. When this is not the case, after every call to this method you should check the value of insight.attach_status to see if your request succeeded.
3. The new attachment will not be available on the Insight server until the scenario completes.
4. Attempting to access attachments outside an Xpress Insight scenario will access local files that have been supplied to this class.
Related topics
AppInterface.attach_status,
AppInterface.get_scen_attach
Parent Topic App Interface Classes

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.