Re: Yet another "simple" headscratcher

2014-05-30 Thread Ian Kelly
On Fri, May 30, 2014 at 9:38 PM, Josh English wrote: > I am trying to whip up a quick matrix class that can handle multiplication. > > Should be no problem, except when it fails. > > [SNIP] > > def zero_matrix(rows, cols): > row = [0] * cols > data = [] > for r in range(rows): >

Re: Yet another "simple" headscratcher

2014-05-30 Thread Gary Herron
On 05/30/2014 08:38 PM, Josh English wrote: ... def zero_matrix(rows, cols): row = [0] * cols data = [] for r in range(rows): data.append(row) return Matrix(data) There is a simple and common newbie mistake here.It looks like you are appending several copies

Re: Yet another "simple" headscratcher

2014-05-30 Thread Josh English
Mea culpa, gang. I found it. It had absolutely nothing to do with the multiplication. It was in zero_matrix. I feel like a fool. Josh -- https://mail.python.org/mailman/listinfo/python-list

Yet another "simple" headscratcher

2014-05-30 Thread Josh English
I am trying to whip up a quick matrix class that can handle multiplication. Should be no problem, except when it fails. --- Begin #!/usr/bin/env python # _*_ coding: utf-8 from operator import mul class Matrix(object): """Matrix([data]) Data should be a list of equal sized lists. De

Re: Script suddenly stops

2014-05-30 Thread Paul McNett
On 5/29/14, 7:47 PM, Chris wrote: I'm trying to read ten 200 MB textfiles into a MySQL MyISAM database (Linux, ext4). The script output is suddenly stopping, while the Python process is still running (or should I say sleeping?). It's not in top, but in ps visible. Does it stop in the same place

Re: daemon thread cleanup approach

2014-05-30 Thread Devin Jeanpierre
On Fri, May 30, 2014 at 1:59 PM, Ethan Furman wrote: > Given the use-case (must shut down, cannot risk a hung process, orphan files > be damned) I don't think having a daemon thread die because it raised an > exception trying to access a missing global is a big deal. It's certainly suboptimal. Su

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Chris Angelico
On Sat, May 31, 2014 at 7:42 AM, Devin Jeanpierre wrote: > In unix shells you can literally use a new line. Or is that only bash? You can in bash, I know, but it's fiddly to type it; and more importantly, it's not a good point in the "this is cleaner than a series of pipes" argument. My primary r

Re: daemon thread cleanup approach

2014-05-30 Thread Ethan Furman
On 05/30/2014 01:47 PM, Devin Jeanpierre wrote: Don't use daemon threads, they are inherently un-thread-safe: any global access you do anywhere inside a daemon thread can fail, because daemon threads are still potentially run during interpreter shutdown, when globals are being deleted from every

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Devin Jeanpierre
In unix shells you can literally use a new line. Or is that only bash? -- Devin On Fri, May 30, 2014 at 2:11 PM, Duncan Booth wrote: > Chris Angelico wrote: > >> Problem: Translate this into a shell one-liner: >> >> import os >> for root, dirs, files in os.walk("."): >> if len(dirs + files)

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Duncan Booth
Chris Angelico wrote: > Problem: Translate this into a shell one-liner: > > import os > for root, dirs, files in os.walk("."): > if len(dirs + files) == 1: print(root) > This is one area where Windows seems to do better than Linux shells: PS C:\python33> python -c "import os`nfor root, di

Re: daemon thread cleanup approach

2014-05-30 Thread Devin Jeanpierre
Don't use daemon threads, they are inherently un-thread-safe: any global access you do anywhere inside a daemon thread can fail, because daemon threads are still potentially run during interpreter shutdown, when globals are being deleted from every module. Most functions you might call are not safe

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Sat, May 31, 2014 at 5:28 AM, Steven D'Aprano wrote: > Before you ask, there is no absolutely hard and fast line between "shell > feature" and "Python code", but the more closely your shell features > resemble Python code, the harder it will be for users (power or not) to > keep them separate i

Re: How to run script from interpreter?

2014-05-30 Thread Steven D'Aprano
On Fri, 30 May 2014 21:46:55 +1000, Chris Angelico wrote: > On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano > wrote: >> This is why I'm so adamant that, while REPLs may be permitted to >> introduce *new* syntax which is otherwise illegal to the Python parser, >> (e.g. like IPython's %magic and !

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 10:47:33 PM UTC+5:30, wxjm...@gmail.com wrote: > = > Ok, thanks for the answer. > "xetex does not quite work whereas pdflatex works smoothly" > ? Problem is a combination of 1. I am a somewhat clueless noob 2. xetex is emerging technology therefore changing fast

Re: IDE for python

2014-05-30 Thread Mark Lawrence
On 30/05/2014 18:07, Rustom Mody wrote: On Friday, May 30, 2014 10:08:04 PM UTC+5:30, Mark Lawrence wrote: On 30/05/2014 17:15, Rustom Mody wrote: On Friday, May 30, 2014 8:36:54 PM UTC+5:30, jmf wrote: It is now about time that we stop taking ASCII seriously!! This can't happen in the Pytho

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 10:08:04 PM UTC+5:30, Mark Lawrence wrote: > On 30/05/2014 17:15, Rustom Mody wrote: > > On Friday, May 30, 2014 8:36:54 PM UTC+5:30, jmf wrote: > > It is now about time that we stop taking ASCII seriously!! > This can't happen in the Python world until there is a sensible

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 10:07:21 PM UTC+5:30, Terry Reedy wrote: > On 5/30/2014 12:15 PM, Rustom Mody wrote: > > > And for those who dont know xetex, its is really xɘtex – a pictorial > > anagram if written as XƎTEX > > I believe you mean 'pictorial palindrome', which it is! > Heh! Getting wooz

Re: IDE for python

2014-05-30 Thread Mark Lawrence
On 30/05/2014 17:15, Rustom Mody wrote: On Friday, May 30, 2014 8:36:54 PM UTC+5:30, wxjm...@gmail.com wrote: It is now about time that we stop taking ASCII seriously!! This can't happen in the Python world until there is a sensible approach to unicode. Ah, but wait a minute, the ball was s

Re: IDE for python

2014-05-30 Thread Terry Reedy
On 5/30/2014 12:15 PM, Rustom Mody wrote: And for those who dont know xetex, its is really xɘtex – a pictorial anagram if written as XƎTEX I believe you mean 'pictorial palindrome', which it is! -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 8:36:54 PM UTC+5:30, wxjm...@gmail.com wrote: > Out of curiosity. > Are you the Rusi Mody attempting to dive in Xe(La)TeX? Yeah :-) As my blog posts labelled unicode will indicate I am a fan of using unicode in program source: http://blog.languager.org/search/label/Unicod

Re: Optparse to parsing Suggestions !!

2014-05-30 Thread Peter Otten
Ganesh Pal wrote: > Hello Python world , > > > I wanted suggestion on how to modify the below code to help me accomodate > the below two cases > > # Here is the Sample code. > > def main(): > """ ---MAIN--- """ > parser = optparse.OptionParser(usage='%prog [options] .]', > version='1.0

Re: IDE for python

2014-05-30 Thread Terry Reedy
On 5/30/2014 9:54 AM, Marko Rauhamaa wrote: Rustom Mody : 3. Search unopened files (grep) for a string or re. How do you do this with emacs? I find a menagerie of greppish commands -- rgrep, lgrep, grep-find etc To grep for a pattern in the directory of the active buffer: M-x grep

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Terry Reedy
On 5/30/2014 2:45 AM, Rustom Mody wrote: $ python -c 'import os, pprint; pprint.pprint ([ r for r, d, f in os.walk(".") if len(d+f) != 1])' Mysterious that print after a ; is fine whereas for is not Not at all. Simple statememts can follow ; or :, compound statements cannot. -- Terry Jan Re

Re: Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
On Fri, May 30, 2014 at 7:48 PM, Ganesh Pal wrote: > > Hello Python world , > > > I wanted suggestion on how to modify the below code to help me accomodate > the below two cases > > # Here is the Sample code. > > def main(): > """ ---MAIN--- """ > parser = optparse.OptionParser(usage='%pr

Re: How to run script from interpreter?

2014-05-30 Thread Terry Reedy
On 5/30/2014 7:46 AM, Chris Angelico wrote: Hmm. I'm not sure that "raises SyntaxError" is any less a part of the language's promise than "evaluates to twice the value of x" is. Of course it is. A real SyntaxError cannot be caught immediately.* When new syntax features are added, breaking the

Optparse to parsing Suggestions !!

2014-05-30 Thread Ganesh Pal
Hello Python world , I wanted suggestion on how to modify the below code to help me accomodate the below two cases # Here is the Sample code. def main(): """ ---MAIN--- """ parser = optparse.OptionParser(usage='%prog [options] .]', version='1.0') object_choice = ('super_block','block

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 7:24:10 PM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody wrote: > > > >> > 3. Search unopened files (grep) for a string or re. > > > > How do you do this with emacs? > > I find a menagerie of greppish commands -- rgrep, lgrep, grep-find etc > > > > To grep for a pattern

Re: IDE for python

2014-05-30 Thread Marko Rauhamaa
Rustom Mody : >> > 3. Search unopened files (grep) for a string or re. > > How do you do this with emacs? > I find a menagerie of greppish commands -- rgrep, lgrep, grep-find etc To grep for a pattern in the directory of the active buffer: M-x grep Run grep (like this): grep -nH -e Compl

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 10:47 PM, Rustom Mody wrote: > On Friday, May 30, 2014 12:50:31 PM UTC+5:30, Chris Angelico wrote: >> On Fri, May 30, 2014 at 4:04 PM, Rustom Mody wrote: >> > I thought when one signs up for python one has to sign an affidavit >> > saying: >> > "I shall not write one-liners

Re: IDE for python

2014-05-30 Thread Rustom Mody
On Thursday, May 29, 2014 10:14:35 PM UTC+5:30, Paul Rudin wrote: > Terry Reedy writes: > > 3. Search unopened files (grep) for a string or re. > Emacs. How do you do this with emacs? I find a menagerie of greppish commands -- rgrep, lgrep, grep-find etc -- https://mail.python.org/mailman/listin

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Rustom Mody
On Friday, May 30, 2014 12:50:31 PM UTC+5:30, Chris Angelico wrote: > On Fri, May 30, 2014 at 4:04 PM, Rustom Mody wrote: > > I thought when one signs up for python one has to sign an affidavit > > saying: > > "I shall not write one-liners\n" * 100 > Certainly not. I write all my list comps on one

Re: IDE for python

2014-05-30 Thread alister
On Thu, 29 May 2014 15:11:31 -0500, Mark H Harris wrote: > On 5/29/14 11:44 AM, Paul Rudin wrote: >> Terry Reedy writes: >>> I am curious how many of the editors people have been recommending >>> have all of the following Idle features, that I use constantly. >>> >>> 1. Run code in the editor wit

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 9:27 PM, Steven D'Aprano wrote: > This is why I'm so adamant that, while REPLs may be permitted to > introduce *new* syntax which is otherwise illegal to the Python parser, > (e.g. like IPython's %magic and !shell commands) they *must not* change > the meaning of otherwise

Re: How to run script from interpreter?

2014-05-30 Thread Steven D'Aprano
On Fri, 30 May 2014 17:19:00 +1000, Chris Angelico wrote: > On Fri, May 30, 2014 at 4:20 PM, Steven D'Aprano > wrote: >>> It's on par with creating a file with a name beginning with a hyphen, >>> and then fiddling around with various commands as you try to >>> manipulate it (tip: "rm ./-r" works)

Re: IDE for python

2014-05-30 Thread Andrea D'Amore
On 2014-05-30 07:21:52 +, Andrea D'Amore said: It aims at providing a beautiful interface, Side note: the text editing is still green. -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: how avoid delay while returning from C-python api?

2014-05-30 Thread Lakshmipathi.G
Yes, Cython looks easier but the problem its a very old code ( 6 or 7 years ). Almost entire code base uses plain python-c api. Thanks for the example, will use Cython or Ctypes way for side-projects! Cheers, Lakshmipathi.G FOSS Programmer. www.giis.co.in/readme.html -- https://mail.pytho

Re: PythonCE successfully inst'ed, but scripts don't work. Please help.

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 1:12 PM, Abdullah Indorewala wrote: > Hi, > > I know you posted this 15 years ago but I recently stumbled across your post > here : > > https://mail.python.org/pipermail/python-list/1999-May/018340.html > > And I am in the same situation (kind of). I can’t get Python to i

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Peter Otten
Rustom Mody wrote: > On Friday, May 30, 2014 12:15:46 PM UTC+5:30, Rustom Mody wrote: >> Heres a (pr) approx >> >> $ python -c 'import os, pprint; pprint.pprint ([ r for r, d, f in >> os.walk(".") if len(d+f) != 1])' > > Without pprint: (pooor) > > python -c 'import os; print "\n".join([ r

Re: Script suddenly stops

2014-05-30 Thread Peter Otten
Chris wrote: > Dear All, > > I'm trying to read ten 200 MB textfiles into a MySQL MyISAM database > (Linux, ext4). The script output is suddenly stopping, while the Python > process is still running (or should I say sleeping?). It's not in top, > but in ps visible. > > Why is it stopping? Is the

Re: IDE for python

2014-05-30 Thread Andrea D'Amore
On 2014-05-29 22:40:36 +, Travis Griggs said: I use either vim or textwrangler for simple one file scripts. Since you're on OS X have a look at Exedore, it's paid but very cheap. It aims at providing a beautiful interface, I fetched the free trial a couple days ago and the job so far is

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 4:04 PM, Rustom Mody wrote: > I thought when one signs up for python one has to sign an affidavit > saying: > "I shall not write one-liners\n" * 100 Certainly not. I write all my list comps on one line! *ducking for cover* ChrisA -- https://mail.python.org/mailman/listi

Re: How to run script from interpreter?

2014-05-30 Thread Chris Angelico
On Fri, May 30, 2014 at 4:20 PM, Steven D'Aprano wrote: >> It's on par with creating a file with a name beginning with a >> hyphen, and then fiddling around with various commands as you try to >> manipulate it (tip: "rm ./-r" works); programs will happily interpret >> "-r" as an option rather than

Re: Script suddenly stops

2014-05-30 Thread dieter
Chris writes: > I'm trying to read ten 200 MB textfiles into a MySQL MyISAM database > (Linux, ext4). The script output is suddenly stopping, while the Python > process is still running (or should I say sleeping?). It's not in top, > but in ps visible. > > Why is it stopping? Is there a way to mak