What does it take to implement a chat system in Python (Not askingfor code just advice before I star

A

Aseem Bansal

I wanted to do a little project for learning Python. I thought a chat system will be good as it isn't something that I have ever done.

I wanted to know what will I need? I think that would require me these
1 learn network/socket programming
2 find a free server to host my chat server
3 GUI development for clients

-I wanted to know whether these are all that I would need or are there more things?
-Will I need to learn a web framework like Django?
-Will I need to learn something for database management like sql for handling people's account names and password?

Is google appengine good for hosting the website or should I look up at django hosting websites?

Any other advice for me(a novice programmer)?
 
V

vikash agrawal

Hi Aseem,

First of all great thought and all the best for the learning!


I wanted to do a little project for learning Python. I thought a chat
system will be good as it isn't something that I have ever done.

I wanted to know what will I need? I think that would require me these
1 learn network/socket programming

Yes! sockets are the heart and soul of chat sys :)

2 find a free server to host my chat server

You can use many, but I would suggest heroku for your free apps.

3 GUI development for clients
There are many python libraries Tkinter, PyQt, PyGtk, wxPython through
which you have GUI!

-I wanted to know whether these are all that I would need or are there
more things?

I think with above you are good to go!

-Will I need to learn a web framework like Django?

That would really depend upon the type of chat application you are relying
upon. For a command line utility I think you can skip it, but if you wish
to have good-looking web version then yes, give Django a shot! But yes do
see other frameworks as well, just for finding out, learning and knowing
more :)

-Will I need to learn something for database management like sql for
handling people's account names and password?

Yes, it will be good decision to use DB to store names and chat histories
(with timestamp) and have your logs ready

Is google appengine good for hosting the website or should I look up at
django hosting websites?

Its good too :)

Any other advice for me(a novice programmer)?

Make mistakes and fail early!

Python is awesome! But do try to learn the best practices. For eg, reverse
a string string[::-1] etc.



Regards
~Vikash
 
E

Eric S. Johansson

I wanted to do a little project for learning Python. I thought a chat
system will be good as it isn't something that I have ever done.

I wanted to know what will I need? I think that would require me these
1 learn network/socket programming
2 find a free server to host my chat server
3 GUI development for clients

Not discourage you but this is a "been there, done that" kind of project.
You could learn more from reading somebody else is code. What hasn't been
done, and this would be very cool, is a chat program that works
peer-to-peer with no central server. To do this, you would probably need
to know about distributed hash tables and methods of piercing address
translation firewalls (think UDP).

First however, I would suggest taking a look at https://jitsi.org/ and see
how they do things. You can learn a lot from these people. They are very
smart.
 
A

Aseem Bansal

@Eric S. Johansson

I am a novice who hasn't done any big project in programming. I haven't done anything I can even call a moderate project. I haven't touched web frameworks ever. I have little or no knowledge of network/socket programming. I have never used databases before.

I understand that there are a lot of chat systems out there but I haven't done anything like that before. This is for learning purposes.

Reading someone else's code is good but doing it yourself is better.

Thanks for the suggestion but for now I'll stick to this idea. I am excitedabout this and I would need that for a hobby project.
 
A

Aseem Bansal

@vikash agrawal

About GUI I discussed it at https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I am thinking about using PySide 1.2 for clients of chat system. I think I'll need downloadable clients if I want to make something like google talk. Then I'll need to implement server side programming also. I think google app engine would be suitable for this as it is going to be always online.

In the above scenario I wanted to know whether the database can be stored on google app engine itself? Is it possible? Having a chat system with server online and DB offline isn't going to be good. Should I consider heroku for this or can it be done using google app engine? Is it viable to have the DB on google appengine itself?

About using web frameworks, in the above scenario when there isn't an online website for chat would I need web frameworks? I am confused about this. Can server side programming be done in Python or by using a web framework only?
 
C

Chris Angelico

I wanted to do a little project for learning Python. I thought a chat system will be good as it isn't something that I have ever done.

A good thing to start with. Yes, it's been done before, many times...
but if you think about it, it's the fundamental on which pretty much
everything else is derived. The step from a multi-person chat system
to a multiplayer game is very slight.
I wanted to know what will I need? I think that would require me these
1 learn network/socket programming
2 find a free server to host my chat server
3 GUI development for clients

Learn network programming, definitely. As an adjunct to that, learn
networking security. For instance, do not think in terms of "the
client will only ever send X"; the server has to be able to cope,
safely, with any stream of bytes coming from the socket. Also, be sure
you understand the difference between bytes (or octets) and Unicode
characters, and know what everything is. Python 3 helps with this.

