Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread John Bokma
"softwindow" <[EMAIL PROTECTED]> wrote: > Carl Banks is right Did he write to check out: http://groups.google.com/support/bin/answer.py?answer=14213 ? Why didn't you do so? -- John MexIT: http://johnbokma.com/mexit/ personal page:

Re: Getting URL's

2006-05-18 Thread Paul McGuire
"defcon8" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How do I get all the URL's in a page? > pyparsing comes with a simple example that does this, too. -- Paul Download pyparsing at http://sourceforge.net/projects/pyparsing -- http://mail.python.org/mailman/listinfo/python-l

Re: Getting URL's

2006-05-18 Thread defcon8
Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-18 Thread PoD
On Thu, 18 May 2006 10:33:58 +0200, Christophe wrote: > PoD a écrit : >> On Wed, 17 May 2006 21:37:14 +0800, Andy Sy wrote: >> >> >>>If tabs are easily misunderstood, then they are a MISfeature >>>and they need to be removed. >>> From the Zen of Python: >>> >>>"Explicit is better than implic

Re: who can give me the detailed introduction of re modle?

2006-05-18 Thread Gary Herron
softwindow wrote: >the re module is too large and difficult to study > >i need a detaild introduction. > > > That's not the kind of question that's likely to get a useful response from an all volunteer newsgroup community, even one with as friendly a reputations as this one. Here's my suggest

Re: Tabs are *MISUNDERSTOOD*, *EVIL* AND *STUPID*, end of discussion. (Re: Tabs versus Spaces in Source Code)

2006-05-18 Thread PoD
On Thu, 18 May 2006 08:30:03 +, Duncan Booth wrote: > PoD wrote: >> How many levels of indentation does 12 spaces indicate? >> It could be 1,2,3,4,6 or 12. If you say it's 3 then you are >> _implying_ that each level is represented by 4 spaces. > > By reading the code I can see how many leve

Re: Getting URL's

2006-05-18 Thread Ju Hui
use htmlparser or regular expression -- http://mail.python.org/mailman/listinfo/python-list

Getting URL's

2006-05-18 Thread defcon8
How do I get all the URL's in a page? -- http://mail.python.org/mailman/listinfo/python-list

Re: import woe

2006-05-18 Thread vaibhav
Hi bob, 1. decide the directory which will be your root folder containing foo [/home/ROOT/foo/] 2. work out your directory structure relative to this root folder here it is ->ROOT->foo->car.py ->bar->far.py ->bar->jar.py 3. a

Re: Which is More Efficient?

2006-05-18 Thread Fredrik Lundh
Dustan wrote: > Obviously it takes a geek to know you have to time it, as opposed to > any other task you could be talking about. wasn't the original question "my program uses a lot of CPU, and I want to make it more efficient" ? what does "a lot of CPU" and "more efficient" mean to you, and h

Re: newb: comapring two strings

2006-05-18 Thread Peter Otten
manstey wrote: > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is ('i','e') > > But if there was str1=yiqtol and str2=yaqtel,

Re: number of different lines in a file

2006-05-18 Thread Fredrik Lundh
r.e.s. wrote: > BTW, the first thing I tried was Fredrik Lundh's program: > > def number_distinct(fn): > return len(set(s.strip() for s in open(fn))) > > which worked without the square brackets. Interesting that > omitting them doesn't seem to matter. a for loop inside square brackets is

Re: import woe

2006-05-18 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > hello, > > i have a problem. i would like to import python files above and below > my current directory. > > i'm working on /home/foo/bar/jar.py > > i would like to import /home/foo/car.py and >/home/foo/bar/far.py > > how can i do this? $ cat >>

who can give me the detailed introduction of re modle?

2006-05-18 Thread softwindow
the re module is too large and difficult to study i need a detaild introduction. -- http://mail.python.org/mailman/listinfo/python-list

Re: import woe

2006-05-18 Thread Gary Herron
[EMAIL PROTECTED] wrote: >hello, > >i have a problem. i would like to import python files above and below >my current directory. > >i'm working on /home/foo/bar/jar.py > >i would like to import /home/foo/car.py and > /home/foo/bar/far.py > >how can i do this? > >thank you, >

import woe

2006-05-18 Thread gsocks
hello, i have a problem. i would like to import python files above and below my current directory. i'm working on /home/foo/bar/jar.py i would like to import /home/foo/car.py and /home/foo/bar/far.py how can i do this? thank you, bob ps: i want to scale, so i do not wa

Re: comapring two strings

2006-05-18 Thread Paul Rubin
"Paul McGuire" <[EMAIL PROTECTED]> writes: > >>> def offByNoMoreThanOneCharacter(a,b): > ... return len(a)==len(b) and sum(map(lambda (x,y): x==y, zip(a,b))) >= > len(a)-1 Yikes! How about (untested): def offByNoMoreThanOneCharacter(a,b): return len(a)==len(b) and \ len([i for i i

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
import os import zipfile z = zipfile.ZipFile(r"c:\text.zip",mode="w",compression=zipfile.ZIP_DEFLATED) cwd = os.getcwd() try: for dirpath,dirs,files in os.walk(cwd): for file in files: z_path = os.path.join(dirpath,file) start = cwd.rfind(os.sep)+1 z.

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
aha now it's right like this: import os import zipfile z = zipfile.ZipFile(r"c:\text.zip",mode="w",compression=zipfile.ZIP_DEFLATED) cwd = os.getcwd() try: for dirpath,dirs,files in os.walk(cwd): for file in files: z_path = os.path.join(dirpath,file) start = cwd

Re: how could I get all email address in a html page?

2006-05-18 Thread George Sakkis
dongdong wrote: > how could I get all email address in a html page? Have any modle can do > this? > like the htmldata.urlextract . As if there arent' enough spammers already... -- http://mail.python.org/mailman/listinfo/python-list

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
Carl Banks is right -- http://mail.python.org/mailman/listinfo/python-list

how could I get all email address in a html page?

2006-05-18 Thread dongdong
how could I get all email address in a html page? Have any modle can do this? like the htmldata.urlextract . -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie append() question

2006-05-18 Thread Gerard Flanagan
Brian Blazer wrote: > I promise that this is not homework. I am trying to self teach here > and have run into an interesting problem. I have created a method > that asks for a class name and then is supposed to add it to classes > []. Here is a snippet: > > def getCurrentClasses(): > cl

Re: comapring two strings

2006-05-18 Thread Paul McGuire
"manstey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread John Bokma
"softwindow" <[EMAIL PROTECTED]> wrote: > aha > we want to do it with python > don't use ant :-D I want to do a lot with Perl, but sometimes it's better to use the right tool for the job. And I think that Ant is better at for what I use it compared to a home brew tool I could make. Be careful

Re: Python trig precision problem

2006-05-18 Thread Robert Kern
Cary West wrote: > Hello all, having a small problem with a trig routine using python math > module. This code is designed to convert geodetic coordinates to lambert > conformal conic coordinates. It implements the formulas found at > http://mathworld.wolfram.com/LambertConformalConicProjection.

Re: Reference Counts

2006-05-18 Thread raghu
Hmm... I tried the gc.collect(). It aint helping. The reference count still keeps growing till 5 after it which it drops. As you said, it is not gonna hurt right away. The only downside in that mysterious up and down thingie is that , we could get to a wrong conclusion about a leak, if we ran the

Re: Programming language productivity

2006-05-18 Thread John Bokma
Connelly Barnes <[EMAIL PROTECTED]> wrote: > http://barnesc.blogspot.com/2006/05/programming-language-productivity.h > tml C:3 hours to write the program, 5 hours to track down the memory leaks Java: 4 hours to write the program, 6 hours to get all the exception handling right C++ 5

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
aha we want to do it with python don't use ant -- http://mail.python.org/mailman/listinfo/python-list

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
my code can work, like below: import os import zipfile z = zipfile.ZipFile(r"c:\text.zip",mode="w",compression=zipfile.ZIP_DEFLATED) cwd = os.getcwd() try: for dirpath,dirs,files in os.walk(cwd): for file in files: z_path = os.path.join(dirpath,file) z.write(z_p

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread John Bokma
"pac" <[EMAIL PROTECTED]> wrote: > I'm preparing to distribute a Windows XP Python program and some > ancillary files, > and I wanted to put everything in a .ZIP archive. It proved to be > inordinately > difficult and I thought I would post my solution here. Is there a > better one? heresy may

Re: newb: comapring two strings

2006-05-18 Thread johnzenger
manstey wrote: > Hi, > > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. You want zip. def diffbyonlyone(string1, string2): diffcount = 0 for c1, c2 in zip(string1, string2): if c1 != c2:

Programming language productivity

2006-05-18 Thread Connelly Barnes
Hi Python folks, I created a summary PDF of two studies on programming language productivity: http://barnesc.blogspot.com/2006/05/programming-language-productivity.html One notes that Python and Perl are the two best languages by the "number of hours to solve problem" metric. I ran into the

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread Carl Banks
pac wrote: > Suppose you have a set of files in a directory c:\a\b and some > additional > files in c:\a\b\subdir. Using a Python script, you would > like to make a Windows-readable archive (.zip) that preserves this > directory structure, and where the root directory of the archive is > c:\a\b.

Re: Script to make Windows XP-readable ZIP file

2006-05-18 Thread softwindow
i am in win2000 "z.write(a_path,a_path)" may change to "z.write(a_path)" but the dirpath is not in zipfile who can tell me? -- http://mail.python.org/mailman/listinfo/python-list

Re: number of different lines in a file

2006-05-18 Thread pac
A generator expression can "share" the parenthesis of a function call. The syntax is explained in PEP 289, which is also in "What's new" in the Python 2.4 docs. Nice line of code! -- http://mail.python.org/mailman/listinfo/python-list

Script to make Windows XP-readable ZIP file

2006-05-18 Thread pac
I'm preparing to distribute a Windows XP Python program and some ancillary files, and I wanted to put everything in a .ZIP archive. It proved to be inordinately difficult and I thought I would post my solution here. Is there a better one? Suppose you have a set of files in a directory c:\a\b an

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > But if a 1 person, using 1 language, with the same set of tools withing > a 3 month period implements the same algo without bugs - I'll bet you > the shorter one was theone written second. You might lose that bet very often. I see often that additi

Re: Quoting relevant material for response (was: Re: python vs perl lines of code)

2006-05-18 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > quoting mechanism is available on the web interface and I haven't found > it - I'd love to know how to use it. http://groups.google.com/support/bin/answer.py?answer=14213 > Also i use the threaded view on > the web client, so I have little trouble

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > Terry Hancock wrote: > >> But the real point is that no one here can make >> any reasonably objective assessment of whether your "data" is >> meaningful unless you post examples. That's what creates the >> hostility, I think. > > Fair enough. But see

Newbie append() question

2006-05-18 Thread Brian Blazer
I promise that this is not homework. I am trying to self teach here and have run into an interesting problem. I have created a method that asks for a class name and then is supposed to add it to classes []. Here is a snippet: def getCurrentClasses(): classes = [] print 'P

Re: Quoting relevant material for response (was: Re: python vs perl lines of code)

2006-05-18 Thread [EMAIL PROTECTED]
Thanks Ben, I actually don't spend a whole lot of time on newsgroups. I don't use my gmail account and use the groups thru the web interface. If that quoting mechanism is available on the web interface and I haven't found it - I'd love to know how to use it. Also i use the threaded view on the w

Re: newb: comapring two strings

2006-05-18 Thread Serge Orlov
manstey wrote: > Hi, > > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is ('i','e') > > But if there was str1=yiqtol and str2=yaqt

Re: python vs perl lines of code

2006-05-18 Thread [EMAIL PROTECTED]
As a coder, I wouldn't normally use the two different conventions. you show in your examples. So it does little to tell us about the importance or lack there of line count. Let me state clearly - to use line count , in absence of other considerations, IS meaningless. But if a 1 person, using 1

Quoting relevant material for response (was: Re: python vs perl lines of code)

2006-05-18 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hmm, and I thought it was respectful to actually address someone you > are talking to. On Usenet, it's respectful to all readers if you give a short quoted passage from the message you're responding to, so we can follow the discussion with context

Re: Opensource vs Microsoft, Wat do you think about opensource?

2006-05-18 Thread Ben Finney
"cracker" <[EMAIL PROTECTED]> writes: > So wat do u think about opensource software? and what is your view > about Microsoft share your views with us! > and let us know what do you think about opensource software. > > http://www.desi-tek.com/forum/index.php?showtopic=394&st= Please don't spam her

Re: python vs perl lines of code

2006-05-18 Thread [EMAIL PROTECTED]
Hmm, and I thought it was respectful to actually address someone you are talking to. Must every statement be a reaction to a quotable comment? In any case, I realize I was completley wrong. Please allow me to retract my statement. -- http://mail.python.org/mailman/listinfo/python-list

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > In theory it should work out of the box. OS X terminal should set > > enviromental variable LANG=en_US.utf-8, then ssh should transfer this > > variable to Linux and python will know that your terminal is utf-8. >

Re: python vs perl lines of code

2006-05-18 Thread Edward Elliott
Terry Hancock wrote: > But the real point is that no one here can make > any reasonably objective assessment of whether your "data" is > meaningful unless you post examples. That's what creates the > hostility, I think. Fair enough. But see my other posts on why I'm not interested in objective

Re: Subprocess or Process or OMG!!

2006-05-18 Thread blair . bethwaite
rh0dium wrote: > This has several problems - least of which args aren't working Has > anyone really tried this approach? No, they just wrote the code for the hell of it. :) Seriously though, you may want to consider using the popen2 module. Then you'll be able to wait on the subprocess to r

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > In article <[EMAIL PROTECTED]>, > > > > Robert Kern <[EMAIL PROTECTED]> wrote: > > >

Re: newb: comapring two strings

2006-05-18 Thread Justin Azoff
manstey wrote: > Hi, > > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is ('i','e') something like this maybe? >>> str1='yaqtil'

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > >>Ron Garret wrote: >> >>>I'm using an OS X terminal to ssh to a Linux machine. >> >>Click on the "Terminal" menu, then "Window Settings...". Choose "Display" >>from >>the combobox. At the bottom you w

Re: python vs perl lines of code

2006-05-18 Thread Terry Hancock
Michael Tobis wrote: >John Bokma wrote: >>"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >>>Ok I'm going to end with a flamebait - but I would posit, ALL OTHER >>>THINGS BEING EQUAL - that a smaller number of characters and lines in >>>code is more maintainable than larger number of characters and

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > > > Ron Garret wrote: > > > > > > > > > I forgot to mention: > > > > > > > > > sy

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
"Michael Tobis" <[EMAIL PROTECTED]> wrote: >> According to your silly rule the shortest book on a subject would be >> the best. Now why is that false? > > No, according to the rule, the shorter of two books **containing the > same information** would be best. What is "the same information"? > I

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > John, > Your hilarious... If you learn to quote, you don't need to address me. But it's beyond you I understand, so bye. -- John MexIT: http://johnbokma.com/mexit/ personal page: ht

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Robert Kern <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > Click on the "Terminal" menu, then "Window Settings...". Choose "Display" > from > the combobox. At the bottom you will see a combobox titl

Re: number of different lines in a file

2006-05-18 Thread r.e.s.
"Tim Chase" <[EMAIL PROTECTED]> wrote ... > 2) use a python set: > > s = set() > for line in open("file.in"): > s.add(line.strip()) > return len(s) > > 3) compact #2: > > return len(set([line.strip() for line in file("file.in")])) > > or, if stripping the lines isn't a concern, it can just be

Re: python vs perl lines of code

2006-05-18 Thread Michael Tobis
> According to your silly rule the shortest book on a subject would be the > best. Now why is that false? No, according to the rule, the shorter of two books **containing the same information** would be best. I don't think I'm a zealot. The original quote said "all else equal". Certainly legible

Opensource vs Microsoft, Wat do you think about opensource?

2006-05-18 Thread cracker
Microsoft has dominated the world of computing for many years, with its heavily guarded 'code' being beyond reach to many in the developing nations. In some of the poorest countries the cost of upgrading an operating system to keep up with the rest of the world amounts to a year's wages, and there

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > corroborations. It's like a guy saying he saw a cloud that looks like > a python. The cloud's gone now, but other people can watch other > clouds and report what they see. Good comparison, now does the cloud gazing make them better programmers? -- J

Re: python vs perl lines of code

2006-05-18 Thread [EMAIL PROTECTED]
John, Your hilarious... I mean it, and as a compliment. But seriously, I think your taking a discussion about trends and twisting them to be about absolutes. Maybe others are too. But, forgive the cheesy paraphrasing, but the solution should be as simple as possible, and no simpler. There is no

Re: WTF? Printing unicode strings

2006-05-18 Thread Paul Boddie
Ron Garret wrote: > > But what about this: > > >>> f2=open('foo','w') > >>> f2.write(u'\xFF') > Traceback (most recent call last): > File "", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in > position 0: ordinal not in range(128) > >>> > > That should have nothi

realization: no assignments inside expressions

2006-05-18 Thread Simon Burton
I've been doing a little c programming again (ouch!) and it's just hit me why python does not allow assignment inside expressions (as in c): because it is absolutely essential that all assignments are as visible as possible. In python the assignment is the declaration; when declarations are as che

Re: python vs perl lines of code

2006-05-18 Thread Edward Elliott
Ben Finney wrote: > Until we get the code to examine independently, all we have is an > anecdote. Thus the comparison to UFO sightings. Except UFO sightings comprise a large body of data containing a vast number of known false reports and others that appear to be in the same vein with no verified

Re: python vs perl lines of code

2006-05-18 Thread Edward Elliott
Ben Finney wrote: > Until we get the code to examine independently, all we have is an > anecdote. Thus the comparison to UFO sightings. Except UFO sightings comprise a large body of data containing a vast number of known false reports and others that appear to be in the same vein with no verified

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > I'm using an OS X terminal to ssh to a Linux machine. Click on the "Terminal" menu, then "Window Settings...". Choose "Display" from the combobox. At the bottom you will see a combobox title "Character Set Encoding". Choose "Unicode (UTF-8)". > But what about this: > f2=

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
"Michael Tobis" <[EMAIL PROTECTED]> wrote: > The relevant corrolary is, "he programs best who programs least". I > would have thought this was conventional wisdom among all dynamic > language communities. Isn't that the whole point? By all means go back > to C++ if you like to have three lines for

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
Edward Elliott <[EMAIL PROTECTED]> wrote: > John Bokma wrote: > >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >>> It seems to me the discussion could actually be beneficial. If >>> several different coders gave similar responses, ie code >>> line/character count comparisons, we might be able

Re: python vs perl lines of code

2006-05-18 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > THe interest, on my part, is more academic than practical. I find > data, particularly "dirty" data very fascinating Me less, maybe that's why I originally had gg kill filed... I prefer quotes. -- John MexIT: http:

Re: WTF? Printing unicode strings

2006-05-18 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > Robert Kern <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > > I forgot to mention: > > > > > > > sys.getdefaultencoding() > > > > > > > > 'u

Re: Subprocess or Process or OMG!!

2006-05-18 Thread Robert Kern
rh0dium wrote: > Needless to say this is much more complex than what I was "hoping" for. > Has anyone solved this in a generic approach.. > > #!/usr/bin/env python > > import os,sys,string > import subprocess > > argc = len(sys.argv) > > # Yes I move all exe's to the .bin

Re: Python trig precision problem

2006-05-18 Thread Roger Miller
If I were you I would see if I could get the Perl script referred to on the ERIN web page. You might find that the discrepancy is something as simple as a slightly different value for the Earth's radius. And by the way, math.radians() might be a bit clearer than the pi/180 business. -- http://mai

Re: newb: comapring two strings

2006-05-18 Thread Diez B. Roggisch
> Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is ('i','e') > > But if there was str1=yiqtol and str2=yaqtel, I am not interes

Re: python vs perl lines of code

2006-05-18 Thread Michael Tobis
John Bokma wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > Ok I'm going to end with a flamebait - but I would posit, ALL OTHER > > THINGS BEING EQUAL - that a smaller number of characters and lines in > > code is more maintainable than larger number of characters and lines in > > the c

newb: comapring two strings

2006-05-18 Thread manstey
Hi, Is there a clever way to see if two strings of the same length vary by only one character, and what the character is in both strings. E.g. str1=yaqtil str2=yaqtel they differ at str1[4] and the difference is ('i','e') But if there was str1=yiqtol and str2=yaqtel, I am not interested. can a

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > > > I forgot to mention: > > > > > sys.getdefaultencoding() > > > > > > 'utf-8' > > > > A) You shouldn't be able to do that. > > What can I say? I can. > > > B) Don't do

