Re: [Tutor] Python hosting again

2005-08-15 Thread Adam Cripps
On 8/11/05, Jorge Louis De Castro <[EMAIL PROTECTED]> wrote:
>  
>   
> Hello, 
>   
> I'm interested in writing with my own Python implementation of a Jabber IM
> server and client. 
> Anyone knows where I could host my Python Jabber IM server for a reasonable
> monlthy fee? It doesn't need to be a top-notch place since my goal is to
> test something else, not the scalability of the application. 
>   
> chrs 
> j. 
> ___

I use http://www.dreamhost.com - they have a jabber server already
running for you to use - not sure if this would interfere with what
you are trying to do.

Adam

-- 
http://www.monkeez.org
PGP key: 0x7111B833
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Replacement for 'Find' Module

2005-08-15 Thread Don Parris
On my Windows XP box running Python 2.4, I attempted to use the 'find'
module per the example in Programming Python (Ch. 2) - i.e.:
>>>import find
>>>find.find('*')

However, Python didn't find the find module.  The docs say it's now
deprecated, but don't point to what tool should be used to replace
find.  My Googling efforts haven't been fruitful so far.  Could
someone please point me in the right direction?

Don
-- 
DC Parris GNU Evangelist
http://matheteuo.org/
[EMAIL PROTECTED]
"Hey man, whatever pickles your list!"
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] parsing through an output stream

2005-08-15 Thread Alan G
> read the returned output stream in non-blocking mode. But, I did
> not getting any of the status messages given out by mplayer 

Traditionally status messages tend to be sent to stderr
rather than stdout (this means that they don't break Unix 
pipelines). But that means that to read them you will need 
to use popen2 (Or the new subprocess module) to access stderr.

I don't know for sure that mplayer is dping that but I'd say 
its a strong possibility.

HTH,

Alan G.



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


Re: [Tutor] Is it possible to...

2005-08-15 Thread jfouhy
Quoting Nathan Pinno <[EMAIL PROTECTED]>:

> Is it possible to create a def that not only deals cards, but also
> assigns a value to each rank, except that the Jacks, Queens, and Kings
> all are the same value as the 10s?
> If this is possible, how should I go about doing this?

Nearly everything is possible; you just have to order your thoughts correctly 
:-)

In this case, you're looking for a way of mapping from cards to values.  Python
has  a mapping type built in, called a dictionary.  You can read about it here:
http://docs.python.org/tut/node7.html#SECTION00750 and here:
http://docs.python.org/lib/typesmapping.html

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


Re: [Tutor] Replacement for 'Find' Module

2005-08-15 Thread Simon Gerber
You could probably do something like this... (Note: This example is
for Linux - but you can adapt it fairly easily to Windows.)


# E.g. Find every .inf file on a CD-ROM.
path = '/cdrom'  
# 'E:\\' or whatever for Windows 
inf_list = []
for root, dirs, files in os.walk(path):
for current_file in files:
if '.inf' in current_file:
   inf_list.append(os.path.join(root, current_file))

I, too, would be interested in knowing if anyone has a better way to do this :)
You would probably combine the 'glob' module with os.walk to grab what
you wanted, and build the list of files that way.

Lemme know what you figure out.

Cheers,

On 15/08/05, Don Parris <[EMAIL PROTECTED]> wrote:
> On my Windows XP box running Python 2.4, I attempted to use the 'find'
> module per the example in Programming Python (Ch. 2) - i.e.:
> >>>import find
> >>>find.find('*')
> 
> However, Python didn't find the find module.  The docs say it's now
> deprecated, but don't point to what tool should be used to replace
> find.  My Googling efforts haven't been fruitful so far.  Could
> someone please point me in the right direction?
> 
> Don
> --
> DC Parris GNU Evangelist
> http://matheteuo.org/
> [EMAIL PROTECTED]
> "Hey man, whatever pickles your list!"
> ___
> 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] How can I make this run right?

2005-08-15 Thread Simon Gerber
I'd do it like this... And there's probably an even quicker way, if
you really sat down and thought about it.

n = int(raw_input("Number: "))
x = n-1
while x > 1:
n *=x
x -=1
print n

The reason why it isn't working is because of
"
while x > 1:
x -= 1
"
When your program hits this point it stays in the while loop,
subtracting 1 from x each time, but not multiplying anything anymore,
until it hits break. So your program does this.

Number: 4
n = 5
x = 4
t = 20
x = 3
x = 2
x = 1
BREAK.



Cheers!

On 15/08/05, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
> The following code is supposed to take in a number, and print number!:
> n = int(raw_input("Number: "))
> x = n-1
> while 1:
> t = n*x
> while x > 1:
> x -= 1
> else:
> break
> print t
>
> Why isn't it working, and how can I make it print out the correct output?
>
> Thanks in advance,
> Nathan
> ---
> Early to bed,
> Early to rise,
> Makes a man healthy, wealthy, and wise.
> --Benjamin Franklin
> ---
> ___
> 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] Is it possible to...

2005-08-15 Thread Alan G
> Is it possible to create a def that not only deals cards, but also
> assigns a value to each rank, except that the Jacks, Queens, and 
> Kings
> all are the same value as the 10s?

Yes. And you probably need to use a dictionary to hold the value 
against
the card.

> Sorry if I'm asking what for most people is a basic question,

Nope, this is a very good question. I haven't been paying attention to
the card dealing functions posted recently but I assume adding in a
dictionary to assign a value per card dealt wouldn't be too hard.
You could then return the cards as tuples or somesuch...

Alan G


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


Re: [Tutor] How can I make this run right?

2005-08-15 Thread Alan G
> The following code is supposed to take in a number, and print 
> number!:
> n = int(raw_input("Number: "))
> x = n-1
> while 1:
>t = n*x
>while x > 1:
>x -= 1
>else:
>break
> print t
>
> Why isn't it working, and how can I make it print out the correct 
> output?

So give is a clue! What is it doing wrong? Is there an error message?
What output did you expect? What did you get?

Without that information we have to read the code and guess what you
were trying to do. Then try to guess what might be different to what
you expected.

Alan G. 

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


Re: [Tutor] How can I make this run right?

2005-08-15 Thread Alan G
> The following code is supposed to take in a number, and print 
> number!:
> n = int(raw_input("Number: "))
> x = n-1
> while 1:
>t = n*x
>while x > 1:
>x -= 1
>else:
>break
> print t
>
> Why isn't it working, and how can I make it print out the correct 
> output?

So give is a clue! What is it doing wrong? Is there an error message?
What output did you expect? What did you get?

Without that information we have to read the code and guess what you
were trying to do. Then try to guess what might be different to what
you expected.

Alan G. 

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


[Tutor] Event handler for optionmenu

2005-08-15 Thread Jorge Louis De Castro



Hi,
 
I have an optionmenu widget that works just fine 
except that  can't find docs to get hold of events as they happen, kinda 
like the command=XYZ of other widgets like buttons.
 
The code I'm using for the option menu is the 
following:
 
OPTIONS = 
["en","pt","es","it","fr","de"]self.startw.variable = 
StringVar()self.startw.variable.set(OPTIONS[0]) # default 
valueself.startw.whis_butt=apply(OptionMenu, (self.startw, 
self.startw.variable) + tuple(OPTIONS))self.startw.whis_butt.grid(column=1, 
row=3)
 
Now I'd like to have a function like:
 
def onChange(self):
 # do optionmenu specific 
stuff
 
but can't find how to do it, how to associate/bind 
onChange with the optionmenu widget.
Any help will be highly appreciated.
 
Chrs
j
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Event handler for optionmenu

2005-08-15 Thread geon




Jorge Louis De Castro napsal(a):

  
  
  
  Hi,
   
  I have an optionmenu widget that
works just fine except that  can't find docs to get hold of events as
they happen, kinda like the command=XYZ of other widgets like buttons.
   
  The code I'm using for the option
menu is the following:
   
  OPTIONS =
["en","pt","es","it","fr","de"]
self.startw.variable = StringVar()
self.startw.variable.set(OPTIONS[0]) # default value
self.startw.whis_butt=apply(OptionMenu, (self.startw,
self.startw.variable) + tuple(OPTIONS))
self.startw.whis_butt.grid(column=1, row=3)
   
  Now I'd like to have a function like:
   
  def onChange(self):
   # do optionmenu specific stuff
   
  but can't find how to do it, how to
associate/bind onChange with the optionmenu widget.
  Any help will be highly appreciated.
   

This art is called Trace Variable and could be used like this (copied
and rearranged from one of the prevously posted message from here):

from Tkinter import *

OPTIONS = [
    "egg",
    "bunny",
    "chicken"
]

def callbackFunc(name, index, mode):
  #print "callback called with name=%r, index=%r, mode=%r" % (name,
index, mode)
  varValue = root.getvar(name)
  print varValue
  # modify the value, just to show it can be done
  #root.setvar(name, varValue)

root = Tk()
var = StringVar()
var.set(OPTIONS[2]) # default value
rememberMe = var.trace_variable('w', callbackFunc)   
# var.trace('w', callbackFunc) # this works, too



w = OptionMenu (root, var, *OPTIONS)
w.pack()


root.mainloop()

Hope its what you asked for :-)
-- 
geon




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


Re: [Tutor] How can I make this run right?

2005-08-15 Thread R. Alan Monroe
> The following code is supposed to take in a number, and print number!:
> n = int(raw_input("Number: "))
> x = n-1
> while 1:
> t = n*x
> while x > 1:
> x -= 1
> else:
> break
> print t

> Why isn't it working, and how can I make it print out the correct output?

One thing you might find handy is IDLE's debugger (if you use IDLE).
Turn it on under Debug / Debugger. Make sure the "Source" checkbox is
checked. Then hit the step button to run your program in "slow motion"
so you can see everything it does one step at a time.

(You might have to temporarily click the output window to the front
when the raw_input wants you to type a number)

Alan

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


[Tutor] web gallery

2005-08-15 Thread paul . hendrick
Hi All,
I'd like to write some web gallery software from scratch for my
girlfriend. I've looked at the PIL (python imaging library) and I'm
using it to generate thumbnails from given images.
Something else i'd like to get done now though, is building an index of
images.
Are there any libs suited for this? basically I want an text index of
images, which contains the main image name, the thumbnail name, and a
description.

a new image can be added to the index either by adding it via ftp, or
through an html upload form with the comment in the form.

So basically, i'm after advice on indexes.

thanks for reading,
Paul

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


[Tutor] Would like some help

2005-08-15 Thread Howard Kao
Directly Quoted From the Python Cookbook
1.3 Constructing a Dictionary Without Excessive Quoting
Credit: Brent Burley

1.3.1 Problem
You'd like to construct a dictionary without having to quote the keys. 

1.3.2 Solution
Once you get into the swing of Python, you may find yourself
constructing a lot of dictionaries. However, the standard way, also
known as a dictionary display, is just a smidgeon more cluttered than
you might like, due to the need to quote the keys. For example:

data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
When the keys are identifiers, there's a cleaner way:

def makedict(**kwargs):
return kwargs
data = makedict(red=1, green=2, blue=3)
You might also choose to forego some simplicity to gain more power.
For example:

def dodict(*args, **kwds):
d = {}
for k, v in args: d[k] = v
d.update(kwds)
return d
tada = dodict(*data.items(  ), yellow=2, green=4)
End Quote

Hi guys, 
Above is a direct cut & paste from the book (hope I am not violating
any thing...).  I've read the Python docs and can understand the first
def example ok, I suppose.  However I would like some detailed
explaination about the second example, the dodict one.  How exactly
does it work?  It just puzzles me why this would be more powerful or
better, even though I can understand and agree that re-writting
programs makes good practice.  In fact that's what I am looking for
from reading this book.  Just hope someone can walk me through this
simple code.  Thanks for the help.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sorting a list of lists aka nested lists

2005-08-15 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> Note that in Python2.4+, you can use key= instead:
> 
> def sortKey(lst):
>  return lst[2]
> Quant.sort(key=sortKey)
> 
> This is more effient than specifying a different comparison function, because
> the key function is only called once for each element.

And instead of defining your own function you can use itertools.itemgetter() 
which is intended for this purpose:
import itertools
Quant.sort(key=itertools.itemgetter(2))

Kent

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


Re: [Tutor] Event handler for optionmenu

2005-08-15 Thread Jorge Louis de Castro
Hi,

Thanks for your reply. It wasn't lazyness, believe me, I did look around for 
solutions and found something similar to yours here:

http://www.astro.washington.edu/owen/TkinterSummary.html#TracingVariables

The problem is that I have a class and it wants the callback function to be 
a global name (I also can't figure out hot to pass parameters to it)

By being a global name I can't access the var with widget.getvar(), and it 
complains if I use root by saying:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
  File "C:\Workplace\python\piim\Tkclient.py", line 312, in doLangChoices
varValue = root.getvar(name)
AttributeError: Tkclient instance has no attribute 'getvar'


The code on the class follows:

class StartWin:

def initialize(self):
self.startw=Tk(className="Login")
self.startw.servlab=Label(self.startw, text="Server:")
self.startw.servin=Entry(self.startw, width=15)
self.startw.servlab.grid(column=0, row=0)
self.startw.servin.grid(column=1, row=0)
self.startw.portlab=Label(self.startw, text="Port:")
self.startw.portin=Entry(self.startw, width=15)
self.startw.portlab.grid(column=0, row=1)
self.startw.portin.grid(column=1, row=1)
self.startw.nicklab=Label(self.startw, text="Nickname:")
self.startw.nickin=Entry(self.startw, width=15)
self.startw.nicklab.grid(column=0, row=2)
self.startw.nickin.grid(column=1, row=2)
self.startw.l1=Label(self.startw, text="Language:")
self.startw.l1.grid(column=0, row=3)
OPTIONS = ["en","pt","es","it","fr","de"]
self.startw.variable = StringVar()
self.startw.variable.set(OPTIONS[0]) # 
default value
self.startw.variable.trace('w', 
doLangChoices) # trace choices
self.startw.whis_butt=apply(OptionMenu, (self.startw, 
self.startw.variable) + tuple(OPTIONS))
self.startw.whis_butt.grid(column=1, row=3)

self.startw.login_butt=Button(self.startw, text="Login", 
command=self.login)
self.startw.login_butt.grid(column=0, row=4)
self.startw.exit_butt=Button(self.startw, text="Exit", 
command=self.exit)
self.startw.exit_butt.grid(column=1, row=4)
self.startw.mainloop()

#connect client with inserted data
def login(self):
start_client(self.startw.servin.get(), 
int(self.startw.portin.get()), 
self.startw.nickin.get(), self.startw.variable.get())

def exit(self):
self.startw.quit()
self.startw.destroy()
#sys.exit()


def doLangChoices(name, index, mode):
print "callback called with name=%r, index=%r, mode=%r" % (name, 
index, mode)
# HOW TO ACCESS THE VAR VALUE HERE??
#varValue = root.getvar(name)
#print varValue

print "Client Started"
try:
conn=StartWin()
conn.initialize()
root=Tkclient()
thread.start_new_thread(listen_server, (client, root))
root.startWindow()
except Exception:
print "Client thread aborted"



>From: geon <[EMAIL PROTECTED]>
>To: Jorge Louis De Castro <[EMAIL PROTECTED]>
>CC: tutor@python.org
>Subject: Re: [Tutor] Event handler for optionmenu
>Date: Mon, 15 Aug 2005 11:41:30 +0200
>
>Jorge Louis De Castro napsal(a):
>
>>Hi,
>>  I have an optionmenu widget that works just fine except that  can't find 
>>docs to get hold of events as they happen, kinda like the command=XYZ of 
>>other widgets like buttons.
>>  The code I'm using for the option menu is the following:
>>  OPTIONS = ["en","pt","es","it","fr","de"]
>>self.startw.variable = StringVar()
>>self.startw.variable.set(OPTIONS[0]) # default value
>>self.startw.whis_butt=apply(OptionMenu, (self.startw, 
>>self.startw.variable) + tuple(OPTIONS))
>>self.startw.whis_butt.grid(column=1, row=3)
>>  Now I'd like to have a function like:
>>  def onChange(self):
>>  # do optionmenu specific stuff
>>  but can't find how to do it, how to associate/bind onChange with the 
>>optionmenu widget.
>>Any help will be highly appreciated.
>>
>
>This art is called Trace Variable and could be used like this (copied and 
>rearranged from one of the prevously posted message from here):
>
>from Tkinter import *
>
>OPTIONS = [
>"egg",
>"bunny",
>"chicken"
>]
>
>def callbackFunc(name, index, mode):
>  #print "callback called with name=%r, index=%r, mode=%r" % (name, index, 
>mode)
>  varValue = root.getvar(name)
>  print varValue
>  # modify the value, just to show it can be done
>  #root.setvar(name, varValue)
>
>root = Tk()
>var = StringVar()
>var.set(OPTIONS[2]) # defaul

Re: [Tutor] Event handler for optionmenu

2005-08-15 Thread geon
Jorge Louis de Castro napsal(a):

>Hi,
>
>Thanks for your reply. It wasn't lazyness, believe me, I did look around for 
>solutions and found something similar to yours here:
>
>http://www.astro.washington.edu/owen/TkinterSummary.html#TracingVariables
>
>The problem is that I have a class and it wants the callback function to be 
>a global name (I also can't figure out hot to pass parameters to it)
>
>By being a global name I can't access the var with widget.getvar(), and it 
>complains if I use root by saying:
>
>Exception in Tkinter callback
>Traceback (most recent call last):
>  File "C:\Python24\Lib\lib-tk\Tkinter.py", line 1345, in __call__
>return self.func(*args)
>  File "C:\Workplace\python\piim\Tkclient.py", line 312, in doLangChoices
>varValue = root.getvar(name)
>AttributeError: Tkclient instance has no attribute 'getvar'
>
>
>  
>
Not sure what Tkclient() is... seems to be not child od Tk(), cause 
there is no getvar() function...
Anyway I am not able to run your script cause you used there both tabs 
and spaces for indentation. (see the row OPTIONS = 
["en","pt","es","it","fr","de"], how much it is intended)

Shoudnt be there varValue = self.startw.getvar(name)? - just guessing - 
I can not check cause the indentation i scorrupted ;-)