Finding hosting (I'll use the word "server" here to mean the program,
and will say "hosting" when I mean a computer) is optional though; for
your first tests, use your own computer. You can run the server and a
number of clients all on the same computer, and alt-tab between them;
or, if you have a LAN, you can use that. Then when you want to expand
to the full internet and let your friends in on this, you can still
host it on your home internet connection, though you may need to
choose carefully which port you use (some home connections prevent
incoming port 25 and 80 traffic). You won't need to worry about
hosting until (a) you need it to be up 24x7 and don't want to depend
on your home system, and/or (b) you need more bandwidth/processing
than your home connection will do. Neither will be true of your first
experiments.

GUI development, in my opinion, should be left for Phase Two. Start by
making a very simple system that just works with plain text; later on,
make a fancy graphical interface. Keep the text version working, and
keep them compatible. Trust me, you'll appreciate that text one when
you start debugging - it'll be so easy to see what's going on.
-I wanted to know whether these are all that I would need or are there more things?
-Will I need to learn a web framework like Django?

Hmm. I would think not; I'd recommend that a chat system work with TCP
sockets directly, for simplicity and performance. Working with a web
framework implies working with HTTP, and unless you're running this in
a web browser, there's no reason to do that.
-Will I need to learn something for database management like sql for handling people's account names and password?

Optional. Leave that for Phase Two; to start off with, just let people
type in their own names, and don't worry about authentication
initially (this isn't such a crazy idea - IRC largely works this way).
You can add authentication later.
Any other advice for me(a novice programmer)?

Get to know as many tools as you can, so that when you're faced with a
problem, you can select the right one for the job. You are not Jeremy
Clarkson, your toolchest is not all hammers :)

In this particular instance, you may find that Python is the best
language for the clients, but not for the server. I've written a
number of chat-server-like systems, most notably MUD clients and
derivatives, and I use Pike for the server. Its biggest advantage
(over Python) is that you can tweak the code while it's running; I've
had Pike servers running for over two years on commodity hardware (and
would still have that uptime today if the UPS hadn't died). Still
trying to claw all that back.. up to 25 weeks so far. Pike and Python
are extremely similar in semantics (even down to having a
nearly-identical internal string representation, as of Python 3.3),
but have distinctly different syntax (Pike looks like C), and their
optimizations are quite different, so performance varies somewhat.
They're both high level languages that let you manipulate functions,
dictionaries, etc, as first-class objects, they're both sufficiently
high performance/efficiency to run something like this on 0.00 load
average (my server's load is more usually from Apache serving PHP
pages than it is from either Pike or Python), and both will serve you
well in this project.

One more tip: Don't be afraid to ask for help! I personally *love*
networking, and will gladly help out with any little problems you run
into; the same, I am sure, will be true of a good number of people on
this list. Networking is a complicated world, and there are a lot of
odd concepts to master; but it's also an immensely fun bunch of
technologies. Why play with just one computer when you can play with
half a dozen!

ChrisA
 
C

Chris Angelico

@vikash agrawal

About GUI I discussed it at https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I am thinking about using PySide 1.2 for clients of chat system. I think I'll need downloadable clients if I want to make something like google talk. Then I'll need to implement server side programming also. I think google app engine would be suitable for this as it is going to be always online.

Hrm. Rather than pointing people to Google Groups, which a number here
(and not unreasonably) detest, you may want to link to the python-list
archive:

http://mail.python.org/pipermail/python-list/2013-July/thread.html#651359
About using web frameworks, in the above scenario when there isn't an online website for chat would I need web frameworks? I am confused about this.Can server side programming be done in Python or by using a web framework only?

You can certainly do your server-side programming directly in Python;
in fact, I recommend it for this task. There's no reason to use HTTP,
much less a web framework (which usually consists of a structured way
to build HTML pages, plus a bunch of routing and stuff, none of which
you need). All you need is a simple structure for separating one
message from another. I would recommend either going MUD/TELNET style
and ending each message with a newline, or prefixing each message with
its length in octets. Both ways work very nicely; newline-termination
allows you to use a MUD client for debugging, which I find very
convenient (full disclosure: I am the author of multiple MUD clients,
including one that's zero-dollar and another that's free).

ChrisA
 
A

Aseem Bansal

@Chris Angelico

Thanks. That cleared many doubts and your suggestions would definitely be useful.

I am asking the next paragraph because you said about Python 3 helping withthings. I am not looking for a debate or anything just a opinion.

I learnt Python myself and everyone told me that Python 2 is status quo so I learned Python 2 and have been working with it. I am just 1.5 months in Python programming so should I consider switching to Python 3 if it helps with new things or should I stick with Python 2 to get a taste of what is currently out there?

About Pike, thanks for the heads up. But for now I'll use Python. I wanted to learn Python through this project. I'll leave Pike for later. Maybe Phase 1.5.

Aren't you guys posting in google groups? I thought you were because I can see your posts here. How do I post in python mailing list and see its archives instead of posting on google groups?
 
A

Andrew Berg

I learnt Python myself and everyone told me that Python 2 is status quo so I learned Python 2 and have been working with it. I am just 1.5 months in Python programming so should I consider switching to Python 3 if it helps with new things or should I stick with Python 2 to get a taste of what is currently out there?
Python 2 is what some people are stuck with because their projects depend on huge libraries that have not yet made all their code compatible
with Python 3 (or on libraries that are not actively maintained or are being replaced by something else). All new code and new Python users
should be using Python 3 unless there is a pressing need for a library that requires Python 2.
Most popular libraries at this point have either been made compatible or have been replaced by something that supports Python 3. Python 3 is
no longer the shiny new thing to look at in the future - 3.0 was released in December 2008.
 
A

Aseem Bansal

@Andrew Berg
@Chris Angelico

Is there a way to have both Python 2 and 3 installed on my computer till I can update the little codebase that I have built? Can I make different commands for invoking python 2 and Python 3? I am using Windows 7 and use Windows Powershell as an alternative to the linux terminal. Any suggestions about how to do that instead of breaking all my code at once?
 
C

Chris Angelico

@Andrew Berg
@Chris Angelico

Is there a way to have both Python 2 and 3 installed on my computer till I can update the little codebase that I have built? Can I make different commands for invoking python 2 and Python 3? I am using Windows 7 and use Windows Powershell as an alternative to the linux terminal. Any suggestions about how to do that instead of breaking all my code at once?

Yep! And in fact, Python 3.3 includes a launcher that makes it fairly
easy. Just install another version, and then check this out:

http://docs.python.org/3.3/using/windows.html#launcher

You can use a Unix-style shebang to specify which Python version some
script depends on.

ChrisA
 
A

Aseem Bansal

@ChrisA

Thanks. That's great. That solved the whole thing easily. I'll install Python 3 and start updating today.

About reading comp.lang.python can you suggest how to read it and reply? I have never read a newsgroup leave alone participated in one. I am used to forums like stackoverflow. Any way to read it and reply by one interface? Ifnot, give any suggestion. I'll use that.
 
C

Chris Angelico

@ChrisA

Thanks. That's great. That solved the whole thing easily. I'll install Python 3 and start updating today.

About reading comp.lang.python can you suggest how to read it and reply? I have never read a newsgroup leave alone participated in one. I am used toforums like stackoverflow. Any way to read it and reply by one interface? If not, give any suggestion. I'll use that.

Easiest, if you're not familiar with newsgroups, is to subscribe to
the mailing list.

Subscribe here:

http://mail.python.org/mailman/listinfo/python-list

Then you get an email every time anyone posts. Threading should be
handled by any decent mail client, and you just hit Reply-List (or
Reply and change the address to (e-mail address removed)) to post a
follow-up.

It's a good system. Works for myriad lists. The software that runs
this one (Mailman) is even written in Python, so you're using Python
to discuss Python :)

