Skip to content

Using context managers in a QCodes NI Daq driver (based on QDAC2 as reference) #5129

Closed Answered by astafan8
zibrov-zlobin asked this question in Q&A
Discussion options

You must be logged in to vote

Could you please clarify further on how would you deal with nested contexts?

yes, i think that's how it would look like (i'm not a frequent used for QDAC2 though, so can't be 100% sure here). as a software dev i don't see problems with many nested contexts, i'd only suggest that the API should be good enough that typing all those contexts should be fast while keeping them readable. Also note that in python it's not necessary to nest the contexts, the with statement supports comma-separating the contexts like this:

with qdac.arrange(...) as arrangement, arrangement.virtual_sweep2d(...) as sweep:
    sweep.start()

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zibrov-zlobin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants