Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-05 Thread Dan Sommers
On Sun, 06 Oct 2013 12:19:13 +1100, Chris Angelico wrote: > On Sun, Oct 6, 2013 at 12:05 PM, Ben Finney wrote: [ ... ] >> With a separately-installed, far more complex database engine like >> MySQL or PostgreSQL, the Python bindings will only work if they are >> compiled against the correct clie

Re: how to read list from file

2013-10-05 Thread Terry Reedy
On 10/5/2013 9:08 PM, Harvey Greenberg wrote: I am looping as for L in file.readlines(), where file is csv. I believe 'for L in file:' does the same, more efficiently, even in 2.7. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 6/10/2013 2:36 πμ, ο/η Denis McMahon έγραψε: On Sat, 05 Oct 2013 16:38:14 +0300, Νίκος Αλεξόπουλος wrote: [my cookie code is fucked] Hi Nick I had never used python for www before yesterday. I had never used python before about 6 months ago. In the last 24 hours I have installed mod-ws

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Steven D'Aprano
On Sat, 05 Oct 2013 20:17:32 -0700, galeomaga wrote: > if __name__ == '__main__': > try: > thread.start_new_thread( readfile, ("Thread-1", ) ) > except: > print "Error: unable to start thread" Why not? If you can't start a thread, you have a problem with

Variable arguments (*args, **kwargs): seeking elegance

2013-10-05 Thread John Ladasky
Hi folks, I'm trying to make some of Python class definitions behave like the ones I find in professional packages, such as Matplotlib. A Matplotlib class can often have a very large number of arguments -- some of which may be optional, some of which will assume default values if the user does

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 2:17 PM, wrote: > After tried many times, updated text file is not shown, it only print text at > the first time. The implementation of tail has a lot of little oddities to deal with edge cases. Why not simply use it? A while ago, I wanted to make a system that would tai

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
Joost Molenaar於 2013年10月5日星期六UTC+8下午7時02分05秒寫道: > A bit of googling found me this: > > http://www.linux-support.com/cms/implementation-of-tail-in-python/ > > > > import time > > import sys > > > > def tail_f(file): > > interval = 1.0 > > while True: > > where = file.tell() > >

Re: how to read list from file

2013-10-05 Thread Roy Smith
In article , Tim Chase wrote: > sounds like you want ast.literal_eval(): This sounds like a better idea than either of my earlier suggestions! -- https://mail.python.org/mailman/listinfo/python-list

Re: how to read list from file

2013-10-05 Thread Roy Smith
In article , Harvey Greenberg wrote: > I am looping as for L in file.readlines(), where file is csv. > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first > item is a dir and 2nd is a list, so parsing with split doesn't work. Is > there a way to convert L, which i

Re: how to read list from file

2013-10-05 Thread Tim Chase
On 2013-10-05 18:08, Harvey Greenberg wrote: > I am looping as for L in file.readlines(), where file is csv. > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that > the first item is a dir and 2nd is a list, so parsing with split > doesn't work. Is there a way to convert L, whic

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 12:05 PM, Ben Finney wrote: > The Python bindings for MySQL or PostgreSQL, or even SQLite, are tied to > extension libraries for the specific database engine. > > With SQLite this is not a problem for Python's release management, > because Python's release includes the entir

how to read list from file

2013-10-05 Thread Harvey Greenberg
I am looping as for L in file.readlines(), where file is csv. L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first item is a dir and 2nd is a list, so parsing with split doesn't work. Is there a way to convert L, which is a string, to the list of 3 items I want? -- ht

Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-05 Thread Ben Finney
Chris Angelico writes: > It's because of threads like this that I would really like Python to > nudge people towards something stronger than MySQL. Would it kill > Python to incorporate PostgreSQL bindings automatically? I'm not sure what would count as “kill Python”. It would certainly make the

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Denis McMahon
On Sat, 05 Oct 2013 16:38:14 +0300, Νίκος Αλεξόπουλος wrote: > [my cookie code is fucked] Hi Nick I had never used python for www before yesterday. I had never used python before about 6 months ago. In the last 24 hours I have installed mod-wsgi on my apache web server, and written test code

