I wouldn't think so, as long as workspace and entrance, line-of-site (if required), etc are all covered. What kind of disco? I don't think a service disco would be ok.
Mark Heller "Well - I oughta....." -Jackie Gleason
Unless said attic can be considered a "closet", then I can't think of any NEC violation. Keep in mind that clearances must be complied with, and accessability could be an issue.
It must be a pretty tall attic to get working space (headroom) and you will need a permanently installed ladder. (readily accessible). I have seen this discussed with attic mounted air handlers and their disconnect. The energy code pretty much did away with them here so it stopped being as much of an issue.