Re: [Tutor] From SQL Blobs to Python Buffers to Actual Files

2010-06-03 Thread Steven D'Aprano
On Fri, 4 Jun 2010 10:57:07 am GoodPotatoes wrote: > I have been given a legacy database, and need to read the binaryfiles > out to a disk. The table has columns "filename" and "binaryFile", > where the binaryFile is a BLOB > > My python script so far is: > > import pyodbc > cnxn=pyodbc.Connectio

[Tutor] From SQL Blobs to Python Buffers to Actual Files

2010-06-03 Thread GoodPotatoes
Environment: Sybase/ODBC/Windows/Python2.5 I have been given a legacy database, and need to read the binaryfiles out to a disk. The table has columns "filename" and "binaryFile", where the binaryFile is a BLOB My python script so far is: import pyodbc cnxn=pyodbc.Connection("DSN=sybasedatabas

Re: [Tutor] Misc question about scoping

2010-06-03 Thread Steven D'Aprano
On Fri, 4 Jun 2010 03:10:41 am Alan Gauld wrote: > "Tino Dai" wrote > > >Is there a way to express this: > >isThumbnail = False > >if size == "thumbnail": > >isThumbnail = True > > > > like this: > > [ isThumbnail = True if size == "thumbnail" isThumbnail = > > False ]

Re: [Tutor] Fw: Misc question about scoping

2010-06-03 Thread Steven D'Aprano
On Fri, 4 Jun 2010 09:00:13 am ALAN GAULD quoted Tino Dai who wrote: > "Tino Dai" wrote [...] > >> I have code that is unpythonic in many places. It works, but > >> it's ugly. One of those unpythonic places is I'm initializing some > >> variable such as a list,dict, or whatever outside of if/

Re: [Tutor] parse text file

2010-06-03 Thread Steven D'Aprano
On Fri, 4 Jun 2010 12:45:52 am Colin Talbert wrote: > I thought when you did a for uline in input_file each single line > would go into memory independently, not the entire file. for line in file: reads one line at a time, but file.read() tries to read everything in one go. However, it should f

[Tutor] Fw: Misc question about scoping

2010-06-03 Thread ALAN GAULD
Fowarding to the list. Remember to use Reply ALL when replying. Alan G. "Tino Dai" wrote >>> >>> >>> Is there a way to express this: isThumbnail = False if size == "thumbnail": isThumbnail = True like this: [ isThumbnail

Re: [Tutor] sockets, servers, clients, broadcasts...?

2010-06-03 Thread Alan Gauld
"Alex Hall" wrote *somehow, your instance of the program starts up a server that broadcasts something; your enemy has selected "client", and is now (SOMEHOW) listening for the signal your server is broadcasting *the signal is picked up, and, SOMEHOW, you and your opponent connect and can sta

Re: [Tutor] Misc question about scoping

2010-06-03 Thread Emile van Sebille
On 6/3/2010 8:50 AM Tino Dai said... Hi All, Is there a way to express this: isThumbnail = False if size == "thumbnail": isThumbnail = True like this: [ isThumbnail = True if size == "thumbnail" isThumbnail = False ] and the scoping extending to one lev

Re: [Tutor] parse text file

2010-06-03 Thread Sander Sweers
On 3 June 2010 21:02, Colin Talbert wrote: > I couldn't find any example of it in use and wasn't having any luck getting > it to work based on the documentation. Good examples of the bz2 module can be found at [1]. greets Sander [1] http://www.doughellmann.com/PyMOTW/bz2/

[Tutor] sockets, servers, clients, broadcasts...?

2010-06-03 Thread Alex Hall
Hi all, I am a CS major, so I have had the required networking class. I get the principles of networking, sockets, and packets, but I have never had to actually implement any such principles in any program. Now I have this Battleship game (not a school assignment, just a summer project) that I am t

Re: [Tutor] parse text file

2010-06-03 Thread Vincent Davis
On Thu, Jun 3, 2010 at 1:02 PM, Colin Talbert wrote: > > Dave, > I think you are probably right about using decompressor. I > couldn't find any example of it in use and wasn't having any luck getting it > to work based on the documentation. Maybe I should try harder on this > front. >

Re: [Tutor] Misc question about scoping

2010-06-03 Thread spir
On Thu, 3 Jun 2010 11:50:42 -0400 Tino Dai wrote: > Hi All, > > Is there a way to express this: > isThumbnail = False > if size == "thumbnail": > isThumbnail = True > > like this: > [ isThumbnail = True if size == "thumbnail" isThumbnail = False ] > and the sc

Re: [Tutor] parse text file

2010-06-03 Thread Colin Talbert
Dave, I think you are probably right about using decompressor. I couldn't find any example of it in use and wasn't having any luck getting it to work based on the documentation. Maybe I should try harder on this front. Colin Talbert GIS Specialist US Geological Survey - Fort Collins S

Re: [Tutor] parse text file

2010-06-03 Thread Dave Angel
Colin Talbert wrote: You are so correct. I'd been trying numerous things to read in this file and had deleted the code that I meant to put here and so wrote this from memory incorrectly. The code that I wrote should have been: import bz2 input_file = bz2.BZ2File(r'C:\temp\planet-latest.osm

Re: [Tutor] parse text file

2010-06-03 Thread Alan Gauld
"Colin Talbert" wrote I thought when you did a for uline in input_file each single line would go into memory independently, not the entire file. Thats true but your code snippet showed you using read() which reads the whole file... I'm pretty sure that this is not your code, because you ca

Re: [Tutor] Misc question about scoping

2010-06-03 Thread Alan Gauld
"Tino Dai" wrote Is there a way to express this: isThumbnail = False if size == "thumbnail": isThumbnail = True like this: [ isThumbnail = True if size == "thumbnail" isThumbnail = False ] Bob showed one way, you could also do: isThumbnail = True if size == "thumbna

Re: [Tutor] Misc question about scoping

2010-06-03 Thread bob gailer
On 6/3/2010 11:50 AM, Tino Dai wrote: Hi All, Is there a way to express this: isThumbnail = False if size == "thumbnail": isThumbnail = True How I do that is: isThumbnail = size == "thumbnail": like this: [ isThumbnail = True if size == "thumbnail" isThumbnail

Re: [Tutor] OOP clarification needed

2010-06-03 Thread Lie Ryan
On 06/03/10 01:37, Jim Byrnes wrote: > >>> some older procedural languages I always end up becoming confused by >>> the large number of built in methods. >> >> C is one of the simplest procedural languages around >> and yet it comes with a huge library of functions (several >> hundred in some case

[Tutor] Misc question about scoping

2010-06-03 Thread Tino Dai
Hi All, Is there a way to express this: isThumbnail = False if size == "thumbnail": isThumbnail = True like this: [ isThumbnail = True if size == "thumbnail" isThumbnail = False ] and the scoping extending to one level above without resorting to the global keywo

Re: [Tutor] parse text file

2010-06-03 Thread Colin Talbert
Hello Steven, Thanks for the reply. Also this is my first post to tu...@python so I'll reply all in the future. However, a file of that size changes things drastically. You can't expect to necessarily be able to read the entire 9.2 gigabyte BZ2 file into memory at once, let along the