Re: using queue

2009-09-02 Thread Jan Kaliszewski

06:49:13 Scott David Daniels  wrote:


Tim Arnold wrote:


(1) what's wrong with having each chapter in a separate thread? Too  
much going on for a single processor?



Many more threads than cores and you spend a lot of your CPU switching
tasks.


In fact, python threads work relatively the best with a powerful single
core; with more cores it becomes being suprisingly inefficient.

The culprit is Pythn GIL and the way it [mis]cooperates with OS
scheduling.

See: http://www.dabeaz.com/python/GIL.pdf

Yo
*j

--
Jan Kaliszewski (zuo) 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to install pywin32 for Python 2.6.2

2009-09-02 Thread Gabriel Genellina
En Thu, 03 Sep 2009 02:16:13 -0300, David Lees   
escribió:


In case anyone else has this problem, my mistake was a PYTHONPATH that  
pointed to my Python 2.5 installation.  I simply changed it to:

C:\Python26\Lib\site-packages
and reran the Pywin32 installer and all is fine.


Assuming you installed Python into C:\Python26, then  
C:\Python26\Lib\site-packages is already on your Python search path; you  
don't even need to set PYTHONPATH at all.


--
Gabriel Genellina

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


Re: string find mystery

2009-09-02 Thread John Yeung
On Sep 3, 1:45 am, Sean DiZazzo  wrote:
> string.find() returns the index at which the given word is found
> within the string.  If the string is not found it returns -1.  So, no
> matter what you do, string.find() will evaluate to "True"

It will evaluate as false if the substring is found at the beginning
(position 0).

> You could use it like this:  if file_str.find("Geometry") != -1:
>
> but you probably want to use: if "Geometry" in file_str:

This is good advice, however.

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


Re: string find mystery

2009-09-02 Thread John Yeung
On Sep 3, 1:10 am, Helvin  wrote:
>         if file_str.find('Geometry'):
>         #if file_str.endswith('Data_Input_Geometry.txt'):
>             print 'I found geometry'
> The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default
> \Data_Input_Material.txt',
> the first if statement if fulfilled, that seemingly says that in this
> file_str, python actually finds the word 'Geometry'.
>
> Does anyone know why this is happening?

Yep.  You should read the documentation on the find method.  It
returns -1 when the substring is not found.  Also, if 'Geometry' had
been found at the beginning, it would have returned 0.

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


Re: string find mystery

2009-09-02 Thread Sean DiZazzo
On Sep 2, 10:10 pm, Helvin  wrote:
> Hi,
>
> I have come across this very strange behaviour. Check this code:
>
>         if file_str.find('Geometry'):
>         #if file_str.endswith('Data_Input_Geometry.txt'):
>             print 'I found geometry'
>         elif file_str.find('Material'):
>             print 'I found material'
> The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default
> \Data_Input_Material.txt',
> the first if statement if fulfilled, that seemingly says that in this
> file_str, python actually finds the word 'Geometry'.
> I know this, because the line: 'I found geometry' is printed. However,
> if instead of using file_str.find(), I use file_str.endswith(), it
> does not exhibit this strange behaviour.
>
> Obviously, I want the elif line to be true, instead of the first if
> statement.
>
> Does anyone know why this is happening?
> Help much appreciated!
>
> Very puzzled,
> Helvin

string.find() returns the index at which the given word is found
within the string.  If the string is not found it returns -1.  So, no
matter what you do, string.find() will evaluate to "True"

You could use it like this:  if file_str.find("Geometry") != -1:

but you probably want to use: if "Geometry" in file_str:

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


Re: string find mystery

2009-09-02 Thread Stephen Hansen
On Wed, Sep 2, 2009 at 10:33 PM, Helvin Lui  wrote:

> Thanks!  I just realised that too, but I used the condition:.find() >
> 0 But I think your's is better.
> Simple programming knowledge...  > <
>

Ah, but != 0 vs > 0 isn't a question of better, but correctness: because if
.find() returns 0, that's a successful result. That means it successfully
found the string-- at index 0, meaning the beginning of the string. This is
a function of Python indexing sequences starting with 0. Some people have
argued that this -1 behavior on .find is "unpythonic" from time to time, but
the other solutions just aren't very good for various reasons (e.g.,
returning None).

An alternate is .index() which raises ValueError on not-found which
side-steps the oddity if the -1.

On the blog:

 if (myString.find('bye') != -1):

It's generally bad-form to surround the expression passed to the "if"
statement in parens (unless necessary for implicit line wrapping purposes)
:) It's considered more Pythonic and clear to just do:

if myString.find('bye') != -1:

Although of course, that's a style and preference issue and so it's really
up to you.

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


Re: map

2009-09-02 Thread Hendrik van Rooyen
On Wednesday 02 September 2009 09:38:20 elsa wrote:

>
> in my own defense - firstly, I was able to implement what I wanted to
> do with loops, and I used this to solve the problem I needed to.

My rant was not intended as a personal attack - far from it - if all the 
people on this list were to post such clear questions as you did, it would be 
an even greater pleasure to participate in than it is.

>
> However, by asking *why* map didn't work, I now understand how map
> works, what contexts it may indeed be useful for, and what the
> alternatives are. To boot, you have all given me about 10 different
> ways of solving the problem, some of which use prettier (and probably
> faster) code than the loops I wrote...

Good. So you will soon be here answering questions too.  When you do that, you 
really learn, as long as you do not feel slighted when people point out 
better (or merely different) solutions than yours.  We all help each other 
here, and sometimes we even crack obscure (and not so obscure) jokes.

- Hendrik

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


Re: string find mystery

2009-09-02 Thread Helvin Lui
Thanks!  I just realised that too, but I used the condition:.find() > 0 But
I think your's is better.
Simple programming knowledge...  > <
I made a blog post:
http://learnwithhelvin.blogspot.com/2009/09/1-is-true-if-loops.html



On Thu, Sep 3, 2009 at 5:19 PM, Stephen Hansen wrote:

> The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default
>> \Data_Input_Material.txt',
>> the first if statement if fulfilled, that seemingly says that in this
>> file_str, python actually finds the word 'Geometry'.
>> I know this, because the line: 'I found geometry' is printed. However,
>> if instead of using file_str.find(), I use file_str.endswith(), it
>> does not exhibit this strange behaviour.
>>
>>
> The problem is str.find returns -1 on failure; and -1 is a true value. Only
> 0, empty string, empty sequences, etc, are false values.
>
> So, you have to test, 'if find_str.find(pattern) != -1:'
>
> HTH,
>
> --S
>



-- 
Helvin

"Though the world may promise me more, I'm just made to be filled with the
Lord."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to install pywin32 for Python 2.6.2

2009-09-02 Thread David Lees

David Lees wrote:
I install Python 2.6.2 with no problem, but then run the installer for 
pywin32 from Source Forge and get this message at the end.  IDLE works, 
but Pywin32 does not.


Traceback (most recent call last):
  File "", line 601, in 
  File "", line 313, in install
ImportError: DLL load failed: The specified module could not be found
--
I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not 
help.  Any suggestions on how to install Pywin32 appreciated.


TIA

David Lees


Oops, Pardon my posting this.  I should have Googled first and would 
have solved the problem.  I posted this in May, and Mark Hammond solved 
the problem then.  I forgot about it and repeated mistake.


In case anyone else has this problem, my mistake was a PYTHONPATH that 
pointed to my Python 2.5 installation.  I simply changed it to:

C:\Python26\Lib\site-packages
and reran the Pywin32 installer and all is fine.

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


Re: string find mystery

2009-09-02 Thread Stephen Hansen
>
> The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default
> \Data_Input_Material.txt',
> the first if statement if fulfilled, that seemingly says that in this
> file_str, python actually finds the word 'Geometry'.
> I know this, because the line: 'I found geometry' is printed. However,
> if instead of using file_str.find(), I use file_str.endswith(), it
> does not exhibit this strange behaviour.
>
>
The problem is str.find returns -1 on failure; and -1 is a true value. Only
0, empty string, empty sequences, etc, are false values.

So, you have to test, 'if find_str.find(pattern) != -1:'

HTH,

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


string find mystery

2009-09-02 Thread Helvin
Hi,

I have come across this very strange behaviour. Check this code:

if file_str.find('Geometry'):
#if file_str.endswith('Data_Input_Geometry.txt'):
print 'I found geometry'
elif file_str.find('Material'):
print 'I found material'
The amazing thing is when file_str  = 'C:\Qt\SimLCM\Default
\Data_Input_Material.txt',
the first if statement if fulfilled, that seemingly says that in this
file_str, python actually finds the word 'Geometry'.
I know this, because the line: 'I found geometry' is printed. However,
if instead of using file_str.find(), I use file_str.endswith(), it
does not exhibit this strange behaviour.

Obviously, I want the elif line to be true, instead of the first if
statement.

Does anyone know why this is happening?
Help much appreciated!

Very puzzled,
Helvin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating slice notation from string

2009-09-02 Thread Paul McGuire
On Sep 2, 4:55 pm, bvdp  wrote:
> I'm trying to NOT create a parser to do this  and I'm sure that
> it's easy if I could only see the light!
>

Well, this is a nice puzzler, better than a sudoku.  Maybe a quick
parser with pyparsing will give you some guidance on how to do this
without a parser library:

from pyparsing import *

# relevant punctuation, suppress after parsing
LBR,RBR,COLON = map(Suppress,"[]:")

# expression to parse numerics and convert to int's
integer = Regex("-?\d+").setParseAction(lambda t: int(t[0]))

# first try, almost good enough, but wrongly parses "[2]" -> [2::]
sliceExpr = ( LBR + Optional(integer,default=None) +
Optional(COLON + Optional(integer,default=None),
default=None) +
Optional(COLON + Optional(integer,default=None),
default=None) +
RBR )

# better, this version special-cases "[n]" -> [n:n+1]
# otherwise, just create slice from parsed int's
singleInteger = integer + ~FollowedBy(COLON)
singleInteger.setParseAction(lambda t : [t[0],t[0]+1])

sliceExpr = ( LBR +
(singleInteger |
Optional(integer,default=None) +
Optional(COLON + Optional(integer,default=None),
default=None) +
Optional(COLON + Optional(integer,default=None),
default=None)
) +
  RBR )

