Re: [Tutor] Creating class / OOP structure

2013-11-05 Thread Steven D'Aprano
On Tue, Nov 05, 2013 at 03:55:05PM -0800, Johan Martinez wrote: > I need help in modifying my program. Right now it looks as follows: [snip code] > Can someone help me in improving my code? Yes! The first thing to do is get rid of the unnecessary class. This is not Java where you have to write cl

Re: [Tutor] Creating class / OOP structure

2013-11-05 Thread Alan Gauld
On 05/11/13 23:55, Johan Martinez wrote: I need help in modifying my program. Right now it looks as follows: class Filedict(): def __init__(self, fname): self.fname =fname def parse(self): with open(self.fname, 'r') as f: # some file

[Tutor] Creating class / OOP structure

2013-11-05 Thread Johan Martinez
I need help in modifying my program. Right now it looks as follows: class Filedict(): def __init__(self, fname): self.fname =fname def parse(self): with open(self.fname, 'r') as f: # some file search and parsing logic return parsed_fil

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Joel Goldstick
On Tue, Nov 5, 2013 at 2:40 PM, Walter Prins wrote: > Hi, > > > On 5 November 2013 19:02, Danny Yoo wrote: >>> >>> Be extra careful if you're constructing SQL statements from user input. >>> You have probably heard of the term "SQL Injection" or "Bobby Tables", both >>> of which are pretty much t

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Walter Prins
Hi, On 5 November 2013 19:02, Danny Yoo wrote: > Be extra careful if you're constructing SQL statements from user input. >> You have probably heard of the term "SQL Injection" or "Bobby Tables", >> both of which are pretty much the same thing: your user may, intentionally >> or not, input valu

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Danny Yoo
> > > from a SQLite database I get a value by SELECT s from... which normaly is > a string, but can be the NULL value, wich means it is not defined. To put > the value into a form (made by QT) I need a string representation. > > str(s) gives either the string itself (which is good) or "None" (which

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread eryksun
On Mon, Nov 4, 2013 at 11:26 AM, Amal Thomas wrote: > @Dave: thanks.. By the way I am running my codes on a server with about > 100GB ram but I cant afford my code to use 4-5 times the size of the text > file. Now I am using read() / readlines() , these seems to be more > efficient in memory usag

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread William Ray Wing
On Nov 5, 2013, at 11:12 AM, Alan Gauld wrote: > On 05/11/13 02:02, Danny Yoo wrote: > >> To visualize the sheer scale of the problem, see: >> >> http://i.imgur.com/X1Hi1.gif >> >> which would normally be funny, except that it's not quite a joke. :P > > I think I'm missing something. All I s

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Peter Otten
Ulrich Goebel wrote: > Hallo, > > from a SQLite database I get a value by SELECT s from... which normaly > is a string, but can be the NULL value, wich means it is not defined. To > put the value into a form (made by QT) I need a string representation. > > str(s) gives either the string itself (

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Steven D'Aprano
On Mon, Nov 04, 2013 at 11:34:01AM +0100, Ulrich Goebel wrote: > Hallo, > > from a SQLite database I get a value by SELECT s from... which normaly > is a string, but can be the NULL value, wich means it is not defined. To > put the value into a form (made by QT) I need a string representation. >

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread Steven D'Aprano
On Tue, Nov 05, 2013 at 04:12:51PM +, Alan Gauld wrote: > On 05/11/13 02:02, Danny Yoo wrote: > > >To visualize the sheer scale of the problem, see: > > > >http://i.imgur.com/X1Hi1.gif > > > >which would normally be funny, except that it's not quite a joke. :P > > I think I'm missing somethi

Re: [Tutor] String representation of NULL (non type) values

2013-11-05 Thread Joel Goldstick
On Mon, Nov 4, 2013 at 5:34 AM, Ulrich Goebel wrote: > Hallo, > > from a SQLite database I get a value by SELECT s from... which normaly is a > string, but can be the NULL value, wich means it is not defined. To put the > value into a form (made by QT) I need a string representation. > > str(s) gi

[Tutor] String representation of NULL (non type) values

2013-11-05 Thread Ulrich Goebel
Hallo, from a SQLite database I get a value by SELECT s from... which normaly is a string, but can be the NULL value, wich means it is not defined. To put the value into a form (made by QT) I need a string representation. str(s) gives either the string itself (which is good) or "None" (which

[Tutor] output generates a sentence made up of words

2013-11-05 Thread Blomquist Mikael
Hi, here is the new code ... just leave a space behind every word. import random def wordList(): adj1 = ["Big ", "Small ", "Early ", "Late ", "Red ", "Tall ", "Short "] subj = ["politician ", "man ", "woman ", "whale ", "company ", "child ", "soldier "] obj = ["budget ", "money ", "box ", "gift

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread Alan Gauld
On 05/11/13 02:02, Danny Yoo wrote: To visualize the sheer scale of the problem, see: http://i.imgur.com/X1Hi1.gif which would normally be funny, except that it's not quite a joke. :P I think I'm missing something. All I see in Firefox is a vertical red bar. And in Chrome I don't even get t

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread Oscar Benjamin
On 5 November 2013 13:20, Amal Thomas wrote: > On Mon, Nov 4, 2013 at 10:00 PM, Steven D'Aprano > wrote: >> > >> >> import os >> filename = "YOUR FILE NAME HERE" >> print("File size:", os.stat(filename).st_size) >> f = open(filename) >> content = f.read() >> print("Length of content actually read

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread Oscar Benjamin
On 4 November 2013 17:41, Amal Thomas wrote: > @Steven: Thank you...My input data is basically AUGC and newlines... I would > like to know about bytearray technique. Please suggest me some links or > reference.. I will go through the profiler and check whether the code > maintains linearity with t

Re: [Tutor] Load Entire File into memory

2013-11-05 Thread Amal Thomas
On Mon, Nov 4, 2013 at 10:00 PM, Steven D'Aprano wrote: > > > import os > filename = "YOUR FILE NAME HERE" > print("File size:", os.stat(filename).st_size) > f = open(filename) > content = f.read() > print("Length of content actually read:", len(content)) > print("Current file position:", f.tell(