Re: set using alternative hash function?

2009-10-16 Thread Ethan Furman
Austin Bingham wrote: On Thu, Oct 15, 2009 at 7:49 PM, Ethan Furman et...@stoneleaf.us wrote: Austin Bingham wrote: I'm feeling really dense about now... What am I missing? What you're missing is the entire discussion up to this point. I was looking for a way to use an alternative

Re: restriction on sum: intentional bug?

2009-10-16 Thread Ethan Furman
Jon Clements wrote: On Oct 16, 5:59 pm, Tim Chase python.l...@tim.thechases.com wrote: Stephen Hansen wrote: Why doesn't duck typing apply to `sum`? Because it would be so hideously slow and inefficient that it'd be way too easy a way for people to program something they think should work

Re: restriction on sum: intentional bug?

2009-10-18 Thread Ethan Furman
Dave Angel wrote: Dieter Maurer wrote: Christian Heimes li...@cheimes.de writes on Fri, 16 Oct 2009 17:58:29 +0200: Alan G Isaac schrieb: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File stdin, line 1, in

Re: File not closed on exception

2009-10-19 Thread Ethan Furman
arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programmers. I'm also quite sure that this is quite a common assumption in various

Re: print()

2009-10-19 Thread Ethan Furman
Dave Angel wrote: It was intended to be understood, not copied. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system() question

2009-10-19 Thread Ethan Furman
Bryan Irvine wrote: I'm a python n00b and so pardon me in advance if this is really stupid question. I have my suspicions but why does the following not work the way I'm anticipating it will? (python 2.4.4) import os if (os.system('echo test')): ...print 'success' ... else: ...

Re: Checking a Number for Palindromic Behavior

2009-10-19 Thread Ethan Furman
gslindstrom wrote: On Oct 18, 5:56 pm, Gary Herron gher...@digipen.edu wrote: Benjamin Middaugh wrote: Thanks to everyone who helped with my query on reversing integers. I have one more simple problem I'm having trouble solving. I want to check a number for palindromic behavior (reading the

Re: Checking a Number for Palindromic Behavior

2009-10-19 Thread Ethan Furman
ru...@yahoo.com wrote: On Oct 19, 12:41 pm, Ethan Furman et...@stoneleaf.us wrote: gslindstrom wrote: On Oct 18, 5:56 pm, Gary Herron gher...@digipen.edu wrote: Benjamin Middaugh wrote: Thanks to everyone who helped with my query on reversing integers. I have one more simple problem

os.path.join

2009-10-19 Thread Ethan Furman
Following closely on the heels of the whole sum()ing strings debate, I think I found an error -- at least, it's not documented to behave this way... def uncompress_job(job_num, save_path='z:\\old_jobs', restore_path='z:\\orders'): destination =

Re: os.path.join

2009-10-19 Thread Ethan Furman
Ethan Furman wrote: Following closely on the heels of the whole sum()ing strings debate, I think I found an error -- at least, it's not documented to behave this way... def uncompress_job(job_num, save_path='z:\\old_jobs', restore_path='z:\\orders

Re: File not closed on exception

2009-10-20 Thread Ethan Furman
arve.knud...@gmail.com wrote: On Oct 19, 3:48 pm, Ethan Furman et...@stoneleaf.us wrote: arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more

Re: A stupid newbie question about output...

2009-10-20 Thread Ethan Furman
J wrote: Can someone explain why this code results in two different outputs? for os in comp.CIM_OperatingSystem (): print os.Name.split(|)[0] + Service Pack, os.ServicePackMajorVersion osVer = os.Name.split(|)[0] + Service Pack, os.ServicePackMajorVersion print osVer the first print

Re: unittest wart/bug for assertNotEqual

2009-10-20 Thread Ethan Furman
Steven D'Aprano wrote: On Tue, 20 Oct 2009 14:45:49 -0700, Zac Burns wrote: My preference would be that failIfEqual checks both != and ==. This is practical, and would benefit almost all use cases. If != isn't not == (IEEE NaNs I hear is the only known use case) numpy uses == and != as

