Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have been writting a socket server in python. I want to send data to some users (no to all) but I dont know how to do it. Can i send it with a for loop?
For example:
some_clients = [client1, client2, client5, client9]
for client in some_clients:
client.send("data")
It is good?
If that works, it's perfectly OK.
If you want something more readable, you could do:
for client in filter(shouldrecieve, all_clients):
client.send(data)
or something like:
for client in (client for client in all_clients if client.attrspam == barfoo):
client.send(data)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I want to send a message to everybody on my friends list via python I want to do it without there id's is there a way to do this?
Users' friend lists are not exposed to the public API. Even if they were, mass DM-ing users is against Discord's Terms of Service.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I need to implement client/server chat application using pure sockets in Python with many different requirements for such a middleware.
The server should serve a small number of clients and I need to decide which sockets should I use TCP and/or UDP. Also I need to implement a multicast.
You can use python's builtin socket module
You should use TCP sockets for this purpose
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I want to block an entity like user or bot with a user account. I cannot find any method for that. Also, it's good to exist some method for unblock entities.
You need to use what is known as raw API. Searching for "block" takes us to BlockRequest which comes with an example:
from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.contacts.BlockRequest(
id='username'
))
print(result)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I was wondering if I can make a PyMongo client that is not localhost such that I can retrieve data from external computers. Is this possible? I read the documentation but there doesn't anything about it.
Yes, it's possible - just use that external computer hostname or IP address instead of localhost.
For example:
import pymongo
client = pymongo.MongoClient("mongodb://10.20.30.40/")
Another example - I have a MongoDB setup with authentication and multiple nodes in a replica set, so I am using
pymongo.MongoClient(
"mongodb://user:password#host1,host2,host3/dbname?replicaSet=rsname",
read_preference=pymongo.ReadPreference.SECONDARY)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I create a client side database to store information of users on client side. Does anybody know of any tutorials or pointers? Which is the recommended database to use? My client is in .js and uses Django framework.
What you are asking for is called Web Storage and is part of HTML5.
http://diveintohtml5.info/storage.html
http://www.gwtproject.org/doc/latest/DevGuideHtml5Storage.html
However, many times when people SAY they need a client-side database, I ask them the details and it turns out that they don't really need client side storage at all, so proceed with caution.