Python-URL! - weekly Python news and links (Oct 17)

2007-10-17 Thread Gabriel Genellina
QOTW: Aaaugh! Don't use __slots__! - Aahz I will use public attributes (with access customizable with properties) and remember that in Python I can do everything :). - Artur Siekielski Don't use __slots__ to create struct-like objects:

ANNOUNCE: pygtkmvc-1.2.1 has been released

2007-10-17 Thread Roberto Cavada
Version 1.2.1 of pygtkmvc has been released. Project homepage: http://pygtkmvc.sourceforge.net Download: http://sourceforge.net/projects/pygtkmvc/ == About pygtkmvc == pygtkmvc is a fully Python-based implementation of the Model-View-Controller (MVC) and Observer

Matlab axis control problem - solved

2007-10-17 Thread Dick Crepeau
I don't understand my earlier problem but the following code works no matter what the ylim is set to: I reworked the example major_minor_demo1.py to find the answer. thanks Dick C ps: I still can't post a reply since I read the list with my mozilla or konqueror browser and email separately

Re: best way of dealing with currency?

2007-10-17 Thread Paddy
On Oct 16, 8:29 pm, Paul Miller [EMAIL PROTECTED] wrote: I'm looking at doing some currency calculations in some Python code integrated with a C++ application. I want to be able to come up with the same values I get in an Excel spreadsheet. Ouch! do really want to come up with the Excel

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-17 Thread Paddy
ot mode='private joke' story stargaming, I caught it first this time !-) intrusion pedant=TrueShouldn't that be s-o-r-r-y :-)/intrusion *ot -- http://mail.python.org/mailman/listinfo/python-list

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

2007-10-17 Thread Robert Kern
Grant Edwards wrote: On 2007-10-16, Robert Kern [EMAIL PROTECTED] wrote: It's not universal. Many people consider it harmful. Google reply-to considered harmful for a variety of opinions, for and against. I use GMane to read and post to this list because I like my lists to act like

Re: Last iteration?

2007-10-17 Thread Raymond Hettinger
[Diez B. Roggisch] out:) But I wanted a general purpose based solution to be available that doesn't count on len() working on an arbitrary iterable. [Peter Otten] You show signs of a severe case of morbus itertools. I, too, am affected and have not yet fully recovered... Maybe you guys

Re: Last iteration?

2007-10-17 Thread Raymond Hettinger
def lastdetecter(iterable): fast iterator algebra lookahead, t = tee(iterable) lookahead.next() t = iter(t) return chain(izip(repeat(False), imap(itemgetter(1), izip(lookahead, t))), izip(repeat(True),t)) More straight-forward version: def

Re: how to get my own namespace ?

2007-10-17 Thread Peter Otten
stef mientki wrote: I want to view my own namespace, i.e. to see the modules namespace in the module itself, is that possible ? I can use dir() but I read dir is just a convenience function, and besides I want key/value pairs. Use globals() or vars(). Peter --

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 10, 8:23 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: However, it is not true that += always leads to a rebinding of a to the result of the operation +. The + operator for lists creates a new list. += for lists does an in-place modification: It still is true. a += b rebinds a.

Re: Simple HTML template engine?

2007-10-17 Thread Adrian Cherry
Bruno Desthuilliers [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Did you read the OP's question ?-) Yup, as much as anyone else has. Why? Adrian -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 00:33:59 -0700, paul.melis wrote: On Oct 10, 8:23 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: However, it is not true that += always leads to a rebinding of a to the result of the operation +. The + operator for lists creates a new list. += for lists does an in-place

Re: Static variable vs Class variable

2007-10-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: On Oct 10, 8:23 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: snip rebinds a. Period. Which is the _essential_ thing in my post, because this rebinding semantics are what confused the OP. Doesn't this depend on wether a supports __iadd__ or not? Section 3.4.7 of

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 17, 10:00 am, Duncan Booth [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Oct 10, 8:23 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: snip rebinds a. Period. Which is the _essential_ thing in my post, because this rebinding semantics are what confused the OP. Doesn't this

Re: Last iteration?

2007-10-17 Thread Peter Otten
Raymond Hettinger wrote: [Diez B. Roggisch] out:) But I wanted a general purpose based solution to be available that doesn't count on len() working on an arbitrary iterable. [Peter Otten] You show signs of a severe case of morbus itertools. I, too, am affected and have not yet fully

Re: Capturing OutputDebugString information in python

2007-10-17 Thread Tim Golden
danbrotherston wrote: I am trying to get the output from the win32 platform command OutputDebugString. I have used the following C++ code as a guideline:

Re: Static variable vs Class variable

2007-10-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: Curious, do you have the relevant section in the docs that describes this behaviour? Yes, but mostly by implication. In section 3.4.7 of the docs, the sentence before the one you quoted says: These methods should attempt to do the operation in-place (modifying

Re: Static variable vs Class variable

2007-10-17 Thread paul . melis
On Oct 17, 11:08 am, Duncan Booth [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Curious, do you have the relevant section in the docs that describes this behaviour? Yes, but mostly by implication. In section 3.4.7 of the docs, the sentence before the one you quoted says: These

Re: Static variable vs Class variable

2007-10-17 Thread Hrvoje Niksic
[EMAIL PROTECTED] writes: Right, the paragraph is actually pretty clear after a second reading. I find it surprising nonetheless, as it's easy to forget to return a result when you're implementing a method that does an in-place operation, like __iadd__: I've recently been bitten by that,

Re: Python's coming... from unexpected angles.

2007-10-17 Thread Eric Brunel
On Tue, 16 Oct 2007 13:19:26 +0200, Ben Finney [EMAIL PROTECTED] wrote: Eric Brunel [EMAIL PROTECTED] writes: Well, I'd definetely vote for a name change for PyPy, as in french, it's pronounced pee-pee, and yes, it means what you think it means... ;-) Does that mean you pronounce the

UK Jobs With VISA Sponsorship

2007-10-17 Thread Devender.Kumar
Hi, Can u let me please about UK work Permit and Job..right now am in Norway and holding Schengen Visa Bye Devender Kumar 0047 96813328 This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely

Re: negative base raised to fractional exponent

2007-10-17 Thread Steve Holden
John Machin wrote: On Oct 17, 8:03 am, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Does anyone know of an approximation to raising a negative base to a fractional exponent? For example, (-3)^-4.1 since this cannot be computed without using imaginary numbers. Any help is

Re: Last iteration?

2007-10-17 Thread Paul Hankin
On Oct 17, 8:16 am, Raymond Hettinger [EMAIL PROTECTED] wrote: def lastdetecter(iterable): fast iterator algebra lookahead, t = tee(iterable) lookahead.next() t = iter(t) return chain(izip(repeat(False), imap(itemgetter(1), izip(lookahead,

Re: NUCULAR fielded text searchable indexing

2007-10-17 Thread Steve Holden
[EMAIL PROTECTED] wrote: On Oct 8, 7:00 pm, Delaney, Timothy (Tim) [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: ANNOUNCE: NUCULAR fielded text searchable indexing Does NUCULAR stand for anything? The (apparent) misspelling of nuclear has already turned me off wanting to find out more

Inheriting automatic attributes initializer considered harmful?

2007-10-17 Thread Thomas Wittek
Hi! I'm relatively new to Python, so maybe there is an obvious answer to my question, that I just didn't find, yet. I've got quite some classes (from a data model mapped with SQL-Alchemy) that can be instatiated using kwargs for the attribute values. Example: class User(object): def

Re: Static variable vs Class variable

2007-10-17 Thread Duncan Booth
Hrvoje Niksic [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: Right, the paragraph is actually pretty clear after a second reading. I find it surprising nonetheless, as it's easy to forget to return a result when you're implementing a method that does an in-place operation, like

Re: Static variable vs Class variable

2007-10-17 Thread Hrvoje Niksic
Duncan Booth [EMAIL PROTECTED] writes: Hrvoje Niksic [EMAIL PROTECTED] wrote: I've recently been bitten by [rebinding the var to what __iadd__ returns], and I don't understand the reasoning behind __iadd__'s design. I mean, what is the point of an *in-place* add operation (and others) if

Re: negative base raised to fractional exponent

2007-10-17 Thread schaefer . mp
On Oct 17, 4:05 am, Ken Schutte [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Does anyone know of an approximation to raising a negative base to a fractional exponent? For example, (-3)^-4.1 since this cannot be computed without using imaginary numbers. Any help is appreciated. As

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-17 Thread Bruno Desthuilliers
Paddy a écrit : ot mode='private joke' story stargaming, I caught it first this time !-) intrusion pedant=TrueShouldn't that be s-o-r-r-y :-)/intrusion crying Oui :( /crying *ot -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 13:41:06 +0200, Hrvoje Niksic wrote: Duncan Booth [EMAIL PROTECTED] writes: Hrvoje Niksic [EMAIL PROTECTED] wrote: I've recently been bitten by [rebinding the var to what __iadd__ returns], and I don't understand the reasoning behind __iadd__'s design. I mean, what is

Displaying future times

2007-10-17 Thread ryan k
I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module http://www.purecode.com/~tsatter/python/README.txt (at that URL) with a function that takes seconds from the epoch and a time zone and returns what is basically a datetime object.

Displaying future times

2007-10-17 Thread ryan k
I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module http://www.purecode.com/~tsatter/python/README.txt (at that URL) with a function that takes seconds from the epoch and a time zone and returns what is basically a datetime object.

Re: Static variable vs Class variable

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 13:41:06 +0200, Hrvoje Niksic wrote: The current implementation of += uses __add__ for addition and __iadd__ for addition that may or may not be in-place. I'd like to know the rationale for that design. Everything you need is in the PEP:

Re: Static variable vs Class variable

2007-10-17 Thread Duncan Booth
Hrvoje Niksic [EMAIL PROTECTED] wrote: The current implementation of += uses __add__ for addition and __iadd__ for addition that may or may not be in-place. I'd like to know the rationale for that design. Apart from the obvious short answer of being consistent (so you don't have to

Re: Automatically organize module imports

2007-10-17 Thread Andrew Durdin
On 10/15/07, Jean-Paul Calderone [EMAIL PROTECTED] wrote: Pyflakes will tell you which imports aren't being used (among other things). I don't know if an existing tool which will automatically rewrite your source, though. I'll second that recommendation of Pyflakes -- as the interpreter only

Re: Static variable vs Class variable

2007-10-17 Thread Duncan Booth
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Simply not to introduce special cases I guess. If you write ``x.a += b`` then `x.a` will be rebound whether an `a.__iadd__()` exists or not. Otherwise one would get interesting subtle differences with properties for example. If `x.a` is a

Best Python Linux distribution

2007-10-17 Thread Anthony Perkins
Hi everyone, What is the best GNU/Linux distribution (or the most preferred) for developing Python applications? Ideally I would like one with both Python *and* IDLE included on the install media (neither Ubuntu nor SUSE have IDLE on the CDs), so that I can use it on machines without a

Re: Dynamic and lazy import

2007-10-17 Thread Alexandre Badez
Thanks for all your advices, but it's not really what I would like to do. I'm going to be more clearer for what I really want to do. Here we have got many library for different applications. All those library have a version and between a version and an other, there isn't always a very good

Re: Displaying future times

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 12:20:06 +, ryan k wrote: I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module http://www.purecode.com/~tsatter/python/README.txt (at that URL) with a function that takes seconds from the epoch and a time

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 2:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Simply not to introduce special cases I guess. If you write ``x.a += b`` then `x.a` will be rebound whether an `a.__iadd__()` exists or not. Otherwise one would get interesting

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-17 Thread Andrew Durdin
On 10/17/07, Thomas Wittek [EMAIL PROTECTED] wrote: Writing such constructors for all classes is very tedious. So I subclass them from this base class to avoid writing these constructors: class AutoInitAttributes(object): def __init__(self, **kwargs): for k, v in

Re: Python's coming... from unexpected angles.

2007-10-17 Thread Ben Finney
Eric Brunel [EMAIL PROTECTED] writes: On Tue, 16 Oct 2007 13:19:26 +0200, Ben Finney [EMAIL PROTECTED] wrote: Does that mean you pronounce the word for the serpent as pee-thon? Yes. Anyway, the pronunciation of Python (and hence the Py in PyPy) is however you pronounce that word in

Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread schaefer . mp
To compute the absolute value of a negative base raised to a fractional exponent such as: z = (-3)^4.5 you can compute the real and imaginary parts and then convert to the polar form to get the correct value: real_part = ( 3^-4.5 ) * cos( -4.5 * pi ) imag_part = ( 3^-4.5 ) * sin( -4.5 * pi )

Re: Displaying future times

2007-10-17 Thread ryan k
On Oct 17, 1:52 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 17 Oct 2007 12:20:06 +, ryan k wrote: I have a schedule of times in the future that I want to display in a timezone the user sets. There is a useful module

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-17 Thread Thomas Wittek
Andrew Durdin: Is there already a standard lib class doing (something like) this? Or is it even harmful to do this? It depends on your kwargs and where they're coming from. They should come from my own code. Does SQLAlchemy let you get a list of column names? Generellay, it does. But it

Re: Best Python Linux distribution

2007-10-17 Thread Rafał Zawadzki
Anthony Perkins wrote: Hi everyone, What is the best GNU/Linux distribution (or the most preferred) for developing Python applications? Ideally I would like one with both Python *and* IDLE included on the install media (neither Ubuntu nor SUSE have IDLE on the CDs), so that I can use it

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 3:20 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 17 Oct 2007 05:57:50 -0700, Paul Melis wrote: On Oct 17, 2:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: class C(object): def setx(self, value): if len(value)2:

Re: Static variable vs Class variable

2007-10-17 Thread Paul Melis
On Oct 17, 3:41 pm, Paul Melis [EMAIL PROTECTED] wrote: On Oct 17, 3:20 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 17 Oct 2007 05:57:50 -0700, Paul Melis wrote: On Oct 17, 2:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: class C(object): def setx(self,

Order by value in dictionary

2007-10-17 Thread Abandoned
Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element.. Result must be: [b, a, d, c .] ( first 100 element) I done this using FOR and ITERATOR but it tooks 1 second and this

Write by logging.FileHandler to one file by many processess

2007-10-17 Thread Rafał Zawadzki
Hello. As I saw in logging source - there is no lock per file during making emit() (only lock per thread). So, my question is - is it safe to log into one file using many processess uses logging logger? Cheers, -- bluszcz http://vegan-planet.net --

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 05:57:50 -0700, Paul Melis wrote: On Oct 17, 2:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: class C(object): def setx(self, value): if len(value)2: raise ValueError self._x = value def getx(self):

Re: Best Python Linux distribution

2007-10-17 Thread Joe Riopel
On 10/17/07, Anthony Perkins [EMAIL PROTECTED] wrote: Hi everyone, What is the best GNU/Linux distribution (or the most preferred) for developing Python applications? Ideally I would like one with both Python *and* IDLE included on the install media (neither Ubuntu nor SUSE have IDLE on the

Re: Dynamic and lazy import

2007-10-17 Thread Diez B. Roggisch
Alexandre Badez wrote: Thanks for all your advices, but it's not really what I would like to do. I'm going to be more clearer for what I really want to do. Here we have got many library for different applications. All those library have a version and between a version and an other, there

Re: Order by value in dictionary

2007-10-17 Thread Diez B. Roggisch
Abandoned wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element.. Result must be: [b, a, d, c .] ( first 100 element) I done this using FOR and ITERATOR but

Re: Static variable vs Class variable

2007-10-17 Thread Hrvoje Niksic
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: Simply not to introduce special cases I guess. If you write ``x.a += b`` then `x.a` will be rebound whether an `a.__iadd__()` exists or not. Otherwise one would get interesting subtle differences with properties for example. If `x.a` is a

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Paul Rubin
[EMAIL PROTECTED] writes: Just to clarify what I'm after: If you plot (-3)^n where n is a set of negative real numbers between 0 I still can't figure out for certain what you're asking, but you might look at the article http://en.wikipedia.org/wiki/De_Moivre%27s_formula --

Re: Order by value in dictionary

2007-10-17 Thread cokofreedom
On Oct 17, 3:39 pm, Abandoned [EMAIL PROTECTED] wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element.. Result must be: [b, a, d, c .] ( first 100 element) I

Re: Write by logging.FileHandler to one file by many processess

2007-10-17 Thread Alexandre Badez
On Oct 17, 3:33 pm, Rafa Zawadzki [EMAIL PROTECTED] wrote: Hello. As I saw in logging source - there is no lock per file during making emit() (only lock per thread). So, my question is - is it safe to log into one file using many processess uses logging logger? Cheers, --

Re: Best Python Linux distribution

2007-10-17 Thread Joe Riopel
On 10/17/07, Joe Riopel [EMAIL PROTECTED] wrote: IDLE and Python came installed on Slackware 12, I am not 100% sure about previous versions. Also, I am sure a lot of it (with most distributions) depends on the packages you select during the installation. --

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread schaefer . mp
Just to clarify what I'm after: If you plot (-3)^n where n is a set of negative real numbers between 0 and -20 for example, then you get a discontinuos line due to the problem mentioned above with fractional exponents. However, you can compute what the correct absolute value of the the missing

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Roy Smith
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Just to clarify what I'm after: If you plot (-3)^n where n is a set of negative real numbers between 0 and -20 for example, then you get a discontinuos line due to the problem mentioned above with fractional exponents. However, you can

readline support on openSuSE

2007-10-17 Thread Milos Prudek
This question concerns compilation of Python from sources. Specifically Python 2.3.6. On Kubuntu 7.04, ./configure outputs these lines about readline: checking for rl_pre_input_hook in -lreadline... yes checking for rl_completion_matches in -lreadline... yes On openSuSE 10.3, ./configure

Re: Order by value in dictionary

2007-10-17 Thread Diez B. Roggisch
Diez B. Roggisch wrote: Abandoned wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element.. Result must be: [b, a, d, c .] ( first 100 element) I done this

Re: Write by logging.FileHandler to one file by many processess

2007-10-17 Thread Diez B. Roggisch
Alexandre Badez wrote: On Oct 17, 3:33 pm, Rafa Zawadzki [EMAIL PROTECTED] wrote: Hello. As I saw in logging source - there is no lock per file during making emit() (only lock per thread). So, my question is - is it safe to log into one file using many processess uses logging logger?

Re: Dynamic and lazy import

2007-10-17 Thread Alexandre Badez
On Oct 17, 3:56 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Alexandre Badez wrote: Thanks for all your advices, but it's not really what I would like to do. I'm going to be more clearer for what I really want to do. Here we have got many library for different applications. All those

Re: negative base raised to fractional exponent

2007-10-17 Thread Ken Schutte
[EMAIL PROTECTED] wrote: On Oct 17, 4:05 am, Ken Schutte [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Does anyone know of an approximation to raising a negative base to a fractional exponent? For example, (-3)^-4.1 since this cannot be computed without using imaginary numbers. Any

Re: Dynamic and lazy import

2007-10-17 Thread Diez B. Roggisch
Diez Well, I would like to be able to use setuptools, but the problem is that I can't. Cause the administrator do not want us to be able to add lib in python dir. So we have to create our own library directory... That doesn't matter, setuptools is capable of installing anywhere - you just

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread J. Robertson
[EMAIL PROTECTED] wrote: Just to clarify what I'm after: If you plot (-3)^n where n is a set of negative real numbers between 0 and -20 for example, then you get a discontinuos line due to the problem mentioned above with fractional exponents. .. It looks like you crash-landed in

Re: Order by value in dictionary

2007-10-17 Thread George Sakkis
On Oct 17, 10:06 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Diez B. Roggisch wrote: Abandoned wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element..

Re: Order by value in dictionary

2007-10-17 Thread Diez B. Roggisch
George Sakkis wrote: On Oct 17, 10:06 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Diez B. Roggisch wrote: Abandoned wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Gerard Flanagan
On Oct 17, 3:17 pm, [EMAIL PROTECTED] wrote: To compute the absolute value of a negative base raised to a fractional exponent such as: z = (-3)^4.5 you can compute the real and imaginary parts and then convert to the polar form to get the correct value: real_part = ( 3^-4.5 ) * cos( -4.5

Re: Order by value in dictionary

2007-10-17 Thread cokofreedom
On Oct 17, 4:06 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Diez B. Roggisch wrote: Abandoned wrote: Hi.. I have a dictionary like these: a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000 element I want to sort this by value and i want to first 100 element..

Re: Static variable vs Class variable

2007-10-17 Thread Hrvoje Niksic
Duncan Booth [EMAIL PROTECTED] writes: Hrvoje Niksic [EMAIL PROTECTED] wrote: The current implementation of += uses __add__ for addition and __iadd__ for addition that may or may not be in-place. I'd like to know the rationale for that design. Apart from the obvious short answer of

Stopping a fucntion from printing its output on screen

2007-10-17 Thread sophie_newbie
Hi, in my program i need to call a couple of functions that do some stuff but they always print their output on screen. But I don't want them to print anything on the screen. Is there any way I can disable it from doing this, like redirect the output to somewhere else? But later on in the program

Re: Stopping a fucntion from printing its output on screen

2007-10-17 Thread Jeremy Sanders
sophie_newbie wrote: Hi, in my program i need to call a couple of functions that do some stuff but they always print their output on screen. But I don't want them to print anything on the screen. Is there any way I can disable it from doing this, like redirect the output to somewhere else?

Re: Order by value in dictionary

2007-10-17 Thread Abandoned
Very very thanks everbody.. These are some method.. Now the fastest method is second.. 1 === def sortt(d): items=d.items() backitems=[ [v[1],v[0]] for v in items] backitems.sort() #boyut=len(backitems) #backitems=backitems[boyut-500:] a=[ backitems[i][1] for i in

Re: Inheriting automatic attributes initializer considered harmful?

2007-10-17 Thread Alex Martelli
Andrew Durdin [EMAIL PROTECTED] wrote: On 10/17/07, Thomas Wittek [EMAIL PROTECTED] wrote: Writing such constructors for all classes is very tedious. So I subclass them from this base class to avoid writing these constructors: class AutoInitAttributes(object): def

HTML Parser for Jython

2007-10-17 Thread Falcolas
Does anybody know of a decent HTML parser for Jython? I have to do some screen scraping, and would rather use a tested module instead of rolling my own. Thanks! GP -- http://mail.python.org/mailman/listinfo/python-list

Re: Order by value in dictionary

2007-10-17 Thread Marc 'BlackJack' Rintsch
On Wed, 17 Oct 2007 08:09:50 -0700, Abandoned wrote: Very very thanks everbody.. These are some method.. Now the fastest method is second.. Maybe because the second seems to be the only one that's not processing the whole dictionary but just 500 items less!? You are building way too much

Re: HTML Parser for Jython

2007-10-17 Thread Stefan Behnel
Falcolas wrote: Does anybody know of a decent HTML parser for Jython? I have to do some screen scraping, and would rather use a tested module instead of rolling my own. Not sure if it works, but have you tried BeautifulSoup? Or maybe an older version of it? Stefan --

linear programming in Python

2007-10-17 Thread jivelasquezt
Hi all, I'm new to this group so I don't know if this question has been posted before, but does anyone knows about linear/integer programming routines in Python that are available on the web, more specifically of the branch and bound method. Thanks, Jorge Velasquez PhD Student, Department of

pymssql - insert NULL to int

2007-10-17 Thread rc
How to insert NULL values in to int field using params. I'm trying to use pymssql.execute, passing the operation and list of params. One of the values in the params is a NULL value going to int field. The pymssql._quote() puts ' around the NULL which causes an exception to be thrown, is there a

Re: HTML Parser for Jython

2007-10-17 Thread Carsten Haese
On Wed, 2007-10-17 at 17:36 +0200, Stefan Behnel wrote: Falcolas wrote: Does anybody know of a decent HTML parser for Jython? I have to do some screen scraping, and would rather use a tested module instead of rolling my own. Not sure if it works, but have you tried BeautifulSoup? Or

Re: Order by value in dictionary

2007-10-17 Thread Peter Otten
Abandoned wrote: These are some method.. Now the fastest method is second.. Your four functions return three different results for the same input. First make sure it's correct, then make it faster (if necessary). Here are two candidates: def largest_sort(d, n): return sorted(d,

ANN: Pyrex 0.9.6.3

2007-10-17 Thread Greg Ewing
Pyrex 0.9.6.3 is now available: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Main features of this release: * The C API now uses just one name in the module namespace, instead of a name per C function. * The 'cdef' keyword and following extern/public/api qualifiers

Re: pymssql - insert NULL to int

2007-10-17 Thread Diez B. Roggisch
rc wrote: How to insert NULL values in to int field using params. I'm trying to use pymssql.execute, passing the operation and list of params. One of the values in the params is a NULL value going to int field. The pymssql._quote() puts ' around the NULL which causes an exception to be

Re: linear programming in Python

2007-10-17 Thread Wayne Brehaut
Hi Jorge, On Wed, 17 Oct 2007 08:44:28 -0700, [EMAIL PROTECTED] wrote: Hi all, I'm new to this group so I don't know if this question has been posted before, but does anyone knows about linear/integer programming routines in Python that are available on the web, more specifically of the branch

Re: Order by value in dictionary

2007-10-17 Thread Abandoned
I tried these: def largest_sort(d, n): return sorted(d, key=d.__getitem__, reverse=True)[:n] def largest_heap(d, n): return heapq.nlargest(n, d, d.__getitem__) def sortt(d): sorted_items = sorted((item[1], item[0]) for item in d.iteritems(), reverse=True)

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

2007-10-17 Thread Terry Reedy
Grant Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On 2007-10-16, Robert Kern [EMAIL PROTECTED] wrote: | | It's not universal. Many people consider it harmful. Google reply-to considered | harmful for a variety of opinions, for and against. | | I use GMane to read and

Re: linear programming in Python

2007-10-17 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Hi all, | | I'm new to this group so I don't know if this question has been posted | before, Searching this group for 'linear programming' at http://groups.google.com/group/comp.lang.python/topics?lnk=srg gives 30 hits. | but does

Re: Best Python Linux distribution

2007-10-17 Thread Rafael Sachetto
You could try this http://www.ibiblio.org/onebase/onebaselinux.com/About/features/developgo.php On 10/17/07, Joe Riopel [EMAIL PROTECTED] wrote: On 10/17/07, Joe Riopel [EMAIL PROTECTED] wrote: IDLE and Python came installed on Slackware 12, I am not 100% sure about previous versions.

Re: HTML Parser for Jython

2007-10-17 Thread Tim Chase
Does anybody know of a decent HTML parser for Jython? I have to do some screen scraping, and would rather use a tested module instead of rolling my own. GIYF[0][1] There are the batteries-included HTMLParser[2] and htmllib[3] modules, and the ever-popular (and more developer-friendly)

Need recommendations on mock object packages

2007-10-17 Thread Matthew Wilson
What are the most popular, easiest to use, and most powerful mock object packages out there? Thanks in advance. Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI and external JavaScript nightmare

2007-10-17 Thread IamIan
Thank you for the replies. After a lot of research I tracked down the issue. I was using the CGI to build all of the pages for the site, then filling in content with .innerHTML= as users clicked on tabs. Since I wanted to place the Google Ads in different parts of each page, the Google Ads

Re: HTML Parser for Jython

2007-10-17 Thread Falcolas
On Oct 17, 9:50 am, Carsten Haese [EMAIL PROTECTED] wrote: Recent releases of BeautifulSoup need Python 2.3+, so they won't work on current Jython, but BeatifulSoup 1.x will work. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI and external JavaScript nightmare

2007-10-17 Thread IamIan
Thank you for the replies. After a lot of research I tracked down the issue. I was using the CGI to build all of the pages for the site, then filling in content with .innerHTML= as users clicked on tabs. Since I wanted to place the Google Ads in different parts of each page, the Google Ads

Re: Can you determine the sign of the polar form of a complex number?

2007-10-17 Thread Matimus
On Oct 17, 6:51 am, [EMAIL PROTECTED] wrote: Just to clarify what I'm after: If you plot (-3)^n where n is a set of negative real numbers between 0 and -20 for example, then you get a discontinuos line due to the problem mentioned above with fractional exponents. However, you can compute

Re: Stopping a fucntion from printing its output on screen

2007-10-17 Thread Steven D'Aprano
On Wed, 17 Oct 2007 07:57:04 -0700, sophie_newbie wrote: Hi, in my program i need to call a couple of functions that do some stuff but they always print their output on screen. But I don't want them to print anything on the screen. Is there any way I can disable it from doing this, like

Re: readline support on openSuSE

2007-10-17 Thread gardsted
Milos Prudek wrote: This question concerns compilation of Python from sources. Specifically Python 2.3.6. On Kubuntu 7.04, ./configure outputs these lines about readline: checking for rl_pre_input_hook in -lreadline... yes checking for rl_completion_matches in -lreadline... yes On

Re: CGI and external JavaScript nightmare

2007-10-17 Thread IamIan
Thank you for the replies. After a lot of research I tracked down the issue. I was using the CGI to build all of the pages for the site, then filling in content with .innerHTML= as users clicked on tabs. Since I wanted to place the Google Ads in different parts of each page, the Google Ads

  1   2   3   >