Re: Feature request: sorting a list slice

2006-05-18 Thread Heiko Wundram
Am Donnerstag 18 Mai 2006 22:13 schrieb Raymond Hettinger: > This is a false optimization. The slicing steps are O(n) and the sort > step is O(n log n) unless the data has some internal structure that > Timsort can use to get closer to O(n). > > If you implemented this and timed in it real apps, I

Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-18 Thread Bruno Desthuilliers
glomde a écrit : > So I read trough all of the make PEP and make would support the syntax > i propose.. > and more generic and better in many ways. Since it was rejected I have > to ... bug the BDFL until he reconsiders its position. -- http://mail.python.org/mailman/listinfo/python-list

Subprocess or Process or OMG!!

2006-05-18 Thread rh0dium
Hi all, Here I was happily coming to working thinking - OK I need to create a wrapper for a tool (UNIX) which does nothing but lauch the end tool and send a sql instert letting the db know the tool was launched (Can we say Big Brother..). Some of the tools are very long running with lots of data

Re: Strange error

2006-05-18 Thread BartlebyScrivener
Sorry, Never mind. wtf.func_defaults Thanks for the examples. Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: python vs perl lines of code

2006-05-18 Thread [EMAIL PROTECTED]
Thank you Ed for your eloquent statement. From now on I will avoid humor in posts on this thread , my previous attempts were not useful or productive - and I think there is something interesting in this discussion. It might be interesting to come up with a coding assignment for developers to atte

