Re: send an email with picture/rich text format in the body

2006-05-29 Thread Edward Elliott
Ten wrote: > Sorry for the rant, good luck to the guy if he's solved his problem, > but damn, that "90% so let's not bother doing things properly" stuff makes > my blood boil. You must really hate browsing the web then. :) -- Edward Elliott UC Berkeley School of La

Re: Finding a lost PYTHONPATH with find

2006-05-29 Thread Edward Elliott
is > redundant since I think find searches breadth-first by default. ??? maxdepth determines how deep the search will look, not the order the search occurs. Your search only find things within 3 levels of the root, unless your directory tree goes no deeper than that (very unlikely) the maxdep

Re: HTMLParser chokes on bad end tag in comment

2006-05-29 Thread Edward Elliott
won't work</EM>") In JavaScript, this code can be expressed legally by hiding the ETAGO delimiter before an SGML name start character: document.write ("<EM>This will work<\/EM>") Guess you learn something new every day. Too bad the

Re: Ricerca Programmatore Python

2006-05-29 Thread Edward Elliott
g the relative resume to me. I hope of to have made what appreciate postando this announcement. In contrary case, I make excuses myself for the disturbance. Salutes, Giandomenico Sica -- Edward Elliott UC Berkeley School of Law (Boalt Hall) complangpython at eddeye dot net -- http://mail.pyt

Re: Need C# Coding for MD5 Algorithm...

2006-05-29 Thread Edward Elliott
orrectly as it is. Leave it to the experts and use a library. -- Edward Elliott UC Berkeley School of Law (Boalt Hall) complangpython at eddeye dot net -- http://mail.python.org/mailman/listinfo/python-list

Re: Uniquifying a list?

2006-04-18 Thread Edward Elliott
You could do >>> uniq = [x for x in set(myList)] but that's not really any different than what you already have. This almost works: >>> uniq = [x for x in myList if x not in uniq] except the r-val uniq isn't updated after each iteration. Personally I think list(set(myList)) is as optimal as

multiline comments

2006-04-18 Thread Edward Elliott
At the risk of flogging a dead horse, I'm wondering why Python doesn't have any multiline comments. One can abuse triple-quotes for that purpose, but that's obviously not what it's for and doesn't nest properly. ML has a very elegant system for nested comments with (* and *). Using an editor

temporary scope change

2006-04-18 Thread Edward Elliott
The only time I miss block delimiters in Python is when I want to temporarily change the scope of a block. Suppose I have this code: for x in list1: i += 1 for y in list2: print x * i Ignore the semantics for the moment (yes the code is suboptimal). Say I need to disable th

Re: temporary scope change

2006-04-18 Thread Edward Elliott
Michael Spencer wrote: > Just replace: > for y in list2: > with: > if True: Of course. I knew it would be blindingly obvious. Sometimes you just can't shake the blinders off though. Thanks. > Note that neither the `if` nor the `for` statement actually creates a > new scope. Good cat

Re: multiline comments

2006-04-18 Thread Edward Elliott
Atanas Banov wrote: > want to comment block of code? use tripple-quotes. does not nest? ahhh, > maybe it's time to get rid of that block you commented out a month ago > "just in case the new code doesnt work". > > that gives you incentive to tidy up. don't be a code slob... don't > leave a mess fo

Re: multiline comments

2006-04-18 Thread Edward Elliott
Ben Finney wrote: > And/or switch to an editor that can perform editing operations on a > range of lines. I'm not unsympathetic to this point of view, as I would feel hamstrung without my vim. It's more that I object to the paternalism of telling people they have to use such an editor. There a

Re: multiline comments

2006-04-18 Thread Edward Elliott
Ben Finney wrote: > Indeed. Using revision control means never needing to comment out > blocks of code. Typing (* and *) on a few line will always be quicker, easier, and less confusing than any rcs diffs/restores. Once you delete the code you can no longer see it or add pieces back in without

Re: multiline comments

