Re: [Tutor] threading mind set

2012-05-13 Thread Steven D'Aprano

bob gailer wrote:

On 5/12/2012 8:22 PM, Steven D'Aprano wrote:
By the way, in future, please don't decorate your code with stars: 
I think you got stars because the code was posted in HTML and bolded. 
Plain text readers add the * to show emphasis.


I think you have it the other way around: if you add asterisks around text, 
some plain text readers hide the * and bold the text. At least, I've never 
seen anything which does it the other way around. (Possibly until now.)


In any case, I'm using Thunderbird, and it does NOT show stars around text 
unless they are already there. When I look at the raw email source, I can see 
the asterisks there.


Perhaps Carlo's mail client is trying to be helpful, and failing miserably. 
While converting HTML   tags into simple markup is a nice thing to do 
for plain text, it plays havoc with code.




--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2012-05-13 Thread Alan Gauld

On 13/05/12 07:21, Steven D'Aprano wrote:

Devin Jeanpierre wrote:

This is the third time I've received a message "for those of you new
to the Tutor list". When does it stop?


I think these come when the listserver gets a message from a mailbox it 
doesn't recognise. It puts the mails in the moderation queue and sends 
the message(it used to send one to the moderators too but seems to have 
stopped doing that! :-(


So if you are not subscribed to the list, or are subscribed but using a 
different mail address then you get one of these messages.


I think But the settings of the sever are cloaked in mystery! :-)

And that reminds me that I haven't checked the mod queue for over a week 
- oops!


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2012-05-13 Thread Steven D'Aprano

Devin Jeanpierre wrote:

On Sat, May 12, 2012 at 10:29 PM, bob gailer  wrote:

oh - and always provide a specific meaningful subject


My client has no idea what thread this post came from.

Is it supposed to?



What's your client? I'm using Thunderbird, and it too doesn't have any idea.

I see that Bob's email does have an In-Reply-To header:

In-Reply-To: 


and if I look at the email which started this thread, Keitaro Kaoru's email 
with no subject line, I see it has the same message ID:


Message-ID: 


so my guess is that Thunderbird is just stupid.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2012-05-13 Thread Dave Angel
On 05/13/2012 04:17 AM, Alan Gauld wrote:
> On 13/05/12 07:21, Steven D'Aprano wrote:
>> Devin Jeanpierre wrote:
>>> This is the third time I've received a message "for those of you new
>>> to the Tutor list". When does it stop?
>
> I think these come when the listserver gets a message from a mailbox
> it doesn't recognise. It puts the mails in the moderation queue and
> sends the message(it used to send one to the moderators too but seems
> to have stopped doing that! :-(
>
> So if you are not subscribed to the list, or are subscribed but using
> a different mail address then you get one of these messages.
>
> I think But the settings of the sever are cloaked in mystery! :-)
>
> And that reminds me that I haven't checked the mod queue for over a
> week - oops!
>

I also seem to get one of these when I haven't posted for a couple of
weeks.  I never tried to calibrate it, but that's what it seems to be.
Perhaps it's keeping a cache of recent posters, and once I'm flushed
from the cache, it considers me new.

This is different from the case where I post from a different address. 
In that case, I get a mail saying that only subscribers can post.  Or
something like that.



-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2012-05-13 Thread Dave Angel
On 05/13/2012 05:44 AM, Steven D'Aprano wrote:
> Devin Jeanpierre wrote:
>> On Sat, May 12, 2012 at 10:29 PM, bob gailer  wrote:
>>> oh - and always provide a specific meaningful subject
>>
>> My client has no idea what thread this post came from.
>>
>> Is it supposed to?
>
>
> What's your client? I'm using Thunderbird, and it too doesn't have any
> idea.
>
> I see that Bob's email does have an In-Reply-To header:
>
> In-Reply-To:
> 
>
> and if I look at the email which started this thread, Keitaro Kaoru's
> email with no subject line, I see it has the same message ID:
>
> Message-ID:
> 
>
>
> so my guess is that Thunderbird is just stupid.
>
>

But my copy of Thunderbird (12.0.1, running on Linux) recognized these
as being the same thread as Keitaro Kaoru's message, and combined them
properly.



-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2012-05-13 Thread Devin Jeanpierre
On Sun, May 13, 2012 at 5:44 AM, Steven D'Aprano  wrote:
> Devin Jeanpierre wrote:
>>
>> On Sat, May 12, 2012 at 10:29 PM, bob gailer  wrote:
>>>
>>> oh - and always provide a specific meaningful subject
>>
>>
>> My client has no idea what thread this post came from.
>>
>> Is it supposed to?
>
>
>
> What's your client? I'm using Thunderbird, and it too doesn't have any idea.

The gmail web interface.

> I see that Bob's email does have an In-Reply-To header:
>
> In-Reply-To:
> 
>
> and if I look at the email which started this thread, Keitaro Kaoru's email
> with no subject line, I see it has the same message ID:
>
> Message-ID:
> 
>
>
> so my guess is that Thunderbird is just stupid.

Welp. Not much I can do here. I should probably switch to a desktop
client at some point.

Thanks for the detective work.

-- Devin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2012-05-13 Thread Alan Gauld

On 13/05/12 10:44, Steven D'Aprano wrote:


and if I look at the email which started this thread, Keitaro Kaoru's
email with no subject line, I see it has the same message ID:

Message-ID:



so my guess is that Thunderbird is just stupid.


Like Dave I am on Thunderbird 12 and it is threading the messages
just fine... But I never noticed a problem with T/Bird 3.1 either.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading mind set

2012-05-13 Thread Russel Winder
Steven,

On Sun, 2012-05-13 at 10:22 +1000, Steven D'Aprano wrote:
> carlo locci wrote:
> > Hello All,
> > I've started to study python a couple of month ago(and I truly love it :)),
> > however I'm having some problems understanding how to modify a sequential
> > script and make it multithreaded (I think it's because I'm not used to
> > think in that way), 
> 
> No, that's because multithreading and parallel processing is hard.

Shared memory multithreading may be hard due to locks, semaphores,
monitors, etc., but concurrency and parallelism need not be hard. Using
processes and message passing, using dataflow, actors or CSP,
parallelism and concurrency is far more straightforward. Not easy,
agreed, but then programming isn't easy.

> > as well as when it's best to use it(some say that
> > because of the GIL I won't get any real benefit from threading my script).
> 
> That depends on what your script does.
> 
> In a nutshell, if your program is limited by CPU processing, then using 
> threads in Python won't help. (There are other things you can do instead, 
> such 
> as launching new Python processes.)

The GIL in Python is a bad thing for parallelism. Using the
multiprocessing package or concurrent.futures gets over the problem.
Well sort of, these processes are a bit heavyweight compared to what can
be achieved on the JVM or with Erlang.

> If your program is limited by disk or network I/O, then there is a 
> possibility 
> you can speed it up with threads.

Or better still use an event based system, cf Twisted.

[...]
> 

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to start developing a website

2012-05-13 Thread Surya K

I have a idea (Website) which I want to develop using Django (Still learning 
it!). Currently I am following DjangoBook (reading DataBase..).
As I am really new to webframe works and Web development, I have a real dumb 
question which I don't really figure out.
# Question:
Broadly speaking my website takes a RSS/Atom feed and try to display dynamic 
content on its page. So, with what ever I know about django until now, all I 
can say that my project can handle creating dynamic content with django but I 
don't figure out how to really "design" it. I mean how to "design the UI part.. 
"..
One way of doing is to explicitly edit the Django's HTML pages using HTML, CSS, 
JavaScript from scratch. But I only know little HTML (I cannot do the design 
with what I know).
So, how can I achieve this thing.. 
I thought of using Adobe's Dreamweaver or any equivalent open source thing but 
their generated HTML code can't be easily edited for "django" template 
designing.. 

Can anyone explain me on it..


Thanks a lot


Surya ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to start developing a website

2012-05-13 Thread Emile van Sebille

On 5/13/2012 8:08 AM Surya K said...

I have a idea (Website) which I want to develop using Django (Still
learning it!). Currently I am following DjangoBook (reading DataBase..).

As I am really new to webframe works and Web development, I have a real
dumb question which I don't really figure out.

# Question:

Broadly speaking my website takes a RSS/Atom feed and try to display
dynamic content on its page.


Have you already found http://wiki.python.org/moin/RssLibraries ?


So, with what ever I know about django
until now, all I can say that my project can handle creating dynamic
content with django but I don't figure out how to really "design" it. I
mean how to "design the UI part.. "..

One way of doing is to explicitly edit the Django's HTML pages using
HTML, CSS, JavaScript from scratch. But I only know little HTML (I
cannot do the design with what I know).

So, how can I achieve this thing..


Take a look at http://www.djangosites.org/s/patternry-com/



I thought of using Adobe's Dreamweaver or any equivalent open source
thing but their generated HTML code can't be easily edited for "django"
template designing..


Can anyone explain me on it..


The folks at Django can -- see 
https://docs.djangoproject.com/en/dev/faq/help/ for django resources.


HTH,

Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to start developing a website

2012-05-13 Thread Joel Goldstick
On Sun, May 13, 2012 at 11:40 AM, Emile van Sebille  wrote:
> On 5/13/2012 8:08 AM Surya K said...
>
>> I have a idea (Website) which I want to develop using Django (Still
>> learning it!). Currently I am following DjangoBook (reading DataBase..).
>>
>> As I am really new to webframe works and Web development, I have a real
>> dumb question which I don't really figure out.
>>
>> # Question:
>>
>> Broadly speaking my website takes a RSS/Atom feed and try to display
>> dynamic content on its page.
>
>
> Have you already found http://wiki.python.org/moin/RssLibraries ?
>
>
>> So, with what ever I know about django
>> until now, all I can say that my project can handle creating dynamic
>> content with django but I don't figure out how to really "design" it. I
>> mean how to "design the UI part.. "..
>>
>> One way of doing is to explicitly edit the Django's HTML pages using
>> HTML, CSS, JavaScript from scratch. But I only know little HTML (I
>> cannot do the design with what I know).
>>
>> So, how can I achieve this thing..
>
>
> Take a look at http://www.djangosites.org/s/patternry-com/
>
>
>>
>> I thought of using Adobe's Dreamweaver or any equivalent open source
>> thing but their generated HTML code can't be easily edited for "django"
>> template designing..
>>
>>
>> Can anyone explain me on it..
>
>
> The folks at Django can -- see
> https://docs.djangoproject.com/en/dev/faq/help/ for django resources.
>
> HTH,
>
> Emile
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

I haven't tried this yet, but I have heard good things about this site:
http://twitter.github.com/bootstrap/

There is a tutorial here
http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/stepping-out-with-bootstrap-from-twitter/

Basically some people from twitter and elsewhere have put together a
package that can be used with django or elsewhere to make designing
html and css for webpages.

Since you are new to django, I would recommend you just get the most
basic site going.  You will stumble and learn a lot along the way.
After that you can dress it up
-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] hello~

