[Tutor] Best way to call a prog that requires root access in linux

2007-01-05 Thread pytutor . 20 . 247ob
Hi all,

I've had a dig around on the forums about this and it was suggested to
use 'sudo'.
Well I have done this, I need to call tcpdump so I can sniff the
traffic and find the url's, I've modified my sudoers file so that for
this exe only I need no password.
This seems to be the best way since the program only runs the tcpdump
command as root (which incidently has a switch that allows you to drop
root privs once it's started) I want to distribute the program once
it's finished so it means explaining this (sudo bit) in the install
instructions.

Is this a good / bad way to achieve this? 

BTW I use Ubuntu which uses sudo by default however anyone might use
it.

Thanks in advance,

Wayne.

Send instant messages to your online friends http://uk.messenger.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Reg http request object

2007-01-05 Thread ALAN GAULD
Forwarding to the group in the hope someone 
may know the answer. 

--- anil maran <[EMAIL PROTECTED]> wrote:

> Date: Thu, 4 Jan 2007 16:57:01 -0800 (PST)
> From: anil maran <[EMAIL PROTECTED]>
> Subject: Reg http request object
> To: Alan Gauld <[EMAIL PROTECTED]>
> 
> Hi Alan
>  I m using webpy
>  The code was written for Django
>  facebook uses Request  http object and I need to get it and
> use it for processing the content after the user logs into
> facebook. This is part of facebook dev program.
>  
>  http://webpy.org/svn/trunk/web/
>  
> So I need to get my hands on the HTTP request object in
> facebook.. do help me out
> 
> Thanks
> 
> 
> > Here is the problem the example usage is in Django
> >
> > and they are talking about a request object
> >if 'session_key' in request.session and 'uid' in
> > request.session:
> >fb.session_key =
> > request.session['session_key']
> >
> > Anyone can tell me how I can access this in webpy
> > Isnt flup something that is set from webpy,
> 
> 
> OK, I\'m confused.
> 
> Can you clarify what is happening for me?
> Are you using Django? Are you using webpy? Or both?
> Also what is flup? I\'ve never heard of it...
> 
> Also what is the \'this\' that you want to access in webpy?
> Is it the request or the session? Or do you want to
> access Django code from webpy?
> 
> As I say, I\'m confused about what you are using
> and what you want us to help you with?
> 
> Alan G.
> Who is learning TurnoGears and knows next to
> nothing about webpy and only a little about Django...
> 
> ",1] ); D(["mb","- Show quoted text -
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> ",0] ); D(["ce"]);  //-->OK, I'm confused.
> 
> Can you clarify what is happening for me?
> Are you using Django? Are you using webpy? Or both?
> Also what is flup? I've never heard of it...
> 
> Also what is the 'this' that you want to access in webpy?
> Is it the request or the session? Or do you want to
> access Django code from webpy?
> 
> As I say, I'm confused about what you are using
> and what you want us to help you with?
> 
> Alan G.
> Who is learning TurnoGears and knows next to
> nothing about webpy and only a little about Django...
>  
>  __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection
> around 
> http://mail.yahoo.com 




___ 
Yahoo! Messenger - with free PC-PC calling and photo sharing. 
http://uk.messenger.yahoo.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Reg http request object

2007-01-05 Thread Kent Johnson
Anil,

I'm also confused about what you are trying to do. Are you writing a 
client application that talks to a web application? A web application 
that talks to a different web application? A new part of an existing web 
application? What are you using web.py for? What does facebook have to 
do with it? You have to give a clearer description of what you need.

The request object is a server-side object that will be specific to the 
web framework in use - the Django request object will most likely be 
different from the web.py request object. Also the way sessions are 
maintained will differ between frameworks. They will contain similar 
information but differ in the specifics.

Kent

ALAN GAULD wrote:
> Forwarding to the group in the hope someone 
> may know the answer. 
> 
> --- anil maran <[EMAIL PROTECTED]> wrote:
> 
>> Date: Thu, 4 Jan 2007 16:57:01 -0800 (PST)
>> From: anil maran <[EMAIL PROTECTED]>
>> Subject: Reg http request object
>> To: Alan Gauld <[EMAIL PROTECTED]>
>>
>> Hi Alan
>>  I m using webpy
>>  The code was written for Django
>>  facebook uses Request  http object and I need to get it and
>> use it for processing the content after the user logs into
>> facebook. This is part of facebook dev program.
>>  
>>  http://webpy.org/svn/trunk/web/
>>  
>> So I need to get my hands on the HTTP request object in
>> facebook.. do help me out
>>
>> Thanks
>>
>>
>>> Here is the problem the example usage is in Django
>>>
>>> and they are talking about a request object
>>>if 'session_key' in request.session and 'uid' in
>>> request.session:
>>>fb.session_key =
>>> request.session['session_key']
>>>
>>> Anyone can tell me how I can access this in webpy
>>> Isnt flup something that is set from webpy,
>>
>> OK, I\'m confused.
>>
>> Can you clarify what is happening for me?
>> Are you using Django? Are you using webpy? Or both?
>> Also what is flup? I\'ve never heard of it...
>>
>> Also what is the \'this\' that you want to access in webpy?
>> Is it the request or the session? Or do you want to
>> access Django code from webpy?
>>
>> As I say, I\'m confused about what you are using
>> and what you want us to help you with?
>>
>> Alan G.
>> Who is learning TurnoGears and knows next to
>> nothing about webpy and only a little about Django...
>>
>> ",1] ); D(["mb","- Show quoted text -
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>> ",0] ); D(["ce"]);  //-->OK, I'm confused.
>>
>> Can you clarify what is happening for me?
>> Are you using Django? Are you using webpy? Or both?
>> Also what is flup? I've never heard of it...
>>
>> Also what is the 'this' that you want to access in webpy?
>> Is it the request or the session? Or do you want to
>> access Django code from webpy?
>>
>> As I say, I'm confused about what you are using
>> and what you want us to help you with?
>>
>> Alan G.
>> Who is learning TurnoGears and knows next to
>> nothing about webpy and only a little about Django...
>>  
>>  __
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection
>> around 
>> http://mail.yahoo.com 
> 
> 
> 
>   
> ___ 
> Yahoo! Messenger - with free PC-PC calling and photo sharing. 
> http://uk.messenger.yahoo.com
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 


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


Re: [Tutor] Find and test a device by MAC address

2007-01-05 Thread János Juhász
Dear Lumbricus,

> From: [EMAIL PROTECTED]
> Subject: Re: [Tutor] Find and test a device by  MAC address
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"

> Quick and dirty:
> As root:
> >>> from scapy import *
> >>> arping("192.168.0.1/24") # or whatever fits to your network
> and then filter the answers; or build your own arp packets with ARP().

I have an XP, so I made a simple ping for the topmost IP address, 
that is the broadcast address in my subnet and I run an arp -a.

Thanks for the hint for scapy.

http://www.secdev.org/projects/scapy/ seems to be very very cool.

Some months earlier someone tried to collect how many application made in 
pure python.
The list should be extended with scapy as a pure python application.

Thanks Lumbricus.

Yours sincerely, 
__
Janos Juhasz 

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


Re: [Tutor] Best way to call a prog that requires root access in linux

2007-01-05 Thread Alan Gauld

<[EMAIL PROTECTED]> wrote

> I've had a dig around on the forums about this and it was suggested 
> to
> use 'sudo'.

sudo is the best way to run applications with a different access 
level.

Since this is an OS thing usinbg sudo is the right solution IMHO.
If you ever want to port your code to XP or VMS or whatever you
would need to rewrite the security model if you tried to do it
in the application. Much better to handle the issue in the OS.

Thats my view at least...


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


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


[Tutor] Load DLL / library and run a thread from it

2007-01-05 Thread Jorgen Bodde
Hi Guys,

I want to make a C++ DLL that spawns a thread, and wrap this with
Python so that a thread still runs inside the DLL, but I can access
methods to communicate with it, and preferrably receive callbacks from
it.

I searched the net for examples explaining concepts like this, but I
am lost. Is this possible or is it that trivial that nobody seems to
explain it?

The C++ DLL will not run any python code, it is a simulation engine
from which I want to make the status available in wxPython.

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


Re: [Tutor] Best way to call a prog that requires root access in linux

2007-01-05 Thread Christopher Arndt
[EMAIL PROTECTED] schrieb:
> I want to distribute the program once
> it's finished so it means explaining this (sudo bit) in the install
> instructions.
> 
> Is this a good / bad way to achieve this? 

Yes, the user should be always made aware, if he is to run something as root.
Requiring him to configure sudo is a good way to do this.

Just make sure your program fails with a meaningful error message, if sudo
isn't set up properly.

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


Re: [Tutor] python web dev

2007-01-05 Thread OkaMthembo

Thanks Gents,

You do all make sense to me. My dilemma really, is that im from a .NET
background where i write business logic in C#  and write my own stored
procs, etc...with the "cosmetic" design fully seperated from it all. so i
think id feel more confortable with a framework thatd provide a basic MVC
architecture and leave me to roll my own SQL etc, not one that will generate
half a project for me. ive taken another look at Cheetah and i think i like
it the most thus far.

My other issue is: has anybody run a python web app under lighttpd? and if
so, where can i get the Windows lighttpd build? the link to
kevinworthington.com on the official site is dead, and ive not had a
response from the lighttpd webmaster.

happy coding...

Shortash



On 1/4/07, Simon Brunning <[EMAIL PROTECTED]> wrote:


On 1/4/07, OkaMthembo <[EMAIL PROTECTED]> wrote:
> this is my first post.

Welcome!

> please could you tell me which is the best
> lightweight python web framework?

Best? That's a potentially contensious one. But I can tell you that if
you were to look at either Django or TurboGears you wouldn't be going
too far wrong. (I use Django, but I know that both are good.)

> also, which is the best templating
> language for python? (which can handle other data formats in addition to
> text). so far im lured by Cheetah, although i havent done any web dev
with
> python yet.

Cheetah's good, but if you go with Django, it has its own which is
pretty good too. (I use both at times.)

--
Cheers,
Simon B
[EMAIL PROTECTED]
http://www.brunningonline.net/simon/blog/

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


[Tutor] Python gui for file input

2007-01-05 Thread Mike Ellis
Hi all,

I am looking to create a simple gui interface to a small script.  The script 
requires the user to input a directory.  I would like to allow the user to 
browse the windows file system for the desired directory rather than type in 
the full path by hand.  This would operate in much the same way as any program 
when you select File>Open.  Is this possible to do with python?  Can anyone 
point me in the proper direction to find more info on this or perhaps an 
example script using a similar feature?

Thanks for your help,
Michael

 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python gui for file input

2007-01-05 Thread Jason Massey

The simplest way would be to use TkInter which is distributed with Python.

Check out the cookbook recipe at:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 for a bunch
of examples.


jason

On 1/5/07, Mike Ellis <[EMAIL PROTECTED]> wrote:


Hi all,

I am looking to create a simple gui interface to a small script.  The
script requires the user to input a directory.  I would like to allow the
user to browse the windows file system for the desired directory rather than
type in the full path by hand.  This would operate in much the same way as
any program when you select File>Open.  Is this possible to do with python?
Can anyone point me in the proper direction to find more info on this or
perhaps an example script using a similar feature?

Thanks for your help,
Michael

__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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



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


Re: [Tutor] python web dev

2007-01-05 Thread Kent Johnson
OkaMthembo wrote:
> Thanks Gents,
> 
> You do all make sense to me. My dilemma really, is that im from a .NET 
> background where i write business logic in C#  and write my own stored 
> procs, etc...with the "cosmetic" design fully seperated from it all. so 
> i think id feel more confortable with a framework thatd provide a basic 
> MVC architecture and leave me to roll my own SQL etc, not one that will 
> generate half a project for me. ive taken another look at Cheetah and i 
> think i like it the most thus far.

Cheetah is only a template language, it doesn't give you any mechanism 
for receiving and responding to HTTP requests. You still need some web 
infrastructure. web.py and pylons both work with Cheetah; I think 
TurboGears will also. Or you could use a bare web server such as 
CherryPy or Karrigell with Cheetah.

You might want to take a look at Pylons, it is perhaps the most 
"pluggable" of the major frameworks. You also might be interested in 
SQLAlchemy which provides a higher-level of access to your database than 
plain DB-API but doesn't hide the SQL from you.

> 
> My other issue is: has anybody run a python web app under lighttpd? and 
> if so, where can i get the Windows lighttpd build? the link to 
> kevinworthington.com  on the official site 
> is dead, and ive not had a response from the lighttpd webmaster.

Any WSGI-compatible web app will run under lighttpd using flup as a 
FastCGI connector. web.py, Pylons, TurboGears and Django all give 
instructions for this in their docs.

Kent

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


Re: [Tutor] Python gui for file input

2007-01-05 Thread Kent Johnson
Jason Massey wrote:
> The simplest way would be to use TkInter which is distributed with Python. 
> 
> Check out the cookbook recipe at: 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 
>  for a 
> bunch of examples.

You might also be interested in EasyGUI which wraps up these and several 
other simple dialog boxes.
http://www.ferg.org/easygui/

Kent

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


[Tutor] Does python produces bytecode??

2007-01-05 Thread Asrarahmed Kadri

Hi Folks,

Just a bit curious about how python runs the program?

I do know that it does not compile the code; its an interpreted language.

Do we have something like Python virtual machine ??

Please hlep me to understand these things.


Regards,
Asrarahmed
--
To HIM you shall return.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Does python produces bytecode??

2007-01-05 Thread Kent Johnson
Asrarahmed Kadri wrote:
> 
> Hi Folks,
>  
> Just a bit curious about how python runs the program?
>  
> I do know that it does not compile the code; its an interpreted language.
>  
> Do we have something like Python virtual machine ??
>  
> Please hlep me to understand these things.

Yes, Python has a bytecode compiler and a virtual machine (bytecode 
interpreter). The compiler is invoked automatically when needed so it is 
not really apparent to a casual user.

The dis module in the standard library lets you see the bytecode 
representation of a function or other code. The docs for this module 
include a listing of all the bytecode instructions.

If you want to dig into the details you have to look at the C source 
code for Python. This page gives a high-level guide:
http://effbot.org/pyfaq/where-do-i-start-if-i-want-to-learn-about-the-cpython-implementation.htm

Kent

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


[Tutor] need help with sending email

2007-01-05 Thread shawn bright

lo there all.

i am in a tight spot because i need to send an email that it mime encoded
plain-text ( not html or anything )
no attachements, no images, just text from a string. like message = 'some
message'
all the tutorials i find out there, and the cookbook recipies are for
sending multipart messages, attachments, etc..
this needs to be simple, but needs to be able to reach a large variety of
cell phone text message receivers.

anyone know of a good tutorial or recipe out there ?

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


Re: [Tutor] need help with sending email

2007-01-05 Thread Mike Hansen
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
> Sent: Friday, January 05, 2007 10:18 AM
> To: tutor-python
> Subject: [Tutor] need help with sending email
> 
> lo there all.
> 
> i am in a tight spot because i need to send an email that it 
> mime encoded plain-text ( not html or anything )
> no attachements, no images, just text from a string. like 
> message = 'some message' 
> all the tutorials i find out there, and the cookbook recipies 
> are for sending multipart messages, attachments, etc..
> this needs to be simple, but needs to be able to reach a 
> large variety of cell phone text message receivers. 
> 
> anyone know of a good tutorial or recipe out there ?
> 
> thanks,
> shawn
> 
>
This might help:

http://effbot.org/librarybook/smtplib.htm 

Also, the docs on smtplib:

http://docs.python.org/lib/module-smtplib.html

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

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


Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright

right, thanks, Mike.
i can send an email fine. Some of the providers we are trying to reach will
reject anything that is not content type: text-plain

thats what i need to know how to add.

thanks again
shawn

On 1/5/07, Mike Hansen <[EMAIL PROTECTED]> wrote:




> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
> Sent: Friday, January 05, 2007 10:18 AM
> To: tutor-python
> Subject: [Tutor] need help with sending email
>
> lo there all.
>
> i am in a tight spot because i need to send an email that it
> mime encoded plain-text ( not html or anything )
> no attachements, no images, just text from a string. like
> message = 'some message'
> all the tutorials i find out there, and the cookbook recipies
> are for sending multipart messages, attachments, etc..
> this needs to be simple, but needs to be able to reach a
> large variety of cell phone text message receivers.
>
> anyone know of a good tutorial or recipe out there ?
>
> thanks,
> shawn
>
>
This might help:

http://effbot.org/librarybook/smtplib.htm

Also, the docs on smtplib:

http://docs.python.org/lib/module-smtplib.html

Mike


-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified
individual or entity.

  Its contents may be privileged, confidential, and exempt from disclosure
under the law.
  Any dissemination, distribution, or copying of this communication is
strictly prohibited.

  Please notify the sender immediately if you are not the intended
recipient.

FGNS


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



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


Re: [Tutor] Load DLL / library and run a thread from it

2007-01-05 Thread Kent Johnson
Jorgen Bodde wrote:
> Hi Guys,
> 
> I want to make a C++ DLL that spawns a thread, and wrap this with
> Python so that a thread still runs inside the DLL, but I can access
> methods to communicate with it, and preferrably receive callbacks from
> it.
> 
> I searched the net for examples explaining concepts like this, but I
> am lost. Is this possible or is it that trivial that nobody seems to
> explain it?

These might help:
http://effbot.org/pyfaq/how-do-i-interface-to-c-objects-from-python.htm
http://effbot.org/pyfaq/writing-c-is-hard-are-there-any-alternatives.htm

Kent

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


Re: [Tutor] need help with sending email

2007-01-05 Thread Kent Johnson
shawn bright wrote:
> right, thanks, Mike.
> i can send an email fine. Some of the providers we are trying to reach 
> will reject anything that is not content type: text-plain
> 
> thats what i need to know how to add.

The first example on this page seems to do what you want:
http://docs.python.org/lib/node162.html

Kent

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


Re: [Tutor] python web dev

2007-01-05 Thread Christopher Arndt
OkaMthembo schrieb:> i think id feel more confortable with a framework thatd
provide a basic
> MVC architecture and leave me to roll my own SQL etc, not one that will
> generate half a project for me.

With TurboGears you're not bound to SQLObject or SQLAlchemy. You can roll your
own database access layer if you want or use a third-party one. You just define
your DAO or functions in model.py. Of course you can't use CatWalk (model
admin, support SQLObject only anyway) and "tg-admin sql" (command line database
admin tool) then.

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


Re: [Tutor] need help with sending email

2007-01-05 Thread Christopher Arndt
shawn bright schrieb:
> lo there all.
> 
> i am in a tight spot because i need to send an email that it mime
> encoded plain-text ( not html or anything )
> 
> anyone know of a good tutorial or recipe out there ?

Simplified example from http://www.python.org/doc/current/lib/node162.html:

# Import the email modules we'll need
from email.MIMEText import MIMEText

# Create a text/plain message
msg = MIMEText("Hello World!")

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'This is a test message'
msg['From'] = 'me'
msg['To'] = 'you'

# Print string repreentation of message
print msg.as_string()


Outputs:

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: This is a test message
From: me
To: you

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


Re: [Tutor] python web dev

2007-01-05 Thread wesley chun
> has anybody run a python web app under lighttpd?

i currently use this at work (on linux/centOS)... we're using FastCGI
with ligHTTPD via the WSGI-compliant fcgi.py module which can be found
all over, but the main source comes in the FLUP pkg found at
http://www.saddi.com/software/flup/

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python gui for file input

2007-01-05 Thread Alan Gauld

"Mike Ellis" <[EMAIL PROTECTED]> wrote in

> I am looking to create a simple gui interface to a small script.
> The script requires the user to input a directory.

You don't need to write an interface just use the standard
one. Of course if you want to display the result/output in
a GUI then you neeed to do some work. But if you are
happy with a console interace, or a silent application,
then its just a case of using the common dialogs:

>>> import Tkinter as tk>>> import tkFileDialog as fd>>> t = 
>>> tk.Tk()>>> t.withdraw()  # hides the Tk root window''>>> d = 
>>> fd.askdirectory() # display the dir dialog>>> print 
>>> dD:/Development>>> dir(fd)['Dialog', 'Directory', 'Open', 
>>> 'SaveAs', '_Dialog', '__builtins__', '__doc__','__file__', 
>>> '__name__', 'askdirectory', 'askopenfile', 'askopenfilename', 
>>> 'askoenfilenames', 'askopenfiles', 'asksaveasfile', 
>>> 'asksaveasfilename']>>>As you see there are a number of other 
>>> dialogs too. Try googling on their names to find example usage. I 
>>> don't know why this isn't documented in the standard library 
>>> docs!HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


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


Re: [Tutor] Tutor Digest, Vol 35, Issue 18

2007-01-05 Thread Tony Cappellini

Message: 7
Date: Fri, 5 Jan 2007 08:04:23 -0800 (PST)
From: Mike Ellis <[EMAIL PROTECTED]>
Subject: [Tutor] Python gui for file input
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Hi all,

I am looking to create a simple gui interface to a small script.  The script
requires the user to input a directory.  I would like to allow the user to
browse the windows file system for the desired directory rather than type in
the full path by hand.  This would operate in much the same way as any
program when you select File>Open.  Is this possible to do with python?  Can
anyone point me in the proper direction to find more info on this or perhaps
an example script using a similar feature?

