Skip to content

How to create multiple components of the same kind #91

Closed Answered by da4089
drzraf asked this question in Q&A
Discussion options

You must be logged in to vote

Firstly, allow me to say that the programmer's API for vObject is, well ... awful. I have plans to improve that, but for now we're stuck with 21 year old decisions that don't seem too good from this end of history (no disrespect to Jeffrey Harris, but Python style in 2025 is a little different!)

Now, the practical:

I suggest a slightly different pattern when adding components to a card, which makes this easier: save the created component as a local variable.

j = vobject.vCard()
fn = j.add('fn')
fn.value = "Foo"

This has no real value over the j.tel.value = "Foo" syntax in simple cases, but it does make access easier when dealing with multiple same-named components.

Step 1, using that syn…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@drzraf
Comment options

@da4089
Comment options

Comment options

You must be logged in to vote
2 replies
@drzraf
Comment options

@da4089
Comment options

Answer selected by da4089
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