geon


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


Re: [Tutor] Would like some help

2005-08-15 Thread luke
Howard,
I believe what's happening in the second example is that you can combine
dictionaries.
...
>>>d2 = {'hello':1,'hi':2}
>>>print d2.items()
[('hi',2),('hello',1)]

so in the second example you can just pass it a list of elements (.items())
and it will concatenate (append?) these to the new dictionary.
hope that helps.

Luke


- Original Message -
From: "Howard Kao" <[EMAIL PROTECTED]>
To: 
Sent: Monday, August 15, 2005 6:32 AM
Subject: [Tutor] Would like some help


> Directly Quoted From the Python Cookbook
> 1.3 Constructing a Dictionary Without Excessive Quoting
> Credit: Brent Burley
>
> 1.3.1 Problem
> You'd like to construct a dictionary without having to quote the keys.
>
> 1.3.2 Solution
> Once you get into the swing of Python, you may find yourself
> constructing a lot of dictionaries. However, the standard way, also
> known as a dictionary display, is just a smidgeon more cluttered than
> you might like, due to the need to quote the keys. For example:
>
> data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
> When the keys are identifiers, there's a cleaner way:
>
> def makedict(**kwargs):
> return kwargs
> data = makedict(red=1, green=2, blue=3)
> You might also choose to forego some simplicity to gain more power.
> For example:
>
> def dodict(*args, **kwds):
> d = {}
> for k, v in args: d[k] = v
> d.update(kwds)
> return d
> tada = dodict(*data.items(  ), yellow=2, green=4)
> End Quote
>
> Hi guys,
> Above is a direct cut & paste from the book (hope I am not violating
> any thing...).  I've read the Python docs and can understand the first
> def example ok, I suppose.  However I would like some detailed
> explaination about the second example, the dodict one.  How exactly
> does it work?  It just puzzles me why this would be more powerful or
> better, even though I can understand and agree that re-writting
> programs makes good practice.  In fact that's what I am looking for
> from reading this book.  Just hope someone can walk me through this
> simple code.  Thanks for the help.
> ___
> 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] LiveWires problems

2005-08-15 Thread Michael Murphy
Hi all

I'm having problems with installing LiveWire for python for Linux
(Linspire 5.0 to be exact) and I'm having trouble compiling setup.py.
Heres the results:

running install
running build
running build_py
running install_lib
creating /usr/lib/python2.3/site-packages/livewires
error: could not create '/usr/lib/python2.3/site-packages/livewires':
Permission denied

I'm new at this but I'm sure this is an easy fix but I can't figure it
out, any help is appreciated.
-- 

Mike

Erie Freeze will rise again!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Would like some help

2005-08-15 Thread Kent Johnson
Howard Kao wrote:
> Directly Quoted From the Python Cookbook
> Once you get into the swing of Python, you may find yourself
> constructing a lot of dictionaries. However, the standard way, also
> known as a dictionary display, is just a smidgeon more cluttered than
> you might like, due to the need to quote the keys. For example:
> 
> data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
> When the keys are identifiers, there's a cleaner way:
> 
> def makedict(**kwargs):
> return kwargs
> data = makedict(red=1, green=2, blue=3)

This recipe is obsolete; since Python 2.3 (at least) you can pass keyword args 
directly to the dict() constructor:
data = dict(red=1, green=2, blue=3)

> You might also choose to forego some simplicity to gain more power.
> For example:
> 
> def dodict(*args, **kwds):
> d = {}
> for k, v in args: d[k] = v
> d.update(kwds)
> return d
> tada = dodict(*data.items(  ), yellow=2, green=4)

This can now be written as 
tada = dict(data, yellow=2, green=4)

Kent

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


Re: [Tutor] LiveWires problems

2005-08-15 Thread ZIYAD A. M. AL-BATLY
On Mon, 2005-08-15 at 11:52 -0400, Michael Murphy wrote:
> Hi all
> 
> I'm having problems with installing LiveWire for python for Linux
> (Linspire 5.0 to be exact) and I'm having trouble compiling setup.py.
> Heres the results:
> 
> running install
> running build
> running build_py
> running install_lib
> creating /usr/lib/python2.3/site-packages/livewires
> error: could not create '/usr/lib/python2.3/site-packages/livewires':
> Permission denied
> 
> I'm new at this but I'm sure this is an easy fix but I can't figure it
> out, any help is appreciated.
Most likely you need "root" privileges to change anything under "/usr".
If you trust the code, try running it again as "root" (also known as
"super-user").  Only do that if you're certain that the code is clean
(i.e. no viruses, trojans, spyware and/or worms)!