Thanks for your help,
Michael

If you're looking for a simple cross-paltform solution, EasyDialogs is by
far the easiest.
http://www.averdevelopment.com/python/EasyDialogs.html

You don't have to learn anything about any GUI framework. This will invoke
the native file open browser for Windows/Linux.
2-3 lines of code max.

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


Re: [Tutor] need help with sending email

2007-01-05 Thread shawn bright

this is really cool. working too,
we have one provider now that it does not work with, but i think its them
this time.
thanks for your help on this

shawn

On 1/5/07, Christopher Arndt <[EMAIL PROTECTED]> wrote:


shawn bright schrieb:
> lo there all.
>
> i am in a tight spot because i need to send an email that it mime
> encoded plain-text ( not html or anything )
>
> anyone know of a good tutorial or recipe out there ?

Simplified example from http://www.python.org/doc/current/lib/node162.html
:

# Import the email modules we'll need
from email.MIMEText import MIMEText

# Create a text/plain message
msg = MIMEText("Hello World!")

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'This is a test message'
msg['From'] = 'me'
msg['To'] = 'you'

# Print string repreentation of message
print msg.as_string()


Outputs:

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: This is a test message
From: me
To: you

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

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


[Tutor] python dictionaries

2007-01-05 Thread Raven Of Night Raven Of Night
Hi, there was this two step program I was working on but i can only complete 
the first step.

