[Tutor] rsync python script

2008-03-21 Thread Kaushal Shriyan
Hi [EMAIL PROTECTED] 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ If i put this two lines in crontab it will run correctly,My requirement was to create a python script, this python script should indicate success or failures and the reason for failure Any ideas Thanks and Rega

Re: [Tutor] Help this newbie

2008-03-21 Thread Alan Gauld
"Elliot Silvers" <[EMAIL PROTECTED]> wrote > I am as new as you can get to Python. I have just learned > how to save my work (very simple work of course). > I created a folder on C:\ (in this case C:\Elliot) for my work. > I am able to use the cmd prompt to run it Congratulations. You should

Re: [Tutor] grammer

2008-03-21 Thread Alan Gauld
"Eric Walker" <[EMAIL PROTECTED]> wrote > I have been reading about python grammers for processing > text files. Does anyone have any simple examples? Can you give us a context? eg. Where were you doing the reading? Alan G ___ Tutor maillist - Tu

Re: [Tutor] Calling super classs __init__?

2008-03-21 Thread Andreas Kostyrka
It does not return them at once. It returns them piece by piece: [EMAIL PROTECTED]:/tmp> cat mro.py class A(object): v=lambda self: "A" class B(object): v=lambda self: "B" class C(B,A): v=lambda self: "C" print C.__mro__ c=C() print c.v() print super(C, c).v() print super(B, c).v()

Re: [Tutor] rsync python script

2008-03-21 Thread Tom Tucker
The success or failure could be confirmed by checking the exit status and/or confirming host77 has the same /var/lib file structure as the source host. The later is the most accurate, however a bit more complicated to confirm. As for determining the reason for failure, possible causes off the top o

Re: [Tutor] Calling super classs __init__?

2008-03-21 Thread Kent Johnson
tiger12506 wrote: > Also, does anyone want to clarify? I thought that super() only return one of > the base classes and was frowned upon for objects using multiple > inheritance??? super() returns the next class in method-resolution order. super() was added to the language specifically to add

Re: [Tutor] grammer

2008-03-21 Thread Kent Johnson
Eric Walker wrote: > Hello, > I have been reading about python grammers for processing text files. Does > anyone have any simple examples? Do you mean parsers written in Python for processing text files? A grammar is usually an abstract specification of a format, not something that will actuall

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
This is why I should not be allowed to write emails at the end of the day. At least ones that need deep explanation. Let's try this a second time. I am running virt-top on a Xen box. This grabs information about various things. I can set how many iterations of it I want to run. I only have it

Re: [Tutor] Calling super classs __init__?

2008-03-21 Thread tiger12506
So super(A, c) refers to the baseclass object? I don't like this. It partially suggests that A is a superclass of B. I guess I have to be sure to notice the second parameter which tells of which instance I'm finding the superclass. fyi I totally didn't notice the first parameter of super... was

Re: [Tutor] CSV file processing...

2008-03-21 Thread Eric Walstad
Hey Spencer, Spencer Parker wrote: > This is why I should not be allowed to write emails at the end of the > day. At least ones that need deep explanation. Let's try this a second > time. Thanks, this looks better, but... > This is what I have now... *What isn't working* the way you want? T

Re: [Tutor] rsync python script

2008-03-21 Thread Eric Walstad
Kaushal Shriyan wrote: > Hi > > [EMAIL PROTECTED] > 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ > > If i put this two lines in crontab it will run correctly,My requirement > was to create a python script, this python script should indicate > succes

Re: [Tutor] rsync python script

2008-03-21 Thread Kaushal Shriyan
On Fri, Mar 21, 2008 at 9:40 PM, Eric Walstad <[EMAIL PROTECTED]> wrote: > Kaushal Shriyan wrote: > > Hi > > > > [EMAIL PROTECTED] > > 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/ > > > > If i put this two lines in crontab it will run correctly,My requ

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
So if my long row is row two...how do I tell it to use row 2? On Thu, Mar 20, 2008 at 5:42 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Spencer Parker wrote: > > I am trying to read a CSV file and the get that information into a MySQL > > database. I am able to do this, but I have a small probl

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > So if my long row is row two...how do I tell it to use row 2? csv_data = csv.reader(file('output.txt','r')) headers = csv_data.next() # Skip header row row = csv_data.next() # The row with data Kent ___ Tutor maillist - Tutor@p

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
Okay...so I got it mostly working...it now dies with this trackback: Traceback (most recent call last): File "./loadcsv.py", line 23, in ? co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) On Fri, Mar 21,

[Tutor] More Converter

