Re: Best method for a menu in a command line program?

2010-11-04 Thread Arnaud Delobelle
Ben Finney writes: [...] > commands = { > 'q': (lambda: quit()), > 'c': (lambda: prompt_and_convert_temperature( > ["Celsius", "Fahrenheit"], celsius_to_fahrenheit)), > 'f': (lambda: prompt_and_convert_temperature( > ["Fahrenheit", "Celsi

Re: Compare source code

2010-11-04 Thread Steven D'Aprano
On Wed, 03 Nov 2010 23:09:10 +, Seebs wrote: > On 2010-11-03, Steven D'Aprano > wrote: >> Yes. How does that contradict what I said? > > Once you understand that you do have to break the rules occasionally, it > is a good idea to design things that will be robust when the rules are > broken.

Re: Compare source code

2010-11-04 Thread Steven D'Aprano
On Wed, 03 Nov 2010 23:42:55 +, Seebs wrote: > No one has claimed that this is a problem *for everybody*. Just that > there exist real-world workflows for which it is a problem, or people > for whom it is a problem. And people have suggested that if your workflow leads to indentation being

Re: Subclassing unittest.TestCase?

2010-11-04 Thread Ulrich Eckhardt
Roy Smith wrote: > I'm writing a test suite for a web application. There is a subclass of > TestCase for each basic page type. [...] > class CommonTestCase(unittest.TestCase): >def test_copyright(self): > self.assert_(find copyright notice in DOM tree) > > class HomepageTestCase(Common

subprocess.Popen not replacing current process?

2010-11-04 Thread goodman
Note: Our server is a Linux machine, but we're restricted to Python 2.4. Hi, I'm wondering why subprocess.Popen does not seem to replace the current process, even when it uses os.execvp (according to the documentation: http://docs.python.org/library/subprocess.html#subprocess.Popen). Specifically,

Re: Best method for a menu in a command line program?

2010-11-04 Thread brf256
Thanks for the help! Ill incorporate this into my menu. Thanks again, Braden Faulkner Sent wirelessly from my BlackBerry device on the Bell network. Envoyé sans fil par mon terminal mobile BlackBerry sur le réseau de Bell. -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare source code

2010-11-04 Thread Seebs
On 2010-11-04, Steven D'Aprano wrote: > And people have suggested that if your workflow leads to indentation > being mangled and your source code no longer running, the solution is to > change the workflow. Yup. But it strikes me as unmistakably a shortcoming of Python (and Makefiles, for that

Re: Must be a bug in the re module [was: Why this result with the re module]

2010-11-04 Thread Yingjie Lan
--- On Wed, 11/3/10, MRAB wrote: > [snip] > The outer group is repeated, so it can match again, but the > inner group > can't match again because it captured all it could the > previous time. > > Therefore the outer group matches and captures an empty > string and the > inner group remembers its

Is there a OrderedDict which can perform an iteritems() in order?

2010-11-04 Thread Jo Chan
Hello all, I have working on a program which need a ordered dictionary that could perform iteritems() sequentially. I found a package on : http://www.voidspace.org.uk/python/odict.html#creating-an-ordered-dictionary

Re: Is there a OrderedDict which can perform an iteritems() in order?

2010-11-04 Thread Vlastimil Brom
2010/11/4 Jo Chan : > Hello all, >      I have working on a program which need a ordered dictionary that could > perform iteritems() sequentially. >      I found a package on > : http://www.voidspace.org.uk/python/odict.html#creating-an-ordered-dictionary >      but it  could only perform items() i

openmp do loops

2010-11-04 Thread Pascal
Hi, I would like to parallelize this loop: do i=1,hklsize fcalctable(i)=structfact(hkltable(1,i),hkltable(2,i),hkltable(3,i)) end do I thought I would do this: !$OMP PARALLEL DO default(private) shared(hkltable, fcalctable,hklsize) do i=1,hklsize fcalctable(i)=structfact(hkltable(1,i),hkltable(

Re: openmp do loops

2010-11-04 Thread Pascal
On 11/04/2010 11:13 AM, Pascal wrote: Hi, Oops, wrong group, sorry... Pascal -- http://mail.python.org/mailman/listinfo/python-list

Re: Best method for a menu in a command line program?

2010-11-04 Thread Michele Simionato
On Nov 4, 2:19 am, braden faulkner wrote: > I'm using a menu for my command line app using this method. > > choice = "foobar" > while choice != "q": >     if choice == "c": >         temp = input("Celsius temperature:") >         print "Fahrenheit:",celsius_to_fahrenheit(temp) >     elif choice ==

Re: openmp do loops

2010-11-04 Thread Stefan Behnel
Pascal, 04.11.2010 11:13: I would like to parallelize this loop: do i=1,hklsize fcalctable(i)=structfact(hkltable(1,i),hkltable(2,i),hkltable(3,i)) end do I thought I would do this: !$OMP PARALLEL DO default(private) shared(hkltable, fcalctable,hklsize) do i=1,hklsize fcalctable(i)=structfact(hk

Re: What people are using to access this mailing list

2010-11-04 Thread tinnews
Tim Harig wrote: > On 2010-11-03, Grant Edwards wrote: > > On 2010-11-03, Paul Rudin wrote: > >> John Bond writes: > >> > >>> On 3/11/2010 11:17 AM, Steven D'Aprano wrote: > On Wed, 03 Nov 2010 08:02:29 +, John Bond wrote: > > > Hope this isn't too O/T - I was just wondering h

Re: Best method for a menu in a command line program?

2010-11-04 Thread Ben Finney
Arnaud Delobelle writes: > Ben Finney writes: > [...] > > commands = { > > 'q': (lambda: quit()), > > 'c': (lambda: prompt_and_convert_temperature( > > ["Celsius", "Fahrenheit"], celsius_to_fahrenheit)), > > 'f': (lambda: prompt_and_convert_temperature

python logging, handling multiline log entries

2010-11-04 Thread Jean-Michel Pichavant
Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s")) l.error('1st line\n2nd line') output: 2010-11-04 1

Re: Best method for a menu in a command line program?

2010-11-04 Thread Ben Finney
[email protected] writes: > Thanks again, > Braden Faulkner > > Sent wirelessly from my BlackBerry device on the Bell network. > Envoyé sans fil par mon terminal mobile BlackBerry sur le réseau de Bell. Please show your thanks by *not* spamming the forum with each message; compose your messages f

Re: Best method for a menu in a command line program?

2010-11-04 Thread Peter Otten
braden faulkner wrote: > I'm using a menu for my command line app using this method. > > choice = "foobar" > while choice != "q": > if choice == "c": > temp = input("Celsius temperature:") > print "Fahrenheit:",celsius_to_fahrenheit(temp) > elif choice == "f": > te

Re: python logging, handling multiline log entries

2010-11-04 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s")) l.error('1st line\n2n

Re: Compare source code

2010-11-04 Thread Antoon Pardon
On Wed, Nov 03, 2010 at 11:37:03AM +, Steven D'Aprano wrote: > On Wed, 03 Nov 2010 12:01:06 +1300, Lawrence D'Oliveiro wrote: > > > In message , Grant Edwards wrote: > > >> Other languages have similar problems if you remove salient bits of > >> syntax before comparing two source files files.

Re: Compare source code

2010-11-04 Thread Ethan Furman
Antoon Pardon wrote: Unless, your code is split over different pages, as when it is printed in a book. You also need to see the next piece of code to notice the dedention. e.g. I have the following code at the bottom of my editor. for i := 0 to 9 do some(code); more(code); end; I

Re: Compare source code

2010-11-04 Thread Grant Edwards
On 2010-11-04, Seebs wrote: > On 2010-11-04, Steven D'Aprano wrote: >> And people have suggested that if your workflow leads to indentation >> being mangled and your source code no longer running, the solution is to >> change the workflow. > > Yup. > > But it strikes me as unmistakably a shortc

Re: Compare source code

2010-11-04 Thread Ethan Furman
Grant Edwards wrote: On 2010-11-04, Emile van Sebille wrote: On 11/3/2010 4:09 PM Seebs said... What's the token that marks the end of a block, corresponding to the colon used to introduce it? My thoughts tend more towards 'can we get Guido to eliminate the colon requirements' -- The inde

Re: Compare source code

2010-11-04 Thread Antoon Pardon
On Fri, Nov 05, 2010 at 06:29:11AM -0700, Ethan Furman wrote: > Antoon Pardon wrote: > >Unless, your code is split over different pages, as when it is printed in a > >book. > >You also need to see the next piece of code to notice the dedention. > > > >e.g. I have the following code at the bottom o

Popen Question

2010-11-04 Thread moogyd
Hi, I usually use csh for my simulation control scripts, but these scripts are becoming more complex, so I plan to use python for the next project. To this end, I am looking at subprocess.Popen() to actually call the simulations, and have a very basic question which is demonstrated below. [sde:st.

Re: openmp do loops

2010-11-04 Thread Alain Ketterlin
Stefan Behnel writes: >> !$OMP PARALLEL DO default(private) shared(hkltable, fcalctable,hklsize) >> do i=1,hklsize >> fcalctable(i)=structfact(hkltable(1,i),hkltable(2,i),hkltable(3,i)) >> end do >> !$OMP END PARALLEL DO (This is Fortan, BTW.) > Seeing this makes me seriously happy that I can w

Re: Compare source code

2010-11-04 Thread Neil Cerutti
On 2010-11-05, Ethan Furman wrote: > Grant Edwards wrote: >> On 2010-11-04, Emile van Sebille wrote: >>> On 11/3/2010 4:09 PM Seebs said... What's the token that marks the end of a block, corresponding to the colon used to introduce it? >>> >>> My thoughts tend more towards 'can we get

Compiling/Installing Python 2.7 on OSX 10.6

2010-11-04 Thread Jeremy
I'm having trouble installing Python 2.7 on OSX 10.6 I was able to successfully compile it from source, but ran into problems when I did make install. The error I got (I received many similar errors) was: /usr/bin/install -c -m 644 ../LICENSE /home/jlconlin/Library/ Frameworks/Python.framework/V

Re: Popen Question

2010-11-04 Thread Ravi
On Nov 4, 7:06 pm, moogyd wrote: > Hi, > I usually use csh for my simulation control scripts, but these scripts > are becoming more complex, so I plan to use python for the next > project. > To this end, I am looking at subprocess.Popen() to actually call the > simulations, and have a very basic q

Re: cms 4 static pages?

2010-11-04 Thread Daniel Fetchinson
> m looking 4 a framework, that allows to build static community software > (similar to facebook) without having to start scripts, database > connects, admin cookies, e.t.c. > > means - should be dynamic without really being dynamic, delivering just > static pages. (yes, i know e.g. nginx does that

Re: [ANN] pyOpenSSL 0.11 released

2010-11-04 Thread Giampaolo Rodolà
2010/11/1 : > Hello all, > > I'm happy to announce the release of pyOpenSSL 0.11.  The primary change > from the last release is that Python 3.2 is now supported.  Python 2.4 > through Python 2.7 are still supported as well.  This release also fixes a > handful of bugs in error handling code.  It

execute shell script from python, needs sys.argv

2010-11-04 Thread Matt
Hi All, I am trying to execute a shell script from within python.. This shell script takes the format, where $1 and $2 are variables from the command line: cat $1 | Fastx_trimmer -n COUNT -o $2 straight into the cmd line it would be: cat file.1 | Fastx_trimmer -n COUNT -o file.2 So, know that

Re: Popen Question

2010-11-04 Thread Alain Ketterlin
moogyd writes: import os, subprocess os.environ['MYVAR'] = "myval" p = subprocess.Popen(['echo', '$MYVAR'],shell=True) p = subprocess.Popen(['echo', '$MYVAR']) $MYVAR > p = subprocess.Popen('echo $MYVAR',shell=True) myval > p = subprocess.Popen('echo $

Re: execute shell script from python, needs sys.argv

2010-11-04 Thread Benjamin Kaplan
On Thu, Nov 4, 2010 at 11:37 AM, Matt wrote: > Hi All, > > I am trying to execute a shell script from within python..  This shell > script takes the format, where $1 and $2 are variables from the > command line: cat $1 | Fastx_trimmer -n COUNT -o $2 > > straight into the cmd line it would be:  cat

Re: execute shell script from python, needs sys.argv

2010-11-04 Thread Peter Otten
Matt wrote: > I am trying to execute a shell script from within python.. This shell > script takes the format, where $1 and $2 are variables from the > command line: cat $1 | Fastx_trimmer -n COUNT -o $2 > > straight into the cmd line it would be: cat file.1 | Fastx_trimmer -n > COUNT -o file.2

Re: Allowing comments after the line continuation backslash

2010-11-04 Thread Lawrence D'Oliveiro
In message , Roy Smith wrote: >> > > That URL takes me to a github page. Can you be more specific about > which file I should be looking at? The extract I previously quoted was from dvd_menu_animator. > 2) You have provided comments for each function,

Re: Man pages and info pages

2010-11-04 Thread Lawrence D'Oliveiro
In message <[email protected]>, rustom wrote: > The printed python docs come to several thousand pages. Do we want them > to be 1 manpage? a hundred? a thousand? Perl managed to condense a lot of useful information into a handful of man pages. --

Re: functions, list, default parameters

2010-11-04 Thread Lawrence D'Oliveiro
In message , Robert Kern wrote: > On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote: > >> In message, Robert >> Kern wrote: >> >>> "Immutable objects" are just those without an obvious API for modifying >>> them. >> >> They are ones with NO legal language constructs for modifying them. Hint: >> if a

Re: Compare source code

2010-11-04 Thread Lawrence D'Oliveiro
In message , Seebs wrote: > It is extremely useful to me to have spaces converted to tabs > for every other file I edit. I’m thinking of going the other way. After many years of treating tabs as four-column steps, I might give up on them and use spaces everywhere. -- http://mail.python.org/mail

Re: Allowing comments after the line continuation backslash

2010-11-04 Thread Lawrence D'Oliveiro
In message , Chris Rebert wrote: > Actually, my PEP 8 reference was in regards to the (imo, terrible) > UseOfCamelCaseForNonClasses (Python != C#), not the formatting of the > for-loop; hence the "In any case" qualification. Hmm ... OK, I might accept that particular criticism. I have to say it’

Re: Python documentation too difficult for beginners

2010-11-04 Thread Lawrence D'Oliveiro
In message , Cameron Simpson wrote: > But its weakness is stuff like this: > > http://epydoc.sourceforge.net/stdlib/Canvas.Polygon-class.html > > Automatic docness, no useful information. But it Conforms to Documentation-Production Metrics as decreed by the Corporate Task Force on Policy. S

Re: Compare source code

2010-11-04 Thread Lawrence D'Oliveiro
In message , Seebs wrote: > The question is *why* diff has that option. > > The answer is because whitespace changes (spaces to tabs, different > tab stops, etcetera) are an extremely common failure mode, such that > it's quite common for files to end up with unintentional whitespace > changes.

How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
Hi Folks How find all childrens values of a nested dictionary, fast! >>> a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc' >>> :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' : >>> {'/' :[12,13,14,15]}, 'ac' :{'/' :[21,22,23]}} >>> a['a'] {'c': {'/': [5, 6

Re: Compare source code

2010-11-04 Thread D'Arcy J.M. Cain
On 04 Nov 2010 08:17:10 GMT Seebs wrote: > Outside of people who seem to be deeply emotionally invested in insisting > that it is never, at all, in ANY way, for ANY person, annoying, it seems > to be pretty consistent to observe that, benefits or no benefits, it has > some kind of non-zero annoyan

Final state of underlying sequence in islice

2010-11-04 Thread Shashank Singh
Hi, Apologies if this has been discussed in this list before. Google has not been very helpful in locating any such previous discussion. Are there any promises made with regard to final state of the underlying sequence that islice slices? for example consider this >>> from itertools import * >>>

Re: functions, list, default parameters

2010-11-04 Thread Robert Kern
On 11/4/10 2:07 AM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: On 11/2/10 2:12 AM, Lawrence D'Oliveiro wrote: In message, Robert Kern wrote: "Immutable objects" are just those without an obvious API for modifying them. They are ones with NO legal language constructs for mod

Re: Compare source code

2010-11-04 Thread John Nagle
On 10/31/2010 6:52 AM, jf wrote: Le 31/10/2010 13:10, Martin v. Loewis a écrit : I've a project with tabs and spaces mixed (yes I know it's bad). I edit each file to remove tabs, but it's so easy to make a mistake. Do you know a tools to compare the initial file with the cleaned one to know if

Re: DateTime object

2010-11-04 Thread M.-A. Lemburg
jf wrote: > Hi, > > I've a bug in my code and I'm trying de reproduce it. > > To trace the bug I print arguments, and it produces this: > {'date': } > > My question is: what is: ? > > I use mx.DateTime put if I print it I get: > > > So what kind of object is ? You might be using the old Pyt

sigaction?

2010-11-04 Thread Neal Becker
Why doesn't python signal support sigaction? I'm interested in trying sigaction with SA_RESTART to prevent interrupted system calls. Or, would the usage of SA_RESTART within python cause other problems? -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare source code

2010-11-04 Thread Mark Wooding
Seebs writes: > Python's the only language I use where an obvious flaw, which is > repeatedly observed by everyone I know who uses the language, is > militantly and stridently defended by dismissing, insulting, and > attacking the character and motives of anyone who suggests that it > might be a

Re: Compare source code

2010-11-04 Thread Mark Wooding
Tim Harig writes: > Python is the only language that I know that *needs* to specify tabs > versus spaces since it is the only language I know of which uses > whitespace formating as part of its syntax and structure. You need to get out more. Miranda, Gofer, Haskell, F#, make(1), and many others

Re: Compare source code

2010-11-04 Thread Neil Cerutti
On 2010-11-04, D'Arcy J.M. Cain wrote: >> * Not being able to write an auto-indenter, ever, because it >> is by design theoretically impossible: Annoying. > > Right. And in C you can never write an auto-bracer for exactly > the same reason. It's not right, actually. Auto-indent is fairly easy i

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Diez B. Roggisch
macm writes: > Hi Folks > > How find all childrens values of a nested dictionary, fast! There is no faster than O(n) here. > a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc' :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' : {'/' :[12,13,1

Re: Compare source code

2010-11-04 Thread Grant Edwards
On 2010-11-04, Neil Cerutti wrote: > On 2010-11-04, D'Arcy J.M. Cain wrote: >>> * Not being able to write an auto-indenter, ever, because it >>> is by design theoretically impossible: Annoying. >> >> Right. And in C you can never write an auto-bracer for exactly >> the same reason. > > It's not

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Peter Otten
macm wrote: > How find all childrens values of a nested dictionary, fast! > a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc' :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' : {'/' :[12,13,14,15]}, 'ac' :{'/' :[21,22,23]}} a['a'] > {'c': {'/':

Re: Compare source code

2010-11-04 Thread MRAB
On 04/11/2010 16:49, Mark Wooding wrote: Seebs writes: Python's the only language I use where an obvious flaw, which is repeatedly observed by everyone I know who uses the language, is militantly and stridently defended by dismissing, insulting, and attacking the character and motives of anyon

Re: What people are using to access this mailing list

2010-11-04 Thread Peter Pearson
On Wed, 3 Nov 2010 08:02:29 + (UTC), John Bond wrote: > Hope this isn't too O/T - I was just wondering how people read/send to this > mailing list, eg. normal email client, gmane, some other software or online > service? Usenet via a server at news.individual.net, newsgroup name comp.lang.p

Re: Compare source code

2010-11-04 Thread Emile van Sebille
On 11/4/2010 7:15 AM Neil Cerutti said... The handsome ':' terminator of if/elif/if statements allows us to omit a newline, conserving vertical space. This improves the readability of certain constructs. if x: print(x) elif y: print(y) else: print() Analogously, x+=1;y=f(x);return We don't h

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, Mark Wooding wrote: > Tim Harig writes: > >> Python is the only language that I know that *needs* to specify tabs >> versus spaces since it is the only language I know of which uses >> whitespace formating as part of its syntax and structure. > > You need to get out more. Miranda,

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, Neil Cerutti wrote: > On 2010-11-04, D'Arcy J.M. Cain wrote: Seebs Wrote: >>> * Not being able to write an auto-indenter, ever, because it >>> is by design theoretically impossible: Annoying. >> >> Right. And in C you can never write an auto-bracer for exactly >> the same reason.

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
Hi Folks Thanks a lot Script from Diez works: print list(f(a)) but should be print list(f(a['a']['b'])) to fit my example. About Peter script I am receiving >>> for v in f(a['a']['b']): ... b.extend(v) ... Traceback (most recent call last): File "", line 2, in TypeError: 'int' obj

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, MRAB wrote: > On 04/11/2010 16:49, Mark Wooding wrote: >> Seebs writes: >>* I don't have many problems with tools trashing whitespace in Python >> programs, though I have seen web forum software mangling >> indentation; since this makes nontrivial chunks of almost any

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
Peter Ok! Both works fine! Thanks a lot! >>> for v in f(a['a']['b']): ... b.extend(v) b Now I will try find which script is the fast! Regards macm On 4 nov, 15:56, macm wrote: > Hi Folks > > Thanks a lot > > Script from Diez works: > > print list(f(a)) > > but should be > > print lis

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Peter Otten
macm wrote: > About Peter script > > I am receiving > for v in f(a['a']['b']): > ... b.extend(v) > ... > Traceback (most recent call last): > File "", line 2, in > TypeError: 'int' object is not iterable > > I am trying understand this error. You are probably mixing Diez' implement

Re: Allow multiline conditions and the like

2010-11-04 Thread Mark Wooding
Chris Rebert writes: > Or, if possible, refactor the conditional into a function (call) so > it's no longer multiline in the first place. No! This /increases/ cognitive load for readers, because they have to deal with the indirection through the name. If you actually use the function multiple

Re: Compare source code

2010-11-04 Thread Neil Cerutti
On 2010-11-04, Grant Edwards wrote: > On 2010-11-04, Neil Cerutti wrote: >> On 2010-11-04, D'Arcy J.M. Cain wrote: * Not being able to write an auto-indenter, ever, because it is by design theoretically impossible: Annoying. >>> >>> Right. And in C you can never write an auto-bracer

Re: Compare source code

2010-11-04 Thread D'Arcy J.M. Cain
On Thu, 4 Nov 2010 17:55:55 + (UTC) Tim Harig wrote: > What Seebs is refering to is that it is difficult or impossible to > re-indent Python source automatically after the indent structure has been > broken (such as his email being converted to html on the server or a web Right. If you mangl

How convert list to nested dictionary?

2010-11-04 Thread macm
Hi Folks How convert list to nested dictionary? >>> l ['k1', 'k2', 'k3', 'k4', 'k5'] >>> result {'k1': {'k2': {'k3': {'k4': {'k5': {}} Regards macm -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert list to nested dictionary?

2010-11-04 Thread Chris Rebert
On Thu, Nov 4, 2010 at 11:48 AM, macm wrote: > Hi Folks > > How convert list to nested dictionary? > l > ['k1', 'k2', 'k3', 'k4', 'k5'] result > {'k1': {'k2': {'k3': {'k4': {'k5': {}} We don't do homework. Hint: Iterate through the list in reverse order, building up your result. Usi

Re: Compare source code

2010-11-04 Thread Mark Wooding
Tim Harig writes: > So, your telling me that mixing tabs and spaces is considered a good > practice in Haskell? It doesn't seem to be a matter which is discussed much. I think Haskell programmers are used to worrying their brains with far more complicated things like wobbly[1] types. > I would

Re: Best method for a menu in a command line program?

2010-11-04 Thread Ned Deily
In article <[email protected]>, Ben Finney wrote: > [email protected] writes: > > Thanks again, > > Braden Faulkner > > > > Sent wirelessly from my BlackBerry device on the Bell network. > > Envoyé sans fil par mon terminal mobile BlackBerry sur le réseau de Bell. > > Please show yo

Re: Compiling/Installing Python 2.7 on OSX 10.6

2010-11-04 Thread Ned Deily
In article <3d9139ae-bd6f-4567-bb02-b21a8ba86...@o15g2000prh.googlegroups.com>, Jeremy wrote: > I'm having trouble installing Python 2.7 on OSX 10.6 I was able to > successfully compile it from source, but ran into problems when I did > make install. The error I got (I received many similar e

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, Mark Wooding wrote: > Tim Harig writes: > This is wishful thinking. Firstly, code written with a narrow > indentation offset (e.g., two spaces) can take up an uncomfortable width > when viewed with a wider offset. I can accept that as a trade-off. People have different ideas abo

Re: Man pages and info pages

2010-11-04 Thread Mark Wooding
Tim Harig writes: > When the GNU folk decided to clone *nix they decided that they knew > better and simply decided to create their own interfaces. This isn't the case. Actually Info has a long history prior to GNU: it was the way that the documentation was presented at the MIT AI lab. In fact

Re: Compiling/Installing Python 2.7 on OSX 10.6

2010-11-04 Thread Jeremy
On Nov 4, 1:23 pm, Ned Deily wrote: > In article > <3d9139ae-bd6f-4567-bb02-b21a8ba86...@o15g2000prh.googlegroups.com>, > > > > > >  Jeremy wrote: > > I'm having trouble installing Python 2.7 on OSX 10.6  I was able to > > successfully compile it from source, but ran into problems when I did > >

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, D'Arcy J.M. Cain wrote: > On Thu, 4 Nov 2010 17:55:55 + (UTC) > Tim Harig wrote: >> What Seebs is refering to is that it is difficult or impossible to >> re-indent Python source automatically after the indent structure has been >> broken (such as his email being converted to ht

Re: Final state of underlying sequence in islice

2010-11-04 Thread Ned Deily
In article , Shashank Singh wrote: > Are there any promises made with regard to final state of the underlying > sequence that islice slices? [...] > While "fixing" this should be rather easy in terms of the change in code > required it might break any code depending > on this seemingly incorrec

Re: Best method for a menu in a command line program?

2010-11-04 Thread Grant Edwards
On 2010-11-04, Ned Deily wrote: > Ben Finney wrote: >> [email protected] writes: >> > Thanks again, >> > Braden Faulkner >> > >> > Sent wirelessly from my BlackBerry device on the Bell network. >> > Envoy?? sans fil par mon terminal mobile BlackBerry sur le r??seau de Bell. >> >> Please show yo

Re: Python documentation too difficult for beginners

2010-11-04 Thread News123
On 11/02/2010 02:42 PM, Steven D'Aprano wrote: > However, there is a Python wiki. It doesn't get anywhere near as much > love as it deserves, and (I think) the consensus was that the official > Python docs should stay official, but link to the wiki for user- > contributed content. This hasn't ha

Re: Ways of accessing this mailing list?

2010-11-04 Thread Mark Wooding
John Bond writes: > Hope this isn't too O/T - I was just wondering how people read/send to > this mailing list, eg. normal email client, gmane, some other software > or online service? > > My normal inbox is getting unmanageable, and I think I need to find a > new way of following this and other

Re: Compiling/Installing Python 2.7 on OSX 10.6

2010-11-04 Thread Ned Deily
In article <[email protected]>, Jeremy wrote: [...] > I downloaded the source from python.org and extracted with 'tar -xzvf > Python-2.7.tgz' My home space is on some network somewhere. I think > the network filesystem creates the ._ at the beginn

Re: Compare source code

2010-11-04 Thread D'Arcy J.M. Cain
On Thu, 4 Nov 2010 19:37:25 + (UTC) Tim Harig wrote: > On 2010-11-04, D'Arcy J.M. Cain wrote: > You are the one who seems to be on a crusade against against braces. It You totally misunderstand me. I am not on a crusade of any sort. I am happy with Python and the number of other people wh

Re: Best method for a menu in a command line program?

2010-11-04 Thread D'Arcy J.M. Cain
On Thu, 4 Nov 2010 19:46:28 + (UTC) Grant Edwards wrote: > I don't know whether it's that somebody is bragging about having a > blackberry/iphone (whoop-de-friggin-do!), or that having one is > somehow a valid excuse for poorly-written postings. I'm not It's really just a matter of not knowi

Re: Best method for a menu in a command line program?

2010-11-04 Thread Terry Reedy
On 11/3/2010 9:19 PM, braden faulkner wrote: I'm using a menu for my command line app using this method. choice = "foobar" while choice != "q": if choice == "c": temp = input("Celsius temperature:") print "Fahrenheit:",celsius_to_fahrenheit(temp) elif choice == "f":

Re: Compare source code

2010-11-04 Thread Seebs
On 2010-11-04, Mark Wooding wrote: > Seebs writes: >> Python's the only language I use where an obvious flaw, which is >> repeatedly observed by everyone I know who uses the language, is >> militantly and stridently defended by dismissing, insulting, and >> attacking the character and motives of

Re: Compare source code

2010-11-04 Thread Mark Wooding
Tim Harig writes: > I use simple comments that are not effected by white space. I don't > waste my time trying to make comments look artistic. They are there > to convey information; not to look pretty. I really detest having to > edit other peoples comment formatting where you have to re-alig

Re: Compare source code

2010-11-04 Thread Seebs
On 2010-11-04, D'Arcy J.M. Cain wrote: > Right. If you mangle spaces in Python or mangle braces in C then > recovery becomes impossible. I don't think anyone is contesting that. > What we question is the idea that somehow Python is special in this > regard. If you move files around in ways that

Re: Compare source code

2010-11-04 Thread Grant Edwards
On 2010-11-04, Seebs wrote: > On 2010-11-04, D'Arcy J.M. Cain wrote: >> Right. If you mangle spaces in Python or mangle braces in C then >> recovery becomes impossible. I don't think anyone is contesting that. >> What we question is the idea that somehow Python is special in this >> regard. If

Re: Allow multiline conditions and the like

2010-11-04 Thread Chris Rebert
On Thu, Nov 4, 2010 at 11:09 AM, Mark Wooding wrote: > Chris Rebert writes: >> Or, if possible, refactor the conditional into a function (call) so >> it's no longer multiline in the first place. > > No!  This /increases/ cognitive load for readers, because they have to > deal with the indirection

3rd party python module with pyd picking up wrong dlls

2010-11-04 Thread Pix
Hi, I'm trying to install OpenSSL by placing it in site-packages\OpenSSL. In the directory there the following files, crypto.pyd libeay32.dll rand.pyd SSL.pyd ssleay32.dll When i try to import the module by doing "import OpenSSL" i get an import error saying "ImportError: DLL load failed: The sp

Re: Compare source code

2010-11-04 Thread Terry Reedy
On 11/4/2010 4:17 AM, Seebs wrote: I am sorry you feel compelled to use a language you so dislike. Not our fault though. Other languages I use are mostly amenable to the development of tools to automatically indent code. Makefiles and Python are the only two exceptions... If you add the no

Re: Compiling/Installing Python 2.7 on OSX 10.6

2010-11-04 Thread Philip Semanchuk
On Nov 4, 2010, at 4:05 PM, Ned Deily wrote: > In article > <[email protected]>, > Jeremy wrote: > [...] >> I downloaded the source from python.org and extracted with 'tar -xzvf >> Python-2.7.tgz' My home space is on some network somewhere. I thi

Re: How convert list to nested dictionary?

2010-11-04 Thread macm
Hi Chris Thanks for your hint. I am reading this http://www.amk.ca/python/writing/functional Do you have good links or books to me learn "Functional Programming"? but I am not asking "...because is easy but because is hard." Show me, please! if you can. Thanks is advance. Best regards macm

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread Arnaud Delobelle
macm writes: > Hi Folks > > How find all childrens values of a nested dictionary, fast! > a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]} ,'bc' :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,7,8]}}, 'ab' : {'/' :[12,13,14,15]}, 'ac' :{'/' :[21,22,23]}}

Re: using google app through python

2010-11-04 Thread Steve Holden
On 11/1/2010 5:05 AM, charu gangal wrote: > Hey! Can anyone help me with python script for reading google > spreadsheets? what all packages do i need to import to make the code > run successfully after deploying it on google environment..thnx in > advance I've found the xlrd module very usable. r

Re: Compare source code

2010-11-04 Thread Tim Harig
On 2010-11-04, Mark Wooding wrote: > Tim Harig writes: > >> I use simple comments that are not effected by white space. I don't >> waste my time trying to make comments look artistic. They are there >> to convey information; not to look pretty. I really detest having to >> edit other peoples c

Re: Best method for a menu in a command line program?

2010-11-04 Thread braden faulkner
Sorry, I wasn't aware it was doing that but... I've removed it :-) Sorry about that, Braden Faulkner -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert list to nested dictionary?

2010-11-04 Thread Chris Rebert
> On 4 nov, 16:53, Chris Rebert wrote: >> On Thu, Nov 4, 2010 at 11:48 AM, macm wrote: >> > Hi Folks >> >> > How convert list to nested dictionary? >> >> l >> > ['k1', 'k2', 'k3', 'k4', 'k5'] >> result >> > {'k1': {'k2': {'k3': {'k4': {'k5': {}} >> >> We don't do homework. >> Hint:

Re: How convert list to nested dictionary?

2010-11-04 Thread Arnaud Delobelle
macm writes: > Hi Folks > > How convert list to nested dictionary? > l > ['k1', 'k2', 'k3', 'k4', 'k5'] result > {'k1': {'k2': {'k3': {'k4': {'k5': {}} > > Regards > > macm reduce(lambda x,y: {y:x}, reversed(l), {}) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-lis

  1   2   >