ChrisA
 
A

Aseem Bansal

@ChrisA

I subscribed to it. How do I reply to a message that has already been posted before my subscription?
 
C

Chris Angelico

@ChrisA

I subscribed to it. How do I reply to a message that has already been posted before my subscription?

Not easily, far as I know. But you now have this reply, and you can
always just post something with the right subject line and hope that
people pick up that it's part of the same discussion topic. Transition
isn't the cleanest but once it's done it's done.

ChrisA
 
A

Aseem Bansal

I tried replying to your message by mail. I used the reply button and send it to "(e-mail address removed)"? Or do I need to use "(e-mail address removed)" as you wrote in your post?
 
C

Chris Angelico

I tried replying to your message by mail. I used the reply button and send it to "(e-mail address removed)"? Or do I need to use "(e-mail address removed)" as you wrote in your post?

You replied correctly. The ellipsis was presumably an anti-spam
feature. Send to python-list at python dot org to post.

ChrisA
 
G

Grant Edwards

Hrm. Rather than pointing people to Google Groups, which a number here
(and not unreasonably) detest, you may want to link to the python-list
archive:

http://mail.python.org/pipermail/python-list/2013-July/thread.html#651359

While that's the canonical archive, the UI is awful. I find gmane's
web UI to be _far_ more friendly and useful than the pipermail archive
UI:

http://thread.gmane.org/gmane.comp.python.general/737271/

1) The search facility sort-of works (though using google with
site:gmane.org:/gmane.comp.python usually works better).

2) You can post from the gmane web UI.

3) It offers both a threaded and a flat, blog-like version.
 
T

Terry Reedy

About reading comp.lang.python can you suggest how to read it and
reply?

To read this list as a newsgroup use news.gmane.org. The difference
between the mailing list interface and newsgroup interface is that the
latter automatically segregates messages by group and only downloads the
messages you want to read. Gmane is also a better way to search the archive.
I have never read a newsgroup leave alone participated in one.
I am used to forums like stackoverflow. Any way to read it and reply
by one interface? If not, give any suggestion. I'll use that.

I use Thunderbird. There is almost no difference between replying to
emails and replying to newsgroup posts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,721
Latest member
NelsonHeil

Latest Threads

Top