From b at bvanderveen.com Tue Nov 1 00:30:55 2011 From: b at bvanderveen.com (Benjamin van der Veen) Date: Mon, 31 Oct 2011 16:30:55 -0700 Subject: [portland] Raw buffers in python Message-ID: Hey all, What's the best way to make a raw buffer out of a string in Python? They key requirement is that inspecting a range of characters in the resulting object does not cause a copy/allocation. Correct me if I'm wrong, but it seems like sequence types (produced by memoryview, bytearray, etc) all return a character or integer object when you access items by index. An example usecase is a parser?you have a string buffer the user gave you, and you're iterating over each character. It would be nice not to allocate a heap object for every iteration. Hm, although, now that I'm typing this up, I'm realizing it might be a bit ridiculous to be asking for a raw char or int in Python. :S Best, Benjamin -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at susens-schurter.com Tue Nov 1 00:44:50 2011 From: michael at susens-schurter.com (Michael Schurter) Date: Mon, 31 Oct 2011 16:44:50 -0700 Subject: [portland] Raw buffers in python In-Reply-To: References: Message-ID: On Mon, Oct 31, 2011 at 4:30 PM, Benjamin van der Veen wrote: > Hey all, > > What's the best way to make a raw buffer out of a string in Python? They > key requirement is that inspecting a range of characters in the resulting > object does not cause a copy/allocation. Correct me if I'm wrong, but it > seems like sequence types (produced by memoryview, bytearray, etc) all > return a character or integer object when you access items by index. > > An example usecase is a parser?you have a string buffer the user gave you, > and you're iterating over each character. It would be nice not to allocate > a heap object for every iteration. If I remember correctly, instances of all single byte ints (0 <= x < 256) are created automatically, so iterating over a bytearray may avoid new object creation. > Hm, although, now that I'm typing this up, I'm realizing it might be a bit > ridiculous to be asking for a raw char or int in Python. :S Yeah, everything is a heap allocated PyObject in CPython. Check out Cython for writing Python that compiles to C and can use raw C types (bytes & chars) without much effort. Depending on your use case and dependencies, PyPy might be worth checking out. Doing lots of iterations over homogeneous data types is where JITs shine. From b at bvanderveen.com Tue Nov 1 17:41:46 2011 From: b at bvanderveen.com (Benjamin van der Veen) Date: Tue, 1 Nov 2011 09:41:46 -0700 Subject: [portland] Portland Digest, Vol 55, Issue 1 In-Reply-To: References: Message-ID: > If I remember correctly, instances of all single byte ints (0 <= x < > 256) are created automatically, so iterating over a bytearray may > avoid new object creation. That would certainly make sense. I wouldn't be too surprised if it pre-allocated/interned single-byte chars as well. > Yeah, everything is a heap allocated PyObject in CPython. Check out > Cython for writing Python that compiles to C and can use raw C types > (bytes & chars) without much effort. Depending on your use case and > dependencies, PyPy might be worth checking out. Doing lots of > iterations over homogeneous data types is where JITs shine. Thanks for the pointers, Michael! From rbednark at gmail.com Tue Nov 1 23:32:44 2011 From: rbednark at gmail.com (Rob Bednark) Date: Tue, 01 Nov 2011 15:32:44 -0700 Subject: [portland] Wanted: suggestions for Python quiz for meetup next week Message-ID: <4EB0738C.50904@gmail.com> Do you have any ideas for questions for the Python quiz for the next Portland Python Meetup? (Tue, Nov 8, 6:30pm, Urban Airship) Please email your quiz suggestions to me, rbednark at gmail.com, or use the following form: https://docs.google.com/spreadsheet/viewform?hl=en_US&formkey=dDYxbi03a3BBU0wzREozaXFyY2tpQWc6MQ#gid=0 The questions from the Python quiz at the last meetup can be found here on github , and you can download a zip file here . -- Rob Bednark | H: 503.663.1526 | C: 503.927.2404 | Skype: rbednark | Facebook | LinkedIn | Twitter | Google+ | portlandUpside.com | resume | bednark.com | rbednark at gmail.com | 10013 SE Eastmont Dr, Damascus, OR 97089 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Rob.100px.JPG Type: image/jpeg Size: 16353 bytes Desc: not available URL: From michelle at pdxpython.org Fri Nov 4 19:48:15 2011 From: michelle at pdxpython.org (Michelle Rowley) Date: Fri, 4 Nov 2011 11:48:15 -0700 Subject: [portland] This Tuesday, 11/8 @ 6:30pm: Urwid, Pythonic Quiz + Q&A, and you Message-ID: Top o' the weekend, Pythonistas -- Coming up this Tuesday, the 8th, is the November 2011 installation of PDX Python. Unbelievably, we have no Monthly Module volunteer, yet! If you have a module you'd like to share with us this month, drop me a line at michelle at pdxpython.org and I'll put you on the schedule. After the mystery module, Peter Banka will present an introduction to a tool called Urwid (http://excess.org/urwid), a console UI library for Python. Then we'll move on to our second monthly Pythonic Trivia Quiz, and a reverse Q&A session, both led by Rob Bednark. If there's time remaining we'll open the floor to lightning talks. All of this Python goodness is going down at 6:30pm at Urban Airship's HQ, 334 NW 11th Ave: http://goo.gl/maps/U6mC. The back door, around the corner on Flanders, will be propped open: http://goo.gl/maps/Ikbh. After the Python, we'll head over to Bailey's for more Python. Hope to see you there! Michelle --- Michelle Rowley @pythonchelle michelle at pdxpython.org http://www.meetup.com/pdxpython -------------- next part -------------- An HTML attachment was scrubbed... URL: From rshepard at appl-ecosys.com Tue Nov 22 18:32:36 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 09:32:36 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) Message-ID: After several years I need to get back up to speed writing python scripts. The immediate need is re-formatting a text file (with a .csv extention) exported from Excel to the format needed by a postgres table (and an R data frame). The script seems to work (python throws no overt errors), but it's showing a python object in the output and that should not be there. The script: #!/usr/bin/env python import sys,csv """ First row of input file is list of chemical parameters. Following rows have sample number, site ID, sample date, and a quantity for each constituent. """ filename = sys.argv[1] try: infile = open(filename, 'r') except: print "Can't open ", filename,"!" sys.exit(1) indata = csv.reader(infile, delimiter='|') # the list of chemicals parmlist = indata.next() outfile = open('out.txt', 'w') outdata = csv.writer(outfile, delimiter = '|', lineterminator = '\n') # The next rows are sample numbers, site ids, dates, and values. for row in indata: for parm, rowval in zip(parmlist,row[0:]): outdata.writerow([outdata, row[0:3], parm, rowval]) infile.close() outfile.close() Some sample data: |||Ag|Al|Alk_CO3|Alk_HCO3|Alk_tot|As|Ba|Be|Bi|Ca|Cd|Cl|Co|Cr|Cu|DO|Fe|Hg|K|Mg|Mn|Mo|Na|NH4-N|Na|NO3-NO2-N|oil_grease|Pb|pH|Sb|SC|Se|SO4|Sr|TDS|Tl|V|Zn 1|SW-1|1990-10-10|0.000|0.000|0.000|213.000|213.000|0.000|0.000|0.000|0.000|66.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|0.000|14.000|0.000|0.000|1.000|0.080|0.000|0.020|NA|0.025|8.640|0.000|596.000|0.000|43.000|0.000|270.000|0.000|0.000|0.000 2|SW-2|1990-10-10|0.000|0.000|0.000|178.000|178.000|0.000|0.000|0.000|0.000|55.000|0.000|1.000|0.000|0.000|0.000|NA|0.000|0.000|1.640|9.000|0.000|0.000|9.000|0.080|0.000|0.020|NA|0.025|8.690|0.000|516.000|0.000|19.000|0.000|220.000|0.000|0.000|0.000 3|SW-3|1990-10-10|0.000|0.000|0.000|183.000|183.000|0.000|0.000|0.000|0.000|69.000|0.000|1.000|0.000|0.000|0.000|NA|0.000|0.000|0.000|6.000|0.000|0.000|7.000|0.080|0.000|0.020|NA|0.025|8.630|0.000|559.000|0.000|29.000|0.000|224.000|0.000|0.000|0.000 4|SW-1|1990-11-29|0.000|0.000|0.000|217.000|217.000|0.000|0.000|0.000|0.000|68.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|14.000|0.000|0.000|10.000|0.050|0.000|0.020|NA|0.025|8.520|0.000|6.630|0.000|24.000|0.000|256.000|0.000|0.000|0.000 5|SW-2|1990-11-29|0.000|0.000|0.000|170.000|170.000|0.000|0.000|0.000|0.000|57.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|1.000|10.000|0.000|0.000|8.000|0.050|0.000|0.020|NA|0.025|8.710|0.000|6.000|0.000|17.000|0.000|206.000|0.000|0.000|0.000 6|SW-3|1990-11-29|0.000|0.000|0.000|180.000|180.000|0.000|0.000|0.000|0.000|74.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|6.000|0.000|0.000|4.000|0.050|0.000|0.020|NA|0.025|8.500|0.000|6.760|0.000|28.000|0.000|226.000|0.000|0.000|0.000 7|SW-1|1991-03-28|0.000|0.000|4.000|172.000|176.000|0.000|0.000|0.000|0.000|50.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|9.000|0.000|0.000|8.000|0.140|0.000|0.020|NA|0.025|8.100|0.000|5.720|0.000|7.000|0.000|182.000|0.000|0.000|0.000 8|SW-2|1991-03-28|0.000|0.000|8.000|204.000|212.000|0.000|0.000|0.000|0.000|59.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|14.000|0.000|0.000|10.000|0.090|0.000|0.020|NA|0.025|8.400|0.000|6.520|0.000|12.000|0.000|220.000|0.000|0.000|0.000 9|SW-3|1991-03-28|0.000|0.000|0.000|194.000|194.000|0.000|0.000|0.000|0.000|69.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|6.000|0.000|0.000|6.000|0.090|0.000|0.020|NA|0.025|8.100|0.000|6.920|0.000|25.000|0.000|224.000|0.000|0.000|0.000 10|SW-1|1991-05-27|0.000|0.000|3.000|153.000|156.000|0.000|0.000|0.000|0.000|48.000|0.000|4.000|0.000|0.000|0.000|NA|0.000|0.000|1.000|8.000|0.000|0.000|9.000|0.050|0.000|0.020|NA|0.025|8.350|0.000|5.100|0.000|21.000|0.000|230.000|0.000|0.000|0.000 11|SW-2|1991-05-27|0.000|0.000|10.000|195.000|205.000|0.000|0.000|0.000|0.000|62.000|0.000|4.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|14.000|0.000|0.000|11.000|0.050|0.000|0.020|NA|0.025|8.360|0.000|5.720|0.000|25.000|0.000|266.000|0.000|0.000|0.000 12|SW-3|1991-05-27|0.000|0.000|10.000|165.000|175.000|0.000|0.000|0.000|0.000|69.000|0.000|1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|5.000|0.000|0.000|4.000|0.050|0.000|0.020|NA|0.025|8.360|0.000|5.720|0.000|29.000|0.000|224.000|0.000|0.000|0.000 13|SW-4|1991-05-27|0.000|0.000|0.000|123.000|123.000|0.000|0.000|0.000|0.000|62.000|0.000|1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|7.000|0.000|0.000|5.000|0.050|0.000|0.020|NA|0.025|8.100|0.000|5.500|0.000|82.000|0.000|222.000|0.000|0.000|0.000 14|SW-5|1991-05-27|0.000|0.000|7.000|182.000|189.000|0.000|0.000|0.000|0.000|73.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|0.000|6.000|0.000|0.000|6.000|0.050|0.000|0.090|NA|0.025|8.310|0.000|6.290|0.000|16.000|0.000|248.000|0.000|0.000|0.000 15|SW-1|1991-06-09|0.000|0.000|8.000|152.000|160.000|0.000|0.000|0.000|0.000|48.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|1.000|8.000|0.000|0.000|7.000|0.050|0.000|0.030|NA|0.025|8.330|0.000|4.260|0.000|16.000|0.000|202.000|0.000|0.000|0.000 16|SW-2|1991-06-09|0.000|0.000|0.000|216.000|216.000|0.000|0.000|0.000|0.000|61.000|0.000|1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|13.000|0.000|0.000|10.000|0.050|0.000|0.070|NA|0.025|8.350|0.000|6.160|0.000|-2.000|0.000|280.000|0.000|0.000|0.000 17|SW-3|1991-06-09|0.000|0.000|40.000|128.000|168.000|0.000|0.000|0.000|0.000|65.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|5.000|0.000|0.000|4.000|0.050|0.000|0.040|NA|0.025|8.390|0.000|4.700|0.000|25.000|0.000|244.000|0.000|0.000|0.000 18|SW-4|1991-06-09|0.000|0.000|0.000|112.000|112.000|0.000|0.000|0.000|0.000|57.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|6.000|0.000|0.000|5.000|0.050|0.000|0.040|NA|0.025|8.120|0.000|4.700|0.000|78.000|0.000|288.000|0.000|0.000|0.000 19|SW-5|1991-06-09|0.000|0.000|0.000|182.000|182.000|0.000|0.000|0.000|0.000|70.000|0.000|-1.000|0.000|0.000|0.000|NA|0.000|0.000|2.000|6.000|0.000|0.000|5.000|0.050|0.000|0.090|NA|0.025|8.320|0.000|5.800|0.000|33.000|0.000|274.000|0.000|0.000|0.000 20|SW-1|1991-07-23|0.000|0.000|0.000|214.000|214.000|0.000|0.000|0.000|0.000|66.000|0.000|2.000|0.000|0.000|0.000|NA|0.000|0.000|4.000|14.000|0.000|0.000|14.000|0.110|0.000|0.040|NA|0.025|8.280|0.000|0.990|0.000|-2.000|0.000|258.000|0.000|0.000|0.000 And the output I see in out.csv: <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|Ag|1 <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|Al|SW-1 <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|Alk_CO3|1990-10-10 <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|Alk_HCO3|0.000 <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|Alk_tot|0.000 <_csv.writer object at 0x80a141c>|['1', 'SW-1', '1990-10-10']|As|0.000 Note that the first three lines repeat the sample number, site id, and date instead of the value associated with the constituents. I don't see my error(s) and would greatly appreciate a clue stick on what I've done incorrectly. TIA, Rich From dermot at tenbridges.com Tue Nov 22 19:02:07 2011 From: dermot at tenbridges.com (TenBridges.Com) Date: Tue, 22 Nov 2011 10:02:07 -0800 Subject: [portland] Not Seeing Script Error(s) In-Reply-To: References: Message-ID: <1321984927.7010.10.camel@10B-2> Don't know about the rest but this line: outdata.writerow([outdata, row[0:3], parm, rowval]) contains "outdata" which is the object reference you are seeing I believe On Tue, 2011-11-22 at 09:32 -0800, Rich Shepard wrote: > outdata.writerow([outdata, row[0:3], parm, rowval]) -- TenBridges.Com L.L.C. Dermot Maty, Owner 1631 NE Broadway #522 Portland, OR, 97232 pho: 503.427.8362 mob: 503.702.0724 Dermot at tenbridges.com www.tenbridges.com NOTICE: DO NOT read, copy or disseminate this e-mail message unless you are the intended recipient. The information contained in this e-mail message is privileged, confidential and protected from disclosure, and any dissemination, distribution or copying is strictly prohibited by anyone other than the intended recipient. If you think you have received this e-mail message in error, please e-mail the sender at Dermot at tenbridges.com or call (503)427-8362. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rshepard at appl-ecosys.com Tue Nov 22 20:35:42 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 11:35:42 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: <1321984927.7010.10.camel@10B-2> References: <1321984927.7010.10.camel@10B-2> Message-ID: On Tue, 22 Nov 2011, TenBridges.Com wrote: > Don't know about the rest but this line: > outdata.writerow([outdata, row[0:3], parm, rowval]) > contains "outdata" which is the object reference you are seeing I > believe OK. That makes sense. This script is a modified copy of one that worked on a different project. Why the 'outdata' was not an issue there I don't know. So, that clears up one issue. The malformed first three lines remain. Could that be because I don't have the row[] properly indexed? Here are the first 4 lines of output: ['1', 'SW-1', '1990-10-10']||1 ['1', 'SW-1', '1990-10-10']||SW-1 ['1', 'SW-1', '1990-10-10']||1990-10-10 ['1', 'SW-1', '1990-10-10']|Ag|0.000 I could just delete them from the output file but that's a non-elegant kludge. I also need to rework the first three columns so they're not list elements but columns each separated by a pipe. Thanks, Rich From rshepard at appl-ecosys.com Tue Nov 22 20:55:30 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 11:55:30 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: References: <1321984927.7010.10.camel@10B-2> Message-ID: On Tue, 22 Nov 2011, Rich Shepard wrote: > So, that clears up one issue. The malformed first three lines remain. > Could that be because I don't have the row[] properly indexed? Here are the > first 4 lines of output: > > ['1', 'SW-1', '1990-10-10']||1 > ['1', 'SW-1', '1990-10-10']||SW-1 > ['1', 'SW-1', '1990-10-10']||1990-10-10 > ['1', 'SW-1', '1990-10-10']|Ag|0.000 The issue, I believe, is that I'm asking the writer to put the first three tokens in each row in a list (which does not explain why each of the first row's leading columns is in a separate row at the top). What I want to see (and apparently don't know how to achieve) is to have the first three rows above not produced, then all subsequent rows looking like a reformated row 4 above: 1|SW-1|1990-10-10|Ag|0.000 Rich From ethan at stoneleaf.us Tue Nov 22 21:26:23 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 22 Nov 2011 12:26:23 -0800 Subject: [portland] Not Seeing Script Error(s) In-Reply-To: References: <1321984927.7010.10.camel@10B-2> Message-ID: <4ECC056F.6030100@stoneleaf.us> Rich Shepard wrote: > On Tue, 22 Nov 2011, Rich Shepard wrote: > >> So, that clears up one issue. The malformed first three lines remain. >> Could that be because I don't have the row[] properly indexed? Here >> are the >> first 4 lines of output: >> >> ['1', 'SW-1', '1990-10-10']||1 >> ['1', 'SW-1', '1990-10-10']||SW-1 >> ['1', 'SW-1', '1990-10-10']||1990-10-10 >> ['1', 'SW-1', '1990-10-10']|Ag|0.000 > > The issue, I believe, is that I'm asking the writer to put the first > three > tokens in each row in a list (which does not explain why each of the first > row's leading columns is in a separate row at the top). What I want to see > (and apparently don't know how to achieve) is to have the first three rows > above not produced, then all subsequent rows looking like a reformated > row 4 > above: > > 1|SW-1|1990-10-10|Ag|0.000 Making a few modifications to the code I suggested back in January ;) 8<----------------------------------------------------------------------- import csv reader = csv.reader(open("test.txt","rb"), delimiter="|", quotechar="'") output = csv.writer(open("out.txt","wb"), delimiter="|", quotechar="'") # records are in columnar, not row, format all_data = list() col_headers = reader.next() col_header_count = 0 for cell in col_headers: if cell: break col_header_count += 1 col_headers = col_headers[col_header_count:] for row in reader: row = list(row) # keep fieldname separate from values all_data.append((row[:col_header_count], row[col_header_count:])) for row_header, row_data in all_data: for col_header, col_data in zip(col_headers, row_data): output.writerow(row_header + [col_header, col_data]) 8<----------------------------------------------------------------------- ~Ethan~ From rshepard at appl-ecosys.com Tue Nov 22 22:12:45 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 13:12:45 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: <4ECC056F.6030100@stoneleaf.us> References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> Message-ID: On Tue, 22 Nov 2011, Ethan Furman wrote: > Making a few modifications to the code I suggested back in January ;) Thanks, Ethan. I used a shorter version then, but have not successfully modified it. Will take your suggestion and use it. Regards, Rich From rshepard at appl-ecosys.com Tue Nov 22 22:31:24 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 13:31:24 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: <4ECC056F.6030100@stoneleaf.us> References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> Message-ID: On Tue, 22 Nov 2011, Ethan Furman wrote: > reader = csv.reader(open("test.txt","r"), > delimiter="|", > quotechar="'") > output = csv.writer(open("out.txt","w"), > delimiter="|", > quotechar="'") Ethan, How are these opened files closed? csv.reader() and csv.writer() have no close method. Rich From ethan at stoneleaf.us Tue Nov 22 22:53:25 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 22 Nov 2011 13:53:25 -0800 Subject: [portland] Not Seeing Script Error(s) In-Reply-To: References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> Message-ID: <4ECC19D5.3070503@stoneleaf.us> Rich Shepard wrote: > On Tue, 22 Nov 2011, Ethan Furman wrote: > >> reader = csv.reader(open("test.txt","r"), >> delimiter="|", >> quotechar="'") >> output = csv.writer(open("out.txt","w"), >> delimiter="|", >> quotechar="'") > > Ethan, > > How are these opened files closed? csv.reader() and csv.writer() have no > close method. > > Rich They are closed automatically. It's not good practice to do this way, though -- better would be to assign the open files to their own name, then you could 'name.close()' when you were done. ~Ethan~ From rshepard at appl-ecosys.com Wed Nov 23 00:05:41 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 15:05:41 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: <4ECC19D5.3070503@stoneleaf.us> References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> <4ECC19D5.3070503@stoneleaf.us> Message-ID: On Tue, 22 Nov 2011, Ethan Furman wrote: > They are closed automatically. Ah, so. > It's not good practice to do this way, though better would be to assign > the open files to their own name, then you could 'name.close()' when you > were done. Ethan, That's what I thought you did in the lines reader = csv.reader(open(filename,"r"), delimiter="|", quotechar="'") output = csv.writer(open("out.txt","w"), delimiter="|", quotechar="'") but reader.close() and output.close() generated python errors. Rich From ethan at stoneleaf.us Wed Nov 23 00:13:23 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 22 Nov 2011 15:13:23 -0800 Subject: [portland] Not Seeing Script Error(s) In-Reply-To: References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> <4ECC19D5.3070503@stoneleaf.us> Message-ID: <4ECC2C93.4080703@stoneleaf.us> Rich Shepard wrote: > On Tue, 22 Nov 2011, Ethan Furman wrote: > >> They are closed automatically. > > Ah, so. > >> It's not good practice to do this way, though better would be to assign >> the open files to their own name, then you could 'name.close()' when you >> were done. > > Ethan, > > That's what I thought you did in the lines > > reader = csv.reader(open(filename,"r"), > delimiter="|", > quotechar="'") > > output = csv.writer(open("out.txt","w"), > delimiter="|", > quotechar="'") > > but reader.close() and output.close() generated python errors. What's happening there is the two files are being opened, and then those open file objects are being handed into the csv.reader and csv.writer functions, and the result of the two csv.* calls are being assigned to 'reader' and 'output'. Basically, the actual file objects are anonymous. When reader and output go out of scope they are destroyed, and at that point the only references to the two open file objects are lost, and then the open file objects are closed by Python. Like I said, it's better to do it explicity. ;) ~Ethan~ From rshepard at appl-ecosys.com Wed Nov 23 00:37:47 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Tue, 22 Nov 2011 15:37:47 -0800 (PST) Subject: [portland] Not Seeing Script Error(s) In-Reply-To: <4ECC2C93.4080703@stoneleaf.us> References: <1321984927.7010.10.camel@10B-2> <4ECC056F.6030100@stoneleaf.us> <4ECC19D5.3070503@stoneleaf.us> <4ECC2C93.4080703@stoneleaf.us> Message-ID: On Tue, 22 Nov 2011, Ethan Furman wrote: > What's happening there is the two files are being opened, and then those > open file objects are being handed into the csv.reader and csv.writer > functions, and the result of the two csv.* calls are being assigned to > 'reader' and 'output'. Basically, the actual file objects are anonymous. That's what I thought. > When reader and output go out of scope they are destroyed, and at that > point the only references to the two open file objects are lost, and then > the open file objects are closed by Python. Like I said, it's better to do > it explicity. ;) I always explicitly close files. So I'll re-write that code so file names are available. Thanks, Rich From edou4rd at gmail.com Sun Nov 27 19:27:00 2011 From: edou4rd at gmail.com (Edouard Richard) Date: Sun, 27 Nov 2011 19:27:00 +0100 Subject: [portland] looking for Django firms Message-ID: <2FA7A81A-13B9-4C9C-9D62-A9D0D0A559F7@gmail.com> Hello pythoners of Portland ! I'm a student in computer science for 4 years in Bordeaux, France. And I'm looking for a job for a period of 6 months minimum in Portland, a city that attracts me particularly ! My goal is to improve my english and mainly to ride pony ! But I have a problem, I know nobody in Portland ? So I hope you don't mind if I ask to the great Python community of Portland which firms use Django framework. With this information, I could target my research and hope to find something. Thank you very much for your help, And maybe : see you soon ! Best regards, Edouard Richard http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sun Nov 27 20:21:31 2011 From: kirby.urner at gmail.com (kirby urner) Date: Sun, 27 Nov 2011 11:21:31 -0800 Subject: [portland] looking for Django firms In-Reply-To: <2FA7A81A-13B9-4C9C-9D62-A9D0D0A559F7@gmail.com> References: <2FA7A81A-13B9-4C9C-9D62-A9D0D0A559F7@gmail.com> Message-ID: Greetings sir. The important question is do you drink beer (first: are you old enough?) and then, if not, wine or coffee? Thank you for coming to Portland with a willingness to share your skills. The user group meeting we usually have every month changes in character in December and is a bigger mostly open source group. A great opportunity. Pycon is coming up in March in California if you can swing it. Djangoncon just happened in September. Got tweet? Kirby On Sun, Nov 27, 2011 at 10:27 AM, Edouard Richard wrote: > Hello pythoners of Portland ! > > I'm a student in computer science for 4 years in Bordeaux, France. > > And I'm looking for a job for a period of 6 months minimum in Portland, a city that attracts me particularly ! > > My goal is to improve my english and mainly to ride pony ! > > But I have a problem, I know nobody in Portland ? > > So I hope you don't mind if I ask to the great Python community of Portland which firms use Django framework. > > With this information, I could target my research and hope to find something. > > Thank you very much for your help, > > And maybe : see you soon ! > > Best regards, > > Edouard Richard > > http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland > From edou4rd at gmail.com Mon Nov 28 02:30:33 2011 From: edou4rd at gmail.com (Edouard Richard) Date: Mon, 28 Nov 2011 02:30:33 +0100 Subject: [portland] looking for Django firms In-Reply-To: References: <2FA7A81A-13B9-4C9C-9D62-A9D0D0A559F7@gmail.com> Message-ID: <084E94F1-67BB-4B84-9FBF-FADA9E296EF6@gmail.com> Hello Kirby, I'm from Bordeaux, so I drink wine ! I'm often in Germany, so I drink good beer too, And I found only java internships then I know coffee ... I know for DjangoCon, it indicates to me that I will feel comfortable in Portland, but I hope to find a job before ? Thank you for your advice, I really love open source, I use it almost exclusively, I've already contribute on open-source project, but I really need to find a paid job because I have no other income. I hope my project can be realized ! Yes, I have tweeter http://twitter.com/#!/vied12 this is my Google+ https://plus.google.com/110957234125847619587/posts And also my linkedin : http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en Now I have no more secret for you ! Le 27 nov. 2011 ? 20:21, kirby urner a ?crit : > Greetings sir. The important question is do you drink beer (first: > are you old enough?) and then, if not, wine or coffee? > > Thank you for coming to Portland with a willingness to share your skills. > > The user group meeting we usually have every month changes in > character in December and is a bigger mostly open source group. A > great opportunity. > > Pycon is coming up in March in California if you can swing it. > Djangoncon just happened in September. > > Got tweet? > > Kirby > > > On Sun, Nov 27, 2011 at 10:27 AM, Edouard Richard wrote: >> Hello pythoners of Portland ! >> >> I'm a student in computer science for 4 years in Bordeaux, France. >> >> And I'm looking for a job for a period of 6 months minimum in Portland, a city that attracts me particularly ! >> >> My goal is to improve my english and mainly to ride pony ! >> >> But I have a problem, I know nobody in Portland ? >> >> So I hope you don't mind if I ask to the great Python community of Portland which firms use Django framework. >> >> With this information, I could target my research and hope to find something. >> >> Thank you very much for your help, >> >> And maybe : see you soon ! >> >> Best regards, >> >> Edouard Richard >> >> http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> URL: >> _______________________________________________ >> Portland mailing list >> Portland at python.org >> http://mail.python.org/mailman/listinfo/portland >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From michelle at pdxpython.org Mon Nov 28 20:22:24 2011 From: michelle at pdxpython.org (Michelle Rowley) Date: Mon, 28 Nov 2011 11:22:24 -0800 Subject: [portland] looking for Django firms In-Reply-To: <084E94F1-67BB-4B84-9FBF-FADA9E296EF6@gmail.com> References: <2FA7A81A-13B9-4C9C-9D62-A9D0D0A559F7@gmail.com> <084E94F1-67BB-4B84-9FBF-FADA9E296EF6@gmail.com> Message-ID: Bonjour Edouard! You might have an easier time finding something in Portland if you widen your search out to Python jobs in general, instead of just Django jobs. There are many Python houses hiring, including Urban Airship: http://urbanairship.com/company/jobs/ and Emma (they do use some Django): http://myemma.com/meet-us/work-here/. Silicon Florist is a great place to find job listings, but they're not all for Python, so read them carefully: http://siliconflorist.com/jobs/. Bonne chance! Et, quand vous ?tes arriv? ? Portland, je voudrais pratiquer un peu de fran?ais, svp! :) Michelle On Nov 27, 2011, at 5:30 PM, Edouard Richard wrote: > Hello Kirby, > > I'm from Bordeaux, so I drink wine ! > I'm often in Germany, so I drink good beer too, > And I found only java internships then I know coffee ... > > I know for DjangoCon, it indicates to me that I will feel comfortable in Portland, but I hope to find a job before ? > > Thank you for your advice, > > I really love open source, I use it almost exclusively, I've already contribute on open-source project, > but I really need to find a paid job because I have no other income. > > I hope my project can be realized ! > > Yes, I have tweeter http://twitter.com/#!/vied12 > this is my Google+ https://plus.google.com/110957234125847619587/posts > And also my linkedin : http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en > > Now I have no more secret for you ! > > > Le 27 nov. 2011 ? 20:21, kirby urner a ?crit : > >> Greetings sir. The important question is do you drink beer (first: >> are you old enough?) and then, if not, wine or coffee? >> >> Thank you for coming to Portland with a willingness to share your skills. >> >> The user group meeting we usually have every month changes in >> character in December and is a bigger mostly open source group. A >> great opportunity. >> >> Pycon is coming up in March in California if you can swing it. >> Djangoncon just happened in September. >> >> Got tweet? >> >> Kirby >> >> >> On Sun, Nov 27, 2011 at 10:27 AM, Edouard Richard wrote: >>> Hello pythoners of Portland ! >>> >>> I'm a student in computer science for 4 years in Bordeaux, France. >>> >>> And I'm looking for a job for a period of 6 months minimum in Portland, a city that attracts me particularly ! >>> >>> My goal is to improve my english and mainly to ride pony ! >>> >>> But I have a problem, I know nobody in Portland ? >>> >>> So I hope you don't mind if I ask to the great Python community of Portland which firms use Django framework. >>> >>> With this information, I could target my research and hope to find something. >>> >>> Thank you very much for your help, >>> >>> And maybe : see you soon ! >>> >>> Best regards, >>> >>> Edouard Richard >>> >>> http://www.linkedin.com/pub/edouard-richard/3a/a90/10b/en >>> -------------- next part -------------- >>> An HTML attachment was scrubbed... >>> URL: >>> _______________________________________________ >>> Portland mailing list >>> Portland at python.org >>> http://mail.python.org/mailman/listinfo/portland >>> > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > _______________________________________________ > Portland mailing list > Portland at python.org > http://mail.python.org/mailman/listinfo/portland --- Michelle Rowley @pythonchelle michelle at pdxpython.org http://www.meetup.com/pdxpython