[Tutor] A question

2006-02-05 Thread Bian Alex
How can I get a string from a random file. 
For Example:
Del    ete On   :   CopyOwner   :  BnPersonalized: 5PersonalizedName    :  My    Documents
 
I want to get the string after 'Owner' ( In example is 'Bn')
 
'import re' ?
 
Pls help.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A question

2006-02-05 Thread Rinzwind
On 2/5/06, Bian Alex <[EMAIL PROTECTED]> wrote:
How can I get a string from a random file. 
For Example:
Del    ete On   :   CopyOwner   :  BnPersonalized: 5PersonalizedName    :  My    Documents
 
I want to get the string after 'Owner' ( In example is 'Bn')
 
'import re' ?
 
Pls help.help You mean like this?>>> line ='Owner:Bn'>>> line = line.split(":")>>> print line
['Owner', 'Bn']>>> print line[1]BnSo you read the lines from the file till you find "Owner:Bn" and split it at the ':'.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A question

2006-02-05 Thread Marilyn Davis
On Sun, 5 Feb 2006, Bian Alex wrote:

> How can I get a string from a random file.
> For Example:
> Delete On   :   Copy
> Owner   :  Bn
> Personalized: 5
> PersonalizedName:  MyDocuments
> 
> I want to get the string after 'Owner' ( In example is 'Bn')
> 
> 'import re' ?

Yes, but maybe it's simpler to use the builtin functions, and slicing:

text = open('the_file').readlines()  <-- now the_file is in text as a string

start = text.find('Owner   :') + 8   <-- start is the index into the text
 where Owner starts + 8 to point
 to the text you want.
end = text.find('\n', start) <-- end is where the newline is, after
 start.
found = text[start:end].strip()  <-- found has the text you want, with
 any spaces stripped off.

I hope it helps.  I didn't test it.

Marilyn Davis

> 
> Pls help.
> 

-- 

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


Re: [Tutor] A question

2006-02-05 Thread Marilyn Davis
On Sun, 5 Feb 2006, Marilyn Davis wrote:

> On Sun, 5 Feb 2006, Bian Alex wrote:
> 
> > How can I get a string from a random file.
> > For Example:
> > Delete On   :   Copy
> > Owner   :  Bn
> > Personalized: 5
> > PersonalizedName:  MyDocuments
> > 
> > I want to get the string after 'Owner' ( In example is 'Bn')
> > 
> > 'import re' ?
> 
> Yes, but maybe it's simpler to use the builtin functions, and slicing:
> 
> text = open('the_file').readlines()  <-- now the_file is in text as a string

Ooops.  This should be:

text = open('the_file').read()

Maybe someone else will show you the readlines() solution.  I have to
run.

Good luck.

Marilyn

> 
> start = text.find('Owner   :') + 8   <-- start is the index into the text
>  where Owner starts + 8 to point
>  to the text you want.
> end = text.find('\n', start) <-- end is where the newline is, after
>  start.
> found = text[start:end].strip()  <-- found has the text you want, with
>  any spaces stripped off.
> 
> I hope it helps.  I didn't test it.
> 
> Marilyn Davis
> 
> > 
> > Pls help.
> > 
> 
> 

-- 

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


[Tutor] Documentation

2006-02-05 Thread Paul Kraus
I have been working through a couple of books and learning alot. However I 
can't seem to find any easy way to learn more about different methods and 
commands.

For instance what are all of the methods that can be applied to lists and what 
do they do and how do they work. Or in TKinter what are all the different 
things can I do with a button besides just setting the command and the text 
and such. These are just examples.

I can't find an easy way to do this.

I know there has to be i have tried the pydoc gui but I found nothing when i 
searched list. *shrug*
-- 
Paul Kraus
=-=-=-=-=-=-=-=-=-=-=
PEL Supply Company
Network Administrator
216.267.5775 Voice
216.267.6176 Fax
www.pelsupply.com
=-=-=-=-=-=-=-=-=-=-=
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Documentation

2006-02-05 Thread Andre Roberge
On 2/5/06, Paul Kraus <[EMAIL PROTECTED]> wrote:
> I have been working through a couple of books and learning alot. However I
> can't seem to find any easy way to learn more about different methods and
> commands.
>
> For instance what are all of the methods that can be applied to lists and what
> do they do and how do they work. Or in TKinter what are all the different
> things can I do with a button besides just setting the command and the text
> and such. These are just examples.
>
> I can't find an easy way to do this.
>
Python is your friend!Here's the (truncated) result of an
interactive session.