Re: Database statements via python but database left intact

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 8:39 AM, Ned Batchelder wrote: > Now is a good time to go read about transactions, and committing, and the > difference between MyISAM and InnoDB. Please don't ask more about it here. It's because of threads like this that I would really like Python to nudge people towards

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 1:31 AM, Νίκος Αλεξόπουλος wrote: > # find the visitor record for the (saved) cID and current > host > cur.execute('''SELECT * FROM visitors WHERE counterID = %s > and cookieID = %s''', (cID, cookieID) ) > > data = cur.fetchone

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Terry Reedy
On 10/5/2013 9:38 AM, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['I

Re: feature requests

2013-10-05 Thread Terry Reedy
On 10/5/2013 11:58 AM, Ethan Furman wrote: On 10/05/2013 05:49 AM, macker wrote: Ugly, menial lines are a clue that a function to hide it could be useful. Or a clue to add a trivial change elsewhere (hint for Ethan: `return self` at the end of `Thread.start()`). I'm aware that would solve y

Re: Database statements via python but database left intact

2013-10-05 Thread Ned Batchelder
On 10/5/13 5:02 PM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 11:31 μμ, ο/η Ian Kelly έγραψε: Well, have you changed anything in your database configuration? Whether MySQL uses transactions or not depends on which storage engine is being used. I suggest running a test insert with and without comm

Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 11:31 μμ, ο/η Ian Kelly έγραψε: Well, have you changed anything in your database configuration? Whether MySQL uses transactions or not depends on which storage engine is being used. I suggest running a test insert with and without commit to check whether you actually need it or no

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Benjamin Rovny
On Oct 5, 2013 8:42 AM, "Νίκος Αλεξόπουλος" wrote: > > # initialize cookie > cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) > cookie.load( cookie ) > vip = cookie.get('ID') > > ... > ... > > # if browser cookie does not exist, set it > vip = random.randrange(0, 1) > coo

Re: Database statements via python but database left intact

2013-10-05 Thread Ian Kelly
On Sat, Oct 5, 2013 at 1:36 PM, Νίκος Αλεξόπουλος wrote: > Στις 5/10/2013 10:29 μμ, ο/η Zero Piraeus έγραψε: >> >> : >> >> On Sat, Oct 05, 2013 at 10:16:46PM +0300, Νίκος Αλεξόπουλος wrote: >>> >>> Excuse me for asking again today, but i see no error in the >>> following code, yes no isertion or u

Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 10:29 μμ, ο/η Zero Piraeus έγραψε: : On Sat, Oct 05, 2013 at 10:16:46PM +0300, Νίκος Αλεξόπουλος wrote: Excuse me for asking again today, but i see no error in the following code, yes no isertion or update happens into the database: [...] When this code runs i check instantly m

Re: Database statements via python but database left intact

2013-10-05 Thread Zero Piraeus
: On Sat, Oct 05, 2013 at 10:16:46PM +0300, Νίκος Αλεξόπουλος wrote: > Excuse me for asking again today, but i see no error in the > following code, yes no isertion or update happens into the database: > > [...] > > When this code runs i check instantly my database via PHPMyAdmin and > i see tha

Re: Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος
Actually the whole code is this: # = # DATABASE INSERTS - # = if cooki

Re: Why didn't my threads exit correctly ?

2013-10-05 Thread Piet van Oostrum
李洛 writes: > Thanks for your reply, MRAB. > > I've seen that the child thread has been stoped, it just died in the queue.If > I want the queue be > empty, I must use queue.get() to dequeue and clean it, but I didn't do that. > I've implement the thread using List now, thanks again. Also make su

Database statements via python but database left intact

2013-10-05 Thread Νίκος Αλεξόπουλος
Excuse me for asking again today, but i see no error in the following code, yes no isertion or update happens into the database: try: # locate the ID of the page's URL cur.execute('''SELECT ID FROM counters WHERE url = %s''', page ) data = cur.fetchone() #URL is unique, so should only

Re: [OT] Re: Hyper-spacial ray-tracer

2013-10-05 Thread Rouslan Korneychuk
On 10/05/2013 11:26 AM, Peter Pearson wrote: On Fri, 04 Oct 2013 20:17:52 -0400, Rouslan Korneychuk wrote: [snip] I was also wondering about general relativity. I'm not going to go into too much detail, but basically: if an object with synchronized clocks on either end of it, passes by a static

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:56 μμ, ο/η Andreas Perstinger έγραψε: On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> pri

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> print(cookie1) Set-Cookie: ID="Set-Cookie: ID=42" >>> cookie1.

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:42 μμ, ο/η Ned Batchelder έγραψε: A better solution is to check to see if you got None: if cookie.get('ID') is None: # make a new cookie I have tried everythign even wgat you suggested right now: here is is: # initialize cookie and retrieve cookie from clie

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread MRAB
On 05/10/2013 15:44, Zero Piraeus wrote: On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote: Every mysql statemtns that involved cookieID fails. in this example this: # find the visitor record for the (saved) cID and current host cur.execute('''SELECT * FROM visitors WHERE count

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 12:17 PM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 7:14 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrot

Re: feature requests

2013-10-05 Thread Ethan Furman
On 10/05/2013 05:49 AM, macker wrote: Ugly, menial lines are a clue that a function to hide it could be useful. Or a clue to add a trivial change elsewhere (hint for Ethan: `return self` at the end of `Thread.start()`). I'm aware that would solve your issue. I'm also aware that Python rare

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Zero Piraeus
: On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote: > Every mysql statemtns that involved cookieID fails. > > in this example this: > > # find the visitor record for the (saved) cID and current host > cur.execute('''SELECT * FROM visitors WHERE counterID = %s and > cookieID = %s

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:14 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έ

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can s

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried t

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:06 μμ, ο/η Zero Piraeus έγραψε: : On Sat, Oct 05, 2013 at 05:40:23PM +0300, Νίκος Αλεξόπουλος wrote: When i print CookieID i was under the impression i would see a random number like '5369' but instead it display the follwong. Set-Cookie: ID="Set-Cookie: ID=5369" On Sat, Oct

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 17:31, Νίκος Αλεξόπουλος wrote: Now i have it like this: # connect to database con = pymysql.connect( db = 'nikos_metrites', user = 'nikos_root', passwd = 't1abhp2r!', charset = 'utf8', host = 'localhost' ) Just to be sure: That's not your real password, is it? Bye, Andreas --

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried t

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Zero Piraeus
: On Sat, Oct 05, 2013 at 05:40:23PM +0300, Νίκος Αλεξόπουλος wrote: > When i print CookieID i was under the impression i would see a > random number like '5369' but instead it display the follwong. > > Set-Cookie: ID="Set-Cookie: ID=5369" On Sat, Oct 05, 2013 at 05:47:54PM +0300, Νίκος Αλεξόπου

[OT] Re: Hyper-spacial ray-tracer

2013-10-05 Thread Peter Pearson
On Fri, 04 Oct 2013 20:17:52 -0400, Rouslan Korneychuk wrote: [snip] > I was also wondering about general relativity. I'm not going to go into > too much detail, but basically: if an object with synchronized clocks on > either end of it, passes by a static observer while traveling near the > sp

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:43 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:30 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and MySQL doesn't know what to do with that object

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:30 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are no

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are not the same line of code. You still have not sho

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:24 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε: On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s,

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: > But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are not the same line of code. You still have not shown us the actual line from the traceback. ChrisA --

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε: On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, vip, host, city, useros, browser,

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: > cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, > useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', > (cID, vip, host, city, useros, browser, ref, lastvisit) ) > ===

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 9:38 AM, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['ID'

Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
# initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['ID']['path'] = '/' # fir

Re: feature requests

2013-10-05 Thread macker
> > Ugly, menial lines are a clue that a function to hide it could be useful. Or a clue to add a trivial change elsewhere (hint for Ethan: `return self` at the end of `Thread.start()`). > Have you verified that this is a problem in Python? ? > You could try subclassing. I could try many thin

Re: Where does MySQLdb put inserted data?

2013-10-05 Thread Mark Lawrence
On 05/10/2013 09:39, F.R. wrote: On 10/05/2013 12:55 AM, Dennis Lee Bieber wrote: On Fri, 04 Oct 2013 09:38:41 +0200, "F.R." declaimed the following: MySQLdb, as with all DB-API compliant adapters, does NOT do "auto-commit" -- you MUST execute a con.commit() after any query (sequence) th

Re: Where does MySQLdb put inserted data?

2013-10-05 Thread F.R.
On 10/05/2013 12:55 AM, Dennis Lee Bieber wrote: On Fri, 04 Oct 2013 09:38:41 +0200, "F.R." declaimed the following: MySQLdb, as with all DB-API compliant adapters, does NOT do "auto-commit" -- you MUST execute a con.commit() after any query (sequence) that modifies data. Without it,

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 12:02, Joost Molenaar wrote: A bit of googling found me this: http://www.linux-support.com/cms/implementation-of-tail-in-python/ import time import sys def tail_f(file): interval = 1.0 while True: where = file.tell() line = file.readline() if not line:

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Joost Molenaar
A bit of googling found me this: http://www.linux-support.com/cms/implementation-of-tail-in-python/ import time import sys def tail_f(file): interval = 1.0 while True: where = file.tell() line = file.readline() if not line: time.sleep(interval) file.seek(where) els

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Nobody
On Sat, 05 Oct 2013 00:38:51 -0700, galeomaga wrote: > #!/usr/bin/python > import time > f = open('/home/martin/Downloads/a.txt') > while 1: > for line in f: > print line; > time.sleep(1); So you're trying to implement "tail -f"? First, check that "tail -f" actually wor

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 09:06, James Harris wrote: wrote in message news:04ee91f9-1cbf-4364-bca3-da25aa4db...@googlegroups.com... #!/usr/bin/python import time f = open('/home/martin/Downloads/a.txt') Looks like you are on Unix so you can do this from the shell tail -F /home/martin/Downloads/a.tx

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread Mark Lawrence
On 05/10/2013 08:54, galeom...@gmail.com wrote: if __name__ == '__main__': logfile = open("/home/martin/Downloads/a.txt","r"); while True: line = logfile.readline(); if not line: print line; time.sleep(1); this also failed Usually please s

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread James Harris
wrote in message news:04ee91f9-1cbf-4364-bca3-da25aa4db...@googlegroups.com... > > > #!/usr/bin/python > import time > f = open('/home/martin/Downloads/a.txt') Looks like you are on Unix so you can do this from the shell tail -F /home/martin/Downloads/a.txt James -- https://mail.python.or

Re: How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
gale...@gmail.com於 2013年10月5日星期六UTC+8下午3時38分51秒寫道: > #!/usr/bin/python > > import time > > f = open('/home/martin/Downloads/a.txt') > > while 1: > > for line in f: > > print line; > > time.sleep(1); if __name__ == '__main__': logfile = open("/home/martin/Downlo

Re: Tail recursion to while iteration in 2 easy steps

2013-10-05 Thread Antoon Pardon
Op 04-10-13 23:14, Terry Reedy schreef: On 10/4/2013 6:46 AM, Ian Kelly wrote: On the other hand, if you start optimizing every tail call and not just the recursive functions, then I can see where that could start to get problematic for debugging -- as arbitrary functions get removed from the s

How to streamingly read text file and display whenever updated text

2013-10-05 Thread galeomaga
#!/usr/bin/python import time f = open('/home/martin/Downloads/a.txt') while 1: for line in f: print line; time.sleep(1); -- https://mail.python.org/mailman/listinfo/python-list