From r1chardj0n3s at gmail.com Wed Apr 7 14:00:27 2010 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Wed, 7 Apr 2010 22:00:27 +1000 Subject: [melbourne-pug] PyCon Australia Call For Proposals Message-ID: Hi everyone, I'm happy to announce that on the 26th and 27th of June we are running PyCon Australia in Sydney! http://pycon-au.org/ We are looking for proposals for Talks on all aspects of Python programming from novice to advanced levels; applications and frameworks, or how you have been involved in introducing Python into your organisation. We welcome first-time speakers; we are a community conference and we are eager to hear about your experience. If you have friends or colleagues who have something valuable to contribute, twist their arms to tell us about it! Please also forward this Call for Proposals to anyone that you feel may be interested. To find out more go to the official Call for Proposals page here: http://pycon-au.org/2010/conference/proposals/ The deadline for proposal submission is the 29th of April. Proposal acceptance will be announced on the 12th of May. See you in Sydney in June! Richard Jones PyCon AU Program Chair From r1chardj0n3s at gmail.com Thu Apr 8 08:12:00 2010 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Thu, 8 Apr 2010 16:12:00 +1000 Subject: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar Message-ID: Meeting details, location and talks list are at: http://wiki.python.org/moin/MelbournePUG It looks like we've got a few cool talks lined up: 15 minute talks - Scientific computing with NumPy / SciPy / Matplotlib (Ed Schofield) 5 minute talks - filemov.py - a tool for relocating old files (Mike Dewhirst) - Load-balancing xmlrpclib/jsonrpclib for robust distributed applications (Andreux Fort) ... and by the looks of it there could be some interesting discussions. And I'm sure there'll be some talk about PyCon AU as well! Richard From yaniv at aknin.name Sun Apr 11 05:42:56 2010 From: yaniv at aknin.name (Yaniv Aknin) Date: Sun, 11 Apr 2010 13:42:56 +1000 Subject: [melbourne-pug] If only the outback had cubicles... In-Reply-To: References: Message-ID: Right, prepare for a weird request, but if there's anywhere to ask this it must be in Aussie... ?I'm a 30 year old programmer/hacker on a year long vacation with my newly wedded wife (currently in Byron Bay, but obviously we're on the move). We're both a bit tired from our vacation and are planning to 'settle down' and rent an apartment for a month or so in Melbourne, sometime in mid-May to mid-June. My wife will find herself a yoga joint to do her hippie stuff, and I just wanna hack (I have some personal Pythonic projects on my mind which I'd love to try my hand at, I'd be happy to explain if you cared). The reason I'm sending this is that all the hacking platforms I have with me is a trusty but small Netbook (heck, even at <2kg its weight is a significant portion of all my worldly possessions which aren't thousands of miles away). I've done some work on it during the trip and even built a rather cool, portable and light contraption to make it more desktop-ish (if you.cared: self.explain()), but as of late my dormant RSI reared its ugly head and I long for a chair, a desk, a keyboard and a screen (no need for a CPU/Internet, I rather use my Netbook anyway and have mobile 3G "broadband" from Telstra). Which leads us to you guys. If you (or someone you know) might be interested in hosting a guest roaming hacker for some kind of an office space near Melbourne on whatever is your usual hacking hours for any period of time for more than a week (and definitely less than a month, I have a flight to India to catch...), well, uh, now is your chance. There's little I can offer in return, other than my good company (a religious experience, really), a beer of your choosing and willingness to do any reasonable amount of Python/Unix assistance/advice/lecturing you may need. I can say that back home people paid good money for my consultancy hours, but trust me, they're all idiots, I'm clueless! :) I reckon this could probably fit someone who has their own small company and has a free seat or a staff member at some University who could convince whomever to give me lab access (even if you have a spare seat at home, I reckon working in someone's home might be a bit awkward, no?). If you find the idea even remotely agreeable, drop me a line and we can iron out the details. Even if you don't find the idea agreeable (or don't have a free desk), at least admit it was a weird one indeed. Cheers! ?- Yaniv (I'm teolicy on IRC, if you happen to know me from #python/#twisted/#ubuntu, I'm not very active, but what the heck) /* cross posted to luv-main, mlug */ From rasjidw at openminddev.net Mon Apr 12 09:54:04 2010 From: rasjidw at openminddev.net (Rasjid Wilcox) Date: Mon, 12 Apr 2010 17:54:04 +1000 Subject: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar In-Reply-To: References: Message-ID: <4BC2D19C.1020907@openminddev.net> Hi all, Was hoping to come tonight, but unfortunately not feeling well. Was really hoping to see Andreux's talk on jsonrpc, since I've been working on some jsonrpc stuff myself (up at http://www.openminddev.net/projects/projects/show/python-rpcbd). Anyway, have a good meeting. Cheers, Rasjid. Richard Jones wrote: > Meeting details, location and talks list are at: > > http://wiki.python.org/moin/MelbournePUG > > It looks like we've got a few cool talks lined up: > > 15 minute talks > - Scientific computing with NumPy / SciPy / Matplotlib (Ed Schofield) > > 5 minute talks > - filemov.py - a tool for relocating old files (Mike Dewhirst) > - Load-balancing xmlrpclib/jsonrpclib for robust distributed > applications (Andreux Fort) > > ... and by the looks of it there could be some interesting discussions. > > And I'm sure there'll be some talk about PyCon AU as well! > > > Richard > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > From pwdyson at yahoo.com Mon Apr 12 14:26:12 2010 From: pwdyson at yahoo.com (Paul) Date: Mon, 12 Apr 2010 05:26:12 -0700 (PDT) Subject: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar In-Reply-To: <4BC2D19C.1020907@openminddev.net> Message-ID: <504569.43564.qm@web53605.mail.re2.yahoo.com> Hi Rasjid, You're in luck. Andreux didn't make it, so you didn't miss the talk. Maybe he'll give it next time. Cheers, Paul --- On Mon, 4/12/10, Rasjid Wilcox wrote: From: Rasjid Wilcox Subject: Re: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar To: "Melbourne Python Users Group" Date: Monday, April 12, 2010, 5:54 PM Hi all, Was hoping to come tonight, but unfortunately not feeling well.? Was really hoping to see Andreux's talk on jsonrpc, since I've been working on some jsonrpc stuff myself (up at http://www.openminddev.net/projects/projects/show/python-rpcbd). Anyway, have a good meeting. Cheers, Rasjid. Richard Jones wrote: > Meeting details, location and talks list are at: > > http://wiki.python.org/moin/MelbournePUG > > It looks like we've got a few cool talks lined up: > > 15 minute talks > - Scientific computing with NumPy / SciPy / Matplotlib (Ed Schofield) > > 5 minute talks > - filemov.py - a tool for relocating old files (Mike Dewhirst) > - Load-balancing xmlrpclib/jsonrpclib for robust distributed > applications (Andreux Fort) > > ... and by the looks of it there could be some interesting discussions. > > And I'm sure there'll be some talk about PyCon AU as well! > > >? ? Richard > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug >??? _______________________________________________ melbourne-pug mailing list melbourne-pug at python.org http://mail.python.org/mailman/listinfo/melbourne-pug -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.fort at gmail.com Mon Apr 12 14:52:43 2010 From: andrew.fort at gmail.com (Andreux Fort) Date: Mon, 12 Apr 2010 22:52:43 +1000 Subject: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar In-Reply-To: <504569.43564.qm@web53605.mail.re2.yahoo.com> References: <4BC2D19C.1020907@openminddev.net> <504569.43564.qm@web53605.mail.re2.yahoo.com> Message-ID: On Mon, Apr 12, 2010 at 10:26 PM, Paul wrote: > > Hi Rasjid, > > You're in luck. Andreux didn't make it, so you didn't miss the talk. Maybe > he'll give it next time. > > Cheers, > Paul > > > --- On *Mon, 4/12/10, Rasjid Wilcox * wrote: > > > From: Rasjid Wilcox > Subject: Re: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ > Horse Bazaar > To: "Melbourne Python Users Group" > Date: Monday, April 12, 2010, 5:54 PM > > > Hi all, > > Was hoping to come tonight, but unfortunately not feeling well. Was > really hoping to see Andreux's talk on jsonrpc, since I've been working > on some jsonrpc stuff myself (up at > http://www.openminddev.net/projects/projects/show/python-rpcbd). > > Anyway, have a good meeting. > > Cheers, > > Rasjid. > > > Richard Jones wrote: > > Meeting details, location and talks list are at: > > > > http://wiki.python.org/moin/MelbournePUG > > > > It looks like we've got a few cool talks lined up: > > > > 15 minute talks > > - Scientific computing with NumPy / SciPy / Matplotlib (Ed Schofield) > > > > 5 minute talks > > - filemov.py - a tool for relocating old files (Mike Dewhirst) > > - Load-balancing xmlrpclib/jsonrpclib for robust distributed > > applications (Andreux Fort) > > > > ... and by the looks of it there could be some interesting discussions. > > > > And I'm sure there'll be some talk about PyCon AU as well! > > > > > > Richard > > For some reason I entered, then confirmed the PUG in my calendar as being on Tuesday. My apologies, I'll give the talk next meeting. -a -------------- next part -------------- An HTML attachment was scrubbed... URL: From r1chardj0n3s at gmail.com Tue Apr 13 02:35:53 2010 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Tue, 13 Apr 2010 10:35:53 +1000 Subject: [melbourne-pug] Next meeting 6:30pm Monday 12th of April @ Horse Bazaar In-Reply-To: References: <4BC2D19C.1020907@openminddev.net> <504569.43564.qm@web53605.mail.re2.yahoo.com> Message-ID: Thanks everyone for the great meeting last night, especially our presenters. It was a great turnout, probably our biggest. The next meeting will be Monday the 10th of May (HB had someone else booked in for the 1st Monday at 7PM). Just a reminder: we're always on the lookout for a better meeting venue (one that's perhaps a little better lit and doesn't require a PA; perhaps an office meeting room). Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengkeatliew at gmail.com Thu Apr 15 09:31:31 2010 From: bengkeatliew at gmail.com (Liew BengKeat) Date: Thu, 15 Apr 2010 15:31:31 +0800 Subject: [melbourne-pug] PyCon APAC - Tutorial + Conference Registration Open - NOW! In-Reply-To: References: <70C1A5315505C942A8274FCA16F363AF3A8ABA29C3@STAFFMAIL1.rp.edu.sg> Message-ID: Hi all Registration for PyCon Asia Pacific is *OPEN!* (Early bird registration ? by end April 2010) [image: PyCon APAC Poster.jpg] We look forward to seeing you in Singapore! Sincerely PyCon APAC Organizing Committee PS : If you?ve never been to Singapore, check out : http://www.yoursingapore.com/content/traveller/en/experience.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From r1chardj0n3s at gmail.com Thu Apr 22 06:28:11 2010 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Thu, 22 Apr 2010 14:28:11 +1000 Subject: [melbourne-pug] PyCon Australia 2010 update Message-ID: Hi everyone, Here's some updates for PyCon Australia 2010, to be held at the Sydney Masonic Center over the weekend of June 26 and 27. 1. Registration is now open 2. Keynotes announced 3. Call For Proposals proceeds 4. Several sponsors confirmed Please pass this message on to those you feel will find it interesting. Registration Is Now Open ======================== We offer two levels of registration for PyCon Australia 2010: Full (Early Bird) - $165 This is the registration rate for regular attendees. We're offering a limited Early Bird rate for the first 50 to registration. Once the Early Bird slots are filled registration will increase to $220. Full registration includes one seat at the conference dinner on Saturday night. Student - $44 For students able to present a valid student card we're offering this reduced rate. Student registrations do not include a seat at the conference dinner. Additional seats at the conference dinner may be purchased for $77 each. All prices include GST. Information about the registration process is on the PyCon Australia website. Register here: http://pycon-au.org/reg Keynotes Announced ================== We're pleased to announce the keynote line-up for PyCon Australia 2010. Saturday: Mark Pesce "Mark Pesce, one of the early pioneers in Virtual Reality is a writer, researcher and teacher. The co-inventor of VRML, he is the author of five books and numerous papers on the future of technology." - Wikipedia Saturday evening dinner: Anthony Baxter Anthony Baxter has been involved in the open source community for more than a decade, largely working in Python and on Python. He's working for Google now. Sunday: Nick Hodge Nick Hodge is a Professional Geek at Microsoft in Australia. Professional Geek is a polite way of saying he does stuff with software running on computers. Previously, he has worked for Adobe and Apple. Call For Proposals ================== We've had a great response to the Call For Proposals but there's still time left and plenty of program to fill. Presentation subjects may range from reports on open source, academic and commercial projects to tutorials and case studies. As long as a presentation is interesting and potentially useful to the Python community, it will be considered for inclusion in the program. We're especially interested in short presentations that will teach conference-goers something new and useful. Can you show attendees how to use a module? Explore a Python language feature? Package an application? Submit your proposal here: http://pycon-au.org/cfp Sponsors Confirmed ================== We have confirmed several sponsors for the conference: Gold: Microsoft Silver: Anchor Silver: Thousand Parsec Project In Kind: Linux Australia Thanks to our sponsors for helping make the event a reality. Richard Jones PyCon Australia 2010 From patrickchan7 at gmail.com Thu Apr 22 15:33:39 2010 From: patrickchan7 at gmail.com (Patrick Chan) Date: Thu, 22 Apr 2010 23:33:39 +1000 Subject: [melbourne-pug] Fwd: Writing Opportunities at Packt Publishing Message-ID: Hi all, If anyone is interested in writing a technical book, get in touch with Packt Publishing. (No, I don't work for them, but have previously reviewed 3 of their books.) Regards, Patrick ---------- Forwarded message ---------- From: Kshipra Singh Date: Thu, Apr 22, 2010 at 19:51 Subject: Writing Opportunities at Packt! To: Kshipra Singh Hi, Communicating the writing opportunities at Packt is a new activity that we have started and we hope that you find it useful. Packt plans to extend its catalogue of books with a special focus on following areas. If any of these topics get your fingers itching, let us know now! *Calling all Liferay Fanatics to write for Packt!* Some of the Liferay topics that we are interested in are: ?Security ?System Administration ?Multimedia ?Ecommerce ?Project Implementation and Cookbooks for developers ?And more! If you think there's an area which is not mentioned here but has a strong potential, please do let us know. More details about the opportunity are available at: http://authors.packtpub.com/content/calling-all-liferay-fanatics-write-packt *Packt invites Microsoft SQL Server Authors and Book Ideas:* Packt is particularly interested in developing books on the following topics: ?SQL Server Administration ?SQL Server High Availability ?MDX with Microsoft SQL Server ?Building Expert Business Intelligence Solutions w/ SQL Server 2008 ?And more! - If you have a book idea other than the topics mentioned here, we are keen to hear from you. More details about this opportunity can be read at: http://authors.packtpub.com/content/packt-invites-microsoft-sql-server-authors-and-book-ideas *Packt seeks .NET Developers for its Focused Cookbook Range* ** Packt Publishing is looking for .NET developers to expand its range of Cookbooks. No previous writing experience necessary, just as enthusiasm for the subject and an ability to put their expertise into words. We?re looking for Cookbooks in topic areas such as: ?*Integrating .NET with APIs* and other applications including integrating Windows, web and other platforms. ?*Cloud programming with Azure* and other online services. ?Using new architectures such as *MVC*. ?Dealing with particular problems or use cases such as *security, performance, parallel programming, UI design*. ?Developing common features such as *e-commerce features, social application features, content management features*, and so on. ?*Targeting multiple platforms*. Windows, Web, Mobile, Silverlight, and so on. ?Building attractive *?Mac-style? apps for Windows*! Don?t lots of VB and C# developers have Mac envy! We?d love to have a book that showed .NET developers how they can produce polished, beautiful interfaces for their Windows apps. ?*And more!* If you have a hot topic you think Packt should cover, don?t hesitate to contact us. More details about the opportunity are available at: http://authors.packtpub.com/content/dot-net-developers-invited-author-cookbook- range ** *Calling Open Source System and Network Administration experts to write for Packt!* ** Packt Publishing is looking for potential Authors who are fanatical about System and Network Administration technologies. No previous writing experience is necessary, just enthusiasm for the subject and an ability to put their expertise into words. The details about this opportunity can be read at: http://authors.packtpub.com/content/calling-open-source-system-and-network-administration-experts-write-packt *Tips for authors by authors* ********************************** We started a new section to provide writing tips to budding authors. These tips come directly from the authors who have already published their books with us. Read them here: http://authors.packtpub.com/content/tips-authors Note: You are receiving this mail as a reviewer of Packt's books. Thanks Kshipra Singh Author Relationship Manager Packt Publishing www.PacktPub.com Skype: kshiprasingh15 Twitter: http://twitter.com/packtauthors Interested in becoming an author? Visit http://authors.packtpub.com for all the information you need about writing for Packt. -------------- next part -------------- An HTML attachment was scrubbed... URL: From r1chardj0n3s at gmail.com Wed Apr 28 02:28:54 2010 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Wed, 28 Apr 2010 10:28:54 +1000 Subject: [melbourne-pug] PyCon Australia CFP: One Day Left! Message-ID: The Call For Proposals for PyCon Australia 2010 FINISHES TOMORROW! Presentation subjects may range from reports on open source, academic and commercial projects to tutorials and case studies. As long as a presentation is interesting and potentially useful to the Python community, it will be considered for inclusion in the program. We're especially interested in short presentations that will teach conference-goers something new and useful. Can you show attendees how to use a module? Explore a Python language feature? Package an application? Submit your proposal here: http://pycon-au.org/cfp As always, please pass this message on to people you feel will find it interesting. Richard Jones PyCon Australia 2010 http://pycon-au.org/ From n6151h at gmail.com Wed Apr 28 23:34:00 2010 From: n6151h at gmail.com (N6151H) Date: Thu, 29 Apr 2010 07:34:00 +1000 Subject: [melbourne-pug] Unix / Windows Admins in MEL Message-ID: A long-time colleague of mine forwarded this to me. Passing it on here in case anyone's interested. Cheers, Nick Unix/Windows Administrators - Melbourne Australia My client is one of the 4 largest consulting groups in the world, wanting to hire either under contract, or permanent, 2 X 5 years plus experienced UNIX/Linux with Windows administrators You will be working longterm with one of their large clients in Melbourne, doing systems administration and support work You will need to have at least 5 years across both Unix and Windows to qualify for these roles, with UNIX the most important, preferably also with Linux background Please send your detailed resume to peter at klareconsulting.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From billjordan121 at yahoo.com Thu Apr 29 19:58:15 2010 From: billjordan121 at yahoo.com (Bill Jordan) Date: Thu, 29 Apr 2010 10:58:15 -0700 (PDT) Subject: [melbourne-pug] array matching Message-ID: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Hey guys, I am?sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each one will have what is attached to. For example I want the output: A =[1,3] and B=[2,4] Thanks, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From filipz at 3g.nec.com.au Fri Apr 30 03:11:59 2010 From: filipz at 3g.nec.com.au (Filip) Date: Fri, 30 Apr 2010 11:11:59 +1000 Subject: [melbourne-pug] array matching In-Reply-To: <83538.68421.qm@web114307.mail.gq1.yahoo.com> References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: <98A0E3F45E944347B711EEB64C76FC94@spoon> You could use dictionary of lists test = { A: [1, 3], B: [2, 4] } print test[A] [1, 3] test[A].append(5) print test[A] [1, 3, 5] Cheers, Fil _____ From: melbourne-pug-bounces+filipz=3g.nec.com.au at python.org [mailto:melbourne-pug-bounces+filipz=3g.nec.com.au at python.org] On Behalf Of Bill Jordan Sent: Friday, 30 April 2010 3:58 AM To: python-dev at python.org; python-list at python.org; bangpypers at python.org; melbourne-pug at python.org; portland at python.org Subject: [melbourne-pug] array matching Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each one will have what is attached to. For example I want the output: A =[1,3] and B=[2,4] Thanks, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From tiskanto at gmail.com Fri Apr 30 08:23:51 2010 From: tiskanto at gmail.com (Teguh Iskanto) Date: Fri, 30 Apr 2010 16:23:51 +1000 Subject: [melbourne-pug] array matching In-Reply-To: <98A0E3F45E944347B711EEB64C76FC94@spoon> References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> <98A0E3F45E944347B711EEB64C76FC94@spoon> Message-ID: Or you can use zip , like this : >>> A = [1,3,5,7] >>> B = [2,4,6,8] >>> C = zip(A,B) >>> C [(1, 2), (3, 4), (5, 6), (7, 8)] >>> C[0] (1, 2) >>> C[1] (3, 4) hope this helps, Rgds Teguh Iskanto On Fri, Apr 30, 2010 at 11:11 AM, Filip wrote: > You could use dictionary of lists > > > > test = { > > A: [1, 3], > > B: [2, 4] > > } > > > > print test[A] > > [1, 3] > > > > test[A].append(5) > > > > print test[A] > > [1, 3, 5] > > > > Cheers, > > > > Fil > ------------------------------ > > *From:* melbourne-pug-bounces+filipz=3g.nec.com.au at python.org [mailto: > melbourne-pug-bounces+filipz = > 3g.nec.com.au at python.org] *On Behalf Of *Bill Jordan > *Sent:* Friday, 30 April 2010 3:58 AM > *To:* python-dev at python.org; python-list at python.org; bangpypers at python.org; > melbourne-pug at python.org; portland at python.org > *Subject:* [melbourne-pug] array matching > > > > Hey guys, > > > > I am sorry if this is not the right list to post some questions. I have a > simple question please and would appreciate some answers as I am new to > Python. > > > > I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] > > I want to arrang this array in different arrays so each one will have what > is attached to. For example I want the output: > > > > A =[1,3] and B=[2,4] > > > > Thanks, > > Bill > > > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From n6151h at gmail.com Fri Apr 30 09:08:18 2010 From: n6151h at gmail.com (N6151H) Date: Fri, 30 Apr 2010 17:08:18 +1000 Subject: [melbourne-pug] array matching In-Reply-To: <83538.68421.qm@web114307.mail.gq1.yahoo.com> References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: I believe this is what you want: dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) returns {'a': [1, 3], 'b': [2, 4]} Cheers, Nick On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: > Hey guys, > > I am sorry if this is not the right list to post some questions. I have a > simple question please and would appreciate some answers as I am new to > Python. > > I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] > I want to arrang this array in different arrays so each one will have what > is attached to. For example I want the output: > > A =[1,3] and B=[2,4] > > Thanks, > Bill > > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevenbird1 at gmail.com Fri Apr 30 09:15:34 2010 From: stevenbird1 at gmail.com (Steven Bird) Date: Fri, 30 Apr 2010 17:15:34 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: Or perhaps: >>> test = [['A',1],['B',2],['A',3],['B',4]] >>> from collections import defaultdict >>> a = defaultdict(list) >>> for key, value in test: ... a[key].append(value) ... >>> a defaultdict(, {'A': [1, 3], 'B': [2, 4]}) On 30 April 2010 17:08, N6151H wrote: > I believe this is what you want: > > ?? dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) > > returns > > ?? {'a': [1, 3], 'b': [2, 4]} > > Cheers, > Nick > > On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan > wrote: >> >> Hey guys, >> >> I am?sorry if this is not the right list to post some questions. I have a >> simple question please and would appreciate some answers as I am new to >> Python. >> >> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >> I want to arrang this array in different arrays so each one will have what >> is attached to. For example I want the output: >> >> A =[1,3] and B=[2,4] >> >> Thanks, >> Bill >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> > > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > From nick at farrell.name Fri Apr 30 09:30:43 2010 From: nick at farrell.name (Nick Farrell) Date: Fri, 30 Apr 2010 17:30:43 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: .. or if you're prepared to sacrifice a little brevity for transparency: >>> s = [['A', 1], ['B', 2], ['A', 3], ['B', 4]] >>> t = collections.defaultdict(list) >>> for k, v in s: t[k].append(v) ... >>> t defaultdict(, {'A': [1, 3], 'B': [2, 4]}) On Fri, Apr 30, 2010 at 5:08 PM, N6151H wrote: > I believe this is what you want: > > dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) > > returns > > {'a': [1, 3], 'b': [2, 4]} > > Cheers, > Nick > > On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: > >> Hey guys, >> >> I am sorry if this is not the right list to post some questions. I have a >> simple question please and would appreciate some answers as I am new to >> Python. >> >> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >> I want to arrang this array in different arrays so each one will have what >> is attached to. For example I want the output: >> >> A =[1,3] and B=[2,4] >> >> Thanks, >> Bill >> >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> >> > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From darius at obsidian.com.au Fri Apr 30 10:00:46 2010 From: darius at obsidian.com.au (Kevin Littlejohn) Date: Fri, 30 Apr 2010 18:00:46 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: Suspect you can do it more efficiently with more lines: d = {} for key, val in test.items(): d.setdefault(key, []).append(val) Saves multiple runs through the original list (which I presume is l1 in your example). Also makes for more readable code. d comes out the same as your example's return val. KJL On 30 April 2010 17:08, N6151H wrote: > I believe this is what you want: > > dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) > > returns > > {'a': [1, 3], 'b': [2, 4]} > > Cheers, > Nick > > On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: > >> Hey guys, >> >> I am sorry if this is not the right list to post some questions. I have a >> simple question please and would appreciate some answers as I am new to >> Python. >> >> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >> I want to arrang this array in different arrays so each one will have what >> is attached to. For example I want the output: >> >> A =[1,3] and B=[2,4] >> >> Thanks, >> Bill >> >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> >> > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -- Kevin Littlejohn Obsidian Consulting Group ph: +613 9355 7844 skype: silarsis -------------- next part -------------- An HTML attachment was scrubbed... URL: From n6151h at gmail.com Fri Apr 30 10:35:42 2010 From: n6151h at gmail.com (N6151H) Date: Fri, 30 Apr 2010 18:35:42 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: Sorry. Should have included l1, which is: [['a', 1], ['b', 2], ['a', 3], ['b', 4]] Same as what the original poster wanted (substituting strings for the A and B objects, WoLOG. Your example presumes test to be an already-populated dict, I think, which is, to my understanding, where the original poster wanted to end up. He's starting with a list. So, you need to build a dict as you iterate through that list, preferrably just once. The method I suggested does indeed require multiple passes. The key problem seems to be how to set the initial value for each key to an empty list, which can then be appended. You can do it in one pass like this: d = {} for k,v in l1: d.setdefault(k, []).append(v) which is probably what you meant to write, rather than test.items(), I suspect. But, it would still be nice to get this down to a one-line expression, wouldn't it? Would be nice if you had a form of the reduce built-in function that worked with something other than scalars. Then you could write: e = {} e = reduce (lambda k,v: e.setdefault(k,[]).append(v), l1, e) How about On Fri, Apr 30, 2010 at 6:00 PM, Kevin Littlejohn wrote: > Suspect you can do it more efficiently with more lines: > > d = {} > for key, val in test.items(): > d.setdefault(key, []).append(val) > > Saves multiple runs through the original list (which I presume is l1 in > your example). Also makes for more readable code. d comes out the same as > your example's return val. > > KJL > > On 30 April 2010 17:08, N6151H wrote: > >> I believe this is what you want: >> >> dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) >> >> returns >> >> {'a': [1, 3], 'b': [2, 4]} >> >> Cheers, >> Nick >> >> On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: >> >>> Hey guys, >>> >>> I am sorry if this is not the right list to post some questions. I have a >>> simple question please and would appreciate some answers as I am new to >>> Python. >>> >>> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >>> I want to arrang this array in different arrays so each one will have >>> what is attached to. For example I want the output: >>> >>> A =[1,3] and B=[2,4] >>> >>> Thanks, >>> Bill >>> >>> >>> _______________________________________________ >>> melbourne-pug mailing list >>> melbourne-pug at python.org >>> http://mail.python.org/mailman/listinfo/melbourne-pug >>> >>> >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> >> > > > -- > Kevin Littlejohn > Obsidian Consulting Group > ph: +613 9355 7844 > skype: silarsis > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From darius at obsidian.com.au Fri Apr 30 10:47:12 2010 From: darius at obsidian.com.au (Kevin Littlejohn) Date: Fri, 30 Apr 2010 18:47:12 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: On 30 April 2010 18:35, N6151H wrote: > Sorry. Should have included l1, which is: [['a', 1], ['b', 2], ['a', 3], > ['b', 4]] > Same as what the original poster wanted (substituting strings for the A and > B objects, WoLOG. > > Your example presumes test to be an already-populated dict, I think, which > is, to my understanding, where the original poster wanted Sorry, you're right, that ".items()" shouldn't be there. I added it in a fit of stupidity. I really dislike the option you gave because one line expressions are evil. They're fine for the initial write, they're hell on the new guy in the company trying to upkeep your code, and they're horrible to have to debug later on. Having maintained the same body of python code for over 10 years (yes, it was initially written under python 1.x), I would rate readability a higher requirement than brevity. Otherwise, you'd be better off in perl, right? :) I don't think offering one-liners to newcomers is wise - at least, not without also giving them a longhand version. I particularly think if you're going to do it as a one-liner, you want to make sure you're gaining something for the sacrificed readability - in the case provided, your one liner was also less efficient than doing it longhand. That seems to often be the case in Python - write it out naturally, and it's likely to be efficient anyway. But, you're right, the .items() was a typo ;) KJL > to end up. He's starting with a list. So, you need to build a dict as you > iterate through that list, preferrably just once. The method I suggested > does indeed require multiple passes. The key problem seems to be how to set > the initial value for each key to an empty list, which can then be > appended. You can do it in one pass like this: > > d = {} > for k,v in l1: > d.setdefault(k, []).append(v) > > which is probably what you meant to write, rather than test.items(), I > suspect. > > But, it would still be nice to get this down to a one-line expression, > wouldn't it? > > Would be nice if you had a form of the reduce built-in function that worked > with something other than scalars. Then you could write: > > e = {} > e = reduce (lambda k,v: e.setdefault(k,[]).append(v), l1, e) > > > How about > > > On Fri, Apr 30, 2010 at 6:00 PM, Kevin Littlejohn wrote: > >> Suspect you can do it more efficiently with more lines: >> >> d = {} >> for key, val in test.items(): >> d.setdefault(key, []).append(val) >> >> Saves multiple runs through the original list (which I presume is l1 in >> your example). Also makes for more readable code. d comes out the same as >> your example's return val. >> >> KJL >> >> On 30 April 2010 17:08, N6151H wrote: >> >>> I believe this is what you want: >>> >>> dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) >>> >>> returns >>> >>> {'a': [1, 3], 'b': [2, 4]} >>> >>> Cheers, >>> Nick >>> >>> On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: >>> >>>> Hey guys, >>>> >>>> I am sorry if this is not the right list to post some questions. I have >>>> a simple question please and would appreciate some answers as I am new to >>>> Python. >>>> >>>> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >>>> I want to arrang this array in different arrays so each one will have >>>> what is attached to. For example I want the output: >>>> >>>> A =[1,3] and B=[2,4] >>>> >>>> Thanks, >>>> Bill >>>> >>>> >>>> _______________________________________________ >>>> melbourne-pug mailing list >>>> melbourne-pug at python.org >>>> http://mail.python.org/mailman/listinfo/melbourne-pug >>>> >>>> >>> >>> _______________________________________________ >>> melbourne-pug mailing list >>> melbourne-pug at python.org >>> http://mail.python.org/mailman/listinfo/melbourne-pug >>> >>> >> >> >> -- >> Kevin Littlejohn >> Obsidian Consulting Group >> ph: +613 9355 7844 >> skype: silarsis >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> >> > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -- Kevin Littlejohn Obsidian Consulting Group ph: +613 9355 7844 skype: silarsis -------------- next part -------------- An HTML attachment was scrubbed... URL: From n6151h at gmail.com Fri Apr 30 10:59:17 2010 From: n6151h at gmail.com (N6151H) Date: Fri, 30 Apr 2010 18:59:17 +1000 Subject: [melbourne-pug] array matching In-Reply-To: References: <83538.68421.qm@web114307.mail.gq1.yahoo.com> Message-ID: In general, I agree with you that code should be readable. On the other hand, we don't necessarily want to be writing for the lowest common denominator, i.e., the newcomer. There's room for abuse in any language, but I don't consider any particular construct (or language) "evil" per se. Otherwise, you can extend that appellation to anything beyond pure machine code since, for the "newcomer" symbolic instruction sets and higher-level, algebraic languages and even macro-assemblers reduce what's really going on to "one-liners". You might see the in-line "for" construct as coming from perl, but in fact it's been around MUCH longer than that, going back to list-directed I/O in FORTRAN IV. What I think is good, here, is that we've managed to show the questioner that there are two ways to solve the problem, discuss the relative merits of both, concluding that yours is, indeed, the more computationally efficient approach. The nice by-product is that it provokes thought as to what may be lacking in the language that would otherwise allow the one-liner approach to be used. Cheers, Nick On Fri, Apr 30, 2010 at 6:47 PM, Kevin Littlejohn wrote: > > > On 30 April 2010 18:35, N6151H wrote: > >> Sorry. Should have included l1, which is: [['a', 1], ['b', 2], ['a', 3], >> ['b', 4]] >> Same as what the original poster wanted (substituting strings for the A >> and B objects, WoLOG. >> >> Your example presumes test to be an already-populated dict, I think, which >> is, to my understanding, where the original poster wanted > > > Sorry, you're right, that ".items()" shouldn't be there. I added it in a > fit of stupidity. > > I really dislike the option you gave because one line expressions are evil. > They're fine for the initial write, they're hell on the new guy in the > company trying to upkeep your code, and they're horrible to have to debug > later on. Having maintained the same body of python code for over 10 years > (yes, it was initially written under python 1.x), I would rate readability a > higher requirement than brevity. Otherwise, you'd be better off in perl, > right? :) > > I don't think offering one-liners to newcomers is wise - at least, not > without also giving them a longhand version. I particularly think if you're > going to do it as a one-liner, you want to make sure you're gaining > something for the sacrificed readability - in the case provided, your one > liner was also less efficient than doing it longhand. That seems to often > be the case in Python - write it out naturally, and it's likely to be > efficient anyway. > > But, you're right, the .items() was a typo ;) > > KJL > > >> to end up. He's starting with a list. So, you need to build a dict as >> you iterate through that list, preferrably just once. The method I >> suggested does indeed require multiple passes. The key problem seems to be >> how to set the initial value for each key to an empty list, which can then >> be appended. You can do it in one pass like this: >> >> d = {} >> for k,v in l1: >> d.setdefault(k, []).append(v) >> >> which is probably what you meant to write, rather than test.items(), I >> suspect. >> >> But, it would still be nice to get this down to a one-line expression, >> wouldn't it? >> >> Would be nice if you had a form of the reduce built-in function that >> worked with something other than scalars. Then you could write: >> >> e = {} >> e = reduce (lambda k,v: e.setdefault(k,[]).append(v), l1, e) >> >> >> How about >> >> >> On Fri, Apr 30, 2010 at 6:00 PM, Kevin Littlejohn > > wrote: >> >>> Suspect you can do it more efficiently with more lines: >>> >>> d = {} >>> for key, val in test.items(): >>> d.setdefault(key, []).append(val) >>> >>> Saves multiple runs through the original list (which I presume is l1 in >>> your example). Also makes for more readable code. d comes out the same as >>> your example's return val. >>> >>> KJL >>> >>> On 30 April 2010 17:08, N6151H wrote: >>> >>>> I believe this is what you want: >>>> >>>> dict([(r[0], [s[1] for s in l1 if s[0] == r[0]]) for r in l1]) >>>> >>>> returns >>>> >>>> {'a': [1, 3], 'b': [2, 4]} >>>> >>>> Cheers, >>>> Nick >>>> >>>> On Fri, Apr 30, 2010 at 3:58 AM, Bill Jordan wrote: >>>> >>>>> Hey guys, >>>>> >>>>> I am sorry if this is not the right list to post some questions. I have >>>>> a simple question please and would appreciate some answers as I am new to >>>>> Python. >>>>> >>>>> I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] >>>>> I want to arrang this array in different arrays so each one will have >>>>> what is attached to. For example I want the output: >>>>> >>>>> A =[1,3] and B=[2,4] >>>>> >>>>> Thanks, >>>>> Bill >>>>> >>>>> >>>>> _______________________________________________ >>>>> melbourne-pug mailing list >>>>> melbourne-pug at python.org >>>>> http://mail.python.org/mailman/listinfo/melbourne-pug >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> melbourne-pug mailing list >>>> melbourne-pug at python.org >>>> http://mail.python.org/mailman/listinfo/melbourne-pug >>>> >>>> >>> >>> >>> -- >>> Kevin Littlejohn >>> Obsidian Consulting Group >>> ph: +613 9355 7844 >>> skype: silarsis >>> >>> _______________________________________________ >>> melbourne-pug mailing list >>> melbourne-pug at python.org >>> http://mail.python.org/mailman/listinfo/melbourne-pug >>> >>> >> >> _______________________________________________ >> melbourne-pug mailing list >> melbourne-pug at python.org >> http://mail.python.org/mailman/listinfo/melbourne-pug >> >> > > > -- > Kevin Littlejohn > Obsidian Consulting Group > ph: +613 9355 7844 > skype: silarsis > > _______________________________________________ > melbourne-pug mailing list > melbourne-pug at python.org > http://mail.python.org/mailman/listinfo/melbourne-pug > > -------------- next part -------------- An HTML attachment was scrubbed... URL: