Re: What do you want in a new web framework?

2006-08-20 Thread 3KWA

[EMAIL PROTECTED] wrote:
> Hello Everyone,
>
> Now, I'm working on a new web framework. I tried many test on the other
> programming languages. Then i decided to use python on my web framework
> project.
>
> Now i want to listen all of you. What do you want in that web
> framework(Easy use of Database, Easy use of XML, GUI Designer, etc...)?
>
> I'm wating your answers. Thank you for all answers...!
>
> King Regards,
>
> Emrah Ayanoglu

Don't want to sound too conservative but really nothing that either
- Django
- Turbogear
- or the "myghty" Pylons (my personal favorite)
cannot provide efficiently today!

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending mailing list with smtplib

2006-08-16 Thread 3KWA

3KWA wrote:
> Just for education purposes  (mine I guess :P) what was the idea behind
> that design decision?

>From the doc (self education :P)

The following methods implement a mapping-like interface for accessing
the message's RFC 2822 headers. Note that there are some semantic
differences between these methods and a normal mapping (i.e.
dictionary) interface. For example, in a dictionary there are no
duplicate keys, but here there may be duplicate message headers. Also,
in dictionaries there is no guaranteed order to the keys returned by
keys(), but in a Message object, headers are always returned in the
order they appeared in the original message, or were added to the
message later. Any header deleted and then re-added are always appended
to the end of the header list.

These semantic differences are intentional and are biased toward
maximal convenience.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending mailing list with smtplib

2006-08-15 Thread 3KWA
Filip Salomonsson wrote:
>
> You can reuse your message object, but you need to delete the old
> header before setting a new one:
>
> 

Thanks!

I am only an occasional Python programmer (love it though). I guess it
is the first time I faced a case where what I thought the code would do
from reading it didn't match what the code is effectively doing i.e.

msg['To']=email1 appending to the header instead of setting the To
field to email. The way my brain works if I wanted to have several
recipient I would have done something like msg['To'].append(email2).

Just for education purposes  (mine I guess :P) what was the idea behind
that design decision?

Thanks again for your assistance,

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending mailing list with smtplib

2006-08-15 Thread 3KWA
Steve Holden wrote:
> OK, now the problem is that you clearly aren't running the code you
> posted, you are running *somethinglike* the code you posted, but that
> has (an) error(s) the code you posted didn't.

All I did was changed the comments to make them more relevant to my
problem but here it is (not sanitized :P)

fp=open('list.txt','r')
list=fp.readlines()
fp.close()

textfile='message.txt'
subject='[xsbar] alive and kicking'
me='[EMAIL PROTECTED]'

# Import smtplib for the actual sending function
import smtplib

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

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()

# me == the sender's email address
# you == the recipient's email address
for line in list:
you=line[:-1]
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.connect()
s.sendmail(me, [you], msg.as_string())
s.close()
print you,

> So let's see the version with the "print" statements in it, not the
> sanitised version you didn't copy-and-paste fro your python source :-)

Yes there was a print statement at the end so I could follow the
process

> For the record, it's clear that youa ren't resetting the senders to an
> empty list each time but growing it as you go round the loop. If this
> helps you find your error, at least confirm that you did indeed find the
> problem.

I must be punching way out of my league here but it is not clear to me.
Why do I need to reset anything when all I seem to be doing is straight
assignation:
1) msg['To']=you
2) [you] in the sendmail call

In order to try to figure it out I did:

list=['a','b','c']

from email.MIMEText import MIMEText

msg=MIMEText('message')

for l in list:
msg['Subject']='subject'
msg['From']='me'
msg['To']=l
print msg.as_string()

Which outputs:

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

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

message
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: subject
From: me
To: a
Subject: subject
From: me
To: b
Subject: subject
From: me
To: c

message

I realized too late that it is what was happenig but I am afraid I
don't understand why it is happening?

What would be the best way to go about it then? Instantiate a new msg
in the loop?

I guess I must read the doc more carefully, thanks for your time (if
you can spare some more I would be grateful).

Regards,

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending mailing list with smtplib

2006-08-15 Thread 3KWA

Gabriel Genellina wrote:
>
> Specify "didn't work" at least... see
> http://www.catb.org/~esr/faqs/smart-questions.html

Ooops, didn't work explained (the worst is I bought and read ESR's book
:()

list.txt=
email1
email2
email3
...
emailn

email1 received from:xsbar.com to:email1 subject: [xsbar] alive and
kicking ... message

from email2 onwards it seems what happened is that the recipient list
kept growing,
email 2 received from:[EMAIL PROTECTED] to:email1 to:email2 subject: ...
email3 received from:[EMAIL PROTECTED] to:email1 to:email2 to:email3
subject:...
...
emailn received from:[EMAIL PROTECTED] to:email1 to:email2 to:email3 ...
to:emailn subject:...

Many didn't receive the email because the header grew too big (I
received 1257 failure notice ~50% of them for header too big or
inappropriate recipient list).

Apologize for the inaccuracy of my first post

-- 
http://mail.python.org/mailman/listinfo/python-list


sending mailing list with smtplib

2006-08-14 Thread 3KWA
Hi all,

I tried to send a small mailing list using python today (2036 emails).
For that purpose I looked in the doc for some code examples (I had
never done it before). And I ended up writing and running this little
script:

# list.txt is a text file container an email per line
fp=open('list.txt','r')
list=fp.readlines()
fp.close()

# message.txt is the plaine text message to send
textfile='message.txt'
subject='[xsbar] alive and kicking'
me='[EMAIL PROTECTED]'

# rom and example in the doc
import smtplib

from email.MIMEText import MIMEText

fp = open(textfile, 'rb')
msg = MIMEText(fp.read())
fp.close()

# ... but the actual message sending in a loop to send one email each
(didn't work)
for line in list:
you=line[:-1]
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you

s = smtplib.SMTP()
s.connect()
s.sendmail(me, [you], msg.as_string())
s.close()

but it copied all the recipients in the header (To:) which I don't
understand?

Can someone help me understand what I did wrong?

Thanks,

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows vs. Linux

2006-07-31 Thread 3KWA
I am not a programming expert but I use python everyday on Windows XP:
* python standard distribution (CPython)
* iPython
* cygwin for the command line interaction, add a unix/linux flavour to
the blend

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: doctest with variable return value

2006-07-25 Thread 3KWA

Peter Otten wrote:

> You cannot test for an unknown value, but you can do some sanity checks:
>
> >>> rate = get_rate('AUDEUR')
> >>> rate > 0
> True
> >>> isinstance(rate, float)
> True
>
> This will at least make sure that get_rate() does not throw an exception.

Thanks a lot ... sanity checks ... it makes a lot of sense to me!

At EuroPython I attended a talk where someone said that untested code
is nothing ... so I am trying to write something instead of nothing ...
on the other hand can code ever be over tested?

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


doctest with variable return value

2006-07-25 Thread 3KWA
Hi all,

I am wondering what is the standard doctest (test) practice for
functions who's returned value change all the time e.g. forex rate:

import urllib

def get_rate(symbol):
"""get_rate(symbol) connects to yahoo finance to return the rate of
symbol.

>>>get_rate('AUDEUR')

"""

url=
"http://finance.yahoo.com/d/quotes.csv?s=%s=X&f=sl1d1t1c1ohgv&e=.csv"; %
\
 symbol
f=urllib.urlopen(url)
return float(f.readline().split(',')[1])

As you can guess I am very new to unittest and doctest in general ...

Thanks for your help,

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Browser Pygame Plug-in?

2006-07-06 Thread 3KWA
Gregory PiƱero wrote:
> I was just idley curious on what it would take to make a web plug-in
> for Pygame.  I'm picturing it working the way my browser currently
> shows flash games.  Is such an idea even possible?  Has anyone
> attempted this?

Not a plugin but at Europython the PyPy crew presented the Javascript
backend  of PyPy which transforms-converts a python program into a
Javascript application (not sure I understood it all so ...). They
showed us a Javascript version of the Bub-n-Bros game (written using
pyGame). Pretty cool is you ask me.

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Programming Books?

2006-05-26 Thread 3KWA
http://www.greenteapress.com/thinkpython/

How to think like a computer scientist is a great first read I think.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New-style Python icons

2006-03-21 Thread 3KWA
Thanks  a lot!

(Still think 2.5 could have spunky new icons:)

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New-style Python icons

2006-03-21 Thread 3KWA
Superb! How about getting them in the 2.5 release?

Part of the reason why I am asking is that I am not sure what I have to
do to get Win XP to use these instead of the one coming with 2.4.2.

Cheers,

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE: great headache....

2006-03-13 Thread 3KWA
Vim + iPython does most of it doesn't it?

That's where I am after I became a bit frustrated with Idle (which I
still use on odd occasions).

EuGeNe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert the contents of a string into name of variable

2005-03-24 Thread 3KWA

Erwan VITIERE wrote:
> Because i don't want to use this syntax because it is too long, I
want a
> direct access :
>
> Not :
> DicoUser['TOTO'].DicoTable.['MY_TABLE'].DicoLabel.['MY_LABEL']  =
"for
> exemple"
>
> Finally, i want to use :
> TOTO.MY_TABLE.MY_LABEL = "for exemple"

setattr might be what you are looking for

-- 
http://mail.python.org/mailman/listinfo/python-list