(Sorry, I don't know anything about Linspire, or else I would guide you
step by step on how to do that!.  In general, try "sudo" with your own
password, or "su" with root's password.)
Ziyad.

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


Re: [Tutor] How can I make this run right?

2005-08-15 Thread Nathan Pinno
I put in a 4 and expected 24, and instead got 12. It is supposed to give 4! 
not 4*3.
---
Early to bed,
Early to rise,
Makes a man healthy, wealthy, and wise.
--Benjamin Franklin
---
- Original Message - 
From: "Alan G" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>; "Tutor mailing list" 

Sent: Monday, August 15, 2005 2:20 AM
Subject: Re: [Tutor] How can I make this run right?


>> The following code is supposed to take in a number, and print number!:
>> n = int(raw_input("Number: "))
>> x = n-1
>> while 1:
>>t = n*x
>>while x > 1:
>>x -= 1
>>else:
>>break
>> print t
>>
>> Why isn't it working, and how can I make it print out the correct output?
>
> So give is a clue! What is it doing wrong? Is there an error message?
> What output did you expect? What did you get?
>
> Without that information we have to read the code and guess what you
> were trying to do. Then try to guess what might be different to what
> you expected.
>
> Alan G.
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make this run right?

2005-08-15 Thread luke

> I put in a 4 and expected 24, and instead got 12. It is supposed to give
4!
> not 4*3.
[snip rest of message]

nathan
your problem is easy to see...
> >> n = int(raw_input("Number: "))
> >> x = n-1
> >> while 1:
> >>t = n*x
> >>while x > 1:
> >>x -= 1
> >>else:
> >>break
> >> print t

think about it for a *while*...
Hint *while*
hint hint *change the while*
hint hint hint *the inner while*

nathan I see that you want to do n!(factorial)
but when you explained it you just said you wanted number!
which is confusing because I think everyone thought you were just excited.
you could always use a recursive function for factorial, IE.

def factorial(n):
 if n > 1:
  return factorial(n-1) * n
 else:
  return n

HTH,
Luke
P.S. Try to fix yours it'll help you.  tell me if you get it working
correctly.

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


Re: [Tutor] How can I make this run right?

2005-08-15 Thread geon
Nathan Pinno napsal(a):

>I put in a 4 and expected 24, and instead got 12. It is supposed to give 4! 
>not 4*3.
>---
>  
>

Dear Nathan,

Everyone is giving you very good hints but seems to me you keep to 
resist :-)
Looks like you always wait for complete solution, dont you?
Here it is. There is one add and two changes. Can you see them?

n = int(raw_input("Number: "))
x = n-1
t=n
while 1:
   t = t*x
   if x > 1:
   x -= 1
   else:
   break
print t

Its not the best solution for number!, but it is yours (and a bit of 
mine :-) )

-- 
geon


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


Re: [Tutor] web gallery

2005-08-15 Thread Luis N
On 8/15/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'd like to write some web gallery software from scratch for my girlfriend. 
> I've looked at the > PIL (python imaging library) and I'm using it to 
> generate thumbnails from given images.
> Something else i'd like to get done now though, is building an index of 
> images.
>
> Are there any libs suited for this? basically I want an text index of images, 
> which 
> contains the main image name, the thumbnail name, and a description. a new 
> image can > be added to the index either by adding it via ftp, or through an 
> html upload form with the  > comment in the form.
> 
> So basically, i'm after advice on indexes.
> 
> thanks for reading,
> Paul
> 

You may find this useful: http://freshmeat.net/projects/python-exif/

I think you need to write a script, cgi or otherwise, which will read
a particular directory to create your index, including:

imagedir = 'path'

import os 
for item in os.listdir(imagedir):
#grab some info about the image.


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


Re: [Tutor] Python hosting again

2005-08-15 Thread Luis N
On 8/11/05, Jorge Louis De Castro <[EMAIL PROTECTED]> wrote:
> Hello, 
>   
> I'm interested in writing with my own Python implementation of a Jabber IM
> server and client. 
> Anyone knows where I could host my Python Jabber IM server for a reasonable
> monlthy fee? It doesn't need to be a top-notch place since my goal is to
> test something else, not the scalability of the application. 
>   
> chrs 
> j. 

I think you will find http://hub.org to be an excellent host. You get
a VPS for about $12/month They are the host of the
http://postgresql.org project

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