# attach parse action to convert parsed int's to a slice
sliceExpr.setParseAction(lambda t: slice(*(t.asList(


tests = """\
[2]
[2:3]
[2:]
[2::2]
[-1:-1:-1]
[:-1]
[::-1]
[:]""".splitlines()

testlist = range(10)
for t in tests:
parsedSlice = sliceExpr.parseString(t)[0]
print t, parsedSlice, testlist[parsedSlice]


Prints:

[2] slice(2, 3, None) [2]
[2:3] slice(2, 3, None) [2]
[2:] slice(2, None, None) [2, 3, 4, 5, 6, 7, 8, 9]
[2::2] slice(2, None, 2) [2, 4, 6, 8]
[-1:-1:-1] slice(-1, -1, -1) []
[:-1] slice(None, -1, None) [0, 1, 2, 3, 4, 5, 6, 7, 8]
[::-1] slice(None, None, -1) [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
[:] slice(None, None, None) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]


Yes, it is necessary to handle the special case of a "slice" that is
really just a single index.  If your list of parsed integers has only
a single value n, then the slice constructor creates a slice
(None,n,None).  What you really want, if you want everything to create
a slice, is to get slice(n,n+1,None).  That is what the singleInteger
special case does in the pyparsing parser.

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


Re: python daemon - compress data and load data into MySQL by pyodbc

2009-09-02 Thread Sean DiZazzo
On Sep 2, 8:36 pm, MacRules  wrote:
> Hi,
>
> I installed Python daemon, pyodbc module to access the back-end DB server.
>
> My setup is like this
>
> load data job -> Python Daemon A, port 6000 -> Python Daemon B, port
> 7000 -> MySQL
>
> Daemon A will perform data compression, such as GZIP, and send over data
> to Daemon B.
> Daemon B will perform data uncompression, GUNZIP, and insert records to
> MySQL or MSSQL or Oracle.
>
> Where should I start this to code this?
> Can someone give me a hint, as detail as possible here?
>
> I am a python newbie.
>
> Thanks for all the help I can get,

Start by reading the tutorial.  http://docs.python.org/tutorial/

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


Unable to install pywin32 for Python 2.6.2

2009-09-02 Thread David Lees
I install Python 2.6.2 with no problem, but then run the installer for 
pywin32 from Source Forge and get this message at the end.  IDLE works, 
but Pywin32 does not.


Traceback (most recent call last):
  File "", line 601, in 
  File "", line 313, in install
ImportError: DLL load failed: The specified module could not be found
--
I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not 
help.  Any suggestions on how to install Pywin32 appreciated.


TIA

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


Re: using queue

2009-09-02 Thread Scott David Daniels

Tim Arnold wrote:
"MRAB"  wrote in message 
news:mailman.835.1251886213.2854.python-l...@python.org...

I don't need that many threads; just create a few to do the work and let
each do multiple chapters, something like this:


a very pretty implementation with worker code:

while True:
chapter = self.chapter_queue.get()
if chapter is None:
# A None indicates that there are no more chapters.
break
chapter.compile()
# Put back the None so that the next thread will also see it.
self.chapter_queue.put(None)


and loading like:

for c in self.document.chapter_objects:
chapter_queue.put()
chapter_queue.put(None)
...
# The threads will finish when they see the None in the queue.
for t in thread_list:
t.join()


hi, thanks for that code. It took me a bit to understand what's going on, 
but I think I see it now.

Still, I have two questions about it:
(1) what's wrong with having each chapter in a separate thread? Too much 
going on for a single processor? 

Many more threads than cores and you spend a lot of your CPU switching
tasks.

(2) The None at the end of the queue...I thought t.join() would just work. 
Why do we need None?


Because your workers aren't finished, they are running trying to get
something more to do out of the queue.  The t.join() would cause a
deadlock w/o the None.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


select.kqueue.control changelist argument

2009-09-02 Thread Ritesh Nadhani
Hi

According to the docs at, http://docs.python.org/library/select.html

Low level interface to kevent

* changelist must be an iterable of kevent object or None
* max_events must be 0 or a positive integer
* timeout in seconds (floats possible)

I am not sure I understood what happens when I pass *None* as
parameter to the method.

Can somebody point me to the right direction?

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


Re: Entry Level Python Jobs

2009-09-02 Thread steve


On 09/03/2009 09:36 AM, steve wrote:

Hi Jonathan,
[...snip...]


I feel stupid replying to my own post but just one more thing i thought about 
mentioning but forgot to add:
- Look at your Liberal Arts major as an advantage. Every field has a 'computing 
gap' that needs to be filled but cannot be done because they aren't any too many 
good people who have the relevant cross-domain knowledge. For instance, one of 
the reasons I think this month's sourceforge.net project of the month is really 
great is because the lead dev. has a CS degree and is listed as being a medicine 
student:

http://sourceforge.net/community/potm-200909/

So, look for these gaps in your domain which can be filled using your technical 
knowledge.


again, ..


Wish you the best,
regards,
- steve



--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: using queue

2009-09-02 Thread Tim Arnold

"MRAB"  wrote in message 
news:mailman.835.1251886213.2854.python-l...@python.org...
> Tim Arnold wrote:
>> Hi, I've been using the threading module with each thread as a key in a 
>> dictionary. I've been reading about Queues though and it looks like 
>> that's what I should be using instead. Just checking here to see if I'm 
>> on the right path.
>> The code I have currently compiles a bunch of chapters in a book (no more 
>> than 80 jobs at a time) and just waits for them all to finish:
>>
>> max_running = 80
>> threads = dict()
>> current = 1
>> chaps = [x.config['name'] for x in self.document.chapter_objects]
>> while current <= len(chaps):
>> running = len([x for x in threads.keys() if 
>> threads[x].isAlive()])
>> if running == max_running:
>> time.sleep(10)
>> else:
>> chap = chaps[current - 1]
>> c = self.compiler(self.document.config['name'], chap)
>> threads[chap] = threading.Thread(target=c.compile)
>> threads[chap].start()
>> current += 1
>>
>> for thread in threads.keys():
>> threads[thread].join(3600.0)
>> -
>> but I think Queue could do a lot of the above work for me. Here is 
>> pseudocode for what I'm thinking:
>>
>> q = Queue(maxsize=80)
>> for chap in [x.config['name'] for x in self.document.chapter_objects]:
>> c = self.compiler(self.document.config['name'], chap)
>> t = threading.Thread(target=c.compile)
>> t.start()
>> q.put(t)
>> q.join()
>>
>> is that the right idea?
>>
> I don't need that many threads; just create a few to do the work and let
> each do multiple chapters, something like this:
>
> class CompilerTask(object):
> def __init__(self, chapter_queue):
> self.chapter_queue = chapter_queue
> def __call__(self):
> while True:
> chapter = self.chapter_queue.get()
> if chapter is None:
> # A None indicates that there are no more chapters.
> break
> chapter.compile()
> # Put back the None so that the next thread will also see it.
> self.chapter_queue.put(None)
>
> MAX_RUNNING = 10
>
> # Put the chapters into a queue, ending with a None.
> chapter_queue = Queue()
> for c in self.document.chapter_objects:
> chapter_queue.put(self.compiler(self.document.config['name'], 
> c.config['name']))
> chapter_queue.put(None)
>
> # Start the threads to do the work.
> for i in range(MAX_RUNNING):
> t = threading.Thread(target=CompilerTask(chapter_queue))
> t.start()
> thread_list.append(t)
>
> # The threads will finish when they see the None in the queue.
> for t in thread_list:
> t.join()
>

hi, thanks for that code. It took me a bit to understand what's going on, 
but I think I see it now.
Still, I have two questions about it:
(1) what's wrong with having each chapter in a separate thread? Too much 
going on for a single processor? I guess that probably doesn't matter at 
all, but some chapters run in minutes and some in seconds.
(2) The None at the end of the queue...I thought t.join() would just work. 
Why do we need None?

thanks for thinking about this,
--Tim Arnold


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


Re: Using select.kqueue()

2009-09-02 Thread Ritesh Nadhani
Indeed, I was facing that issue.

Appplying the patch to the select26 module now works.

Also, I had to change:

kq.control([]...)

to

kq.control(ev, ...)

Not sure what happens when you pass None as the first parameter.

On Tue, Sep 1, 2009 at 5:47 AM,  wrote:
> On 07:51 am, rite...@gmail.com wrote:
>>
>> Hi
>>
>> I am trying to use kqueue. Since, I am on v2.5, I use the baclport:
>> http://pypi.python.org/pypi/select26/0.1a3.
>>
>> Following the example at:
>> http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which
>> works perfectly as it tells all events), I tried to port it to Python:
>>
>> http://www.bpaste.net/show/25/
>>
>> Not sure where I am wrong but the poller only returns *one* event
>> ever. Adding new text, deleting the file does not return any event.
>>
>> What can I be doing wrong?
>
> Perhaps you are encountering http://bugs.python.org/issue5910
>
> Jean-Paul
>



-- 
Ritesh
http://www.riteshn.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Entry Level Python Jobs

2009-09-02 Thread steve

Hi Jonathan,

On 09/02/2009 10:22 PM, JonathanB wrote:

Ok, so what I'm hearing is "Get a code portfolio together and watch
the job board on python.org." Thanks for the advice!

I've been watching the python job board 3-4 times a week and I've been
working my way through the Project Euler problems in my free time. I
also have a trade generator that I wrote up to support a Traveller
game I was running a while back, but that code is old (the first non-
trivial program I ever wrote) and really fairly buggy. The user
interface is basically an infinite recursion that I sys.exit() out of
when I'm through, which means the code slows considerably as you do
more stuff in it because each trip back to the main menu is a
recursive call to the main() function. Hey, I was young and naive. I'm
working on cleaning it up right now. Any other tips?


- Keep an eye out for jobs which are not directly programming related -- things 
like system administration (which might involve scripting), that's the way I 
started.


- Bid for some projects at places like odesk.com, rentacoder.com, 
getafreelancer.com etc. A lot of people here might be averse to the idea (and 
they'd have good reasons for it too), but doing this will pay off in the long 
run. You might get a feel of why people might be averse to the idea by reading 
these:

http://www.codinghorror.com/blog/archives/001190.html
http://www.examiner.com/x-1652-Gadgets-Examiner~y2008m11d14-oDesk-Guru-Elance-and-RentACoder--Are-they-worth-it

Basically, these kind of jobs might end up being more trouble than their worth. 
However, I personally found that it is possible to build long term business 
relationships, which you can then take external to these sites, quite quickly if 
you are any good.


Here is a comparison chart in case you decide to go for it

http://thethriftygeek.com/2008/11/comparing-the-online-consulting-sites/

Wish you the best,
regards,
- steve
--
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: exec globals and locals

2009-09-02 Thread John Nagle

Chris Rebert wrote:

On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin wrote:

Hi,
Being fairly new to Python, I'm trying to figure out the best way to use the
exec statement and I must admit that I am a bit lost.


Generally, if you want to use the exec statement, you're probably lost.
Unless you have a desperate need to execute some code whose content isn't
determined until run time, don't use the exec statement.  If the code
comes from an external source, you're probably creating a security hole.

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


Re: Creating slice notation from string

2009-09-02 Thread Steven D'Aprano
On Wed, 02 Sep 2009 17:32:09 -0700, Bob van der Poel wrote:

> Actually, nither this or Jan's latest is working properly. I don't know
> if it's the slice() function or what (I'm using python 2.5). But:
> 
> x = [1,2,3,4,5]
> slice_string="2"
> items = [int(n) if n else None for n in slice_string.split(":")]
> [slice(*items)]
> [1, 2]

It's not clear what is input and what is output. I'm *guessing* that the 
first four lines are input and the fifth is output.

By the way, nice catch for the "else None". But why are you wrapping the 
call to slice() in a list in the fourth line?


I can't replicate your results. I get the expected results:


>>> slice_string="2"
>>> items = [int(n) if n else None for n in slice_string.split(":")]
>>> [slice(*items)]
[slice(None, 2, None)]

exactly the same as:

>>> slice(2)
slice(None, 2, None)

Testing this, I get the expected result:

>>> x = [1,2,3,4,5]
>>> x[slice(*items)]
[1, 2]

which is exactly the same if you do this:

>>> x[:2:]
[1, 2]


> not the expected:
> 
> [3]

Why would you expect that? You can't get that result from a slice based 
on 2 only. Watch:

>>> x[2::]
[3, 4, 5]
>>> x[:2:]
[1, 2]
>>> x[::2]
[1, 3, 5]

There is no slice containing *only* 2 which will give you the result you 
are asking for. You would need to do this:

>>> x[2:3]
[3]


Perhaps what you are thinking of is *indexing*:

>>> x[2]
3

but notice that the argument to list.__getitem__ is an int, not a slice, 
and the result is the item itself, not a list.

To get the behaviour you want, you need something more complicated:

def strToSlice(s):
if ':' in s:
items = [int(n) if n else None for n in s.split(':')]
else:
if s:
n = int(s)
items = [n, n+1]
else:
items = [None, None, None]
return slice(*items)



> Things like -1 don't work either.

They do for me:


>>> slice_string="2:-2"
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> items = [int(n) if n else None for n in slice_string.split(":")]
>>> x[ slice(*items) ]
[3, 4, 5, 6, 7, 8]
>>> x[2:-2]
[3, 4, 5, 6, 7, 8]




> I'm really not sure what's going on, but I suspect it's the way that
> slice() is getting filled when the slice string isn't a nice one with
> each ":" present?

I think you're confused between __getitem__ with a slice argument and 
__getitem__ with an int argument.



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


python daemon - compress data and load data into MySQL by pyodbc

2009-09-02 Thread MacRules

Hi,

I installed Python daemon, pyodbc module to access the back-end DB server.

My setup is like this

load data job -> Python Daemon A, port 6000 -> Python Daemon B, port 
7000 -> MySQL


Daemon A will perform data compression, such as GZIP, and send over data 
to Daemon B.
Daemon B will perform data uncompression, GUNZIP, and insert records to 
MySQL or MSSQL or Oracle.


Where should I start this to code this?
Can someone give me a hint, as detail as possible here?

I am a python newbie.

Thanks for all the help I can get,
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating slice notation from string

2009-09-02 Thread Ethan Furman
On Wed, 02 Sep 2009 17:36:36 -0700, Bob van der Poel   
wrote:



On Sep 2, 4:27 pm, Ethan Furman  wrote:

Bob van der Poel wrote:



>>For a one-liner:

>>   x[slice(*map(int, x[1:-1].split(':')))]

> Thanks.

> Almost works :)

> For s="[2]" and s="[1:2]" it's fine. But, if I have

> s = "[:2]" then I get:

x[slice(*[int(i) for i in s.strip("[]").split(":")])]

> Traceback (most recent call last):
>   File "", line 1, in 
> ValueError: invalid literal for int() with base 10: ''

> Similar problem with  [2:].

> Ideas?

try:
     start, end = s[1:-1].split(':')
except ValueError:
     start = int(s[1:-1] # only one value specified
     end = start+1
start = int(start) if start else 0
end = int(end) if end else len(x)
x[start:end]

~Ethan~


Yes ... I see. I'm thinking that eval() is looking very nice. If we do
it the above way we also have to check for empties using things like
[1::2] and I'm really getting confused about the possibilities :)


How about:

[untested]
s = s[1:-1]  # strip the brackets
if s.count(':') == 0:
return x[int(s)]
while s.count(':') < 2:
s += ':'
start, stop, step = s.split(':')
start = int(start) if start else 0
end = int(stop) if stop else len(x)
step = int(step) if step else 1
return x[start:stop:step)

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


Re: ctypes WNetGetUniversalNameW

2009-09-02 Thread Gabriel Genellina
En Wed, 02 Sep 2009 14:24:10 -0300, Gustavo   
escribió:



I'm trying to call WNetGetUniversalNameW via the ctypes module but I'm
only causing the interpreter to crash. Unfortunately I don't have much
experience with the ctypes module and I'm still trying to figure it
out. I've searched for a solution to no avail. My confusion is
centered around the LPVOID buffer parameter and how this should be
created/used. Any help is appreciated.

# DWORD WNetGetUniversalName(
#  __in LPCTSTR lpLocalPath,
#  __in DWORD dwInfoLevel,
#  __outLPVOID lpBuffer,
#  __inout  LPDWORD lpBufferSize
# );


import ctypes, win32netcon
from ctypes import wintypes

LPDWORD = ctypes.POINTER(wintypes.DWORD)
class UniversalNameInfo(ctypes.Structure):
# note the SINGLE underscores!
_fields_ = [("lpUniversalName", wintypes.LPWSTR)]
PUniversalNameInfo = ctypes.POINTER(UniversalNameInfo)

WNetGetUniversalNameW = ctypes.windll.mpr.WNetGetUniversalNameW
WNetGetUniversalNameW.argtypes = [
  wintypes.LPCWSTR,
  wintypes.DWORD,
  wintypes.LPVOID,
  LPDWORD]

path = 'Y:'
level = win32netcon.UNIVERSAL_NAME_INFO_LEVEL
# you must suply your own buffer:
buffer = ctypes.create_unicode_buffer(1024)
buffersize = wintypes.DWORD(ctypes.sizeof(buffer))

ret = WNetGetUniversalNameW(path, level,
  ctypes.byref(buffer), ctypes.byref(buffersize))
print ret
# casting to pointer to UniversalNameInfo struct
puni = ctypes.cast(buffer, PUniversalNameInfo)
# dereference the pointer and access its (only) field
print puni.contents.lpUniversalName

--
Gabriel Genellina

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


Re: website feedback to where?

2009-09-02 Thread Gabriel Genellina
En Wed, 02 Sep 2009 17:47:04 -0300, rogerdpack   
escribió:

On Sep 2, 12:30 pm, Terry Reedy  wrote:

rogerdpack wrote:



>http://docs.python.org/3.1/tutorial/introduction.html
> some of the "text" examples are [incorrectly] color formatted.

I did not see any problems with my browser (FF3.5), so please be more
specific.


search for "This is a rather long string containing"
I suppose this is more of a documentation bug...


patch submitted: http://bugs.python.org/issue6828

--
Gabriel Genellina

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


Qstrings to Strings

2009-09-02 Thread Helvin
Just wanted to say, to convert qstrings (or integers for that matter)
to strings, use the str() function.

http://learnwithhelvin.blogspot.com/2009/09/qstrings-and-strings.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with writelines

2009-09-02 Thread r
On Sep 2, 8:20 am, LeeRisq  wrote:
(snip: code)

> Traceback:
(snip)
> TypeError: writelines() argument must be a sequence of strings

Well you need to print out "y" and see whats in there. The error is
pretty obvious.

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


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:27 pm, Ethan Furman  wrote:
> Bob van der Poel wrote:
>
>
>
> >>For a one-liner:
>
> >>   x[slice(*map(int, x[1:-1].split(':')))]
>
> > Thanks.
>
> > Almost works :)
>
> > For s="[2]" and s="[1:2]" it's fine. But, if I have
>
> > s = "[:2]" then I get:
>
> x[slice(*[int(i) for i in s.strip("[]").split(":")])]
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ValueError: invalid literal for int() with base 10: ''
>
> > Similar problem with  [2:].
>
> > Ideas?
>
> try:
>      start, end = s[1:-1].split(':')
> except ValueError:
>      start = int(s[1:-1] # only one value specified
>      end = start+1
> start = int(start) if start else 0
> end = int(end) if end else len(x)
> x[start:end]
>
> ~Ethan~

Yes ... I see. I'm thinking that eval() is looking very nice. If we do
it the above way we also have to check for empties using things like
[1::2] and I'm really getting confused about the possibilities :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 5:16 pm, Steven D'Aprano  wrote:
> On Wed, 02 Sep 2009 16:41:34 -0700, Bob van der Poel wrote:
>
> > But, translating 1, 2 or 3 ints into a valid splice isn't quit that
> > easy? I could figure each value, and convert them to either int or None
> > (key is the None! From my previous try '' doesn't work!)
>
> > But, I still need three possible lines:
>
> >  if len(i) == 1:
> >     x=x[i(0)]
> >   else if len(i) == 2:
> >     x=x[i(0):i(1)]
> >    
>
> items = [int(n) for n in slice_string.split(":")]
> slice(*items)
>
> --
> Steven

Actually, nither this or Jan's latest is working properly. I don't
know if it's the slice() function or what (I'm using python 2.5). But:

x = [1,2,3,4,5]
slice_string="2"
items = [int(n) if n else None for n in slice_string.split(":")]
[slice(*items)]
[1, 2]

not the expected:

[3]

Things like -1 don't work either.

I'm really not sure what's going on, but I suspect it's the way that
slice() is getting filled when the slice string isn't a nice one with
each ":" present?

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


Re: Creating slice notation from string

2009-09-02 Thread Ethan Furman

Bob van der Poel wrote:

For a one-liner:

  x[slice(*map(int, x[1:-1].split(':')))]



Thanks.

Almost works :)

For s="[2]" and s="[1:2]" it's fine. But, if I have

s = "[:2]" then I get:



x[slice(*[int(i) for i in s.strip("[]").split(":")])]


Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: ''

Similar problem with  [2:].

Ideas?


try:
start, end = s[1:-1].split(':')
except ValueError:
start = int(s[1:-1] # only one value specified
end = start+1
start = int(start) if start else 0
end = int(end) if end else len(x)
x[start:end]

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


Re: Creating slice notation from string

2009-09-02 Thread Steven D'Aprano
On Wed, 02 Sep 2009 16:41:34 -0700, Bob van der Poel wrote:

> But, translating 1, 2 or 3 ints into a valid splice isn't quit that
> easy? I could figure each value, and convert them to either int or None
> (key is the None! From my previous try '' doesn't work!)
> 
> But, I still need three possible lines:
> 
>  if len(i) == 1:
> x=x[i(0)]
>   else if len(i) == 2:
> x=x[i(0):i(1)]
>

items = [int(n) for n in slice_string.split(":")]
slice(*items)



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


Re: Why does this group have so much spam?

2009-09-02 Thread Steven D'Aprano
On Wed, 02 Sep 2009 21:53:15 +0200, David wrote:

>> As for the argument that home users who send spam are the victim,
>> that's true up to a point, but not very far. Here's an analogy: suppose
>> that terrorists sneak into your house after picking the lock -- or in
>> the case of Windows users with no firewall or anti-malware, stroll
>> through the unlocked front door -- and spend the next six months camped
>> in your spare bedroom, using your home for their base of operations
>> while they make terrorist attacks. When the FBI kicks your doors down,
>> don't you think you would be arrested and would have to prove that you
>> couldn't be reasonably expected to know they were there? If millions of
>> spam emails are coming out of your PC, that's prima facie evidence that
>> YOU are spamming. You would need to prove that you're an innocent
>> victim who couldn't *reasonably* be expected to know that your machine
>> was hijacked -- you would need to prove that the spam bot was so
>> sophisticated that it infected your PC despite the firewall, that you
>> didn't install it yourself in order to get some stupid game, that no
>> commonly available anti-malware program detects it. Anything less than
>> that is *at least* negligence, and possibly willful negligence.
> 
> Mmh, sounds like a presumption of guilt. I wouldn't go so far on this
> way. The metaphor of terrorists in the bedroom applies up to a point.
> While it's evident that you can not be unaware of people living in your
> home, modern malware is made to be silent to the infected computer, so
> it's a hidden menace and not so evident.

Presumption of innocence doesn't apply when it comes to breaking of terms 
of service. If an ISP wants to treat customers as guilty unless proven 
innocent, the market will decide whether that's acceptable behaviour.

As for criminal charges against people sending spam, it's not presumption 
of guilt. The prosecutor still needs to prove you were sending spam. But 
if spam is coming from your machine, that's prima facie ("in the face of 
it") evidence that you are sending spam, or at least, that you were aware 
of it and did nothing to stop it. In the same way that if you are found 
standing over a corpse who has been stabbed to death, the murder weapon 
in your hand, blood to your elbows, that's prima facie evidence that you 
stabbed the victim. You still have the opportunity to refute the 
evidence, say by arguing that the blood is on your arms (but not 
splattered all over your face and clothes) because you tried to save the 
victim's life, and you had just picked up the knife.

The burden of reasonable efforts to avoid sending spam isn't high. Are 
you using a platform which is resistant to malware (Mac or Linux, say)? 
If you are using a platform prone to malware, do you have at least one 
each of "industry practice" anti-virus and anti-spyware programs? Do you 
run them regularly? Are they regularly updated? Do you have a firewall 
enabled, blocking the usual ports? Are you blocking outgoing port 25? Do 
you avoid installing random software and games (including Flash-based 
games) from untrusted web sites? If your computer starts playing up, with 
unexpected slow-downs, popups, crashes and so forth, do you take steps to 
have it serviced?

If you answer No to more than one of the above, then you should be taking 
extra efforts to ensure you're not sending spam, and failure to do so is 
negligent. If you can answer Yes to all of the above, and nevertheless 
have been infected, then you have done pretty much everything the random 
non-expert computer user should be reasonably expected to do.



> You are depicting a situation where the owner is perfectly aware of
> whats happening on his machine, but this is not always the case. I agree
> that ignorance is not an excuse but I wouldn't use the harsh manners at
> first.

"At first"???

Viruses and malware have existed on computers for thirty years, if not 
longer! Spam has been a huge problem for a decade or more. How many more 
warnings do people need before they will do something about the spambots 
on their computers?

We don't let people play load music at 3am disturbing the neighbours. 
Regardless of whether they were aware of what they were doing or not, we 
make them turn their stereo down, and if they don't, they can be charged 
with disturbing the peace. Why should sending out millions of spams be 
treated more lightly? At the moment, the only incentive people have to 
remove spambots from their computer is if it causes performance problems 
or extra ISP charges. It's time to hold computer users responsible for 
what their computer does.



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


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:43 pm, "Jan Kaliszewski"  wrote:
> 03-09-2009 o 00:55:10 Bob van der Poel  wrote:
>
>
>
> >> For a one-liner:
>
> >>    x[slice(*map(int, x[1:-1].split(':')))]
>
> > Thanks.
>
> > Almost works :)
>
> > For s="[2]" and s="[1:2]" it's fine. But, if I have
>
> > s = "[:2]" then I get:
>
>  x[slice(*[int(i) for i in s.strip("[]").split(":")])]
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ValueError: invalid literal for int() with base 10: ''
>
> > Similar problem with  [2:].
>
> > Ideas?
>
>      x = [1,4,3,5,4,6,5,7]
>      s = '[3:6]'
>
>      x[slice(*((int(i) if i else None)
>                for i in s.strip("[]").split(":")))]
>

Thanks. I think this will work fine. If I paste the above in a python
shell it's perfect. And if I paste it into my code it errors out ...
so I have to look a bit more. Always the problem with one-liners if
figuring out where the error is. I think it's just a naming thing ...
I'm sure I'll get it soon. I'll shout if I find more problems.

Best,

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


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel
On Sep 2, 4:16 pm, "Rhodri James"  wrote:
> On Wed, 02 Sep 2009 23:57:48 +0100, Bob van der Poel   
> wrote:
>
>
>
> >> Of course, you could also do something like this:
>
> >>      eval('x' + s)
> >> or
> >>      eval(str(x) + s)
>
> > Yes, I have user inputed 's'. So, if I can't get the generalized list
> > version from Robert working I'll have to use this. Speed is not a big
> > deal in this. As to malicious input, I could pretty easily check to
> > see that all the values are integers.
>
> If you've done that check, you've parsed the input so you might as well
> use the values you've derived rather than waste time and add risk by
> using eval().

Not sure exactly what you mean here? Checking the values is (fairly)
trivial. Probably split on ":" and check the resulting list, etc.

But, translating 1, 2 or 3 ints into a valid splice isn't quit that
easy? I could figure each value, and convert them to either int or
None (key is the None! From my previous try '' doesn't work!)

But, I still need three possible lines:

 if len(i) == 1:
x=x[i(0)]
  else if len(i) == 2:
x=x[i(0):i(1)]
   


But, I'm wondering if just doing a split() on the index list and
seeing if they are all ints or None isn't safe?


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


Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski

03-09-2009 o 00:55:10 Bob van der Poel  wrote:


For a one-liner:

   x[slice(*map(int, x[1:-1].split(':')))]


Thanks.

Almost works :)

For s="[2]" and s="[1:2]" it's fine. But, if I have

s = "[:2]" then I get:


x[slice(*[int(i) for i in s.strip("[]").split(":")])]

Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: ''

Similar problem with  [2:].

Ideas?


x = [1,4,3,5,4,6,5,7]
s = '[3:6]'

x[slice(*((int(i) if i else None)
  for i in s.strip("[]").split(":")))]

Cheers,
*j

--
Jan Kaliszewski (zuo) 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread Steven D'Aprano
On Wed, 02 Sep 2009 15:22:08 -0400, Terry Reedy wrote:

> Steven D'Aprano wrote:
>> On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote:
> 
>>> The rationale I have seen is this: if one leaves the wi-fi router open
>>> and illegal activity is conducted thru it, and there is no residual
>>> evidence on the hard drives of on-premises machines, then one may
>>> claim that it must have been someone else. On the other hand, if the
>>> router is properly closed, then it will be hard to argue that someone
>>> hacked trough it.
>>>
>>> There are, of course, flaws in this argument, and I take it as
>>> evidence of intention to conduct illegal activity, whether properly so
>>> or not.
>> 
>> So, if somebody leaves their car unlocked, is that evidence that they
>> were intending to rob a bank and wanted a fast getaway car?
>> 
>> If you leave your window open on a hot summer's night, is that evidence
>> that you're planning to fake a burglary?
>> 
>> If you leave your knife and fork unattended in a restaurant while you
>> go to the toilet, is that evidence that you intended to stab the waiter
>> and blame somebody else?
>> 
>> 
>> I assume you would answer No to each of these. So why the harsher
>> standard when it comes to computer crime?
> 
> Your cases are not at all analogous or parallel.

I disagree, obviously, otherwise I wouldn't have posted them.


> First, I did not say 'computer crime'. I said 'illegal activity, whether
> properly so [illegal] or not'. The latter is much broader, sometimes
> including the viewing of non-sexual pictures of undraped young adults.

You're talking about *crimes* ("illegal activity") committed via 
*computer*. Having an open wi-fi connection isn't going to be an alibi if 
you're caught with a scrapbook full of such photos, or if you have a meth 
lab in your bathroom.


> Second, I was talking about advocacy of 'open windows' by someone who
> knows how to close and lock a window.

If you're known to advocate "open windows" *for the express purpose of 
being an alibi*, then some people might (improperly, in my opinion) draw 
the conclusion you do. But I read your argument as being that having an 
open wi-fi connection was prima facie evidence of intent to commit crime 
regardless of whether you were a public advocate or not. Perhaps I 
misunderstood.

The distinction you seem to be making between people who known how to 
lock windows (lock their wi-fi network) and those who don't is 
irrelevant. The question we're debating is whether or not the deliberate 
decision to leave your windows (your wi-fi network) open is prima facie 
evidence of intention to commit crime. You say it is. I say that such a 
conclusion would be seen as ridiculous if applied to common everyday 
situations, and wonder what's so special about wi-fi that it is treated 
more harshly than analogous situations involving non-computer crimes?

The only other example I can think of is that now that mobile phones are 
so ubiquitous, and since they can be tracked so easily by police, leaving 
your mobile phone at home can be treated as prima facie evidence that you 
were committing a crime during the period you were untrackable. So far 
this outrageous conclusion has only been applied to "Mafia bosses" 
accused of murder (as far as I know), but how long will it be before 
people are arguing that if you've got nothing to hide, why would you 
object to being tracked by police 24/7?



> So the analogy would be someone who advocates leaving your living room
> window open so that if the Feds come knocking on your door about
> 'illegal' materials being sent to or from your home, you can claim that
> the within-house sender or receiver must have been a stranger that came
> in through the window. H.

So it's the *advocacy* (for the purposes of alibi) which is evidence of 
wrong-doing? Not the open windows themselves?

What do you make of those who advocate for open windows but don't have 
illegal materials in the house? Or those who have open windows, and 
illegal materials, but have never spoken about the use of open windows as 
an alibi?

How would your answers change if we lived in a world where strangers did 
routinely drop illegal materials into people's houses (or at least to 
their front door), and police frequently treated the recipient as a de 
facto criminal?

We live in such a world:

http://en.wikipedia.org/wiki/Berwyn_Heights,_Maryland_mayor's_residence_drug_raid

This sort of episode -- a botched, probably illegal, paramilitary raid by 
police against innocents -- is only unusual because the victim was white 
and the mayor of the town.


There's an interesting parallel here. Many patent lawyers recommend that 
you never search the patent records for technology before attempting to 
market something you've invented, because if *don't* search, and 
infringe, you are liable to damages, but if you *do* search, fail to find 
anything, and then nevertheless infringe inadvertently, you are deemed to 
have willfu

Re: Creating slice notation from string

2009-09-02 Thread Robert Kern

On 2009-09-02 17:55 PM, Bob van der Poel wrote:



For a one-liner:

x[slice(*map(int, x[1:-1].split(':')))]


Thanks.

Almost works :)

For s="[2]" and s="[1:2]" it's fine. But, if I have

s = "[:2]" then I get:


x[slice(*[int(i) for i in s.strip("[]").split(":")])]

Traceback (most recent call last):
   File "", line 1, in
ValueError: invalid literal for int() with base 10: ''

Similar problem with  [2:].

Ideas?


Expanding out to a couple of lines now:

slice_args = []
for i in s.strip("[]").split(':'):
if i.strip() == '':
slice_args.append(None)
else:
slice_args.append(int(i))

y = x[slice(*slice_args)]


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Creating slice notation from string

2009-09-02 Thread Rhodri James
On Wed, 02 Sep 2009 23:57:48 +0100, Bob van der Poel   
wrote:





Of course, you could also do something like this:

     eval('x' + s)
or
     eval(str(x) + s)



Yes, I have user inputed 's'. So, if I can't get the generalized list
version from Robert working I'll have to use this. Speed is not a big
deal in this. As to malicious input, I could pretty easily check to
see that all the values are integers.


If you've done that check, you've parsed the input so you might as well
use the values you've derived rather than waste time and add risk by
using eval().


--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel

> Of course, you could also do something like this:
>
>      eval('x' + s)
> or
>      eval(str(x) + s)
>

Yes, I have user inputed 's'. So, if I can't get the generalized list
version from Robert working I'll have to use this. Speed is not a big
deal in this. As to malicious input, I could pretty easily check to
see that all the values are integers.

I tried something like this earlier but could not get it to work.
Didn't think of converting my x[] to a string. Makes sense.

Thanks.

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


Re: Creating slice notation from string

2009-09-02 Thread Bob van der Poel

> For a one-liner:
>
>    x[slice(*map(int, x[1:-1].split(':')))]

Thanks.

Almost works :)

For s="[2]" and s="[1:2]" it's fine. But, if I have

s = "[:2]" then I get:

>>> x[slice(*[int(i) for i in s.strip("[]").split(":")])]
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: ''

Similar problem with  [2:].

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


Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski

Erratum:


 eval(str(x) + s)

-- but it's worse: less secure (e.g. if s could be user-typed) and most
probably much more time-consuming (especially the latter).


There should be *repr* instead of *str*.

*j

--
Jan Kaliszewski (zuo) 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating slice notation from string

2009-09-02 Thread Jan Kaliszewski

03-09-2009 o 00:11:17 MRAB  wrote:


bvdp wrote:

I'm trying to NOT create a parser to do this  and I'm sure that
it's easy if I could only see the light!
 Is it possible to take an arbitrary string in the form "1:2", "1",
":-1", etc. and feed it to slice() and then apply the result to an
existing list?
 For example, I have a normal python list. Let's say that x = [1,2,3,4]
and I have a string, call it "s', in the format "[2:3]". All I need to
do is to apply "s" to "x" just like python would do.
 I can, of course, convert "x" to a list with split(), convert the 2
and 3 to ints, and then do something like: x[a:b] ... but I'd like
something more general. I think the answer is in slice() but I'm lost.


 >>> x = [1,2,3,4]
 >>> s = "[2:3]"
 >>> # Using map.
 >>> x[slice(*map(int, s.strip("[]").split(":")))]