2006-04-19 Thread Edward Elliott
Duncan Booth wrote: > Want to comment out a block of code in C++? The only (nearly) reliable way > is to insert single-line comments down the block. You can't use a block > comment if there are any other block comments inside the code you want to > block out. As Roel said, #if 0 is the standard

Re: multiline comments

2006-04-19 Thread Edward Elliott
Sion Arrowsmith wrote: > Really? Under what circumstances is it easier to see what's going on > with start/end comments than with comment-to-end-of-line? Off the top of my head: 1. The code is usually easier to read as # can obscure the first token on the line. This can be alleviated by leaving

Re: multiline comments

2006-04-19 Thread Edward Elliott
Sion Arrowsmith wrote: > Jorge Godoy <[EMAIL PROTECTED]> wrote: >>Is it harder to remove "n" lines of code commented out with "#" than "n" >>lines of multiline commented code? How? > > I'd say it's harder to remove the latter, due to having to search for > the end of comment sequence, rather tha

Re: multiline comments

2006-04-19 Thread Edward Elliott
Jorge Godoy wrote: > Edward Elliott wrote: > Try using Subversion. You can work and make diffs disconnected from the > network. rcs isn't the issue. I'm already assuming a local store, a networked one just makes my argument even easier. >>I'm not saying neste

Re: multiline comments

2006-04-19 Thread Edward Elliott
Peter Tillotson wrote: > discouraged except where vital. Perhaps we should make them really hard > and elegant - mandate latex/mathml markup so good editors can display > the equations we are implementing :-) I like this guy already! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: multiline comments

2006-04-19 Thread Edward Elliott
Jorge Godoy wrote: > You can use either """ or '''. I don't keep changing them in my code, so I > can always use the other type (usually I use " so for commenting things out > I'd use ') to do that. It's close, only problem is it doesn't nest. It'll have to be good enough for now. >>Forcing p

Re: perspective on ruby

2006-04-20 Thread Edward Elliott
RK wrote: > I just don't get it. The scripted object-oriented clean programming > language is done. Nothing's ever done except LISP. There's always room for experimentation and improvement. > I'm more than willing to supprt RoR if it's being sold as the popular > alternative to .NET programmin

Re: multiline comments

2006-04-20 Thread Edward Elliott
Sion Arrowsmith wrote: > It appears to me that our fundamental difference is that you see value > in long-term preservation of sections of commented-out code without > any kind of real comment as to what's going on, whereas I consider > this to be appallingly bad practice. Then you're reading too

Re: perspective on ruby

2006-04-20 Thread Edward Elliott
Peter Otten wrote: > Edward Elliott wrote: >>The fact that even numeric literals are objects make me suspicious of Ruby >>as a general-purpose language though. > >>>>add_one = 1 .__add__ > > Just in case you didn't know... True enough, but I don&#x

Re: Thanks from the Java Developer

2006-04-20 Thread Edward Elliott
I know this isn't comp.lang.java but I can't resist... Jarek Zgoda wrote: > Going from Python to Java (as it's in my case) is real pain I wish > nobody to feel... Even with multi-million support for Java from giants > like Sun, IBM or Oracle, I find it much easier to gain full control over > m

Re: perspective on ruby

2006-04-20 Thread Edward Elliott
Alex Martelli wrote: > The only "single language" I could see fitting that role is Mozart, > deliberately designed to be SUPER-multi-paradigm -- not even Lisp and > Scheme (the only real competition) can compare. Don't know Mozart. After 5 minutes of googling, it looks like strictly a high-level

Re: how to append to a list twice?

2006-04-21 Thread Edward Elliott
John Salerno wrote: > If I want to create a list of the form [100, 99, 99, 98, 98, 97, 97...] > (where each item is repeated twice after the first one), how might I do > that most efficiently? Why not just this: series = [x/2 for x in range(200, 1, -1)] -- http://mail.python.org/mailman/listi

Re: how to append to a list twice?

2006-04-21 Thread Edward Elliott
Nick Craig-Wood wrote: > That should be > > series = [x//2 for x in range(200, 1, -1)] > > to be "from __future__ import division" safe from __present__ import gratitude -- http://mail.python.org/mailman/listinfo/python-list

Re: Jython: exec a string

2006-04-21 Thread Edward Elliott
iirc java doesn't like multiple classes in a single file (not counting anonymous or inner classes). sounds like jython may have the same restriction... abcd wrote: > the error i get when i run the exec is, "java.lang.ClassFormatError"... > > thanks > -- http://mail.python.org/mailman/listinf

Re: Recommended IDE for creating GUI?

2006-04-21 Thread Edward Elliott
can anyone here comment on boa constructor? http://boa-constructor.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-21 Thread Edward Elliott
Anthony Liu wrote: > But, I want the random numbers just generated sum up > to 1 . This seems like an odd request. Might I ask what it's for? Generating random numbers in [0,1) that are both uniform and sum to 1 looks like an unsatisfiable task. Each number you generate restricts the possib

Re: perspective on ruby

2006-04-22 Thread Edward Elliott
robert wrote: > Yes - start them explore. I'd not want to be "teached" a specific > _language_ in a course longer that one day. A language cannot be teached. > Who of the posters in this thread want themselves to be _teached_ more > than one day on a language? > > Isn't the fun, finding the ri

Re: list example

2006-04-22 Thread Edward Elliott
No substantive problems. The str() calls are unnecessary, print calls list.__str__ already. You can replace the loop with list comprehensions or slices. Same result, a bit more succinct. See these pages for more: http://docs.python.org/lib/typesseq.html http://docs.python.org/tut/node7.html

Re: PYTHONPATH

2006-04-23 Thread Edward Elliott
Brian van den Broek wrote: > The suggestions above appear not to work for me: > > [EMAIL PROTECTED]:~$ cat /etc/profile | grep 'export PYTHONPATH' > export PYTHONPATH="~/PythonFiles" > [EMAIL PROTECTED]:~$ cat .bash_profile | grep 'export PYTHONPATH' > export PYTHONPATH="~/PythonFiles" Those file

Re: getattr from local scope

2006-04-23 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > Basically my application has a scheduler which stores names of functions > defined in the "schedule" module in a database, to be run on certain > days. Every night I call schedule.RunSchedule, which grabs all the rows on > the database that have to be run now, and I want

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-23 Thread Edward Elliott
Alex Martelli wrote: > Such total disuniformity, where the very distribution of each value is > skewed by the preceding one, may still be "random" for some sufficiently > vague meaning of "random", but my intuition suggests it's unlikely to > prove satisfactory for the OP's purposes. It does seem

Re: getattr from local scope

2006-04-23 Thread Edward Elliott
Alex Martelli wrote: > sys.modules[__name__].__dict__ may be more handily accessed by the > built-in function globals(). Well there you go. Glad it's not that awkward. -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHONPATH

2006-04-23 Thread Edward Elliott
Brian van den Broek wrote: > if 1; then > somestuff > > Trying (3) gave > [EMAIL PROTECTED]:~$ . .bash_profile > bash: 1: command not found The error indicates the shell tried to execute a program named '1' and couldn't find one. Arthimetic expressions generally have to be wrapped in (()) i

Re: Using distutils in Windows XP / "Python in a Nutshell"

2006-04-23 Thread Edward Elliott
Blair LeGent wrote: > error: The .NET Framework SDK needs to be installed before building > extensions for Python. > > ...but the .NET Framework IS installed Just a guess, but is the C compiler in your PATH when you run python? I'm assuming python on xp still uses environment variables and not

Re: MS VC++ Toolkit 2003, where?

2006-04-23 Thread Edward Elliott
Alex Martelli wrote: > the Windows version, despite the slight > overhead of running under Parallels' virtualization, is an impressive > 12%+ _faster_ than the "native" MacOSX Python 2.4.3 (I'm not quite sure > about how good Parallels' virtualization IS, but even if it's as > impressive as a mere

Re: RESOLVED Re: PYTHONPATH

2006-04-24 Thread Edward Elliott
Brian van den Broek wrote: > It > didn't work here until I used ':' rather than ';' as the path > element separator. Sorry, I missed the semi-colon before. Yes, unix uses colon to separate path elements. Glad you figured it out and got it working. FYI you can type 'man ' at the shell to get inf

Re: Counting elements in a list wildcard

2006-04-24 Thread Edward Elliott
Dave Hughes wrote: > Another algorithm that might interest isn't based on "sounds-like" but > instead computes the number of transforms necessary to get from one > word to another: the Levenshtein distance. A C based implementation > (with Python interface) is available: I don't know what algorith

Re: MS VC++ Toolkit 2003, where?

2006-04-25 Thread Edward Elliott
Alex Martelli wrote: > OK, I've placed on http://www.aleax.it/Python/ the files that pybench > writes (with the -file option) for each machines, the names are > onmbp.txt and onwin2k.txt -- just 20k each (I'm not sure their format is > documented, but I guess that, worst case, one just needs to stu

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote: > At the same time, if the 14% slowdown is representative, then it's not > true that the compiler responsible for it "optimizes as well" as the > other; indeed, "does not optimize particularly well", under such a > hypothesis, would be far from a "beyond BS" assertion. Maybe s

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote: > about MacOSX, which also uses gcc: 14% faster pybench using Python 2.4.3 this is the second time I've seen that 14% figure. OOC, where does it come from? the data sets you posted show an average 12.6% speedup. 14 is an odd way to round. :) I don't think it's very useful

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Brian Elmegaard wrote: > "Martin v. Löwis" <[EMAIL PROTECTED]> writes: >> You can build the entire Python interpreter with Cygwin (but you >> don't need to, because there is a precompiled version), and you can >> build extensions for the python.org binary using MingW. > > Great, then I tend to agr

Re: Counting elements in a list wildcard

2006-04-25 Thread Edward Elliott
John Machin wrote: > On 25/04/2006 6:26 PM, Iain King wrote: >> iain = re.compile("(Ia(i)?n|Eoin)") >> steven = re.compile("Ste(v|ph|f)(e|a)n") > > IMHO, the amount of hand-crafting that goes into a *general-purpose* > phonetic matching algorithm is already bordering on overkill. Your > method usi

Re: Counting elements in a list wildcard

2006-04-25 Thread Edward Elliott
John Machin wrote: > On 25/04/2006 3:15 PM, Edward Elliott wrote: >> Phoneme matching seems overly complex and might >> grab things like Tsu-zi. > > It might *only* if somebody had a rush of blood to the head and devised > yet another phonetic key "algorithm&quo

Re: The whitespaceless frontend

2006-04-25 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > It's less explicit than self. but it's shorter, this improves typing, > and allows to produce more compact code: > > return "".join(["Graph(", repr($o), ", ", repr($nodeData), ")"]) > > Instead of: > > return "".join(["Graph(", repr(self.o), ", ", repr(self.nodeData),

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
sturlamolden wrote: > MinGW and Cygwin GCC is actually the same compiler. On Cygwin you can > remove the dependency on the cygwin dll by compiling with -mno-cygwin. > But as long as the cygwin dll is there, it creates an overhead for any > system call. Thanks for that very informative post! To c

Re: python application ideas.

2006-04-25 Thread Edward Elliott
Thomas Bartkus wrote: > Tis the conundrum of programming in general. If all you know how to do is > write code - then you truly have nothing to do. What *other* interests do > you have? Hobbies? Job Skills? > What *does* "blow your hair back" ;-) > > That's where your programming ideas need to

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
sturlamolden wrote: > Edward Elliott wrote: >> Couldn't you compile the msvc-python code under gcc/mingw? > > Yes I could, but I cannot compile the code under msvc for comparison. I > only have MinGW. If build the mingw binary then someone else has to > build the msvc b

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
"Martin v. Löwis" wrote: > Well, you are not compiling with neither mingw, nor cygwin; you are > compiling with gcc in either case. touche, mr. pedant. :) > Well, there is no native C library on Microsoft Windows: the system > simply doesn't include an official C library (I know there is crtdll.d

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Ross Ridge wrote: > MSVCRT.DLL ... It's not > exactly "endorsed", Microsoft would rather you use it's current > compiler and runtime, but it is the standard "official" Windows system > C library. Does it comply with the ANSI C89 standard? I'm still not seeing why mingw can't just link python to i

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote: > I assume you mean "compare pybench on Python 2.4.3 compiled under" etc. Yep > Unfortunately, I suspect the ex-officio gcc defenders will only react by > finding yet another quibble (anything to avoid admitting that gcc may > not be as good at optimizing as a _Microsoft_ pro

Re: MinGW and Python

2006-04-25 Thread Edward Elliott
Alex Martelli wrote: > I believe the single figure is a useful summary. Even the most > sophisticated benchmarks are eventually boiled down to single figures, > as in "so many SPECmarks" etc, because in everyday discourse a scalar is > what you can reasonably discuss. Sure, philosophically speaki

Re: how to browse using urllib2 and cookeilib the correct way

2006-04-25 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > can anybody explain, in the first case why i need to do two attempts. I would guess it's because redhat requires your browser to submit a session cookie with the login form. In the urllib2 example, the first request you make tries to submit login form data directly. Si

Re: Counting elements in a list wildcard

2006-04-26 Thread Edward Elliott
Iain King wrote: > steven = re.compile("Ste(v|ph|f|ff)(e|a)n") > steven = ["Steven", "Stephen", "Stefen", "Steffen", "Stevan", > "Stephan", "Stefan", "Steffan"] > > I know which I'd rather type. 'Course, if you can use a ready-built > list of names... Oh I agree, I'd rather *type* the former, bu

Re: Counting elements in a list wildcard

2006-04-26 Thread Edward Elliott
Iain King wrote: > steven = re.compile("Ste(v|ph|f|ff)(e|a)n") Also you can expand the RE a bit to improve readability: re.compile("Stev|Steph|Stef|Steff)(en|an)") -- http://mail.python.org/mailman/listinfo/python-list

Re: The whitespaceless frontend

2006-04-26 Thread Edward Elliott
Sion Arrowsmith wrote: > Absolutely. I've written quite a lot of code (which I wasn't expecting > anyone else to maintain) using 'I' for the same reasons. Plus, it's > even shorter in terms of characters (if not keystrokes), stands out > reasonably well, and for how I read it makes for better Engli

Re: A defense for bracket-less code

2006-04-26 Thread Edward Elliott
Dave Hansen wrote: > Not really. It was mostly a lead-in to that last sentence. Problems > like this couldn't happen in Python. So it's an opportunity to get a > giggle at the expense of programmers using a language that gives you > enough rope to shoot yourself in the foot... Which can be enti

Re: A defense for bracket-less code

2006-04-26 Thread Edward Elliott
Stelios Xanthakis wrote: > Also, I think that perl does that because otherwise code like > > if ($x) $y++ if $z; else $z--; > > would be even more confusing :) With or without braces, that's not legal code. A one-line if can't be followed by an else. The closest you can do is this: $y++ if $z

Re: Regular Expression help

2006-04-27 Thread Edward Elliott
RunLevelZero wrote: > 10:00am - 11:00am: > Here is the re. > > findshows = > re.compile(r'(\d\d:\d\d\D\D\s-\s\d\d:\d\d\D\D:*.*)') 1. A regex remembers everything it matches -- no need to wrap the entire thing in parens. Just call group() on the returned MatchObject. 2. If all you want is the

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Panos Laganakos wrote: > i.e. we usually define private properties and provide public functions > to access them, in the form of: > get { ... } set { ... } > > Should we do the same in Python: > Or there's no point in doing so? > > Some other techniques come to mind, but I think that Python tends

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Philippe Martin wrote: '' On the other hand, foo.__doc__ and foo.__name__ work fine. (I was going to quote your post but my reader interprets everything after the two dashes as your sig and ignores it. And I won't bother to fix it.) -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Philippe Martin wrote: > I'm not sure I understand what you mean ... I did get a strange new > message from my email client and disabled the signature. Look again at the post I replied to (great-grandparent of this one). It's not your sig quote that was the problem. -- http://mail.python.org/ma

Re: Regular Expression help

2006-04-27 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > If you are parsing HTML, it may make more sense to use a package > designed especially for that purpose, like Beautiful Soup. I don't know Beautiful Soup, but one advantage regexes have over some parsers is handling malformed html. Omitted closing tags can wreak havoc.

Re: stdin: processing characters

2006-04-27 Thread Edward Elliott
Kevin Simmons wrote: > I have a python script that prompts the user for input from stdin via a > menu. I want to process that input when the user types in two characters > and not have to have the user press . As a comparison, in the bash > shell one can use (read -n 2 -p "-->" CHOICE; case $CHOICE

Re: How to import whole namespace into global symbol table? (newbie)

2006-04-27 Thread Edward Elliott
Scott Simpson wrote: > def func(): > from sys import stderr, exit > try: > f = open("foo", 'r') > except IOError: > print >> stderr, "Input file foo does not exist" > exit(1) IOError can be raised when foo exists, e.g. if there's a permission problem. It'

Re: How to align the text of a Listbox to the right

2006-04-28 Thread Edward Elliott
Leonardo da Vinci wrote: >> to limit the width to something acceptable, and show >> only the tail of the line. > > Yes, this is exactly what I wanted to do. Do you know a way to > accomplish that? Because Eric Brunel said it is impossible on a > Listbox. Use a string slice. -- http://mail.pytho

Re: Converstion

2006-04-28 Thread Edward Elliott
Peter Otten wrote: > del x[-1:] # or del x[-1] if you are sure that len(x) > 0 > just deletes the last item (if any) from x whereas > x = x[:-1] > copies all but the last item of the original list into a new one. This can > take much longer: But his data is a string, which is immutable but heavily

Re: best way to determine sequence ordering?

2006-04-28 Thread Edward Elliott
[email protected] wrote: > class Item(object): >def __init__(self, value): > self.val=value > self.order = dict(c=0, a=1, d=2, b=3) >def __cmp__(self, other): > return cmp(self.order[self.val], self.order[other.val]) An object that keeps track of the order it's stored in an

Re: best way to determine sequence ordering?

2006-04-29 Thread Edward Elliott
Steven Bethard wrote: > Ok, lets get comparable functions by writing them both in Python: First of all, your functions aren't quite comparable. The first index takes the value to locate as a variable, while the second has both values hard-coded as literals. Changing the second one to index2(L, a

Re: Add file to zip, or replace file in zip

2006-04-30 Thread Edward Elliott
Scott David Daniels wrote: > It is not currently possible to delete or replace individual elements > in a zip file, nor (in all likelihood) would you want to do so. It > would require having the zip[ file in a broken state for some time > as you copy data from one area of the zip to another. If

Re: setting file permissions on a web server

2006-04-30 Thread Edward Elliott
John Salerno wrote: > Thanks, but I'm still a little confused. Since I'm running Windows You misplaced your period, it goes at the end of that line. ;) > assume that I can't run the chmod line on my own computer. Sure you can, install cygwin. chmod only affects files on your computer, and won'

Re: basic python programing

2006-04-30 Thread Edward Elliott
gregarican wrote: >> How To Ask Questions The Smart Way >> http://www.catb.org/~esr/faqs/smart-questions.html > > Actual the parent post on the thread wasn't asking a question. They > were making a somewhat puzzling dangling statement. Maybe it's time for the sequel, How To Make Smart Statements

Re: setting file permissions on a web server

2006-04-30 Thread Edward Elliott
Daniel Nogradi wrote: > I have next to zero experience with windows but as far as I know > windows doesn't have file permissions at all (anyone, please correct > me if I'm wrong :)) so in windows land it doesn't make any sense to > "change file permissions". Actually Windows has a quite good perm

Re: ending a string with a backslash

2006-04-30 Thread Edward Elliott
John Salerno wrote: > Obviously the single backslash at the end of 'path' will cause a > problem, and escaping it with a backslash seems to fix this problem, but > how does escaping work when I already have it as a raw string? see the first two items here: http://www.ferg.org/projects/python_gotc

Re: returning none when it should be returning a list?

2006-04-30 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > The function basically takes in a list of all the prime number found, > it takes the next number to be tested for (next) and the limit it will > go up to. It divide next by the list of previous prime numbers if next > is not bigger than lim, count up all the times where i

Re: Add file to zip, or replace file in zip

2006-05-01 Thread Edward Elliott
Scott David Daniels wrote: > Edward Elliott wrote: >> Scott David Daniels wrote: >>>... > > ... You windows kids and your crazy data formats. > There were a few oth OS's than Linux and Windows. Maybe you > should call me "you crazy Tenex kid." W

Re: noob question: "TypeError" wrong number of args

2006-05-01 Thread Edward Elliott
Holger wrote: > oops, that was kinda embarrassing. It's really not. You got a completely unhelpful error message saying you passed 2 args when you only passed one explicitly. The fact the b is also an argument to b.addfile(f) is totally nonobvious until you know that 1) b is an object not a modu

Re: Add file to zip, or replace file in zip

2006-05-01 Thread Edward Elliott
Scott David Daniels wrote: > Actually I think it was a combination of CP/M and DOS that popularized > the ZIP format; essentially the floppy-disk set, for whom the zip format > was a godsend. Ah you're right. I just lump all Microsoft OSes under the term 'Windows' now, though I suppose that's unf

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
Steve Holden wrote: > Objects don't actually "pass references to themselves". The interpreter > adds the bound instance as the first argument to a call on a bound method. Sure, if you want to get technical For that matter, objects don't actually call their methods either -- the interpreter looks

Re: set partitioning

2006-05-02 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > For the list [1,2,3,4], I'm looking for the following for k = 2: > > [[1,2], [3,4]] > [[1,3], [2,4]] > [[1,4], [2,3]] That's not what you asked for the first time. You said you wanted "m non-empty, disjoint subsets", but the subsets above are clearly not all disjoint;

Re: Can Python kill a child process that keeps on running?

2006-05-02 Thread Edward Elliott
Serge Orlov wrote: > I. Myself wrote: >> Suppose it is supposed to run for one minute, but it just keeps going >> and going. Does Python have any way to kill it? > > On linux it's pretty easy to do, just setup alarm signal. On windows > it's not so trivial to the point you cannot do it using pyth

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
bruno at modulix wrote: >> that 1) b is an object not a module*, and 2) objects pass references to >> themselves as the first argument to their methods. > > Nope. It's the MethodType object (a descriptor) that wraps the function > that do the job. The object itself is totally unaware of this. It'

Re: stripping

2006-05-02 Thread Edward Elliott
[EMAIL PROTECTED] wrote: > while 1: > line = f.readline().rstrip("\n") > if line == '': > break > #if not re.findall(r'^$',line): > print line you want continue, not break there. but that gives you an infinite loop, so you need a new exit condition

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
bruno at modulix wrote: > It is to be taken literally. Either you talk about how Python > effectively works or the whole discussion is useless. I started talking about the code-level view (programmer's perspective) so shorthand was fine. Now that we've moved on to interpreter/compiler-level stuff

Re: ConfigParser and multiple option names

2006-05-02 Thread Edward Elliott
Florian Lindner wrote: > I think the best solution would be to use a seperation character: > > dir="/home/florian, /home/john, home/whoever" > > What character would be best to work on various operating systems? (of > what names may a path consist is the question) I don't think there are any uni

Re: simultaneous assignment

2006-05-02 Thread Edward Elliott
bruno at modulix wrote: > re-phrase it according to how Python works, and you'll get the answer: > > "Is there a way to bind multiple names to the same object, but so the > identity of this object is different from the identity of this object ?" Which raises an interesting parallel question: is

Re: stripping blanks

2006-05-02 Thread Edward Elliott
Scott David Daniels wrote: > A little better: > > f = open("test.dat") > for line in f: > printLine = line.rstrip("\n") > if printLine: > print printLine [sys.stdout.write(line) for line in open('test.dat') if line.rstrip('\n')] Where's my prize? What do

Re: simultaneous assignment

2006-05-02 Thread Edward Elliott
Heiko Wundram wrote: > Integer and string objects > are immutable in Python, so why'd you want to have different IDs for an > object of the same value? It's the value you're working with in a program, > not the objects ID. At least it should be, if you're truly intent on > working with the (pseudo-

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
Bruno Desthuilliers wrote: > Edward, I know I told you so at least three times, but really, > seriously, do *yourself* a favor : take time to read about descriptors > and metaclasses - and if possible to experiment a bit - so you can get a > better understanding of Python's object model. Then I'll

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
Ben Finney wrote: > So now you're proposing that this be a special case when a function is > declared by that particular syntax, and it should be different to when > a function is created outside the class definition and added as a > method to the object at run-time. > > Thus breaking not only "ex

Re: noob question: "TypeError" wrong number of args

2006-05-02 Thread Edward Elliott
Ben Finney wrote: > So the tradeoff you propose is: > > - Honour "explicit is better than implicit", but users are confused > over "why do I need to declare the instance in the method > signature?" > > against > > - Break "explicit is better than implicit", take away some of the >

Re: assignment in if

2006-05-02 Thread Edward Elliott
Roy Smith wrote: > decision. In Python, assignment is not an operator with side effects like > in C or Java, but a statement. assignemnt is actually an expression in those languages, not a statement. > The lack of embedded assignments leads to slightly more verbose code in > situations like

Re: assignment in if

2006-05-02 Thread Edward Elliott
Edward Elliott wrote: > assignemnt is actually an expression in those languages, not a > statement. s/statement/operator/ -- http://mail.python.org/mailman/listinfo/python-list

Re: assignment in if

2006-05-02 Thread Edward Elliott
Edward Elliott wrote: > Edward Elliott wrote: >> assignemnt is actually an expression in those languages, not a >> statement. > > s/statement/operator/ it was probably clearer the first time, but let me rephrase: in C/Java, assignment is neither a statement not a

Re: Newbie question on code vetting

2006-05-03 Thread Edward Elliott
Dennis Lee Bieber wrote: >> I work for a risk-averse company, and I want to compile a solid case for >> obtaining and using Python at work. >> > Given the nature of the US Patent Office... You might as well lock > the doors now... > > The Patent Office could issue a patent next week that makes all

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Bruno Desthuilliers wrote: > IOW, let's give Edward some time to come up with enough rope so we can > hang him to the nearest (AS) Tree !-) That's all I ask. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
Bruno Desthuilliers wrote: > But then, constructs like: > > class Obj(object): >def method(...): ... >method = staticmethod(method) > > or it's newer syntactic-sugar-version would become somewhat more > difficult to parse properly - but I admit that this is beyond my > knowledge. Hmm, th

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Edward Elliott
bruno at modulix wrote: > And of course propose an implementation - perhaps the compiler.ast could > be useful ? Ugh. Just when I thought I'd seen my last abstract syntax tree, one rears its ugly head. -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible constant assignment operators ":=" and "::=" for Python

2006-05-03 Thread Edward Elliott
Michele Simionato wrote: > Python solution is to rely on the intelligence of programmers. If they > see an all caps name and then they try to change it without knowing what > they are doing, then they are stupid. If you have stupid programmers there > is no way the language can stop them for makin

  1   2   3   >