Re: [Tutor] How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Ricardo Aráoz
El 23/12/13 12:31, Mark Lawrence escribió: I'll nag who I bloody well like until such time time as they can post without pissing me off. But what really pisses me off is people telling me how to behave. So please stop nagging, you nagger. And that's a PLONK! You are not so interesting that

Re: [Tutor] formatting datetime.timedelta to "HH:MM:SS"

2013-12-11 Thread Ricardo Aráoz
El 11/12/13 10:37, Mark Lawrence escribió: On 11/12/2013 13:12, Jignesh Sutar wrote: print str(exe_time).split('.')[0] Sorry, I guess my question was why I can't use something similar to below on exe_time (of type datetime.timedelta)? Rather than doing string manipulation on decimals or colo

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
El 22/10/13 10:44, Alan Gauld escribió: On 22/10/13 14:21, Ricardo Aráoz wrote: - Did you notice your assignment specifically asks for a "while" loop for validation? ... (tip: you should be using "while" and "on error") on error? You're not thinking of

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
", format (product_weight, '9,.2f')) print ("Your total to ship", product_name, "is: $", format (total, '9,.2f')) main () On Sun, Oct 20, 2013 at 6:01 PM, Ricardo Aráoz <mailto:ricar...@gmail.com>> wrote: Sorry, I sent thi

[Tutor] Fwd: Re: Passing arguments?

2013-10-20 Thread Ricardo Aráoz
Sorry, I sent this answer to the OP directly and not to the list. Mensaje original Asunto: Re: [Tutor] Passing arguments? Fecha: Sun, 20 Oct 2013 11:25:52 -0300 De: Ricardo Aráoz A: Jenny Allar El 20/10/13 01:20, Jenny Allar escribió: I've writte

Re: [Tutor] 2 basic problems

2013-06-16 Thread Ricardo Aráoz
El 29/05/13 18:23, charles benoit escribió: 1:Python 2.7.4 (default, Apr 19 2013, 18:32:33) [GCC 4.7.3] on linux2 Type "copyright", "credits" or "license()" for more information. >>> 4+4 8 >>> 3+3=4 SyntaxError: can't assign to operator >>> 3=1 SyntaxError: can't assign to literal > I thought the

Re: [Tutor] PyScripter header?

2013-05-08 Thread Ricardo Aráoz
El 08/05/13 05:10, Jim Mooney escribió: PyScripter has enough extra features, that I'll probably switch to it. But has anyone found any odd problems with it? Tks. Jim Given that your main() question ;c) has been answered, you might also want to give Spyder a try before switching.

Re: [Tutor] List comprehension + lambdas - strange behaviour

2010-05-06 Thread Ricardo Aráoz
Artur Siekielski wrote: > Hello. > I found this strange behaviour of lambdas, closures and list > comprehensions: > > funs = [lambda: x for x in range(5)] [f() for f in funs] > [4, 4, 4, 4, 4] > > Of course I was expecting the list [0, 1, 2, 3, 4] as the result. The > 'x'

[Tutor] About property() - For Marco Rompré

2010-04-23 Thread Ricardo Aráoz
Hi Marco (and everybody), in another thread you showed your code and made extensive use of property(). Wrongful use I might say. Let's see an example: >>> class C(object): ... def __init__(self): self._x = None ... def getx(self): return self._x - 10 ... def setx(self, value): self.

Re: [Tutor] Would you please help me understand my error

2010-04-23 Thread Ricardo Aráoz
Marco Rompré wrote: > Its supposed to be a object magasin (shop in french) with some golf > items in it > > > class Magasin: > """ > Le concept magasin pour la gestion d'inventaire des items de golf. > """ > def __init__(self, nom ="", items =[] ): > self.nom = nom >

Re: [Tutor] Binary search question

2010-04-23 Thread Ricardo Aráoz
Hugo Arts wrote: > On Fri, Apr 23, 2010 at 11:33 PM, Emile van Sebille wrote: > >> On 4/23/2010 2:21 PM Alan Gauld said... >> >>> "Emile van Sebille" wrote >>> It's expensive enough that for a list this size I'd convert it to a dict and use in on that. eg, a = r

Re: [Tutor] the binary math "wall"

2010-04-21 Thread Ricardo Aráoz
Lowell Tackett wrote: > >From the virtual desk of Lowell Tackett > > > > --- On Wed, 4/21/10, Dave Angel wrote: > > >> From: Dave Angel >> Subject: Re: [Tutor] the binary math "wall" >> To: "Lowell Tackett" >> Cc: tutor@python.org, "Steven D'Aprano" >> Date: Wednesday, April 21, 2010, 12:3

Re: [Tutor] accessing Postgres db results by column name

2010-04-09 Thread Ricardo Aráoz
Serdar Tumgoren wrote: > Hi folks, > > Does anyone know if there's native support in psycopg2 for accessing > rows in a result-set by column name (rather than by index)? > > I'd like to be able to do something like below: > > cur.execute('select id, name from mytable') > data = cur.fetchall() > for

Re: [Tutor] Difflib comparing string sequnces

2010-03-10 Thread Ricardo Aráoz
Vincent Davis wrote: > I have never used the difflib or similar and have a few questions. > I am working with DNA sequences of length 25. I have a list of 230,000 > and need to look for each sequence in the entire genome (toxoplasma > parasite) I am not sure how large the genome is but more that 23

Re: [Tutor] Difflib comparing string sequnces

2010-03-10 Thread Ricardo Aráoz
Vincent Davis wrote: > I have never used the difflib or similar and have a few questions. > I am working with DNA sequences of length 25. I have a list of 230,000 > and need to look for each sequence in the entire genome (toxoplasma > parasite) I am not sure how large the genome is but more that 23

[Tutor] How to use pydoc

2010-02-26 Thread Ricardo Aráoz
Checked the manuals on pydoc and wanted to try it. Must certainly be doing something wrong but I can't figure what. Here's my session : Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> p

Re: [Tutor] raising number to a power

2010-02-25 Thread Ricardo Aráoz
Stefan Behnel wrote: > Monte Milanuk, 25.02.2010 16:47: > >> Is there a benefit (besides brevity) one way or the other between using: >> >> import math >> ... >> math.pow(x,y) # x raised to the power y >> >> vs. >> >> x**y >> >> ? >> > > Did you try it? > > >>> import math > >>> pr

Re: [Tutor] raising number to a power

2010-02-25 Thread Ricardo Aráoz
Stefan Behnel wrote: > Monte Milanuk, 25.02.2010 16:47: > >> Is there a benefit (besides brevity) one way or the other between using: >> >> import math >> ... >> math.pow(x,y) # x raised to the power y >> >> vs. >> >> x**y >> >> ? >> > > You might also be interested in this: > > http://doc

Re: [Tutor] What Editori?

2010-02-24 Thread Ricardo Aráoz
Lowell Tackett wrote: > The environment [OS} of choice can do a lot to expand/enhance the > capabilities of an editor. I fell upon Vim from the beginning, and > stayed with it for its' rich palate of features and adaptability (and > of course, the often...and exhilarating "oh, Vim can do that!").

Re: [Tutor] Best Python Editor

2009-06-16 Thread Ricardo Aráoz
Eddie wrote: > I downloaded the previous version of PyScripter although couldn't get > it to work and after googling it, I downloaded Python Portable 1.1 > (Python 2.6.1 as most sites/books recommend this and not 3) which has > PySCripter included and this then works fine.Ii also downloaded Komod0

[Tutor] web cam

2009-05-20 Thread Ricardo Aráoz
Hi, a friend of mine has asked me how difficult would it be to send web cam images through python program as a hobby project. Honestly, at this point I have no idea where does he want to put python in the equation nor what does the project entail. So I'm asking for pointers to : a) Any already done

Re: [Tutor] Here's something to talk about

2009-04-16 Thread Ricardo Aráoz
Weidner, Ronald wrote: > One of your points represents a great opportunity to make mine. Suppose > this code is several years old. Now we have a new requirement that > states we need to work with the data as you described above. How > much of the existing code would you have to change to make th

Re: [Tutor] Fw: list.replace -- string.swap

2009-03-18 Thread Ricardo Aráoz
ALAN GAULD wrote: > It wasn't my question :-) > > Forwarding to list... > > > Alan Gauld > Author of the Learn To Program website > http://www.alan-g.me.uk/ > > > > > - Original Message > >> From: Ricardo Aráoz >

[Tutor] Detecting wx

2009-02-12 Thread Ricardo Aráoz
There are a couple of utilities I want to be able to run from the command window. Now, if I'm at the command window, or Idle, or other non wx shell I want to establish a wx app. But if I'm in pythonWin, PyCrust, or any other wx based shell then there is a wx event loop already running and if I crea

Re: [Tutor] Defining "bit" type

2009-01-28 Thread Ricardo Aráoz
> "Vicent" wrote > >> Anyway, I am working with Python 2.5.4, and I am interested in >> defining a >> new type called "bit" (if possible), which represents a number that >> can only >> take values 0 or 1 —that's what we would call a "binary variable", in a >> Mathematical Programming context. The

Re: [Tutor] extend my re

2008-11-22 Thread Ricardo Aráoz
the trick. Thanks a lot Marco! > On Sat, Nov 22, 2008 at 12:52 PM, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: > >> Hi, I've got a half working re but I can't find a way to give it the >> final touch. >> Let's say I have (it would actually be sou

[Tutor] extend my re

2008-11-22 Thread Ricardo Aráoz
Hi, I've got a half working re but I can't find a way to give it the final touch. Let's say I have (it would actually be source code file) : >>> import re >>> MyString = """Algo ... Start ... otro ... comment ... otro ... comment ... comment ... otro ... end ... """ >>>

Re: [Tutor] Python Docs (Was: Reformatting phone number)

2008-08-25 Thread Ricardo Aráoz
Kent Johnson wrote: On Fri, Aug 22, 2008 at 9:46 AM, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: What I find lacking in the docs are a link to a code example for every item and a "See Also" link to other related items. With some modules I can't make sense of the different b

Re: [Tutor] pass argument into running program *outside* of program

2008-08-25 Thread Ricardo Aráoz
Emile van Sebille wrote: Lie Ryan wrote: In a much simpler situation, even a communicating from a plain file could be enough. In the daemon's program folder, there'll be two files: input and output. You write to input to instruct the server and read the response from output. This model is in re

Re: [Tutor] Python Docs (Was: Reformatting phone number)

2008-08-22 Thread Ricardo Aráoz
Hansen, Mike wrote: On Thu, Aug 21, 2008 at 12:01 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote: 2008/8/21 Kent Johnson <[EMAIL PROTECTED]>: Chapters 2 and 3 of the library reference are highly recommended. http://docs.python.org/lib/lib.html Let's start from there. I need the startswith() function

Re: [Tutor] something is fundamentally wrong...

2008-08-11 Thread Ricardo Aráoz
Joshua Nikkel wrote: ah that was it. I had a variable named len earlier. On a restart it was fine. Thanks! Besides that you have a HUGE error!!! Your spelling! It should be : >>> s = 'supercalifragilisticoexpialidoso' :P On Sun, Aug 10, 2008 at 2:04 PM, Robert Berman <[EMAIL PROTE

Re: [Tutor] removing whole numbers from text

2008-08-05 Thread Ricardo Aráoz
Dinesh B Vadhia wrote: I want to remove whole numbers from text but retain numbers attached to words. All whole numbers to be removed have a leading and trailing space. For example, in "the cow jumped-20 feet high30er than the lazy 20 timing fox who couldn't keep up the 865 meter race." remov

Re: [Tutor] Style help: long strings with formatting

2008-07-31 Thread Ricardo Aráoz
Alan Gauld wrote: "W W" <[EMAIL PROTECTED]> wrote output = "At an average weekly savings of $%.02f, your monthly savings will be $%.02f. \n Your annual savings will be $%.02f." % (diff, monthly_savings, annual_savings) print output. As you can see, it's very much longer than the 72 charact

Re: [Tutor] String Replacement question

2008-05-22 Thread Ricardo Aráoz
Faheem wrote: Hi all, How do I replace the same value multiple times without repeating the same variable name/value repeatedly? for ex. some = 'thing' print '%s %s %s %s' % (some,some,some,some) in this case, my question is how do i replace "% (some,some,some)" with something more concis

Re: [Tutor] Remove specific chars from a string

2008-04-15 Thread Ricardo Aráoz
> Malcolm Greene wrote: >> What is the Pythonic way to remove specific chars from a string? The >> .translate( table[, deletechars]) method seems the most 'politically >> correct' and also the most complicated. Why complicated? import string myStr = 'some text from which you want to delete some

Re: [Tutor] Conventions for code snippets for debugging and testing?

2008-04-14 Thread Ricardo Aráoz
Robert Kirkpatrick wrote: > Hi All, > > Just wondering if there are any basic conventions for including code > snippets that are for testing / debugging only? > > For example, you could set a boolean variable called DEBUG, then have > snippets of code like: > > if DEBUG: > do stuff > else: >

Re: [Tutor] Calling super classs __init__?

2008-03-23 Thread Ricardo Aráoz
Luciano Ramalho wrote: > Nowadays the best practice for invoking a method from all superclasses > (yes, multiple inheritance) is this: > > class SubClass(BaseClass): > def __init__(self, t, *args, **kw): > super(SubClass, self).__init__(*args, **kw) > # do something with t > >

Re: [Tutor] my first project: a multiplication trainer

2008-03-15 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Considering the fact that choices[x] == x, > > Only until the first delete (that is not at the end). > >> shouldn't it be : >> del choices[proxyq] > > No. &g

Re: [Tutor] my first project: a multiplication trainer

2008-03-15 Thread Ricardo Aráoz
Chris Fuller wrote: > The basic approach I use in these sorts of problems is to generate the > choices, remove them from a list as they are asked, and then stop when this > list is empty. > > > If you don't need the list of questions afterwards, this will work: > > from random import choice >

Re: [Tutor] Const on Python

2008-03-08 Thread Ricardo Aráoz
Jeff Younker wrote: > On Mar 7, 2008, at 7:48 PM, Ricardo Aráoz wrote: > >> Alan Gauld wrote: >> Well, I guess it's about what you think a programmer is. I think if >> you >> are a "true" programmer you'll be good in ANY language (though you m

Re: [Tutor] Const on Python

2008-03-07 Thread Ricardo Aráoz
Alan Gauld wrote: > Absolutely. I totally agree that moving an organization to Python > or similar modern language is a sensible move for many applications. > Only where very high performance or scaleability are required would > Python (or similar) be inappropriate and even in the largest > organi

Re: [Tutor] Const on Python

2008-03-07 Thread Ricardo Aráoz
Alan Gauld wrote: >> In commercial practice sometimes "political" considerations make for >> crazy decisions, e.g. witnessed by me: > >> 1.) a new web service needs to be developed. >> 2.) the policy of the company is that all developers need to know C > ++/Java. >> snipped... desire to use Python

Re: [Tutor] Const on Python

2008-03-07 Thread Ricardo Aráoz
Tiago Katcipis wrote: > thanks for the help Andreas, i dont really need that much a const so i > wont do anything like that to have a const like data. I am very used to > java and c++, thats why i always used acess modifier, but i think i can > live without it now i know that it dont exist in py

Re: [Tutor] comparison bug in python (or do I not get it?)

2008-03-01 Thread Ricardo Aráoz
Hans Fangohr wrote: > Hi Kent, > >> Hans Fangohr wrote: >> >>> In [2]: 2 in [1,2,3] == True >>> Out[2]: False >>> >>> Why does [2] return False? Would people agree that this is a bug? >> No, not a bug. Don't be too quick to blame your tools! > > That's good news. I'd be worried if this wasn't the

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
To further document some points. This comes from PEP 8 (http://www.python.org/dev/peps/pep-0008/) For those who need "authority" : Author: Guido van Rossum , Barry Warsaw """ With this in mind, here are the Pythonic guidelines: - Public attributes should have no leading underscores.

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: >>> This is all fine and dandy, but the video game is pretty worthless unless >>> it >>> can show us what the score is. There are two ways to go about this. A) >>> Give >>> the video game a display which it updates, or B) Tear open the case of >>> the >>> video game and look at

[Tutor] Mail revisited

2008-02-12 Thread Ricardo Aráoz
Ok, so I've started the path to put a GUI to the "MandarMails.py" program. For starters I've included a progress bar. Any enhancements you may suggest will be appreciated. Note: not tested yet ## ### MandarMails.py ### ## #!/usr/bin/env python import time

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: > This is all fine and dandy, but the video game is pretty worthless unless it > can show us what the score is. There are two ways to go about this. A) Give > the video game a display which it updates, or B) Tear open the case of the > video game and look at the actual gears t

Re: [Tutor] designing POOP

2008-02-12 Thread Ricardo Aráoz
Tiger12506 wrote: > This is all fine and dandy, but the video game is pretty worthless unless it > can show us what the score is. There are two ways to go about this. A) Give > the video game a display which it updates, or B) Tear open the case of the > video game and look at the actual gears t

Re: [Tutor] Anyone fancy giving me some tips and an expert opinion??

2008-02-09 Thread Ricardo Aráoz
Damian Archer wrote: > I have written what i see as a pretty decent script to resolve this > question: > > Write an improved version of the Chaos program from Chapter 1 that > allows a user to input two initial > values and the number of iterations and then prints a nicely formatted > table showin

Re: [Tutor] creating a nested dictionary

2008-01-31 Thread Ricardo Aráoz
Kent Johnson wrote: > Remco Gerlich wrote: >> I can't think of a really good generalization, one that will work for >> all depths. That's the sort of thing you use Lisp, combinators and lots >> of coffee for. Perhaps later today. > > Some nice solutions here: > http://groups.google.com/group/com

Re: [Tutor] conditionals with slicing not seeming to work

2008-01-28 Thread Ricardo Aráoz
Alan Gauld wrote: > "Rob Stevenson" <[EMAIL PROTECTED]> wrote > >> I'm working at a certain website's puzzles using >> python in order to learn the language, > > OK, Then I'll add some other comments > >> the intention of this snippet is to only print slices where >> character 1 is >> lower cas

Re: [Tutor] Projects (fwd)

2008-01-25 Thread Ricardo Aráoz
Tiger12506 wrote: >> Nope, if you read the code you'll see the only mapping done is up to 20 >> and then by tens up to 100, that's all. >> The same code could be used with a list, you'd only have to change the >> exception name. > > I see. There were "..." in between each of the tens entries which

Re: [Tutor] Projects (fwd)

2008-01-24 Thread Ricardo Aráoz
Tiger12506 wrote: >> Isn't dictionary access faster than list access? Why are three lists >> 'much more efficient'? > > Oh no, no, no. Dictionaries are faster when you are *searching through* for > a particular value. If you already know the index of the item in the list, > lists are much faste

Re: [Tutor] Projects (fwd)

2008-01-23 Thread Ricardo Aráoz
Tiger12506 wrote: >> up to a thousand (not tested) >> >> words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten', >> 11:'eleven', 12:'twelve', ..., 19:'nineteen', >> 20:'twenty', , 90:'ninety', 100:'one hundred' } >> def digitToString(n) : >>try : >>retStr = words[n]

Re: [Tutor] Projects (fwd)

