Re: [Tutor] help

2005-08-10 Thread mailing list
Also, you may want to consider something like easygui - http://www.ferg.org/easygui/ if all you need is simple dialogs. You may also want to consider Pythoncard - pythoncard.sourceforge.net, it's quite capable of more elaborate GUI stuff, but it's built on wxPython, which can be a little

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
Hi Negroup, First off, you may want to use os.path.join to create paths - path = 'categories/%s' % self.name could be - path = os.path.join(categories, self.name) This will ensure minimum hassle if you ever want to use this across multiple OS. Also, it looks a little tidier, and IMAO,

Re: [Tutor] Question on classes/instances

2005-08-10 Thread mailing list
Erk, I of course meant - path = os.path.join('categories', self.name) On 8/10/05, mailing list [EMAIL PROTECTED] wrote: Hi Negroup, First off, you may want to use os.path.join to create paths - path = 'categories/%s' % self.name could be - path = os.path.join(categories, self.name)

Re: [Tutor] What can I do with this code?

2005-08-10 Thread python-tutor
How about changing it into a math quiz program? You have the program output random problems (What is 14 * 3 ?) And then you can output appropriate random insults, words of encouragement, or praise as appropriate until the user gets the answer right. Just be careful with division. You

[Tutor] Customized endswith/startswith version

2005-08-10 Thread Negroup -
Hi. f = open('codes.txt') # valid codes starts with 'abc' or '123' or 'ff5' [valid for valid in f.readlines() if valid.startswith('abc') or valid.startswith('123') or valid.startswith('ff5')] This is just an example, in my application I don't need to check strings against a huge number of

Re: [Tutor] Customized endswith/startswith version

2005-08-10 Thread Kent Johnson
Michael Janssen wrote: On 8/10/05, Negroup - [EMAIL PROTECTED] wrote: how to modify startswith in order to make it accept a list instead of a simple string? [valid for valid in f.readlines() if valid.startswith(['abc', '123', 'ff5'])] the easy way is not to use the string method startwith

Re: [Tutor] Customized endswith/startswith version

2005-08-10 Thread Kent Johnson
Negroup - wrote: My solution is: foo.py class MyStr(str): def myStartsWith(self, options=[]): if (type(options) != type([]) or not options): return 'Error' else: for option in options: if self.startswith(option):

[Tutor] SSH commands in Python on Linux

2005-08-10 Thread Bernard Lebel
Hello, I'm trying to make a script to send a SSH command from a Linux computer to another Linux compter. The Python syntax I'm using... import os os.system( 'ssh [EMAIL PROTECTED] ls' ) Now the problem is that I'm always asked for the password. So my question is two-fold: 1- Is there a way

Re: [Tutor] SSH commands in Python on Linux

2005-08-10 Thread python-tutor
Ignoring the python stuff for the moment In answer to Question 1., You want to use Public Key authentication...this will let you log in without a password.Google for SSH Public Key Authentication will give you several hits for the howto's One pretty good one was

[Tutor] Untainting CGI parameters

2005-08-10 Thread Jan Eden
Hi, I would like to untaint all parameters with which my CGI script is called. Example: if parameters.has_key('type'): match = re.search('\w+', parameters['type'].value) type = match.group() else: type = 'page' In Perl, I used the ternary operator to write it like this: my $type =

Re: [Tutor] Untainting CGI parameters

2005-08-10 Thread Kent Johnson
Jan Eden wrote: Hi, I would like to untaint all parameters with which my CGI script is called. Example: if parameters.has_key('type'): match = re.search('\w+', parameters['type'].value) type = match.group() else: type = 'page' OK, I don't know much Perl but I don't think these

Re: [Tutor] Customized endswith/startswith version

2005-08-10 Thread Danny Yoo
This is just an example, in my application I don't need to check strings against a huge number of cases. If however it would happen, how to modify startswith in order to make it accept a list instead of a simple string? [valid for valid in f.readlines() if valid.startswith(['abc', '123',

Re: [Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-10 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 23:31: Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?. Nathan Nathan, I write this

[Tutor] distutils?

2005-08-10 Thread Jeff Peery
Hello, I was wondering what is the difference between the distutils core and py2exe... they look the same to me? thanks.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] SSH commands in Python on Linux

2005-08-10 Thread Martin Walsh
Bernard Lebel wrote: Hello, Hi Bernard, I'm trying to make a script to send a SSH command from a Linux computer to another Linux compter. The Python syntax I'm using... import os os.system( 'ssh [EMAIL PROTECTED] ls' ) Now the problem is that I'm always asked for the password.

Re: [Tutor] distutils?

2005-08-10 Thread Kent Johnson
Jeff Peery wrote: Hello, I was wondering what is the difference between the distutils core and py2exe... they look the same to me? thanks. distutils.core basically installs the .py files needed by an application or library. It can also build extension modules, but it doesn't try to install

Re: [Tutor] distutils?

2005-08-10 Thread Kent Johnson
I should add that distutils gives you some help on the packaging end of things, too - not just for installing. And py2exe is an addon to distutils. Kent Kent Johnson wrote: Jeff Peery wrote: Hello, I was wondering what is the difference between the distutils core and py2exe... they look the

[Tutor] Net mask in hex. to dec.

2005-08-10 Thread Jonas Melian
Hi, I get the netmask (mask=0xff00) from ifconfig in openbsd, and i would convert it to decimal (255.255.255.0) I think that socket module doesn't help on this. So I'll have to make something as this for separate 'mask' [s[i:i+2] for i in range(0, len(s), 2)] then i could use int('', 16)

Re: [Tutor] Customized endswith/startswith version

2005-08-10 Thread Alan G
| [valid for valid in f.readlines() if valid.startswith('abc') or | valid.startswith('123') or valid.startswith('ff5')] | | how to modify startswith in order to make it accept a list instead of | a simple string? | | [valid for valid in f.readlines() if valid.startswith(['abc', '123', 'ff5'])]

Re: [Tutor] SSH commands in Python on Linux

2005-08-10 Thread Alan G
import os os.system( 'ssh [EMAIL PROTECTED] ls' ) system is probably the wrong thing to use here since it doesn't return any output only a final error code. 1- Is there a way to not be asked for the root password? Yes but you need to set up user security keys and such. The ssh man pages

Re: [Tutor] Untainting CGI parameters

2005-08-10 Thread Alan G
I would like to untaint all parameters with which my CGI script is called. Example: Can you explain 'untaint'??? Not a term I'm familiar with... if parameters.has_key('type'): match = re.search('\w+', parameters['type'].value) type = match.group() else: type = 'page' I Python

[Tutor] AppendText as new lines

2005-08-10 Thread _ Dan _
Hi, to all. Well, I have some list results that I must write to a Window. This is what I have tu show: (('Name1',), ('Name2',)) This is my show function def Listar_Mostrar(self,event): connect = MySQLdb.connect(host,user,passwd,db) cursor = connect.cursor()

Re: [Tutor] AppendText as new lines

2005-08-10 Thread Kent Johnson
_ Dan _ wrote: for record in result: self.text_ctrl_listar.AppendText(record[0]) The results are shown in the text window as: Name1Name2 And what I really want to do is something like this: Name1 Name2 Looks like you need some newlines:

[Tutor] pls. help me in sorting and choosing

2005-08-10 Thread Srinivas Iyyer
Dear Group: After cutting short a lot of gory detail, I finally arrived at atomic level of my problem and here I crash. I guess this crash is due to not so strong logic (hopefully i get better with more and more exerise in solving problems). I have a file with two columns: Column A (accession

Re: [Tutor] pls. help me in sorting and choosing

2005-08-10 Thread jfouhy
Quoting Srinivas Iyyer [EMAIL PROTECTED]: My question is how can I code to distinguish all high scoring group and all low scoring group. One thing you need to decide is what it means to be high scoring. Is an element high scoring if its score is above some threshhold, or it a percentage? Or

Re: [Tutor] pls. help me in sorting and choosing

2005-08-10 Thread Srinivas Iyyer
Hi John: thank you for your reply: There is no cutoff. I would choose top 20% of the all the scores. 2. I know how to read a tab delim txt file as list but not into the tupeles. Apologies for my inexperience. can you please help me further. thanks srini --- [EMAIL PROTECTED] wrote:

Re: [Tutor] pls. help me in sorting and choosing

2005-08-10 Thread jfouhy
Quoting Srinivas Iyyer [EMAIL PROTECTED]: 2. I know how to read a tab delim txt file as list but not into the tupeles. Apologies for my inexperience. How are you currently reading the file? --- can you show us some code? You can create tuples directly. For example: x = 3 y = 7 t = (x,