Re: number of different lines in a file

2006-05-18 Thread Andrew Robert
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L

Re: Question about exausted iterators

2006-05-18 Thread Terry Reedy
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Instead of saying that all works as intended could you be a little >helpful and tell me why it was intended in such an obviously broken way >instead ? I answered both your explicit and implied questions in good faith. But

Re: Which is More Efficient?

2006-05-18 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > >> 2. Measure it. > > > > Tell me how and I will; I'm not nearly that much of a geek > > unfortunately. > > do you have to be a geek to be able to measure how much time > something takes? Obviously it takes a geek to know you have to time it, as opposed to

Re: number of different lines in a file

2006-05-18 Thread Tim Chase
> I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. A few ideas: 1) the shell way: bash$ sort file.in | uniq | wc -l This doesn't strip whitespace...a little sed magic would strip off whitespace for you: bash$ sed

Re: Which is More Efficient?

2006-05-18 Thread Fredrik Lundh
Dustan wrote: >> 2. Measure it. > > Tell me how and I will; I'm not nearly that much of a geek > unfortunately. do you have to be a geek to be able to measure how much time something takes? -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-18 Thread glomde
So I read trough all of the make PEP and make would support the syntax i propose.. and more generic and better in many ways. Since it was rejected I have to continue live with my preprocessor... >From the make PEP . Allowing this sort of customization could allow XML to be written without rep

