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

2012-05-12 Thread Steven D'Aprano

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?


The problem isn't getting it to stop. The problem is getting it to not start 
up again.


I too occasionally get these "Welcome" messages, about once every twenty or 
thirty posts. (Estimated.)



--
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-12 Thread Devin Jeanpierre
This is the third time I've received a message "for those of you new
to the Tutor list". When does it stop?

-- Devin

On Sat, May 12, 2012 at 11:19 PM,   wrote:
> Your message for tutor@python.org, the Python programming tutor list,
> has been received and is being delivered.  This automated response is
> sent to those of you new to the Tutor list, to point out a few
> resources that can help with answering your own questions, or improve
> the chances of getting a useful answer from the other subscribers.
>
> If your question is something akin to:
>
>    "I've just heard about Python, and it sounds great!  Where can I
>     find out more on how to program with Python?"
>
>  or:
>
>     "What's Python?"
>
> please read section 1 below.
>
> On the other hand, if your question is:
>
>    "I've heard that Python is good for hacking -- I want to know
> more!"
>
>  or
>
>    "Can you teach me how to break into a computer with Python?"
>
> please read section 2 at the bottom of this email.
>
> Section 1: --
>
> The most comprehensive overview of python.org help resources is at
>
>  http://www.python.org/Help.html
>
> The Python FAQ is available at
>
>  http://www.python.org/doc/FAQ.html
>
> and it has answers to many questions that people ask, possibly
> including your question.  Another wealth of information and experience
> can be found via the python.org searches, at
>
>  http://www.python.org/search/
>
> There you'll find comprehensive, easy-to-use searches over the
> python.org web site and the Python newsgroup, comp.lang.python.
>
> Python has an online tutorial, available freely from
>
>  http://www.python.org/doc/current/tutorial/index.html
>
> Finally, when you do send email to the Tutor list, be as clear as you
> can about the problem, including, when relevant, details like:
>
>  - Precise error messages, including complete tracebacks
>  - The hardware platform (available in the Python sys module as
> sys.platform)
>  - The python version (sys.version)
>  - The python search path (sys.path)
>
> In general, be specific about what was going on connected with the
> problem or what specific concept you're having difficulties with.  The
> better the info you provide, the more likely the helpers will be able
> to glean the answer...
>
> There's a HOWTO that shows how to ask "smart" questions to technical
> folks:
>
> http://catb.org/~esr/faqs/smart-questions.html
>
> Although it is provocative, it does have some good points, and is an
> interesting read.
>
>
> Note that no one is paid to read the tutor list or provide answers,
> and most readers often have other work that demands their attention.
> Well-posed requests for help are usually answered fairly promptly, but
> occasionally a request slips by, so if you do not get a response with
> one or two working days (it's usually quicker than that), please feel
> free to send a followup, asking whether anyone is working on your
> question.
>
> Anyway, your message is being delivered to the Tutor list as this one
> is being sent.  However, if your question was about as detailed as
> "Teach me how to program in Python", do not count on an answer -- this
> email contains all the information you need to start.  Come back with
> a more precise question, and we'll be glad to help.
>
>
> Thanks!
>
> Section 2: --
>
> We periodically get requests which ask about hacking or cracking or
> breaking into computers.  If you haven't yet, go read Eric Raymond's
> article "How To Become a Hacker" at
>  http://catb.org/esr/faqs/hacker-howto.html
>
> If, after you've read that, you want help learning how to hack the way
> Eric defines the word, then come back to us (and read Section 1
> above).  If you want help learning how to crack, go look elsewhere --
> we're not interested in helping you do that.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] syntax error

2012-05-12 Thread Devin Jeanpierre
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?

-- Devin
___
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-12 Thread bob gailer

def read():
couple of observations
1 - it is customary to put all import statements at the beginning of the 
file.
2 - it is customary to begin variable and function names with a lower 
case letter.
3 - it is better to avoid using built-in function names common method 
names (e.g. read).


def read():
import csv
with open('C:\\test\\VDB.csv', 'rb') as somefile:
read = csv.reader(somefile)
l = []
for row in read:
l += row
return l

def DirGetSize(cartella):
import os
cartella_size = 0
for (path, dirs, files) in os.walk(cartella):
for x in files:
filename = os.path.join(path, x)
cartella_size += os.path.getsize(filename)
return cartella_size

import os.path
for x in read():
if not os.path.exists(x):
print ' DOES NOT EXIST ON', x
else:
S = DirGetSize(x)
print 'the file size of', x, 'is',S



--
Bob Gailer
919-636-4239
Chapel Hill NC

___
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-12 Thread bob gailer

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.


When i copied and pasted the code it came out fine.

carlo: in future please post plain text rather than HTML.

--
Bob Gailer
919-636-4239
Chapel Hill NC

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


Re: [Tutor] syntax error

2012-05-12 Thread bob gailer

oh - and always provide a specific meaningful subject

--
Bob Gailer
919-636-4239
Chapel Hill NC

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


Re: [Tutor] (no subject)

2012-05-12 Thread bob gailer

On 5/12/2012 6:34 PM, Keitaro Kaoru wrote:
hey i keep having a problem with adding commands.. i get this error 
message


Traceback (most recent call last):
  File "bot.py", line 23, in 
import modules.core, modules.ai , modules.dict, 
modules.fun, modules.kc, modules.games, modules.lulz2, 
modules.modding, modules.meta, modules.mpd, modules.post, 
modules.poll, modules.util, modules.yt 

  File "/home/digest/digest/modules/core.py", line 170
def pm(mgr, room, user, msg, args):
  ^
SyntaxError: invalid syntax

Thanks for posting the traceback. All we need is to see more of the 
program (especially the lines before the one you posted. It is always a 
good idea to post more of the code regardless of the problem.


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
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-12 Thread Steven D'Aprano

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.



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.)


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




It's my understanding that threading a program in python can be useful when
we've got some I/O involved,


To see the benefit of threads, it's not enough to have "some" I/O, you need 
*lots* of I/O. Threads have some overhead. Unless you save at least as much 
time as just starting and managing the threads consumes, you won't see any 
speed up.


In my experience, for what little it's worth [emphasis on "little"], unless 
you can keep at least four threads busy doing separate I/O, it probably isn't 
worth the time and effort. And it's probably not worth it for trivial scripts 
-- who cares if you speed your script up from 0.2 seconds to 0.1 seconds?


But as a learning exercise, sure, go ahead and convert your script to threads. 
One experiment is worth a dozen opinions.


You can learn more about threading from here:

http://www.doughellmann.com/PyMOTW/threading/


By the way, in future, please don't decorate your code with stars:


* def read():*
*import csv*
*with open('C:\\test\\VDB.csv', 'rb') as somefile:*

[...]


We should be able to copy and paste your code and have it run immediately, not 
have to spend time editing it by hand to turn it back into valid Python code 
that doesn't give a SyntaxError on every line.


See also this: http://sscce.org/



--
Steven

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


Re: [Tutor] (no subject)

2012-05-12 Thread Steven D'Aprano

Keitaro Kaoru wrote:

hey i keep having a problem with adding commands.. i get this error message

Traceback (most recent call last):
  File "bot.py", line 23, in 
import modules.core, modules.ai, modules.dict, modules.fun, modules.kc,
modules.games, modules.lulz2, modules.modding, modules.meta, modules.mpd,
modules.post, modules.poll, modules.util, modules.yt
  File "/home/digest/digest/modules/core.py", line 170
def pm(mgr, room, user, msg, args):
  ^
SyntaxError: invalid syntax

worked fine before i edited a command in front of it...



Hint: when you change something, and things break, check the thing you changed.

In this case, I would expect that you haven't closed a set of brackets: you're 
probably missing a ) ] or }, most likely a ). The parser sometimes can't 
detect missing close-brackets until the line *following* the error.