Re: Why does passing tuple as arg WITHOUT scattering work?

2009-10-20 Thread Ethan Furman
MRAB wrote: Alf P. Steinbach wrote: Hi all. I'm just learning Python from scratch, on my own. Apologies if this question is too newbie... Or perhaps answered in some FAQ (where?). Here's my original code for simple starter program, using the ActivePython implementation in Windows XP Prof,

Re: Windows file paths, again

2009-10-21 Thread Ethan Furman
Dan Guido wrote: I'm trying to write a few methods that normalize Windows file paths. I've gotten it to work in 99% of the cases, but it seems like my code still chokes on '\x'. I've pasted my code below, can someone help me figure out a better way to write this? This seems overly complicated

Re: unittest wart/bug for assertNotEqual

2009-10-22 Thread Ethan Furman
Gabriel Genellina wrote: En Tue, 20 Oct 2009 19:57:19 -0300, Ethan Furman et...@stoneleaf.us escribió: Steven D'Aprano wrote: On Tue, 20 Oct 2009 14:45:49 -0700, Zac Burns wrote: My preference would be that failIfEqual checks both != and ==. This is practical, and would benefit almost all

attribute access and indirection

2009-10-22 Thread Ethan Furman
Greetings, List! Say I have an old-fashioned dbf style table, with a single name field of 50 characters: names = dbf.Table(':memory:', 'name C(40)') Then I add a bunch of names from who-knows-where: for name in some_iterable(): names.append((name)) Now I want to know how many start

unicode and dbf files

2009-10-22 Thread Ethan Furman
Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding of the file. For example, \x03 is code-page 437 MS-DOS. My google-fu is apparently not up to the task of locating a complete resource that has a list of the 256

Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Ethan Furman
KB wrote: Hi, I have to pass over 150 parameters to a print statement ala: print %s text %s other text %s 150'th unique text %s % (v [0], v[1], ... v[150]) I can't use a for loop like I normally would over the list v due to the different text fragments between each var. Is there a lambda

Re: unicode and dbf files

2009-10-22 Thread Ethan Furman
John Machin wrote: On Oct 23, 7:28 am, Ethan Furman et...@stoneleaf.us wrote: Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding of the file. For example, \x03 is code-page 437 MS-DOS. My google-fu is apparently

Re: unicode and dbf files

2009-10-23 Thread Ethan Furman
John Machin wrote: On Oct 23, 3:03 pm, Ethan Furman et...@stoneleaf.us wrote: John Machin wrote: On Oct 23, 7:28 am, Ethan Furman et...@stoneleaf.us wrote: Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding

Re: unicode and dbf files

2009-10-26 Thread Ethan Furman
John Machin wrote: On Oct 24, 4:14 am, Ethan Furman et...@stoneleaf.us wrote: John Machin wrote: On Oct 23, 3:03 pm, Ethan Furman et...@stoneleaf.us wrote: John Machin wrote: On Oct 23, 7:28 am, Ethan Furman et...@stoneleaf.us wrote: Greetings, all! I would like to add unicode

Re: unicode and dbf files

2009-10-26 Thread Ethan Furman
John Machin wrote: On Oct 27, 3:22 am, Ethan Furman et...@stoneleaf.us wrote: John Machin wrote: Try this: http://webhelp.esri.com/arcpad/8.0/referenceguide/ Wow. Question, though: all those codepages mapping to 437 and 850 -- are they really all the same? 437 and 850 *are* codepages

Re: restriction on sum: intentional bug?

2009-10-27 Thread Ethan Furman
Steve wrote: On Oct 17, 8:28 pm, Tim Chase python.l...@tim.thechases.com wrote: Christian Heimes wrote: Alan G Isaac wrote: On 10/16/2009 5:03 PM, Christian Heimes wrote: It's not going to happen. That's a prediction, not a justification. It's not a prediction, it's a statement.

Re: fastest native python database?