2012-05-13 Thread Keitaro Kaoru
hey. Austin here for some reason this command. all it does it produces the
error message at the bottom.. itll say my name and the persons name im
trying to send the message to but thats it. heres the command.

mgr.addCommand("tell", 1, "send a person a message to the rooms he is in",
tell, unlisted = True)

def tell(mgr, croom, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name,
seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
for room in mgr.rooms:
if data[1] == "join":
mgr.sendObject(target, Html("%s, %s wants to tell you %s",
name.title, user.name.title$
else:
return Error("%s I couldn't find %s
anywhere", user.name.title(), name.title())

i built it off these 2 commands

def broadcast(mgr, croom, user, msg, args):
for room in mgr.rooms:
mgr.sendObject(room, Html("Broadcast by %s:%s",
user.name, args))

def seen(mgr, room, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name, seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
ifdata[1] == "join":
return Html("Last seen %s join %s, %s ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "leave":
return Html("Last seen %s leave %s, %s ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "message":
return Html("Last seen %s message in %s, %s ago:
\"%s\"", name, data[0], tdelta(data[2]), data[3])
return Html("I have no records about this user.")

as you can see i only use some of the command. it doesnt produce an error
message tho.. just repeats "return Error("%s I couldn't find %s
anywhere", user.name.title(), name.title())"
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] hello~

2012-05-13 Thread Mark Lawrence

On 14/05/2012 00:04, Keitaro Kaoru wrote:

hey. Austin here for some reason this command. all it does it produces the
error message at the bottom.. itll say my name and the persons name im
trying to send the message to but thats it. heres the command.

mgr.addCommand("tell", 1, "send a person a message to the rooms he is in",
tell, unlisted = True)

def tell(mgr, croom, user, msg, args):
 name = args.lower().split(" ")[0]
 if not name.isalnum(): return Html("Non-alphanumeric name,
seriously?")
 data = shared_db.get("seen:" + name)
 if data == None:
 return Html("I have no records about this user.")
 data = json.loads(data)
 for room in mgr.rooms:
 if data[1] == "join":
 mgr.sendObject(target, Html("%s,%s  wants to tell you%s",
name.title, user.name.title$
 else:
 return Error("%s  I couldn't find %s
anywhere", user.name.title(), name.title())

i built it off these 2 commands

def broadcast(mgr, croom, user, msg, args):
 for room in mgr.rooms:
 mgr.sendObject(room, Html("Broadcast by%s:%s",
user.name, args))

def seen(mgr, room, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name, seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
ifdata[1] == "join":
return Html("Last seen%s  join%s,%s  ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "leave":
return Html("Last seen%s  leave%s,%s  ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "message":
return Html("Last seen%s  message in%s,%s  ago:
\"%s\"", name, data[0], tdelta(data[2]), data[3])
return Html("I have no records about this user.")

as you can see i only use some of the command. it doesnt produce an error
message tho.. just repeats "return Error("%s  I couldn't find %s
anywhere", user.name.title(), name.title())"




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Sorry but it's unreadable to me.  Have you sent this in HTML when you 
should have sent in plain text?


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sorry seems like it was sent in html

2012-05-13 Thread Keitaro Kaoru
is that better? not html... ? hey. Austin here for some reason this
command. all it does it produces the
error message at the bottom.. itll say my name and the persons name im
trying to send the message to but thats it. heres the command.

mgr.addCommand("tell", 1, "send a person a message to the rooms he is in",
tell, unlisted = True)

def tell(mgr, croom, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name,
seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
for room in mgr.rooms:
if data[1] == "join":
mgr.sendObject(target, Html("%s,%s  wants to tell you%s",
name.title, user.name.title$
else:
return Error("%s  I couldn't find %s
anywhere", user.name.title(), name.title())

i built it off these 2 commands

def broadcast(mgr, croom, user, msg, args):
for room in mgr.rooms:
mgr.sendObject(room, Html("Broadcast by%s:%s",
user.name, args))

def seen(mgr, room, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name, seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
ifdata[1] == "join":
return Html("Last seen%s  join%s,%s  ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "leave":
return Html("Last seen%s  leave%s,%s  ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "message":
return Html("Last seen%s  message in%s,%s  ago:
\"%s\"", name, data[0], tdelta(data[2]), data[3])
return Html("I have no records about this user.")

as you can see i only use some of the command. it doesnt produce an error
message tho.. just repeats "return Error("%s  I couldn't find %s
anywhere", user.name.title(), name.title())"

-- 
~Keitaro Kaoru-Sama~
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sorry seems like it was sent in html

2012-05-13 Thread Mark Lawrence

On 14/05/2012 00:22, Keitaro Kaoru wrote:

is that better? not html... ? hey. Austin here for some reason this
command. all it does it produces the
error message at the bottom.. itll say my name and the persons name im
trying to send the message to but thats it. heres the command.

mgr.addCommand("tell", 1, "send a person a message to the rooms he is in",
tell, unlisted = True)


mgr is wahh ?


def tell(mgr, croom, user, msg, args):
 name = args.lower().split(" ")[0]
 if not name.isalnum(): return Html("Non-alphanumeric name,
seriously?")
 data = shared_db.get("seen:" + name)
 if data == None:
 return Html("I have no records about this user.")
 data = json.loads(data)
 for room in mgr.rooms:
 if data[1] == "join":
 mgr.sendObject(target, Html("%s,%s   wants to tell you%s",
name.title, user.name.title$
 else:
 return Error("%s   I couldn't find %s
anywhere", user.name.title(), name.title())

i built it off these 2 commands

def broadcast(mgr, croom, user, msg, args):
 for room in mgr.rooms:
 mgr.sendObject(room, Html("Broadcast by%s:%s",
user.name, args))

def seen(mgr, room, user, msg, args):
name = args.lower().split(" ")[0]
if not name.isalnum(): return Html("Non-alphanumeric name, seriously?")
data = shared_db.get("seen:" + name)
if data == None:
return Html("I have no records about this user.")
data = json.loads(data)
ifdata[1] == "join":
return Html("Last seen%s   join%s,%s   ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "leave":
return Html("Last seen%s   leave%s,%s   ago.", name,
data[0], tdelta(data[2]))
elif data[1] == "message":
return Html("Last seen%s   message in%s,%s   ago:
\"%s\"", name, data[0], tdelta(data[2]), data[3])
return Html("I have no records about this user.")

as you can see i only use some of the command. it doesnt produce an error
message tho.. just repeats "return Error("%s   I couldn't find %s
anywhere", user.name.title(), name.title())"




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


No :( Please cut and past the exact code that you're using and the 
exception that you're getting, without that that it's impossible for us 
to help you.


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading mind set

2012-05-13 Thread Steven D'Aprano

Russel Winder wrote:

Steven,

On Sun, 2012-05-13 at 10:22 +1000, Steven D'Aprano wrote:

carlo locci wrote:

Hello All,
I've started to study python a couple of month ago(and I truly love it :)),
however I'm having some problems understanding how to modify a sequential
script and make it multithreaded (I think it's because I'm not used to
think in that way), 

No, that's because multithreading and parallel processing is hard.


Shared memory multithreading may be hard due to locks, semaphores,
monitors, etc., but concurrency and parallelism need not be hard. 


No hard compared to what?



Using processes and message passing, using dataflow, actors or CSP,
parallelism and concurrency is far more straightforward. Not easy,
agreed, but then programming isn't easy.



My argument is that once you move beyond the one-operation-after-another 
programming model, almost any parallel processing problem is harder than the 
equivalent sequential version, inherently due to the parallelism. Except 
perhaps for "embarrassingly parallel" problems, parallelism adds complexity 
even if your framework abstracts away most of the tedious detail like semaphores.


http://en.wikipedia.org/wiki/Embarrassingly_parallel

Once you move beyond sequential execution, you have to think about issues that 
don't apply to sequential programs: how to divide the task up between 
processes/threads/actors/whatever, how to manage their synchronization, 
resource starvation (e.g. deadlocks, livelocks), etc.


We have linear minds and it doesn't take that many real-time parallel tasks to 
overwhelm the human brain. I'm not saying that people can't reason in 
parallel, because we clearly can and do, but it's inherently harder than 
sequential reasoning.




The GIL in Python is a bad thing for parallelism. Using the
multiprocessing package or concurrent.futures gets over the problem.
Well sort of, these processes are a bit heavyweight compared to what can
be achieved on the JVM or with Erlang.


Python doesn't have a GIL. Some Python implementations do, most obviously 
CPython, the reference implementation. But Jython and IronPython don't. If the 
GIL is a problem for your program, consider running it on Jython or IronPython.




--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading mind set

2012-05-13 Thread Devin Jeanpierre
On Sun, May 13, 2012 at 8:31 PM, Steven D'Aprano  wrote:
>> Using processes and message passing, using dataflow, actors or CSP,
>> parallelism and concurrency is far more straightforward. Not easy,
>> agreed, but then programming isn't easy.
>
> My argument is that once you move beyond the one-operation-after-another
> programming model, almost any parallel processing problem is harder than the
> equivalent sequential version, inherently due to the parallelism. Except
> perhaps for "embarrassingly parallel" problems, parallelism adds complexity
> even if your framework abstracts away most of the tedious detail like
> semaphores.

If you agree that embarrassingly parallel multithreaded frameworks are
easy, what do you think of dataflow programming? It is exactly the
same, except that you can have multiple tasks, where one task depends
on the output of a previous task. It shares the property that it makes
no difference in what order things are executed (or sequential vs
parallel), so long as the data dependencies are respected -- so it's
another case where you don't actually have to think in a
non-sequential manner. (Rather, think in a "vectorized" per-work-item
manner.)

http://en.wikipedia.org/wiki/Dataflow_programming

It should be clear that not all ways of programming multithreaded code
are equal, and some are easier than others. In particular, having
mutable state shared between two concurrently-executing procedures is
phenomenally hard, and when it's avoided things become simpler.

-- Devin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sorry seems like it was sent in html

2012-05-13 Thread Dave Angel
On 05/13/2012 07:22 PM, Keitaro Kaoru wrote:
> is that better? not html... ? 

Your message is still html.  The following section of code shows no
indentation, so is very hard to interpret.


>
> def seen(mgr, room, user, msg, args):
> name = args.lower().split(" ")[0]
> if not name.isalnum(): return Html("Non-alphanumeric name, seriously?")
> data = shared_db.get("seen:" + name)
> if data == None:
> return Html("I have no records about this user.")
> data = json.loads(data)
> ifdata[1] == "join":
> return Html("Last seen%s  join%s,%s  ago.", name,
> data[0], tdelta(data[2]))
> elif data[1] == "leave":
> return Html("Last seen%s  leave%s,%s  ago.", name,
> data[0], tdelta(data[2]))
> elif data[1] == "message":
> return Html("Last seen%s  message in%s,%s  ago:
> \"%s\"", name, data[0], tdelta(data[2]), data[3])
> return Html("I have no records about this user.")
>
> as you can see i only use some of the command. it doesnt produce an error
> message tho.. just repeats "return Error("%s  I couldn't find %s
> anywhere", user.name.title(), name.title())"
>
>

  The following excerpt will show some of the html you sent:

Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

is that better? not html... ? hey. Austin here for some reason this co=
mmand. all it does it produces theerror message at the bottom.. =
itll say my name and the persons name imtrying to send the messa=
ge to but thats it. heres the command.=A0
mgr.addCommand("tell", 1, "send a person=
 a message to the rooms he is in",tell, unlisted =3D True)<=


In addition you keep starting new threads.  Use Reply-all to keep related 
messages together, and don't change the subject line if it's supposed to be 
part of the same thread.

I can't tell what this message's context is.  You start it with "hey Austin" 
but I don't see any other messages from an Austin, except about a year ago from 
an Austin Rodgers.


I guess I need to back off.  You don't list your imports, so people can only 
guess.  But clearly you're using some libraries I'm not familiar with.

Ask a clearer question, and somebody can probably help.

-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] hello~

2012-05-13 Thread Russel Winder
On Mon, 2012-05-14 at 00:19 +0100, Mark Lawrence wrote:
[...]
> Sorry but it's unreadable to me.  Have you sent this in HTML when you 
> should have sent in plain text?

I think it is just line wrapping, email still is supposed to have no
lines greater that 78 characters (RFC 2822) and some email clients
enforce this on sending by amending what the author thought they sent.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


signature.asc
Description: This is a digitally signed message part
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] threading mind set

2012-05-13 Thread Russel Winder
On Mon, 2012-05-14 at 10:31 +1000, Steven D'Aprano wrote:
[...]
> No hard compared to what?

Compared to sequential programming.

[...]
> My argument is that once you move beyond the one-operation-after-another 
> programming model, almost any parallel processing problem is harder than the 
> equivalent sequential version, inherently due to the parallelism. Except 
> perhaps for "embarrassingly parallel" problems, parallelism adds complexity 
> even if your framework abstracts away most of the tedious detail like 
> semaphores.
> 
> http://en.wikipedia.org/wiki/Embarrassingly_parallel
> 
> Once you move beyond sequential execution, you have to think about issues 
> that 
> don't apply to sequential programs: how to divide the task up between 
> processes/threads/actors/whatever, how to manage their synchronization, 
> resource starvation (e.g. deadlocks, livelocks), etc.

Actor systems, dataflow systems and CSP (Communicating Sequential
Processes), do not guarantee lack of deadlock or livelock, but the whole
"processes communicating by passing messages not by sharing data" make
it hugely easier to reason about what is happening.

Moreover if like with CSP, your actors or dataflow systems enforce
sequential actors/operators then it gets even better.

The secret to parallel processing (in general, there are always
exception/corner cases) is to write sequential bits that then
communicate using queues or channels.

No semaphores. No locks. No monitors. These are tools for operating
systems folk and for folk creating actor, dataflow and CSP queues and
channels.

> We have linear minds and it doesn't take that many real-time parallel tasks 
> to 
> overwhelm the human brain. I'm not saying that people can't reason in 
> parallel, because we clearly can and do, but it's inherently harder than 
> sequential reasoning.

I think if you delve into the psychology of it, our minds are far from
linear. Certainly at the electro-chemical level the brain is a massively
parallel machine.

Over the last 50 years, we have enshrined single processor, single
memory into our entire thinking about computing and programming. Our
education systems enforce sequential programming for all but the final
parallel programming option. The main reason for parallel programming
being labelled hard is that we have the wrong tools for reasoning about
it. This is the beauty of the 1960s/1970s models of actors, dataflow and
CSP, you deconstruct the problem into small bits each of which are
sequential and comprehensible, then the overall behaviour of the system
is an emergent property of the interaction between these small
subsystems.

Instead of trying to reason about all the communications systems wide,
we just worry about what happens with a small subsystem.

The hard part is the decomposition. But then the hard part of software
has always been the algorithm.

You highlight "embarrassingly parallel" which is the simplest
decomposition possible, straight scatter/gather, aka map/reduce. More
often that not this is handled by a façade such as "parallel reduce".

It is perhaps worth noting that "Big Data" is moving to dataflow
processing in a "Big Way" :-) Data mining and the like has been
revolutionized by changing it's perception of algorithm and how to
decompose problems. 

[...]
> Python doesn't have a GIL. Some Python implementations do, most obviously 
> CPython, the reference implementation. But Jython and IronPython don't. If 
> the 
> GIL is a problem for your program, consider running it on Jython or 
> IronPython.

It is true that Python doesn't have a GIL, thanks for the correction.
CPython and (until recently) PyPy have a GIL. The PyPy folk are
experimenting with software transactional memory (STM) in the
interpreter to be able to remove the GIL. To date things are looking
very positive. PyPy will rock :-)

Although Guido had said (EuroPython 2010) he is happy to continue with
the GIL in CPython, there are subversive elements (notable the PyPy
folk) who are trying to show that STM will work with CPython as well.

Jython is sadly lagging behind in terms of versions of Python supported
and is increasingly becoming irrelevant -- unless someone does something
soon. Groovy, JRuby and Clojure are the dynamic languages of choice on
the JVM.

IronPython is an interesting option except that there is all the FUD
about use of the CLR and having to buy extortion^H^H^H^H^H^H^H^H^H
licencing money to Microsoft. Also Microsoft ceasing to fund IronPython
(and IronRuby) is a clear indicator that Microsoft have no intention of
supporting use of Python on CLR. Thus it could end up in the same state
as Jython.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


signature.asc
Description: This is a digita