[3]
 >>> # Using a list comprehension.
 >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])]
[3]


Of course, you could also do something like this:

eval('x' + s)
or
eval(str(x) + s)

-- but it's worse: less secure (e.g. if s could be user-typed) and most
probably much more time-consuming (especially the latter).

Cheers,
*j

--
Jan Kaliszewski (zuo) 
--
http://mail.python.org/mailman/listinfo/python-list


recursive decorator

2009-09-02 Thread Ethan Furman

Greetings, List!

The recent thread about a recursive function in a class definition led 
me back to a post about bindfunc from Arnaud, and from there I found 
Michele Simionato's decorator module (many thanks! :-), and from there I 
began to wonder...


from decorator import decorator

@decorator
def recursive1(func, *args, **kwargs):
return func(func, *args, **kwargs)

@recursive1
def factorial1(recurse, n):
if n < 2:
return 1
return n * recurse(n-1)

factorial(4)
TypeError: factorial1() takes exactly 2 arguments (1 given)

Now it's *entirely* possible that I am missing something easy here, but 
at any rate I was thinking about the above error, about how one of the 
design goals behind the decorator module was to enable introspection to 
give accurate information about usage, etc, and how if the signature was 
*exactly* preserved then we have this pesky and seemingly out of place 
variable, not mention we can't 'just use it' in the code.


So I set out to create a signature-modifying decorator that would lose 
that first parameter from the wrapper, while keeping the rest of the 
signature intact.  This is what I was able to come up with:


def recursive(func):
"""
recursive is a signature modifying decorator.
Specifially, it removes the first argument, so
that calls to the decorated function act as
if it does not exist.
"""
argspec = inspect.getargspec(func)
first_arg = argspec[0][0]
newargspec = (argspec[0][1:], ) + argspec[1:]
fi = decorator.FunctionMaker(func)
old_sig = inspect.formatargspec( \
formatvalue=lambda val: "", *argspec)[1:-1]
new_sig = inspect.formatargspec( \
formatvalue=lambda val: "", *newargspec)[1:-1]
new_def = '%s(%s)' % (fi.name, new_sig)
body = 'return func(%s)' % old_sig
def wrapper(*newargspec):
return func(wrapper, *newargspec)
evaldict = {'func':func, first_arg:wrapper}
return fi.create(new_def, body, evaldict, \
doc=fi.doc, module=fi.module)


I cannot remember whose sig it is at the moment (maybe Aahz'?), but it 
says something about debugging being twice as hard as coding, so if you 
code as cleverly as you can you are, by definition, not smart enough to 
debug it!  And considering the amount of trial-and-error that went into 
this (along with some thought and reasoning about scopes !-), I am 
hoping to get some code review.


And if there's an easier way to do this, I wouldn't mind knowing about 
that, too!


Many thanks.

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


Re: Creating slice notation from string

2009-09-02 Thread Robert Kern

On 2009-09-02 16:55 PM, bvdp wrote:

I'm trying to NOT create a parser to do this  and I'm sure that
it's easy if I could only see the light!

Is it possible to take an arbitrary string in the form "1:2", "1",
":-1", etc. and feed it to slice() and then apply the result to an
existing list?

For example, I have a normal python list. Let's say that x = [1,2,3,4]
and I have a string, call it "s', in the format "[2:3]". All I need to
do is to apply "s" to "x" just like python would do.

I can, of course, convert "x" to a list with split(), convert the 2
and 3 to ints, and then do something like: x[a:b] ... but I'd like
something more general. I think the answer is in slice() but I'm lost.


For a one-liner:

  x[slice(*map(int, x[1:-1].split(':')))]

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Creating slice notation from string

2009-09-02 Thread MRAB

bvdp wrote:

I'm trying to NOT create a parser to do this  and I'm sure that
it's easy if I could only see the light!

Is it possible to take an arbitrary string in the form "1:2", "1",
":-1", etc. and feed it to slice() and then apply the result to an
existing list?

For example, I have a normal python list. Let's say that x = [1,2,3,4]
and I have a string, call it "s', in the format "[2:3]". All I need to
do is to apply "s" to "x" just like python would do.

I can, of course, convert "x" to a list with split(), convert the 2
and 3 to ints, and then do something like: x[a:b] ... but I'd like
something more general. I think the answer is in slice() but I'm lost.


>>> x = [1,2,3,4]
>>> s = "[2:3]"
>>> # Using map.
>>> x[slice(*map(int, s.strip("[]").split(":")))]
[3]
>>> # Using a list comprehension.
>>> x[slice(*[int(i) for i in s.strip("[]").split(":")])]
[3]

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


Creating slice notation from string

2009-09-02 Thread bvdp
I'm trying to NOT create a parser to do this  and I'm sure that
it's easy if I could only see the light!

Is it possible to take an arbitrary string in the form "1:2", "1",
":-1", etc. and feed it to slice() and then apply the result to an
existing list?

For example, I have a normal python list. Let's say that x = [1,2,3,4]
and I have a string, call it "s', in the format "[2:3]". All I need to
do is to apply "s" to "x" just like python would do.

I can, of course, convert "x" to a list with split(), convert the 2
and 3 to ints, and then do something like: x[a:b] ... but I'd like
something more general. I think the answer is in slice() but I'm lost.

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


Re: website feedback to where?

2009-09-02 Thread Diez B. Roggisch

MRAB schrieb:

Diez B. Roggisch wrote:

rogerdpack schrieb:

On Sep 2, 12:30 pm, Terry Reedy  wrote:

rogerdpack wrote:

on this page
http://docs.python.org/3.1/tutorial/introduction.html
some of the "text" examples are [incorrectly] color formatted.

I did not see any problems with my browser (FF3.5), so please be more
specific.


search for "This is a rather long string containing"

I suppose this is more of a documentation bug...


I don't see any wrong formatting.


I see what the OP means.

The blocks with a green background mostly contain code with syntax
colouring, but a couple of them show what's printed when the code is
run, _also_ with syntax colouring.

I've copied the text below, indicating the coloured words with
underscores:

This _is_ a rather long string containing
several lines of text just _as_ you would do _in_ C.
Note that whitespace at the beginning of the line _is_ significant.


Ah. Now I see - but *barely*, which might be a question of 
text-rendering and browser-defaults.


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


Re: website feedback to where?

2009-09-02 Thread MRAB

Diez B. Roggisch wrote:

rogerdpack schrieb:

On Sep 2, 12:30 pm, Terry Reedy  wrote:

rogerdpack wrote:

on this page
http://docs.python.org/3.1/tutorial/introduction.html
some of the "text" examples are [incorrectly] color formatted.

I did not see any problems with my browser (FF3.5), so please be more
specific.


search for "This is a rather long string containing"

I suppose this is more of a documentation bug...


I don't see any wrong formatting.


I see what the OP means.

The blocks with a green background mostly contain code with syntax
colouring, but a couple of them show what's printed when the code is
run, _also_ with syntax colouring.

I've copied the text below, indicating the coloured words with
underscores:

This _is_ a rather long string containing
several lines of text just _as_ you would do _in_ C.
Note that whitespace at the beginning of the line _is_ significant.
--
http://mail.python.org/mailman/listinfo/python-list


Re: website feedback to where?

2009-09-02 Thread Diez B. Roggisch

rogerdpack schrieb:

On Sep 2, 12:30 pm, Terry Reedy  wrote:

rogerdpack wrote:

on this page
http://docs.python.org/3.1/tutorial/introduction.html
some of the "text" examples are [incorrectly] color formatted.

I did not see any problems with my browser (FF3.5), so please be more
specific.


search for "This is a rather long string containing"

I suppose this is more of a documentation bug...


I don't see any wrong formatting.

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


Re: pickling question

2009-09-02 Thread Gary Robinson
Many thanks for the responses I've received here to my question (below).

After reading the responses, I understand what the problem is much better. In 
addition to the solutions mentioned in the responses, now that I understand the 
problem I'll offer up my own solution. The following is an executable script 
named pick1.py:

===
import pickle

class A(object):

def __init__(self, x):
self.x = x

def writePickle():
import pick1
a5 = pick1.A(5)
f = open('pick1.pickle', 'wb')
pickle.dump(a5, f)
f.close()

writePickle() # The dumped pickle can be read by any other script.


That is, we need to do the pickling in a context where the module name for the 
class is "pick1" rather than "__main__". The example above allows us to do that 
without changing __name__ or doing anything else of that nature.

Thanks again!
Gary



> When you define a class in a script, and then pickle instances of 
> that class in the same script and store them to disk, you can't load 
> that pickle in another script. At least not the straightforward way 
> [pickle.load(file('somefile.pickle'))]. If you try it, you get an 
> AttributeError during the unpickling operation.
> 
> There is no problem, of course, if the class is defined in a module 
> which is imported by the pickling script. 
> pickle.load(file('somefile.pickle')) then works.
> 
> Rather than provide specific examples here, there's a blog post from 
> 2005 that discusses this issue in depth and presents the problem very 
> well: http://stefaanlippens.net/pickleproblem. (I tested in Python 
> 2.6 yesterday and the same issue persists.)
> 
> Questions:
> 
> 1) Does this have to be the case, or is it a design problem with 
> pickles that should be remedied?
> 
> 2) Is there an easier way around it than moving the class definition 
> to a separate module? The blog post I point to above suggests putting 
> "__module__ = os.path.splitext(os.path.basename(__file__))[0]" into 
> the class definiton, but that's not working in my testing because 
> when I do that, the pickling operation fails. Is there something else 
> that can be done?
> 
> This is obviously not a huge problem. Substantial classes should 
> usually be defined in a separate module anyway. But sometimes it 
> makes sense for a script to define a really simple, small class to 
> hold some data, and needing to create a separate module just to 
> contain such a class can be a little annoying.
-- 

