From simon at brunningonline.net Tue Nov 13 15:15:34 2007 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 13 Nov 2007 14:15:34 +0000 Subject: [python-uk] London Python meetup, Wednesday, December the 5th Message-ID: <8c7f10c60711130615y3223c8c6qe159cd6d6581a534@mail.gmail.com> Details here: http://tinyurl.com/2cvtlq -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues From jn.ml.pyuk.93 at wingsandbeaks.org.uk Fri Nov 16 09:29:29 2007 From: jn.ml.pyuk.93 at wingsandbeaks.org.uk (Jeremy Nicoll - pyuk) Date: Fri, 16 Nov 2007 08:29:29 +0000 Subject: [python-uk] Reading a file of tab-separated values Message-ID: Is there a simple way to read a whole (modest sized, parameter) file of lines of tab-separated lines into one Python data-structure? -- Jeremy C B Nicoll - my opinions are my own. From miles.chris at gmail.com Fri Nov 16 09:51:23 2007 From: miles.chris at gmail.com (Chris Miles) Date: Fri, 16 Nov 2007 19:51:23 +1100 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: References: Message-ID: <1373FB64-E60C-451C-9D2F-9A783C7155BC@gmail.com> The built-in csv module is good for this. You can specify the delimiter (ie: tabs instead of commas) and it handles a bunch of edge cases (like quoted values containing the delimiter) that makes it a better solution than string.split('\t'). Cheers CM On 16 Nov 2007, at 19:29, Jeremy Nicoll - pyuk wrote: > Is there a simple way to read a whole (modest sized, parameter) file > of > lines of tab-separated lines into one Python data-structure? From mark at qtrac.eu Fri Nov 16 09:57:21 2007 From: mark at qtrac.eu (Mark Summerfield) Date: Fri, 16 Nov 2007 08:57:21 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: References: Message-ID: <200711160857.22000.mark@qtrac.eu> On 2007-11-16, Jeremy Nicoll - pyuk wrote: > Is there a simple way to read a whole (modest sized, parameter) file of > lines of tab-separated lines into one Python data-structure? I think the csv module can do this. (Despite its name it can handle any delimiter you give it.) -- Mark Summerfield, Qtrac Ltd., www.qtrac.eu From a.harrowell at gmail.com Fri Nov 16 10:40:14 2007 From: a.harrowell at gmail.com (Alexander Harrowell) Date: Fri, 16 Nov 2007 09:40:14 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: <200711160857.22000.mark@qtrac.eu> References: <200711160857.22000.mark@qtrac.eu> Message-ID: On Nov 16, 2007 8:57 AM, Mark Summerfield wrote: > On 2007-11-16, Jeremy Nicoll - pyuk wrote: > > Is there a simple way to read a whole (modest sized, parameter) file of > > lines of tab-separated lines into one Python data-structure? > > I think the csv module can do this. (Despite its name it can handle any > delimiter you give it.) Can it also handle the situation where you have a gaggle of tuples separated by commas? I.e. does it disregard commas nested within brackets? > > > -- > Mark Summerfield, Qtrac Ltd., www.qtrac.eu > > > _______________________________________________ > python-uk mailing list > python-uk at python.org > http://mail.python.org/mailman/listinfo/python-uk > From tim.couper at scivisum.co.uk Fri Nov 16 11:24:20 2007 From: tim.couper at scivisum.co.uk (Tim Couper) Date: Fri, 16 Nov 2007 10:24:20 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: References: <200711160857.22000.mark@qtrac.eu> Message-ID: <473D6FD4.3000103@scivisum.co.uk> Best way is to try it out :-) If you've set it to tab-delimited, then commas are surely not an issue. If you've created a csv with stringified tuples, the tuple entries look like ...,"(1,2,3)",.... and so the csv module, using a comma delimiter, is not confused by the "tuple" commas. Tim Dr Tim Couper CTO, SciVisum Ltd www.scivisum.com Alexander Harrowell wrote: > On Nov 16, 2007 8:57 AM, Mark Summerfield wrote: > >> On 2007-11-16, Jeremy Nicoll - pyuk wrote: >> >>> Is there a simple way to read a whole (modest sized, parameter) file of >>> lines of tab-separated lines into one Python data-structure? >>> >> I think the csv module can do this. (Despite its name it can handle any >> delimiter you give it.) >> > > Can it also handle the situation where you have a gaggle of tuples > separated by commas? I.e. does it disregard commas nested within > brackets? > > >> -- >> Mark Summerfield, Qtrac Ltd., www.qtrac.eu >> >> >> _______________________________________________ >> python-uk mailing list >> python-uk at python.org >> http://mail.python.org/mailman/listinfo/python-uk >> >> > _______________________________________________ > python-uk mailing list > python-uk at python.org > http://mail.python.org/mailman/listinfo/python-uk > > From betatim at gmail.com Fri Nov 16 15:31:38 2007 From: betatim at gmail.com (Tim Head) Date: Fri, 16 Nov 2007 14:31:38 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: References: <200711160857.22000.mark@qtrac.eu> Message-ID: <85dba0990711160631o29b91af0j6d90fd75cb6a86fe@mail.gmail.com> On 16/11/2007, Alexander Harrowell wrote: > On Nov 16, 2007 8:57 AM, Mark Summerfield wrote: > > On 2007-11-16, Jeremy Nicoll - pyuk wrote: > > > Is there a simple way to read a whole (modest sized, parameter) file of > > > lines of tab-separated lines into one Python data-structure? > > > > I think the csv module can do this. (Despite its name it can handle any > > delimiter you give it.) > > Can it also handle the situation where you have a gaggle of tuples > separated by commas? I.e. does it disregard commas nested within > brackets? > Like so? import csv input = csv.StringIO('Hello, World\tThe Spanish inquisition\tis coming to town, tomorrow\t(1,2,3,4)') reader = csv.reader(input, delimiter="\t") for line in reader: print line cheers, tim > > > > > > -- > > Mark Summerfield, Qtrac Ltd., www.qtrac.eu > > > > > > _______________________________________________ > > python-uk mailing list > > python-uk at python.org > > http://mail.python.org/mailman/listinfo/python-uk > > > _______________________________________________ > python-uk mailing list > python-uk at python.org > http://mail.python.org/mailman/listinfo/python-uk > -- http://tim.jottit.com/ From a.harrowell at gmail.com Fri Nov 16 16:05:41 2007 From: a.harrowell at gmail.com (Alexander Harrowell) Date: Fri, 16 Nov 2007 15:05:41 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: <85dba0990711160631o29b91af0j6d90fd75cb6a86fe@mail.gmail.com> References: <200711160857.22000.mark@qtrac.eu> <85dba0990711160631o29b91af0j6d90fd75cb6a86fe@mail.gmail.com> Message-ID: On Nov 16, 2007 2:31 PM, Tim Head wrote: > On 16/11/2007, Alexander Harrowell wrote: > > On Nov 16, 2007 8:57 AM, Mark Summerfield wrote: > > > On 2007-11-16, Jeremy Nicoll - pyuk wrote: > > > > Is there a simple way to read a whole (modest sized, parameter) file of > > > > lines of tab-separated lines into one Python data-structure? > > Like so? > > import csv > > input = csv.StringIO('Hello, World\tThe Spanish inquisition\tis coming > to town, tomorrow\t(1,2,3,4)') > reader = csv.reader(input, delimiter="\t") > > for line in reader: > print line > I was thinking more like ("Data","more data","even more data"), ("data", "data", "yet further data"), ("you", "get", "the", "picture") to ("Data", "more data", "even more data") (etc, etc) (etc) From a.harrowell at gmail.com Fri Nov 16 16:12:18 2007 From: a.harrowell at gmail.com (Alexander Harrowell) Date: Fri, 16 Nov 2007 15:12:18 +0000 Subject: [python-uk] Reading a file of tab-separated values In-Reply-To: References: <200711160857.22000.mark@qtrac.eu> <85dba0990711160631o29b91af0j6d90fd75cb6a86fe@mail.gmail.com> Message-ID: Works anyway. Thanks. From jn.ml.pyuk.93 at wingsandbeaks.org.uk Mon Nov 19 14:21:59 2007 From: jn.ml.pyuk.93 at wingsandbeaks.org.uk (Jeremy Nicoll - pyuk) Date: Mon, 19 Nov 2007 13:21:59 +0000 Subject: [python-uk] What else is running on my machine? Message-ID: Is there a cross-platform of determining what other processes (or in Windows terms, other applications) are running? Is it possible in a cross-platform way to ask some other application to shut down, wait a while, and then test to see if it did shut? -- Jeremy C B Nicoll - my opinions are my own. From jn.ml.pyuk.93 at wingsandbeaks.org.uk Mon Nov 19 14:20:30 2007 From: jn.ml.pyuk.93 at wingsandbeaks.org.uk (Jeremy Nicoll - pyuk) Date: Mon, 19 Nov 2007 13:20:30 +0000 Subject: [python-uk] Where is a Python program running? Message-ID: Under Windows XP, I could have a program running under python.exe or pythonw.exe or under IDLE. How can I test within a python program which of these situations apply? At the moment, for example, I have a program which runs under python.exe because it might produce some output - certainly while writing it there's quite a few inline print statements. I set a flag as soon as any output is produced (whether error messages, intentional trace statements, whatever), and at the end of the program if the flag is set then execute: toldtostop = "" while toldtostop.upper() <> "QQ": toldtostop = raw_input("\nEnter QQ to close window...") If nothing has been printed that's not done, and the console window just shuts. If I were to use pythonw instead, presumably I'd need to find some other way to display output? If I test these programs under IDLE the toldtostop/QQ stuff is just a nuisance, so I'd prefer to be able not to have it run. I suppose that also applied to a.n.other.ide - so is there a general way to test if any ide is in use? There's a possibility that some of what I'm writing may also get run on Mac and/or Linux/Unix systems. Do whatever methods I might use to test what's going on work cross-platform? -- Jeremy C B Nicoll - my opinions are my own. From mail at timgolden.me.uk Mon Nov 19 16:48:35 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 19 Nov 2007 15:48:35 +0000 Subject: [python-uk] Where is a Python program running? In-Reply-To: References: Message-ID: <4741B053.6020203@timgolden.me.uk> Jeremy Nicoll - pyuk wrote: > Under Windows XP, I could have a program running under python.exe or > pythonw.exe or under IDLE. How can I test within a python program which of > these situations apply? (As a starter, you're better off asking this on the main Python list; this is Python-UK which is quite low-volume and mostly used for meetups etc. That said, here goes...) I'm not sure if there's anything absolutely foolproof / x-platform. A couple of starting points, though: the value of sys.executable and the value of sys.stdout. Try this program (which uses the pywin32 extensions): import os, sys import win32api win32api.MessageBox (0, "%s\n%s" % (sys.executable, repr (sys.stdout))) Save it as showme.py (or whatever) and run it under the different environments you're considering. It gives enough to apply some sort of metric, but it's hardly foolproof. As I say, ask the question on the main Python list where there are more and smarter minds than mine. I'm using the MessageBox functionality simple to get something showing on-screen. Obviously this won't work x-platform, so you'd need to write out to a file or use the logging module or something. TJG From mail at timgolden.me.uk Mon Nov 19 16:53:04 2007 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 19 Nov 2007 15:53:04 +0000 Subject: [python-uk] What else is running on my machine? In-Reply-To: References: Message-ID: <4741B160.3080000@timgolden.me.uk> [as per other answer: ask on main python list] Jeremy Nicoll - pyuk wrote: > Is there a cross-platform of determining what other processes (or in Windows > terms, other applications) are running? > Is it possible in a cross-platform way to ask some other application to shut > down, wait a while, and then test to see if it did shut? Pretty much "no" to both questions *cross-platform*. But I'm fairly sure that all platforms offer something specific, and there's nothing to stop you wrapping that up in a module with conditional imports or judicious use of the platform module or whatever. See the various list archives for Windows answers to this, at least. (Check comp.lang.python & python-win32). Not sure about Linux/OSX but again c.l.py is a good start. TJG From tibs at tibsnjoan.co.uk Mon Nov 26 23:13:11 2007 From: tibs at tibsnjoan.co.uk (Tony Ibbs) Date: Mon, 26 Nov 2007 22:13:11 +0000 Subject: [python-uk] Cambridge & East Anglia Pub Meeting, 4th Dec Message-ID: <9EB5F866-F05C-44F2-96FD-3D1D49F6E1CD@tibsnjoan.co.uk> The second meeting of the Cambridge & East Anglia Python group will be at 8pm on Tuesday 4th December, at the Carlton Arms (http:// www.thecarltonarms.co.uk/) This time we've got an agenda: * when future pub meetings will be held * whether we want to join O'Reilly's discount scheme * some discussion about how we might organise talks (particularly where) Tony Ibbs / Tibs -- tibs at tibsnjoan.co.uk http://www.pyconuk.org/community/Cambridge_and_East_of_England http://groups.google.com/group/campug