2009-06-19 Thread Ethan Furman
Ethan Furman wrote: This body part will be downloaded on demand. Not sure what happened there... here's the text... Howdy, Pierre! I have also written a pure Python implementation of a database, one that uses dBase III or VFP 6 .dbf files. Any chance you could throw it into the mix

Re: pep 8 constants

2009-06-29 Thread Ethan Furman
Eric S. Johansson wrote: yup how long will i[t] be before you become disablesd? maybe not as badly as I am but you should start feeling some hand problems in your later 40's to early 50's and it goes down hill from there. self preservation/interest comes to mind as a possible motive for

regex question on .findall and \b

2009-07-02 Thread Ethan Furman
Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]: re.findall('\d+','this is test a3 attempt 79')

Re: regex question on .findall and \b

2009-07-02 Thread Ethan Furman
Ethan Furman wrote: Greetings! My closest to successfull attempt: Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] Type copyright, credits or license for more information. IPython 0.9.1 -- An enhanced Interactive Python. In [161]: re.findall('\d

Re: regex question on .findall and \b

2009-07-06 Thread Ethan Furman
Many thanks to all who replied! And, yes, I will *definitely* use raw strings from now on. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: tough-to-explain Python

2009-07-09 Thread Ethan Furman
Steven D'Aprano wrote: There is some evidence that 30-60% of people simply cannot learn to program, no matter how you teach them: http://www.codinghorror.com/blog/archives/000635.html http://www.cs.mdx.ac.uk/research/PhDArea/saeed/ I'm sympathetic to the idea, but not entirely convinced.

Re: Clarity vs. code reuse/generality

2009-07-10 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 06 Jul 2009 21:02:19 -0700, Aahz wrote: In article 006e795f$0$9711$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Mon, 06 Jul 2009 14:32:10 +0200, Jean-Michel Pichavant wrote: kj wrote: sense = cmp(func(hi),

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
Robert Kern wrote: On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != does do what I want, except that it doesn't indicate to someone reading the code that the operands are being treated as logicals. (Readability is supposed to be one of the major selling points of Python). But, this is

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
MRAB wrote: Ethan Furman wrote: Robert Kern wrote: On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != does do what I want, except that it doesn't indicate to someone reading the code that the operands are being treated as logicals. (Readability is supposed to be one of the major

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
Christian Heimes wrote: Chris Rebert wrote: Using the xor bitwise operator is also an option: bool(x) ^ bool(y) I prefer something like: bool(a) + bool(b) == 1 It works even for multiple tests (super xor): if bool(a) + bool(b) + bool(c) + bool(d) != 1: raise

Re: missing 'xor' Boolean operator

2009-07-15 Thread Ethan Furman
Scott David Daniels wrote: Ethan Furman wrote: and returns the last object that is true A little suspect this. _and_ returns the first object that is not true, or the last object. or returns the first object that is true Similarly: _or_ returns the first object that is true

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
Helmut Jarausch wrote: Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does anybody know a tool/Python script to do so? I know, I could use dbfpy and create the SQLite table and import all data. But is there something

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
John Machin wrote: If dbfpy can't handle any new-fangled stuff you may have in your files, drop me a line ... I have a soon-to-be released DBF module that should be able to read the new stuff up to dBase7 and VFP9, including memo files, conversion from whatever to Unicode if needed, ...

Re: missing 'xor' Boolean operator

2009-07-17 Thread Ethan Furman
Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means no error and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1 or result_2 or

Re: Einstein summation notation

2009-07-17 Thread Ethan Furman
Paul Rubin wrote: Steven D'Aprano st...@remove-this-cybersource.com.au writes: def assemble_page(header, body, footer): if header or body or footer: do_lots_of_expensive_processing() else: do_nothing_gracefully() Why should the processing be expensive if all three fields

Re: missing 'xor' Boolean operator

2009-07-20 Thread Ethan Furman
[fixed for bottom-posting] Dr. Phillip M. Feldman wrote: MRAB-2 wrote: snip What values should 'xor' return? IMHO, if only one of the values is true then it should return that value, otherwise it should return False. 1 xor 0 = 1 0 xor 2 = 2 1 xor 2 = False 0 xor 0 = False

Re: missing 'xor' Boolean operator

2009-07-21 Thread Ethan Furman
Mark Dickinson wrote: On Jul 20, 11:34 pm, Ethan Furman et...@stoneleaf.us wrote: Dr. Phillip M. Feldman wrote: Suppose that 'xor' returns the value that is true when only one value is true, and False otherwise. This definition of xor doesn't have the standard associative property

Re: Changing the private variables content

2009-07-23 Thread Ethan Furman
Ryniek90 wrote: Got it: exec('self.' + attr + '=\'' + val + '\'') That worked. I think it'll do what you want now ;) Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com mailto:cont...@xavierho.com Website:

Re: Changing the private variables content

2009-07-23 Thread Ethan Furman
Or, in other words, what Steven D'Aprano had already said. Guess I should read the whole thread before madly posting! :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a dream language: sounds like Python to me.

2009-07-27 Thread Ethan Furman
[corrected top posting] Mohammad Tayseer wrote: *From:* Piet van Oostrum p...@cs.uu.nl *To:* python-list@python.org *Sent:* Monday, July 27, 2009 11:18:20 AM *Subject:* Re: Looking for a dream language: sounds like Python to me. Dotan Cohen dotanco...@gmail.com mailto:dotanco...@gmail.com

Re: Does python have the capability for driver development ?

2009-07-30 Thread Ethan Furman
Ben Finney wrote: Martin P. Hellwig martin.hell...@dcuktec.org writes: Machine Code: Whatever the machine executes, it could be that the CPU uses an abstraction of microcode to do this but from the perspective of the user, this is all done in the same 'black box' This requires, of course,

Re: Regexp problem

2009-07-30 Thread Ethan Furman
Marcus Wanner wrote: On 7/30/2009 9:32 AM, Beldar wrote: On 30 jul, 15:07, MRAB pyt...@mrabarnett.plus.com wrote: Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like lalala lalala tiruri beldar-is-listening tiruri lalala I need a regexp

Re: Confessions of a Python fanboy

2009-07-31 Thread Ethan Furman
Steven D'Aprano wrote: On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote: That and the fact that I couldn't stop laughing for long enough to learn any more when I read in the Pragmatic Programmer's Guide that Ruby, unlike less flexible languages, lets you alter the value of a constant. Yep,

Re: Regexp problem

2009-07-31 Thread Ethan Furman
MRAB wrote: Ethan Furman wrote: Marcus Wanner wrote: Wow, I really need to learn more about regexp... Any tutorials you guys can recommend? Marcus Mastering Regular Expressions Powerful Techniques for Perl and Other Tools By Jeffrey E. F. Friedl Great book! +1 I have the first edition

.dbf tables and Null

2009-07-31 Thread Ethan Furman
Mornin'! and a good one, too, I hope. Question for you... First part of the question: What is the general value in having Null capability for fields? Second part: Is there a tangible difference between Null, and the nothing of 0, '', False, etc, in python? Third part: If there is a

Re: .dbf tables and Null

2009-08-03 Thread Ethan Furman
John Machin wrote: On Aug 1, 3:41 am, Ethan Furman et...@stoneleaf.us wrote: Mornin'! and a good one, too, I hope. Question for you... First part of the question: What is the general value in having Null capability for fields? In general, in any database system, so that one can

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Ethan Furman
Mensanator wrote: snippers galore What does this mean? import turtle tooter = turtle.Turtle() *tooter*.tracer Traceback (most recent call last): File pyshell#2, line 1, in module tooter.tracer AttributeError: 'Turtle' object has no attribute 'tracer' tooter.hideturtle()

Programming by Contract

2009-08-05 Thread Ethan Furman
Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/) and now I have at least one question: Is this basically another way of thinking about unit testing, or is the idea

Re: Help with regex

2009-08-06 Thread Ethan Furman
Nobody wrote: On Thu, 06 Aug 2009 08:35:57 -0700, Robert Dailey wrote: I'm creating a python script that is going to try to search a text file for any text that matches my regular expression. The thing it is looking for is: FILEVERSION #,#,#,# The # symbol represents any number that can be

Re: question: why isn't a byte of a hash more uniform? how could I improve my code to cure that?

2009-08-07 Thread Ethan Furman
László Sándor wrote: Thank you, Tim. My comments are below. On 2009-08-07 13:19:47 -0400, Tim Chase python.l...@tim.thechases.com said: After I have written a short Python script that hashes my textfile line by line and collects the numbers next to the original, I checked what I got.

Re: variable scoping question.

2009-08-10 Thread Ethan Furman
Cornelius Keller wrote: [snip] I still think this is very confusing, because default values don't behave like most people would expect without reading the docs. - Cornelius Why would you expect to become a good programmer of _any_ language without reading its docs? ~Ethan~ --

Re: Python docs disappointing - group effort to hire writers?

2009-08-10 Thread Ethan Furman
Kee Nethery wrote: As someone trying to learn the language I want to say that the tone on this list towards people who are trying to learn Python feels like it has become anti-newbies. Learning a new language is difficult enough without seeing other newbies getting shamed for not knowing

Re: Python docs disappointing - group effort to hire writers?

2009-08-11 Thread Ethan Furman
David Lyon wrote: On Mon, 10 Aug 2009 09:13:34 -0700, Ethan Furman et...@stoneleaf.us wrote: As someone who relies heavily on the docs I will also say that the idea of giving the ability to modify the official documentation to somebody who is /learning/ the language is, quite frankly

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: But you're right, it's too late to change this now. Not really. There is a procedure for making non-backwards compatible changes. If you care deeply enough about this, you could agitate for Python 3.2 to raise

Re: add fields in a existing dbf

2009-08-11 Thread Ethan Furman
Alonso Luján Torres Taño wrote: Hi! I'm trying to modify a dbf adding a new field in a python script, but I can't. Just I can add a field in new dbf created in the same script. I tryed with: db = dbf.Dbf(../filesource.dbf,new =False, readOnly=False) ...

Re: Programming by Contract

2009-08-11 Thread Ethan Furman
Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/) and now I have at least one question: Is this basically another way of thinking about unit

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Ethan Furman
Douglas Alan wrote: On Aug 11, 2:00 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: test.cpp:1:1: warning: unknown escape sequence '\y' Isn't that a warning, not a fatal error? So what does temp contain? My Annotated C++ Reference Manual is packed, and surprisingly in