--
Steven

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


[Tutor] (no subject)

2012-05-12 Thread Keitaro Kaoru
hey i keep having a problem with adding commands.. i get this error message

Traceback (most recent call last):
  File "bot.py", line 23, in 
import modules.core, modules.ai, modules.dict, modules.fun, modules.kc,
modules.games, modules.lulz2, modules.modding, modules.meta, modules.mpd,
modules.post, modules.poll, modules.util, modules.yt
  File "/home/digest/digest/modules/core.py", line 170
def pm(mgr, room, user, msg, args):
  ^
SyntaxError: invalid syntax

worked fine before i edited a command in front of it...
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] threading mind set

2012-05-12 Thread carlo locci
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), 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).
It's my understanding that threading a program in python can be useful when
we've got some I/O involved, so here is my case, I wrote a quite simple
script that reads the first column from a csv file and insert every row of
the value into a tuple, then I created a function which gets me the size of
a given path/folder and I made it loop so that it'll print the the folder
dimension of each path is in the tuple previously created. Here's the code:

* def read():*
*import csv*
*with open('C:\\test\\VDB.csv', 'rb') as somefile:*
*read = csv.reader(somefile)*
*l = []*
*for row in read:*
*l += row*
*return l*
*
*
*def DirGetSize(cartella):*
*import os*
*cartella_size = 0*
*for (path, dirs, files) in os.walk(cartella):*
*for x in files:*
*filename = os.path.join(path, x)*
*cartella_size += os.path.getsize(filename)*
*return cartella_size*
*
*
*import os.path*
*for x in read():*
*if not os.path.exists(x):*
*print ' DOES NOT EXIST ON', x*
*else:*
*S = DirGetSize(x)*
*print 'the file size of', x, 'is',S*
*
*
The script works quite well(at least does what I want), but my real
question is will I gain any better performance, in terms of speed, out of
it, if I multithread it? The csv file contains a list of server/path/folder
therefore I though that If I would multitread it I's gonna became much
faster since it will perform the *DirGetSize,*
function almost concurrently, although I'm quite confused by the subject,
so I'm not really sure. I would really appreciate anyone who would make me
understand when it's useful to implement a multreaded script and when it's
not and why :),(Maybe I'm asking to much), as well as any good resources
where I can study
from. Thank you in advance to anyone who will reply me as well as thank you
for having such a mailinglist(I discovered it when I had watched a google
I/O conference on youtube). Thank you guys.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2012-05-12 Thread allen.fow...@yahoo.com
http://laespecialeu.com/gdfgdsf/lightbox/thjfle.html?bnd=fhttd.gve&dd=rd.fhr&sw=xrsq___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor