I need help to connect to db on Linux machine.
When I do it manually -all right, try to execute script does not work.
My script is simple:
-------------------------------------------------------
def Connect3():
    #arg=os.system('sql.py --prompt qa2:adsdb
inbl27,inbl27,inbl27:root:adsgoogle:qa2ads0,qa2ads1')
    arg=os.popen('sql.py --prompt qa2:adsdb
inbl27,inbl27,inbl27:root:adsgoogle:qa2ads0,qa2ads1')
   
Connect3() 
-----------------------------------------------------
Thanks in advance,
Vic
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Tuesday, March 07, 2006 3:00 AM
To: tutor@python.org
Subject: Tutor Digest, Vol 25, Issue 18

Send Tutor mailing list submissions to
        tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific than
"Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: search and replace (Danny Yoo)
   2. Re: search and replace (Alan Gauld)
   3. Re: Functions and random buttons (Alan Gauld)
   4. Re: [OT] Shells (Alan Gauld)
   5. how to write a string into a specific line in a file (tak)
   6. Re: how to write a string into a specific line in a file (tak)


----------------------------------------------------------------------

Message: 1
Date: Tue, 7 Mar 2006 00:13:07 -0800 (PST)
From: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] search and replace
To: tak <[EMAIL PROTECTED]>
Cc: tutor@python.org
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; charset=US-ASCII



> I have a problem finding specific words.
> I would like to filter out a word or replace it in a file.
> I notices that the re module is good for finding patterns.

Hi Tak,

Although regular expressions might be overkill for this problem, it can't
hurt to know about the Regex HOWTO:

    http://www.amk.ca/python/howto/regex/


Note that strings can already do simple replacement:

######
>>> 'this is a test hi world'.replace('hi', 'hello')
'thellos is a test hello world'
######

As this example shows, we need to be a bit careful with it.


Regexes allow us to do a slightly smarter, word boundary-specific
substitution:

######
>>> import re
>>> re.sub(r'\bhi\b', 'hello', 'this is a test hi world')
'this is a test hello world'
######

The Regex HOWTO link above is a tutorial on how to use the module
effectively.  If you have questions, please feel free to bring them up.

Good luck!



------------------------------

Message: 2
Date: Tue, 7 Mar 2006 09:33:03 -0000
From: "Alan Gauld" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] search and replace
To: "tak" <[EMAIL PROTECTED]>, <tutor@python.org>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
        reply-type=original

Hi tak,

> hello, Othello. # just the hello and not Othello

One simplistic approach that does not use regex is to search for spaces as
part of the string. But that doesn't work for punctuation nor at the start
or end of lines.

So that leaves us, as you observed, with regular expressions.

regex allows us to specify certain conditions in the patterns such as
whether the characters are digits etc, and also whether we are kooking for a
word which is wat you want.
Specifically \W signifies a word boundary so

\Whello\W

will find hello as a word.

Take a look at my tutorial topic on regex for more detail, or go to the
excellent regex How-To linked from the Python site.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld





------------------------------

Message: 3
Date: Tue, 7 Mar 2006 09:42:00 -0000
From: "Alan Gauld" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Functions and random buttons
To: "Simon Stoltze" <[EMAIL PROTECTED]>, <tutor@python.org>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
        reply-type=original

Simon,

> ...I want to make each button clickable

The buttons are clickable so I'm not absolutely sure what you mean?
Do you mean you want to add some action to them when they are clicked?
Thats done with the command option in Tkinter.

define a function and assign it to the button.

In this case it will likely be the same function for all buttons so you
might want to do a wee bit of trickery like:

def func(x,y):    #x,y the button coords
    # do something here

        for i in range(length):
            for j in range(length):
                self.dict['%s%s' % (i, j)] = Button(sel.frame, text = ' 
'
                                                         command = lambda
x=i,y=j: func(x,y))

That uses the default values of the lambda function to pass the coords of
the button being pressed to your generic function. func can then use those
coords to address the button in the dictionary to update the label or
appearance etc.

One other wee point:

                self.dict['%s%s' % (i, j)].grid(row = i, column = j)

You don't need to use a string for a key in a dictionary, the tuple will be
just fine so you can replace the string formatting stuff with:

                self.dict[(i, j)].grid(row = i, column = j)

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




------------------------------

Message: 4
Date: Tue, 7 Mar 2006 10:04:30 -0000
From: "Alan Gauld" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] [OT] Shells
To: "John Fouhy" <[EMAIL PROTECTED]>, "Python Tutor" <tutor@python.org>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
        reply-type=original

Hi john,

> Agreed --- but the new Microsoft shell looks very interesting.
> Ars has a good review of it here: 
> http://arstechnica.com/guides/other/msh.ars

Nice heads-up. I hadn't heard of this before, despite reading several of the
comics' views on Vista.

It looks promising, although without good command line editing and the
ability to create active GUIs it will be limited. But then, you can't do
GUIs in bash either...

But an OO pipeline is interesting, I wonder how long before somebody in
Linux comes up with a new shell mechanism for that?

Thanks again,

Alan G.



------------------------------

Message: 5
Date: Tue, 07 Mar 2006 19:22:09 +0900
From: tak <[EMAIL PROTECTED]>
Subject: [Tutor] how to write a string into a specific line in a file
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-2022-JP

Hello,

I was wondering if it is possible to write a string to a specific line in a
file without reading in the whole file in as the below.
___________________________________________________________________

f = open(filename)
lines = f.readlines()
f.close()
# num for some line number
line[num] = "String"
f = open(filename)
f.writelines(lines)
f.close()
____________________________________________________________________

Writing directly to the line number would be ideal.
Some thing like: f.write(line number, string) if there is a function like
that.

Or would the best way to do line replacement be through iteration.
__________________________________________________________________

for line in open(filename):
# write to current line???

_________________________________________________________________

Thank you.

Best regards,

Tak




------------------------------

Message: 6
Date: Tue, 07 Mar 2006 19:29:51 +0900
From: tak <[EMAIL PROTECTED]>
Subject: Re: [Tutor] how to write a string into a specific line in a
        file
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

Sorry, I meant lines in line in the below:

f = open(filename)
lines = f.readlines()
f.close()
# num for some line number
>>lines[num] = "String"
f = open(filename)
f.writelines(lines)
f.close()



*******************************************************************

Hello,

I was wondering if it is possible to write a string to a specific line in a
file without reading in the whole file in as the below.
___________________________________________________________________

f = open(filename)
lines = f.readlines()
f.close()
# num for some line number
line[num] = "String"
f = open(filename)
f.writelines(lines)
f.close()
____________________________________________________________________

Writing directly to the line number would be ideal.
Some thing like: f.write(line number, string) if there is a function like
that.

Or would the best way to do line replacement be through iteration.
__________________________________________________________________

for line in open(filename):
# write to current line???

_________________________________________________________________

Thank you.

Best regards,

Tak




------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 25, Issue 18
*************************************

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to