Re: [Tutor] Replacement for 'Find' Module

2005-08-15 Thread Luis N
On 8/15/05, Simon Gerber <[EMAIL PROTECTED]> wrote:
> You could probably do something like this... (Note: This example is
> for Linux - but you can adapt it fairly easily to Windows.)
> 
> 
> # E.g. Find every .inf file on a CD-ROM.
> path = '/cdrom'
> # 'E:\\' or whatever for Windows
> inf_list = []
> for root, dirs, files in os.walk(path):
> for current_file in files:
> if '.inf' in current_file:

if current_file.endswith('.inf'): #or current_file[:-4] might be more
appropriate, just my 2c

I wrote this in a script for limited globbing:

if cd:
toss = os.path.join(trashcan, os.path.split(i)[1])
pwd = os.getcwd()
else:
toss = os.path.join(trashcan, i)

if toss[-1] == '*': 
crumple = []
if cd:
l = os.listdir(cd)
for i in l:
crumple.append(os.path.join(cd, i))
else:
crumple = os.listdir('.')
for i in crumple:
if i.startswith(toss[:-1]):
junk.append(i)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make this run right?

2005-08-15 Thread Alan G

>I put in a 4 and expected 24, and instead got 12. It is supposed to 
>give 4!
> not 4*3.

Thanks Nathan. It would be good to get that kind of detail when you 
post
the initial message. Your function didn't look like the usual 
factorial
function.

FWIW here is my version :-)

def factorial(n):
   result = 1
   for x in range(2,n+1):
  result *= x
   return result

By avoiding while loops you avoid all the mess of trying to maintain
the counter - one of the most common causes of errors in programming!

For a different approach see the recursion topic in my tutor.

HTH,

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


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


[Tutor] convert a file from plaintext(Ascii) to unicode? very quick questions

2005-08-15 Thread D. Hartley
Hello guys!

Is there a way to convert a file from plaintext(Ascii) to unicode?  I
have found all my notes about moving between hex., int's, chr's,
ord's, etc, but all of these things were only riddle exercises to me
and I have a hard time keeping them straight.  I'm pretty sure I knew
the answer to this and now cannot find it anywhere (even googling
through my old tutor posts!)

Does anyone have a quick answer/pointer?

Thanks so much!

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


Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quickquestions

2005-08-15 Thread luke
um...
>>> help(unicode)
Help on class unicode in module __builtin__:
[snip help stuff]
 |  encode(...)
 |  S.encode([encoding[,errors]]) -> string or unicode
 |
 |  Encodes S using the codec registered for encoding. encoding defaults
 |  to the default encoding. errors may be given to set a different
error
 |  handling scheme. Default is 'strict' meaning that encoding errors
raise
 |  a UnicodeEncodeError. Other possible values are 'ignore', 'replace'
and
 |  'xmlcharrefreplace' as well as any other name registered with
 |  codecs.register_error that can handle UnicodeEncodeErrors.

[snip rest of help]

Denise,
I dont know much about Unicode but it seems like
f = file(filename, "r")
text = f.readlines()
text = text.encode()
#or maybe just text.encode()?
f.close()

should encode the filetext to unicode.
then you could do a
f = file(filename, "w")
f.writelines(text)
f.close()

sorry I don't know more about it but I hope that helps you.
-Luke
- Original Message -
From: "D. Hartley" <[EMAIL PROTECTED]>
To: "Python tutor" 
Sent: Monday, August 15, 2005 7:49 PM
Subject: [Tutor] convert a file from plaintext(Ascii) to unicode? very
quickquestions


> Hello guys!
>
> Is there a way to convert a file from plaintext(Ascii) to unicode?  I
> have found all my notes about moving between hex., int's, chr's,
> ord's, etc, but all of these things were only riddle exercises to me
> and I have a hard time keeping them straight.  I'm pretty sure I knew
> the answer to this and now cannot find it anywhere (even googling
> through my old tutor posts!)
>
> Does anyone have a quick answer/pointer?
>
> Thanks so much!
>
> ~Denise
> ___
> 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] Would like some help

2005-08-15 Thread Howard Kao
Thanks for the help Luke and Kent.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quickquestions

2005-08-15 Thread luke
List:
I'm forwarding this private message(hope you don't mind Denise)
I personally have no idea what to do, but
someone else might be able to help.
-Luke


- Forwarded Message -

text is a list, so you can't encode it.  but you can iterate over each
of the elements and encode them.  I have tried several variations of
that, but keep ending up with all my newlines being little boxes. any
ideas?

Thanks,
Denise