- - Write a Who's Your Daddy? program that lets the user enter the name of 
the male and produces the name of his father. Allow the user to add, 
replace, and delete father son pairs. The program should also allow the user 
to get a list of all son, fathers, or father son pairs.

I made a dictionary:
family = { "Wane Wilright" : "Dan Wilright",
   "Michal Zheng" : "Tsu Zheng",
   "Art Core" : "Vandalee Core",
   "John Wane" : "Calvin Wane" }

and was able to complete the rest of the program.


Then I was asked to improve the program:
- - Improve the Who's Your Daddy program by adding a choice that lets the 
user enter a name and get back a grandfather. Your program should still use 
one dictionary of son-father pairs. Make sure to include several generatios 
in your dictionary so that a match can be found.

I don't understand, dictionarys only allow two elements so how can you 
include several generations in the dictinoary... could you perhaps put a 
dictinoary inside a dictionary? I don't understand how you would do the 
second part.

_
The MSN Entertainment Guide to Golden Globes is here.  Get all the scoop. 
http://tv.msn.com/tv/globes2007/?icid=nctagline2

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


Re: [Tutor] python dictionaries

2007-01-05 Thread Adam Bark

On 05/01/07, Raven Of Night Raven Of Night <[EMAIL PROTECTED]> wrote:


