python 3.x - Python3 access previously created object -


I'm new to programming in general and I need some help to reach an example of a class already created. I did some search but I could not find anything ... Maybe this is just because I should not try to do this.

  for servers in: c = rconprotocol.Rcon (s [0], s [2], s [1]) t = threading. Thread (target = c. Connect) t. Start () c. Messenger (All Messages, 10)  

Now, if I want to call the function "C", then what can I do? Thanks, Hugo

You are creating several different objects, which you can summarize in the c As you go through the loop, if you want to be able to reach more than the last of them, you will need to protect them from somewhere that will not be overwritten. Perhaps the best way is to use a list to keep consistent values, but depending on your specific needs, any other data structure can also be used (for example, you can use a specific key with each value can see).

This is a trivial adjustment for your current code which will save c in the list:

  c_list = [] For: c = Rconprotocol.Rcon (s [0], s [2], s [1]) t = threading. Thread (target = c. Connect) t. Start () c. Messenger (all messages, 10) c_list.append (c)  

later with c with c_list [index] In any or C, you can re-enter with . C_list .

To create a slightly more topical version list, you can use an understanding of the list instead of attachments (also shows that after c_list Someone may look like this:) C_ List for servers in:

  c_list = [rconprotocol.Rcon (s [0], s [2], s [1]): T = Threading Thread (target = c. Connect) t. Start () c. Messenger (All Messages, 10)  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -