In $\operatorname{Set}$, one can construct the coproduct (here the disjoint union) of some sets $(S_λ)_{λ \in Λ}$ as follows: We take $$ \prod_{λ \in Λ} \prod_{x \in S_λ} \{0_x, 1_x\} $$ and then we take the subset where exactly one entry equals $1$. My question is whether this construction carries over to any other category.
Obviously, some categories are right out, because the subset above may not be closed under whatever operation one has on one's (say) universal algebra instance or whatever. In $\operatorname{Top}$ the product topology is too sparse if the sets $S_λ$ or $Λ$ are more than finitely large.
But maybe any of you knows another one where it works.
Similar cases where coproduct can be constructed as a subobject of product that comes to my mind are categories of $R$-modules. The product has a form $$ \prod_I M_i = \{(m_i)_{i \in I} \ \ |\ \ m_i \in M_i\}$$ Then the elements of coproduct $\bigoplus_I M_i$ we can identify with sequences $(m_i) \in \prod_I M_i$ such all but finitely many $m_i$ vanish. We can get a form more similar to yours by considering elements from product as families of elements from $M_i$ indexed by subsets of $I$, filling indices not belonging to the subset with zeros. Then elements coproduct are exactly families with finite indexing subsets.