Hi, there was this two step program I was working on but i can only
complete
the first step.

- - Write a Who's Your Daddy? program that lets the user enter the name of
the male and produces the name of his father. Allow the user to add,
replace, and delete father son pairs. The program should also allow the
user
to get a list of all son, fathers, or father son pairs.

I made a dictionary:
family = { "Wane Wilright" : "Dan Wilright",
   "Michal Zheng" : "Tsu Zheng",
   "Art Core" : "Vandalee Core",
   "John Wane" : "Calvin Wane" }

and was able to complete the rest of the program.


Then I was asked to improve the program:
- - Improve the Who's Your Daddy program by adding a choice that lets the
user enter a name and get back a grandfather. Your program should still
use
one dictionary of son-father pairs. Make sure to include several
generatios
in your dictionary so that a match can be found.

I don't understand, dictionarys only allow two elements so how can you
include several generations in the dictinoary... could you perhaps put a
dictinoary inside a dictionary? I don't understand how you would do the
second part.



Hopefully this will make sense to you as I don't want to give the whole game
away.
A grandfather is just a father's father. If you don't get it still then I'll
make it a bit
more obvious.
HTH,
Adam.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python dictionaries

2007-01-05 Thread Alan Gauld

"Raven Of Night Raven Of Night" <[EMAIL PROTECTED]> wrote