2008-03-21 Thread wackedd
I am still in need of more help. Currently I am just trying to get one conversion down, as then I can duplicate it. However I am not sure how to make it Convert. Currently I am working with: # Converter Original = raw_input("Insert inches, feet ") To = raw_input("Insert inches, feet ") Variable

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > Okay...so I got it mostly working...it now dies with this trackback: It would be helpful to see what 'it' is (i.e. your code), and also to see the actual error message as well as the traceback. We try to read minds on this group but we aren't really very good at it. Kent

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
I posted it in a previous message on the list...but here it is... #!/usr/bin/python import MySQLdb import csv import sys try: db = MySQLdb.connect (host = "localhost",user = "root",passwd = "Ch33s3Monk3y",db = "xenstats") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > I posted it in a previous message on the list...but here it is... Looks new to me... > > #!/usr/bin/python > > import MySQLdb > import csv > import sys > > try: > db = MySQLdb.connect (host = "localhost",user = "root",passwd = > "Ch33s3Monk3y",db = "xenstats") > exc

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
This is all that I get when I run it... Traceback (most recent call last): File "./loadcsv.py", line 23, in ? co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) TypeError: not all arguments converted during

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
That loop was some weird indentation that was caused when I pasted it...it wasn't suppose to be indented like that... On Fri, Mar 21, 2008 at 1:42 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > This is all that I get when I run it... > > Traceback (most recent call last): > File "./loadcsv.py"

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
I took that loop out...I had that in from something else and forgot to take it out...I took it out and it still does the same error. On Fri, Mar 21, 2008 at 1:44 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > That loop was some weird indentation that was caused when I pasted it...it > wasn't sup

Re: [Tutor] CSV file processing...

2008-03-21 Thread Marc Tompkins
On Fri, Mar 21, 2008 at 12:42 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > This is all that I get when I run it... > > Traceback (most recent call last): > File "./loadcsv.py", line 23, in ? > co.execute(""" > File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, > in

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > That loop was some weird indentation that was caused when I pasted > it...it wasn't suppose to be indented like that... Why is it there at all? The loop with range() is the one that is generating the data you want to store. > This is all that I get when I run it... >

Re: [Tutor] CSV file processing...

2008-03-21 Thread Marc Tompkins
Sorry... no, it still shouldn't work... maybe like so: co.execute('''INSERT INTO stats VALUES("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % row''') > You have triple quotes around your SQL. That means that "implied" line > breaks become real. It won't look as ni

Re: [Tutor] CSV file processing...

2008-03-21 Thread Spencer Parker
Okay...so this is what I have now.. co.execute(""" File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args) TypeError: not enough arguments for format string [EMAIL PROTECTED] ~]$ vim loadcsv.py [EMAIL PROTECTED] ~]$ vim output.t

[Tutor] Python Grammer

2008-03-21 Thread Eric Walker
Did anyone respond to my Python Grammer Question? Thanks Eric Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wc

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Spencer Parker wrote: > Okay...so this is what I have now.. Do you really expect us to read through this? If you can't be bothered to compose a decent question and read the answers then neither can I. Kent ___ Tutor maillist - [email protected] http:/

Re: [Tutor] CSV file processing...

