Attribution: Quoting a Fictional Character

Famously:

"Try not. Do or do not. There is no try."
-- Yoda

Thing is, this is from a movie. A writer wrote it and a voice actor spoke it. Is there a correct form of attribution for a case like this? If so, what?


The author Robert Asprin famously sprinkles his books with quotations, many of which are fictitious. They're attributed in the form you show in your question:

"In times of crisis, it is of utmost importance not to lose one's head."

--M. Antoinette

"A little help at the right time is better than a lot of help at the wrong time."

--Tevye

Et cetera.


So "everyone" knows who Yoda is. But in a more formal context, or with a less well-known character or work, you might want to use something more like:

"Try not. Do or do not. There is no try."
    -- Yoda, In Star Wars, George Lucas

or even

    -- Yoda [1]

[1] Proper reference to Star Wars.