> I don't understand, dictionarys only allow two elements so how can 
> you
> include several generations in the dictinoary...

Grandfather -> Father -> Son

can be expressed as two pairs:

Grandfather -> Father
Father -> Son

Now you can put it in your dictionary.

You only need to figure out how to join the pairs back into
a triple again...

> could you perhaps put a dictinoary inside a dictionary?

You can, but you don;t need to. And, assuming its a homework,
I don't think thats what you are expected to do here.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


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


Re: [Tutor] Python gui for file input

2007-01-05 Thread Alan Gauld
Apologies for the wird formatting, looks like the news reader
got confused by Pythons chevrons and thought it was a thread!
Hopefully spacing will fix it...

"Alan Gauld" <[EMAIL PROTECTED]> wrote

>>> import Tkinter as tk

>>> import tkFileDialog as fd

>>> t =  tk.Tk()

>>> t.withdraw()  # hides the Tk root window''

>>> d = fd.askdirectory() # display the dir dialog

>>> print  d
D:/Development

>>> dir(fd)
['Dialog', 'Directory', 'Open', 'SaveAs', '_Dialog', '__builtins__',
'__doc__','__file__',  '__name__', 'askdirectory', 'askopenfile',
'askopenfilename',  'askoenfilenames', 'askopenfiles', 
'asksaveasfile',
 'asksaveasfilename']



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


Re: [Tutor] python dictionaries

