[ale] James Gosling will be speaking at the Sept.AJUG meeting]
Christopher Fowler
cfowler at outpostsentinel.com
Thu Aug 31 12:46:49 EDT 2006
I believe in perl threads behave more like a vfork(). I've not had much
success with data sharing between threads in perl. I need to do some
research on the python side to see if it can really do threads. Maybe
there is an implementation of pthreads for it?
On Thu, 2006-08-31 at 11:46 -0400, Charles Shapiro wrote:
> Usual way of most OO languages, looks like. I do threading with the
> web server (it's all just cgi-bin), so I haven't worried about this
> too very much. Anyways, there's a Thread class, you sub-class off it
> to make your own thread classes, and then you override its "run"
> method to put in what you want to do.
>
> import threading
>
> class my_thread (threading.Thread)
>
> def run(self):
> Run some thread code...
>
> There's a bunch of python threading tutorials out there, of course. I
> slobbed together a sample in 26 lines which counts for a whiles:
>
> import threading
> import time
> import random
>
> class A_Thread(threading.Thread):
> def __init__(self,name):
> threading.Thread.__init__(self)
> self.setName(name)
>
> def run(self):
> for kk in range(0,20):
>
> print self.getName() + " " + str(kk)
> time.sleep(int(random.random()*3))
>
>
> if __name__ == "__main__" :
>
> names=["First","Second","Third", "Fourth", "Fifth", "Sixth"]
>
> for kk in names:
> vv = (A_Thread(kk))
> vv.start()
>
>
> -- CHS
>
>
>
>
>
>
>
>
>
>
>
> On 8/31/06, Christopher Fowler <cfowler at outpostsentinel.com> wrote:
> How does Python handle threads. I've not been too impressed
> with Perl
> and threads. I have a project that requires threads and I
> could switch
> to python.
>
>
> On Thu, 2006-08-31 at 10:53 -0400, Charles Shapiro wrote:
> > Umm. I wrote a bunch of perl for both work and play, then
> got this
> > gig where python is the Official Scripting Language. Python
> is my
> > current language of choice for recreational coding as well
> for work.
> > I'd rather not get into a language war here, but I'll not go
> back to
> > perl unless someone nearby pays me. The OP was right that
> perl has
> > better community support. But python also has community
> support --
> > check out the Python Cheeseshop
> ( http://cheeseshop.python.org/pypi )
> > for example. Of course, for learning Good Coding Style,
> community
> > support may be less critical than for getting something
> working on a
> > deadline.
> >
> > I find it a easier to write code I consider elegant and
> comprehensible
> > in python than I do in perl, and I have a a
> reasonable amount of
> > experience in perl. Working code samples of mine are
> available for
> > both languages: the fraudulator
> ( http://tomshiro.org/fraudulator/ )
> > is written in perl, and the sudoku grinder
> > ( http://tomshiro.org/sudoku-grinder/ ) is in python. So if
> you wish
> > you can make your own comparisions -- as well as pointing
> and laughing
> > at my "WTF"-style coding if you wish. NB that these comments
> apply to
> > perl 5 only -- I haven't worked at all with perl 6.
> >
> > The canonical Big Python Project is zope
> ( http://www.zope.org ), a
> > web application server which is very easy to use but has
> been accused
> > of scaling troubles. Other projects I'm aware of in this
> space include
> > Cherrypy ( http://www.cherrypy.org/ ) and django
> > ( http://www.djangoproject.com/ ). You can of course google
> "big
> > python projects" as well as I can. There're plenty of them
> out there
> > it appears.
> >
> > And hey, if you're gonna write C++., you should read Bjarne
> > Stroustroup's _The_Design_and_Evolution_of_C++ . It's a
> surprisingly
> > entertaining as well as deep look at the design issues
> Stroustroup
> > faced from the Man Himself.
> >
> > -- CHS
> >
> >
> > On 8/31/06, Christopher Fowler <cfowler at outpostsentinel.com>
> wrote:
> > I believe KDE and GNOME are both written in C++ and
> they are
> > large
> > projects.
> >
> > I think it is good that schools are now teaching
> stuff like
> > scripting
> > languages vs Cobol. I ask why the choice of
> Python? Maybe
> > because it
> > has a strong focus in OOP. It seems that Perl would
> give you
> > more bang
> > for the buck in terms of languages to program
> in. They are
> > both
> > excellent choices. I believe Perl has better
> community
> > support which
> > would lend itself to a good choice in almost any
> > project. I'll put it
> > this way, there has not been a time when I thought
> that Perl
> > could not
> > do what I needed and I thought about using something
> > else. I've done
> > some unique things with Perl so far.
> >
> >
> > On Thu, 2006-08-31 at 00:28 -0400, Steve Brown
> wrote:
> > >
> > > From: Christopher Fowler
> <cfowler at outpostsentinel.com>
> > > >Another method is looking at source code. Look
> at OSS
> > projects.
> > > Large
> > > >projects that don't usually commit patches from
> crap code.
> > >
> > >
> > > That's a good idea, do you know a few good ones
> off the top
> > of your
> > > head? I'm taking C++ and Python classes this
> semester if
> > that helps :)
> > >
> > > -Steve
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://www.ale.org/mailman/listinfo/ale
> >
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale
> >
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list