Gary Robinson
CTO
Emergent Music, LLC
personal email: gary...@me.com
work email: grobin...@flyfi.com
Company: http://www.flyfi.com
Blog:http://www.garyrobinson.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem w/ mysqldump

2009-09-02 Thread Victor Subervi
I tried running it like you said, got this error:
'mysqldump' is not a recognized internal or external command.
If I could just figure out in what file the data were stored, I could copy
it and try it in another computer. Any ideas?
TIA,
V

On Wed, Sep 2, 2009 at 2:10 PM, Rami Chowdhury wrote:

>  I tried running the mysqldump command
>> from the python prompt
>>
>
> I think you were being asked to try running it from the command prompt
> (cmd.exe) -- it won't work from the Python prompt, of course.
>
>
> On Wed, 02 Sep 2009 10:50:55 -0700, Victor Subervi <
> victorsube...@gmail.com> wrote:
>
> I am running this on Windoze. I do not use the mysql db without python. I'm
>> just building something for a client. I tried running the mysqldump
>> command
>> from the python prompt. Didn't know I could do that :) It tells me
>> "mysqldump is not defined" :(
>> V
>>
>> On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz > >wrote:
>>
>> On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote:
>>> >
>>> > Obviously I'm sure. It created the file. But the file was blank. How
>>> can
>>> I
>>> > do a mysqldump in mysql itself?
>>> >
>>>
>>> As I said, I only got a blank file when the actual command itself
>>> failed.  How do you dump the MySQL database itself without using Python?
>>> Just run the 'mysqldump' command from the prompt.  Is that what you are
>>> asking?
>>>
>>> Are you running this on Windows?  What OS?  You do have the 'mysqldump'
>>> command available from the shell prompt and in your path, right?
>>>
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>
>
> --
> Rami Chowdhury
> "Never attribute to malice that which can be attributed to stupidity" --
> Hanlon's Razor
> 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: website feedback to where?

2009-09-02 Thread rogerdpack
On Sep 2, 12:30 pm, Terry Reedy  wrote:
> rogerdpack wrote:
> > on this page
>
> >http://docs.python.org/3.1/tutorial/introduction.html
>
> > some of the "text" examples are [incorrectly] color formatted.
>
> I did not see any problems with my browser (FF3.5), so please be more
> specific.

search for "This is a rather long string containing"

I suppose this is more of a documentation bug...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple addition to random module - Student's t

2009-09-02 Thread Robert Kern

On 2009-09-02 14:15 PM, Raymond Hettinger wrote:

On Sep 2, 6:51 am, Thomas Philips  wrote:

While the random module allows one to generate randome numbers with a
variety of distributions, some useful distributions are omitted - the
Student's t being among them.


I'm curious to hear what your use cases are.

My understanding is that t-distribution is an estimation tool
used with small samples of a population where the variance or
standard deviation is unknown.

So, when do you ever need to generate random variables with
this distribution?  ISTM that this is akin to wanting
a generator for a Kolmogorov distribution -- usually the
distribution is used to test empirical data, not to generate it.


In more complicated models, estimates of one parameter need to be propagated 
through the model, particularly if you are looking at sensitivity to parameters. 
Student's t describes the variation of an estimate of a mean of a sample from a 
Gaussian distribution. If I were modeling a processing wherein someone makes an 
estimate of a mean and then acts on that estimate, I would want to generate 
random t variates to feed that model.



I think most of the existing generators were chosen because they
are useful in simulation programs.  AFAICT, the Student's t-
distribution
doesn't fall into that category (usually, you know the population
standard deviation when you're the one generating data).


Student's t distribution is also used as a sort of generic fat-tailed 
distribution in some models and is not tied to the "estimate of a mean" description.



ISTM, there ought to be a statistics module that can calculate
cumulative distribution functions for a variety of distributions.
This would be far more helpful than creating more generators.


Yes, scipy.stats.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: exec globals and locals

2009-09-02 Thread Quentin Lampin
2009/9/2 Chris Rebert 

> On Wed, Sep 2, 2009 at 1:13 PM, Quentin Lampin
> wrote:
> > 2009/9/2 Chris Rebert 
> >>
> >> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin >
> >> wrote:
> >> > Hi,
> >> > Being fairly new to Python, I'm trying to figure out the best way to
> use
> >> > the
> >> > exec statement and I must admit that I am a bit lost.
> >> >
> >> > Consider this case:
> >> > exec "print 'a'" in {},{}   [exp.1]
> >> > It means  that I'm (kindly) asking the interpreter to execute the code
> >> > string  "print 'a'" with empty globals and locals.
> >> > Considering that globals and locals are empty, I would expect [exp.1]
> to
> >> > raise an exception about 'print' not being known.
> >>
> >> In Python versions prior to 3.0, print is a statement (like for,
> >> while, if, etc), not a function (note how you don't need parentheses
> >> when using it); so it doesn't matter whether the built-in functions
> >> are available or not, print will still work.
> >>
> >> Cheers,
> >> Chris
> >> --
> >> http://blog.rebertia.com
> >
> > Ok, thanks for the explanation.
> > I'm really confused with print being a statement but it's seems that I
> won't
> > have to put too much effort on understanding why since 3.0 states the
> > contrary. :p
> > By the way, could you suggest me a link that explains why 3.0 changed
> this.
> > It might provide some material to understand the pros and cons of
> "function
> > statements".
>
> http://www.python.org/dev/peps/pep-3105/ (PEP 3105 -- Make print a
> function)
> http://mail.python.org/pipermail/python-dev/2005-September/056154.html
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>


Thanks a lot Chris!
Quentin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec globals and locals

2009-09-02 Thread Chris Rebert
On Wed, Sep 2, 2009 at 1:13 PM, Quentin Lampin wrote:
> 2009/9/2 Chris Rebert 
>>
>> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin
>> wrote:
>> > Hi,
>> > Being fairly new to Python, I'm trying to figure out the best way to use
>> > the
>> > exec statement and I must admit that I am a bit lost.
>> >
>> > Consider this case:
>> > exec "print 'a'" in {},{}   [exp.1]
>> > It means  that I'm (kindly) asking the interpreter to execute the code
>> > string  "print 'a'" with empty globals and locals.
>> > Considering that globals and locals are empty, I would expect [exp.1] to
>> > raise an exception about 'print' not being known.
>>
>> In Python versions prior to 3.0, print is a statement (like for,
>> while, if, etc), not a function (note how you don't need parentheses
>> when using it); so it doesn't matter whether the built-in functions
>> are available or not, print will still work.
>>
>> Cheers,
>> Chris
>> --
>> http://blog.rebertia.com
>
> Ok, thanks for the explanation.
> I'm really confused with print being a statement but it's seems that I won't
> have to put too much effort on understanding why since 3.0 states the
> contrary. :p
> By the way, could you suggest me a link that explains why 3.0 changed this.
> It might provide some material to understand the pros and cons of "function
> statements".

http://www.python.org/dev/peps/pep-3105/ (PEP 3105 -- Make print a function)
http://mail.python.org/pipermail/python-dev/2005-September/056154.html

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: website feedback to where?

2009-09-02 Thread Aahz
In article ,
rogerdpack   wrote:
>
>on this page
>
>http://docs.python.org/3.1/tutorial/introduction.html
>
>some of the "text" examples are [incorrectly] color formatted.
>
>I assume this a bug reportable to bugs.python.org?

Actually, for doc bugs you should follow the instructions in the docs,
see the link "Reporting bugs" at e.g.
http://docs.python.org/3.1/
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Look, it's your affair if you want to play with five people, but don't
go calling it doubles."  --John Cleese anticipates Usenet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec globals and locals

2009-09-02 Thread Quentin Lampin
2009/9/2 Chris Rebert 

> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin
> wrote:
> > Hi,
> > Being fairly new to Python, I'm trying to figure out the best way to use
> the
> > exec statement and I must admit that I am a bit lost.
> >
> > Consider this case:
> > exec "print 'a'" in {},{}   [exp.1]
> > It means  that I'm (kindly) asking the interpreter to execute the code
> > string  "print 'a'" with empty globals and locals.
> > Considering that globals and locals are empty, I would expect [exp.1] to
> > raise an exception about 'print' not being known.
>
> In Python versions prior to 3.0, print is a statement (like for,
> while, if, etc), not a function (note how you don't need parentheses
> when using it); so it doesn't matter whether the built-in functions
> are available or not, print will still work.
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>

Ok, thanks for the explanation.I'm really confused with print being a
statement but it's seems that I won't have to put too much effort on
understanding why since 3.0 states the contrary. :p
By the way, could you suggest me a link that explains why 3.0 changed this.
It might provide some material to understand the pros and cons of "function
statements".

Regards,
Quentin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec globals and locals

2009-09-02 Thread Chris Rebert
On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin wrote:
> Hi,
> Being fairly new to Python, I'm trying to figure out the best way to use the
> exec statement and I must admit that I am a bit lost.
>
> Consider this case:
> exec "print 'a'" in {},{}   [exp.1]
> It means  that I'm (kindly) asking the interpreter to execute the code
> string  "print 'a'" with empty globals and locals.
> Considering that globals and locals are empty, I would expect [exp.1] to
> raise an exception about 'print' not being known.

In Python versions prior to 3.0, print is a statement (like for,
while, if, etc), not a function (note how you don't need parentheses
when using it); so it doesn't matter whether the built-in functions
are available or not, print will still work.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread David
Il 02 Sep 2009 00:17:05 GMT, Steven D'Aprano ha scritto:

> This can be done already, without the need for an email tax. ISPs could 
> easily detect spammers, if they cared to.
> 
> There are a few things that can already be done to cut the spam problem 
> to manageable size:
> 
> (1) Why aren't ISPs blocking port 25 for home users by default? My home 
>[...]

> (2) Why aren't ISPs cutting off detected spam bots? Owners of zombied PCs 
[...]
 
> (3) ISPs who won't cut off spam bots are either incompetent or have a 
> financial incentive to do business with spammers. Therefore, responsible 
> ISPs should cut them off. If this means the email universe divides into 
> two halves, the Wild West where 999 emails out of every 1000 are spam, 
> and Civilization where only one in a thousand is spam, I'm okay with that.

I don't know ISP's internal dynamics so I can't imagine what kind of
financial incentive they have with spammers, AFAIK ISPs must sustain costs
to augment their infrastructures to face this huge amount of traffic, costs
charged on the subscribers monthly bill. At first this conduct can appear
convenient but higer fares lead to reduced competitivity on the market.
There are opposing forces that I can not interpret, so can not give an
answer for that.

> 
> As for the argument that home users who send spam are the victim, that's 
> true up to a point, but not very far. Here's an analogy: suppose that 
> terrorists sneak into your house after picking the lock -- or in the case 
> of Windows users with no firewall or anti-malware, stroll through the 
> unlocked front door -- and spend the next six months camped in your spare 
> bedroom, using your home for their base of operations while they make 
> terrorist attacks. When the FBI kicks your doors down, don't you think 
> you would be arrested and would have to prove that you couldn't be 
> reasonably expected to know they were there? If millions of spam emails 
> are coming out of your PC, that's prima facie evidence that YOU are 
> spamming. You would need to prove that you're an innocent victim who 
> couldn't *reasonably* be expected to know that your machine was hijacked 
> -- you would need to prove that the spam bot was so sophisticated that it 
> infected your PC despite the firewall, that you didn't install it 
> yourself in order to get some stupid game, that no commonly available 
> anti-malware program detects it. Anything less than that is *at least* 
> negligence, and possibly willful negligence.

Mmh, sounds like a presumption of guilt. I wouldn't go so far on this way.
The metaphor of terrorists in the bedroom applies up to a point. While it's
evident that you can not be unaware of people living in your home, modern
malware is made to be silent to the infected computer, so it's a hidden
menace and not so evident.
You are depicting a situation where the owner is perfectly aware of whats
happening on his machine, but this is not always the case. I agree that
ignorance is not an excuse but I wouldn't use the harsh manners at first.

I think that the owner of the infected computer should be warned by his ISP,
who can easily monitor the amount of traffic, and being induced to take
countermisures. If that warning is an amount of maney to pay proportional to
mail generated, I'm confident that it would be 'inducing' enough.

After that the situation can develop only in three possible ways:

1) the owner takes appropriate countermisures proving his innocence (but he
must pay the mail-tax for the period of infection!)

2) the owner takes no countermisures and pays the tax: it's very likely he
is a spammer and we can start the assault with tanks

3) the owner takes no countermisures and doesn't pay the tax: well, It's up
to you to choose the action to take towards him.

[...]

> Yes, I'd like to see the criminals, the malware authors and the spammers 
> punished, but I'd be satisfied to see them put out of business. The weak 
> link is the zombie PCs -- fix the home users' PCs, or block them, take 
> them off the Internet, and spam becomes manageable again.


you got the crux of the matter.

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


Re: Why does this group have so much spam?

2009-09-02 Thread Grant Edwards
On 2009-09-02, Emile van Sebille  wrote:
> On 9/2/2009 7:07 AM Unknown said...
>> A spam/malware merchange who can't afford/arrange other
>> internet access?  How is net access on the critical path?
>
> Mailbots (a significant source of spam IMHO) thrive on net access -- for 
> them, is there anything _more_ critical?

A mailbot which would otherwise not have network access is
going to come park itself outside my house if I leave my AP
open?

There are open APs at all sorts of libraries, coffee houses,
restaurants, auto dealers, book stores, etc, etc. I don't see
how net access is an issue for somebody who wants to send spam.

-- 
Grant Edwards   grante Yow! Now I am depressed ...
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps)

2009-09-02 Thread Raymond Hettinger

