Re: How about adding rational fraction to Python?

2008-02-25 Thread J. Cliff Dyer
On Mon, 2008-02-25 at 16:27 +, Grant Edwards wrote: On 2008-02-25, Carl Banks [EMAIL PROTECTED] wrote: In other words, 3/4 in Python rightly yields a float Unless you're in the camp that believes 3/4 should yield the integer 0. ;) I'm in the camp that believes that 3/4 does indeed

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 04:29 -0800, Lie wrote: J Cliff Dyer: I'm in the camp that believes that 3/4 does indeed yield the integer 0, but should be spelled 3//4 when that is the intention. That's creepy for people that are new to programming and doesn't know how CPUs work and are used

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 10:08 -0500, D'Arcy J.M. Cain wrote: On Tue, 26 Feb 2008 06:45:45 -0800 (PST) Carl Banks [EMAIL PROTECTED] wrote: On Feb 26, 9:29 am, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: If 3/4 ever returned 0.75 in any language I would drop that language. Have fun dropping

Re: How about adding rational fraction to Python?

2008-02-26 Thread J. Cliff Dyer
On Tue, 2008-02-26 at 13:51 -0500, D'Arcy J.M. Cain wrote: On Tue, 26 Feb 2008 13:39:38 -0500 J. Cliff Dyer [EMAIL PROTECTED] wrote: a = 2 * 2 b = 20 * 20 type(a) type 'int' type(b) type 'long' A long int is still integral which is the crux of the issue. So

Re: How about adding rational fraction to Python?

2008-02-28 Thread J. Cliff Dyer
On Thu, 2008-02-28 at 11:22 -0500, D'Arcy J.M. Cain wrote: Not obvious to you. You are using subjective perception as if it was a law of nature. If obvious was the criteria then I would argue that the only proper result of integer division is (int, int). Give me the result and the

Re: Re: manipulating hex values

2008-04-01 Thread J. Cliff Dyer
On Tue, 2008-04-01 at 12:09 -0700, Stephen Cattaneo wrote: The source of my confusion is that I need to keep my bytes formated correctly. I am using the below 'raw socket example' proof-of-concept code as my example. (And yes, I have tried the proof-of-concept. It works correctly. It

Re: String Literal to Blob

2008-04-15 Thread J. Cliff Dyer
remotely like temper from me :-) And I'm glad to see that you finally got it, too! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- Oook, J. Cliff Dyer Carolina

Re: Finally had to plonk google gorups.

2008-04-16 Thread J. Cliff Dyer
until I switched to digest view :) -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list

Re: Finally had to plonk google gorups.

2008-04-16 Thread J. Cliff Dyer
as Ctrl-T on your inbox. It isn't much different in Thunderbird. But I agree...there are other alternatives. I'll have to start trying them again I suppose. Mike -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python

Re: More Fun With MySQL and Images

2008-04-17 Thread J. Cliff Dyer
no longer a well-formed jpeg, so it won't work. That's exactly what you're asking the browser to do. I guess this isn't really python related, so my apologies for that. Cheers, Cliff -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman

Re: Can't do a multiline assignment!

2008-04-17 Thread J. Cliff Dyer
On Thu, 2008-04-17 at 13:53 -0400, Steve Holden wrote: Gary Herron wrote: [EMAIL PROTECTED] wrote: On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote: On 17 avr, 17:40, [EMAIL PROTECTED] wrote: Out of sheer curiosity, why do you need thirty (hand-specified and dutifully commented)

Re: Python-list Digest, Vol 55, Issue 296

2008-04-18 Thread J. Cliff Dyer
On Fri, 2008-04-18 at 17:25 +0200, [EMAIL PROTECTED] wrote: I really like developing in Python -- but it's hard to keep doing it when the growth curve is so slow and a so many people have deep reservations about it, inspired in part, justifiably, by nonsense

Re: Another MySQL Images Question

2008-04-18 Thread J. Cliff Dyer
id=%s, ;', (pic1, id)) it tells me I have an error in my MySQL syntax. What is the error? TIA, Victor -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k concerns. An example

2008-04-18 Thread J. Cliff Dyer
of a performance hit will actually cause you trouble? 1% extra on string interpolation? 10%? 50%? 200%? You do provide a link to a website called xfeedme.com. And I just fed you. IHBT. HAND. :-/ -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org

Re: Colors for Rows

2008-04-29 Thread J. Cliff Dyer
On Tue, 2008-04-29 at 13:14 -0500, Victor Subervi wrote: On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote: On Tue, 29 Apr 2008 09:33:32 -0500 Victor Subervi [EMAIL PROTECTED] wrote: why doesn't this work? First,

Re: Colors for Rows

2008-04-29 Thread J. Cliff Dyer
On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote: On Tue, 29 Apr 2008 15:03:23 -0400 J. Cliff Dyer [EMAIL PROTECTED] wrote: Or, if you aren't sure how many colors you'll be using, try the more robust: bg[z % len(bg)] Good point although I would have calculated the length

Re: Custom Classes?

2008-04-30 Thread J. Cliff Dyer
contextual hints which improve readability. Post working code, and I'll answer your actual question. Cheers, Cliff -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list

Re: confused about self, why not a reserved word?

2008-05-05 Thread J. Cliff Dyer
, copyright, credits or license for more information. class Foo(object): ... def Hello(sel): ... print hi ... f = Foo() f.Hello() hi Can you paste an example that breaks for you? -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http

Re: pygame music, cant read mp3?

2008-05-05 Thread J. Cliff Dyer
the gritty details, and you don't have to. -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill -- http://mail.python.org/mailman/listinfo/python-list

Re: generator functions in another language

2008-05-05 Thread J. Cliff Dyer
On Mon, 2008-05-05 at 10:08 -0700, [EMAIL PROTECTED] wrote: At some point, code goes on and off the processor, which knowledge I do owe to spending money. Thus, if the group news is a localcy (other dimension of currency), that's bounce check the house dollar. What do [second person plural]

[Fwd: Re: Am I missing something with Python not having interfaces?]

2008-05-07 Thread J. Cliff Dyer
-- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill ---BeginMessage--- On Wed, 2008-05-07 at 21:19 +0200, Daniel Marcel Eichler wrote: Am Dienstag 06 Mai 2008 16:07:01 schrieb Mike Driscoll: If so, then it looks like an Interface is a generic class with method

Re: Parsing Email 'References' header.

2008-05-08 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 14:53 +0200, Aspersieman wrote: Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a threaded view of these emails (these

Re: listen on TCP port

2008-05-08 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 05:56 -0700, [EMAIL PROTECTED] wrote: Hello, is it possibble listening on TCP port by python and how? I am trying chilkat but poorly :(. Thanks -- http://mail.python.org/mailman/listinfo/python-list You just asked this exact same question yesterday, and got a few

Re: Am I missing something with Python not having interfaces?

2008-05-08 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 13:25 -0400, J. Cliff Dyer wrote: On Thu, 2008-05-08 at 19:11 +0200, Daniel Marcel Eichler wrote: Am Donnerstag 08 Mai 2008 13:02:52 schrieb J. Clifford Dyer: I didn't said that interfaces are a kind of duck-typing. In fact it was the exact opposite

Re: Surprising difference in behavior between import blah and from blah import thing

2008-05-08 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 12:00 -0700, Eric Hanchrow wrote: (This is with Python 2.5.2, on Ubuntu Hardy, if it matters.) This seems so basic that I'm surprised that I didn't find anything about it in the FAQ. (Yes, I am fairly new to Python.) Here are three tiny files: mut.py

Dynamic generation of images (was Re: Custom Classes?)

2008-05-09 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 10:33 -0500, Victor Subervi wrote: Okay, trying this again with everything working and no ValueError or any other errors, here we go: Load this code. Unless you use a similar login() script, you will want to edit your own values into the user, passwd, db and host:

Re: observer pattern (notification chain synchronization)

2008-05-09 Thread J. Cliff Dyer
That looks like a good approach to me. Alternative to a dict would just be a count of reported stocks tested against the total number of stocks, but if one stock reports twice before another reports at all, you'll get funny results. Your method is probably better, in the general case. Cheers,

Re: python newbie: some surprises

2008-05-09 Thread J. Cliff Dyer
On Fri, 2008-05-09 at 15:08 +, Yves Dorfsman wrote: Gabriel Genellina wrote: I see the point of the OP. Couldn't the new-line be used as an equivalent of ':', for example, do you find this difficult to read: if a == 3 do_something() if a == 3: do_something() Yes,

Re: A question about python and xml

2008-05-09 Thread J. Cliff Dyer
On Fri, 2008-05-09 at 08:39 -0700, Holden wrote: Hello everyone I heard this was a good community to go too for help and advice. I want to make a web site that uses the python programming language which I am VERY new at. This website would store simple data such as names in a form. At first I

Re: Python and Flaming Thunder

2008-05-14 Thread J. Cliff Dyer
On Wed, 2008-05-14 at 13:27 -0700, [EMAIL PROTECTED] wrote: On 14 mai, 00:41, John Machin [EMAIL PROTECTED] wrote: (snip) IIRC the idea was so that managers could write programs in English. It failed because nobody could write a parser that would handle something like The bottom line is

Re: class problem, NoneType obj has no attribute

2008-05-16 Thread J. Cliff Dyer
On Fri, 2008-05-16 at 06:07 -0700, globalrev wrote: On 16 Maj, 14:19, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: globalrev a écrit : wassup here? 7 Traceback (most recent call last): File C:\Python25\myPrograms\netflix\netflix.py, line 22, in module print

Re: class problem, NoneType obj has no attribute

2008-05-16 Thread J. Cliff Dyer
On Fri, 2008-05-16 at 06:04 -0700, globalrev wrote: On 16 Maj, 13:54, Peter Otten [EMAIL PROTECTED] wrote: Christian Heimes wrote: globalrev schrieb: cust1 = customer.__init__('12',['1','435','2332']) cust1 = customer('12',['1','435','2332']) ... and before that from customer

Re: Battleship style game

2009-02-25 Thread J. Cliff Dyer
On Wed, 2009-02-25 at 15:54 -0500, Shawn Milochik wrote: On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch de...@nospam.web.de wrote: Not really. The point about properties is that you *can* make attribute access trigger getter or setter code. But not that you do unless there is an

Re: Mangle function name with decorator?

2009-03-18 Thread J. Cliff Dyer
You might be interested in redefining __getattribute__(self, attr) on your class. This could operate in conjunction with the hash tables (dictionaries) mentioned by andrew cooke. i.e. (untested code): class C(object): def __init__(self): self._get_table = {} self._post_table

Re: Another of those is issues.

2009-03-24 Thread J. Cliff Dyer
On Fri, 2009-03-20 at 11:20 -0700, Emanuele D'Arrigo wrote: Hi everybody, I was unit testing some code today and I eventually stumbled on one of those is issues quickly solved replacing the is with ==. Still, I don't quite see the sense of why these two cases are different: def

Re: Mangle function name with decorator?

2009-03-25 Thread J. Cliff Dyer
On Wed, 2009-03-18 at 08:18 -0700, Adam wrote: On Mar 18, 10:33 am, J. Cliff Dyer j...@sdf.lonestar.org wrote: You might be interested in redefining __getattribute__(self, attr) on your class. This could operate in conjunction with the hash tables (dictionaries) mentioned by andrew cooke

Re: Introducing Python to others

2009-03-26 Thread J. Cliff Dyer
On Thu, 2009-03-26 at 09:35 +, Paddy O'Loughlin wrote: Hi, As our resident python advocate, I've been asked by my team leader to give a bit of a presentation as an introduction to python to the rest of our department. It'll be less than an hour, with time for taking questions at the end.

Re: Eval Problem

2009-04-07 Thread J. Cliff Dyer
OK. You still haven't shown the code where tableTop gets defined, so your code is unrunnable. However, I think your problem is that wherever tableTop lives, it isn't part of your globals or locals in eval. See the documentation on evals here: http://www.python.org/doc/1.4/lib/node26.html

Re: extract Infobox contents

2009-04-08 Thread J. Cliff Dyer
On Wed, 2009-04-08 at 01:57 +0100, Rhodri James wrote: On Tue, 07 Apr 2009 12:46:18 +0100, J. Clifford Dyer j...@sdf.lonestar.org wrote: On Mon, 2009-04-06 at 23:41 +0100, Rhodri James wrote: On Mon, 06 Apr 2009 23:12:14 +0100, Anish Chapagain anishchapag...@gmail.com wrote: Hi,

Re: Lambda alternative?

2009-04-17 Thread J. Cliff Dyer
On Thu, 2009-04-16 at 13:33 +0200, Hrvoje Niksic wrote: mousemeat mousem...@gmail.com writes: Correct me if i am wrong, but i can pickle an object that contains a bound method (it's own bound method). No, you can't: import cPickle as p p.dumps([]) '(l.' p.dumps([].append)

Re: Test if list contains another list

2008-09-09 Thread J. Cliff Dyer
On Tue, 2008-09-09 at 10:49 +0200, Bruno Desthuilliers wrote: Matimus a écrit : On Sep 8, 12:32 am, Bruno Desthuilliers [EMAIL PROTECTED] wrote: (snip) set(a).issubset(set(b)) True Just to clarify, doing it using sets is not going to preserve order OR number of elements

Re: append on lists

2008-09-16 Thread J. Cliff Dyer
On Tue, 2008-09-16 at 08:49 -0500, Grant Edwards wrote: On 2008-09-16, Hrvoje Niksic [EMAIL PROTECTED] wrote: Duncan Booth [EMAIL PROTECTED] writes: The only relatively common use I can think of where you might want to call a method directly on a literal is to produce a list of strings

Re: improving a huge double-for cycle

2008-09-18 Thread J. Cliff Dyer
On Thu, 2008-09-18 at 07:57 -0500, Tim Chase wrote: Code: Select all for i in range(len(IN)): #scan all elements of the list IN for j in range(len(IN)): if i j: if IN[i].coordinates[0] == IN[j].coordinates[0]: if IN[i].coordinates[1] ==

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread J. Cliff Dyer
On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote: On 2008-10-03, greg [EMAIL PROTECTED] wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Steven D'Aprano wrote: (2) Even when the source is available, it is sometimes a legal trap to read it with respect to

Re: Error

2008-10-21 Thread J. Cliff Dyer
On Tue, 2008-10-21 at 09:34 -0400, Philip Semanchuk wrote: On Oct 21, 2008, at 9:05 AM, Amie wrote: Hi, what does is the meaning of this error: int object is unsubscriptable. This is the code that I have written that seems to give me that: def render_sideMenu(self, ctx, data):

Re: Changing the middle of strings in a list--I know there is a better way.

2008-10-21 Thread J. Cliff Dyer
On Tue, 2008-10-21 at 10:28 -0700, Ben wrote: Hello All: I am new to Python, and I love it!! I am running 2.6 on Windows. I have a flat text file here is an example of 3 lines with numbers changed for security: 9088869199020081099

Re: Help with character encodings

2008-05-20 Thread J. Cliff Dyer
On Tue, 2008-05-20 at 08:28 -0700, Gary Herron wrote: A_H wrote: Help! I've scraped a PDF file for text and all the minus signs come back as u'\xad'. Is there any easy way I can change them all to plain old ASCII '-' ??? str.replace complained about a missing codec. Hints?

Re: import X vs from x import *

2008-05-22 Thread J. Cliff Dyer
On Thu, 2008-05-22 at 10:44 -0700, [EMAIL PROTECTED] wrote: import Tkinter from Tkinter import * i have a program where if i comment out either of those import- statements i get an error. i thought they meant the same thing and from was supposed to be just to imort just a specific

Re: Why is math.pi slightly wrong?

2008-05-23 Thread J. Cliff Dyer
On Thu, 2008-05-22 at 15:06 -0400, Dan Upton wrote: Who wants to verify that that's correct to that many digits? ;) Verified. I checked it against the million digits on piday.org, by putting each into a string, stripping out spaces and newlines, and doing: piday[:len(clpy)] == clpy False

Re: Struct usages in Python

2008-05-28 Thread J. Cliff Dyer
On Wed, 2008-05-28 at 09:31 -0400, Alok Kumar wrote: I am getting following error when tried as you suggested. self.event = [] #Create an empty list, bind to the name event under the self namespace self.event.append(Event()) #Create an event object and append to the end of the

[OT] Re: FW: php vs python

2008-05-29 Thread J. Cliff Dyer
On Thu, 2008-05-29 at 08:47 +1200, Phil Runciman wrote: The Inuit have 13 terms for snow. Microsoft advocate DSLs. Why have DSLs if language does not matter? For that matter, the English have several terms for snow as well. snow flurry blizzard powder pack flakes crystals sleet slush And

Re: help

2008-05-30 Thread J. Cliff Dyer
Take a look at django's built in pagination features: http://www.djangoproject.com/documentation/generic_views/ http://www.djangoproject.com/documentation/pagination/ Also, take a look at the django specific mailing list. [EMAIL PROTECTED] Cheers, Cliff On Fri, 2008-05-30 at 12:59 +, ha

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread J. Cliff Dyer
On Wed, 2008-07-09 at 12:29 -0700, samwyse wrote: On Jul 8, 11:01 am, Kris Kennaway [EMAIL PROTECTED] wrote: samwyse wrote: You might want to look at Plex. http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ Another advantage of Plex is that it compiles all of the regular

Re: 'if name is not None:' v. 'if name:'

2008-07-15 Thread J. Cliff Dyer
On Tue, 2008-07-15 at 14:37 -0400, Victor Noagbodji wrote: Hello, what's the difference between these two statement? And which one should one use? Aside: Please include all relevant information in the *body* of your post, not just the subject header. The two statements in question are:

Re: Case-insensitive string compare?

2008-09-05 Thread J. Cliff Dyer
Please keep the discussion on-list. On Fri, 2008-09-05 at 15:36 +0200, Maric Michaud wrote: Le Friday 05 September 2008 14:33:22 J. Clifford Dyer, vous avez écrit : On Thu, 2008-09-04 at 18:48 -0500, Robert Dailey wrote: Thanks everyone for your help. I'm not opposed to using [key.lower()

Re: why doesn't have this list a reply-to ?

2007-10-16 Thread J. Cliff Dyer
Dick Crepeau wrote: It seems to me the original question was how can I reply to a posted message. I'm new here and see that while there are replies to several messages, many times, like with this note, the issue is brought up as if it is new. I don't know how to do a reply, can someone

Re: Failure to connect in SimpleXMLRPCServer/xmlrpclib

2007-10-22 Thread J. Cliff Dyer
iu2 wrote: Hi all, I've copied the example of RPC usage from the Python's doc. When the client and server were on the same PC (localhost) (I use Windows) it worked ok. But putting the server on a different PC raised the error: gaierror: (11001, 'getaddrinfo failed') The error was raised

Re: if..else stmt

2007-10-22 Thread J. Cliff Dyer
Your else statement is incorrectly indented. The interpreter treats it as part of the for-loop construct inside the if statement rather than as part of the if statement itself. See the recent thread about for-else constructs for more details. If your problem is not obvious yet, make sure you

Re: if..else stmt

2007-10-22 Thread J. Cliff Dyer
bigden007 wrote: Hi, I have a if..else statement in my script. The statements all execute fine, but the problem is , even if the IF part of the statement is true, the else part executes as well. The verion of pythin i use 2.5 Any help is appreciatiated. Regards Big Den. Your else

Re: Going past the float size limits?

2007-10-26 Thread J. Cliff Dyer
[EMAIL PROTECTED] wrote: Hello all It would be great if I could make a number that can go beyond current size limitations. Is there any sort of external library that can have infinitely huge numbers? Way way way way beyond say 5x10^350 or whatever it is? I'm hitting that inf boundary rather

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Matimus wrote: - Traling characters at the end of a literal are already used (the L for long). The trailing L is going away in Python 3.0. For your consideration may I suggest a '$' prefix. Though, I'm not sure I even support the idea of a decimal literal, and I'm not even sure if I

Re: Proposal: Decimal literals in Python.

2007-10-26 Thread J. Cliff Dyer
Ben Finney wrote: Matimus [EMAIL PROTECTED] writes: The trailing L [for 'long' literals] is going away in Python 3.0. Yes. On the other hand, we are gaining '0b' for binary literals, to go along with '0o' for octal and '0x' for hexadecimal. So, the original poster

Re: Alarming message when running Python code

2007-10-27 Thread J. Cliff Dyer
peter wrote: I'm not sure if this query should be directed to comp.lang.python or comp.os.linux.misc so I intend to post it to both with apologies if it's inappropriate on either. I have a small python utility which I wrote myself and which crawls through a directory comparing all possible

Re: while within while

2007-10-27 Thread J. Cliff Dyer
Shawn Minisall wrote: K I've since fixed the UnboundLocalError: local variable 'ai' referenced before assignment error, I forgot to include decision = (1, 2, 3) inside for each number. You mean like decision = (1, 2, 3) ? I don't think that would have caused the error you reported.

Re: Proposal: Decimal literals in Python.

2007-10-27 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: On Sat, 27 Oct 2007 13:28:02 -0500, Tim Chase wrote: Even clearer is not to allow octal literals :) Is there *any* use for them? The mode argument to os.chmod. You mean instead of import this os.chmod(filename, os.R_OK | os.W_OK |

Re: tuples within tuples

2007-10-27 Thread J. Cliff Dyer
J. Clifford Dyer wrote: On Fri, Oct 26, 2007 at 06:59:51AM -0700, [EMAIL PROTECTED] wrote regarding Re: tuples within tuples: Resolve *what*? The problem isn't clear yet; at least to me. Above you say what you get. What exactly do you want? Examples please. Sorry for my poor

Re: Pari Python

2007-10-28 Thread J. Cliff Dyer
Anton Mellit wrote: And I think (correct me if I am wrong) that the ^ operator (xor) is used very very infrequently. And it is not difficult to replace all ^ with say ^^. Oh God! *Please* don't start that conversation again. We had a thread about bitwise operators a few weeks back. Half the

Re: attaching someconfusing results in webbrowser.open on gnulinux

2007-11-01 Thread J. Cliff Dyer
krishnakant Mane wrote: hello all, I had mentioned previously that I can't open html files in python. I have my username as krishna and there is a documents folder. so when I give webbrowser.open(file:///home/krishna/documents/tut.html) on python prompt I get true as return value but web

Re: A Python 3000 Question

2007-11-01 Thread J. Cliff Dyer
Steven D'Aprano wrote: On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: I hope you're not serious that $# would make a good operator. If you happen to know where I borrowed it from, it would be pretty evident that I wasn't being serious. Ooh, now I'm curious.

Re: serving html from a python script in IE

2007-11-01 Thread J. Cliff Dyer
bluegray wrote: I'm writing a script that outputs html. It works fine in Firefox, however, IE wants to download the file instead of displaying the output. I keep getting the file download dialog instead of the html page. I am doing something like this: print 'Content-Type: text/html ;

Re: ValueError: invalid \x escape

2007-11-01 Thread J. Cliff Dyer
crybaby wrote: I wrote a python code in linux text pad and copied to thumb drive and try to ran the file by changing the path to windows: sys.path = sys.path + ['D:\Python24\Lib\site-packages\mycode] I get the following error: ValueError: invalid \x escape I am pretty sure this problem

Re: regular expressions

2007-11-07 Thread J. Cliff Dyer
Paul McGuire wrote: On Nov 6, 11:07 am, J. Clifford Dyer [EMAIL PROTECTED] wrote: On Tue, Nov 06, 2007 at 08:49:33AM -0800, [EMAIL PROTECTED] wrote regarding regular expressions: hi i am looking for pattern in regular expreesion that replaces anything starting with and betweeen

Re: How to optimise this code?

2007-08-21 Thread J. Cliff Dyer
David N Montgomery wrote: class testCase: def __init__(self, tc): if tc == 1:self.testCase1() if tc == 2:self.testCase2() if tc == 3:self.testCase3() if tc == 4:self.testCase4() if tc == 5:self.testCase5() if tc == 6:self.testCase6()

Re: for statement on empty iterable

2007-08-22 Thread J. Cliff Dyer
Neil Cerutti wrote: On 2007-08-22, Diez B. Roggisch [EMAIL PROTECTED] wrote: While it is desireable to not only write working, but also aesthetically pleasing code, as a beginner you shouldn't worry too much. The sense of aesthetics develops with time. Important is to try and grasp the

Re: Using Regular Expresions to change .htm to .php in files

2007-08-24 Thread J. Cliff Dyer
Tim Williams wrote: On 23/08/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have a bunch of files that have changed from standard htm files to php files but all the links inside the site are now broken because they point to the .htm files while they are now .php files. Does anyone

Re: Using Regular Expresions to change .htm to .php in files

2007-08-24 Thread J. Cliff Dyer
are internal so we'll save time this way. There's probably a way to analyse if a link is internal or external, but I needed something fast. But still, I would be interested about knowing how to do such a thing for the future. On 8/24/07, J. Cliff Dyer [EMAIL PROTECTED] wrote: Tim Williams wrote: On 23

Re: How to replace a method in an instance.

2007-08-24 Thread J. Cliff Dyer
Steven W. Orr wrote: On Friday, Aug 24th 2007 at 12:26 -0400, quoth Steven W. Orr: =On Friday, Aug 24th 2007 at 09:12 -0700, quoth [EMAIL PROTECTED]: = ==On Aug 24, 11:02 am, Steven W. Orr [EMAIL PROTECTED] wrote: == In the program below, I want this instance to end up calling repmeth ==

Re: Biased random?

2007-08-27 Thread J. Cliff Dyer
I don't know if this is pythonic or not, but try something like this: from math import log from random import randint def: skewedrandom(n): int(log(randrange(1,n), 2)) Play with your log to get the range you want Cheers, Cliff Grant Edwards wrote: On 2007-08-27, Jun-geun Park [EMAIL

Re: strings (dollar.cents) into floats

2007-08-30 Thread J. Cliff Dyer
Gary Herron wrote: luca bertini wrote: Hi, i have strings which look like money values (ie 34.45) is there a way to convert them into float variables? everytime i try I get this error: numb = float(my_line) ValueError: empty string for float() here's the code import sys

Re: why should I learn python

2007-09-06 Thread J. Cliff Dyer
Torsten Bronger wrote: Hallöchen! Tom Brown writes: [...] Python has been by far the easiest to develop in. Some people might say it is not real programming because it is so easy. I can't believe this. Have you really heard such a statement? Tschö, Torsten. The catch-phrase

Re: Modul (%) in python not like in C?

2007-09-09 Thread J. Cliff Dyer
Dotan Cohen wrote: FIrst of all, how is the % symbol (as in 70%6=4) called in English? Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or the other in error? Is this a known gotcha? I tried to google the subject however one cannot google the symbol %. Thanks in advance.

Re: Python syntax wart

2007-09-10 Thread J. Cliff Dyer
J. Cliff Dyer wrote: Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Bjoern Schliessmann wrote: What's wrong with this: for Link in GetEachRecord( Then you're no longer showing the syntax structure in two dimensions. If somebody handed me a program of more than twenty

Re: question on python syntax

2007-09-10 Thread J. Cliff Dyer
Andrew Robert wrote: a.m. wrote: If I type this in shell $ ./yourfile.py 12:34 PM What does '$', '.', '/' and ' means in this succession? Note: 12:34 PM is a argument to the yourfile.py. This not python syntax but Unix shell. $ = shell prompt ./= look for the

Re: printing list containing unicode string

2007-09-10 Thread J. Cliff Dyer
Xah Lee wrote: This post is about some notes and corrections to a online article regarding unicod and python. -- by happenstance i was reading: Unicode HOWTO http://www.amk.ca/python/howto/unicode Here's some problems i see: ・ No conspicuous authorship. (however, oddly, it

Re: Enum class with ToString functionality

2007-09-10 Thread J. Cliff Dyer
TheFlyingDutchman wrote: On Sep 10, 7:12 pm, Ben Finney [EMAIL PROTECTED] wrote: TheFlyingDutchman [EMAIL PROTECTED] writes: URL:http://cheeseshop.python.org/pypi/enum/ (Please preserve attribution lines so it's clear who wrote what.) Looking at the documentation it looks excellent. But

Re: Modul (%) in python not like in C?

2007-09-11 Thread J. Cliff Dyer
Bryan Olson wrote: Scott David Daniels wrote: C, which was designed as a high level assembly language, does not tightly define the results of / and % for negative numbers. Instead it defines the result for positive over positive, and constrains the result for the others. Not

Re: Enum class with ToString functionality

2007-09-11 Thread J. Cliff Dyer
Zara wrote: On Mon, 10 Sep 2007 02:28:57 -0700, [EMAIL PROTECTED] wrote: Hi, I have the following class - class TestOutcomes: PASSED = 0 FAILED = 1 ABORTED = 2 plus the following code - testResult = TestOutcomes.PASSED testResultAsString if testResult ==

Re: function to do dynamic import?

2007-09-11 Thread J. Cliff Dyer
bambam wrote: import works in the main section of the module, but does not work as I hoped when run inside a function. That is, the modules import correctly, but are not visible to the enclosing (global) scope. Questions: (1) Where can I read an explanation of this? (2) Is there a work

Re: Python statements not forcing whitespace is messy?

2007-09-15 Thread J. Cliff Dyer
buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y)

Re: string questions

2007-09-15 Thread J. Cliff Dyer
Marc 'BlackJack' Rintsch wrote: But please don't use the functions in `string` that are also available as methods on strings. Those functions are deprecated. Meaning (for newbie clarification): instead of string.upper(s2), just do s2.upper(). For more detail, see the docs. --

Re: generate list of partially accumulated values

2007-09-16 Thread J. Cliff Dyer
ZeD wrote: cesco wrote: The list is composed of objects: l = [obj1, obj2, obj3, obj4] and I need to call a method (say method1) on each object as follow: l1 = [obj1.method1(obj2), obj2.method1(obj3), obj3.method1(obj4), obj4] to me it sounds a bit different from the original

SVG to raster conversion.

2007-09-16 Thread J. Cliff Dyer
Does anybody know a good solution (preferably in python) for rasterizing SVG or other vector graphics. I'm thinking something like vector_image = SVGFile(path_to_image) raster_image = vector_image.rasterize(format, (width, height), dpi) raster_image.write(out_file) Thanks for any pointers you

Re: SVG to raster conversion.

2007-09-16 Thread J. Cliff Dyer
Stefan Behnel wrote: J. Cliff Dyer wrote: Does anybody know a good solution (preferably in python) for rasterizing SVG or other vector graphics. I'm thinking something like vector_image = SVGFile(path_to_image) raster_image = vector_image.rasterize(format, (width, height), dpi

Re: Python with

2007-09-16 Thread J. Cliff Dyer
Ivan Voras wrote: Hi, I'm looking for a construct that's similar to (Turbo) Pascal's with statement. I read about the Python's new with statement, but I was dissapointed to learn that it does something different (I still don't see how it's better than try..except..finally, but that's not my

Re: Try this

2007-09-16 Thread J. Cliff Dyer
[EMAIL PROTECTED] wrote: The very presence of an algorithm to detect encoding is a bug. Files with they .txt extension should always be treated as ANSI even if they contain binary data. Notepad should never be allowed to try to decide what the encoding is if the the open dialog has the

Re: Python with

2007-09-17 Thread J. Cliff Dyer
Ivan Voras wrote: Laurent Pointal wrote: The ugly part is the 'tmp' name, try to choose a name with a proper meaning about what it is really, and it become clean and readable: filerefs = some.big.structure.or.nested.object.with.file.references filerefs.encoding = utf-8 filerefs.name =

Re: adodb with mysql - connection string syntax for filepath

2007-09-17 Thread J. Cliff Dyer
Mridula Ramesh wrote: Dear all, Hi. I am not very tech-savvy so please pardon me if this is a stupid question: so far I have been googling for about 4 days to find help for this, so now I am desperate! :) How do you use adodb with mysql to connect to a file that is on your machine? I'm

Re: UTF-8 characters in doctest

2007-09-20 Thread J. Cliff Dyer
John J. Lee wrote: Peter Otten [EMAIL PROTECTED] writes: [...] def f(s): return (s,) Forgive me if this is a stupid question, but: What purpose does function f serve? John Well, it has nothing to do with the unicode bit that came before it. It just takes an argument,

Re: UTF-8 characters in doctest

2007-09-20 Thread J. Cliff Dyer
J. Cliff Dyer wrote: John J. Lee wrote: Peter Otten [EMAIL PROTECTED] writes: [...] def f(s): return (s,) Forgive me if this is a stupid question, but: What purpose does function f serve? John Well, it has nothing to do with the unicode bit

Re: RE Help

2007-09-21 Thread J. Cliff Dyer
Thomas Jollans wrote: On Friday 21 September 2007, [EMAIL PROTECTED] wrote: Not specific to Python, but it will be implemented in it... how do I compile a RE to catch everything between two know values? Here's what I've tried (but failed) to accomplish... the knowns here are START and

  1   2   3   >