Re: python question

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 18 Dec 2008 13:50:50 +0200

Ok, thanks.

Even though it requires a few more keywords, at least it doesn't require
quoting the keys of the dictionary.

I am searching for information about a good ORM in python, but what I found so far wasn't too impressive. Does anyone know a really good ORM in python like DBIx::Class or Rose::DB::Object in perl?

I found that for python there are more ORMS like: SQLObject, Axiom, Bazaar ORM, DbObj, Dejavu, forgetSQL, MiddleKit, Modeling Object-Relational Bridge, Object Relational Membrame, PyDo, SQLAlchemy, Storm... which of them do you think it is the best?

Thanks.

Octavian

----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Thursday, December 18, 2008 12:45 AM
Subject: Re: python question


Here is a Python 3 version.
Jamal

d = dict(John = 40, Michael = 40, Joe = 30)
l = sorted(d.keys(), reverse = True)
l = sorted(l, key = lambda k: d[k])
for k in l: print(k + ', ' + str(d[k]))


On Wed, 17 Dec 2008, Octavian
Rasnita wrote:

Date: Wed, 17 Dec 2008 22:52:20 +0200
From: Octavian Rasnita <orasnita@xxxxxxxxx>
Reply-To: programmingblind@xxxxxxxxxxxxx
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: python question

Thank you for your answer, but I couldn't run it with python 3.

I have re-formatted the print statement which in python 3 is a function,
but
I don't know how to solve the other error that appeared.

The code is:

hash = {'John': 40, 'Michael': 40, 'Joe': 30}
keys = sorted(hash.keys(), reverse = True)
keys = sorted(keys, lambda x, y: cmp(hash[x], hash[y]))
for key in keys: print(key + ', ' + str(hash[key]))

And the error is:

Traceback (most recent call last):
File "srt.py", line 3, in <module>
keys = sorted(keys, lambda x, y: cmp(hash[x], hash[y]))
TypeError: must use keyword argument for key function

Thanks.

Octavian

----- Original Message -----
From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, December 17, 2008 10:18 PM
Subject: RE: python question


> I'm not an advanced Python user, so there may be more efficient or
> elegant
> solutions.  The code below is a Python 2.5 equivalent.
>
> Jamal
>
> hash = {'John': 40, 'Michael': 40, 'Joe': 30}
> keys = sorted(hash.keys(), reverse = True)
> keys = sorted(keys, lambda x, y: cmp(hash[x], hash[y]))
> for key in keys: print key + ', ' + str(hash[key])
>
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Octavian
> Rasnita
> Sent: Wednesday, December 17, 2008 8:40 AM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: python question
>
> The Windows msi installer for python from python.org contains a chm
> help
> file for python 3, or at least this is how it is named.
>
> I haven't started to read it though.
>
> But I have a question regarding python.
>
> I have started to read the book "Perl to python migration" hoping to
> understand it better, but I am pretty confused of how python does the
> sorting, or at least about how it is explained in that book that might
> be
> old, because it talks about python 2.0.
>
> For example, if I have a perl hash, or python dictionary like:
>
> my %hash = (Joe => 30, John => 40, Michael => 40);
>
> and I want to sort it for example by the values of the hashin
> increasing
> order, then by the keys of the hash in decreasing order, in perl I
> would
> need to do just:
>
> foreach my $key(sort {$hash{$a} <=> $hash{$b} or $b cmp $a} keys %hash)
> {
> print "$key, $hash{$key}\n"; }
>
> This would print:
> Joe, 30
> Michael, 40
> John, 40
>
> Can you tell me how to do this in python? I hope there are newer ways
> of
> doing this more easier than what I read in that book.
>
> And I would also like to know which is the prefered ORM, the prefered
> templating systems, form manager(s), web framework... (although I think
> it
> is Zope), so if you have used them, please tell me.
>
> Octavian
>
> ----- Original Message -----
> From: <james.homme@xxxxxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Wednesday, December 17, 2008 2:29 PM
> Subject: RE: python question
>
>
>> Hi,
>> Along those lines, does anyone know if any of the Python documentation
> on
>> http://www.nonvisualdevelopment.org talks about 3.0?
>>
>> Thanks.
>>
>> Jim
>>
>> James D Homme, Usability Engineering, Highmark Inc.,
>> james.homme@xxxxxxxxxxxx, 412-544-1810
>>
>> "The difference between those who get what they wish for and those who
>> don't is action. Therefore, every action you take is a complete
>> success,regardless of the results." -- Jerrold Mundis
>> Highmark internal only: For usability and accessibility:
>> http://highwire.highmark.com/sites/iwov/hwt093/
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: