Re: Best way to compute length of arbitrary dimension vector?

2011-06-02 Thread Algis Kabaila
On Monday 30 May 2011 23:38:53 Gabriel wrote: Thanks a lot to both of you, Chris Peter! (I knew the solution would be simple ... ;-) ) import math length = math.hypot(z, math.hypot(x, y)) One line and fast. OldAl. -- Algis http://akabaila.pcug.org.au/StructuralAnalysis.pdf --

Re: Puzzled by list-appending behavior

2011-05-26 Thread Algis Kabaila
On Thursday 26 May 2011 14:46:45 Uncle Ben wrote: In playing with lists of lists, I found the following: (In 3.1, but the same happens also in 2.7) list = [1,2,3] list.append ( [4,5,6] ) x = list x - [1,2,3,[4,5,6]] as expected. But the shortcut fails: list=[1,2,3] x =

Re: Odp: Re: Strange behaviour of input() function (Python 3.2)

2011-05-25 Thread Algis Kabaila
On Wednesday 25 May 2011 06:27:52 sunrrrise wrote: Ok, another time I'd like to thank you for your help. I gave up, I'm going to get used to IDLE GUI... at least this one works! With IDLE, after any changes to the program, you are asked to save file. IDLE knows that a file in python needs to

Re: Deleting a file?

2011-05-17 Thread Algis Kabaila
On Tuesday 17 May 2011 07:23:33 garyr wrote: A file can be deleted by opening it with mode os.O_TEMPORARY and then closing it. How can a file be moved to the Recycle Bin, a la Windows? Just highlight it, pess the Del key and select move to Trash. (With minor variation between different

Python 3.2 Vectors.py module

2011-05-15 Thread Algis Kabaila
Hi All, I would really appreciate any comments and suggestions for the Vectors.py module, which can be downloaded from http://akabaila.pcug.org.au/linalg/vectors.tar.gz The tar ball is only about 4 KiB, but I gather that this mailing list does not tolerate attachments. The module is

Re: Python 3.2 Vectors.py module

2011-05-15 Thread Algis Kabaila
On Sunday 15 May 2011 19:44:29 Daniel Kluev wrote: On Sun, May 15, 2011 at 8:15 PM, Algis Kabaila akaba...@pcug.org.au wrote: Hi All, I would really appreciate any comments and suggestions for the Vectors.py module, which can be downloaded from - If you intend to provide

Re: checking if a list is empty

2011-05-15 Thread Algis Kabaila
On Friday 13 May 2011 18:47:50 Hans Georg Schaathun wrote: On Thu, 12 May 2011 23:20:20 +1000, Chris Angelico ros...@gmail.com wrote: : Writing a program requires expertise both in programming snip... And the main difference here, is that the civil engineers have a much better language

Re: list equal to subclass of list?

2011-05-12 Thread Algis Kabaila
On Thursday 12 May 2011 22:23:04 Roy Smith wrote: I have a vague feeling this may have been discussed a long time ago, but I can't find the thread, so I'll bring it up again. I recently observed in the checking if a list is empty thread that a list and a subclass of list can compare equal:

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used. But how to enable the standard matrix notation a[i, j

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 17:22:42 Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 17:44:44 Terry Reedy wrote: On 5/10/2011 3:22 AM, Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: class listwrap: def __init__(self, lis): self._list = lis def __getitem__(self, dex): i,j = dex return self

Re: scipy

2011-05-09 Thread Algis Kabaila
On Tuesday 10 May 2011 04:13:55 pb wrote: On May 9, 3:34 pm, Robert Kern robert.k...@gmail.com wrote: On 5/9/11 3:35 AM, pb wrote: On May 9, 12:29 am, Terry Reedytjre...@udel.edu wrote: On 5/8/2011 6:44 AM, pb wrote: Hi, I', having trouble with scipy. If you do not get an

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Algis Kabaila
On Tuesday 10 May 2011 05:24:16 Terry Reedy wrote: On 5/9/2011 4:25 AM, Antonio CHESSA wrote: apple = [[a,b,c],[1,2,3,4,5,6],[antony,max,sandra,seb astian]] for j in range (len(apple[i])): print apple[i][j] While this illustrate double indexing, it can be simplified to

Re: Coolest Python recipe of all time

2011-05-03 Thread Algis Kabaila
On Tuesday 03 May 2011 16:00:05 Terry Reedy wrote: On 5/3/2011 1:04 AM, Stefan Behnel wrote: The bad thing about this recipe is that it requires quite a bit of background knowledge in order to infer that the code the developer is looking at is actually correct. The main math knowledge

Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 13:22:44 Ben Finney wrote: rusi rustompm...@gmail.com writes: You may want to look at rcs if you are in the space where But today, Bazaar or Mercurial fill that role just as well: quick simple set up, good tool support (yes, even in Emacs using VC mode), and easy to

Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 17:19:57 rusi wrote: On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au wrote: Actually, Bazaar is more convenient than rcs for a single user, as the repository can be the working directory (with a hidden .bzr directory that stores diffs). Dont exactly

Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 19:09:38 jacek2v wrote: On May 2, 9:48 am, Algis Kabaila akaba...@pcug.org.au wrote: On Monday 02 May 2011 17:19:57 rusi wrote: On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au wrote: Actually, Bazaar is more convenient than rcs for a single user

Re: De-tupleizing a list

2011-04-27 Thread Algis Kabaila
On Wednesday 27 April 2011 20:56:20 John Pinner wrote: On Apr 26, 4:28 am, Gnarlodious gnarlodi...@gmail.com wrote: I have an SQLite query that returns a list of tuples: [('0A',), ('1B',), ('2C',), ('3D',),... What is the most Pythonic way to loop through the list returning a list

Re: Deditor

2011-04-27 Thread Algis Kabaila
On Thursday 28 April 2011 01:53:18 Kruptein wrote: Hey, I released a new version (0.2.5) of my pythonic text-editor called Deditor. snip... ( only a .deb is available for download now, if you would like another format (.tar.gz) please comment ) Congratulations! Though I am happy with

Re: use of index (beginner's question)

2011-04-27 Thread Algis Kabaila
On Thursday 28 April 2011 11:23:51 Thomas 'PointedEars' Lahn wrote: Chris Angelico wrote: Rusty Scalf wrote: list1 = ['pig', 'horse', 'moose'] list2 = ['62327', '49123', '79115'] n = 2 s2 = list + `n` list + 'n' 'listn' And IMHO you did not want that, did you? OldAl. -- Algis

Re: Vectors

2011-04-26 Thread Algis Kabaila
On Monday 25 April 2011 20:49:34 Jonathan Hartley wrote: On Apr 20, 2:43 pm, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au writes: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication

Re: How to concatenate unicode strings ???

2011-04-26 Thread Algis Kabaila
On Wednesday 27 April 2011 02:33:00 Ariel wrote: with commands.getoutput(one_comand.encode('utf-8')) it works !!! On Tue, Apr 26, 2011 at 6:22 PM, Ariel isaacr...@gmail.com wrote: And what about if after the string is concat I want it to pass is to the command line to do anything else,

Re: De-tupleizing a list

2011-04-26 Thread Algis Kabaila
On Tuesday 26 April 2011 22:19:08 Gnarlodious wrote: On Apr 25, 10:59 pm, Steven D'Aprano wrote: In Python 3, map becomes lazy and returns an iterator instead of a list, so you have to wrap it in a call to list(). Ah, thanks for that tip. Also works for outputting a tuple:

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Algis Kabaila
On Wednesday 27 April 2011 03:59:25 Thomas Rachel wrote: Am 26.04.2011 16:39, schrieb snorble: When I write a Python app, I have several unorganized I don't see how these tools will help to get up to date the way you describe it - but all other issues are well coped with using a VCS. I

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Algis Kabaila
On Wednesday 27 April 2011 04:31:19 CM wrote: I guess it depends on your project, but that sounds needlessly complex and way too tough with a VCS. I'd say just don't go there. (Whoops, I meant way too tough *without* a VCS, not with) And read your own emails *before* sending them :)

Re: Development tools and practices for Pythonistas

2011-04-26 Thread Algis Kabaila
On Wednesday 27 April 2011 09:41:53 Ben Finney wrote: Chris Angelico ros...@gmail.com writes: As other people have said, version control is very handy. I use git myself, but imho the choice of _which_ VCS you use is far less important than the choice of _whether_ to use one. True

Re: Vectors

2011-04-25 Thread Algis Kabaila
On Monday 25 April 2011 12:59:38 rusi wrote: On Apr 25, 4:49 am, Robert Kern robert.k...@gmail.com wrote: On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabailaakaba...@pcug.org.au wrote: Are there any

Re: Vectors

2011-04-23 Thread Algis Kabaila
On Saturday 23 April 2011 14:13:31 sturlamolden wrote: On Apr 23, 2:32 am, Algis Kabaila akaba...@pcug.org.au wrote: Thanks for that. Last time I looked at numpy (for Python3) it was available in source only. I know, real men do compile, but I am an old man... I will compile

Re: Vectors

2011-04-22 Thread Algis Kabaila
On Friday 22 April 2011 11:43:26 Gregory Ewing wrote: Algis Kabaila wrote: the Vector3 class is available without any prefix euclid: import euclid v = Vector3(111.., 222.2, 333.3) Doesn't work that way for me: Python 2.7 (r27:82500, Oct 15 2010, 21:14:33) [GCC 4.2.1 (Apple Inc

Re: Vectors

2011-04-22 Thread Algis Kabaila
On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabaila akaba...@pcug.org.au wrote: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication [scalar and vector]. Could you give me a reference

Re: learnpython.org - an online interactive Python tutorial

2011-04-21 Thread Algis Kabaila
On Thursday 21 April 2011 03:15:50 Ron wrote: Hey everyone. I've written an online interactive Python tutorial atop Google App Engine: http://www.learnpython.org. All you need to do is log in using your Google account and edit the wiki to add your tutorials. Read more on the website.

Re: Vectors

2011-04-21 Thread Algis Kabaila
On Thursday 21 April 2011 01:49:57 Andreas Tawn wrote: On Apr 20, 6:43 am, Andreas Tawn andreas.t...@ubisoft.com wrote: Algis Kabaila akaba...@pcug.org.au writes: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication

Vectors

2011-04-20 Thread Algis Kabaila
Hi, Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication [scalar and vector]. Could you give me a reference to such module? platform - ubuntu 10.10 (Linux), Python 3.1 or higher. Thanks for your help to avoid re-invention of the

Re: Python IDE/text-editor

2011-04-16 Thread Algis Kabaila
On Saturday 16 April 2011 15:55:59 harrismh777 wrote: Alec Taylor wrote: Please continue your recommendations. IDLE? (works for me) 3.2 is working much better for me this week... :) (thanks) kind regards, m harris IDLE is ok and it comes by default with Python. Eric4 for

Re: PYTHONPATH

2011-04-16 Thread Algis Kabaila
On Saturday 16 April 2011 14:16:59 harrismh777 wrote: Algis Kabaila wrote: Is PYTHONPATH a system variable that sets the path for several sessions and if so, where in the system is it? Do I need to create one for setting python path for several sessions? snip... Of course this only

Re: PYTHONPATH

2011-04-16 Thread Algis Kabaila
On Saturday 16 April 2011 20:03:22 jmfauth wrote: On 16 avr, 06:16, harrismh777 harrismh...@charter.net wrote: By default the sys.path always shows the directory python was opened in, usually the users home directory. With .profile you can set the path any way you want... most useful

Re: [OT] Free software versus software idea patents

2011-04-16 Thread Algis Kabaila
On Saturday 16 April 2011 16:46:10 geremy condra wrote: On Fri, Apr 15, 2011 at 10:21 PM, harrismh777 harrismh...@charter.net wrote: snip This looks to me like an application of the troll motto if you can't dazzle them with brilliance, baffle them with bull. It certainly does nothing to

Re: memory usage multi value hash

2011-04-15 Thread Algis Kabaila
On Friday 15 April 2011 02:13:51 christian wrote: Hello, i'm not very experienced in python. Is there a way doing below more memory efficient and maybe faster. I import a 2-column file and then concat for every unique value in the first column ( key) the value from the second columns.

PYTHONPATH

2011-04-15 Thread Algis Kabaila
Hi, An elementary question that is bugging me, regarding sys.path values.sys.path can be altered easily, but the changes last for the current session only. I would like the changes to stay for several sessions. Is PYTHONPATH a system variable that sets the path for several sessions and if

Re: PYTHONPATH

2011-04-15 Thread Algis Kabaila
On Friday 15 April 2011 19:21:12 Chris Rebert wrote: On Fri, Apr 15, 2011 at 1:33 AM, Algis Kabaila akaba...@pcug.org.au wrote: Hi, snip.. It is an environment variable: http://en.wikipedia.org/wiki/Environment_variable Alternatively, you can use a .pth file to add directories

Re: Converting an array of string to array of float

2011-03-25 Thread Algis Kabaila
On Saturday 26 March 2011 02:27:12 Jason Swails wrote: I'm guessing you have something like list1=['1.0', '2.3', '4.4', '5.5', ...], right? You can do this: for i in range(len(list1)): list1[i] = float(list1[i]) Better, list1 = [float(v) for v in list1] One statement only - long

Re: newbie question (for loop)

2011-03-15 Thread Algis Kabaila
On Wednesday 16 March 2011 05:48:14 Tim Morneau wrote: You have to add the colon to the end of the statement if this is an accurate representation of the statement so: for i in range(len(list)): instead of for i in range(len(list)) It seems to me that it would be simpler to simply

Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Algis Kabaila
On Friday 11 March 2011 14:13:52 Paul Rubin wrote: Robert sigz...@gmail.com writes: Is there a push to one toolkit or the other? Tkinter or a simple web app with cgihttpserver. I haven't ever had occasion to write a fancy desktop app and I think of them as a mostly-obsolete medium, though