[Tutor] idiomatic way of merging two dictionaries

2009-11-03 Thread Amit Sethi
Hi , I am trying to merge(I am not sure if that is the right term) dictionaries like this dict1 ={'a':4,'b':3,'v':7,'h':4} dict2={'a':5,'v':4,'k':3} dict3 would be {'a':[4,5],'b':[3,4],'v':[7,4],'k':[0,3],'h':[4,0]} -- A-M-I-T S|S ___ Tutor maillist -

Re: [Tutor] Stolen thread: Bottom folk vs. toppers was trouble using2to3.py

2009-11-03 Thread Alan Gauld
"Robert Berman" wrote The war between bottom posters and top posters has been long, arduous, and most often incredibly silly. It has, I agree but there is a very real difference in that gratuitous top posting does actually become unreadable if not done very carefully. And it also encorages pe

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
On Tue, Nov 3, 2009 at 17:21, Richard D. Moores wrote: > Another is, although I've seen this before in older Python docs, I > never really understood things like > > for_stmt ::= "for" target_list "in" expression_list ":" suite >             ["else" ":" suite] > > help> ::= > no Python documentati

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread bob gailer
Robert Berman wrote: In [69]: l1=[(0,0)] * 4 In [70]: l1 Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] In [71]: l1[2][0] Out[71]: 0 In [72]: l1[2][0] = 3 --- TypeError Traceback (most recent ca

Re: [Tutor] Can't find modules at command line

2009-11-03 Thread Alan Gauld
"Christian Witts" wrote >>> import gun Traceback (most recent call last): File "", line 1, in ImportError: No module named gun >>> This file is at [/Users/sam/Documents/gun.py]. What should I do to make it visible to Python? In the console when you start it up you appear to be in your

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
My sincere thanks to Dave Angel and Alan Gauld for their clear explanations of .bat files and how to use them. I've already made several useful ones. Dick Moores ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http:

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Alan Gauld
"Richard D. Moores" wrote My sincere thanks to Dave Angel and Alan Gauld for their clear explanations of .bat files and how to use them. I've already made several useful ones. Start the cmd shell in windows and run the help command to get a list of things you can put in to spruce them up.

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Alan Gauld
"Richard D. Moores" wrote Or the way I do it, have python31.bat and python26.bat, which launch the exact pythons that I want. Thanks, Dave. I'm not familiar with .bat files. Could you give me a look at one of them? A bat file is just a file of "DOS" commands and ends in .bat so python31.b

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Dave Angel
Tim Golden wrote: Richard D. Moores wrote: On Tue, Nov 3, 2009 at 05:30, Dave Angel wrote: Or the way I do it, have python31.bat and python26.bat, which launch the exact pythons that I want. Thanks, Dave. I'm not familiar with .bat files. Could you give me a look at one of them? As an a

[Tutor] Stolen thread: Bottom folk vs. toppers was trouble using 2to3.py

2009-11-03 Thread Robert Berman
The war between bottom posters and top posters has been long, arduous, and most often incredibly silly. There have been written group rules mandating one over the other. Oft times these rules have doomed the group. I have used both approaches most often favoring top posting only because my mail p

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Dave Angel
Richard D. Moores wrote: On Tue, Nov 3, 2009 at 05:30, Dave Angel wrote: Easiest way to know which python is being used is to run it same way: e:\python31\temp> python 2to3.py -w mycalc.py Or the way I do it, have python31.bat and python26.bat, which launch the exact pythons that I want.

Re: [Tutor] java for python programmers

2009-11-03 Thread Alan Gauld
"Amit Sethi" wrote Hi their is a book , python for java programmers is their a book on java for python programmers for some one who wants to move to java from python Not that I know of but you could try the Jython book for starters to play with the Java class library which is half the bat

Re: [Tutor] Retrieving information from a plain text file(WinXP/py2.6.2/Beginner)

2009-11-03 Thread Alan Gauld
"Serdar Tumgoren" wrote Also, on a side note, you can greatly improve the readability of your code by using the triple-quote style for multi-line docstrings inside functions (rather than the hash comment marks). I tend to use hash marks for one-line/inline comments, since they can really beco

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Kent Johnson
On Tue, Nov 3, 2009 at 1:10 PM, Luke Paireepinart wrote: > I was under the impression that you were supposed to top-post unless you > were referring to a specific thing someone said, in which case you quoted > it, much like you do on a forum. > Is that not how it works? Presumably you are replyin

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
On Tue, Nov 3, 2009 at 16:46, Alan Gauld wrote: > > "Richard D. Moores" wrote >> >> My sincere thanks to Dave Angel and Alan Gauld for their clear >> explanations of .bat files and how to use them. I've already made >> several useful ones. > > Start the cmd shell in windows and run the help comma

Re: [Tutor] Stolen thread: Bottom folk vs. toppers was trouble using 2to3.py

2009-11-03 Thread Modulok
[snip] > The war between bottom posters and top posters has been long, arduous, > and most often incredibly silly. There have been written group rules > mandating one over the other. Oft times these rules have doomed the > group. > Two words come to mind: Bikeshed color. > I simply propose that t

Re: [Tutor] PyWin32 - Library of functions to interact with windows?

2009-11-03 Thread Scott Nelson
Scott Nelson wrote: > > It *is* possible to color console text with Python and pywin. But, it is > tricky and not obvious. I've been wondering how to do this myself and I > recently found some C code on the web [2] that does this and I translated > that into to Python and pywin. It can be done

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Luke Paireepinart
On Tue, Nov 3, 2009 at 7:30 AM, Dave Angel wrote: > (Erasing entire history, since you both top-posted, and it's too confusing) > I was under the impression that you were supposed to top-post unless you were referring to a specific thing someone said, in which case you quoted it, much like you do

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Robert Berman
Thank you for your explanations and especially your clear examples of a phenomenon(when list elements are tuples) which takes a few moments of study to truly grasp. Robert On Tue, 2009-11-03 at 09:53 -0600, Wayne Werner wrote: > On Tue, Nov 3, 2009 at 9:20 AM, Robert Berman > wrote: > >

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Mark Tolonen
"Robert Berman" wrote in message news:1257261606.29483.23.ca...@bermanrl-desktop... In [69]: l1=[(0,0)] * 4 In [70]: l1 Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] In [71]: l1[2][0] Out[71]: 0 In [72]: l1[2][0] = 3 --- T

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Andre Engels
On Tue, Nov 3, 2009 at 4:20 PM, Robert Berman wrote: > > In [69]: l1=[(0,0)] * 4 > > In [70]: l1 > Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] > > In [71]: l1[2][0] > Out[71]: 0 > > In [72]: l1[2][0] = 3 > --- > TypeError

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Emile van Sebille
On 11/3/2009 7:20 AM Robert Berman said... In [69]: l1=[(0,0)] * 4 In [70]: l1 Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] In [71]: l1[2][0] Out[71]: 0 In [72]: l1[2][0] = 3 --- TypeError Tra

Re: [Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Wayne Werner
On Tue, Nov 3, 2009 at 9:20 AM, Robert Berman wrote: > > In [69]: l1=[(0,0)] * 4 > > In [70]: l1 > Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] > > In [71]: l1[2][0] > Out[71]: 0 > This calls the element at index 2 which is: (0,0) - a tuple, then calls element [0] from that tuple, which is 0 whe

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Tim Golden
Richard D. Moores wrote: On Tue, Nov 3, 2009 at 05:30, Dave Angel wrote: (Erasing entire history, since you both top-posted, and it's too confusing) When you run a xxx.py on Windows, it locates the python.exe using the registry entries set up by assoc and ftype. But when you run "python" it

[Tutor] Being beaten up by a tuple that's an integer thats a tuple that may be an unknown 'thing'.

2009-11-03 Thread Robert Berman
In [69]: l1=[(0,0)] * 4 In [70]: l1 Out[70]: [(0, 0), (0, 0), (0, 0), (0, 0)] In [71]: l1[2][0] Out[71]: 0 In [72]: l1[2][0] = 3 --- TypeError Traceback (most recent call last) /home/bermanr

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
On Tue, Nov 3, 2009 at 05:30, Dave Angel wrote: > (Erasing entire history, since you both top-posted, and it's too confusing) > > When you run a xxx.py on Windows, it locates the python.exe using the > registry entries set up by  assoc and ftype.  But when you run "python" it > looks for python.ex

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
After much fiddling around, I got 2to3 to work! And it did a fine, if not perfect job on mycalc.py (which has about 120 functions and 1993 lines). What I did that worked, was to use the E:\Python26\Tools\Scripts, and not Python31. E:\Python26\Tools\Scripts has 2to3.py. I added the folder lib2to3\

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Dave Angel
(Erasing entire history, since you both top-posted, and it's too confusing) When you run a xxx.py on Windows, it locates the python.exe using the registry entries set up by assoc and ftype. But when you run "python" it looks for python.exe (or python.bat, or ...) on the PATH. So there's not

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
And here's the same try (without the -w switch, to keep it simple), but this time on my laptop (64-bit Vista SP1). The result is a bit different: = C:\Python31\temp>2to3.py mycalc.py Traceback (most recent call last): File "C:\Python31\temp\2to3.py", line 2, i

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
Well, here's the same try again, followed by starting the shell: = E:\Python31\temp>2to3.py -w mycalc.py Traceback (most recent call last): File "E:\Python31\temp\2to3.py", line 2, in from lib2to3.main import main File "E:\Python31\temp\lib2to3\main

[Tutor] java for python programmers

2009-11-03 Thread Amit Sethi
Hi their is a book , python for java programmers is their a book on java for python programmers for some one who wants to move to java from python -- A-M-I-T S|S ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] trouble using 2to3.py

2009-11-03 Thread Luke Paireepinart
Are you sure you're using the 3.1 version of Python to run the script? Welcome back, btw. haven't heard from you in a while. On Tue, Nov 3, 2009 at 2:09 AM, Richard D. Moores wrote: > I'm in the process to learning Python 3.1, and need to convert a bunch > of handy functions I wrote and stole ov

[Tutor] trouble using 2to3.py

2009-11-03 Thread Richard D. Moores
I'm in the process to learning Python 3.1, and need to convert a bunch of handy functions I wrote and stole over several years. They are all written in 2.x, and are together in one file, mycalc.py. I created a folder E:\Python31\temp\ (my OS is Vista SP1 64-bit), and in it I placed copies of mycal