Re: Programming by Contract

2009-08-11 Thread Ethan Furman
Charles Yeomans wrote: On Aug 11, 2009, at 3:30 PM, Ethan Furman wrote: Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very brief look at pycontract (http://www.wayforward.net/pycontract/ ) and now I have

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-12 Thread Ethan Furman
Paul Boddie wrote: On 12 Aug, 17:08, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: It's not the people who suggest improvements to the docs that are the problem, but the ones who insist that the docs are terrible, but aren't willing to do anything but complain. Oh, and trolls

Re: what is it, that I don't understand about python and lazy evaluation?

2009-08-13 Thread Ethan Furman
Erik Bernoth wrote: Hi List, look at the following code: def evens(): # iterator returning even numbers i = 0 while True: yield i i += 2 # now get all the even numbers up to 15 L = [n for n in evens() if n 15] Isn't it strange, that this code runs (in a lazy

Re: what is it, that I don't understand about python and lazy evaluation?

2009-08-13 Thread Ethan Furman
Ethan Furman wrote: Erik Bernoth wrote: Hi List, look at the following code: def evens(): # iterator returning even numbers i = 0 while True: yield i i += 2 # now get all the even numbers up to 15 L = [n for n in evens() if n 15] Isn't it strange

Re: Python and behavior

2009-08-14 Thread Ethan Furman
MRAB wrote: Gary Herron wrote: goldtech wrote: Could you explain or link me to an explanation of this? Been using Python for a while but not sure I understand what's happening below. Thanks. ss=1 and f ss 'f' ss=0 and f ss 0 Python's Boolean

Re: Splitting on '^' ?

2009-08-14 Thread Ethan Furman
kj wrote: Sometimes I want to split a string into lines, preserving the end-of-line markers. In Perl this is really easy to do, by splitting on the beginning-of-line anchor: @lines = split /^/, $string; But I can't figure out how to do the same thing with Python. E.g.: import re

Re: implementing descriptors

2009-08-14 Thread Ethan Furman
dippim wrote: On Aug 14, 10:48 am, Dave Angel da...@ieee.org wrote: dippim wrote: On Aug 14, 2:34 am, Raymond Hettinger pyt...@rcn.com wrote: [David] I am new to Python and I have a question about descriptors. If I have a class as written below, is there a way to use descriptors to be

Re: Programming by Contract

2009-08-14 Thread Ethan Furman
Charles Yeomans wrote: On Aug 14, 2009, at 12:09 AM, Scott David Daniels wrote: Charles Yeomans wrote: On Aug 11, 2009, at 3:30 PM, Ethan Furman wrote: Ethan Furman wrote: Greetings! I have seen posts about the assert statement and PbC (or maybe it was DbC), and I just took a very

Re: Python 'for' loop is memory inefficient

2009-08-14 Thread Ethan Furman
Dr. Phillip M. Feldman wrote: I wrote the following correct but inefficient test of primality for purposes of demonstrating that the simplest algorithm is often not the most efficient. But, when I try to run the following code with a value of n that is large enough to produce a significant

Re: Python 'for' loop is memory inefficient

2009-08-17 Thread Ethan Furman
Emmanuel Surleau wrote: Dr. Phillip M. Feldman wrote: [snip] def is_prime(n): for j in range(2,n): if (n % j) == 0: return False return True It seems as though Python is actually expanding range(2,n) into a list of numbers, even though this is incredibly wasteful of memory. There

Re: Code formatting question: conditional expression

2009-08-18 Thread Ethan Furman
John Posner wrote: BTW, from the (admittedly few) responses to my original post, it seems there's some sentiment that conditional expressions are a non-Pythonic misfeature. Interesting ... -John I didn't read it that way. One of the (to me) core points of Pythonic is readability. A

Re: Identifying a class type - bad practice?

2009-08-18 Thread Ethan Furman
James Harris wrote: I am writing some code to form a tree of nodes of different types. The idea is to define one class per node type such as class node_type_1(node): specific properties by name including other node types class node_type_2(node): specific properties by name including other

Re: [OT]romantic poetry

2010-06-11 Thread Ethan Furman
Mark Lawrence wrote: For a bit of light relief from those fed up of reading of the perceived shortcomings of tkinker thought you might like this. Enjoy :) http://www.cc.gatech.edu/fac/Spencer.Rugaber/poems/love.txt Kindest regards. Mark Lawrence AH hahahahahahahahahahahah Much

Re: Deformed Form

2010-06-13 Thread Ethan Furman
Stephen Hansen wrote: On 6/12/10 12:50 PM, Dennis Lee Bieber wrote: On Sat, 12 Jun 2010 14:42:27 -0400, Victor Subervi victorsube...@gmail.com declaimed the following in gmane.comp.python.general: Interestingly, ls -al reveals *no* *.pyc files. Which would seem to indicate that

Re: Will and Abe's Guide to Pyjamas

2010-06-14 Thread Ethan Furman
lkcl wrote: oh look - there's a common theme, there: web technology equals useless :) this is getting sufficiently ridiculous, i thought it best to summarise the discussions of the past few days, from the perspective of four-year-olds: AH hahahahahahahahahahahaha --

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@bdurham.com wrote: Now, this is all IMHO: the style guide does not define any 'guidelines' on this, except that its okay to use from ... import ... to pull in classes and (implicitly) constants, and despite how the rules say 'one module per line'

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Stephen Hansen wrote: On 6/17/10 10:01 AM, Ethan Furman wrote: Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@bdurham.com wrote: Now, this is all IMHO: the style guide does not define any 'guidelines' on this, except that its okay to use from ... import ... to pull in classes

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Jack Diederich wrote: You want to import a name that is itself a namespace; preferably a module or package and sometimes a class. Importing constants can lead to trouble. ex/ from settings import DEBUG if DEBUG: log('debug is on!') The value of the flag gets fetched at import time. If code

Re: super() woes (n00b)

2010-06-17 Thread Ethan Furman
Deadly Dirk wrote: On Thu, 17 Jun 2010 13:48:45 -0400, J. Cliff Dyer wrote: super gives you an instantiated version of the super class, which means that you don't have to explicitly send self to any methods you call on it. So use `super().__init__()` instead. Thanks. Interestingly enough,

Re: super() woes (n00b)

2010-06-18 Thread Ethan Furman
Deadly Dirk wrote: On Thu, 17 Jun 2010 12:18:33 -0700, Ethan Furman wrote: Deadly Dirk wrote: On Thu, 17 Jun 2010 13:48:45 -0400, J. Cliff Dyer wrote: super gives you an instantiated version of the super class, which means that you don't have to explicitly send self to any methods you call

Re: GUIs - A Modest Proposal

2010-06-18 Thread Ethan Furman
Jeff Hobbs wrote: On Jun 6, 2:11 pm, rantingrick rantingr...@gmail.com wrote: On Jun 6, 2:06 pm, Mark Lawrence breamore...@yahoo.co.uk wrote: On 06/06/2010 16:31, rantingrick wrote: On Jun 5, 9:22 pm, antshi...@uklinux.net wrote: I ask the group; should we try to create a new GUI for

Re: Python dynamic attribute creation

2010-06-25 Thread Ethan Furman
WANG Cong wrote: On 06/25/10 15:34, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: WANG Cong a écrit : Hi, list! I have a doubt about the design of dynamic attribute creation by assignments in Python. As we know, in Python, we are able to create a new attribute of a

Re: hex question

2010-06-25 Thread Ethan Furman
Sneaky Wombat wrote: Why is python turning \x0a into a \n ? In [120]: h='\x0a\xa8\x19\x0b' In [121]: h Out[121]: '\n\xa8\x19\x0b' I don't want this to happen, can I prevent it? '\x0a' == '\n' -- http://mail.python.org/mailman/listinfo/python-list

Python v3.1.2 documentation question

2010-06-29 Thread Ethan Furman
In the glossary section it states: doc nested scope The ability to refer to a variable in an enclosing definition. For instance, a function defined inside another function can refer to variables in the outer function. Note that nested scopes work only for reference and not for assignment

Re: Python dynamic attribute creation

2010-06-29 Thread Ethan Furman
WANG Cong wrote: On 06/27/10 12:01, Carl Banks pavlovevide...@gmail.com wrote: On Jun 25, 8:24 pm, WANG Cong xiyou.wangc...@gmail.com wrote: Understand, but please consider my proposal again, if we switched to: setattr(foo, 'new_attr', blah) by default, isn't Python still dynamic as it is?

Re: Python dynamic attribute creation

2010-06-29 Thread Ethan Furman
WANG Cong wrote: On 06/29/10 17:48, Andre Alexander Bell p...@andre-bell.de wrote: As said previously I don't think one should differentiate between meta programming and programming within the language, since the former is nothing different than the latter. If you check other programming

Re: Python v3.1.2 documentation question

2010-06-29 Thread Ethan Furman
Stephen Hansen wrote: On 6/29/10 10:01 AM, Ethan Furman wrote: In the glossary section it states: doc nested scope The ability to refer to a variable in an enclosing definition. For instance, a function defined inside another function can refer to variables in the outer function. Note

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Ethan Furman
Terry Reedy wrote: On 6/30/2010 8:22 AM, Nobody wrote: I've noticed over the years a significant anti-RE sentiment in the Python community. IMHO, the sentiment isn't so much against REs per se, but against excessive or inappropriate use. Apart from making it easy to write illegible code,

Re: Solutions for hand injury from computer use

2010-07-01 Thread Ethan Furman
Ben Finney wrote: geremy condra debat...@gmail.com writes: Right. I'm much more concerned about the position of my Ctrl key, to avoid hand injury from all the key chording done as a programmer. Not saying its a cure-all, but I broke my hand pretty badly a few years ago and had a lot of luck

Re: Python v3.1.2 documentation question

2010-07-01 Thread Ethan Furman
Aahz wrote: In article mailman.2365.1277844243.32709.python-l...@python.org, Ethan Furman et...@stoneleaf.us wrote: Stephen Hansen wrote: On 6/29/10 10:01 AM, Ethan Furman wrote: In the glossary section it states: doc nested scope The ability to refer to a variable in an enclosing

Re: Python v3.1.2 documentation question

2010-07-02 Thread Ethan Furman
Terry Reedy wrote: On 7/1/2010 6:42 PM, Ethan Furman wrote: Hmmm Well, as this is my first ever bug post (yay! ;) Great! I *think* this is what you want: http://bugs.python.org/issue9121 I believe Benjamin meant that it was already fixed in http://docs.python.org/dev/py3k

Re: automate minesweeper with python

2010-07-02 Thread Ethan Furman
Terry Reedy wrote: On 7/1/2010 6:42 PM, Emile van Sebille wrote: On 7/1/2010 2:52 PM Jay said... pywinauto looks to be almost perfect. All I need now is to read the numbers uncovered when a minesweeper square is clicked on, or that I just hit a mine. ... or, you could always win...

Re: Python -- floating point arithmetic

2010-07-07 Thread Ethan Furman
Nobody wrote: On Wed, 07 Jul 2010 15:08:07 +0200, Thomas Jollans wrote: you should never rely on a floating-point number to have exactly a certain value. Never is an overstatement. There are situations where you can rely upon a floating-point number having exactly a certain value. It's not

Re: Python -- floating point arithmetic

2010-07-08 Thread Ethan Furman
Wolfram Hinderer wrote: On 7 Jul., 19:32, Ethan Furman et...@stoneleaf.us wrote: Nobody wrote: On Wed, 07 Jul 2010 15:08:07 +0200, Thomas Jollans wrote: you should never rely on a floating-point number to have exactly a certain value. Never is an overstatement. There are situations

Re: Easy questions from a python beginner

2010-07-14 Thread Ethan Furman
Alf P. Steinbach /Usenet wrote: * MRAB, on 12.07.2010 00:37: Alf P. Steinbach /Usenet wrote: Of course there are variables, that's why the docs call them variables. In Java a variable is declared and exists even before the first assignment to it. In Python a 'variable' isn't declared and

Re: rstrip()

2010-07-18 Thread Ethan Furman
MRAB wrote: [snip] How about 'strip_str', 'lstrip_str' and 'rstrip_str', or something similar? +1 on the names ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-26 Thread Ethan Furman
Gregory Ewing wrote: Raymond Hettinger wrote: Every class in the MRO implementing the target method *must* call super() to give the next class in the MRO a chance to run. EXCEPT for the last one, which must NOT call super! The posted example happens to work because object has a default

Re: hasattr + __getattr__: I think this is Python bug

2010-07-26 Thread Ethan Furman
Bruno Desthuilliers wrote: Duncan Booth a écrit : Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: If you don't want to create as many Whatever instances as MyClass instances, you can create a single Whatever instance before defining your class: DEFAULT_WHATEVER =

Re: hasattr + __getattr__: I think this is Python bug

2010-07-27 Thread Ethan Furman
Bruno Desthuilliers wrote: Bruno Desthuilliers a écrit : Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: I have a class (FuncDesigner oofun) that has no attribute size, but it is overloaded

<    1   2   3   4   5   6   7   8   9   10   >