2007-01-05 Thread Carroll, Barry
> -Original Message-
> Message: 7
> Date: Fri, 05 Jan 2007 15:43:56 -0800
> From: "Raven Of Night Raven Of Night" <[EMAIL PROTECTED]>
> Subject: [Tutor] python dictionaries
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; format=flowed
> 
> Hi, there was this two step program I was working on but i can only
> complete
> the first step.
> 
> - - Write a Who's Your Daddy? program that lets the user enter the
name of
> the male and produces the name of his father. Allow the user to add,
> replace, and delete father son pairs. The program should also allow
the
> user
> to get a list of all son, fathers, or father son pairs.
> 
> I made a dictionary:
> family = { "Wane Wilright" : "Dan Wilright",
>"Michal Zheng" : "Tsu Zheng",
>"Art Core" : "Vandalee Core",
>"John Wane" : "Calvin Wane" }
> 
> and was able to complete the rest of the program.
> 
> 
> Then I was asked to improve the program:
> - - Improve the Who's Your Daddy program by adding a choice that lets
the
> user enter a name and get back a grandfather. Your program should
still
> use
> one dictionary of son-father pairs. Make sure to include several
> generatios
> in your dictionary so that a match can be found.
> 
> I don't understand, dictionarys only allow two elements so how can you
> include several generations in the dictinoary... could you perhaps put
a
> dictinoary inside a dictionary? I don't understand how you would do
the
> second part.
> 
> _
> The MSN Entertainment Guide to Golden Globes is here.  Get all the
scoop.
> http://tv.msn.com/tv/globes2007/?icid=nctagline2
> 
> 
> 
> --
> 
> Message: 8
> Date: Sat, 6 Jan 2007 00:02:22 +
> From: "Adam Bark" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] python dictionaries
> To: "Raven Of Night Raven Of Night" <[EMAIL PROTECTED]>
> Cc: tutor@python.org
> Message-ID:
>   <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> On 05/01/07, Raven Of Night Raven Of Night <[EMAIL PROTECTED]>
wrote:
> >
> > Hi, there was this two step program I was working on but i can only
> > complete
> > the first step.
> >
> > - - Write a Who's Your Daddy? program that lets the user enter the
name
> of
> > the male and produces the name of his father. Allow the user to add,
> > replace, and delete father son pairs. The program should also allow
the
> > user
> > to get a list of all son, fathers, or father son pairs.
> >
> > I made a dictionary:
> > family = { "Wane Wilright" : "Dan Wilright",
> >"Michal Zheng" : "Tsu Zheng",
> >"Art Core" : "Vandalee Core",
> >"John Wane" : "Calvin Wane" }
> >
> > and was able to complete the rest of the program.
> >
> >
> > Then I was asked to improve the program:
> > - - Improve the Who's Your Daddy program by adding a choice that
lets
> the
> > user enter a name and get back a grandfather. Your program should
still
> > use
> > one dictionary of son-father pairs. Make sure to include several
> > generatios
> > in your dictionary so that a match can be found.
> >
> > I don't understand, dictionarys only allow two elements so how can
you
> > include several generations in the dictinoary... could you perhaps
put a
> > dictinoary inside a dictionary? I don't understand how you would do
the
> > second part.
> 
> 
> Hopefully this will make sense to you as I don't want to give the
whole
> game
> away.
> A grandfather is just a father's father. If you don't get it still
then
> I'll
> make it a bit
> more obvious.
> HTH,
> Adam.
> -- next part --
> An HTML attachment was scrubbed...
> URL:
>
http://mail.python.org/pipermail/tutor/attachments/20070106/df0a537b/att
ac
> hment.htm

Think of it this way:

My name is Barry.
My father's name is Jim.
Jim's father's name is Walt (***my grandfather***).

How can you use your dictionary to emulate that?

Good luck.

Regards,
 
Barry
[EMAIL PROTECTED]
541-302-1107

We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed



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