Re: pickle and infinity

2006-11-29 Thread Grant Edwards
On 2006-11-29, Bart Ogryczak <[EMAIL PROTECTED]> wrote: > > Fredrik Lundh wrote: >> Bart Ogryczak wrote: >> >> > I´ve got this problem with pickle, it seems it doesn´t handle >> > correctly infinite values (nor does Python return overflow/underflow >> > error). >> >> Python 2.X relies on the C libr

Re: libboost, python, and dijkstra shortest path

2006-11-29 Thread Roman Yakovenko
On 29 Nov 2006 11:35:52 -0800, Bytter <[EMAIL PROTECTED]> wrote: > Ok, found the solution here: http://www.osl.iu.edu/~dgregor/bgl-python/ > > But still cannot make anything that works... Anyone who has experience > in this area can help me with the following code: > > import boost as bgl > > graph

Re: utf - string translation

2006-11-29 Thread Fredrik Lundh
John Machin wrote: > 3. ... and to check for missing maps. The OP may be working only with > French text, and may not care about Icelandic and German letters, but > other readers who stumble on this (and miss past thread(s) on this > topic) may like something done with \xde (capital thorn), \xfe

Re: why would anyone use python when java is there?

2006-11-29 Thread Stephen Eilert
Score: -1 (Flamebait) gavino escreveu: > wtf -- http://mail.python.org/mailman/listinfo/python-list

type(foo) == function ?

2006-11-29 Thread Tom Plunket
I'd like to figure out if a given parameter is a function or not. E.g. >>> type(1) >>> type(1) == int True implies: >>> def foo(): ... pass ... >>> type(foo) >>> type(foo) == function Traceback (most recent call last): File "", line 1, in ? NameError: name 'function' is not defined Is th

Re: type(foo) == function ?

2006-11-29 Thread Chris Mellon
On 11/29/06, Tom Plunket <[EMAIL PROTECTED]> wrote: > I'd like to figure out if a given parameter is a function or not. > > E.g. > > >>> type(1) > > >>> type(1) == int > True > > implies: > > >>> def foo(): > ... pass > ... > >>> type(foo) > > >>> type(foo) == function > Traceback (most recent

Re: type(foo) == function ?

2006-11-29 Thread Erik Max Francis
Hi Tom. Tom Plunket wrote: > I'd like to figure out if a given parameter is a function or not. > > E.g. > type(1) > type(1) == int > True > > implies: > def foo(): > ... pass > ... type(foo) > type(foo) == function > Traceback (most recent call last): > File "",

Re: type(foo) == function ?

2006-11-29 Thread Fredrik Lundh
Tom Plunket wrote: > I'd like to figure out if a given parameter is a function or not. http://effbot.org/pyref/callable -- http://mail.python.org/mailman/listinfo/python-list

Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, "Scott_Davies" <[EMAIL PROTECTED]> wrote: > Hi, > > I have an old Mac with OS X Panther installed. I also have the Python > language download file, but I haven't got a text/script editor to use > for it. Does anyone have a recommendation for a good Python text >

Re: Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread Timothy Grant
On 11/29/06, Lou Pecora <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "Scott_Davies" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I have an old Mac with OS X Panther installed. I also have the Python > > language download file, but I haven't got a text/script editor to use > > fo

Re: Python program that validates an url against w3c markup validator

2006-11-29 Thread Nikita the Spider
In article <[EMAIL PROTECTED]>, "yaru22" <[EMAIL PROTECTED]> wrote: > I'd like to create a program that validates bunch of urls against the > w3c markup validator (http://validator.w3.org/) and store the result in > a file. > > Since I don't know network programming, I have no idea how to start

Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread Nikita the Spider
In article <[EMAIL PROTECTED]>, Lou Pecora <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "Scott_Davies" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I have an old Mac with OS X Panther installed. I also have the Python > > language download file, but I haven't got a text/scri

Re: type(foo) == function ?

2006-11-29 Thread Tom Plunket
Erik Max Francis wrote: > In dynamically-typed languages in general, explicit typechecks are not > a good idea, since they often preclude user-defined objects from being > used. Instead, try performing the call and catch the resulting > TypeError: Good point, although I need to figure out if

Re: type(foo) == function ?

2006-11-29 Thread Chris Mellon
On 11/29/06, Tom Plunket <[EMAIL PROTECTED]> wrote: > Erik Max Francis wrote: > > > In dynamically-typed languages in general, explicit typechecks are not > > a good idea, since they often preclude user-defined objects from being > > used. Instead, try performing the call and catch the resulting >

Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread Stephen Hansen
If you're looking for something free, there's always IDLE. http://www.python.org/download/mac/ However, if you don't mind paying a little bit-- you should really look at TextMate at http://www.macromates.com/ It's .. the best editor ever :) I'm the envy of all my windows coworkers who I had prev

ensuring valid latin-1

2006-11-29 Thread Chris Curvey
Hey all, I'm trying to write something that will "fail fast" if one of my users gives me non-latin-1 characters. So I tried this: >>> testString = "\x80" >>> foo = unicode(testString, "latin-1") >>> foo u'\x80' I would have thought that that should have raised an error, because \x80 is not a va

Re: utf - string translation

2006-11-29 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > 3. ... and to check for missing maps. The OP may be working only with > > French text, and may not care about Icelandic and German letters, but > > other readers who stumble on this (and miss past thread(s) on this > > topic) may like something done

Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
Just wanted to report a delightful little surprise while experimenting with psyco. The program below performs astonoshingly well with psyco. It finds all the prime numbers < 10,000,000 Processor is AMD64 4000+ running 32 bit. Non psyco'd python version takes 94 seconds. psyco'd version takes 9.

Re: utf - string translation

2006-11-29 Thread Fredrik Lundh
John Machin wrote: > Another point: there are many non-latin1 characters that could be > mapped to ASCII. For example: > u"\u0141ukasziewicz".translate(unaccented_map()) > doesn't work unless an entry is added to the no-decomposition table: > 0x0141: u"L", # LATIN CAPITAL LETTER L WITH STR

Re: SPE refuses.

2006-11-29 Thread egbert
On Wed, Nov 29, 2006 at 11:31:27AM -0800, SPE - Stani's Python Editor wrote: > If wxPython is rightly installed, which means that "import wx" works > fine and "wx.VERSION" gives the right version, you can ignore the > wxPython warning. > In a Python shell the commands 'import wx' and 'wx.VERSION'

Re: ensuring valid latin-1

2006-11-29 Thread John Machin
Chris Curvey wrote: > Hey all, > > I'm trying to write something that will "fail fast" if one of my users > gives me non-latin-1 characters. So I tried this: > > >>> testString = "\x80" > >>> foo = unicode(testString, "latin-1") > >>> foo > u'\x80' > > I would have thought that that should have ra

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
> #!/usr/bin/python -OO > import math > import sys > import psyco > > psyco.full() > > def primes(): > primes=[3] > for x in xrange(5,1000,2): > maxfact = int(math.sqrt(x)) > flag=True > for y in primes: > if y > maxfact: > break >

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
Steve Bergman wrote: > Just wanted to report a delightful little surprise while experimenting > with psyco. > The program below performs astonoshingly well with psyco. > > It finds all the prime numbers < 10,000,000 Actualy, it doesn't. You forgot 1 and 2. Will McGugan -- blog: http://www.will

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Beliavsky
Will McGugan wrote: > Steve Bergman wrote: > > Just wanted to report a delightful little surprise while experimenting > > with psyco. > > The program below performs astonoshingly well with psyco. > > > > It finds all the prime numbers < 10,000,000 > > Actualy, it doesn't. You forgot 1 and 2. The n

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
Beliavsky wrote: > > The number 1 is not generally considered to be a prime number -- see > http://mathworld.wolfram.com/PrimeNumber.html . > I stand corrected. -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread Stephen Eilert
Lou Pecora escreveu: > In article <[EMAIL PROTECTED]>, > "Scott_Davies" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I have an old Mac with OS X Panther installed. I also have the Python > > language download file, but I haven't got a text/script editor to use > > for it. Does anyone have a re

Re: Detecting recursion loops

2006-11-29 Thread Ben Finney
robert <[EMAIL PROTECTED]> writes: > Carl Banks wrote: > > 2. Consider whether you're unwittingly trying to cover up a bug. > > ISTM no matter how problematic the input is, you should at least > > be able to make progress on it. Are you getting this error > > because, say, you're not incrementing

Re: Good script editor for Python on Mac OS 10.3

2006-11-29 Thread SPE - Stani's Python Editor
Install wxPython and than you can use SPE, a free Python IDE with UML, GUI builders, ... Stani Scott_Davies wrote: > Hi, > > I have an old Mac with OS X Panther installed. I also have the Python > language download file, but I haven't got a text/script editor to use > for it. Does anyone have a

Re: utf - string translation

2006-11-29 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > Another point: there are many non-latin1 characters that could be > > mapped to ASCII. For example: > > u"\u0141ukasziewicz".translate(unaccented_map()) > > doesn't work unless an entry is added to the no-decomposition table: > > 0x0141: u"L"

Re: SPE refuses.

2006-11-29 Thread SPE - Stani's Python Editor
Do you have python-wxversion installed? $sudo apt-get install python-wxversion Stani On 29 nov, 23:21, egbert <[EMAIL PROTECTED]> wrote: > On Wed, Nov 29, 2006 at 11:31:27AM -0800, SPE - Stani's Python Editor wrote:> > If wxPython is rightly installed, which means that "import wx" works > > fin

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread dickinsm
> BTW, can this code be made any more efficient? I'm not sure, but the following code takes around 6 seconds on my 1.2Ghz iBook. How does it run on your machine? def smallPrimes(n): """Given an integer n, compute a list of the primes < n""" if n <= 2: return [] sieve = range

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
Will McGugan wrote: > Some trivial optimizations. Give this a whirl. I retimed and got 9.7 average for 3 runs on my version. Yours got it down to 9.2. 5% improvement. Not bad. (Inserting '2' at the beginning doesn't seem to impact performance much.;-) ) BTW, strictly speaking, shouldn't I b

Re: About alternatives to Matlab

2006-11-29 Thread aap
John Henry wrote: > Bill Gates will have you jailed! :-) > > On a more serious note, is there any alternative to Simulink though? > It's called SciCos, and as far as I've seen it not only covers Simulink but also PowerSim. I found only 1 major disadvantage inSciLab, ... ... it has no ActiveX che

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steve Bergman
[EMAIL PROTECTED] wrote: > > BTW, can this code be made any more efficient? > > I'm not sure, but the following code takes around 6 seconds on my > 1.2Ghz iBook. How does it run on your machine? > > Hmm. Come to think of it, my algorithm isn't the sieve. Anyway, this is indeed fast as long as y

for i in range() anti-pattern [was Re: trouble writing results to files]

2006-11-29 Thread Steven D'Aprano
On Wed, 29 Nov 2006 17:00:30 +0100, Fredrik Lundh wrote: > Neil Cerutti wrote: > >>> BTW, iterating over range(len(a)) is an anti-pattern in Python. >> >> Unless you're modifying elements of a, surely? > > and needs to run on a Python version that doesn't support enumerate. This isn't meant as

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread dickinsm
On Nov 29, 6:59 pm, "Steve Bergman" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > BTW, can this code be made any more efficient? > > > I'm not sure, but the following code takes around 6 seconds on my > > 1.2Ghz iBook. How does it run on your machine? > > Hmm. Come to think of it,

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Steven D'Aprano
On Wed, 29 Nov 2006 15:35:39 -0800, Steve Bergman wrote: > BTW, strictly speaking, shouldn't I be adding something to the floating > point sqrt result, before converting to int, to allow for rounding > error? If you don't mind doing no more than one unnecessary test per candidate, you can just

Re: How to detect what type a variable is?

