Re: Bit of List replacing trouble (newbie)
Zethex wrote: > At the moment i'm doing a piece of work for school and I'm stuck at the > moment. > > I have a list of words, for example: > > Sentence = ['A', 'dog', 'walked', 'across', 'the', 'street'] > > I have another list which I need to use to replace certain words, and its > in the form of: > > synonyms = [ > [canine, [dog, puppy, bulldog]], > [ road, [street, avenue, court]] > ] > What the procedure must do is replace dog with canine, and street with > road. Therefore if a word is in the sentence and appears on the right side > of the list entry, replace it with the left entry. > > I can't seem to find a help file with what I'm after. I'm just wondering > if anyone can help me on the right track on how to start this procedure, > maybe not an answer but just a little help on how to get started as I'm > complete stuck right now. See if you can put the synonyms in a dict: syndict = {"dog": "canine", "puppy": "canine", ..., "court": "road"} The code to achieve that should consist of two nested loops. You can then look up a word easily with word = syndict.get(word, word) Put that into another loop iterating over the words of the original sentence and build the new sentence by appending to a fresh list. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 22, 1:41 am, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote: > > > > Notice that 1e16-1 doesn't exist in IEEE double precision: > > > 1e16-2 == 0x1.1c37937e07fffp+53 > > > 1e16 == 0x1.1c37937e08p+53 > > > > (that is, the hex representation ends with "7fff", then goes to > > > "8000"). > > > > So, it's just rounding. It could go up, to 1e16, or down, to 1e16-2. > > > This is not a bug, it's a feature. > > > I didn't answer your question. :-/ > > > Adding a small number to 1e16-2 should be rounded to nearest (1e16-2) > > by default. So that's strange. > > > The following code compiled with gcc 4.2 (without optimization) gives > > the same result: > > > #include > > > int main (void) > > { > > double a; > > > while(1) { > > scanf("%lg", &a); > > printf("%a\n", a); > > printf("%a\n", a + 0.999); > > printf("%a\n", a + 0.); > > } > > > } > > However, compiling it with "-mfpmath=sse -msse2" it works. (it > doesn't work with -msse either). Finally (and the answer is obvious). 387 breaks the standards and doesn't use IEEE double precision when requested to do so. It reads the 64-bit double and converts it to a 80-bit long double. In this case, 1e16-2 + 0. == 1e16-1. When requested by the printf call, this 80-bit number (1e16-1) is converted to a double, which happens to be 1e16. -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On May 21, 1:10 pm, notbob <[EMAIL PROTECTED]> wrote: > > So, here's my delimna: I want to start a blog. Yeah, who doesn't. > Yet, I want learn the guts of it instead of just booting up some > wordwank or whatever. Here's a simple computation to consider... WordPress' codebase is approximately a megabyte of PHP code and megabyte of JavaScript code. Assuming that the average line of that code is 50 characters long, you are looking at 20,000 lines of code in PHP and as many in JavaScript. Based on the notion that the average developer out there writes 100 lines a day, either you're in for a two-year project or your product is going to have seriously reduced functionality compared to something that's been freely available for years. What's your choice? > Then I run across that blog, Coding Horror, and start reading > articles like this: > > http://www.codinghorror.com/blog/archives/001119.html You should read what some computer scientists write about SQL... :) > Now what? Nothing. Everyone is entitled to their opinion. You are free to form your own. > I've taken basic basic and basic C, but am barely literate > in html. Maybe that (and some JavaScript) is something to work on first before delving into server-side programming? > Well, that's my actual question, then. Is php really so bad > I'm just wasting my time? Or is it really the quickest way > to blog functionality? The quickest way to blog functionality is an account on a blogging service... :) > Would I be better served in the long run learning python, which > claims to be easy as pie to learn/program (still looks hard to > me). I admit I'm no code geek. But, I'm not completely brain > dead, either, and I need something to keep my geezer brain > sparking. What say ye? If the purpose is to keep the brain sparking, it doesn't matter what you learn as long as you're enjoying the process. You might as well take up Japanese while you're at it... Cheers, NC -- http://mail.python.org/mailman/listinfo/python-list
Re: related to python
On May 21, 9:34 pm, "salil_reeves" <[EMAIL PROTECTED]> wrote: > develop a function called standardise_phrase to convert > the user's input to a standard form for subsequent processing. This > involves: > 1. removing all inter-word punctuation, which for our purposes is > assumed to > consist only of commas (`,'), full stops (`.'), exclamation marks > (`!') or > question marks (`?'); > 2. stripping away any leading and trailing blank spaces; and > 3. replacing words in the user's input with ELIZA's preferred > vocabulary. > how it is done ?? > can anyone help me with it Yes, but I'm only as willing to put as much effort into my answer as you do into your thread titles. help(str) -- http://mail.python.org/mailman/listinfo/python-list
Bit of List replacing trouble (newbie)
At the moment i'm doing a piece of work for school and I'm stuck at the moment. I have a list of words, for example: Sentence = ['A', 'dog', 'walked', 'across', 'the', 'street'] I have another list which I need to use to replace certain words, and its in the form of: synonyms = [ [canine, [dog, puppy, bulldog]], [ road, [street, avenue, court]] ] What the procedure must do is replace dog with canine, and street with road. Therefore if a word is in the sentence and appears on the right side of the list entry, replace it with the left entry. I can't seem to find a help file with what I'm after. I'm just wondering if anyone can help me on the right track on how to start this procedure, maybe not an answer but just a little help on how to get started as I'm complete stuck right now. -- View this message in context: http://www.nabble.com/Bit-of-List-replacing-trouble-%28newbie%29-tp17397379p17397379.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: related to python
This looks like a homework assignment, but... On Wed, May 21, 2008 at 10:34 PM, salil_reeves <[EMAIL PROTECTED]> wrote: > develop a function called standardise_phrase to convert > the user's input to a standard form for subsequent processing. This > involves: > 1. removing all inter-word punctuation, which for our purposes is > assumed to > consist only of commas (`,'), full stops (`.'), exclamation marks > (`!') or > question marks (`?'); I think a question similar to this was answered on the list today or yesterday, for removing spaces and hyphens. > 2. stripping away any leading and trailing blank spaces; and If your solution for part 1 can't be extended to cover this... you might have to find another way to "strip" the the spaces ;) > 3. replacing words in the user's input with ELIZA's preferred > vocabulary. Assuming you have some sort of dictionary mapping words to ELIZA words, you should be able to iterate through all of the words in the input and, using that dictionary, swap the key for the value in your input string. There, I think those are sufficiently vague as to not do your homework for you, but maybe get you started... -- http://mail.python.org/mailman/listinfo/python-list
Re: Write bits in file
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >On May 20, 12:14 am, Tim Roberts <[EMAIL PROTECTED]> wrote: >> Monica Leko <[EMAIL PROTECTED]> wrote: >> >> >I have a specific format and I need binary representation. Does >> >Python have some built-in function which will, for instance, represent >> >number 15 in exactly 10 bits? >> >> For the record, I'd like to point out that even C cannot do this. You need >> to use shifting and masking to produce a stream of 8-bit bytes, or to >> extract your values from a stream of 8-bit bytes. > >Technically specifying 8-bits isn't quite accurate, as C allows for 9- >bit bytes and other variations depending on the architecture. But >that may be overly pedantic unless you have a PDP-10 laying around >that you're writing C code on or something like that. As long as we are being pedantic, and I don't mind that, I would point out that I didn't actually say that C worked in 8-bit bytes. I was very careful to say merely that, assuming you wanted a stream of 8-bit bytes, you need to use shifting and masking to produce it. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: related to python
On May 21, 9:34 pm, "salil_reeves" <[EMAIL PROTECTED]> wrote: > develop a function called standardise_phrase to convert > the user's input to a standard form for subsequent processing. This > involves: > 1. removing all inter-word punctuation, which for our purposes is > assumed to > consist only of commas (`,'), full stops (`.'), exclamation marks > (`!') or > question marks (`?'); > 2. stripping away any leading and trailing blank spaces; and > 3. replacing words in the user's input with ELIZA's preferred > vocabulary. > how it is done ?? > can anyone help me with it -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 22, 1:36 am, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote: > On May 22, 1:26 am, Henrique Dante de Almeida <[EMAIL PROTECTED]> > wrote: > > > > > On May 21, 3:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > > >>> a = 1e16-2. > > > >>> a > > > 9998.0 > > > >>> a+0.999 # gives expected result > > > 9998.0 > > > >>> a+0. # doesn't round correctly. > > > > 1.0 > > > Notice that 1e16-1 doesn't exist in IEEE double precision: > > 1e16-2 == 0x1.1c37937e07fffp+53 > > 1e16 == 0x1.1c37937e08p+53 > > > (that is, the hex representation ends with "7fff", then goes to > > "8000"). > > > So, it's just rounding. It could go up, to 1e16, or down, to 1e16-2. > > This is not a bug, it's a feature. > > I didn't answer your question. :-/ > > Adding a small number to 1e16-2 should be rounded to nearest (1e16-2) > by default. So that's strange. > > The following code compiled with gcc 4.2 (without optimization) gives > the same result: > > #include > > int main (void) > { > double a; > > while(1) { > scanf("%lg", &a); > printf("%a\n", a); > printf("%a\n", a + 0.999); > printf("%a\n", a + 0.); > } > > } > > However, compiling it with "-mfpmath=sse -msse2" it works. (it doesn't work with -msse either). -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 22, 1:26 am, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote: > On May 21, 3:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > >>> a = 1e16-2. > > >>> a > > 9998.0 > > >>> a+0.999 # gives expected result > > 9998.0 > > >>> a+0. # doesn't round correctly. > > > 1.0 > > Notice that 1e16-1 doesn't exist in IEEE double precision: > 1e16-2 == 0x1.1c37937e07fffp+53 > 1e16 == 0x1.1c37937e08p+53 > > (that is, the hex representation ends with "7fff", then goes to > "8000"). > > So, it's just rounding. It could go up, to 1e16, or down, to 1e16-2. > This is not a bug, it's a feature. I didn't answer your question. :-/ Adding a small number to 1e16-2 should be rounded to nearest (1e16-2) by default. So that's strange. The following code compiled with gcc 4.2 (without optimization) gives the same result: #include int main (void) { double a; while(1) { scanf("%lg", &a); printf("%a\n", a); printf("%a\n", a + 0.999); printf("%a\n", a + 0.); } } -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: >>> a = 1e16-2. > >>> a > 9998.0 > >>> a+0.999 # gives expected result > 9998.0 > >>> a+0. # doesn't round correctly. > > 1.0 Notice that 1e16-1 doesn't exist in IEEE double precision: 1e16-2 == 0x1.1c37937e07fffp+53 1e16 == 0x1.1c37937e08p+53 (that is, the hex representation ends with "7fff", then goes to "8000"). So, it's just rounding. It could go up, to 1e16, or down, to 1e16-2. This is not a bug, it's a feature. -- http://mail.python.org/mailman/listinfo/python-list
Re: C-like assignment expression?
On 21 Mai, 19:56, sturlamolden <[EMAIL PROTECTED]> wrote: > On May 21, 11:38 am, [EMAIL PROTECTED] wrote: > > > if (match = my_re1.match(line): > > # use match > > elsif (match = my_re2.match(line)): > > # use match > > elsif (match = my_re3.match(line)) > > # use match > > > ...buy this is illegal in python. > > Assignment expressions is disallowed in Python to protect against a > very common bug in C/C++ programs, the (accidental) confusion of > >if (match = my_re1.match(line)) > > with > >if (match == my_re1.match(line)) > > or vice versa. This is just a syntactical issue. But what is the *value* of an assigment? In Python it is always None: assigments are statements, not expressions. However Guido and team have found a *pragmatic* solution for this at another place: with open("myFile") as f: BLOCK Compare this with a possible syntactical form of an if-statement: if EXPR as NAME: BLOCK This isn't ugly syntax-wise. It's just a bit harder to understand the semantics of an if-statement. It might read like this: "Evaluate EXPR and compute bool(EXPR). If this value is True assign EXPR to NAME and execute BLOCK. Otherwise refuse both assigment and BLOCK execution." Maybe assignment can be performed unconditionally as in the C case. I'm not sure about this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 11:27 pm, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 7:01 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > The crucial thing is not to slow down the calculations with useless > > bells and whistles. > > Are you running your simulations on a system that does or does not > support the "useless bell and whistle" of correct rounding? If not, > how do you prevent regression towards 0? The "useless bell and whistle" is switching to multiprecision. I'm not sure whether our hardware has a rounding bias or not but I doubt it would matter if it did. > For example, one of the things that caused the PS3 to be in 3rd place > behind the Wii and XBox 360 is that to save a cycle or two, the PS3 > cell core does not support rounding of single precision results -- it > truncates them towards 0. That led to horrible single-pixel errors in > the early demos I saw, which in term helped contribute to game release > delays, which has turned into a major disappointment for Sony. And you believe that automatically detecting rounding errors and switching to multi-precision in software would have saved Sony all this? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On 21 Mag, 17:34, Dave Parker <[EMAIL PROTECTED]> wrote: > [...] symbols are more confusing for people to learn about than > words. There are lots of people who are fluent in English, but > dislike math. > > So, I opted for a simple, unambiguous, non-mathematical way of > expressing "assignment" which makes sense even to the non- > mathematically inclined: > > Set x to 8. Sorry but... are you really trying to tell us that a person which is not able to understand "x = 5" should use a programming language? Such a person shouldn't even use a computer and I strongly doubt that your syntax solution would make ring a bell in his head! Besides that what makes you think that: Set n to 1 Factorial is a function(n) doing if n = 0 then return 1 else return n*factorial(n-1). ...is more clear/intuitive than: n = 1 def factorial(n): "this is a function doing:" return 1 if n == 0 else n * factorial(n-1) ...? IMHO, it seems to me that you've just tried to mix "comments" and "code" into a single thing for no other reason than to be different. I'd be curious to see some code samples solving some - real world - problems instead of showing hot to calculate factorials, printing hello worlds or read from a file, which are the only code samples I've seen in the homepage and in the documentation. --- Giampaolo http://code.google.com/p/pyftpdlib -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 7:01 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > The crucial thing is not to slow down the calculations with useless > bells and whistles. Are you running your simulations on a system that does or does not support the "useless bell and whistle" of correct rounding? If not, how do you prevent regression towards 0? For example, one of the things that caused the PS3 to be in 3rd place behind the Wii and XBox 360 is that to save a cycle or two, the PS3 cell core does not support rounding of single precision results -- it truncates them towards 0. That led to horrible single-pixel errors in the early demos I saw, which in term helped contribute to game release delays, which has turned into a major disappointment for Sony. -- http://mail.python.org/mailman/listinfo/python-list
Re: about python modules
srinivas wrote: ... i want to know how to import my functions folder to python in sucha way that the functions in functions folder should work like python library modules . i have python in folder C:\python25\.. and functions folder D:\programs\Functions\ pls help me friends how to do that. An unmentioned possibility: Create a file named "whatever.pth" (where the "whatever" is your choice). The contents of this file should be a line containing the path to your directory (in your case a single line containing "D:\programs\Functions" (w/o the quotes). Put this file in your site-packages file (for windows in your case, that is C:\Python25\Lib\site-packages --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Publish a program
On May 21, 11:31 pm, TheSaint <[EMAIL PROTECTED]> wrote: > Other idea, I'll apreciate somebody to join and put new views on this > project. Have you thought about putting the full project somewhere like http://code.google.com/ ? Nothing gets comments & criticisms like used code :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 21, 7:49 pm, MRAB <[EMAIL PROTECTED]> wrote: > I've thought of one possible drawback: "a" and "an" can be used as > variables, so the "is a" part might cause a problem. You'd need to > check the parser to find out... Good point, I hadn't noticed that. I'll check it out. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's doc problems: sort
On May 22, 2:28 am, Xah <[EMAIL PROTECTED]> wrote: > «No, what was generally rejected was the idea that *you* could bring > more clarity to the documentation, based on the complete absence of it > in your posts & "essays". Basically, noone wanted docs that would > randomly degenerate into ad hominem accusations of elitism aimed at > the module authors.» > > Dear Alex moron number 23, Thank you for illustrating my point perfectly. -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting title and/or summary of a website
On May 22, 3:28 am, रवींदर ठाकुर (ravinder thakur) <[EMAIL PROTECTED]> wrote: > is there any lib in python that provides a mechanism to get the title > of a web page ? also is there anything available to get a nice summary > like the way google shows below every link ? It's not part of the standard lib but I really like using BeautifulSoup for this kind of thing: from urllib import urlopen from BeautifulSoup import BeautifulSoup html = urlopen("http://www.google.com";).read() soup = BeautifulSoup(html) print soup.title # 'Google' print soup.title.renderContents() # 'Google' http://www.crummy.com/software/BeautifulSoup/ - alex23 -- http://mail.python.org/mailman/listinfo/python-list
related to python
develop a function called standardise_phrase to convert the user's input to a standard form for subsequent processing. This involves: 1. removing all inter-word punctuation, which for our purposes is assumed to consist only of commas (`,'), full stops (`.'), exclamation marks (`!') or question marks (`?'); 2. stripping away any leading and trailing blank spaces; and 3. replacing words in the user's input with ELIZA's preferred vocabulary. how it is done ?? can anyone help me with it -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I know when all threads are done?
Zerge wrote: I can launch threads just fine, but then I have to do a time.sleep(n) so the main thread from which they where launched will wait for all the threads to return. How can I detect when all threads are done and then return control to the main threads? Thanks for your help Use "join". John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Psyche (scheme in python), how to run on vista?
On May 22, 5:19 am, [EMAIL PROTECTED] wrote: > anyone using psyche? > > how do you run it on Vista? what file do you click? there is no > obvious file like psyche.py... After installation, you should be able to find 'psyche.bat' in C: \Python2.X\Scripts. However, it hard codes the path for the python interpreter, so you'll need to edit it to fix. BUT! Doing so just reveals the next problem, running it I keep getting complaints about the following piece of code: def get_epsilon(self, None = None): """ Return the mapping for epsilon, or None. """ return self.special.get('', None) I've never used psyche and I've no idea what the author was thinking here, but the 'None = None' in the function parameters is a serious 'wtf?' You need to edit site-packages\psyche\Plex\Transitions.py line 85 to be: def get_epsilon(self): Then running psyche.bat will at least get the interpreter running. I can make no guarantees on its correctness, however. But at least it _seems_ to work: C:\Python25\Scripts>psyche Psyche version 0.4.3, Copyright (C) 2002 Y. Duppen Psyche comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; read the attached COPYING for details. psyche> (define (plus1 x) (+ x 1)) psyche> (plus1 2) 3 Hope this helps! - alex23 -- http://mail.python.org/mailman/listinfo/python-list
Re: backport of 'set' to python 2.3?
>> Does anyone have a pure python implementation of the builtin 'set' >> object so that I could use that in python 2.3? > > Yes. You have one in Python 2.3 already > http://www.python.org/doc/2.3.5/lib/module-sets.html>, it's just > not a builtin. > >> If this would be the case that would be really great as I wouldn't >> have to change my code that runs happily on 2.5 > > You will, but it's as simple as: > > try: > set() > except NameError: > from sets import Set as set > > You then know that 'set' refers to the set type from that point on (or > you're not on a version of Python that has a 'set' type at all). Thanks Ben! I should have checked the docs Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: backport of 'set' to python 2.3?
Daniel Fetchinson wrote: Does anyone have a pure python implementation of the builtin 'set' object so that I could use that in python 2.3? If this would be the case that would be really great as I wouldn't have to change my code that runs happily on 2.5 and makes use of 'set'. Speed and performance doesn't matter, any implementation that does exactly the same as the builtin 'set' in 2.5 would be great. Cheers, Daniel From "What's new in Python 2.4": Python 2.3 introduced the sets module. C implementations of set data types have now been added to the Python core as two new built-in types, set(iterable) and frozenset(iterable). They provide high speed operations for membership testing, for eliminating duplicates from sequences, and for mathematical operations like unions, intersections, differences, and symmetric differences. You should be able to use sets module in 2.3. -Larry -- http://mail.python.org/mailman/listinfo/python-list
How do I know when all threads are done?
I can launch threads just fine, but then I have to do a time.sleep(n) so the main thread from which they where launched will wait for all the threads to return. How can I detect when all threads are done and then return control to the main threads? Thanks for your help -- http://mail.python.org/mailman/listinfo/python-list
Re: backport of 'set' to python 2.3?
"Daniel Fetchinson" <[EMAIL PROTECTED]> writes: > Does anyone have a pure python implementation of the builtin 'set' > object so that I could use that in python 2.3? Yes. You have one in Python 2.3 already http://www.python.org/doc/2.3.5/lib/module-sets.html>, it's just not a builtin. > If this would be the case that would be really great as I wouldn't > have to change my code that runs happily on 2.5 You will, but it's as simple as: try: set() except NameError: from sets import Set as set You then know that 'set' refers to the set type from that point on (or you're not on a version of Python that has a 'set' type at all). -- \ "I have a large seashell collection, which I keep scattered on | `\the beaches all over the world. Maybe you've seen it." -- | _o__)Steven Wright | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 21, 8:34 pm, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 1:14 pm, MRAB <[EMAIL PROTECTED]> wrote: > > > I wonder whether "is" could be used both for "x is value" and "x is a > > type" without causing a problem: > > > If command is a string ... > > > If command is "quit" ... > > I think you are right. I like "If command is "quit" ...". For a user > who wasn't mathemetically inclined and was doing mainly string > manipulation, I think it might be easier to read than the equivalent > "If command = "quit" ...". By making them exactly equivalent, I can't > think of any confusion that might induce bugs. If you think of any > drawbacks, please let me know. > I've thought of one possible drawback: "a" and "an" can be used as variables, so the "is a" part might cause a problem. You'd need to check the parser to find out... > Otherwise, I'll put it in the next > time I update the parser (probably this weekend). Thank you again for > your suggestions. -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
notbob wrote: I'm not posting this just to initiate some religious flame war, though it's the perfect subject to do so. No, I actaully want some serious advice about these two languages and since I think usenet is the best arena to find it, here ya' go. So, here's my delimna: I want to start a blog. Yeah, who doesn't. Yet, I want learn the guts of it instead of just booting up some wordwank or whatever. I started to learn python, but heard php was easier or faster or more like shell scripting or... fill in the blank. Anyway, so I change over to learning php. Then I run across that blog, Coding Horror, and start reading articles like this: http://www.codinghorror.com/blog/archives/001119.html Now what? Go back to python. Soldier on with php? What do I know? Not much. I can setup mysql and apache,, but don't know how to use 'em, really. I use emacs and run slackware and can fumble my way through bash scripts, but I can't really write them or do lisp. I've taken basic basic and basic C, but am barely literate in html. Sometimes it seems overwhelming, but I persevere because it's more fun/challenging than video games, which bore me to tears. Well, that's my actual question, then. Is php really so bad I'm just wasting my time? Or is it really the quickest way to blog functionality? Would I be better served in the long run learning python, which claims to be easy as pie to learn/program (still looks hard to me). I admit I'm no code geek. But, I'm not completely brain dead, either, and I need something to keep my geezer brain sparking. What say ye? nb Check out the Pylons blog tutorial. You will have a simple blog up and running in less than 30 minutes and have a platform to extend it with as much functionality as you want later on. Larry Bates Pylons blog tutorial: http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On May 22, 6:10 am, notbob <[EMAIL PROTECTED]> wrote: > Well, that's my actual question, then. Is php really so bad I'm just > wasting my time? Or is it really the quickest way to blog functionality? > Would I be better served in the long run learning python, which claims to be > easy as pie to learn/program (still looks hard to me). I admit I'm no code > geek. But, I'm not completely brain dead, either, and I need something to > keep my geezer brain sparking. What say ye? Python has 71 built in functions (in 2.5). Atwood's list of PHP built ins beginning with 'a' is 124 functions long. There's a clear reason why people say Python "fits your brain" :) -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser error
On May 22, 8:18 am, [EMAIL PROTECTED] wrote: > Sorry, im new to both python and newsgroups, this is all pretty > confusing. So I need a line in my __init__ function of my class? The > spider class I made inherits from HTMLParser. Its just using the > feed() function that produces errors though, the rest seems to work > fine. Let me repeat: it would make this a lot easier if you would paste actual code. As you say, your Spider class inherits from HTMLParser, so you need to make sure that you set it up correctly so that the HTMLParser functionality you've inherited will work correctly (or work as you want it to work). If you've added your own __init__ to Spider, then the __init__ on HTMLParser is no longer called unless you *explicitly* call it yourself. Unfortunately, my earlier advice wasn't totally correct... HTMLParser is an old-style object, whereas super() only works for new-style objects, I believe. (If you don't know about old- v new-style objects, see http://docs.python.org/ref/node33.html). So there are a couple of approaches that should work for you: class SpiderBroken(HTMLParser): def __init__(self): pass # don't do any ancestral setup class SpiderOldStyle(HTMLParser): def __init__(self): HTMLParser.__init__(self) class SpiderNewStyle(HTMLParser, object): def __init__(self): super(SpiderNewStyle, self).__init__() Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> html = open('temp.html','r').read() >>> from spider import * >>> sb = SpiderBroken() >>> sb.feed(html) Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\HTMLParser.py", line 107, in feed self.rawdata = self.rawdata + data AttributeError: SpiderBroken instance has no attribute 'rawdata' >>> so = SpiderOldStyle() >>> so.feed(html) >>> sn = SpiderNewStyle() >>> sn.feed(html) >>> The old-style version is probably easiest, so putting this line in your __init__ should fix your issue: HTMLParser.__init__(self) If this still isn't clear, please let me know. - alex23 -- http://mail.python.org/mailman/listinfo/python-list
backport of 'set' to python 2.3?
Does anyone have a pure python implementation of the builtin 'set' object so that I could use that in python 2.3? If this would be the case that would be really great as I wouldn't have to change my code that runs happily on 2.5 and makes use of 'set'. Speed and performance doesn't matter, any implementation that does exactly the same as the builtin 'set' in 2.5 would be great. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On May 21, 11:10 pm, notbob <[EMAIL PROTECTED]> wrote: > I'm not posting this just to initiate some religious flame war, though it's > the perfect subject to do so. No, I actaully want some serious advice about > these two languages and since I think usenet is the best arena to find it, > here ya' go. > > So, here's my delimna: I want to start a blog. Yeah, who doesn't. Yet, I > want learn the guts of it instead of just booting up some wordwank or > whatever. I started to learn python, but heard php was easier or faster or > more like shell scripting or... fill in the blank. Anyway, so I change over > to learning php. Then I run across that blog, Coding Horror, and start > reading articles like this: > > http://www.codinghorror.com/blog/archives/001119.html > > Now what? Go back to python. Soldier on with php? What do I know? Not > much. I can setup mysql and apache,, but don't know how to use 'em, really. > I use emacs and run slackware and can fumble my way through bash scripts, > but I can't really write them or do lisp. I've taken basic basic and basic > C, but am barely literate in html. Sometimes it seems overwhelming, but I > persevere because it's more fun/challenging than video games, which bore me > to tears. > > Well, that's my actual question, then. Is php really so bad I'm just > wasting my time? Or is it really the quickest way to blog functionality? > Would I be better served in the long run learning python, which claims to be > easy as pie to learn/program (still looks hard to me). I admit I'm no code > geek. But, I'm not completely brain dead, either, and I need something to > keep my geezer brain sparking. What say ye? > > nb By the way anything goes to you.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
alex23 <[EMAIL PROTECTED]> writes: > On May 22, 9:13 am, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > > In case it's not clear what I meant: after executing > > some_function() exception SomeExcpetion gets risen. Then, in > > except block I do something to fix whatever is causing the > > exception and then I would like to go back to try block, and > > execute some_function() again. Is that doable? > > If you know what exception to expect, and you know how to "fix" the > cause, why not just put tests _before_ some_function() is called to > ensure that everything is as it needs to be? This is LBYL ("Look Before You Leap") programming style, and is contrasted with EAFP ("it is Easier to Ask Forgiveness than Permission") style. http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html> EAFP is usually considered more Pythonic, and usually results in smaller, clearer code. I'm currently undecided in this case whether EAFP is correct — though I suspect it is, as in most cases. I wanted to address your "why not LBYL" question though. -- \ “Courage is not the absence of fear, but the decision that | `\ something else is more important than fear.” —Ambrose | _o__) Redmoon | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
Dave Parker wrote: On May 20, 7:05 pm, Collin <[EMAIL PROTECTED]> wrote: Personally, FT is a bit meh to me. The way you issue your statements I always think something is wrong, mainly because when I want to define, say, x, in python I'd go: x = "whatever" Instantly noting that I defined x. While in Flaming Thunder I'd have to type: Set x to "whatever" It just feels wrong. Actually, it felt wrong to me when I first started working on Flaming Thunder because I've been programming for decades and have had all of the programming idioms burned into my brain. But after getting input from children and teachers, etc, it started feeling right. For example, consider the two statements: x = 8 x = 10 The reaction from most math teachers (and kids) was "one of those is wrong because x can't equal 2 different things at the same time". Many computer languages conflate "equality" with "assignment" and then go to even more confusing measures to disambiguate them (such as using == for equality, or := for assignment). Plus, symbols are more confusing for people to learn about than words. There are lots of people who are fluent in English, but dislike math. So, I opted for a simple, unambiguous, non-mathematical way of expressing "assignment" which makes sense even to the non- mathematically inclined: Set x to 8. That way, = can be reserved unambiguously and unconfusingly for the mathematical notion of "equality" -- because it's in their math classes that people learn what = means: Set QuadraticEquation to a*x^2 + b*x + c = 0. Then I guess the elementary school kids will use your FT system while we will use our naturally burned-in sense of syntax from other programming languages, eh? Not saying this as a negative or anything, I'm just saying that most of us have a habit, and it's not necessarily a bad nor good habit, of doing things the way most languages have them done. For example, x = 8 is extremely readable, to, I assume, most of us. Set x to 8, it takes some time getting used to. Why should we switch to a language that will take us time to get used and some more time to understand syntax when we already understand and can efficiently use our current languages? It's like going to the middle of London and screaming: "HEY GUYS GUESS WHAT! I JUST INVENTED A NEW LANGUAGE AND IT'S VERY VERY EASY TO LEARN!" And the people who would try the language would find the way you do everything is very different from English, or their native language, for that matter. Best let sleeping dogs lie. Collin -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
On May 22, 9:13 am, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > In case it's not clear what I meant: after executing some_function() > exception SomeExcpetion gets risen. Then, in except block I do something > to fix whatever is causing the exception and then I would like to go back > to try block, and execute some_function() again. Is that doable? If you know what exception to expect, and you know how to "fix" the cause, why not just put tests _before_ some_function() is called to ensure that everything is as it needs to be? -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 4:56 pm, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > > My understand is no, not if you're using IEEE floating point. > > Yes, that would explain it. I assumed that Python automatically > switched from hardware floating point to multi-precision floating > point so that the user is guaranteed to always get correctly rounded > results for +, -, *, and /, like Flaming Thunder gives. Correct > rounding and accurate results are fairly crucial to mathematical and > scientific programming, in my opinion. Having done much mathematical and scientific prorgamming in my day, I would say your opinion is dead wrong. The crucial thing is not to slow down the calculations with useless bells and whistles. Scientists and engineers are smart enough to use more precision than we need, and we don't really need that much. For instance, the simulations I run at work all use single precision (six decimal digits) even though double precision is allowed. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: simple way to touch a file if it does not exist
On May 21, 5:37 pm, Nikhil <[EMAIL PROTECTED]> wrote: > bukzor wrote: > > On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > >> On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > > >>> what are the simple ways? > >>> I could think of os.open(), os.exec(touch file) > >>> are there any simpler methods? > >> Just use os.path.exists to check for file existence and open() as > >> replacement for touch. > > > import os > > if not os.path.exists('file'): > >> ... open('file', 'w').close() > >> ... > > >> --- Giampaolohttp://code.google.com/p/pyftpdlib/ > > > As simple as it gets is a single builtin function call: > > > open("somefile.txt", "a") > > > Leave out the ,"a" if you don't mind blanking a pre-existing file. > > Thanks :-) > > That reminds me to check if I could quickly nullify a file if it exists > > if os.path.exists('file'): > open('file', 'w').close() > > Right? You only want to blank it if it exists? If it doesn't exist you won't create it. The .close() is superlative: since you don't keep the value, it gets deallocated and closed by the destructor. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple way to touch a file if it does not exist
bukzor wrote: On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? Just use os.path.exists to check for file existence and open() as replacement for touch. import os if not os.path.exists('file'): ... open('file', 'w').close() ... --- Giampaolohttp://code.google.com/p/pyftpdlib/ As simple as it gets is a single builtin function call: open("somefile.txt", "a") Leave out the ,"a" if you don't mind blanking a pre-existing file. Thanks :-) That reminds me to check if I could quickly nullify a file if it exists if os.path.exists('file'): open('file', 'w').close() Right? -- http://mail.python.org/mailman/listinfo/python-list
Re: simple way to touch a file if it does not exist
On May 21, 5:10 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > > > what are the simple ways? > > I could think of os.open(), os.exec(touch file) > > > are there any simpler methods? > > Just use os.path.exists to check for file existence and open() as > replacement for touch. > > >>> import os > >>> if not os.path.exists('file'): > > ... open('file', 'w').close() > ... > > > > --- Giampaolohttp://code.google.com/p/pyftpdlib/ As simple as it gets is a single builtin function call: open("somefile.txt", "a") Leave out the ,"a" if you don't mind blanking a pre-existing file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:28 pm, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 4:21 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > Which is exactly what the python decimal module does. > > Thank you (and Jerry Hill) for pointing that out. If I want to check > Flaming Thunder's results against an independent program, I'll know to > use Python with the decimal module. Utterly shameless. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple way to touch a file if it does not exist
On 22 Mag, 01:15, Nikhil <[EMAIL PROTECTED]> wrote: > what are the simple ways? > I could think of os.open(), os.exec(touch file) > > are there any simpler methods? Just use os.path.exists to check for file existence and open() as replacement for touch. >>> import os >>> if not os.path.exists('file'): ... open('file', 'w').close() ... >>> --- Giampaolo http://code.google.com/p/pyftpdlib/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
On May 21, 4:33 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > André <[EMAIL PROTECTED]> wrote innews:[EMAIL PROTECTED]: > > > How about something like the following (untested) > > > done = False > > while not done: > > try: > > some_function() > > done = True > > except: > > some_function2() > > some_function3() > > Sure, that works, but I was aiming for something more elegant and Pythonic > ;). > > -- > ___Karlo Lozovina - Mosor > | | |.-.-. web:http://www.mosor.net|| ICQ#: 10667163 > | || _ | _ | Parce mihi domine quia Dalmata sum. > |__|_|__||_|_| It's hard to get around a while loop if you want to conditionally repeat something. There's no built-in way to do what you ask. -- http://mail.python.org/mailman/listinfo/python-list
Re: Showing the method's class in expection's traceback
On 20 mayo, 12:10, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 19 May 2008 10:54:05 -0300, Agustin Villena > <[EMAIL PROTECTED]> escribió: > > > On May 18, 4:31 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> Agustin Villena schrieb: > > >> > is there anyway to show the class of amethodin anexception's > >> > traceback? > >> > I want to improve the line > >> > File "G:\dev\exceptions\sample.py", line 3, in foo > >> > to > >> > File "G:\dev\exceptions\sample.py", line 3, in Some.foo > > >> It should be. You can get a dictionary of the locals of anexception > >> stack frame, of which you could extract the self-parameter's class. > > > I digged on sys.exc_info() object and the traceback module and I > > could't figure how I can get the locals() of theexceptionstackframe > > Put this function in traceback.py, and replace the lines > name = co.co_name > with > name = guess_full_method_name(f) > everywhere. > Please read the docstring!!! > > def guess_full_method_name(frame): > """Guess classname.methodname for a given frame. > > Only a guess! > Assumes the frame belongs to an instancemethod > whose first argument is "self", or a classmethod > whose first argument is "cls". > Doesn't handle correctly any other situation. > Returns the class name of the object on which > the method was called, not the class where > the method was actually defined. > """ > cls_name = None > fun_name = frame.f_code.co_name > self = frame.f_locals.get('self', None) > if self is None: > cls = frame.f_locals.get('cls', None) > else: > cls = getattr(self, '__class__', None) > if cls is not None: > cls_name = getattr(cls, '__name__', None) > if cls_name is not None: > return '%s.%s' % (cls_name, fun_name) > return fun_name > > -- > Gabriel Genellina Thanks! I'll try it Agustin -- http://mail.python.org/mailman/listinfo/python-list
Re: Showing the method's class in expection's traceback
> And not that useful - why would one care about the function being > defined in class X or Y when one have the exact file and line ? I have 3 reasons: 1) My developing time is expended running unit tests and browsing tracebacks to find which is the real problem. Knowing the offender class (instead of the method alone) makes me understand more quickly which component of my software is failing. 2) There are some ocassions where I only have the traceback (e.g. when analyzing an app's log) and no inmediate access to teh source code 3) And finally, for completeness: If a function is really a method, if the traceback show only its name and not the class that defines it, for me its a bug, because the method name has no sense out of its class. Just my two cents Agustin -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
"Karlo Lozovina" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | André <[EMAIL PROTECTED]> wrote in | news:[EMAIL PROTECTED]: | | > How about something like the following (untested) | > | > done = False | > while not done: | > try: | > some_function() | > done = True | > except: | > some_function2() | > some_function3() | | Sure, that works, but I was aiming for something more elegant and Pythonic | ;). while True: try: some_function() break except Exception: patchup() ??? -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
André <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > How about something like the following (untested) > > done = False > while not done: > try: > some_function() > done = True > except: > some_function2() > some_function3() Sure, that works, but I was aiming for something more elegant and Pythonic ;). -- ___Karlo Lozovina - Mosor | | |.-.-. web: http://www.mosor.net || ICQ#: 10667163 | || _ | _ | Parce mihi domine quia Dalmata sum. |__|_|__||_|_| -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On Wed, May 21, 2008 at 5:27 PM, Fuzzyman <[EMAIL PROTECTED]> wrote: > On May 14, 10:30 pm, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: >> > Dave Parker schrieb: >> > > All of the calculators and textbooks that elementary school students >> > > use, use "^" for powers. >> >> I've never seen this symbol in textbooks. In textbooks, powers are >> written using superscript. >> >> >> Just like Flaming Thunder does. I haven't >> > > seen "**" for powers since FORTRAN. >> >> I haven't seen any language using '^' as the power operator so far - >> but I've seen quite a lot of them using it as the bitwise XOR operator. > > > Excel uses the caret as the power operator. Arguably the worlds most > widely used programming environment... > I think BASIC did, too. I know I used to use it in some language and was confused when I first tried to use it in Java and didn't get what I was expecting. ("Some language" must be in the set (BASIC, C, Logo).) -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning to 'try' block after catching an exception
On May 21, 8:13 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > I'm not sure if Python can do this, and I can't find it on the web. So, > here it goes: > > try: > some_function() > except SomeException: > some_function2() > some_function3() > ... > # somehow goto 'try' block again > > In case it's not clear what I meant: after executing some_function() > exception SomeExcpetion gets risen. Then, in except block I do something > to fix whatever is causing the exception and then I would like to go back > to try block, and execute some_function() again. Is that doable? How about something like the following (untested) done = False while not done: try: some_function() done = True except: some_function2() some_function3() André > > Thanks. > > -- > ___Karlo Lozovina - Mosor > | | |.-.-. web:http://www.mosor.net|| ICQ#: 10667163 > | || _ | _ | Parce mihi domine quia Dalmata sum. > |__|_|__||_|_| -- http://mail.python.org/mailman/listinfo/python-list
simple way to touch a file if it does not exist
what are the simple ways? I could think of os.open(), os.exec(touch file) are there any simpler methods? -- http://mail.python.org/mailman/listinfo/python-list
Returning to 'try' block after catching an exception
I'm not sure if Python can do this, and I can't find it on the web. So, here it goes: try: some_function() except SomeException: some_function2() some_function3() ... # somehow goto 'try' block again In case it's not clear what I meant: after executing some_function() exception SomeExcpetion gets risen. Then, in except block I do something to fix whatever is causing the exception and then I would like to go back to try block, and execute some_function() again. Is that doable? Thanks. -- ___Karlo Lozovina - Mosor | | |.-.-. web: http://www.mosor.net || ICQ#: 10667163 | || _ | _ | Parce mihi domine quia Dalmata sum. |__|_|__||_|_| -- http://mail.python.org/mailman/listinfo/python-list
Re: Separate output for log file and stdout
On May 19, 4:05 pm, "Kam-Hung Soh" <[EMAIL PROTECTED]> wrote: > On Tue, 20 May 2008 06:58:28 +1000, <[EMAIL PROTECTED]> wrote: > > On May 16, 6:37 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > >> [EMAIL PROTECTED] writes: > >> > I've recently jumped big time into python and I'm working on a > >> > software program for testing automation. > > >> Welcome, to both fields :-) > > > Thanks! I am having a great time learning and coding in python. It's > > an amazing programming language. > > >> > I had a question about proper logging of output. What I would like > >> > is: > > >> > 1. a function syslog (to log output to log file only) > >> > 2. a function stdout (to log output to stdout only) > >> > 3. a function sslog (to log output to both log and stdout) > > >> > Right now I am using StandOut module > > >> Have you investigated the 'logging' module in the Python standard > >> library http://www.python.org/doc/lib/module-logging>? It appears > >> to meet your listed requirements, without need of external > >> dependencies. > > > Hmm..Yeah I didn't realize python had its own standard logging > > facility. I took a look at it and it seems to do the job. However, the > > output seems to be syslog style output. In the program I am writing, > > the log file stores all the output of the commands being run (e.g. tcl > > scripts, etc). Will this be possible using the built in python logging > > module? > > > Thanks, > > Amit > > -- > >http://mail.python.org/mailman/listinfo/python-list > > You can define the format of the log output in basicConfig(), for example: > > from logging import basicConfig, error, info, INFO > ... >basicConfig( >datefmt='%Y%m%d_T%H%M%S', >filemode='a', >filename=LOG_PATH, >format='%(asctime)s,%(levelname)s,%(message)s', >level=INFO >) > > If you want to log the output of other commands in your log file, you can > connect a pipe to that command. Maybe look at "subprocess -- Subprocess > management" inhttp://docs.python.org/lib/module-subprocess.html > > -- > Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman Thanks for the reply. Yeah I am using the subprocess module and I am able to capture the output and save it to log a file. However, looking at module-logging the output format is like syslog. What I want is my own custom log file format. I wrote a separate module containing all the functions for the logging but I can't seem to use it globally. How does one use global variables in python? Code: # log.py - A base class that provides logging functionality. # # Copyright 2008 Amit Uttamchandani <[EMAIL PROTECTED]> # import os import sys logfile = None global logfile def createLogFile(filename): '''Opens a file for logging.''' try: logfile = open(filename, 'w') except IOError: print 'Error: Cannot create log file: %s' % os.abspath(logfile) sys.exit(0) def stdlog(logstr): '''Writes output to stdout.''' sys.stdout.write(logstr) def syslog(logstr): '''Writes output to logfile.''' logfile.write(logstr) def agglog(logstr): '''Aggregate output of logstr.''' syslog(logstr) stdlog(logstr) def closeLogFile(): '''Closes the log file.''' logfile.close() Thanks, Amit -- http://mail.python.org/mailman/listinfo/python-list
Re: persistent deque
something randomly made me realize why my second solution didn't work, so i fixed it. now you have a working persistent deque. 1. if you call somepdequeobject.load(filename) (as opposed to pdeque.load(filename)), do you want it to return a new object that it loaded from file, or do you want it to change somepdequeobject to be the object in the file? i'm not sure which way is canonical. 2. i'm not sure if i actually have to use a temp file and then copy it. i don't know if pickle.dump as an "atomic commit". 3. cPickle would be faster but i think that means you might end up storing something in your deque that can't be pickled, like a circular reference, and dunno what else. 4. can someone tell me if the way i'm using the decorator is sane? i've never used decorators before. it just seems ridiculous to a) define a lambda that just throws away the parameter, and b) define a meaningless function to pass to that lambda. 5. Of course, I am a genius. from collections import deque import os, pickle, random class pdeque(deque): def __init__(self, filename, initial=None): if initial is None: initial = [] deque.__init__(self, initial) self.filename = filename self.tempfilename = ''.join((random.choice("abcdefghijklmnopqrstuvwxyz") for x in xrange(10)))+".tmp" self.save() def save(self): pickle.dump(deque(self), open(self.tempfilename,'wb')) try: os.remove(self.filename) except: pass os.rename(self.tempfilename, self.filename) @classmethod def load(cls, filename): return pdeque(filename, pickle.load(open(filename,'rb'))) #todo: change this so that if it's called from an object it loads #the data into that object? def makefunc(func): def func2(instance, *args): result = func(instance, *args) instance.save() return result return lambda _: func2 for name, func in deque.__dict__.items(): if (not name.startswith("_")) or name in ('__delitem__', '__setitem__'): @makefunc(func) def f(): pass setattr(pdeque, name, f) "castironpi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd like a persistent deque, such that the instance operations all > commit atomicly to file system. -- http://mail.python.org/mailman/listinfo/python-list
ANN: PyQt v4.4.2 Released
Riverbank Computing is pleased to announce the release of PyQt v4.4.2 available from http://www.riverbankcomputing.com/software/pyqt/. This release adds full support for Qt v4.4.0 including the new QtHelp, QtWebKit, QtXmlPatterns and phonon modules. A Windows installer is provided for the GPL version of PyQt which contains everything needed for PyQt development (including Qt, Qt Designer and QScintilla) except Python itself. PyQt is a comprehensive set of Qt bindings for the Python programming language and supports the same platforms as Qt (Windows, Linux and MacOS/X). Like Qt, PyQt is available under the GPL and a commercial license. PyQt v4 supports Qt v4 (http://www.trolltech.com/products/qt/index.html). PyQt v3 is still available to support earlier versions of Qt. PyQt v4 is implemented as a set of 17 extension modules containing over 400 classes and over 6,000 functions and methods. QtCore The non-GUI infrastructure including event loops, threads, i18n, Unicode, signals and slots, user and application settings, mapped files and shared memory. QtDesigner A set of classes that allow the Qt Designer GUI design tool to be extended with PyQt. QtGui A rich collection of GUI widgets. QtHelp A set of classes for creating and viewing searchable documentation and being able to integrate online help with PyQt applications. It includes the C++ port of the Lucene text search engine. QtNetwork A set of classes to support TCP and UDP socket programming and higher level protocols (eg. HTTP, SSL). QtOpenGL A set of classes that allows PyOpenGL to render onto Qt widgets. QtScript A set of classes that implements a JavaScript interpreter. Python objects may be exposed in the interpreter as JavaScript objects. QtSql A set of classes that implement SQL data models and interfaces to industry standard databases. It includes an implementation of SQLite. QtSvg A set of classes to render SVG files onto Qt widgets. QtTest A set of classes to automate unit testing of PyQt applications and GUIs. QtWebKit This implements a web browser engine based on the WebKit engine used by Apple's Safari browser. It allows the methods and properties of Python objects to be published and appear as JavaScript objects to scripts embedded in HTML pages. QtXML A set of classes that implement DOM and SAX parsers. QtXMLPatterns A set of classes that implement XQuery and XPath support for XML and custom data models. QtAssistant A set of classes that enables the Qt Assistant online help browser to be integrated with an application. QAxContainer A set of classes for Windows that allows the integration of ActiveX controls and COM objects. phonon A cross-platform multimedia framework that enables the use of audio and video content in PyQt applications. DirectX is used as the Windows backend, QuickTime as the MacOS/X backend, and GStreamer as the Linux backend. DBus PyQt includes dbus.mainloop.qt that allows the Qt event loop to be used with the standard DBus Python bindings. PyQt includes the pyuic4 utility which generates Python code to implement user interfaces created with Qt Designer in the same way that the uic utility generates C++ code. It is also able to load Designer XML files dynamically. Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Separate output for log file and stdout
On May 19, 4:05 pm, "Kam-Hung Soh" <[EMAIL PROTECTED]> wrote: > On Tue, 20 May 2008 06:58:28 +1000, <[EMAIL PROTECTED]> wrote: > > On May 16, 6:37 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > >> [EMAIL PROTECTED] writes: > >> > I've recently jumped big time into python and I'm working on a > >> > software program for testing automation. > > >> Welcome, to both fields :-) > > > Thanks! I am having a great time learning and coding in python. It's > > an amazing programming language. > > >> > I had a question about proper logging of output. What I would like > >> > is: > > >> > 1. a function syslog (to log output to log file only) > >> > 2. a function stdout (to log output to stdout only) > >> > 3. a function sslog (to log output to both log and stdout) > > >> > Right now I am using StandOut module > > >> Have you investigated the 'logging' module in the Python standard > >> library http://www.python.org/doc/lib/module-logging>? It appears > >> to meet your listed requirements, without need of external > >> dependencies. > > > Hmm..Yeah I didn't realize python had its own standard logging > > facility. I took a look at it and it seems to do the job. However, the > > output seems to be syslog style output. In the program I am writing, > > the log file stores all the output of the commands being run (e.g. tcl > > scripts, etc). Will this be possible using the built in python logging > > module? > > > Thanks, > > Amit > > -- > >http://mail.python.org/mailman/listinfo/python-list > > You can define the format of the log output in basicConfig(), for example: > > from logging import basicConfig, error, info, INFO > ... >basicConfig( >datefmt='%Y%m%d_T%H%M%S', >filemode='a', >filename=LOG_PATH, >format='%(asctime)s,%(levelname)s,%(message)s', >level=INFO >) > > If you want to log the output of other commands in your log file, you can > connect a pipe to that command. Maybe look at "subprocess -- Subprocess > management" inhttp://docs.python.org/lib/module-subprocess.html > > -- > Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman Thanks for the reply. Yeah I am using the subprocess module and I am able to capture the output and save it to log a file. However, looking at module-logging the output format is like syslog. What I want is my own custom log file format. I wrote a separate module containing all the functions for the logging but I can't seem to use it globally. How does one use global variables in python? Code: # log.py - A base class that provides logging functionality. # # Copyright 2008 Amit Uttamchandani <[EMAIL PROTECTED]> # import os import sys logfile = None global logfile def createLogFile(filename): '''Opens a file for logging.''' try: logfile = open(filename, 'w') except IOError: print 'Error: Cannot create log file: %s' % os.abspath(logfile) sys.exit(0) def stdlog(logstr): '''Writes output to stdout.''' sys.stdout.write(logstr) def syslog(logstr): '''Writes output to logfile.''' logfile.write(logstr) def agglog(logstr): '''Aggregate output of logstr.''' syslog(logstr) stdlog(logstr) def closeLogFile(): '''Closes the log file.''' logfile.close() Thanks, Amit -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
notbob <[EMAIL PROTECTED]> writes: > Well, that's my actual question, then. Is php really so bad I'm just > wasting my time? Or is it really the quickest way to blog functionality? php is very easy to get started with and some big sites have been written in it. There is lots of low cost php hosting available. It is not as good a language as Python. However, Python's advantages are strongest in more complex projects. For simple stuff, php is frankly less hassle just because of its wide deployment and that extensive function library that the blog post your quoted described as a bad thing. Python's libraries are not bad, but php's are more intensely focused on web apps and includes what you need as part of the standard build. With Python, if you want a database adapter or web template framework, you have to choose between a bunch of different ones and download and configure it which often involves head scratching when the auto-install stuff hits some quirk of your system. With php, it's all right there when you flip the switch. Knowing lots of languages is good for you. php is probably your quickest route to getting a rudimentary web app running. Python is a longer term project. Do both. -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to check if pid is dead?
On May 21, 1:27 pm, bukzor <[EMAIL PROTECTED]> wrote: > On May 21, 12:13 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > > > > > In article > > <[EMAIL PROTECTED]>, > > > bukzor <[EMAIL PROTECTED]> wrote: > > > Does anyone have a pythonic way to check if a process is dead, given > > > the pid? > > > > This is the function I'm using is quite OS dependent. A good candidate > > > might be "try: kill(pid)", since it throws an exception if the pid is > > > dead, but that sends a signal which might interfere with the process. > > > > Thanks. > > > --Buck > > > The canonical way is to do kill(pid, 0). If it doesn't throw, the process > > exists. No actual signal is sent to the process either way. > > > Of course, the process could exit immediately after the kill() call, so by > > the time you find out it's alive, it's dead. Such is life. > > Thanks! That's exactly what I was looking for. A little more > background: > > "If sig is 0 (the null signal), error checking is performed but no > signal is actually sent. The null signal can be used to check the > validity of pid." > > Taken from :http://www.opengroup.org/onlinepubs/009695399/functions/kill.html Here are the functions I wrote with this information. There are three functions: kill() is similar to os.kill, but returns True if the pid is dead and throws less exceptions dead() checks if a process is dead, and gets rid of zombies if necessary goodkill() kills a pid by sending gradually harser signals until dead. def kill(pid, signal=0): """sends a signal to a process returns True if the pid is dead with no signal argument, sends no signal""" #if 'ps --no-headers' returns no lines, the pid is dead from os import kill try: return kill(pid, signal) except OSError, e: #process is dead if e.errno == 3: return True #no permissions elif e.errno == 1: return False else: raise def dead(pid): if kill(pid): return True #maybe the pid is a zombie that needs us to wait4 it from os import waitpid, WNOHANG try: dead = waitpid(pid, WNOHANG)[0] except OSError, e: #pid is not a child if e.errno == 10: return False else: raise return dead #def kill(pid, sig=0): pass #DEBUG: test hang condition def goodkill(pid, interval=1, hung=20): "let process die gracefully, gradually send harsher signals if necessary" from signal import SIGTERM, SIGINT, SIGHUP, SIGKILL from time import sleep for signal in [SIGTERM, SIGINT, SIGHUP]: if kill(pid, signal): return if dead(pid): return sleep(interval) i = 0 while True: #infinite-loop protection if i < hung: i += 1 else: print "Process %s is hung. Giving up kill." % pid return if kill(pid, SIGKILL): return if dead(pid): return sleep(interval) -- http://mail.python.org/mailman/listinfo/python-list
Re: C-like assignment expression?
On May 21, 10:38 am, [EMAIL PROTECTED] wrote: > Hello, > > I have an if-elif chain in which I'd like to match a string against > several regular expressions. Also I'd like to use the match groups > within the respective elif... block. The C-like idiom that I would > like to use is this: > > if (match = my_re1.match(line): > # use match > elsif (match = my_re2.match(line)): > # use match > elsif (match = my_re3.match(line)) > # use match > > ...buy this is illegal in python. The other way is to open up an else: > block in each level, do the assignment and then the test. This > unneccessarily leads to deeper and deeper nesting levels which I find > ugly. Just as ugly as first testing against the RE in the elif: clause > and then, if it matches, to re-evaluate the RE to access the match > groups. > > Thanks, > robert You could use named groups to search for all three patterns at once like this: original: prog1 = re.compile(r'pat1') prog2 = re.compile(r'pat2') prog3 = re.compile(r'pat3') ... Becomes: prog = re.compile(r'(?Ppat1)|(?Ppat2)|(?Ppat3)') match = prog.match(line) for p in 'p1 p2 p3'.split(): if match.groupdict()[p]: do_something_for_prog(p) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Segmentation fault on updating a BYTEA field [psycopg2]
I have a simple DB table that stores md5 signature pairs: Table "public.duplicate" Column | Type | Modifiers --+---+--- sig | bytea | not null orig_sig | bytea | not null Indexes: "duplicate_pkey" PRIMARY KEY, btree (sig) "ix_duplicate_orig_sig" btree (orig_sig) I use SqlAlchemy to interact with it and inserting works fine; update however crashes hard with a segfault. Sure enough, the crash is reproducible when using the underlying psycopg2 directly: >>> import psycopg2 >>> connect_string = ... >>> conn = psycopg2.connect(connect_string) >>> cur = conn.cursor() >>> cur.execute('SELECT sig,orig_sig from duplicate limit 1') >>> d = cur.fetchone() >>> d (, ) >>> map(str,d) ["\x02#qO\xb0\xcc\xfcx\xb9u\xa5\x83)\xc4'@", '\xa1\xf22\xf6y\xd0\xbc \xea6\xf0Y\xf1"\xc9(\n'] >>> cur.execute('UPDATE duplicate SET orig_sig=%(orig_sig)s WHERE duplicate.sig >>> = %(duplicate_sig)s', ... dict(orig_sig=d[0], duplicate_sig=d[1])) Segmentation fault Am I (and SqlAlchemy) doing something silly or is this a bug in psycopg2 ? George -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 4:21 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Which is exactly what the python decimal module does. Thank you (and Jerry Hill) for pointing that out. If I want to check Flaming Thunder's results against an independent program, I'll know to use Python with the decimal module. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
Dave Parker schrieb: On May 21, 3:19 pm, "Dan Upton" <[EMAIL PROTECTED]> wrote: The fact is, sometimes it's better to get it fast and be good enough, where you can use whatever methods you want to deal with rounding error accumulation. I agree. I also think that the precision/speed tradeoff should be under user control -- not at the whim of the compiler writer. So, for example, if a user says: Set realdecimaldigits to 10. then it's okay to use hardware double precision, but if they say: Set realdecimaldigits to 100. then it's not. The user should always be able to specify the precision and the rounding mode, and the program should always provide correct results to those specifications. Which is exactly what the python decimal module does. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: HTMLParser error
On May 21, 11:08 am, alex23 <[EMAIL PROTECTED]> wrote: > On May 21, 8:04 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > Is your Spider class a subclass ofHTMLParser? Is it over-riding > > __init__? If so, is it doing something like: > > > super(Spider, self).__init__() > > > If this is your issue[...] > > I'm sorry, this really wasn't clear at all. What I meant was that you > need to call theHTMLParser.__init__ inside your Spider.__init__ in > order to have it initialise properly. Failing to do so would lead to > the .rawdata attribute not being defined. The super() function is the > best way to achieve this. > > Sorry for the rambling, hopefully some of that is relevant. > > - alex23 Sorry, im new to both python and newsgroups, this is all pretty confusing. So I need a line in my __init__ function of my class? The spider class I made inherits from HTMLParser. Its just using the feed() function that produces errors though, the rest seems to work fine. Thanks for the help, Jon -- http://mail.python.org/mailman/listinfo/python-list
Re: Running programs under a python program...
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > So I have a python program that runs a bunch of other programsit > then loops forever, occasionally executing other programs. > > To run each of these programs my python code executes: > subprocess.Popen(command_line, shell=True, stdout=fd, > stderr=subprocess.STDOUT) > > where command_line is an appropriate command line. :) > > Now my problem is when I abort this program it kills off all the child > processes I've started. In this case I don't want that. How can I > stop the child processes from dieing when I kill off the parent? It depends on why the children are dying. >From what you say, it seems likely that they're trying to write to their standard output, and exiting because that's a pipe that is now closed. If that's the case, it's probably best to start by deciding where you want that output to go when the parent process has ended. Perhaps you can just send it all to a log file in the first place. -M- -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:41 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > When told why you got different results (an answer you > probably already knew, if you know enough about IEEE to do the > auto-conversion you alluded to) ... Of course I know a lot about IEEE, but you are assuming that I also know a lot about Python, which I don't. I assumed Python was doing the auto-conversion, too, because I had heard that Python supported arbitrary precision math. Jerry Hill explained that you had to load a separate package to do it. > you treated it as another opportunity > to (not very subtly) imply that Python was doing the wrong thing. This person who started this thread posted the calculations showing that Python was doing the wrong thing, and filed a bug report on it. If someone pointed out a similar problem in Flaming Thunder, I would agree that Flaming Thunder was doing the wrong thing. I would fix the problem a lot faster, though, within hours if possible. Apparently this particular bug has been lurking on Bugzilla since 2003: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On 2008-05-21, Damon Getsman <[EMAIL PROTECTED]> wrote: > My suggestion, if you want to keep that gray meat sparking, is to go > with only html & php. You could have the php dumping your entries > into date/time named textfiles on there when you're writing, and when > someone is reading, it just orders them sequentially by the date & > time in their filenames. > > Then again, you learn the HTML+PHP+MySQL thing and you've got a skill > that you can market on Craigslist to a bunch of people for $20/hr > +. :) That certainly couldn't hurt. Thank you for your advice. nb -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On Wed, May 21, 2008 at 4:29 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 3:17 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > >> If you're going to use every post and question about Python as an >> opportunity to pimp your own pet language you're going irritate even >> more people than you have already. > > Actually, I've only posted on 2 threads that were questions about > Python -- this one, and the one about for-loops where the looping > variable wasn't needed. I apologize if that irritates you. But maybe > some Python users will be interested in Flaming Thunder if only to > check the accuracy of the results that they're getting from Python, > like I did on this thread. I think most people will agree that having > two independent programs confirm a result is a good thing. > -- Please don't be disingenuous. You took the opportunity to pimp your language because you could say that you did this "right" and Python did it "wrong". When told why you got different results (an answer you probably already knew, if you know enough about IEEE to do the auto-conversion you alluded to) you treated it as another opportunity to (not very subtly) imply that Python was doing the wrong thing. I'm quite certain that you did this intentionally and with full knowledge of what you were doing, and it's insulting to imply otherwise. You posted previously that you wrote a new language because you were writing what you wanted every other language to be. This is very similar to why Guido wrote Python and I wish you the best of luck. He was fortunate enough that the language he wanted also happened to be the language that lots of other people wanted. You don't seem to be so fortunate, and anti-social behavior on newsgroups dedicated to other languages is unlikely to change that. You're not the first and you won't be the last. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:19 pm, "Dan Upton" <[EMAIL PROTECTED]> wrote: > The fact is, sometimes it's better to get it fast and be good enough, > where you can use whatever methods you want to deal with rounding > error accumulation. I agree. I also think that the precision/speed tradeoff should be under user control -- not at the whim of the compiler writer. So, for example, if a user says: Set realdecimaldigits to 10. then it's okay to use hardware double precision, but if they say: Set realdecimaldigits to 100. then it's not. The user should always be able to specify the precision and the rounding mode, and the program should always provide correct results to those specifications. -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On 2008-05-21, Carl Banks <[EMAIL PROTECTED]> wrote: > If you just want to write a simple blog, PHP is probably good enough. > It's undeniably easier to jump into web programming with PHP-- > partially because of it's widespread support and straightforward > usage, partially because Python web solutions tend to aim for > separability of content and presenation which raises the bar for > entry--and that could easily outweigh your concerns over quality of > the language. > > (Incidentally: if you didn't want to start a religious war, it would > have been better if you had posted it separately to the two groups. > Lots of flamewars start by one person posting a cutdown not intended > for the ears of the other group.) Yeah, but years of usenet have taught me how to navigate the battlefield. Your top paragraph above is the kind of advice I'm looking for. Thank you. nb -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:17 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > If you're going to use every post and question about Python as an > opportunity to pimp your own pet language you're going irritate even > more people than you have already. Actually, I've only posted on 2 threads that were questions about Python -- this one, and the one about for-loops where the looping variable wasn't needed. I apologize if that irritates you. But maybe some Python users will be interested in Flaming Thunder if only to check the accuracy of the results that they're getting from Python, like I did on this thread. I think most people will agree that having two independent programs confirm a result is a good thing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 14, 10:30 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > Dave Parker schrieb: > > > All of the calculators and textbooks that elementary school students > > > use, use "^" for powers. > > I've never seen this symbol in textbooks. In textbooks, powers are > written using superscript. > > >> Just like Flaming Thunder does. I haven't > > > seen "**" for powers since FORTRAN. > > I haven't seen any language using '^' as the power operator so far - > but I've seen quite a lot of them using it as the bitwise XOR operator. Excel uses the caret as the power operator. Arguably the worlds most widely used programming environment... Michael Foord http://www.ironpythoninaction.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On 2008-05-21, Michael Vilain <[EMAIL PROTECTED]> wrote: > your site. They may even have a blogging package you can administer > entries without any programming. > > What's your end-goal here? If you can't program, you may be better off > with a package or tool that does all the heavy lifting for you. I said I didn't want to do that, but that's not entirely true. I figured I'd use one of the CMSs while learning how it works, much like linux. I hate doing something without knowing why. Windows and Dreamweaver are good examples. Nope. I want to get under the hood. nb -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On Wed, May 21, 2008 at 4:56 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > >> My understand is no, not if you're using IEEE floating point. > > Yes, that would explain it. I assumed that Python automatically > switched from hardware floating point to multi-precision floating > point so that the user is guaranteed to always get correctly rounded > results for +, -, *, and /, like Flaming Thunder gives. Correct > rounding and accurate results are fairly crucial to mathematical and > scientific programming, in my opinion. However, this is not an issue of language correctness, it's an issue of specification and/or hardware. If you look at the given link, it has to do with the x87 being peculiar and performing 80-bit floating-point arithmetic even though that's larger than the double spec. I assume this means FT largely performs floating-point arithmetic in software rather than using the FP hardware (unless of course you do something crazy like compiling to SW on some machines and HW on others depending on whether you trust their functional units). The fact is, sometimes it's better to get it fast and be good enough, where you can use whatever methods you want to deal with rounding error accumulation. When accuracy is more important than speed of number crunching (and don't argue to me that your software implementation is faster than, or probably even as fast as, gates in silicon) you use packages like Decimal. Really, you're just trying to advertise your language again. -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
In my opinion, with the previous experience that you have in coding that you've mentioned, you're probably better off if you minimize the amount of new syntaxes you'll have to pick up. Standard technique for what you're trying to accomplish is more often than not Apache with the PHP and MySQL support built in. PHP has great support for accessing a MySQL database, which is where the script would store and load your entries (and/or other applicable data) from. Then again, you are really learning HTML, PHP, and MySQL at the same time, which can be a pain in the ass. There are some excellent books by O'Reilly and Associates on just that subject, though. They combine the PHP & MySQL into one book that'll get you started and able to handle that kind of task really quick. The HTML syntax is going to be separate, wherever you go. It'll be simple if you want it dumping text to the screen, and a pain in the ass if you want pretty formatting with designs and text that lays out just in a certain area. My suggestion, if you want to keep that gray meat sparking, is to go with only html & php. You could have the php dumping your entries into date/time named textfiles on there when you're writing, and when someone is reading, it just orders them sequentially by the date & time in their filenames. Then again, you learn the HTML+PHP+MySQL thing and you've got a skill that you can market on Craigslist to a bunch of people for $20/hr +. :) http://unix.derkeiler.com/Newsgroups/comp.sys.sun.apps/ 2008-04/msg0.html"> -Damon A. Getsman Linux/Solaris Systems Administrator -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
Dave Parker schrieb: On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: My understand is no, not if you're using IEEE floating point. Yes, that would explain it. I assumed that Python automatically switched from hardware floating point to multi-precision floating point so that the user is guaranteed to always get correctly rounded results for +, -, *, and /, like Flaming Thunder gives. Correct rounding and accurate results are fairly crucial to mathematical and scientific programming, in my opinion. Who says that rounding on base 10 is more correct than rounding on base 2? And in scientific programming, speed matters - which is why e.g. the cell-processor shall grow a double-precision float ALU. And generally supercomputers use floats, not arbitrary precision BCD or even rationals. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On Wed, May 21, 2008 at 3:56 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > >> My understand is no, not if you're using IEEE floating point. > > Yes, that would explain it. I assumed that Python automatically > switched from hardware floating point to multi-precision floating > point so that the user is guaranteed to always get correctly rounded > results for +, -, *, and /, like Flaming Thunder gives. Correct > rounding and accurate results are fairly crucial to mathematical and > scientific programming, in my opinion. > -- If you're going to use every post and question about Python as an opportunity to pimp your own pet language you're going irritate even more people than you have already. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
2008/5/21 Dave Parker <[EMAIL PROTECTED]>: > On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > > > My understand is no, not if you're using IEEE floating point. > > Yes, that would explain it. I assumed that Python automatically > switched from hardware floating point to multi-precision floating > point so that the user is guaranteed to always get correctly rounded > results for +, -, *, and /, like Flaming Thunder gives. Correct > rounding and accurate results are fairly crucial to mathematical and > scientific programming, in my opinion. > -- > http://mail.python.org/mailman/listinfo/python-list > That's why there is the Decimal module. That's why the IEEE standard exists as well, because it is not possible to always use what you call multi-precision floating point with decent speed. That's why numerical analysis exists. Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
On May 21, 4:10 pm, notbob <[EMAIL PROTECTED]> wrote: > Sometimes it seems overwhelming, but I > persevere because it's more fun/challenging than video games, which bore me > to tears. Ha, exactly the opposite here. > Well, that's my actual question, then. Is php really so bad I'm just > wasting my time? Or is it really the quickest way to blog functionality? > Would I be better served in the long run learning python, which claims to be > easy as pie to learn/program (still looks hard to me). I admit I'm no code > geek. But, I'm not completely brain dead, either, and I need something to > keep my geezer brain sparking. What say ye? If you just want to write a simple blog, PHP is probably good enough. It's undeniably easier to jump into web programming with PHP-- partially because of it's widespread support and straightforward usage, partially because Python web solutions tend to aim for separability of content and presenation which raises the bar for entry--and that could easily outweigh your concerns over quality of the language. (Incidentally: if you didn't want to start a religious war, it would have been better if you had posted it separately to the two groups. Lots of flamewars start by one person posting a cutdown not intended for the ears of the other group.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 2:44 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > My understand is no, not if you're using IEEE floating point. Yes, that would explain it. I assumed that Python automatically switched from hardware floating point to multi-precision floating point so that the user is guaranteed to always get correctly rounded results for +, -, *, and /, like Flaming Thunder gives. Correct rounding and accurate results are fairly crucial to mathematical and scientific programming, in my opinion. -- http://mail.python.org/mailman/listinfo/python-list
Re: php vs python
notbob wrote: > I > persevere because it's more fun/challenging than video games This is the crux of the matter from where I'm sitting. If the purpose of learning a programming language is fun, then the primary relevant question is: Is it more fun to code in Python or PHP? The answer is a no-brainer for me. It seems to me that Python is designed from the ground up with my enjoyment in mind. Your Fun May Vary :-) Jeffrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On Wed, May 21, 2008 at 4:34 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 12:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > >> >>> a+0.999 # gives expected result >> 9998.0 >> >>> a+0. # doesn't round correctly. >> >> 1.0 > > Shouldn't both of them give .0? My understand is no, not if you're using IEEE floating point. > I wrote the same program under Flaming Thunder: > > Set a to 10^16-2.0. > Writeline a+0.999. > Writeline a+0.. > > and got: > > 9998.999 > 9998. You can get the same results by using python's decimal module, like this: >>> from decimal import Decimal >>> a = Decimal("1e16")-2 >>> a Decimal("9998") >>> a+Decimal("0.999") Decimal("9998.999") >>> a+Decimal("0.") Decimal("9998.") >>> -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 12:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > >>> a+0.999 # gives expected result > 9998.0 > >>> a+0. # doesn't round correctly. > > 1.0 Shouldn't both of them give .0? I wrote the same program under Flaming Thunder: Set a to 10^16-2.0. Writeline a+0.999. Writeline a+0.. and got: 9998.999 9998. I then set the precision down to 16 decimal digits to emulate Python: Set realdecimaldigits to 16. Set a to 10^16-2.0. Writeline a+0.999. Writeline a+0.. and got: .0 .0 -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to check if pid is dead?
On May 21, 12:13 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > > bukzor <[EMAIL PROTECTED]> wrote: > > Does anyone have a pythonic way to check if a process is dead, given > > the pid? > > > This is the function I'm using is quite OS dependent. A good candidate > > might be "try: kill(pid)", since it throws an exception if the pid is > > dead, but that sends a signal which might interfere with the process. > > > Thanks. > > --Buck > > The canonical way is to do kill(pid, 0). If it doesn't throw, the process > exists. No actual signal is sent to the process either way. > > Of course, the process could exit immediately after the kill() call, so by > the time you find out it's alive, it's dead. Such is life. Thanks! That's exactly what I was looking for. A little more background: "If sig is 0 (the null signal), error checking is performed but no signal is actually sent. The null signal can be used to check the validity of pid." Taken from : http://www.opengroup.org/onlinepubs/009695399/functions/kill.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 3:22 pm, Marc Christiansen <[EMAIL PROTECTED]> wrote: > On my system, it works: > > Python 2.5.2 (r252:60911, May 21 2008, 18:49:26) > [GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> a = 1e16 - 2.; a > 9998.0 > >>> a + 0. > 9998.0 > > Marc Thanks for all the replies! It's good to know that it's not just me. :-) After a bit (well, quite a lot) of Googling, it looks as though this might be known problem with gcc on older Intel processors: those using an x87-style FPU instead of SSE2 for floating-point. This gcc 'bug' looks relevant: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323 Now that I've got confirmation I'll open a Python bug report: it's not clear how to fix this, or whether it's worth fixing, but it seems like something that should be documented somewhere... Thanks again, everyone! Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
Mark Dickinson <[EMAIL PROTECTED]> wrote: > On SuSE 10.2/Xeon there seems to be a rounding bug for > floating-point addition: > > [EMAIL PROTECTED]:~> python > Python 2.5 (r25:51908, May 25 2007, 16:14:04) > [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. a = 1e16-2. a > 9998.0 a+0.999 # gives expected result > 9998.0 a+0. # doesn't round correctly. > 1.0 > > The last result here should be 9998.0, > not 1.0. Is anyone else seeing this > bug, or is it just a quirk of my system? On my system, it works: Python 2.5.2 (r252:60911, May 21 2008, 18:49:26) [GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 1e16 - 2.; a 9998.0 >>> a + 0. 9998.0 Marc -- http://mail.python.org/mailman/listinfo/python-list
php vs python
I'm not posting this just to initiate some religious flame war, though it's the perfect subject to do so. No, I actaully want some serious advice about these two languages and since I think usenet is the best arena to find it, here ya' go. So, here's my delimna: I want to start a blog. Yeah, who doesn't. Yet, I want learn the guts of it instead of just booting up some wordwank or whatever. I started to learn python, but heard php was easier or faster or more like shell scripting or... fill in the blank. Anyway, so I change over to learning php. Then I run across that blog, Coding Horror, and start reading articles like this: http://www.codinghorror.com/blog/archives/001119.html Now what? Go back to python. Soldier on with php? What do I know? Not much. I can setup mysql and apache,, but don't know how to use 'em, really. I use emacs and run slackware and can fumble my way through bash scripts, but I can't really write them or do lisp. I've taken basic basic and basic C, but am barely literate in html. Sometimes it seems overwhelming, but I persevere because it's more fun/challenging than video games, which bore me to tears. Well, that's my actual question, then. Is php really so bad I'm just wasting my time? Or is it really the quickest way to blog functionality? Would I be better served in the long run learning python, which claims to be easy as pie to learn/program (still looks hard to me). I admit I'm no code geek. But, I'm not completely brain dead, either, and I need something to keep my geezer brain sparking. What say ye? nb -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 21, 1:29 pm, "Dan Upton" <[EMAIL PROTECTED]> wrote: > ... --somewhat akin to the > guy who a month or so ago wanted to sneakily teach his high school > class programming fundamentals by teaching them game programming. Yep, that's kind of my plan, too. After I get enough "computer languagey" stuff running, I'm going to incorporate the 3D graphics from DPGraph. > Maybe this should be your selling point, and maybe you should be > drawing comparisons to programming in Matlab or Mathematica. That sounds like a good idea. Personally, the first thing I wanted to get running in Flaming Thunder was the ability to cross-compile CGI scripts for Linux under Windows, because some inexpensive web-hosting sites (such as GoDaddy) don't allow shell access, so I couldn't compile the CGI scripts natively. Also, the ability to cross-compile programs for the Mac since Macs often appear in educational settings. Now that those are up and running and Flaming Thunder is released to the public, I'm adding features as prioritized by customer requests. Currently, the highest big things on the list are arrays/matrices and 3D graphics. Next on the list is improved symbolics. -- http://mail.python.org/mailman/listinfo/python-list
Re: xpath with big files
Vladimir Kropylev wrote: > I've encountered a problem when trying to use lxml.etree.xpath with > big (63Mb) file. It returns empty list on any request. > Is there any restriction on file size for lxml.etree.xpath? No. > This is what I do: > > f=open(filename) > tree = etree.parse(f) > f.close() Consider using tree = etree.parse(filename) > r = tree.xpath('//image') > print(r) > > it prints: > [] > > What is wrong here? Does your document use namespaces? In that case, asking for an unnamespaced "image" will not get you any result. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: getting dir(x), but not as list of strings?
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | [EMAIL PROTECTED] wrote: | > I want to iterate over members of a module, something like: | > | > for i in dir(x): | > if type(i) == types.FunctionType: ... | > | > but of course dir() returns a list of strings. If x is a module, | > how can I get the list of its members as their actual types? | > | > Many TIA! | > Mark | > | > | Use the builtin vars to get a dictionary of names and associated objects. | | import sys | for name,ob in vars(sys).items(): | print name,type(ob) This also works on classes, but apparently not on most other objects. -- http://mail.python.org/mailman/listinfo/python-list
Re: Removing Space and "-" from a string
"Paul Hankin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On May 20, 5:02 pm, "Ahmed, Shakir" <[EMAIL PROTECTED]> wrote: > I have thousands of records in MS Access database table, which records I > am fetching using python script. One of the columns having string like > '8 58-2155-58' > > Desired output: '858215558' |def cleanup(s): |return filter(lambda x: x not in ' -', s) Or >>> s='8 58-2155-58' >>> t=str.maketrans('','',' -') >>> s.translate(t) '858215558' -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to check if pid is dead?
On Wed, May 21, 2008 at 3:02 PM, bukzor <[EMAIL PROTECTED]> wrote: > Does anyone have a pythonic way to check if a process is dead, given > the pid? > > This is the function I'm using is quite OS dependent. A good candidate > might be "try: kill(pid)", since it throws an exception if the pid is > dead, but that sends a signal which might interfere with the process. > > Thanks. > --Buck > -- > http://mail.python.org/mailman/listinfo/python-list > I don't know if you would call this pythonic, but the way I do it in linux is: import os os.path.exists("/proc/%d"%(pid)) Or, more to the point, I'm usually checking to see if processes I forked have finished, without just having to do a wait4 on them; in the case you can do something like procfile = open("/proc/%d/stat" %(pid)) procfile.readline().split[2] You can do man proc to see what each of the possible letters means; I look for Z to find that the process has exited but it's waiting for its parent to do a wait4. HTH -dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 21, 1:14 pm, MRAB <[EMAIL PROTECTED]> wrote: > I wonder whether "is" could be used both for "x is value" and "x is a > type" without causing a problem: > > If command is a string ... > > If command is "quit" ... I think you are right. I like "If command is "quit" ...". For a user who wasn't mathemetically inclined and was doing mainly string manipulation, I think it might be easier to read than the equivalent "If command = "quit" ...". By making them exactly equivalent, I can't think of any confusion that might induce bugs. If you think of any drawbacks, please let me know. Otherwise, I'll put it in the next time I update the parser (probably this weekend). Thank you again for your suggestions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On Wed, May 21, 2008 at 12:11 PM, Dave Parker <[EMAIL PROTECTED]> wrote: > On May 21, 10:00 am, "Dan Upton" <[EMAIL PROTECTED]> wrote: > >> Sounds to me like the teacher is being difficult, ... > > No, proof-by-contradiction is a common technique in math. If you can > show that x=8 and x=10, then you have shown that your assumptions were > incorrect. Yes, I'm aware of proof by contradiction. However, I think there's a flaw in your use of this to justify your case--proof by contradiction would essentially be showing x=8 and x=10 simultaneously, whereas the sequence of instructions x=8 x=10 imply a time relation, and there's no contradiction that x equals something at one point in time, and something else at another point in time. (For any kid who is capable of understanding variables anyway, just tell them something to the effect of "Plot the line y=x. Okay, now let 'y' be time. At no point in time does x take on two values, but it may take on different values at different points in time. Same concept.") > >> If you can't do, or don't like, math, you probably shouldn't be >> programming. > > Why not? Recipes are programs. I prefer to look at it the other way: > an easy-to-use programming language might encourage more people to > like math. To continue your analogy, if a recipe is the program, a person is the computer. Following a recipe is (relatively) easy, making up a new recipe is relatively difficult unless you understand, or are at least willing to tinker with, things like interactions between ingredients and flavors. Likewise, it's tedious and time-consuming but not necessarily difficult to follow a program (assuming you understand the rules of the language; I suppose here you could make some argument "it'd be easier to read it in English"), but you need to understand more about symbolic reasoning and such to be able to do much in the way of programming. All the same, I suppose you might have a point there, if you can show somebody something cool while sneaking in the math and programming such that they learn without even realizing it--somewhat akin to the guy who a month or so ago wanted to sneakily teach his high school class programming fundamentals by teaching them game programming. >> You keep trotting out this quadratic equation example, but does FT >> actually have any kind of useful equation solver in it? > > Not yet, but it will. Probably around July. Maybe this should be your selling point, and maybe you should be drawing comparisons to programming in Matlab or Mathematica. -- http://mail.python.org/mailman/listinfo/python-list
Re: Struct usage and varying sizes of h, l, etc
On May 21, 10:04 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > Yes, C defines "char" to be one byte, but it doesn't define the > size of a "byte" other than it's at least big enough to hold > one character (or something like that). In practice, a byte is > pretty much guaranteed to be at least 8 bits. If you're discussing standard C, you can omit "in practice" and "pretty much". CHAR_BITS is required to be at least 8 by the ANSI/ISO C Standard. > But, on some targets a "byte" is 16 bits, and on others a byte > is 32 bits. Yep, or 9 bits or 36 bits, or anything >= 8. -- http://mail.python.org/mailman/listinfo/python-list
Psyche (scheme in python), how to run on vista?
anyone using psyche? how do you run it on Vista? what file do you click? there is no obvious file like psyche.py... -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with import / namespace
ohad frand wrote Hi Thanks for the answer. I probably didnt write the problem accurately but it is not as you described. (i already read before the section that you pointed and it didnt help me) the problem is that i dont want to import a file from different directory but only from the same directory. \\1\tmp2.py imports \\1\tmp1.py \\2\tmp2.py imports \\2\tmp2.py but when i execute the following script in the interpreter i get that the second tmp2.py file imports not the file from the same directory but the file that was already imported by the first executed tmp2.py file. I think that using absolute names DOES solve the problem. import two.tmp2 # This will import tmp2.py in "two" folder for sure! >>> execfile("tmp2.py") <- here the executaion is OK >>> os.chdir("c:\\2") >>> execfile("tmp2.py") <- here the execution is not ok because tmp2.py file imports the tmp1.py file from c:\\1 which is not OK Hmm looks like your tmp2.py file is not a module but a whole program. No wonder I could not understand you - I thought that "tmp2.py" is a module, not a program. The answer in this case: if tmp2.py is a program then you should either manipulate sys.path or chdir to the containing dir, as I told in my former post. ( os.split(os.abspath(__file...))) -> then chdir or sys.path.insert(0,mydir) ) in between those two execfile commands i tried to do a lot of things but every time python imported the incorrect file for the second execution. (i am not building a package and those names are just examples for the problem, i am not really using 1 and 2 names as dirs) Why do you need execfile? Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Flaming Thunder
On May 21, 4:15 pm, Dave Parker <[EMAIL PROTECTED]> wrote: > > Or just: > > > If command is "quit" ... > > Hmmm. In Flaming Thunder, I'm using "is" (and "is an", "is a", etc) > for assigning and checking types. For example, to read data from a > file and check for errors: > > Read data from "input.txt". > If data is an error then go to ... > > Or when assigning a type to an identifier: > > HarmonicMean is a function(x, y) ... > LoopCount is a variable ... > > By using = only for equality and "is" only for types, the Flaming > Thunder compiler can detect when either is being used incorrectly > because the syntax for the two is incompatible. That avoids the man- > years of wasted debugging time spent on languages that accept > statements that are easily confused, yet syntactically valid (e.g. the > confusion between = and == in C if-statments, or the confusion between > = (equality) and "is" (identity) in Python). > [snip] I wonder whether "is" could be used both for "x is value" and "x is a type" without causing a problem: If command is a string ... If command is "quit" ... -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to check if pid is dead?
In article <[EMAIL PROTECTED]>, bukzor <[EMAIL PROTECTED]> wrote: > Does anyone have a pythonic way to check if a process is dead, given > the pid? > > This is the function I'm using is quite OS dependent. A good candidate > might be "try: kill(pid)", since it throws an exception if the pid is > dead, but that sends a signal which might interfere with the process. > > Thanks. > --Buck The canonical way is to do kill(pid, 0). If it doesn't throw, the process exists. No actual signal is sent to the process either way. Of course, the process could exit immediately after the kill() call, so by the time you find out it's alive, it's dead. Such is life. -- http://mail.python.org/mailman/listinfo/python-list
Re: Bug in floating-point addition: is anyone else seeing this?
On May 21, 11:38 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On SuSE 10.2/Xeon there seems to be a rounding bug for > floating-point addition: > > [EMAIL PROTECTED]:~> python > Python 2.5 (r25:51908, May 25 2007, 16:14:04) > [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> a = > 1e16-2. > >>> a > 9998.0 > >>> a+0.999 # gives expected result > 9998.0 > >>> a+0. # doesn't round correctly. > > 1.0 > > The last result here should be 9998.0, > not 1.0. Is anyone else seeing this > bug, or is it just a quirk of my system? > > Mark I see it too -- http://mail.python.org/mailman/listinfo/python-list
best way to check if pid is dead?
Does anyone have a pythonic way to check if a process is dead, given the pid? This is the function I'm using is quite OS dependent. A good candidate might be "try: kill(pid)", since it throws an exception if the pid is dead, but that sends a signal which might interfere with the process. Thanks. --Buck -- http://mail.python.org/mailman/listinfo/python-list
Re: What replaces `` in py3k?
On May 21, 10:48 am, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > On May 21, 10:45 am, bukzor <[EMAIL PROTECTED]> wrote: > > > What are backticks going to be translated into? > > repr Thanks for the quick reply! --Buck -- http://mail.python.org/mailman/listinfo/python-list