Re: [Tutor] str.split and quotes

2005-04-05 Thread Brian van den Broek
Tony Meyer said unto the world upon 2005-04-06 01:59: s = 'Hi "Python Tutors" please help' s.split() ['Hi', '"Python', 'Tutors"', 'please', 'help'] I wish it would leave the stuff in quotes in tact: ['Hi', '"Python Tutors"', 'please', 'help'] You can do this with a regular expression: Or you can

[Tutor] str.split and quotes

2005-04-05 Thread Marilyn Davis
Hi Tutors, I need a little help with this, if anyone has the time and inclination: >>> s = 'Hi "Python Tutors" please help' >>> s.split() ['Hi', '"Python', 'Tutors"', 'please', 'help'] >>> I wish it would leave the stuff in quotes in tact: ['Hi', '"Python Tutors"', 'please', 'help'] Any sugge

RE: [Tutor] str.split and quotes

2005-04-05 Thread Tony Meyer
> I recommend this http://www.amk.ca/python/howto/regex/ > and python2x/tools/scripts/redemo.py to learn how to use regexes well. I also highly recommend for learning how to use regexes. In addition, Kodos is a great tool to both experiment around with reg

Re: [Tutor] str.split and quotes

2005-04-05 Thread Liam Clarke
Hi Marilyn, Before you get numerous suggestions to use regexes (which was my first idea), you could use the split method to do it - >>> q = 'Hi "Python Tutors" please help' >>> w = q.split('\"') >>> print w ['Hi ', 'Python Tutors', ' please help'] I'm splitting using a double speech mark as t

RE: [Tutor] str.split and quotes

2005-04-05 Thread Tony Meyer
> >>> s = 'Hi "Python Tutors" please help' > >>> s.split() > ['Hi', '"Python', 'Tutors"', 'please', 'help'] > >>> > > I wish it would leave the stuff in quotes in tact: > > ['Hi', '"Python Tutors"', 'please', 'help'] You can do this with a regular expression: >>> import re >>> re.findall(r'\".

Re: [Tutor] Re: If elif not working in comparison

2005-04-05 Thread Brian van den Broek
gerardo arnaez said unto the world upon 2005-04-05 23:00: Hi all. I would like some crituqe on this code. It is three separate files (all put on one web page) Each one is labeled in the comment that begins each section of code. It is a little longer when I put it all on one page, so I have it up on

[Tutor] Birthday Book

2005-04-05 Thread Kedar Tangudu
Hi I am building a birthday book for myself and would appreciate some quick help from you. Just click on the link below and enter your birthday details. It's easy and you can keep your age secret!... http://www.BirthdayAlarm.com/bd1/38729335a575244353b530591538c915052256d1386 Thanks Kedar

Re: [Tutor] Re: If elif not working in comparison

2005-04-05 Thread gerardo arnaez
Hi all. I would like some crituqe on this code. It is three separate files (all put on one web page) Each one is labeled in the comment that begins each section of code. It is a little longer when I put it all on one page, so I have it up on a link. If any kind souls would critique it before I mo

Re: [Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Jacob S.
Type this into the interpreter and post the results - copy and pasted, not hand typed. import sys for x in sys.path: print x## This is indented It should give you a list of paths -- these are all of the paths that python looks for modules in. My guess is that you don't have the fo

Re: [Tutor] Calendar question

2005-04-05 Thread Jacob S.
Also, I have been looking for some exercises to do using Python, obviously (and unfortunately) they need to be at a beginner level. Or better if anyone wants to send me one to do I would be very grateful I know a few exercises -- those that I have done. Some are beginner, some are difficult. Use

Re: [Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Chad Crabtree
The symptoms you explain mean you don't have py2exe installed correctly. Try uninstalling it and reinstalling it. Joseph Quigley wrote: > Joseph Q. (Uspantan, Guatemala) Using Python 2.4 > > I downloaded py2exe and can't get it to make exe's of my python files. > There are a list of instructi

RE: [Tutor] Re: Calendar question

2005-04-05 Thread jfouhy
Quoting John Carmona <[EMAIL PROTECTED]>: Hi John, Some comments --- > import calendar > > MonthName = {'January': 1,'February': 2, 'March': 3,'April': 4\ > ,'May': 5,'June': 6,'July': 7,'August': 8,\ > 'September': 9,'October': 10,'November': 11,'December': 12} You can actually get away wit

RE: [Tutor] Re: Calendar question

2005-04-05 Thread John Carmona
Roel you wrote: - A dictionary is a data structure containing keys and values that defines a mapping from each key to its corresponding value. You define it like this: >>> squares = {1: 1, 10: 100, 4: 15,

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Shidai Liu
On Apr 5, 2005 3:40 PM, Bernard Lebel <[EMAIL PROTECTED]> wrote: > As far as I'm aware, this is very normal. The file is being used by an > application, so there is a lock on it. > However, os.access('somefile.csv', os.W_OK) returns True. Shouldn't it return False? ___

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Shidai Liu
On Apr 5, 2005 6:33 PM, Nick Lunt <[EMAIL PROTECTED]> wrote: > I havent got access to a windows box unfortunately at the moment. And I > have no idea about permissions on windows boxes anyway :) > However, did you already have the .csv file open in Excel or some other > app ? Or is is password prot

Re: [Tutor] Major Newbie Here

2005-04-05 Thread jfouhy
Quoting Danny Yoo <[EMAIL PROTECTED]>: > Try: > > ## > class Spam: > """A meat for combining with other foods > It can be used with other foods to make interesting meals. > It comes with lots of nutrients and can be cooked using many > different techniques""" > > def__init__(self): > #

Re: [Tutor] Re: random import errors

2005-04-05 Thread Jay Loden
Only one version installed, and I could copy it over from elsewhere, but I wouldn't be inclined to do so since it works right now. -Jay On Tuesday 05 April 2005 10:22 pm, Lee Harr wrote: > >I have a python script that runs on my webserver every fifteen minutes. > > It has run for several month

[Tutor] Re: Script (Python) for Zope

2005-04-05 Thread Lee Harr
Hello, I am looking for a Python-script for Zope which counts the objects (files) in the current folder and all its subfolders, but I don't know how to implement this script. Can somebody help me, please? Or ist there a newsgroup/mailing list which can help me to find a solution for this problem? T

[Tutor] Re: random import errors

2005-04-05 Thread Lee Harr
I have a python script that runs on my webserver every fifteen minutes. It has run for several months with absolutely no problems. Suddenly, yesterday morning I got an email from cron with an import error for sre_constants (see below) File "/usr/lib/python2.2/sre_compile.py", line 15, in ?

[Tutor] Re: Major Newbie Here

2005-04-05 Thread Roel Schroeven
[EMAIL PROTECTED] wrote: > Hello all, > > I'm a cell biologist that is learning python. I've been following Alan > Gauld's tutorial online and I've hit a wall. > > I'm typing > > class Spam: > """A meat for combining with other foods > > It can be used with other foods to make interes

Re: [Tutor] Major Newbie Here

2005-04-05 Thread Danny Yoo
> I'm a cell biologist that is learning python. I've been following Alan > Gauld's tutorial online and I've hit a wall. > > I'm typing > > class Spam: > """A meat for combining with other foods > > It can be used with other foods to make interesting meals. > It comes with lots

Re: [Tutor] Major Newbie Here

2005-04-05 Thread Kristian Zoerhoff
On Apr 5, 2005 2:49 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm a cell biologist that is learning python. I've been following Alan > Gauld's tutorial online and I've hit a wall. > > I'm typing > > class Spam: > """A meat for combining with other foods > >

[Tutor] Re: Calendar question

2005-04-05 Thread Roel Schroeven
John Carmona wrote: > Kristian you wrote: > > - > > This assumes all input as integers; if you want months entered by > name, you'll have to write a conversion routine (hint: use a dict). > --

[Tutor] Major Newbie Here

2005-04-05 Thread glaevsky
Hello all, I'm a cell biologist that is learning python. I've been following Alan Gauld's tutorial online and I've hit a wall. I'm typing class Spam: """A meat for combining with other foods It can be used with other foods to make interesting meals. It comes with lots of

Fwd: [Tutor] Calendar question

2005-04-05 Thread Kristian Zoerhoff
Forgot to Reply-All. Dagnabbit. -- Forwarded message -- From: Kristian Zoerhoff <[EMAIL PROTECTED]> Date: Apr 5, 2005 3:33 PM Subject: Re: [Tutor] Calendar question To: John Carmona <[EMAIL PROTECTED]> On Apr 5, 2005 3:08 PM, John Carmona <[EMAIL PROTECTED]> wrote: > Kristian you

[Tutor] Mouseclick

2005-04-05 Thread Øyvind
I am creating a little application that demonstrates some tasks on the screen for the user, but cannot seem to click the left mousebutton. I have moved the cursor to the correct position by >>> from ctypes import * >>> windll.user32.SetCursorPos(100, 400) and would like to click the left mousebu

Re: [Tutor] Calendar question

2005-04-05 Thread John Carmona
Kristian you wrote: - This assumes all input as integers; if you want months entered by name, you'll have to write a conversion routine (hint: use a dict). ---

Re: [Tutor] pickle in unicode format

2005-04-05 Thread Danny Yoo
> Are you trying to send it off to someone else as a part of an XML > document? If you are including some byte string into an XML document, > you can encode those bytes as base64: > > ## > >>> bytes = 'Fran\xe7ois' > >>> encodedBytes = bytes.encode('base64') > >>> encodedBytes > 'RnJhbudvaXM=\

Re: [Tutor] pickle in unicode format

2005-04-05 Thread Danny Yoo
> > I have this dictionnary : > > > > a={'partition': u'/export/diskH1/home_evol/ricquebo', > > 'rsmFirstname': u'Fran\xe7ois', > > 'rsmLastname': u'Ricquebourg', > > 'size': u'8161222.0', > > 'size_max': '1'} > > > > and I'd like to *serialize* it with pickle and that the output format > > w

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Nick Lunt
Shidai Liu wrote: I found out in the following situation, it fails to work. Say, 'somefile.csv' is opened by EXCEL, os.access('somefile.csv', os.W_OK) True file('somefile.csv', 'w') IOError: [Errno 13] Permission denied: 'somefile.csv' By the way, using os.stat & stat a

Re: [Tutor] pickle in unicode format

2005-04-05 Thread Kent Johnson
Kent Johnson wrote: BRINER Cedric wrote: unicode(pickle.dumps(a)) doesn't work ! pickle.dumps() doesn't return a value, it puts the data into 'a' which must be a file-like object. Oops, pickle.dumps() does return a value and the parameter is the object to be pickled. I even knew that before I se

Re: [Tutor] Calendar question

2005-04-05 Thread John Carmona
Thanks Kristian, it works a treat. Now you have set me up with finding out how to use the months entered by name. If I am stuck I will post again. Thanks very much JC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Calendar question

2005-04-05 Thread Kristian Zoerhoff
On Apr 5, 2005 11:26 AM, John Carmona <[EMAIL PROTECTED]> wrote: > But how do you use the prmonth command, if you, for example, want to write > something asking you: > > to enter a year (this I know) > to enter a month of that year > and print just the month >>> import calendar >>> year = int(raw

[Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Joseph Quigley
Joseph Q. (Uspantan, Guatemala) Using Python 2.4 I downloaded py2exe and can't get it to make exe's of my python files. There are a list of instructions: # A very simple setup script to create 2 executables. # # hello.py is a simple "hello, world" type program, which alse allows # to explore the

[Tutor] Calendar question

2005-04-05 Thread John Carmona
I am back, thanks again all to help me sorting out the High_Low guessing game using time. Can somebody put me on the right track for the following script. I know how to use the calendar.prcal command to print the 12 months of choosen year. But how do you use the prmonth command, if you, for exa

Re: [Tutor] pickle in unicode format

2005-04-05 Thread Kent Johnson
BRINER Cedric wrote: hi, I have this dictionnary : a={'partition': u'/export/diskH1/home_evol/ricquebo', 'rsmFirstname': u'Fran\xe7ois', 'rsmLastname': u'Ricquebourg', 'size': u'8161222.0', 'size_max': '1'} and I'd like to *serialize* it with pickle and that the output format will be of type un

Re: [Tutor] [HELP]how to test properties of a file

2005-04-05 Thread Bernard Lebel
As far as I'm aware, this is very normal. The file is being used by an application, so there is a lock on it. Cheers Bernard On Apr 4, 2005 7:34 PM, Shidai Liu <[EMAIL PROTECTED]> wrote: > I found out in the following situation, it fails to work. > Say, 'somefile.csv' is opened by EXCEL, > >>>

Re: [Tutor] one line code

2005-04-05 Thread Gregor Lingl
Pierre Barbier de Reuille schrieb: Mmmhhh ... not strictly one line but ... import re float_str = re.compile(r"^\s*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$") val = [ ( (float_str.match(s) and [float(s)]) or [s])[0] for s in l2 ] It's not really "readable" but well ... it works ^_^ Pierre This c

[Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Joseph Quigley
Maybe I shouldn't be posting this... I downloaded py2exe and can't get it to make exe's of my python files. There are a list of instructions: # A very simple setup script to create 2 executables. # # hello.py is a simple "hello, world" type program, which alse allows # to explore the environment

[Tutor] pickle in unicode format

2005-04-05 Thread BRINER Cedric
hi, I have this dictionnary : a={'partition': u'/export/diskH1/home_evol/ricquebo', 'rsmFirstname': u'Fran\xe7ois', 'rsmLastname': u'Ricquebourg', 'size': u'8161222.0', 'size_max': '1'} and I'd like to *serialize* it with pickle and that the output format will be of type unicode. unicode(pi

Re: [Tutor] one line code

2005-04-05 Thread Kent Johnson
Pierre Barbier de Reuille wrote: [EMAIL PROTECTED] a écrit : This is a perfect opportunity to give the reminder that the conversion functions are also types that can be used more transparently for such Neat I didn't know\ that. How dioes Python equate a function object to a type? Is it hard wired?

Re: [Tutor] one line code

2005-04-05 Thread Pierre Barbier de Reuille
[EMAIL PROTECTED] a écrit : This is a perfect opportunity to give the reminder that the conversion functions are also types that can be used more transparently for such Neat I didn't know\ that. How dioes Python equate a function object to a type? Is it hard wired? No, you see it the wrong way !

Re: [Tutor] one line code

2005-04-05 Thread alan . gauld
>This is a perfect opportunity to give the reminder that the >conversion >functions are also types that can be used more transparently for such Neat I didn't know\ that. How dioes Python equate a function object to a type? Is it hard wired? > >>> [(type(x)==int and float(x) or x) for x in l] >[

[Tutor] Re: one line code

2005-04-05 Thread Andrei
Alan Gauld freenet.co.uk> writes: > > With other words I'd like to tell Python: Convert into a float if > > possible, otherwise append anyway. > > [ (type(x) == type(5) and float(x) or x) for x in mylist ] Almost fell for it too, but the original list contains numbers stored as strings :).

Re: [Tutor] enter key

2005-04-05 Thread jfouhy
Quoting Diana Hawksworth <[EMAIL PROTECTED]>: > I am using the tkinter toolkit. Just wish to have the button I have > formed replaced by the Enter key - if possible. Would the raw_input() work, as > Bernard has suggested, or do I need another piece of code that refers to > the Enter key? A couple

Re: [Tutor] using the enter key

2005-04-05 Thread Kent Johnson
Here is a simple example. It is not well structured but it should give you the idea. from Tkinter import * def showText(evt): print 'Text is:', text.get('0.0', END) return 'break' # Prevent the event from propagating to the Text widget root = Tk() text = Text() # This line binds the showT

Re: [Tutor] using the enter key

2005-04-05 Thread Michael Lange
On Tue, 5 Apr 2005 06:28:54 +1000 "Diana Hawksworth" <[EMAIL PROTECTED]> wrote: > Hello list! > > At the moment I have some user input tied to a button that allows the input > to be "submitted" and then an answer is supplied. How can I get rid of this > submit button, and have the user just pr