Re: number of different lines in a file

2006-05-18 Thread Bill Pursell
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L =

Re: Which is More Efficient?

2006-05-18 Thread Dustan
Fredrik Lundh wrote: > Dustan wrote: > > > I have a program that uses up a lot of CPU and want to make it is > > efficient as possible with what I have to work with it. So which of the > > following would be more efficient, knowing that l is a list and size is > > a number? > > > > l=l[:size] > >

Reminder: call for proposals "Python Language and Libraries Track" for Europython 2006

2006-05-18 Thread Samuele Pedroni
Registration for Europython (3-5 July) at CERN in Geneva is now open, if you feel submitting a talk proposal there's still time until the 31th of May. If you want to talk about a library you developed, or you know well and want to share your knowledge, or about how you are making the best out of P

Re: Which is More Efficient?

2006-05-18 Thread Ben Finney
"Dustan" <[EMAIL PROTECTED]> writes: > John Machin wrote: > > 2. Measure it. > > Tell me how and I will; I'm not nearly that much of a geek > unfortunately. You've already been told. Here it is again: http://docs.python.org/lib/profile.html> -- \ "I don't know half of you half as we

Re: Feature request: sorting a list slice

2006-05-18 Thread George Sakkis
Fredrik Lundh wrote: > George Sakkis wrote: > >> It would be useful if list.sort() accepted two more optional >> parameters > > > useful for what? what's the use case ? > > > Although there is a use case (see below), I don't think it's strictly necessary in this case. Arguments to add it: - Don

