Re: frozendict (v0.1)

2010-10-07 Thread Arnaud Delobelle
kj writes: > In <87hbgxlk67@gmail.com> Arnaud Delobelle writes: > >>A simple fix is to use hash(frozenset(self.items())) instead. > > Thanks for pointing out the hash bug. It was an oversight: I meant > to write > > def __hash__(self): > return hash(sorted(tuple(self.items(

Re: del() function - cannot find documentation

2010-10-07 Thread Tim Roberts
Chris Rebert wrote: >On Thu, Oct 7, 2010 at 1:12 PM, wrote: >> >> there is following python script: >> >> mine = { 1: "sd", 2: "mk" } >> del(mine[1]) >> print mine >> >> the problem is I cannot find any information about del() function in >> python 2.7 documentation. >> is it a documentation bug

ANN: Roundup Issue Tracker 1.4.16 released

2010-10-07 Thread Richard Jones
I'm proud to release version 1.4.16 of Roundup which introduces some minor features and, as usual, fixes some bugs: Features: - allow trackers to override the classes used to render properties in templating per issue2550659 (thanks Ezio Melotti) - new mailgw configuration item "subject_updates_

Re: toy list processing problem: collect similar terms

2010-10-07 Thread sln
On Wed, 06 Oct 2010 10:52:19 -0700, s...@netherlands.com wrote: >On Sat, 25 Sep 2010 21:05:13 -0700 (PDT), Xah Lee wrote: > >>here's a interesting toy list processing problem. >> >>I have a list of lists, where each sublist is labelled by >>a number. I need to collect together the contents of all

Re: Ordering tests in a testsuite

2010-10-07 Thread Steven D'Aprano
On Fri, 08 Oct 2010 08:35:12 +1100, Ben Finney wrote: > Ulrich Eckhardt writes: > >> However, sometimes it doesn't make sense to run test_bar() if >> test_foo() already failed, because they basically build upon each >> other. > > That's a mistake. If the success of ‘test_bar’ depends on the res

Re: frozendict (v0.1)

2010-10-07 Thread Steven D'Aprano
On Fri, 08 Oct 2010 00:23:30 +, kj wrote: > In <87hbgxlk67@gmail.com> Arnaud Delobelle > writes: > >>A simple fix is to use hash(frozenset(self.items())) instead. > > Thanks for pointing out the hash bug. It was an oversight: I meant to > write > > def __hash__(self): > re

Re: Many newbie questions regarding python

2010-10-07 Thread Steven D'Aprano
On Thu, 07 Oct 2010 20:10:14 -0300, Rogério Brito wrote: > What is the Pythonic way of writing code like this? So far, I have > found many alternatives and I would like to write code that others in > the Python community would find natural to read. Some of the things > that crossed my mind: > >

Re: frozendict (v0.1)

2010-10-07 Thread kj
In <87hbgxlk67@gmail.com> Arnaud Delobelle writes: >A simple fix is to use hash(frozenset(self.items())) instead. Thanks for pointing out the hash bug. It was an oversight: I meant to write def __hash__(self): return hash(sorted(tuple(self.items( I imagine that frozenset i

Re: Many newbie questions regarding python

2010-10-07 Thread Tim Harig
On 2010-10-07, Rogério Brito wrote: > 1 - The first issue that I am having is that I don't seem to be able to, say, > use something that would be common for people writing programs in C: defining > a > one-dimensional vector and only initializing it when needed. > > For instance, in C, I would wr

Re: Many newbie questions regarding python

2010-10-07 Thread Andreas Waldenburger
On Fri, 08 Oct 2010 00:46:41 +0100 MRAB wrote: > In other words, don't try to write a C program in Python! Man, I'm good. :D /W -- To reach me via email, replace INVALID with the country code of my home country. But if you spam me, I'll be one sour kraut. -- http://mail.python.org/mailman

Re: Many newbie questions regarding python

2010-10-07 Thread Andreas Waldenburger
On Thu, 07 Oct 2010 20:10:14 -0300 Rogério Brito wrote: > I am used to some languages like C, but I am just a complete newbie > with Python and, while writing some small snippets, I had encountered > some problems, with which I would sincerely appreciate any help, > since I appreciate this langua

Re: Many newbie questions regarding python

2010-10-07 Thread MRAB
On 08/10/2010 00:10, Rogério Brito wrote: Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate this language to write

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-07 Thread Lawrence D'Oliveiro
In message <87hbgyosdc@web.de>, Diez B. Roggisch wrote: > Lawrence D'Oliveiro writes: > >> In message <87d3rorf2f@web.de>, Diez B. Roggisch wrote: >> >>> Lawrence D'Oliveiro writes: >>> What exactly is the point of a BOM in a UTF-8-encoded file? >>> >>> It's a marker like the "co

Many newbie questions regarding python

2010-10-07 Thread Rogério Brito
Hi there. I am used to some languages like C, but I am just a complete newbie with Python and, while writing some small snippets, I had encountered some problems, with which I would sincerely appreciate any help, since I appreciate this language to write my "running pseudocode in" and I am serious

Re: frozendict (v0.1)

2010-10-07 Thread Arnaud Delobelle
Oops I sent off my reply before I had finished! kj writes: > Following a suggestion from MRAB, I attempted to implement a > frozendict class. My implementation took a lot more work than > something this simple should take, and it still sucks. So I'm > hoping someone can show me a better way.

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Chris Rebert
On Thu, Oct 7, 2010 at 2:28 PM, Christian Heimes wrote: > Am 07.10.2010 22:02, schrieb Chris Rebert: >> On Thu, Oct 7, 2010 at 12:13 PM, kj wrote: >> >>> It would facilitate the implementation of t() to have a simple test >>> for mutability.  Is there one? >> >> Non-default hashability is an app

Re: frozendict (v0.1)

2010-10-07 Thread Arnaud Delobelle
kj writes: > Following a suggestion from MRAB, I attempted to implement a > frozendict class. My implementation took a lot more work than > something this simple should take, and it still sucks. So I'm > hoping someone can show me a better way. Specifically, I'm hoping > that there is a "recip

Re: harmful str(bytes)

2010-10-07 Thread Arnaud Delobelle
Hallvard B Furuseth writes: > I've been playing a bit with Python3.2a2, and frankly its charset > handling looks _less_ safe than in Python 2. > > The offender is bytes.__str__: str(b'foo') == "b'foo'". > It's often not clear from looking at a piece of code whether > some data is treated as strin

frozendict (v0.1)

2010-10-07 Thread kj
Following a suggestion from MRAB, I attempted to implement a frozendict class. My implementation took a lot more work than something this simple should take, and it still sucks. So I'm hoping someone can show me a better way. Specifically, I'm hoping tha

Re: Ordering tests in a testsuite

2010-10-07 Thread Ben Finney
Ulrich Eckhardt writes: > However, sometimes it doesn't make sense to run test_bar() if > test_foo() already failed, because they basically build upon each > other. That's a mistake. If the success of ‘test_bar’ depends on the result of ‘test_foo’, then it's not an independent test and therefore

harmful str(bytes)

2010-10-07 Thread Hallvard B Furuseth
I've been playing a bit with Python3.2a2, and frankly its charset handling looks _less_ safe than in Python 2. The offender is bytes.__str__: str(b'foo') == "b'foo'". It's often not clear from looking at a piece of code whether some data is treated as strings or bytes, particularly when translatin

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Christian Heimes
Am 07.10.2010 22:02, schrieb Chris Rebert: > On Thu, Oct 7, 2010 at 12:13 PM, kj wrote: > >> It would facilitate the implementation of t() to have a simple test >> for mutability. Is there one? > > Non-default hashability is an approximate heuristic: Except that every user defined class is has

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Arnaud Delobelle
Chris Rebert writes: > On Thu, Oct 7, 2010 at 1:46 PM, Arnaud Delobelle wrote: [...] >> I think defining mutability is subject to opinion, but here is a first >> approximation. >> >> >> def mutable(obj): >>    return obj.__hash__ is None or type(obj).__hash__ == object.__hash__ > > Corner case (

Re: 64 bit offsets?

2010-10-07 Thread MRAB
On 07/10/2010 20:12, jay thompson wrote: I'm not sure if it is limited to 32 bit addresses or if it's only re.start() that is limited to 'em. jt From what I can tell, Microsoft compilers (I'm assuming you're using Windows) have a 32-bit 'int' type for both 32-bit and 64-bit builds, and the re

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Chris Rebert
On Thu, Oct 7, 2010 at 1:46 PM, Arnaud Delobelle wrote: > kj writes: >> I want to implement a test t() that will return True if its two >> arguments are "completely" different.  By this I mean that they >> don't share any "non-atomic" component.  E.g., if >> >> a = [0, 1] >> b = [0, 1] >> c = [2,

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Arnaud Delobelle
kj writes: > I want to implement a test t() that will return True if its two > arguments are "completely" different. By this I mean that they > don't share any "non-atomic" component. E.g., if > > a = [0, 1] > b = [0, 1] > c = [2, 3] > d = [2, 3] > > A = (a, c, 0) > B = (a, d, 1) > C = (b, d, 0

Re: del() function - cannot find documentation

2010-10-07 Thread Chris Rebert
On Thu, Oct 7, 2010 at 1:12 PM, wrote: > Hallo ML. > > there is following python script: > > mine = { 1: "sd", 2: "mk" } > del(mine[1]) > print mine > > the problem is I cannot find any information about del() function in > python 2.7 documentation. > is it a documentation bug or I misunderstand

del() function - cannot find documentation

2010-10-07 Thread mafeusek
Hallo ML. there is following python script: mine = { 1: "sd", 2: "mk" } del(mine[1]) print mine the problem is I cannot find any information about del() function in python 2.7 documentation. is it a documentation bug or I misunderstand something about del()? best regards, Pawel -- http://mai

Re: hashkey/digest for a complex object

2010-10-07 Thread Arnaud Delobelle
kj writes: > The short version of this question is: where can I find the algorithm > used by the tuple class's __hash__ method? > > Now, for the long version of this question, I'm working with some > complext Python objects that I want to be able to compare for > equality easily. > > These object

Re: how to test for atomicity/mutability/hashability?

2010-10-07 Thread Chris Rebert
On Thu, Oct 7, 2010 at 12:13 PM, kj wrote: > It would facilitate the implementation of t() to have a simple test > for mutability.  Is there one? Non-default hashability is an approximate heuristic: def is_immutable(x): try: hash(x) except TypeError: return False els

how to test for atomicity/mutability/hashability?

2010-10-07 Thread kj
I want to implement a test t() that will return True if its two arguments are "completely" different. By this I mean that they don't share any "non-atomic" component. E.g., if a = [0, 1] b = [0, 1] c = [2, 3] d = [2, 3] A = (a, c, 0) B = (a, d, 1) C = (b, d, 0) The desired test t() would y

Re: 64 bit offsets?

2010-10-07 Thread jay thompson
I'm not sure if it is limited to 32 bit addresses or if it's only re.start() that is limited to 'em. jt - "It's quite difficult to remind people that all this stuff was here for a million years before people. So the idea that we are required to manage it is ridiculous. What we are having to

Re: Ordering tests in a testsuite

2010-10-07 Thread Peter Otten
Ulrich Eckhardt wrote: > I'm currently working on a testsuite using Python's unittest library. This > works all good and fine, but there's one thing where I haven't seen an > elegant solution to yet, and that is the ordering. Currently, it takes all > classes and orders them alphabetically and the

Re: mantissa and exponent in base 10

2010-10-07 Thread Jason Swails
On Thu, Oct 7, 2010 at 11:51 AM, C or L Smith wrote: > I just sent a similar suggestion to tutor: check out the %g format. > > >>> print '%g' % 1.2345e7 > 1.2345e+07 > >>> print '%g' % 1.2345e-7 > 1.2345e-07 > >>> print '%g' % 1.2345 > 1.2345 > > >>> def me(n, sigfigs = 4): > ... s = ('%.'+'%ig'

Ordering tests in a testsuite

2010-10-07 Thread Ulrich Eckhardt
Hello! I'm currently working on a testsuite using Python's unittest library. This works all good and fine, but there's one thing where I haven't seen an elegant solution to yet, and that is the ordering. Currently, it takes all classes and orders them alphabetically and then takes all test functio

Re: Python Programmer needed in the LA area

2010-10-07 Thread Jack Diederich
On Thu, Oct 7, 2010 at 11:55 AM, Capstick, Antony H wrote: > I am looking for an experienced Person .. to develop and implement a > graphical track map operating in MS > Windows that will be used to display graphical information for a new Disney > attraction. 1) http://www.python.org/community/j

Re: ConFoo spam?

2010-10-07 Thread Jack Diederich
On Thu, Oct 7, 2010 at 7:56 AM, Diez B. Roggisch wrote: > Chris Withers writes: >> >> Is it just me or does the mailing of just about every single >> python-based project mailing list with a 90% form email advertising a >> conference that only has one python track *and* clashes with PyCon >> feel

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-07 Thread Diez B. Roggisch
Lawrence D'Oliveiro writes: > In message <87d3rorf2f@web.de>, Diez B. Roggisch wrote: > >> Lawrence D'Oliveiro writes: >> >>> What exactly is the point of a BOM in a UTF-8-encoded file? >> >> It's a marker like the "coding: utf-8" in python-files. It tells the >> software aware of it that

Re: mantissa and exponent in base 10

2010-10-07 Thread C or L Smith
I just sent a similar suggestion to tutor: check out the %g format. >>> print '%g' % 1.2345e7 1.2345e+07 >>> print '%g' % 1.2345e-7 1.2345e-07 >>> print '%g' % 1.2345 1.2345 >>> def me(n, sigfigs = 4): ... s = ('%.'+'%ig' % sigfigs) % n # check docs for a better way? ... if 'e' in s: m, e = s.s

Python Programmer needed in the LA area

2010-10-07 Thread Capstick, Antony H
I am looking for an experienced Person or Company located in Southern California to develop and implement a graphical track map operating in MS Windows that will be used to display graphical information for a new Disney attraction. Implementer Qualifications General requirements: * Exp

Re: ConFoo spam?

2010-10-07 Thread Yannick Gingras
On October 7, 2010, Chris Withers wrote: > Hi All, > > Is it just me or does the mailing of just about every single > python-based project mailing list with a 90% form email advertising a > conference that only has one python track and clashes with PyCon feel > just a bit like spam? > > I know

Re: 64 bit offsets?

2010-10-07 Thread MRAB
On 06/10/2010 22:41, jay thompson wrote: Hello everyone, I'm trying to extract some data from a large memory mapped file (the largest is ~30GB) with re.finditer() and re.start(). Pythons regular expression module is great but the size of re.start() is 32bits (signed so I can really only address

Re: ConFoo spam?

2010-10-07 Thread Yannick Gingras
On October 7, 2010, Chris Withers wrote: > Hi All, > > Is it just me or does the mailing of just about every single > python-based project mailing list with a 90% form email advertising a > conference that only has one python track and clashes with PyCon feel > just a bit like spam? > > I know

Data source path of a lyer file

2010-10-07 Thread Ahmed, Shakir
Hi, Is there any way that I can read the data source path of a .lyr file using Arc Object gp processor. Thanks sa -- http://mail.python.org/mailman/listinfo/python-list

Re: hashkey/digest for a complex object

2010-10-07 Thread MRAB
On 07/10/2010 11:42, kj wrote: In Terry Reedy writes: If these two attributes, and hence the dicts, are public, then your instances are mutable. I guess I should have written "immutable among consenting adults." As far as I know, Python does not support private attributes, so I guess the

Re: hashkey/digest for a complex object

2010-10-07 Thread Diez B. Roggisch
kj writes: > In <87pqvmp611@web.de> de...@web.de (Diez B. Roggisch) writes: > >>I tried codesearch first. Not satisfied after 30 seconds with the >>results, I did the most straight forward thing - I downloaded and >>un-packed the python source... and took a look. > >>From that I learned the

Re: hashkey/digest for a complex object

2010-10-07 Thread kj
In <87pqvmp611@web.de> de...@web.de (Diez B. Roggisch) writes: >I tried codesearch first. Not satisfied after 30 seconds with the >results, I did the most straight forward thing - I downloaded and >un-packed the python source... and took a look. >From that I learned the tuplehash function na

[ANN] pywebkit - python bindings for webkit DOM (alpha)

2010-10-07 Thread lkcl
i've been kindly sponsored by http://www.samurai.com.br to create direct python bindings to webkit's DOM: http://www.gnu.org/software/pythonwebkit/ the significance of this project is that it makes python a peer of javascript when it comes to manipulating HTML through DOM functions (including gain

[ANN] pywebkit - python bindings for webkit DOM (alpha)

2010-10-07 Thread lkcl
From: l...@lkcl.net To: python-list@python.org i've been kindly sponsored by http://www.samurai.com.br to create direct python bindings to webkit's DOM: http://www.gnu.org/software/pythonwebkit/ the significance of this project is that it makes python a peer of javascript when it comes to manipul

Re: hashkey/digest for a complex object

2010-10-07 Thread Diez B. Roggisch
kj writes: > In de...@web.de (Diez B. Roggisch) writes: > >>kj writes: > >>> The short version of this question is: where can I find the algorithm >>> used by the tuple class's __hash__ method? > >>Surprisingly, in the source: > >>http://google.com/codesearch/p?hl=de#-2BKs-LW4I0/trunk/python/sr

Re: ConFoo spam?

2010-10-07 Thread Diez B. Roggisch
Chris Withers writes: > Hi All, > > Is it just me or does the mailing of just about every single > python-based project mailing list with a 90% form email advertising a > conference that only has one python track *and* clashes with PyCon > feel just a bit like spam? > > I know it's enough to put

Re: how to write an xml file without dom.ext?

2010-10-07 Thread Diez B. Roggisch
hackingKK writes: > Hello all. > I need to create an xml file. > I am using dom.minidom module. > It works fine as long as the xml tree is created. > But I get the import error for dom.ext. > I searched through the python docs but can't find a solution. > I am pritty sure that there is way to wri

Re: SysLogHandler message formatting

2010-10-07 Thread Vinay Sajip
On Oct 6, 6:56 pm, "Dustin C. Hatch" wrote: > > My question, therefore, is where does this problem lie? Is it a bug in > Metalog that it doesn't properly parse the message, or is it a bug in > SysLogHandler that it doesn't properly format it? I guess it could > also be that if one wants to use t

Re: mantissa and exponent in base 10

2010-10-07 Thread Dave Angel
On 2:59 PM, Steven D'Aprano wrote: I want the mantissa and decimal exponent of a float, in base 10: mantissa and exponent of 1.2345e7 => (1.2345, 7) (0.12345, 8) would also be acceptable. The math module has a frexp() function, but it produces a base-2 exponent: math.frexp(1.2345e7) (0.7

Re: if the else short form

2010-10-07 Thread BartC
On Thu, 07 Oct 2010 01:36:33 +0100, BartC wrote: However, as I mentioned, one problem here is having to evaluate all the items in the list before selecting one: ... x = {1 : fna(), 2 : fnb(), 3 : fnc()}.get(i, "None Of The Above") "Mel" wrote in message news:i8j56e$ub...@speranza.aioe.org

Re: how to write an xml file without dom.ext?

2010-10-07 Thread Nitin Pawar
import xml.dom.minidom import os xml = xml.dom.minidom.parse(xml_fname) # or xml.dom.minidom.parseString(xml_string) pretty_xml_as_string = xml.toprettyxml() file = open("newfile", 'w') file.write(pretty_xml_as_string) file.close() 1. On Thu, Oct 7, 2010 at 4:16 PM, hackingKK wrote: >

Re: hashkey/digest for a complex object

2010-10-07 Thread kj
In de...@web.de (Diez B. Roggisch) writes: >kj writes: >> The short version of this question is: where can I find the algorithm >> used by the tuple class's __hash__ method? >Surprisingly, in the source: >http://google.com/codesearch/p?hl=de#-2BKs-LW4I0/trunk/python/src/Objects/tupleobject.c&

Re: how to write an xml file without dom.ext?

2010-10-07 Thread hackingKK
On Thursday 07 October 2010 03:49 PM, Nitin Pawar wrote: why not just convert it to string with print pretty and then normal write to a file Can you give an example. happy hacking. Krishnakant. On Thu, Oct 7, 2010 at 3:36 PM, hackingKK > wrote: Hello all.

Re: hashkey/digest for a complex object

2010-10-07 Thread kj
In Terry Reedy writes: >If these two attributes, and hence the dicts, are public, then your >instances are mutable. I guess I should have written "immutable among consenting adults." As far as I know, Python does not support private attributes, so I guess the dicts are public no matter what

Re: how to write an xml file without dom.ext?

2010-10-07 Thread Nitin Pawar
why not just convert it to string with print pretty and then normal write to a file On Thu, Oct 7, 2010 at 3:36 PM, hackingKK wrote: > Hello all. > I need to create an xml file. > I am using dom.minidom module. > It works fine as long as the xml tree is created. > But I get the import error for

Re: no .pyc

2010-10-07 Thread News123
On 10/07/2010 11:55 AM, Tim Hanson wrote: > I feel a little silly. I am learning Python by reading _Learning_Python_ by > Mark Lutz. I made it all the way to "Hello World" before my first question. > :-) > > The program isn't too complicated. > print "Hello World" > print 2**100 > > I saved i

how to write an xml file without dom.ext?

2010-10-07 Thread hackingKK
Hello all. I need to create an xml file. I am using dom.minidom module. It works fine as long as the xml tree is created. But I get the import error for dom.ext. I searched through the python docs but can't find a solution. I am pritty sure that there is way to write the file to disk without usin

no .pyc

2010-10-07 Thread Tim Hanson
I feel a little silly. I am learning Python by reading _Learning_Python_ by Mark Lutz. I made it all the way to "Hello World" before my first question. :-) The program isn't too complicated. print "Hello World" print 2**100 I saved it to a directory for which I have rw permissions that I move

Re: mantissa and exponent in base 10

2010-10-07 Thread Jason Swails
On Wed, Oct 6, 2010 at 6:54 PM, Steven D'Aprano < steve-remove-t...@cybersource.com.au> wrote: > I want the mantissa and decimal exponent of a float, in base 10: > > mantissa and exponent of 1.2345e7 > Perhaps not the prettiest, but you can always use string manipulations: def frexp_10(decimal):

[ANN] pywebkit - python bindings for webkit DOM (alpha)

2010-10-07 Thread Luke Kenneth Casson Leighton
i've been kindly sponsored by http://www.samurai.com.br to create direct python bindings to webkit's DOM: http://www.gnu.org/software/pythonwebkit/ the significance of this project is that it makes python a peer of javascript when it comes to manipulating HTML through DOM functions (including gain

Re: list parameter of a recursive function

2010-10-07 Thread TP
Seebs wrote: > On 2010-10-07, TP wrote: >> Diez B. Roggisch wrote: >>> A safer alternative for these cases is using tuples, because they are >>> immutable. > >> The problem with tuples is that it is not easy to modify them: > > This is probably the best post-and-response I've seen in the last c

64 bit offsets?

2010-10-07 Thread jay thompson
Hello everyone, I'm trying to extract some data from a large memory mapped file (the largest is ~30GB) with re.finditer() and re.start(). Pythons regular expression module is great but the size of re.start() is 32bits (signed so I can really only address 2GB). I was wondering if any here had some

Re: 64 bit offsets?

2010-10-07 Thread jay thompson
As nice as it would be to use 64bit offsets I am instead mmapping the file in 1GB chunks and getting the results I need. I would still be interested in a 64bit solution though. jt On Wed, Oct 6, 2010 at 2:41 PM, jay thompson wrote: > Hello everyone, > > I'm trying to extract some data from a lar

ConFoo spam?

2010-10-07 Thread Chris Withers
Hi All, Is it just me or does the mailing of just about every single python-based project mailing list with a 90% form email advertising a conference that only has one python track *and* clashes with PyCon feel just a bit like spam? I know it's enough to put me off even considering going to

Opening a webpage in the background via webbrowser.open()

2010-10-07 Thread python
Python 2.7 (32-bit/Windows): Is there a way to use webbrowser.open() to open a web page in the default browser, but in the background, so that the application making the webbrowser.open() call remains the active application? Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-lis

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-07 Thread Terry Reedy
On 10/6/2010 7:14 AM, Antoon Pardon wrote: That right-hand-half-open intervals (i.e. a<= i< b, equivalently [a, b) ), which are what Python uses, are to be preferred. (See aforelinked PDF: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF) This specifically discusses subsequences of 'natu

Re: help!!!

2010-10-07 Thread Emile van Sebille
On 10/6/2010 12:08 PM Diez B. Roggisch said... writes: plz can u convert this cpp file into python i need that badly as soon as possible... I am new to python. I just wanna learn it For such an aspiring student of the art of computer programming, I have the strange feeling of lack-of-e

Re: hashkey/digest for a complex object

2010-10-07 Thread Terry Reedy
On 10/6/2010 2:58 PM, kj wrote: These objects are non-mutable once they are created, See below. like to use a two-step comparison for equality, based on the assumption that I can compute (either at creation time, or as needed and memoized) a hashkey/digest for each object. The test for equa

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-07 Thread Terry Reedy
On 10/6/2010 12:02 PM, geekbuntu wrote: in general, what are things i would want to 'watch for/guard against' in a file upload situation? i have my file upload working (in the self-made framework @ work without any concession for multipart form uploads), but was told to make sure it's cleansed a

Re: list parameter of a recursive function

2010-10-07 Thread Terry Reedy
On 10/6/2010 3:22 PM, TP wrote: Hi, I have a function f that calls itself recursively. It has a list as second argument, with default argument equal to None (and not [], as indicated at: http://www.ferg.org/projects/python_gotchas.html#contents_item_6 ) This sort of function is an exception. I

Re: mantissa and exponent in base 10

2010-10-07 Thread Robert Kern
On 10/6/10 5:54 PM, Steven D'Aprano wrote: I want the mantissa and decimal exponent of a float, in base 10: mantissa and exponent of 1.2345e7 => (1.2345, 7) (0.12345, 8) would also be acceptable. The math module has a frexp() function, but it produces a base-2 exponent: math.frexp(1.2345e7

Re: list parameter of a recursive function

2010-10-07 Thread Diez B. Roggisch
TP writes: > Diez B. Roggisch wrote: > >> Back to your example: your solution is perfectly fine, although a bit >> costly and more error-prone if you happen to forget to create a copy. >> A safer alternative for these cases is using tuples, because they are >> immutable. > > Thanks Diez for your

Re: list parameter of a recursive function

2010-10-07 Thread Chris Rebert
On Wed, Oct 6, 2010 at 10:25 PM, TP wrote: > Diez B. Roggisch wrote: > >> Back to your example: your solution is perfectly fine, although a bit >> costly and more error-prone if you happen to forget to create a copy. >> A safer alternative for these cases is using tuples, because they are >> immut

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-07 Thread MRAB
On 06/10/2010 21:01, Martin Gregorie wrote: On Wed, 06 Oct 2010 09:02:21 -0700, geekbuntu wrote: in general, what are things i would want to 'watch for/guard against' in a file upload situation? i have my file upload working (in the self-made framework @ work without any concession for multipa