> I dont know guppy,
> but if h.load(f) raises StopIteration upon eof, as seems implied by your
> proposal, then something like the following would work.
>
> sets.extend(h.load(f) for _ in xrange(1e9))

Sounds like hpy has a weird API.  Either it should be an
iterator supporting __iter__() and next() and raising
StopIteration when it's done, or it should simply return
None to indicate an empty load.

In the first case, you would write:
   sets.extend(h.load(f))

And in the second case:
   sets.extend(iter(partial(h.load, f), None))

The first way just uses the iterator protocol in a way that
is consistent with the rest of the language.

The second way, using the two argument form of iter(),
is the standard way of creating an iterator from a
function that has a sentinel return value.

IOW, it is not normal to use StopIteration in a function
that isn't an iterator.


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


Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 2:37 pm, Mark Dickinson  wrote:
> On Sep 2, 6:15 pm, Thomas Philips  wrote:
>
> > I mis-spoke - the variance is infinite when df=2 (the variance is df/
> > (df-2),
>
> Yes:  the variance is infinite both for df=2 and df=1, and Student's t
> with df=1 doesn't even have an expectation.  I don't see why this
> would stop you from generating meaningful samples, though.
>
> > and you get the Cauchy when df=2.
>
> Are you sure about this?  All my statistics books are currently hiding
> in my mother-in-law's attic, several hundred miles away, but wikipedia
> and mathworld seem to say that df=1 gives you the Cauchy distribution.
>
> > I made the mistake because the denominator is  equivalent to the
> > square root of the sample variance of df normal observations,
>
> As I'm reading it, the denominator is the square root of the sample
> variance of *df+1* independent standard normal observations.  I agree
> that the wikipedia description is a bit confusing.
>
> It seems that there are uses for Student's t distribution with
> non-integral degrees of freedom.  The Boost library, and the R
> programming language both allow non-integral degrees of freedom.
> So (as Robert Kern already suggested), you could drop the test
> for integrality of df.  In fact, you could just drop the tests
> on df entirely:  df <= 0.0 will be picked up in the gammavariate
> call.
>
> --
> Mark

To tell you the truth, I have never used it with a non-integer number
of degrees of freedom, but that's not the same as saying that df
should be an integer. When df is an integer, one can interpret the t-
distribution as the ratio of a unit normal (i.e. N(0,1)) to the sample
standard deviation of a set of df+1 unit normals divided by sqrt(df
+1). However, as Robert Kern correctly observes, the distribution is
defined for all positive non-integer df, though we then lose the above
interpretation, and must think of it in abstract terms. The
distribution has infinite variance when df=2 and an undefined mean
when df<=1, but the code can still be used to generate samples.
Whether or not these samples make sense is altogether another
question, but it's easy enough to remmove the restrictions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IMGCrush (New Python image optimizing tool)

2009-09-02 Thread kiithsa...@gmail.com
On Sep 2, 8:59 pm, "kiithsa...@gmail.com" 
wrote:
> Hello people,
>
> I started to work on a small Python script to simplify mass conversion
> of images for a website I was working on.
> I eventually got interested in the script more than the site istelf,
> and it got a lot bigger, so I released it as an opensource project
>
> It's licensed under BSD and not very polished yet, but I think I
> reached a point where it's at least partially usable.
> It should run on most Unixes but it's not compatible with Windows
> (using unix shell).
>
> IMGCrush (as it's called) tries to save given image (or images, it can
> process directories of images as well)
> with the smallest possible filesize, so it works similarly to pngcrush
> and other png optimizers, with the exception that it can also save to
> GIF, JPG, PNG, and user can specify image quality loss he/she can
> tolerate.
>
> The way it's used is that the user for instance specfies that he/she
> wants an image with smallest possible size with at least 99% quality
> or the highest quality image with 50% of size of input, etc. (there
> are also other ways to measure quality/size).
> Quality isn't measured in a very "human" way now, which will hopefully
> change in future.
> IMGCrush is also quite slow at the moment, and will probably never be
> fast, but it can be a lot faster than it is now.
>
> Project is hosted at Launchpad:
> Homepage link:https://launchpad.net/icrush
> Downloads:      https://launchpad.net/icrush/+download
>
> Use at your own risk :-)
> run "imgcrush --help" for usage instructions.
>
> Criticism/ideas/whatever is welcome.
>
> -Kiith-Sa

Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6
but it might run on older python as well)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread Emile van Sebille

On 9/2/2009 7:07 AM Unknown said...

A spam/malware merchange who can't afford/arrange other
internet access?  How is net access on the critical path?


Mailbots (a significant source of spam IMHO) thrive on net access -- for 
them, is there anything _more_ critical?


Emile



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


Re: notes

2009-09-02 Thread kiithsa...@gmail.com
On Sep 2, 9:27 pm, "kiithsa...@gmail.com" 
wrote:
> Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6
> but it might run on older python as well)

Sorry, got confused by Google Groups interface and posted a new topic
instead of just replying
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread r
On Sep 2, 4:22 am, MRAB  wrote:

> The preferred option these days is to slow down net access of the
> offenders, not cut them off completely. I'm not sure how many ISPs
> actually do that yet.

That seems to be the case with ISP and "good" users also in the form
of quotas ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


notes

2009-09-02 Thread kiithsa...@gmail.com
Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6
but it might run on older python as well)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread r
On Sep 2, 12:33 pm, Steven D'Aprano  wrote:

(snip)

> I learned one thing though. System Restore sounds like a good idea, but
> in my experience it's only good for restoring malware when you reboot.

System restore is a joke! and a complete waste of HD space even if you
have TB's to spare! Actually i can do with almost very piece of built-
in software on this stinking windows platform. Microsoft's whole
system of security is a joke as evidenced by Stevens experience.
Windows ships with back doors wide open just begging for an infection!


-
BS Packaged software
-
Windows Mail -> virus magnet/backdoor use gmail
Internet Exploder -> virus magnet/frontdoor, use Chrome|Mozilla
Windows Calendar -> only slightly useful
Windows Media Player -> complete bloatware
Windows Media Center -> bloatware built on bloatware
Windows sync center -> what a joke!
Windows Movie Maker -> yea for kids and housewife's!
Windows Photo Galley -> only slightly useful.
Windows Update -> well i don't like hosting viruses so...?
My meeting place -> worthless junk
Windows Games -> *puke*


*Dangerous and annoying services and settings from the factory*

-Remote Resitry -> completly moronic!
-Remote assistance
-hide known filetypes -> Donde es "destroy useless bloatware button"
-UAC -> what a nagging POS!
-Menus are hidden by default in explorer
-Ready Boost -> *puke*
-Internet Connection Sharing
-NET Tcp port sharing
-Secondary Logon
-Terminal Services
-Windows BackUp
-Windows remote managment
-Routing and Remote Access
-All Peer * services
-all Windows Media center/player network services


--
Accessories crap!
--
Calculator -> POS, use the python shell instead
CMD -> What else ya gonna use?
Notepad -> What a useless POS, only one undo! COME ON!
Paint -> are you jokeing M$ -- Glorified etch-a-sketch!
sidebar -> Yes i love wasting memory just to see an analog clock!
sound recorder -> very slightly useful, needs more functionality
WordPad -> no thanks, OO will suffice!

charactor map -> only slightly useful
defragmenter -> too slow
disk cleanup -> obviously made for morons!
Internet Explorer(no add-ons) -> polish a turd, still a turd!

Windows Experience index -> useless bloat
Computer Management -> horrible UI
Task Manager -> The worst UI i have ever used! (Vista)
Windows Help -> maybe for complete morons!

---
misc bloat
---
Desktop backgrounds -> crap! use a solid color (black is my fav!)
Sceen savers -> crap! ohh...look at the pretty colors!
Windows Transparency -> crap! vanity run muck!
Themes -> crap! adolescent accessorizing!

Sadly none of these built in memory robbing hard space eating annoying
POS bloatwares can be uninstalled. The only advancement (if you could
call it that) with Vista is the search from start menu is much better
than the previous "puppy dog" search of XP. Short of that Vista is
just lipstick on a pig!  Thanks M$ for bending us over yet again!

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


Re: Simple addition to random module - Student's t

2009-09-02 Thread Raymond Hettinger

> To get this into core Python, you'd usually submit a feature request
> athttp://bugs.python.org.

If you do submit a patch, please assign it to me.
I've been the primary maintainer for that module
for several years.


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


Re: Why does this group have so much spam?

2009-09-02 Thread Terry Reedy

Steven D'Aprano wrote:

On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote:



The rationale I have seen is this: if one leaves the wi-fi router open
and illegal activity is conducted thru it, and there is no residual
evidence on the hard drives of on-premises machines, then one may claim
that it must have been someone else. On the other hand, if the router is
properly closed, then it will be hard to argue that someone hacked
trough it.

There are, of course, flaws in this argument, and I take it as evidence
of intention to conduct illegal activity, whether properly so or not.


So, if somebody leaves their car unlocked, is that evidence that they 
were intending to rob a bank and wanted a fast getaway car?


If you leave your window open on a hot summer's night, is that evidence 
that you're planning to fake a burglary?


If you leave your knife and fork unattended in a restaurant while you go 
to the toilet, is that evidence that you intended to stab the waiter and 
blame somebody else?



I assume you would answer No to each of these. So why the harsher 
standard when it comes to computer crime?


Your cases are not at all analogous or parallel.

First, I did not say 'computer crime'. I said 'illegal activity, whether 
properly so [illegal] or not'. The latter is much broader, sometimes 
including the viewing of non-sexual pictures of undraped young adults.


Second, I was talking about advocacy of 'open windows' by someone who 
knows how to close and lock a window.


So the analogy would be someone who advocates leaving your living room 
window open so that if the Feds come knocking on your door about 
'illegal' materials being sent to or from your home, you can claim that 
the within-house sender or receiver must have been a stranger that came 
in through the window. H.


[Of course, with unlockable street-side mailboxes, a stranger would not 
need an open window to do such.]


Terry Jan Reedy

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


Re: Simple addition to random module - Student's t

2009-09-02 Thread Raymond Hettinger
On Sep 2, 6:51 am, Thomas Philips  wrote:
> While the random module allows one to generate randome numbers with a
> variety of distributions, some useful distributions are omitted - the
> Student's t being among them.

I'm curious to hear what your use cases are.

My understanding is that t-distribution is an estimation tool
used with small samples of a population where the variance or
standard deviation is unknown.

So, when do you ever need to generate random variables with
this distribution?  ISTM that this is akin to wanting
a generator for a Kolmogorov distribution -- usually the
distribution is used to test empirical data, not to generate it.

I think most of the existing generators were chosen because they
are useful in simulation programs.  AFAICT, the Student's t-
distribution
doesn't fall into that category (usually, you know the population
standard deviation when you're the one generating data).

ISTM, there ought to be a statistics module that can calculate
cumulative distribution functions for a variety of distributions.
This would be far more helpful than creating more generators.


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


Re: Entry Level Python Jobs

2009-09-02 Thread Adam
On Sep 2, 12:52 pm, JonathanB  wrote:
>  Any other tips?

I'm probably going to come off as very old school, but give yourself a
good and thorough education in data structures and algorithms. You
might never be called on to actually code a quick sort, merge sort,
heap sort, doubly-linked list or trie, but knowing what they are and
why they are important will fundamentally shape how you approach all
software problem solving.

There are a lot of good data structures and algorithms books that use
C, so that'd be a good approach to also adding a very important
language to your toolbelt.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why does this group have so much spam?

2009-09-02 Thread David
Il Wed, 02 Sep 2009 10:22:50 +0100, MRAB ha scritto:

> The preferred option these days is to slow down net access of the
> offenders, not cut them off completely. I'm not sure how many ISPs
> actually do that yet.

If they do, it doesn't look like it's working that much.

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


IMGCrush (New Python image optimizing tool)

2009-09-02 Thread kiithsa...@gmail.com
Hello people,

I started to work on a small Python script to simplify mass conversion
of images for a website I was working on.
I eventually got interested in the script more than the site istelf,
and it got a lot bigger, so I released it as an opensource project

It's licensed under BSD and not very polished yet, but I think I
reached a point where it's at least partially usable.
It should run on most Unixes but it's not compatible with Windows
(using unix shell).

IMGCrush (as it's called) tries to save given image (or images, it can
process directories of images as well)
with the smallest possible filesize, so it works similarly to pngcrush
and other png optimizers, with the exception that it can also save to
GIF, JPG, PNG, and user can specify image quality loss he/she can
tolerate.

The way it's used is that the user for instance specfies that he/she
wants an image with smallest possible size with at least 99% quality
or the highest quality image with 50% of size of input, etc. (there
are also other ways to measure quality/size).
Quality isn't measured in a very "human" way now, which will hopefully
change in future.
IMGCrush is also quite slow at the moment, and will probably never be
fast, but it can be a lot faster than it is now.

Project is hosted at Launchpad:
Homepage link: https://launchpad.net/icrush
Downloads:   https://launchpad.net/icrush/+download

Use at your own risk :-)
run "imgcrush --help" for usage instructions.

Criticism/ideas/whatever is welcome.

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


Re: evolution [was Re: An assessment of the Unicode standard]

2009-09-02 Thread Nigel Rantor

r wrote:

I'd like to present a bug report to evolution, obviously the garbage
collector is malfunctioning.


I think most people think that when they read the drivel that you generate.

I'm done with your threads and posts.

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


Re: pickle error - 'module' object has no attribute '_reconstruct'

2009-09-02 Thread Skip Montanaro
Skip Montanaro  pobox.com> writes:

> 
> Saw a new-to-me error today when trying to unpickle a moderately large
> object (about 500k):
> 
> AttributeError: 'module' object has no attribute '_reconstruct'

I believe I have it figured out.  Most of the pickled data consists of
numpy arrays.  It appears I picked up an ancient version of numpy when
I got the failure.

S



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


pickle error - 'module' object has no attribute '_reconstruct'

2009-09-02 Thread Skip Montanaro
Saw a new-to-me error today when trying to unpickle a moderately large
object (about 500k):