PythonWin 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED])
- see 'Help/About PythonWin' for further copyright information.
>>> a = []
>>> dir (a)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__',
'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
'__setslice__', '__str__', 'append', 'count', 'extend', 'index',
'insert', 'pop', 'remove', 'reverse', 'sort']
>>> help(a.index)
Help on built-in function index:

index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value

>>> import Tkinter
>>> dir(Tkinter)
['ACTIVE', 'ALL', 'ANCHOR', 'ARC', 'At', 'AtEnd', 'AtInsert',
'AtSelFirst', 'AtSelLast', 'BASELINE', 'BEVEL', 'BOTH', 'BOTTOM',
'BROWSE', 'BUTT', 'BaseWidget', 'BitmapImage', 'BooleanType',
'BooleanVar', 'BufferType', 'BuiltinFunctionType',
'BuiltinMethodType', 'Button',

[snip]

>>> dir(Tkinter.Button)
['_Misc__winfo_getint', '_Misc__winfo_parseitem', '__doc__',
'__getitem__', '__init__', '__module__', '__setitem__', '__str__',
'_bind', '_configure', '_displayof', '_do', '_getboolean',
'_getdoubles', '_getints', '_grid_configure', '_nametowidget',
'_noarg_', '_options', '_register', '_report_exception', '_root',
'_setup', '_subst_format', '_subst_format_str', '_substitute',

[snip]

>>> help(Tkinter.Button.configure)
Help on method configure in module Tkinter:

configure(self, cnf=None, **kw) unbound Tkinter.Button method
Configure resources of a widget.

The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.


Try it on your own!  As a rule, stay away from methods that start with
an underscore.

André
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Documentation

2006-02-05 Thread Paul Kraus
> >>> help(Tkinter.Button.configure)
>
> Help on method configure in module Tkinter:
>
> configure(self, cnf=None, **kw) unbound Tkinter.Button method
> Configure resources of a widget.
>
> The values for resources are specified as keyword
> arguments. To get an overview about
> the allowed keyword arguments call the method keys.
>
>
> Try it on your own!  As a rule, stay away from methods that start with
> an underscore.
Thanks for the fast response. This was exactly what I was looking for. One 
last question how would I 'call the method keys'. from the example above.
-- 
Paul Kraus
=-=-=-=-=-=-=-=-=-=-=
PEL Supply Company
Network Administrator
216.267.5775 Voice
216.267.6176 Fax
www.pelsupply.com
=-=-=-=-=-=-=-=-=-=-=
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Documentation

2006-02-05 Thread Andre Roberge
On 2/5/06, Paul Kraus <[EMAIL PROTECTED]> wrote:
> > >>> help(Tkinter.Button.configure)
> >
> > Help on method configure in module Tkinter:
> >
> > configure(self, cnf=None, **kw) unbound Tkinter.Button method
> > Configure resources of a widget.
> >
> > The values for resources are specified as keyword
> > arguments. To get an overview about
> > the allowed keyword arguments call the method keys.
> >
> >
> > Try it on your own!  As a rule, stay away from methods that start with
> > an underscore.
> Thanks for the fast response. This was exactly what I was looking for. One
> last question how would I 'call the method keys'. from the example above.

To be honest ... I don`t know.  I don't use Tkinter myself.  Here's
what I get from the help function:
-
>>> help(Tkinter.Button.keys)
Help on method keys in module Tkinter:

keys(self) unbound Tkinter.Button method
Return a list of all resource names of this widget.
---
So, I would guess that, after creating a button, through something like
aButton = Button(parent, text="Some label", command=some_action)

You could do:
resources = aButton.keys()

There is a free book on using Tkinter to be found at
http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html

Another great resource is to be found on
http://www.pythonware.com/library/index.htm

You will find there a Tkinter reference book on-line (html version) or
a downloadable one (pdf).  Here's what I found by browsing...
===
The following dictionary method also works for widgets:

keys() => list

Return a list of all options that can be set for this widget. The
name option is not included in this list (it cannot be queried or
modified through the dictionary interface anyway, so this doesn't
really matter).
===

You may have to wait until tomorrow to get your answer, when the "real
tutors" are online ;-)

Good luck!

André
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Documentation

2006-02-05 Thread John Fouhy
On 06/02/06, Paul Kraus <[EMAIL PROTECTED]> wrote:
> Thanks for the fast response. This was exactly what I was looking for. One
> last question how would I 'call the method keys'. from the example above.

If b is a Tkinter.Button, then it means call b.keys().

eg:

>>> from Tkinter import *
>>> tk = Tk()
>>> b = Button(tk, text='Hello world!')
>>> b.keys()
['activebackground', 'activeforeground', 'anchor', 'background', 'bd',
'bg', 'bitmap', 'borderwidth', 'command', 'compound', 'cursor',
'default', 'disabledforeground', 'fg', 'font', 'foreground', 'height',
'highlightbackground', 'highlightcolor', 'highlightthickness',
'image', 'justify', 'overrelief', 'padx', 'pady', 'relief',
'repeatdelay', 'repeatinterval', 'state', 'takefocus', 'text',
'textvariable', 'underline', 'width', 'wraplength']

So, these are the possible things you can configure with a Tkinter.Button.

Also, the online documentation at python.org is very good.  I
recommend going to http://www.python.org/doc/ and downloading the
current documentation.  You'll get a bunch of HTML files which you can
put somewhere.  Then set up a bookmark for the main index file.  I
have it on my browser's toolbar and I use it all the time :-)

The Library Reference is particularly useful.  For example, if you
want to know about all the methods specific to lists, you can read the
section on mutable sequence types:
http://docs.python.org/lib/typesseq-mutable.html

HTH!

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


[Tutor] Debugger Needed

2006-02-05 Thread Akanksha Govil
Hi,I am new to python, I want to know how to use a debugger and which debugger give a GUI .I am using Suse 9.1.ThanksAkanksha
		Relax. Yahoo! Mail 
virus scanning helps detect nasty viruses!___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python in Mac

2006-02-05 Thread linda.s
I installed python in both Windows and Mac.
I am very curious why the installation under Mac take so long time
compared to that under Windows.
Thanks,
Linda
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugger Needed

2006-02-05 Thread Danny Yoo


On Sun, 5 Feb 2006, Akanksha Govil wrote:

> I am new to python, I want to know how to use a debugger and which
> debugger give a GUI .

Hi Akanksha,


Have you looked at 'pdb' yet?

http://www.python.org/doc/lib/module-pdb.html

Several of the major Python IDEs also provide some kind of debugging
support; you may want to check them out.  Here's a good link to them:

http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

I've heard interesting things about Komodo and eric3, though I've never
used them personally.


Best of wishes!

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


Re: [Tutor] is there any tool like "run line or selection" in Pythonwin?

2006-02-05 Thread linda.s
I installed python in both Windows and Mac.
I am very curious why the installation under Mac take so long time
compared to that under Windows.
Thanks,
Linda
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] installing python on windows and macs

2006-02-05 Thread Danny Yoo


On Sun, 5 Feb 2006, linda.s wrote:

> I installed python in both Windows and Mac. I am very curious why the
> installation under Mac take so long time compared to that under
> Windows.

Hi Linda,

But that's somewhat odd, because it should take zero time: Python's
already installed under Mac OS X 10.3.  *grin*

Is this a really big problem for you?  Installation is something that
usually happens just once, so I'm sure the Python developers haven't done
anything particularly focused to make installation on any platform
blazingly fast.  So, frankly, as long as the installation worked out ok, I
wouldn't worry too much about this.


Still if this does matter to you, let's see... can you be more specific
about what version of Mac OS and what installation of Python you've tried?
I made a flippant comment above, but I assume that you mean some other
version of Mac OS (perhaps 9?)  In order to evaluate what's happening, we
need details about your system to advise better.  And since your question
is about speed, knowing what kinds of machines we're comparing against
(CPU, RAM) would also be good, since your computer's raw performance is a
significant factor.

You might also want to talk with the MacPython folks, and you can give
them numbers on how long the installation takes. (How long do you mean by
"long"?  Minutes, hours... days?  *grin*)  The folks on the macpython list
might be able to corroborate that your situation is unusual, or they might
be able to point out something that they know as an outstanding issue.
They have a mailing list here:

http://www.python.org/sigs/pythonmac-sig/

Good luck to you.

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