2006-11-29 Thread Dustan
Eduardo "EdCrypt" O. Padoan wrote: > > > > One might prefer to check for string-ness, as strings can > > duck-type somewhat like lists: > > > > my_list = ['my', 'brain', 'hurts'] > > my_string = 'Are you the brain specialist?' > > > > for test in [my_list, my_string]: > > try: > > fo

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Gabriel Genellina
At Wednesday 29/11/2006 20:35, Steve Bergman wrote: BTW, strictly speaking, shouldn't I be adding something to the floating point sqrt result, before converting to int, to allow for rounding error? If it is supposed to be 367 but comes in at 366., don't I potentially classify a composit

[help] Is it true to call obj.__str__() while executing "print obj"?

2006-11-29 Thread Tommy Zong
Hi, I am learning metaclass by reading "Metaclass programming in Python, Part 2". I have a question as following and had tried to search from internet and also have read the article "Unifying types and classes in Python 2.2" but failed to get satisfied answer. Could you please give me any comme

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread George Sakkis
Will McGugan wrote: > > #!/usr/bin/python -OO > > import math > > import sys > > import psyco > > > > psyco.full() > > > > def primes(): > > primes=[3] > > for x in xrange(5,1000,2): > > maxfact = int(math.sqrt(x)) > > flag=True > > for y in primes: > >

PyLint syntax question

2006-11-29 Thread Brendon
Hi, This may seem like a stupid question, but I'd like to know anyway. How do I used pylint's --ignore option to prevent it from looking at some files? The documentation says you have to use a base name. What the heck is a base name? Are there any other ways to stop it looking at certain files

Joining data from three different files to be written into three Columns

2006-11-29 Thread Dawn Abbott
I have three files of binary data. I want to write the three binary data files to one file. I want the old files to each have their own column in the new file. This is what I have, f=open('relative_x.INT32','rb') a=array('l') a.fromfile(f,10) g=open('relative_y.INT32','rb') b=array('l') b.from

Re: [help] Is it true to call obj.__str__() while executing "print obj"?

2006-11-29 Thread Calvin Spealman
On 11/29/06, Tommy Zong <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > > > I am learning metaclass by reading "Metaclass programming in Python, Part > 2". I have a question as following and had tried to search from internet and > also have read the article "Unifying types and classes in Python 2.

Re: How to detect what type a variable is?

2006-11-29 Thread Calvin Spealman
On 29 Nov 2006 07:36:26 -0800, Leandro Ardissone <[EMAIL PROTECTED]> wrote: > Hi, > > I want to know what type is a variable. > For example, I get the contents of an xml but some content is a list or > a string, and I need to know what type it is. > > Thanks > > -- > http://mail.python.org/mailman/

Re: Joining data from three different files to be written into three Columns

2006-11-29 Thread Gabriel Genellina
At Wednesday 29/11/2006 23:07, Dawn Abbott wrote: I have three files of binary data. I want to write the three binary data files to one file. I want the old files to each have their own column in the new file. This is what I have, f=open('relative_x.INT32','rb') a=array('l') a.fromfile(f,1

PythonTidy

2006-11-29 Thread Chuck Rhode
I couldn't find a routine to clean up, regularize, and reformat Python code, so I wrote one: http://www.lacusveris.com/PythonTidy/PythonTidy.python Now, I'm looking for beta-testers. Compensation is a bit on the low side. In fact it's limited to the satisfaction of helping out. Thanks. -- .

a quickie: range - x

2006-11-29 Thread rjtucke
I want an iterable from 0 to N except for element m (<=M). I could write x = range(N) x.remove(m) but I want it in one expression. Thanks, Ross -- http://mail.python.org/mailman/listinfo/python-list

Re: a quickie: range - x

2006-11-29 Thread johnzenger
(x for x in xrange(N+1) if x != m) rjtucke wrote: > I want an iterable from 0 to N except for element m (<=M). > I could write > x = range(N) > x.remove(m) > but I want it in one expression. > > Thanks, > Ross -- http://mail.python.org/mailman/listinfo/python-list

Re: a quickie: range - x

2006-11-29 Thread Steven D'Aprano
On Wed, 29 Nov 2006 19:42:16 -0800, rjtucke wrote: > I want an iterable from 0 to N except for element m (<=M). > I could write > x = range(N) > x.remove(m) > but I want it in one expression. Because the world will end if you can't? What's wrong with the solution you already have? If you need to

Re: Joining data from three different files to be written into three Columns

2006-11-29 Thread Dawn Abbott
No, two of the binary data files are integers and the third file is a float. The data is large and the binary saves time and space. On 11/29/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: At Wednesday 29/11/2006 23:07, Dawn Abbott wrote: >I have three files of binary data. I want to write

Re: a quickie: range - x

2006-11-29 Thread Paul Rubin
"rjtucke" <[EMAIL PROTECTED]> writes: > I want an iterable from 0 to N except for element m (<=M). > I could write > x = range(N) > x.remove(m) > but I want it in one expression. itertools.chain(xrange(0,m), xrange(m+1, N)) -- http://mail.python.org/mailman/listinfo/python-list

Why are slice indices the way they are in python?

2006-11-29 Thread Steve Bergman
A couple of off the wall questions. It seems to me that there is usually a solid *reason* for things in Python and I'm wondering about the rationale for the way slicing works: my_string[2:5] gets you the 3rd through the 3rd through the 5th character of the string because indexing starts at 0 and

Re: odict the Ordered Diction 0.2.2

2006-11-29 Thread jim-on-linux
Thanks for the post, Its become a part time job keeping up with updates. jim-on-linux http://www.inqvista.com On Wednesday 29 November 2006 09:41, Fuzzyman wrote: > After a break of almost a year there has been > an update to `odict the Ordered Dictionary >

Re: a quickie: range - x

2006-11-29 Thread rjtucke
Thanks, all- that helped. Ross -- http://mail.python.org/mailman/listinfo/python-list

Re: About alternatives to Matlab

2006-11-29 Thread Bill Maxwell
On 16 Nov 2006 13:09:03 -0800, "sturlamolden" <[EMAIL PROTECTED]> wrote: ...SNIP... >To compare Matlab with NumPy we can e.g. use the D4 discrete wavelet >transform. I have here coded it in Matlab and Python/NumPy using Tim >Swelden's lifting scheme. > >First the Matlab version (D4_Transform.m):

Re: Why are slice indices the way they are in python?

2006-11-29 Thread Terry Reedy
"Steve Bergman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >A couple of off the wall questions. > > It seems to me that there is usually a solid *reason* for things in > Python and I'm wondering about the rationale for the way slicing works Yes, see below. > my_string[2:5] > >

Python Question About Compiling.

2006-11-29 Thread Scheol Service
-- Forwarded message -- From: Scheol Service <[EMAIL PROTECTED]> Date: Nov 29, 2006 10:57 PM Subject: Python Question About Compiling. To: mailto:python-list@python.org Im just unsure on how to compile python code into .exe executionable files. Is there a simple way to do this? -

XML blooming

2006-11-29 Thread Paddy
(That is bloom as in http://www.wmhelp.com/xmlpad2.htm ;-) Suddenly, OK, over a number of months, our design environment at work has sprouted a wealth of XML configuration files, DTD's etc. The time has come when I need to loose my XML cherry. So , I guess I need to learn Elementtree. In supporti

Re: Python Question About Compiling.

2006-11-29 Thread Gabriel Genellina
At Thursday 30/11/2006 02:02, Scheol Service wrote: Im just unsure on how to compile python code into .exe executionable files. Is there a simple way to do this? py2exe -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio para todos tu

Re: Python Question About Compiling.

2006-11-29 Thread Fredrik Lundh
Scheol Service wrote: > Im just unsure on how to compile python code into .exe executionable > files. Is there a simple way to do this? typing "compile python code" into google gives you http://effbot.org/zone/python-compile.htm which gives you some background, and links to a bunch of bun

Re: Python Question About Compiling.

2006-11-29 Thread Gabriel G
At Thursday 30/11/2006 03:40, Scheol Service wrote: i know this. Is there better directions on how to use it? Have you tried it? What's your actual problem? See http://www.py2exe.org/ -- Gabriel Genellina Softlab SRL __ Correo Yahoo! Espacio

<    1   2