AttributeError: 'module' object has no attribute '_reconstruct'

Google turned up nothing as far as I could tell, "_reconstruct"
doesn't appear in the docs and pickletools.dis() was happy to 
disassemble the pickle.  This was with Python 2.4.  Any ideas about
the cause of this error?

Thx,

Skip Montanaro


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


Re: Simple addition to random module - Student's t

2009-09-02 Thread Mark Dickinson
On Sep 2, 6:15 pm, Thomas Philips  wrote:
> I mis-spoke - the variance is infinite when df=2 (the variance is df/
> (df-2),

Yes:  the variance is infinite both for df=2 and df=1, and Student's t
with df=1 doesn't even have an expectation.  I don't see why this
would stop you from generating meaningful samples, though.

> and you get the Cauchy when df=2.

Are you sure about this?  All my statistics books are currently hiding
in my mother-in-law's attic, several hundred miles away, but wikipedia
and mathworld seem to say that df=1 gives you the Cauchy distribution.

> I made the mistake because the denominator is  equivalent to the
> square root of the sample variance of df normal observations,

As I'm reading it, the denominator is the square root of the sample
variance of *df+1* independent standard normal observations.  I agree
that the wikipedia description is a bit confusing.

It seems that there are uses for Student's t distribution with
non-integral degrees of freedom.  The Boost library, and the R
programming language both allow non-integral degrees of freedom.
So (as Robert Kern already suggested), you could drop the test
for integrality of df.  In fact, you could just drop the tests
on df entirely:  df <= 0.0 will be picked up in the gammavariate
call.

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


Re: Entry Level Python Jobs

2009-09-02 Thread Paul Rubin
JonathanB  writes:
> Any other tips?

Learn some more languages besides Python.  Python is good to know but
other languages present other ways of doing things.  A skillful
programmer has a variety of techniques to draw from.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: website feedback to where?

2009-09-02 Thread Terry Reedy

rogerdpack wrote:

on this page

http://docs.python.org/3.1/tutorial/introduction.html

some of the "text" examples are [incorrectly] color formatted.


I did not see any problems with my browser (FF3.5), so please be more 
specific.



I assume this a bug reportable to bugs.python.org?


Yes, this would be a components: documentation issue.
Since you are new to this, reporting and asking here first is a  good 
idea. (The tracker already has too many invalid newbie reports.)


tjr

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


Re: Python on the Web

2009-09-02 Thread Ed Singleton
On Aug 26, 4:17 am, alex23  wrote:
> Frameworks created for the sake of creating a framework, as opposed to
> those written to meet a defined need, tend to be the worst examples of
> masturbatory coding.

Indeed, but masturbation is perfectly healthy and acceptable, and we
all do it every now and then.  It is however, much like the framework
in question, best kept private and not made public.

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


Re: Problem w/ mysqldump

2009-09-02 Thread Rami Chowdhury

I tried running the mysqldump command
from the python prompt


I think you were being asked to try running it from the command prompt  
(cmd.exe) -- it won't work from the Python prompt, of course.


On Wed, 02 Sep 2009 10:50:55 -0700, Victor Subervi  
 wrote:


I am running this on Windoze. I do not use the mysql db without python.  
I'm
just building something for a client. I tried running the mysqldump  
command

from the python prompt. Didn't know I could do that :) It tells me
"mysqldump is not defined" :(
V

On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz  
wrote:



On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote:
>
> Obviously I'm sure. It created the file. But the file was blank. How  
can

I
> do a mysqldump in mysql itself?
>

As I said, I only got a blank file when the actual command itself
failed.  How do you dump the MySQL database itself without using Python?
Just run the 'mysqldump' command from the prompt.  Is that what you are
asking?

Are you running this on Windows?  What OS?  You do have the 'mysqldump'
command available from the shell prompt and in your path, right?

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





--
Rami Chowdhury
"Never attribute to malice that which can be attributed to stupidity" --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Sep 2)

2009-09-02 Thread Gabriel Genellina
QOTW:  "I like how being very friendly means calling people after a guy who
tried to blow up the English Parliament." - Carl Banks

http://groups.google.com/group/comp.lang.python/browse_thread/thread/7a190c24d8025bb4


unichr/ord cannot handle characters outside the BMP in a narrow build:
http://groups.google.com/group/comp.lang.python/t/2fe770303f1d85ea/

How to determine if a class implements a particular interface:
http://groups.google.com/group/comp.lang.python/t/27ea61dd2aaa0fcb/

Igor Novikov provides a lovely small pure-Python extension to
manage ARGB cursors in Tkinter.
http://tkinter.unpy.net/wiki/tkXcursor

Why does `some_integer += 1` create a new integer object instead of
incrementing the current value?
http://groups.google.com/group/comp.lang.python/t/25b921e3b00ec2ae/

Iterating and mutating a list from two or more threads:
http://groups.google.com/group/comp.lang.python/t/b19381a806007f4d/

Mapping message identifiers to methods:
http://groups.google.com/group/comp.lang.python/t/8f7f1771945b4add/

A class definition doesn't introduce a new lexical scope - and that's
a Good Thing [long thread]:
http://groups.google.com/group/comp.lang.python/t/2cd187fa256744fe/

A clean way of adding directories to the module search path:
http://groups.google.com/group/comp.lang.python/t/9052cc623088bdb2/

Recipe: convert an existing module into a package or sub-package
http://groups.google.com/group/comp.lang.python/t/9919cf2a60722344/

Tools for designing professional-looking applications for Windows:
http://groups.google.com/group/comp.lang.python/t/d22dcd394ab08333/

The basics for doing Web applications in Python:
http://groups.google.com/group/comp.lang.python/t/1176ea4e6814f466/

What CAN'T be done in Python?
http://groups.google.com/group/comp.lang.python/t/a368e85aa85ab436/

Favorite debugging tools?
http://groups.google.com/group/comp.lang.python/t/1efb7b97d5d94d9b/

In 3.1, print() requires the terminal to be correctly configured with
respect to locale settings:
http://groups.google.com/group/comp.lang.python/t/8e666bb7eae9c859/

Idea: expand the for statement to accept additional, nested 'for's and
an '= if' clause:
http://groups.google.com/group/comp.lang.python/t/83b1d70457345877/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiasts":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the "Planet" sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.
http://groups.google.com/group/comp.lang.python.announce/topics

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

The Python Package Index catalogues packages.
http://www.python.org/pypi/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donations/

The Summary of Python Tracker Issues is an automatically generated
report summarizing new bugs, closed ones, and patch submissions. 

http://search.gmane.org/?author=status%40bugs.python.org&group=gmane.comp.python.devel&sort=date

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http:

Re: Issue with writelines

2009-09-02 Thread S.Selvam
On Wed, Sep 2, 2009 at 6:50 PM, LeeRisq  wrote:

> I've written this program that has been working fine until today.
> Can't work out why it stopped working. The program pulls a list from
> an xls file, inserts each item from the list into a repeating string,
> that then concatenates the repeating string and writes it to a text
> file. It has worked fine until today, and now for some reason, it
> stops after 30 items in my list. I also just tried another list, and
> that one stopped after 70 items. Perhaps someone could take a look?
>
> Here's the file followed by the traceback:
>
> import xlrd
> import win32clipboard
>
>
>
> def program_uno():
>ofile = open(r"C:\Query\DQLVault.txt", "w")
>book = xlrd.open_workbook(r"C:\DocLoader\MCL_Drawing and Legacy
> Docloader Sheet.xls")
>sh = book.sheet_by_index(0)
>e = sh.cell_value(1, 0)
>a = sh.col_values(0, start_rowx=2, end_rowx=200)
>b = r'%' + e
>c = r'%Master-V%'
>y = r"SELECT object_name, bp_master_date, revision,
> bp_revision_date, bp_unit_no, r_version_label, r_object_id,
> r_lock_owner, r_content_size, a_content_type, r_modify_date,
> r_object_type, r_link_cnt, r_assembled_from_id, r_has_frzn_assembly,
> a_is_hidden, i_is_replica, i_is_reference, r_is_virtual_doc,
> i_chronicle_id, i_folder_id FROM mcl_engineer (ALL) WHERE (((upper
> (object_name) like upper('%s')) and (any upper(r_version_label) like
> upper('%s'))" %(b, c)
>
>w = r")) ORDER BY object_name ASC, r_object_id DESC, i_position
> DESC"
>
>ofile.writelines(y)
>for x in a:
>d = r'%' + x
>z = r" or (upper(object_name) like upper('%s')) and (any upper
> (r_version_label) like upper('%s'))" %(d, c)
>f = ofile.writelines(z)
>ofile.writelines(w)
>
>
> def copy_text():
>ifile = open(r"C:\Query\DQLVault.txt", "r")
>text = ifile.read()
>ifile.close()
>
>win32clipboard.OpenClipboard()
>win32clipboard.EmptyClipboard()
>win32clipboard.SetClipboardText(text)
>win32clipboard.CloseClipboard()
>
> program_uno()
> copy_text()
>
> Traceback:
>
>  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework
> \scriptutils.py", line 310, in RunScript
>exec codeObject in __main__.__dict__
>  File "C:\Query\DQL Vault Revision Check.py", line 34, in 
>program_uno()
>  File "C:\Query\DQL Vault Revision Check.py", line 20, in program_uno
>f = ofile.writelines(z)
> TypeError: writelines() argument must be a sequence of strings
>

why can't you print/analyse the 'z ' value on except block.


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



-- 
Yours,
S.Selvam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple addition to random module - Student's t

2009-09-02 Thread Robert Kern

On 2009-09-02 11:28 AM, Mark Dickinson wrote:

On Sep 2, 2:51 pm, Thomas Philips  wrote:

def student_t(df): # df is the number of degrees of freedom
 if df<  2  or int(df) != df:
raise ValueError, 'student_tvariate: df must be a integer>  1'


By the way, why do you exclude the possibility df=1 here?


Similarly, requiring df to be an integer is extraneous.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Problem w/ mysqldump

2009-09-02 Thread Victor Subervi
I am running this on Windoze. I do not use the mysql db without python. I'm
just building something for a client. I tried running the mysqldump command
from the python prompt. Didn't know I could do that :) It tells me
"mysqldump is not defined" :(
V

On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz wrote:

> On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote:
> >
> > Obviously I'm sure. It created the file. But the file was blank. How can
> I
> > do a mysqldump in mysql itself?
> >
>
> As I said, I only got a blank file when the actual command itself
> failed.  How do you dump the MySQL database itself without using Python?
> Just run the 'mysqldump' command from the prompt.  Is that what you are
> asking?
>
> Are you running this on Windows?  What OS?  You do have the 'mysqldump'
> command available from the shell prompt and in your path, right?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Entry Level Python Jobs

2009-09-02 Thread Tim Wintle
On Wed, 2009-09-02 at 08:31 -0700, JonathanB wrote:
> I am a self-taught Python programmer with a liberal arts degree
> (Cross-cultural studies). I have been programming for several years
> now and would like to get a job as a python programmer. Unfortunately
> most of the job posts I have seen are for CS Majors or people with
> experience.
> 
> Is there a place I can look for job posts for entry level positions
> requiring no experience? For the hiring managers, if the job post said
> "CS Major" in the requirements, would you consider a liberal arts
> major at all?

Definately not without any experience - but "experience" doesn't have to
come from paid work - coding as a hobby in your free time is what's made
all the best developers I know.

Some things I personally would expect (and find more important than a CS
background) - in order of importance:


 * Experience (e.g. open source / hobby projects / work) - several years
worth.

 * Problem solving ability

 * A good comprehension of C, machine code, or something where you have
to care about pointers/references.

 * Basic maths skills.


Tim

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


Re: evolution [was Re: An assessment of the Unicode standard]

2009-09-02 Thread r
On Sep 2, 4:41 am, Steven D'Aprano
 wrote:
(snip)
> > No evolution awards those that benefit evolution. You make it seem as
> > evolution is some loving mother hen, quite the contrary! Evolution is
> > selfish, greedy, and sometimes evil. And it will endure all of us...
>
> > remember the old cliche "Nice guys finish last"?
>
> This is Not Even Wrong. Evolution isn't a *thing*, it is a *process*.
> Nothing exists to "benefit evolution", that's like saying that horses
> have long legs to "benefit running" or people have lungs to "benefit
> breathing".

Well horses do have long and well evolved legs for running and humans
lungs for breathing, and they have them because it benefits them which
in turn benefits evolution. the buck stops with evolution.


> "R" is utterly confused if he thinks species live or die according to
> because they're benefiting evolution. Species live or die according to
> whether or not they reproduce,

Dear God i hate the current "progress" of evolution if reproduction
guaranteed survival. I think it is just a "wee" bit more complicated
than that Steven. *wink*


> (This sort of nonsense, anthropomorphizing the process of evolution,
> seems to be unique to those on the right-wing of politics. Go figure.)

Uh? let's not go there. Leave politics corrupting influence out of
this.


> Steve (the other Steve) is right -- species which are incapable of
> dealing with the complexity and dynamism of the world are doomed to
> extinction. Biologists have a word for stasis: "dead". The most vigorous,
> lively ecosystems are those that are complex, like rain forests (what
> used to be called "jungles" when I was a lad), coral reefs and mangroves.
> Messy, complicated, complex ecosystems are successful because they are
> resilient to damage -- a plague comes along and even if it kills off
> every individual of one species of fruit, there are a thousand different
> species unharmed.
>
> The sort of monoculture which "r" sings the praises of are fragile and
> brittle. Look at the Cavendish banana, nearly extinct because a disease
> is wiping the plants out, and there's not enough genetic variability in
> it to survive. (Fortunately there are dozens of varieties of bananas, so
> when the Cavendish becomes extinct, we'll still have bananas.)

You cannot draw parallels between bio diversity and language
diversity. Bio diversity is fundamental to all species survival, even
a virus. I am quite sure that the adoption of Universal World language
will not usher in the apocalypse for human kind, quite the contrary!

Ok a Jew, a Catholic Priest and a Chinese man walk into a bar Now
if the bar suddenly catches fire and only one of them notices, how
should this person convey the danger to the others. Well he could jump-
up-and-down-yelling-oh!-oh!-oh!-with-arms-failing-in-the-air, but i
think human evolution has presented a far more elegant way to
communicate than that of the chimpanzee.

> Or the Irish Potato Famine: millions of Irish dead from famine because
> 90% of their food intake came from a *single* source, potatoes, which in
> turn came from not just a single variety but just a handful of closely
> related individuals.

OMG! human kind will be utterly wiped out by the universal language.
Somebody please jump-up-and-down-with-flailing-arms we must warn
everyone of this impending doom before it is too late! 

(snip: more political innuendo)
> As for the idea "nice guys finish last", that's a ridiculous over-
> simplification. Vampire bats share their food with other vampire bats who
> otherwise would be hungry.

...could be they are fatting them up for the kill!

> Remoras stick to sharks, who carry them around
> for years without eating them.

...Well yes sharks share a personality trait with cab drivers but...?
And i wonder if they really *know* they are back there? Sharks aren't
exactly evolutions shining jewel.

> There's those little birds which climb
> into the mouths of crocodiles to clean their teeth while the crocodile
> sits patiently with it's mouth wide open.

...Hmm, i have thought about clamping down hard while my dentist pokes
around with his fingers in there. But who then would clean my teeth?
And it could be that those crocs are just slightly vain?

> Wolves and wild dogs and hyenas
> hunt cooperatively. Baboons and chimpanzees form alliances. Penguins
> huddle together through the freezing months of darkness, and although the
> winds are so cold that the penguins on the outside would freeze to death,
> few of them do, because they all take their share of time in the centre.

...birds of a feather flock together!

> Monkeys cry out warnings when they see a leopard or a hawk, even though
> it puts them personally at risk. Meercats post sentries, who expose
> themselves to danger to protect the rest of the colony.

...they could be expendable to the community!

> And the most successful mammal on the planet, more successful than any
> other large animal, is also the most cooperative, 

Re: Why does this group have so much spam?

2009-09-02 Thread Steven D'Aprano
On Wed, 02 Sep 2009 06:20:39 -0700, Emile van Sebille wrote:

> On 9/1/2009 9:22 PM r said...
>> On Sep 1, 10:16 pm, Steven D'Aprano
>>> Took me two weeks of elapsed time and around 30 hours of effort to
>>> remove those suckers from the machine. Now I run Linux, behind two
>>> firewalls.
>> 
>> Takes me less than one hour to rebuild my system
> 
> If that's your job (as it's sometimes mine) then that sounds about
> right.  Otherwise, you must have a lot of practice rebuilding!

I could have nuked the machine and rebuilt it from scratch, but I 
couldn't find my WinXP original media. Besides, when I started the 
process, I had no idea it would take so long.

I learned one thing though. System Restore sounds like a good idea, but 
in my experience it's only good for restoring malware when you reboot.

(I won't tell you how many times I deleted the same spyware apps before I 
worked out what was happening. Grrr arrg.)



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


ctypes WNetGetUniversalNameW

2009-09-02 Thread Gustavo
Hello,

I'm trying to call WNetGetUniversalNameW via the ctypes module but I'm
only causing the interpreter to crash. Unfortunately I don't have much
experience with the ctypes module and I'm still trying to figure it
out. I've searched for a solution to no avail. My confusion is
centered around the LPVOID buffer parameter and how this should be
created/used. Any help is appreciated.

# DWORD WNetGetUniversalName(
#  __in LPCTSTR lpLocalPath,
#  __in DWORD dwInfoLevel,
#  __outLPVOID lpBuffer,
#  __inout  LPDWORD lpBufferSize
# );

import ctypes, win32netcon

LPDWORD = ctypes.POINTER(DWORD)

class UniversalNameInfo(ctypes.Structure):
__fields__ = [("lpUniversalName", LPCWSTR)]

WNetGetUniversalNameW = ctypes.windll.mpr.WNetGetUniversalNameW

path = LPCWSTR('Y:')
level = DWORD(win32netcon.UNIVERSAL_NAME_INFO_LEVEL)
buffer_len = LPDWORD(DWORD(1024))
uni_struct = UniversalNameInfo()

ret = WNetGetUniversalNameW(path, level, uni_struct, buffer_len)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 1:03 pm, Thomas Philips  wrote:
> On Sep 2, 12:28 pm, Mark Dickinson  wrote:
>
> > On Sep 2, 2:51 pm, Thomas Philips  wrote:
>
> > > def student_t(df):         # df is the number of degrees of freedom
> > >     if df < 2  or int(df) != df:
> > >        raise ValueError, 'student_tvariate: df must be a integer > 1'
>
> > By the way, why do you exclude the possibility df=1 here?
>
> > --
> > Mark
>
> I exclude df=1 hereBecause the variance is then infinite (in fact, the
> distribution is then Cauchy). That said, your point is well taken;
> allowing df=1 makes the Cauchy distribution available to users of
> random, in much the same way as the Gamma makes the Chi-squared
> available. Here's the revised code:
>
> def student_tvariate(df):         # df is the number of degrees of
> freedom
>     if df < 1  or int(df) != df:
>         raise ValueError, 'student_tvariate: df must be a positive
> integer'
>
>     x = random.gauss(0, 1)
>     y = random.gammavariate(df/2.0, 2)
>
>     return x / (math.sqrt(y/df))
>
> I'll follow your suggestion, add in documentation and submit it to
> bugs.python.com. Thanks for your guidance.
>
> Thomas Philips

Mark,

I mis-spoke - the variance is infinite when df=2 (the variance is df/
(df-2), and you get the Cauchy when df=2. So I'm going to eat humble
pie and go back to

def student_tvariate(df): # df is the number of degrees of
freedom
if df < 2  or int(df) != df:
   raise ValueError, 'student_tvariate: df must be a integer > 1'

x = random.gauss(0, 1)
y = random.gammavariate(df/2.0, 2)

return x / (math.sqrt(y/df))



I made the mistake because the denominator is  equivalent to the
square root of the sample variance of df normal observations, which in
turn has df-1 degrees of freedom...Oh well,  I think it's
much easier to apologize than to rationalize my error


Sincerely

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


Re: Entry Level Python Jobs

2009-09-02 Thread Adam
On Sep 2, 11:31 am, JonathanB  wrote:
> For the hiring managers, if the job post said
> "CS Major" in the requirements, would you consider a liberal arts
> major at all?

I got my English Writing degree in 1990, and I have been a software
engineer ever since. Landing the first job was very difficult, but it
gave me the foundation of experience that allowed me to circumvent the
"CS-degree or equivalent" requirement on every job that I have had
since. If you do choose to pursue software development as a career,
you'll be shocked at how many of your fellow liberal arts degree
holders are doing the same.

It will be a hard road. You will have to overcome significant
obstacles. You will do boring, tedious work. You will find out what it
really means to pay one's dues. You will also, perchance, succeed and
find happiness in a fulfilling career.

I think that Python is an outstanding foundation for learning
programming, but I would advise you to branch out as quickly as
possible. I imagine that saying so won't endear me to anyone here, but
in good conscience, I have to recommend C# and the .NET framework; it
has lead me to continual and well-paying employment for many, many
years now. Also, put together an on-line portfolio of code, preferably
composed of complete and useful programs. Actually seeing well-
written, well-documented code can go a long way towards getting you in
the door for an interview.
-- 
http://mail.python.org/mailman/listinfo/python-list


website feedback to where?

2009-09-02 Thread rogerdpack
Greetings.  A little new to python here, but...

on this page

http://docs.python.org/3.1/tutorial/introduction.html

some of the "text" examples are [incorrectly] color formatted.

I assume this a bug reportable to bugs.python.org?
Thanks!
-r
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickling question

2009-09-02 Thread exarkun

On 02:06 pm, gary...@me.com wrote:
When you define a class in a script, and then pickle instances of that 
class in the same script and store them to disk, you can't load that 
pickle in another script. At least not the straightforward way 
[pickle.load(file('somefile.pickle'))]. If you try it, you get an 
AttributeError during the unpickling operation.


There is no problem, of course, if the class is defined in a module 
which is imported by the pickling script. 
pickle.load(file('somefile.pickle')) then works.


Rather than provide specific examples here, there's a blog post from 
2005 that discusses this issue in depth and presents the problem very 
well: http://stefaanlippens.net/pickleproblem. (I tested in Python 2.6 
yesterday and the same issue persists.)


Questions:

1) Does this have to be the case, or is it a design problem with 
pickles that should be remedied?


2) Is there an easier way around it than moving the class definition to 
a separate module? The blog post I point to above suggests putting 
"__module__ = os.path.splitext(os.path.basename(__file__))[0]" into the 
class definiton, but that's not working in my testing because when I do 
that, the pickling operation fails. Is there something else that can be 
done?


I described another solution here: 
http://jcalderone.livejournal.com/45604.html


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


Re: Entry Level Python Jobs

2009-09-02 Thread Aahz
In article ,
JonathanB   wrote:
>
>I am a self-taught Python programmer with a liberal arts degree (Cross-
>cultural studies). I have been programming for several years now and
>would like to get a job as a python programmer. Unfortunately most of
>the job posts I have seen are for CS Majors or people with experience.
>
>Is there a place I can look for job posts for entry level positions
>requiring no experience? For the hiring managers, if the job post said
>"CS Major" in the requirements, would you consider a liberal arts
>major at all?

You should also look into finding e.g. a tech support job at a company
using Python.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Look, it's your affair if you want to play with five people, but don't
go calling it doubles."  --John Cleese anticipates Usenet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 12:28 pm, Mark Dickinson  wrote:
> On Sep 2, 2:51 pm, Thomas Philips  wrote:
>
> > def student_t(df):         # df is the number of degrees of freedom
> >     if df < 2  or int(df) != df:
> >        raise ValueError, 'student_tvariate: df must be a integer > 1'
>
> By the way, why do you exclude the possibility df=1 here?
>
> --
> Mark

I exclude df=1 hereBecause the variance is then infinite (in fact, the
distribution is then Cauchy). That said, your point is well taken;
allowing df=1 makes the Cauchy distribution available to users of
random, in much the same way as the Gamma makes the Chi-squared
available. Here's the revised code:

def student_tvariate(df): # df is the number of degrees of
freedom
if df < 1  or int(df) != df:
raise ValueError, 'student_tvariate: df must be a positive
integer'

x = random.gauss(0, 1)
y = random.gammavariate(df/2.0, 2)

return x / (math.sqrt(y/df))


I'll follow your suggestion, add in documentation and submit it to
bugs.python.com. Thanks for your guidance.

Thomas Philips

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


Re: Entry Level Python Jobs

2009-09-02 Thread JonathanB
Ok, so what I'm hearing is "Get a code portfolio together and watch
the job board on python.org." Thanks for the advice!

I've been watching the python job board 3-4 times a week and I've been
working my way through the Project Euler problems in my free time. I
also have a trade generator that I wrote up to support a Traveller
game I was running a while back, but that code is old (the first non-
trivial program I ever wrote) and really fairly buggy. The user
interface is basically an infinite recursion that I sys.exit() out of
when I'm through, which means the code slows considerably as you do
more stuff in it because each trip back to the main menu is a
recursive call to the main() function. Hey, I was young and naive. I'm
working on cleaning it up right now. Any other tips?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Entry Level Python Jobs

2009-09-02 Thread Ethan Furman

Philip Semanchuk wrote:


On Sep 2, 2009, at 11:48 AM, r wrote:


On Sep 2, 10:31 am, JonathanB  wrote:


I am a self-taught Python programmer with a liberal arts degree  (Cross-
cultural studies). I have been programming for several years now and
would like to get a job as a python programmer. Unfortunately most of
the job posts I have seen are for CS Majors or people with  experience.

Is there a place I can look for job posts for entry level positions
requiring no experience? For the hiring managers, if the job post  said
"CS Major" in the requirements, would you consider a liberal arts
major at all?



Have you thought about getting involved with the Python core
development. Not a paying position, but may lead you to some good
connections, and i can't think of a better place to prove yourself
than that ;-)



Or instead of diving into the Python core which might be pretty heavy  
stuff, create some open source code -- a game, a calculator, a music  
generator, an app to automatically download weather maps, etc.  Whatever 
tickles your fancy. If you're willing to stand on your merits  (and it 
sounds like you are), you can point people to where your code  is hosted 
and say, "I wrote that".