2008-03-21 Thread Kent Johnson
Marc Tompkins wrote: > Sorry... no, it still shouldn't work... > maybe like so: > co.execute('''INSERT INTO stats > VALUES("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" > > % row''') > > > You have triple quotes around your SQL. That means that "implied" >

Re: [Tutor] Python to C++

2008-03-21 Thread Dinesh B Vadhia
Thank-you for all the suggestions for converting to C/C++ which will be followed up. Can we interface Python to a C++ library and if so how? Dinesh Date: Thu, 20 Mar 2008 17:21:52 - From: "Alan Gauld" <[EMAIL

Re: [Tutor] Python Grammer

2008-03-21 Thread Eric Walker
Ok, I found the responses, sorry.. I have been reading the book "Text Processing in PYTHON" by David Mertz. I have some text that I have to parse. I want to use grammers. I can't seem to understand how the syntax works. something like: hello := Thanks in Advance Eric _

Re: [Tutor] More Converter

2008-03-21 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > Original = raw_input("Insert inches, feet ") > To = raw_input("Insert inches, feet ") > Variable = int(raw_input("Insert Amount to Convert ")) Up to here is OK. > if Original == raw_input(feet) and To == raw_input(inches): But here you get a bit confused. raw_input

Re: [Tutor] Python Grammer

2008-03-21 Thread Alan Gauld
"Eric Walker" <[EMAIL PROTECTED]> wrote . > I have some text that I have to parse. I want to use grammers. > I can't seem to understand how the syntax works. > something like: > hello := OK, Thats somethjing called Backaus Naur Format (or BNF), try Googling for it - or Wikipedia - and you will g

[Tutor] returning two values

2008-03-21 Thread elis aeris
is it possible to return two values? ___ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor

[Tutor] list

2008-03-21 Thread elis aeris
how do I create an empy int array of 10? ___ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor

[Tutor] append string

2008-03-21 Thread elis aeris
how do I append to the end of strings? ___ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor

[Tutor] int to string

2008-03-21 Thread elis aeris
how do I convert int to string? ___ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] returning two values

2008-03-21 Thread Gregor Lingl
elis aeris schrieb: is it possible to return two values? Yes: >>> def return2(): return "this", "that" >>> return2() ('this', 'that') >>> a,b=return2() >>> a 'this' >>> b 'that' >>> Regards, Gregor _

Re: [Tutor] returning two values

2008-03-21 Thread Steve Willoughby
elis aeris wrote: > is it possible to return two values? Yes and no. You can return "a" value, but that value may itself be a tuple of values. Or a list, dictionary or other kind of object. > how do I create an empy int array of 10? If an int array has 10 things in it, it's not empty. You do

Re: [Tutor] returning two values

2008-03-21 Thread elis aeris
oh this is brillant, i LOVE python thank for replying On Fri, Mar 21, 2008 at 5:11 PM, Gregor Lingl <[EMAIL PROTECTED]> wrote: > elis aeris schrieb: > > is it possible to return two values? > > Yes: > >>> def return2(): > return "this", "that" > > >>> return2() > ('this', 'that') > >>> a,b

Re: [Tutor] returning two values

2008-03-21 Thread elis aeris
so just str(int) got it, thanks ! On Fri, Mar 21, 2008 at 5:11 PM, elis aeris <[EMAIL PROTECTED]> wrote: > > oh this is brillant, i LOVE python > > thank for replying > > > On Fri, Mar 21, 2008 at 5:11 PM, Gregor Lingl <[EMAIL PROTECTED]> wrote: > > > elis aeris schrieb: > > > > is it possible

Re: [Tutor] list

2008-03-21 Thread Andreas Kostyrka
Empty? array = [] If you want to assign 10 "None", that would be: array = [None] * 10 Andreas Am Freitag, den 21.03.2008, 17:03 -0700 schrieb elis aeris: > how do I create an empy int array of 10? > ___ > Tutor maillist - [email protected] > http://

Re: [Tutor] list

2008-03-21 Thread elis aeris
arra = [0] * 10 ? On Fri, Mar 21, 2008 at 5:29 PM, Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > Empty? > > array = [] > > If you want to assign 10 "None", that would be: > > array = [None] * 10 > > Andreas > > Am Freitag, den 21.03.2008, 17:03 -0700 schrieb elis aeris: > > how do I create an emp

Re: [Tutor] list

2008-03-21 Thread Steve Willoughby
elis aeris wrote: > arra = [0] * 10 ? If you want a list of ten zeroes, yes. A couple of suggestions: Find a tutorial introduction to Python such as those on python.org, or google for "dive into python", and go through the examples in there. Also, use the interactive Python interpreter to try o

Re: [Tutor] int to string

2008-03-21 Thread Tom Tucker
>>> y = 3 >>> type(y) >>> x = str(y) >>> type(x) On Fri, Mar 21, 2008 at 8:05 PM, elis aeris <[EMAIL PROTECTED]> wrote: > how do I convert int to string? > > ___ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor >

Re: [Tutor] Python to C++

2008-03-21 Thread Eike Welk
On Friday 21 March 2008 23:37, Dinesh B Vadhia wrote: > Thank-you for all the suggestions for converting to C/C++ which > will be followed up. > > Can we interface Python to a C++ library and if so how? > > Dinesh > If you have only few classes / member functions Boost-Python is a good solution.

Re: [Tutor] append string

2008-03-21 Thread Tom Tucker
Strings are immutable, you can't append to them. How about this >>> mystring = 'Elis' >>> mystring.append('Aeris') Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'append' >>> mystring + ' Aeris' 'Elis Aeris' >>> x = mystring + ' Aeri

[Tutor] Pseudo-functions and dicts

2008-03-21 Thread Shrutarshi Basu
I have a dictionary (in a module) which contains values of various sensors. I would like a user to be able use to a function syntax to get the sensor values, both as a whole and individually. Currently I have a function for each value who's sole purpose is to look up the corresponding dict value an

[Tutor] what is @classmethod and @staticmethod ??

2008-03-21 Thread maser
Hi I couldn't find a good resource explaining what @classmethod and @staticmethod are in python and when, how these could be used. If someone could explain what these are, or point me to resources that may help, it is appreciated. Thanks iyer

[Tutor] Even More Converter!

2008-03-21 Thread wackedd
After my last Email received I have been able to successfully create a Converter, currently it only has 6 units, but I will be adding more. My current code is # Converter Unit_Menu=""" 1) Centimeters 2) Inches 3) Feet 4) Yards 5) Miles 6) Millimeter Select a unit(1-6) """ >From = raw_input(Uni