2008-01-23 Thread Ricardo Aráoz
Danny Yoo wrote: > Hi Jason, > > > Looking back at that Java code: > > > static String convertDigitToEnglish(int d) { > switch ( d ) > { >case 1: return "one"; >case 2: return "two"; >case 3

Re: [Tutor] Interview questions in python and wxpython

2008-01-19 Thread Ricardo Aráoz
bob gailer wrote: > Varsha Purohit wrote: >> Hello All, >>I have an interview in python program development. Can i know >> some interview questions in python ? If you know any website where i >> can refer that would be helpful. > My first engineering job interview went thus: > > "We need

Re: [Tutor] Input

2008-01-16 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: > >> _validChars = { >> 'X' : >> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' >> , '9' : '1234567890&

Re: [Tutor] Input

2008-01-16 Thread Ricardo Aráoz
Tiger12506 wrote: >> Of course I know and use reg. exps., the point of the function is not to >> validate input but to force the proper input. > > So? Are you going to try to tell me that you can force particular input > without actually determining if its valid or not first? ;-) > > Just a thou

Re: [Tutor] Input

2008-01-15 Thread Ricardo Aráoz
Tiger12506 wrote: > Try regular expressions in the re module. This should make this code below > much much simpler. Downside is you have to learn a slightly different > syntax. Upside is - regular expressions are very powerful. > Of course I know and use reg. exps., the point of the function is

[Tutor] Input

2008-01-15 Thread Ricardo Aráoz
Last week someone had an issue with raw_input() and how to get input for a number. So I remembered my CP/M times and got to think of a little function I had there. The function is lost and my time is scarce but I made a little effort and here you have the results. It has loads of room for improveme

Re: [Tutor] Pyhon Mac/Pc

2008-01-13 Thread Ricardo Aráoz
Kent Johnson wrote: > Hendrik Verlinden wrote: >> Yes I'm using the files from this link >> http://relro.net/racer/dofexport.html :) >> >> Do you now what the problem is with these files on a mac? >> Otherwise how do I have to change the carriage return or

Re: [Tutor] Why Won't My Pizza Fall?

2008-01-13 Thread Ricardo Aráoz
Alan Gauld wrote: > However, I do agree that an init method is probably the wrong > place to have a dx/dy pair since we should, I would ex[pect, > be positioning the object initially before trying to move it. > Thus I'd expect a move metjod someplasce that took the > dx and dy. Something like: >

Re: [Tutor] Program review

2008-01-07 Thread Ricardo Aráoz
Torsten Marek wrote: >> try : >> with open('/etc/passwd', 'r') as f: >> for line in f: >> print line >> ... more processing code ... >> except ExceptionsOnOpening : >> ... exception handling >> except : >> ... exceptions inside the for >> >> >> >> Whereas

Re: [Tutor] Program review

2008-01-07 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Kent Johnson wrote: >>> from contextlib import nested >>> with nested(open_file(self.direcciones), open_file(self.excluidas)) >>> as (fIncl, fExcl): >>> >> Nice! How would you add exception re

Re: [Tutor] Program review

2008-01-07 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> PEP 0343 is not an >> example of clarity in the definition of a statement, it mixes >> justification with historic development with definition with actual >> equivalent code. Couldn't or wouldn't bother to understa

Re: [Tutor] Scope and elegance

2008-01-07 Thread Ricardo Aráoz
James Newton wrote: > Hi Python Practicioners! > > I'm trying to come to terms with how Python handles the scope of > objects. In particular, I'd like to create an instance of one class and > make it available inside instances of other classes. Something like: > > > # Test 1---

Re: [Tutor] Program review

2008-01-07 Thread Ricardo Aráoz
Kent Johnson wrote: > Jeff Younker wrote: > >> Or if you're using python 2.5 then you can use with statements: >> >> from __future__ import with_statements >> from contextlib import closing >> ... >> def mails(self): >> with closing(open_file(self.direcciones)) as fIncl: >>with clo

Re: [Tutor] Program review

2008-01-07 Thread Ricardo Aráoz
Jeff Younker wrote: >> Maybe it is my poor understanding of exception handling. My intention >> here is to open the first file, if error then report in logging and >> finish normally, else open the 2nd file, if error then report in >> logging >> close the 1st file and finish normally. If no error

Re: [Tutor] Program review

2008-01-06 Thread Ricardo Aráoz
Ok, now the "tested" version (has been corrected) : #!/usr/bin/env python import time import smtplib import email import ConfigParser import logging class Mensaje(object) : def __init__(self) : cfg = ConfigParser.ConfigParser() try : cfg.readfp(open('config.cfg'))

Re: [Tutor] Program review

2008-01-06 Thread Ricardo Aráoz
Jeff Johnson wrote: > I would like to "butt" in here and mention that this is some of the most > useful information I have seen! I am a programmer of 25 years that is > new to Python. This type of back and forth dialog on actual production > code is extremely useful to learning the language.

Re: [Tutor] Program review

2008-01-06 Thread Ricardo Aráoz
Ok, new version. In procesar() I tried getting rid of the outer try block and having 'return' instead of 'raise' in the inner try blocks but I didn't like the result. I'd rather have one more indent level but have only one exit point from the function. Redesigned class Mensaje so that it now includ

Re: [Tutor] Program review

2008-01-06 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Jeff Younker wrote: > >>> The enclosing try block isn't needed. More on this later. > >> Maybe it is my poor understanding of exception handling. My intention >> here is to open the first file, if error then

Re: [Tutor] Program review

2008-01-06 Thread Ricardo Aráoz
Jeff Younker wrote: > The procesar function is complicated. It tries to do several things > that that are better done elsewhere. It needs to be broken up into > several functions and methods. This also clarifies and isolates the > exception handling. > >> def procesar(mensaje): >>try : >

Re: [Tutor] Program review

2008-01-05 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >> Ok, here is a corrected new version, I hope. >> >> Kent, the fact that Mensaje.__init__ reads the message configuration is >> by design (it's a feature, not a bug ;c) ). > > You misunderstood my suggestion

Re: [Tutor] Program review

2008-01-05 Thread Ricardo Aráoz
Ok, here is a corrected new version, I hope. Kent, the fact that Mensaje.__init__ reads the message configuration is by design (it's a feature, not a bug ;c) ). The class is meant to be instantiated for using only once and with only one configuration and one message so including the configuration

Re: [Tutor] Program review

2008-01-05 Thread Ricardo Aráoz
Thanks everyone for your feedback. I'll correct the code and re-post it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Program review

2008-01-04 Thread Ricardo Aráoz
Considering we are reviewing programs I'd like to submit one of mine and I would be thankful for any critic/improvement you can suggest. My ex needs to send mails to a long list of customers, problem is that she can not send more than 70 every 10 minutes or her ISP will consider her a spammer. So s

Re: [Tutor] how to compare elements of 2 lists

2007-12-25 Thread Ricardo Aráoz
sith . wrote: > sith . wrote: >> Hi, >> I've read the posts on comparing 2 lists and couldn't find the answer to >> my question. >> I have 2 lists >> a = [4,3,2,6,7,9] >> b = [8,6,3,3,2,7] >> How can I determine if the elements in a are larger or smaller than the >> elements in b. >> >> for i in a

Re: [Tutor] how to compare elements of 2 lists

2007-12-25 Thread Ricardo Aráoz
sith . wrote: > Hi, > I've read the posts on comparing 2 lists and couldn't find the answer to > my question. > I have 2 lists > a = [4,3,2,6,7,9] > b = [8,6,3,3,2,7] > How can I determine if the elements in a are larger or smaller than the > elements in b. > > for i in a: > for u in b: >

Re: [Tutor] Output of list

2007-12-22 Thread Ricardo Aráoz
Martin Walsh wrote: > Ricardo Aráoz wrote: >> Emil wrote: >>> hey >>> >>> I want to be capable of converting a string into a list where all the >>> items, in the list, have a fixed length not equal to 1 e.g i have k = >>> 'abcdefgh'

Re: [Tutor] Output of list

2007-12-22 Thread Ricardo Aráoz
Emil wrote: > hey > > I want to be capable of converting a string into a list where all the items, > in the list, have a fixed length not equal to 1 e.g i have k = 'abcdefgh' > and I want the fixed length for all the the items to be 2 then the list would > look like ['ab', 'cd', 'ef, 'gh']. Ho

Re: [Tutor] Output of list

2007-12-22 Thread Ricardo Aráoz
Emil wrote: > hey > > I want to be capable of converting a string into a list where all the items, > in the list, have a fixed length not equal to 1 e.g i have k = 'abcdefgh' > and I want the fixed length for all the the items to be 2 then the list would > look like ['ab', 'cd', 'ef, 'gh']. Ho

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-17 Thread Ricardo Aráoz
Hans Fangohr wrote: >>>> Ricardo Aráoz wrote: >>>>> Kent Johnson wrote: >>>>>> I don't know the answer, but it has nothing to do with the logging >>>>>> module. The question is, can the same file reliably be opened >>>&g

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Ricardo Aráoz
Kent Johnson wrote: > Hans Fangohr wrote: >> Dear all, >> >> thanks to everybody who replied to my question. >> >> On 15 Dec 2007, at 16:34, Kent Johnson wrote: >> >>> Ricardo Aráoz wrote: > >> What is the recommended method to make such a

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Ricardo Aráoz
Hans Fangohr wrote: > Dear all, > > thanks to everybody who replied to my question. > > On 15 Dec 2007, at 16:34, Kent Johnson wrote: > >> Ricardo Aráoz wrote: >>> Kent Johnson wrote: >>>> I don't know the answer, but it has nothing to do with

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-15 Thread Ricardo Aráoz
Kent Johnson wrote: > Hans Fangohr wrote: > >> (i) is this (as in the log.conf file) the right use of the logging >> module to achieve what I need? > > I think you understand the module correctly. > >> (ii) in particular, it appears we have two filehandlers that write to >> the same file (in mod

[Tutor] A couple of modules

2007-12-09 Thread Ricardo Aráoz
Hi, somebody did ask about dates. Found this package, might be usefull http://labix.org/python-dateutil """ The dateutil module provides powerful extensions to the standard datetime module, available in Python 2.3+. Features * Computing of relative deltas (next month, next year, next monday,

Re: [Tutor] Sleeping it out

2007-12-08 Thread Ricardo Aráoz
t works > fine from the command prompt (at least in XP) > > Alan G. Thanks guys, Idle seems to work ok, so I guess I'll do my testing in Idle. Ricardo > > > > Ricardo Aráoz wrote: >> Hi, I have this code : >> >> import time >> L = [i for i

[Tutor] Sleeping it out

2007-12-08 Thread Ricardo Aráoz
Hi, I have this code : import time L = [i for i in xrange(20)] for n, i in enumerate(L) : if n%3 == 0 and n > 0 : print 'waiting 3 seconds' time.sleep(3) print i I'm using Py 2.51 and PyAlaMode. It works ok but instead of printing in groups of three, it will go through the

Re: [Tutor] Still Can't Find Timed While Loops

2007-12-07 Thread Ricardo Aráoz
earlylight publishing wrote: > Hello all, > > I now have my bit of code in while loop form and it works! It's great > but not exactly what I wanted to do. I've been googling my heart out > and I find lots of info on while loops and lots of info on timers that > will execute an action AFTER a gi

Re: [Tutor] Mail? What's that?

2007-12-06 Thread Ricardo Aráoz
Justin Cardinal wrote: > Ricardo Aráoz wrote: > >>Are From: To: Date: and Subject: mandatory in the contents of the >>email(text)? Do I have to put "real" address in From when calling >>sendmail()? And in the contents? > > Here's the

Re: [Tutor] Mail? What's that?

2007-12-06 Thread Ricardo Aráoz
Luke Paireepinart wrote: > Ricardo Aráoz wrote: >> So I eventually got to sending mail with python. >> Some articles, trying and google led me to this script: >> >> import smtplib >> import time >> >> date = time.ctime(time.time( )) >> >

[Tutor] Mail? What's that?

2007-12-05 Thread Ricardo Aráoz
So I eventually got to sending mail with python. Some articles, trying and google led me to this script: import smtplib import time date = time.ctime(time.time( )) >From = '[EMAIL PROTECTED]' To = ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]'] Subj = 'Hi' text = ('From: %s\nTo: %s\nDate: %s\nSubject:

Re: [Tutor] lstrip removes '/' unexpectedly

2007-12-04 Thread Ricardo Aráoz
Eric Brunson wrote: > Ricardo Aráoz wrote: >> Danny Yoo wrote: >> >>>> Hello: >>>> I'm seeing some strange behavior with lstrip operating >>>> on string representations of *nix-style file paths >>>> Example: >>>

Re: [Tutor] Selecting a browser

2007-12-04 Thread Ricardo Aráoz
Tim Golden wrote: > Ricardo Aráoz wrote: >> These guys have given their free time so that we can enjoy their module, > > hey could have no documentation at all... > > That said, my comments about documentation lacking still stand. > > I think the important thing h

Re: [Tutor] Selecting a browser

2007-12-04 Thread Ricardo Aráoz
Tim Golden wrote: > Ricardo Aráoz wrote: >> Martin Walsh wrote: >>> And by the way, the '&' has special meaning >>> to the webbrowser.get method -- it determines whether a >>> BackgroundBrowser or GenericBrowser object is returned. >> LO

Re: [Tutor] Selecting a browser

2007-12-04 Thread Ricardo Aráoz
Tim Golden wrote: > Ricardo Aráoz wrote: >> Martin Walsh wrote: >>> And by the way, the '&' has special meaning >>> to the webbrowser.get method -- it determines whether a >>> BackgroundBrowser or GenericBrowser object is returned. >> LO

Re: [Tutor] Selecting a browser

2007-12-03 Thread Ricardo Aráoz
Martin Walsh wrote: > Ricardo Aráoz wrote: >> Martin Walsh wrote: >> Hi Marty, thanks for your help. >> I've tried your suggestions but they don't seem to work for me. In W's >> system window I can do : >> C:/> S:\FirefoxPortable\FirefoxPortab

Re: [Tutor] Selecting a browser

2007-12-03 Thread Ricardo Aráoz
Kent Johnson wrote: > Ricardo Aráoz wrote: >>>>> import webbrowser >>>>> ff = webbrowser.get("S:\FirefoxPortable\FirefoxPortable.exe %s &") >>>>> ff.open('http://www.google.com') >> False > > Beware of backslash

  1   2   >