On 8/15/05, luke <[EMAIL PROTECTED]> wrote:
> um...
> >>> help(unicode)
> Help on class unicode in module __builtin__:
> [snip help stuff]
>  |  encode(...)
>  |  S.encode([encoding[,errors]]) -> string or unicode
>  |
>  |  Encodes S using the codec registered for encoding. encoding
defaults
>  |  to the default encoding. errors may be given to set a different
> error
>  |  handling scheme. Default is 'strict' meaning that encoding errors
> raise
>  |  a UnicodeEncodeError. Other possible values are 'ignore',
'replace'
> and
>  |  'xmlcharrefreplace' as well as any other name registered with
>  |  codecs.register_error that can handle UnicodeEncodeErrors.
>
> [snip rest of help]
>
> Denise,
> I dont know much about Unicode but it seems like
> f = file(filename, "r")
> text = f.readlines()
> text = text.encode()
> #or maybe just text.encode()?
> f.close()
>
> should encode the filetext to unicode.
> then you could do a
> f = file(filename, "w")
> f.writelines(text)
> f.close()
>
> sorry I don't know more about it but I hope that helps you.
> -Luke
> - Original Message -
> From: "D. Hartley" <[EMAIL PROTECTED]>
> To: "Python tutor" 
> Sent: Monday, August 15, 2005 7:49 PM
> Subject: [Tutor] convert a file from plaintext(Ascii) to unicode? very
> quickquestions
>
>
> > Hello guys!
> >
> > Is there a way to convert a file from plaintext(Ascii) to unicode?  I
> > have found all my notes about moving between hex., int's, chr's,
> > ord's, etc, but all of these things were only riddle exercises to me
> > and I have a hard time keeping them straight.  I'm pretty sure I knew
> > the answer to this and now cannot find it anywhere (even googling
> > through my old tutor posts!)
> >
> > Does anyone have a quick answer/pointer?
> >
> > Thanks so much!
> >
> > ~Denise
> > ___
> > 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 maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quick questions

2005-08-15 Thread Bob Gailer
At 06:49 PM 8/15/2005, D. Hartley wrote:
>Hello guys!
>
>Is there a way to convert a file from plaintext(Ascii) to unicode?  I
>have found all my notes about moving between hex., int's, chr's,
>ord's, etc, but all of these things were only riddle exercises to me
>and I have a hard time keeping them straight.  I'm pretty sure I knew
>the answer to this and now cannot find it anywhere (even googling
>through my old tutor posts!)
>
>Does anyone have a quick answer/pointer?

Try the unicode() built-in function. Read the file into a variable, apply 
the unicode() function, write the result.

Bob Gailer
303 442 2625 home
720 938 2625 cell 

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


[Tutor] From file2.py append an item to file1.py combobox

2005-08-15 Thread _ Dan _
Hi to all:
How can I append some data from file1.py to a combobox
on file2.py?
I know, if you want to append data to a combobox
inside the same script, I would be like follows:

# file1.py
import wx
class Myframe(wx.Frame):
  def __init__(self, *args, **kwds):
...
self.mycombobox = wx.Combobox(...
...
# and then...

self.mycombobox.Append("Item")

# would append to the combobox a new item.



# file2.py
# So here are my problems...
# I got:
import wx,file1
class Subframe(wx.Frame):
  def __init__(self, *args, **kwds)
  ...

  def Mymethod(self,event):
file1.Myframe.mycombobox.Append("Item")

  # and it doesnt work...
  # file1.Myframe.self.mycombobox.Append("item")
  # does not work either..

What can I do? thanks in advance
Daniel.









__ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quickquestions

2005-08-15 Thread Kent Johnson
I think Luke's suggestion will work if you use f.read() (to read the whole file 
as a single string) instead of f.readlines() and f.write() instead of 
writelines().

Kent

luke wrote:
> List:
> I'm forwarding this private message(hope you don't mind Denise)
> I personally have no idea what to do, but
> someone else might be able to help.
> -Luke
> 
> 
> - Forwarded Message -
> 
> text is a list, so you can't encode it.  but you can iterate over each
> of the elements and encode them.  I have tried several variations of
> that, but keep ending up with all my newlines being little boxes. any
> ideas?
> 
> Thanks,
> Denise
> 
> On 8/15/05, luke <[EMAIL PROTECTED]> wrote:
>>I dont know much about Unicode but it seems like
>>f = file(filename, "r")
>>text = f.readlines()
>>text = text.encode()
>>#or maybe just text.encode()?
>>f.close()
>>
>>should encode the filetext to unicode.
>>then you could do a
>>f = file(filename, "w")
>>f.writelines(text)
>>f.close()

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