Anyway, it's something to do in between hitting refresh on 
http://www.python.org/community/jobs/


Good luck to you
Philip


Philip is right -- I would consider a non-CS major, but then you'd get 
round-filed for the no experience.  Write something, or better yet, a 
few smallish somethings and a medium something, and then you can claim 
experience.


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


Re: Entry Level Python Jobs

2009-09-02 Thread Paul Rubin
JonathanB  writes:
> I am a self-taught Python programmer with a liberal arts degree (Cross-
> cultural studies)
> Is there a place I can look for job posts for entry level positions
> requiring no experience? For the hiring managers, if the job post said
> "CS Major" in the requirements, would you consider a liberal arts
> major at all?

I think in the current economy there are not many entry level
positions requiring no experience, except for internships and that
sort of thing.  Also there are some jobs which really do call for a CS
major or someone of equivalent background.  

Often though, pure technical background doesn't matter as much as
inventiveness and the ability to make things happen, which is more a
matter of personality than training.  I don't know what cross-cultural
studies is, but I could imagine assignments (e.g. internationalizing
the user interface of a program or web site) where someone with that
background could work out fine.

Basically I think for pure software development openings, you may be
difficult to place, but there's lots of other types of openings where
the primary task is something other than programming and yet
incidental amounts of programming are involved.  For those, you'd have
a much better shot.

One thing that can certainly help is to have a portfolio of code
you've written for personal or academic projects or whatever.  Where I
work we're in the process of interviewing a guy who is some kind of
artist, who has used Python in some pretty cool art projects.  He has
a bunch of code on his web site that were very helpful in getting an
impression of his capabilities.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >