Re: [Tutor] reclassify values in an array

2011-09-01 Thread Sander Sweers
On Thu,  1 Sep 2011, 01:17:45 CEST, questions anon wrote: > Firstly just make them zeros and ones, for example if the values in the > array are less than 100 make them 0 and if greater than 100 make them 1. > And then finally sum them together. > I have attempted a few methods, see code below.

Re: [Tutor] reclassify values in an array

2011-09-01 Thread Peter Otten
questions anon wrote: > I have been going round in circles trying to solve something that sounds > simple. I have a huge array and I would like to reclassify the values. > Firstly just make them zeros and ones, for example if the values in the > array are less than 100 make them 0 and if greater t

[Tutor] SOLVED and thank you was: Re: meaning of % in: if n % x == 0:

2011-09-01 Thread Lisi
This was meant to go to the list. I did notrealise that it had not until I looked at the list just now and couln't see my reply. Sorry, "delegbede", and sorry list. On Wednesday 31 August 2011 Lisi wrote: > ?? If either n or x or both were 0, and % were the same thing as *, the > statement wo

[Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
The glossary defines "hashable" as: hashable An object is hashable if it has a hash value which never changes during its lifetime (it needs a __hash__() method), and can be compared to other objects (it needs an __eq__() method). Hashable objects which compare equal must have the same hash value.

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread James Reynolds
On Thu, Sep 1, 2011 at 10:32 AM, Richard D. Moores wrote: > The glossary defines "hashable" as: > > hashable > An object is hashable if it has a hash value which never changes > during its lifetime (it needs a __hash__() method), and can be > compared to other objects (it needs an __eq__() method)

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
Thanks, James, from your ideas I've come up with this function as a general test for hashibility of any object: def is_hashable(object): try: if hash(object): return True except TypeError: return False But is it? It returns True for ints, floats, sets, tuples,

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Hugo Arts
On Thu, Sep 1, 2011 at 5:28 PM, Richard D. Moores wrote: > Thanks, James, from your ideas I've come up with this function as a > general test for hashibility of any object: > > def is_hashable(object): >    try: >        if hash(object): >            return True >    except TypeError: >        ret

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread James Reynolds
On Thu, Sep 1, 2011 at 11:37 AM, Hugo Arts wrote: > On Thu, Sep 1, 2011 at 5:28 PM, Richard D. Moores > wrote: > > Thanks, James, from your ideas I've come up with this function as a > > general test for hashibility of any object: > > > > def is_hashable(object): > >try: > >if hash(o

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Chris Fuller
On Thursday 01 September 2011, Richard D. Moores wrote: > Thanks, James, from your ideas I've come up with this function as a > general test for hashibility of any object: > > def is_hashable(object): > try: > if hash(object): > return True > except TypeError: >

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Emile van Sebille
On 9/1/2011 11:30 AM Chris Fuller said... On Thursday 01 September 2011, Richard D. Moores wrote: Thanks, James, from your ideas I've come up with this function as a general test for hashibility of any object: def is_hashable(object): try: if hash(object): return True

Re: [Tutor] Quote of the Day version 1.0

2011-09-01 Thread Christopher King
I would use a tuple of dictionaries. import random quotes = ( {'author':"Kahlil Gibran", 'quote':"A candle loses nothing of its light when lighting another."), #My favorite {'author':"Henrik Ibsen", 'quote':"The strongest man in the world is he who stands most alone."}) quote = random.choic

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
def is_hashable(object): try: hash(object) return True except TypeError: return False it is then. Thanks to all! Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyth

Re: [Tutor] [Python-ideas] aliasing

2011-09-01 Thread Christopher King
> > > >>> list = [3,] > >>> a = list > >>> list[0] = 6 > >>> a[0] > 3 > - > Slight error in my code. It should be. >>> list = [3,] >>> a = list >>> list[0] = 6 >>> a[0] 6 -

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Chris Fuller
On Thursday 01 September 2011, Chris Fuller wrote: > On Thursday 01 September 2011, Richard D. Moores wrote: > > Thanks, James, from your ideas I've come up with this function as a > > general test for hashibility of any object: > > > > def is_hashable(object): > > try: > > if hash(obj

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
On Thu, Sep 1, 2011 at 12:29, Chris Fuller wrote: > *Ahem* > > def is_hashable(object): >   try: >        hash(object) >    except TypeError: >        return False > >    return True Why is that preferred to def is_hashable(object): try: hash(object) return True except

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Chris Fuller
On Thursday 01 September 2011, Richard D. Moores wrote: > On Thu, Sep 1, 2011 at 12:29, Chris Fuller > > wrote: > > *Ahem* > > > > def is_hashable(object): > > try: > >hash(object) > >except TypeError: > >return False > > > >return True > > Why is that preferred to >

[Tutor] openpyxl

2011-09-01 Thread Helen Brown
Will someone share with me  a link where I can download subject in order for my script to run? Any assistance will help! Thanks, ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinf

[Tutor] openpyxl

2011-09-01 Thread Helen Brown
Will someone share if there is a link where I can download to read a script with subject file? Thanks, ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
Ah. I'll follow you with that. Thanks, Dick On Thu, Sep 1, 2011 at 15:42, Chris Fuller wrote: > On Thursday 01 September 2011, Richard D. Moores wrote: >> On Thu, Sep 1, 2011 at 12:29, Chris Fuller >> >> wrote: >> > *Ahem* >> > >> > def is_hashable(object): >> >   try: >> >        hash(object)

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Steven D'Aprano
Richard D. Moores wrote: I'm trying to write a general test for hashability. How can I test if an object has both a __hash__() method and an __eq__() method? Just because an object has a __hash__ method doesn't mean it is guaranteed to be hashable. The method might (deliberately, or acciden

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Steven D'Aprano
Richard D. Moores wrote: Thanks, James, from your ideas I've come up with this function as a general test for hashibility of any object: def is_hashable(object): try: if hash(object): return True except TypeError: return False No need for the "if hash" test,

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Steven D'Aprano
On Fri, Sep 02, 2011 at 12:17:48PM +1000, Steven D'Aprano wrote: > Richard D. Moores wrote: > >Thanks, James, from your ideas I've come up with this function as a > >general test for hashibility of any object: > > > >def is_hashable(object): > >try: > >if hash(object): > >re

Re: [Tutor] openpyxl

2011-09-01 Thread Steven D'Aprano
On Thu, Sep 01, 2011 at 05:55:04PM -0700, Helen Brown wrote: > Will someone share with me  a link where I can download subject in order for > my script to run? Any assistance will help! Did you try googling for it? http://duckduckgo.com/?q=openpyxl http://www.bing.com/search?q=openpyxl http://au

[Tutor] use of logging module is shared by all?

2011-09-01 Thread James Hartley
I'm just needing to verify some behavior. Functionality within the logging module is exercised by calling functions defined within the module itself. I am using SQLAlchemy for database access, but it can be configured to dump out intermediate access information & queries to the logging module --

Re: [Tutor] Is there a test for hashability?

2011-09-01 Thread Richard D. Moores
On Thu, Sep 1, 2011 at 18:08, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> I'm trying to write a general test for hashability. How can I test if >> an object has both a  __hash__() method and an __eq__() method? > > > Just because an object has a __hash__ method doesn't mean it is guara

Re: [Tutor] use of logging module is shared by all?

2011-09-01 Thread Peter Otten
James Hartley wrote: > I'm just needing to verify some behavior. > > Functionality within the logging module is exercised by calling functions > defined within the module itself. I am using SQLAlchemy for database > access, but it can be configured to dump out intermediate access > information >

Re: [Tutor] use of logging module is shared by all?

2011-09-01 Thread James Hartley
Thanks, Peter for taking the time to respond. I need to study the reference further, & your comments pointed out some of my misconceptions. Thank you for clearing up some of my half-researched understanding. Jim On Thu, Sep 1, 2011 at 10:53 PM, Peter Otten <__pete...@web.de> wrote: > James Hart