Rant on web browsers

2011-06-13 Thread Chris Angelico
Random rant and not very on-topic. Feel free to hit Delete and move on. I've just spent a day coding in Javascript, and wishing browsers supported Python instead (or as well). All I needed to do was take two dates (as strings), figure out the difference in days, add that many days to both dates, a

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Xah Lee
On Jun 13, 6:45 pm, Gregory Ewing wrote: > Chris Angelico wrote: > > And did any of the studies take into account the fact that a lot of > > computer users - in all but the purest data entry tasks - will use a > > mouse as well as a keyboard? > > What I think's really stupid is designing keyboard

Re: Binding was Re: Function declarations ?

2011-06-13 Thread Ethan Furman
Patty wrote: So I am wondering if you learned this in Computer Science or Computer Engineering?, on the job? I learned it on this list. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Looking for Coders or Testers for an Open Source File Organizer

2011-06-13 Thread zainul franciscus
I started an open source file organizer called Miranda. Miranda is inspired by Belvedere written by Adam Pash of Lifehacker (http:// lifehacker.com/341950/belvedere-automates-your-self+cleaning-pc). I know you guys must be thinking "Hmm, Miranda, isn't that an IM application ?"; Yep I hear you, I'

Re: split long string in two code lines

2011-06-13 Thread Terry Reedy
On 6/13/2011 5:51 PM, darnold wrote: print "this" \ " is" \ " a" \ " test" \ this is a test >>> print('this' ' is' ' a' ' test') this is a test Python ignores \n within parentheses, brackets, and braces, so no fragile trailing backslash needed. ('Fragile', bec

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Grant Edwards
On 2011-06-14, Gregory Ewing wrote: > Chris Angelico wrote: > >> And did any of the studies take into account the fact that a lot of >> computer users - in all but the purest data entry tasks - will use a >> mouse as well as a keyboard? > > What I think's really stupid is designing keyboards with

Binding was Re: Function declarations ?

2011-06-13 Thread Patty
"Gregory Ewing" wrote in message news:95ntrifod...@mid.individual.net... > Tim Roberts wrote: >> Andre Majorel wrote: >> >>>Anyway, it seems the Python way to declare a function is >>> >>> def f (): >>> pass >> >> No, that DEFINES a function. > > Actually, it's more illuminating to say tha

Re: Function declarations ?

2011-06-13 Thread Gregory Ewing
Tim Roberts wrote: Andre Majorel wrote: Anyway, it seems the Python way to declare a function is def f (): pass No, that DEFINES a function. Actually, it's more illuminating to say that it *creates* a function. The 'def' statement in Python is an executable statement. Executing it has

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 11:45 AM, Gregory Ewing wrote: > Chris Angelico wrote: > >> And did any of the studies take into account the fact that a lot of >> computer users - in all but the purest data entry tasks - will use a >> mouse as well as a keyboard? > > What I think's really stupid is design

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Gregory Ewing
Chris Angelico wrote: And did any of the studies take into account the fact that a lot of computer users - in all but the purest data entry tasks - will use a mouse as well as a keyboard? What I think's really stupid is designing keyboards with two big blocks of keys between the alphabetic key

Re: Function declarations ?

2011-06-13 Thread Gregory Ewing
Steven D'Aprano wrote: "Hoisting" in computing refers to the idea of "lifting" variables or code outside of one block into another. I'm not sure it's the right term for what's happening here, though. Nothing is being lifted to a higher level -- the functions remain at the same level they were

Re: Infinite recursion in __reduce__ when calling original base class reduce, why?

2011-06-13 Thread Chris Torek
In article <4df669ea$0$49182$e4fe5...@news.xs4all.nl> Irmen de Jong wrote: >I've pasted my test code below. It works fine if 'substitute' is True, >but as soon as it is set to False, it is supposed to call the original >__reduce__ method of the base class. However, that seems to crash >because of

Re: dummy, underscore and unused local variables

2011-06-13 Thread Ben Finney
Tim Johnson writes: > If I use > for dummy in range(mylimit): > > ## or > for _ in range(mylimit): > > I get no complaint from pychecker. > I would welcome comments on best practices for this issue. I have argued in the past against overloading the name ‘_’ for this http:/

Re: Function declarations ?

2011-06-13 Thread John Nagle
On 6/12/2011 12:38 PM, Andre Majorel wrote: On 2011-06-10, Asen Bozhilov wrote: Andre Majorel wrote: Is there a way to keep the definitions of the high-level functions at the top of the source ? I don't see a way to declare a function in Python. Languages with variable and function declarat

Re: Python Card alternatives?

2011-06-13 Thread rzed
Wolfgang Keller wrote in news:20110612191740.0de83e0e.felip...@gmx.net: >> Are there any other, better solutions? > > Others are e.g.: > - Pypapi > - Camelot > - Kiwi > - Sqlkit > - Gnuenterprise > etc... > > Sincerely, > > Wolfgang > Many thanks to all of you for the interesting responses.

Re: Python 2.6 OR 3.2

2011-06-13 Thread geremy condra
On Thu, Jun 9, 2011 at 11:00 PM, harrismh777 wrote: > Andrew Berg wrote: >> >> AFAICT, there are three reasons to learn Python 2: > >   ... there is a fourth reason. > > The linux distro you are using currently was customized with python 2.x > > I ran into this problem this week in fact... on my H

Re: Python 2.6 OR 3.2

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 9:08 AM, SigmundV wrote: > To the OP I'd say: learn Python through 3.2. It's the best way > forward, for the sake of yourself and others. The only way more > modules can become 3k compatible is if more people use 3k. I skipped 3.2 and went straight to 3.3a0 from hg, but th

Re: split long string in two code lines

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 9:03 AM, Tim Chase wrote: > On 06/13/2011 05:38 PM, Chris Angelico wrote: >> I'm not seeing the difference between these two. Pointer, please? >> *puzzled* > > Sorry...tried to make that clear in the surrounding text.  The first one has > the open-paren on the same line as

Re: Python 2.6 OR 3.2

2011-06-13 Thread SigmundV
I'm using 2.7.1, because that's what my Ubuntu 11.04 bundles (python -- version reports 2.7.1+ though, no idea what the + means). On the other hand, Ubuntu provides 3.2 packages via apt-get, so I'm in the process of migrating to 3k. I really like the focus on laziness in 3k (don't know if 'focus' i

Re: split long string in two code lines

2011-06-13 Thread Tim Chase
On 06/13/2011 05:38 PM, Chris Angelico wrote: On Tue, Jun 14, 2011 at 8:33 AM, Tim Chase wrote: print ("this is not " "such a huge line " "even though it has " "lots of text in it." ) print ( "this is not " "such a huge line " "even though it has " "lots of

Re: I want this to work. [[]] * n

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 8:37 AM, SherjilOzair wrote: > I want a list which contains n lists, which are all different. I had > read a page which was about the mutability of lists, and how the * > operator on lists just does a shallow copy. But I can't find it now. > Does anyone know of that page ?

I want this to work. [[]] * n

2011-06-13 Thread SherjilOzair
I want a list which contains n lists, which are all different. I had read a page which was about the mutability of lists, and how the * operator on lists just does a shallow copy. But I can't find it now. Does anyone know of that page ? Either way, How to get a list of list, with all original list

Re: split long string in two code lines

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 8:33 AM, Tim Chase wrote: >  print ("this is not " >    "such a huge line " >    "even though it has " >    "lots of text in it." >    ) > >  print ( >    "this is not " >    "such a huge line " >    "even though it has " >    "lots of text in it." >    ) I'm not seeing th

Re: split long string in two code lines

2011-06-13 Thread Tim Chase
On 06/13/2011 04:55 PM, Tycho Andersen wrote: On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote: 4print "this is a very long string that i'm going to write 5 here, it'll be for sure longer than 80 columns" Is there a better way to split the string? There is! Python (as C) c

Re: split long string in two code lines

2011-06-13 Thread Redcat
On Mon, 13 Jun 2011 23:31:29 +0200, Tracubik wrote: > 1 def foo(): > 2for index in ... > 3for plsdoit in ... > 4print "this is a very long string that i'm going to/ 5 > write here, it'll be for sure longer than 80 columns" If you're going to use the \ anyway, how about: >

Re: split long string in two code lines

2011-06-13 Thread Tycho Andersen
On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote: > Hi all, > > newbie question here > > how can i write code like this: > > 1 def foo(): > 2for index in ... > 3for plsdoit in ... > 4print "this is a very long string that i'm going to > write 5 here, it'll be for

Re: split long string in two code lines

2011-06-13 Thread darnold
print "this" \ " is" \ " a" \ " test" \ >>> RESTART >>> this is a test -- http://mail.python.org/mailman/listinfo/python-list

split long string in two code lines

2011-06-13 Thread Tracubik
Hi all, newbie question here how can i write code like this: 1 def foo(): 2for index in ... 3for plsdoit in ... 4print "this is a very long string that i'm going to write 5 here, it'll be for sure longer than 80 columns" the only way i've found is to use the "/", but

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 5:11 AM, Ethan Furman wrote: > I suspect Geremy is referring to your "most of the batteries you're used to, > included" comment -- which batteries are missing? Oh! There's a handful of modules that aren't yet available in 3.x, which might surprise someone who's moving from

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 4:58 pm, kafooster wrote: > On 13 Cze, 22:52, Wanderer wrote: > > > > > > > > > > > On Jun 13, 4:41 pm, kafooster wrote: > > > > Wanderer: by *.raw I mean images with .raw extension, pure pixel data > > > without headerhttp://en.wikipedia.org/wiki/Raw_image_format > > > > That is a cl

Re: working with raw image files

2011-06-13 Thread kafooster
On 13 Cze, 22:52, Wanderer wrote: > On Jun 13, 4:41 pm, kafooster wrote: > > > Wanderer: by *.raw I mean images with .raw extension, pure pixel data > > without headerhttp://en.wikipedia.org/wiki/Raw_image_format > > > That is a clear and nice code however I think Image.open cannot > > handle .ra

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 4:41 pm, kafooster wrote: > Wanderer: by *.raw I mean images with .raw extension, pure pixel data > without headerhttp://en.wikipedia.org/wiki/Raw_image_format > > That is a clear and nice code however I think Image.open cannot > handle .raw since i get error > >     image1 = Image.open

Re: working with raw image files

2011-06-13 Thread kafooster
Wanderer: by *.raw I mean images with .raw extension, pure pixel data without header http://en.wikipedia.org/wiki/Raw_image_format That is a clear and nice code however I think Image.open cannot handle .raw since i get error image1 = Image.open("hand.raw", "rb") File "D:\Python27\lib\site-p

Re: working with raw image files

2011-06-13 Thread MRAB
On 13/06/2011 21:20, Wanderer wrote: On Jun 13, 4:08 pm, Wanderer wrote: On Jun 13, 2:18 pm, kafooster wrote: I am working on some medical image data, and I try to look into specific slice of 3d *.raw image. I know voxels are 16 bit int, and dimensions are 352*470*96. I checked it

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 4:08 pm, Wanderer wrote: > On Jun 13, 2:18 pm, kafooster wrote: > > > > > > > > > > > I am working on some medical image data, and I try to look into > > specific slice of   3d  *.raw image. I know voxels are 16 bit int, and > > dimensions are 352*470*96. I checked it in some pro medic

Re: working with raw image files

2011-06-13 Thread Wanderer
On Jun 13, 2:18 pm, kafooster wrote: > I am working on some medical image data, and I try to look into > specific slice of   3d  *.raw image. I know voxels are 16 bit int, and > dimensions are 352*470*96. I checked it in some pro medical image > viewer, it is alright. However, with the code I use,

Infinite recursion in __reduce__ when calling original base class reduce, why?

2011-06-13 Thread Irmen de Jong
Hi, I'm having a rather obscure problem with my custom __reduce__ function. I can't use __getstate__ to customize the pickling of my class because I want to change the actual type that is put into the pickle stream. So I started experimenting with __reduce__, but am running into some trouble.

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Zachary Dziura
For this script, it's guaranteed that whatever tables the script goes through and processes, there will be no duplicate headers. I didn't include functionality to deal with duplicates because there won't be any to begin with! I just wanted to find out the most efficient way of checking for similar

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 13 Jun 2011 00:21:53 -0700, Elena wrote: On 13 Giu, 06:30, Tim Roberts wrote: Studies have shown that even a strictly alphabetical layout works perfectly well, once the typist is acclimated. Once the user is acclimated to move her hands much more (about 40% mo

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Ethan Furman
Chris Angelico wrote: On Tue, Jun 14, 2011 at 4:20 AM, geremy condra wrote: I know that, but I mean what were you talking about before if you weren't talking about cmp? Not sure what you mean. I suspect Geremy is referring to your "most of the batteries you're used to, included" comment -

Re: how to inherit docstrings?

2011-06-13 Thread Carl Banks
On Friday, June 10, 2011 7:30:06 PM UTC-7, Steven D'Aprano wrote: > Carl, I'm not exactly sure what your opposition is about here. Others > have already given real-world use cases for where inheriting docstrings > would be useful and valuable. Do you think that they are wrong? If so, > you shoul

Re: working with raw image files

2011-06-13 Thread Terry Reedy
On 6/13/2011 2:18 PM, kafooster wrote: I am working on some medical image data, and I try to look into specific slice of 3d *.raw image. I know voxels are 16 bit int, and dimensions are 352*470*96. I checked it in some pro medical image viewer, it is alright. However, with the code I use, I di

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Torek
In article Chris Angelico wrote: >If order and duplicates matter, then you want a completely different >diff. I wrote one a while back, but not in Python. ... If order and duplicates matter, one might want to look into difflib. :-) -- In-Real-Life: Chris Torek, Wind River Systems Salt Lake Cit

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 4:20 AM, geremy condra wrote: > I know that, but I mean what were you talking about before if you > weren't talking about cmp? Not sure what you mean. There were other threads before the cmp thread started. That thread started with, if my memory serves me correctly, someth

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread geremy condra
On Mon, Jun 13, 2011 at 10:50 AM, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 3:46 AM, geremy condra wrote: >> On Mon, Jun 13, 2011 at 9:30 AM, Chris Angelico wrote: >>> Ha! That *lengthy* thread started fairly soon after I joined this >>> list. It was highly... informative. I learned a bit

working with raw image files

2011-06-13 Thread kafooster
I am working on some medical image data, and I try to look into specific slice of 3d *.raw image. I know voxels are 16 bit int, and dimensions are 352*470*96. I checked it in some pro medical image viewer, it is alright. However, with the code I use, I display just white noise image.(but worked

Re: Python Card alternatives?

2011-06-13 Thread Wolfgang Keller
> > Are there any other, better solutions? > > Others are e.g.: > - Pypapi > - Camelot > - Kiwi > - Sqlkit > - Gnuenterprise And I've just learned of another one: - QtAlchemy Sincerely, Wolfgang -- Führungskräfte leisten keine Arbeit(D'Alembert) -- http://mail.python.or

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 4:11 AM, Chris Angelico wrote: > The algorithm went > something like this: > > * Start with pointers to beginnings of both lists. PS. It wasn't C with pointers and the like; iirc it actually used array indices as the "pointers". Immaterial to the algorithm though. ChrisA

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 3:58 AM, Dan Stromberg wrote: > > This is a beautiful solution, and yet I feel compelled to mention that it > disregards duplicates within a given list.  If you need duplicate > detection/differencing, it's better to sort each list and then use an > algorithm similar to the

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Dan Stromberg
On Mon, Jun 13, 2011 at 8:09 AM, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 12:58 AM, Zachary Dziura > wrote: > > if set(source_headers) == set(target_headers): > >similar_headers = len(source_headers) > > Since you're making sets already, I'd recommend using set operations - > same_hea

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 3:46 AM, geremy condra wrote: > On Mon, Jun 13, 2011 at 9:30 AM, Chris Angelico wrote: >> Ha! That *lengthy* thread started fairly soon after I joined this >> list. It was highly... informative. I learned a bit about Python, and >> a lot about python-list, from the posts t

Re: dummy, underscore and unused local variables[thanks]

2011-06-13 Thread Tim Johnson
* Tim Johnson [110613 07:58]: > > :) I expect to be edified is so many ways, some > of them unexpected. Thanks for all of the responses and for those which might come later. I'm going to stick with the convention of using a variable beginning with `dummy' and stick that in my snippet gene

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread geremy condra
On Mon, Jun 13, 2011 at 9:30 AM, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 2:04 AM, Steven D'Aprano > wrote: >> On Tue, 14 Jun 2011 01:39:50 +1000, Chris Angelico wrote: >> >>> Python: "Batteries Included". >>> >>> (Although Python 3 is "Most of the batteries you're used to, included".) >>

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Elena
On 13 Giu, 15:19, Steven D'Aprano wrote: > On Mon, 13 Jun 2011 00:21:53 -0700, Elena wrote: > > On 13 Giu, 06:30, Tim Roberts wrote: > >> Studies have shown that even a > >> strictly alphabetical layout works perfectly well, once the typist is > >> acclimated. > > > Once the user is acclimated to

Re: dummy, underscore and unused local variables

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 2:15 AM, Steven D'Aprano wrote: > On Tue, 14 Jun 2011 01:55:04 +1000, Chris Angelico wrote: >> _ is special to IDLE. > > Not just IDLE. Also the vanilla Python command line interpreter. In fact, > you can even find the code that controls it: Sorry, my bad! I should have sa

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 2:04 AM, Steven D'Aprano wrote: > On Tue, 14 Jun 2011 01:39:50 +1000, Chris Angelico wrote: > >> Python: "Batteries Included". >> >> (Although Python 3 is "Most of the batteries you're used to, included".) > > Oh gods, you're not going to bring up sort(cmp=...) again are yo

Re: dummy, underscore and unused local variables

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 2:02 AM, Steven D'Aprano wrote: > On Mon, 13 Jun 2011 07:37:02 -0800, Tim Johnson wrote: > >> Consider the following code: > [...] > > You know Tim, if you hadn't blocked my email address in a fit of pique > over something that didn't even involve you, you would have seen m

Re: [Python-ideas] 'Injecting' objects as function-local constants

2011-06-13 Thread Steven D'Aprano
Did you mean to cross-post this from python-ideas to python-list? On Mon, 13 Jun 2011 16:43:11 +0100, MRAB wrote: > Here's another way: > > def do_work(args): > do_work.pr("doing spam") > spam() > do_work.pr("doing ham") > ham() > # and so on Sure, there are lots of way

Re: dummy, underscore and unused local variables

2011-06-13 Thread Steven D'Aprano
On Tue, 14 Jun 2011 01:55:04 +1000, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 1:37 AM, Tim Johnson > wrote: >> On a related note: from the python interpreter if I do > help(_) >> I get >> Help on bool object: >> >> class bool(int) >>  |  bool(x) -> bool >>  .. >>  I'd welcome commen

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Steven D'Aprano
On Tue, 14 Jun 2011 01:39:50 +1000, Chris Angelico wrote: > Python: "Batteries Included". > > (Although Python 3 is "Most of the batteries you're used to, included".) Oh gods, you're not going to bring up sort(cmp=...) again are you /me ducks and covers -- Steven -- http://mail.python

Re: dummy, underscore and unused local variables

2011-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2011 07:37:02 -0800, Tim Johnson wrote: > Consider the following code: [...] You know Tim, if you hadn't blocked my email address in a fit of pique over something that didn't even involve you, you would have seen my answer to your question on the tu...@python.org mailing list yes

Re: dummy, underscore and unused local variables

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 1:37 AM, Tim Johnson wrote: > On a related note: from the python interpreter if I do help(_) > I get > Help on bool object: > > class bool(int) >  |  bool(x) -> bool >  .. >  I'd welcome comments on this as well. _ is special to IDLE. >>> 1+2 3 >>> _ 3 It's the

Re: dummy, underscore and unused local variables

2011-06-13 Thread Philip Semanchuk
On Jun 13, 2011, at 11:37 AM, Tim Johnson wrote: > NOTE: I see much on google regarding unused local variables, > however, doing a search for 'python _' hasn't proved fruitful. Yes, Google's not good for searching punctuation. But 'python underscore dummy OR unused' might work better. > On a

Re: [Python-ideas] 'Injecting' objects as function-local constants

2011-06-13 Thread MRAB
On 13/06/2011 15:33, Steven D'Aprano wrote: Nick Coghlan wrote: On Mon, Jun 13, 2011 at 5:11 PM, Steven D'Aprano wrote: Function parameters should be kept for actual arguments, not for optimizing name look-ups. Still, the post-** shared state (Jan's option 2) is likely the most obvious way t

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 1:21 AM, Zachary Dziura wrote: > Wow! That was a lot easier than I thought it would be! I guess I > should have done a little bit more research into such operations. > Thanks a bunch!! :) Python: "Batteries Included". (Although Python 3 is "Most of the batteries you're u

dummy, underscore and unused local variables

2011-06-13 Thread Tim Johnson
Consider the following code: for i in range(mylimit): foo() running pychecker gives me a """ Local variable (i) not used """ complaint. If I use for dummy in range(mylimit): ## or for _ in range(mylimit): I get no complaint from pychecker. I would welcome comments on

Re: What is the most efficient way to find similarities and differences between the contents of two lists?

2011-06-13 Thread nn
On Jun 13, 11:06 am, Zachary Dziura wrote: > Hi all. > > I'm writing a Python script that will be used to compare two database > tables. Currently, those two tables are dumped into .csv files, > whereby my code goes through both files and makes comparisons. Thus > far, I only have functionality co

Re: Date2Epoch script

2011-06-13 Thread MRAB
On 13/06/2011 14:03, miguel olivares varela wrote: > Hello > > i try to create a script to convert a date "mmddHHMMSS" as an UNIX timestamp. This is an example of my log file > > cat /tmp/test.log > 20110612112233 > 20110126145535 > 20110126185500 > > here is my code: > > #! /usr/bin/pyth

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Zachary Dziura
On Jun 13, 11:09 am, Chris Angelico wrote: > On Tue, Jun 14, 2011 at 12:58 AM, Zachary Dziura wrote: > > if set(source_headers) == set(target_headers): > >    similar_headers = len(source_headers) > > Since you're making sets already, I'd recommend using set operations - > same_headers is the (le

What is the most efficient way to find similarities and differences between the contents of two lists?

2011-06-13 Thread Zachary Dziura
Hi all. I'm writing a Python script that will be used to compare two database tables. Currently, those two tables are dumped into .csv files, whereby my code goes through both files and makes comparisons. Thus far, I only have functionality coded to make comparisons on the headers to check for sim

Re: What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Chris Angelico
On Tue, Jun 14, 2011 at 12:58 AM, Zachary Dziura wrote: > if set(source_headers) == set(target_headers): >    similar_headers = len(source_headers) Since you're making sets already, I'd recommend using set operations - same_headers is the (length of the) intersection of those two sets, and differ

What is the most efficient way to compare similar contents in two lists?

2011-06-13 Thread Zachary Dziura
similar_headers = 0 different_headers = 0 source_headers = sorted(source_mapping.headers) target_headers = sorted(target_mapping.headers) # Check if the headers between the two mappings are the same if set(source_headers) == set(target_headers): similar_headers = len(source_headers) else:

Re: Function declarations ?

2011-06-13 Thread Steven D'Aprano
On Sun, 12 Jun 2011 19:38:42 +, Andre Majorel wrote: > On 2011-06-10, Asen Bozhilov wrote: >> Andre Majorel wrote: >> >>> Is there a way to keep the definitions of the high-level functions at >>> the top of the source ? I don't see a way to declare a function in >>> Python. >> >> Languages wi

Re: the stupid encoding problem to stdout

2011-06-13 Thread Chris Angelico
2011/6/14 Sérgio Monteiro Basto : > And see, I can send ascii and utf-8 to utf-8 output and never have problems, > but if I send ascii and utf-8 to ascii files sometimes got encode errors. > If something fits inside 7-bit ASCII, it is by definition valid UTF-8. This is not a coincidence. Those ho

RE: Date2Epoch script

2011-06-13 Thread miguel olivares varela
Hi Gary, thank you for your answer but i'm using int in my file cat /tmp/test.log201106121122332011012614553520110126185500 the problem is related to variable "line_log" that i use in the function, file_brut = open(log_files_in, 'r')line_log = file_brut.readline()while line_log:

Re: the stupid encoding problem to stdout

2011-06-13 Thread Sérgio Monteiro Basto
Ian Kelly wrote: > If you want your output to behave that way, then all you have to do is > specify that with an explicit encode step. ok >> If we want we change default for whatever we want, but without this >> "default change" Python should not change his behavior depending on >> output. yeah

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Rustom Mody
On Jun 13, 6:19 pm, Steven D'Aprano wrote: > Even if we accept that Dvorak is an optimization, it's a micro- > optimization. +1 Dvorak -- like qwerty and any other keyboard layout -- assumes the computer is a typewriter. This means in effect at least two constraints, necessary for the typewrite

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Pascal J. Bourguignon
Steven D'Aprano writes: > The actual physical cost of typing is a small part of coding. > Productivity-wise, optimizing the distance your hands move is worthwhile > for typists who do nothing but type, e.g. if you spend their day > mechanically copying text or doing data entry, then increasing

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2011 00:21:53 -0700, Elena wrote: > On 13 Giu, 06:30, Tim Roberts wrote: >> Studies have shown that even a >> strictly alphabetical layout works perfectly well, once the typist is >> acclimated. > > Once the user is acclimated to move her hands much more (about 40% more > for Qwe

Re: Deditor 0.3.0

2011-06-13 Thread TheSaint
Kruptein wrote: > Deditor is a text-editor for python developers, I'd like a editor that runs programs on trace and highlight the line(s) where it step into. Obviously, if running at normale speed it will disable or if the speed is reduced it will works. -- goto /dev/null -- http://mail.pyth

Date2Epoch script

2011-06-13 Thread miguel olivares varela
Hello i try to create a script to convert a date "mmddHHMMSS" as an UNIX timestamp. This is an example of my log file cat /tmp/test.log201106121122332011012614553520110126185500 here is my code: #! /usr/bin/python import osimport sysimport globimport reimport time dir_log = "/tmp"#loop to

Deditor 0.3.0

2011-06-13 Thread Kruptein
Hey, I just released a new version of my pythonic text-editor; Short description: Deditor is a text-editor for python developers, deditor offers a python interpreter, code analyzing, checking of errors on save, run your code directly from the editor or load your module in the interpreter for dire

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Chris Angelico
On Mon, Jun 13, 2011 at 6:42 PM, Yang Ha Nguyen wrote: > Could you show which studies?  Do they do research just about habit or > other elements (e.g. movement rates, comfortablility, ...) as well? > Have they ever heard of RSI because of repetitive movements? And did any of the studies take into

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Yang Ha Nguyen
On Jun 13, 11:30 am, Tim Roberts wrote: > Xah Lee wrote: > > >(a lil weekend distraction from comp lang!) > > >in recent years, there came this Colemak layout. The guy who created > >it, Colemak, has a site, and aggressively market his layout. It's in > >linuxes distro by default, and has become

Re: Permission denied and lock issue with multiprocess logging

2011-06-13 Thread kracekumar ramaraju
In case the File System is NFTS you might get this error because of user mapping.There may be some other issues too. -- http://mail.python.org/mailman/listinfo/python-list

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Elena
On 13 Giu, 06:30, Tim Roberts wrote: > Studies have shown that even a > strictly alphabetical layout works perfectly well, once the typist is > acclimated. Once the user is acclimated to move her hands much more (about 40% more for Qwerty versus Dvorak), that is. -- http://mail.python.org/mailm