Re: number of different lines in a file

2006-05-18 Thread Fredrik Lundh
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L

Re: Which is More Efficient?

2006-05-18 Thread Dustan
John Machin wrote: > 1. Think about it. The first case will make a new list and copy "size" > *objects. When the assignment happens, the old list has its reference > count decremented. Not very memory-friendly. The second case merely > truncates the existing list in situ. Bit hard to imagine how t

Re: number of different lines in a file

2006-05-18 Thread Ben Finney
"r.e.s." <[EMAIL PROTECTED]> writes: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. I'd generalise it by allowing the caller to pass any iterable set of items. A file handle can be iterated this way, but so can an

Re: python vs perl lines of code

2006-05-18 Thread Edward Elliott
John Bokma wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> It seems to me the discussion could actually be beneficial. If several >> different coders gave similar responses, ie code line/character count >> comparisons, we might be able to see if there is a trend of any sort - >> the mo

Re: number of different lines in a file

2006-05-18 Thread Larry Bates
r.e.s. wrote: > I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. > > On my PC, this little program just goes to never-never land: > > def number_distinct(fn): > f = file(fn) > x = f.readline().strip() > L

Re: WTF? Printing unicode strings

2006-05-18 Thread Robert Kern
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > >>Ron Garret wrote: >> >>>I forgot to mention: >>> >>> >>sys.getdefaultencoding() >>> >>>'utf-8' >> >>A) You shouldn't be able to do that. > > What can I say? I can. See B). >>B) Don't do that.

  1   2   3   >