Re: Dealing with marketing types...

2005-06-11 Thread Paul Rubin
Andrew Dalke <[EMAIL PROTECTED]> writes:
> I know little about it, though I read at
> http://goathack.livejournal.org/docs.html
> ] LiveJournal source is lots of Perl mixed up with lots of MySQL
> 
> I found more details at
> http://jeremy.zawodny.com/blog/archives/001866.html
> 
> It's a bunch of things - Perl, C, MySQL-InnoDB, MyISAM, Akamai,
> memcached.  The linked slides say "lots of MySQL usage." 60 servers.

LM uses MySQL extensively but what I don't know is whether it serves
up individual pages by the obvious bunch of queries like a smaller BBS
might.  I have the impression that it's more carefully tuned than that.

> I don't see that example as validating your statement that
> LAMP doesn't scale for mega-numbers of hits any better than
> whatever you might call "printing press" systems.

What example?  Slashdot?  It uses way more hardware than it needs to,
at least ten servers and I think a lot more.  If LJ is using 6x as
many servers and taking 20x (?) as much traffic as Slashdot, then LJ
is doing something more efficiently than Slashdot.  

> How permanent though does the history need to be?  Your
> approach wipes history when the user clears the cookie and it
> might not be obvious that doing so should clear the history.

The cookie is set at user login and it only has to persist through the
login session.  It's not as if the info only exists in the cookie and
nowhere else.

> > As for "big", hmm, I'd say as production web sites go, 100k users is
> > medium sized, Slashdot is "largish", Ebay is "big", Google is huge.
> 
> I'ld say that few sites have >100k users, much less
> daily users with personalized information. As a totally made-up
> number, only few dozens of sites (maybe a couple hundred?) would
> need to worry about those issues.

Yes, but for those of us interested in how big sites are put together,
those are the types of sites we have to think about ;-).  I'd say
there's more than a few hundred of them, but it's not like there's
millions.  And some of them really can't afford to waste so much
hardware--look at the constant Wikipedia fundraising pitches for more
server iron because the Wikimedia software (PHP/MySQL, natch) can't
handle the load.

> If that's indeed the case then I'll also argue that each of
> them is going to have app-specific choke points which are best
> hand-optimized and not framework optimized.  Is there enough
> real-world experience to design a EnterpriseWeb-o-Rama (your
> "printing press") which can handle those examples you gave
> any better than starting off with a LAMP system and hand-caching
> the parts that need it?

Yes, of course there is.  Look at the mainframe transaction systems of
the 60's-70's-80's, for example.  Look at Google.  Then there's the
tons of experience we all have with LAMP systems.  By putting some
effort into seeing where the resources in those things go, I believe
we can do a much better job.  In particular, those sites like Slashdot
are really not update intensive in the normal database sense.  They
can be handled almost entirely with some serial log files plus some
ram caching.  At that point almost all the SQL overhead and a lot of
the context switching can go away.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What language to manipulate text files

2005-06-11 Thread Terry Hancock
On Saturday 11 June 2005 11:37 pm, ross wrote:
> I want to do some tricky text file manipulation on many files, but have
> only a little programming knowledge.
[...]

> Would Python be best, or would a macro-scripting thing like AutoHotKey
> work?
> I thought about Perl, but think I would learn bad habits and have hard
> to read code.

Both Perl and Python are *extremely* good at this kind of work.  This is
pretty much what inspired Perl, and Python implements most of the same
toolset.  You will solve many of these kinds of problems using "regular
expressions"  (built-in first-class object in Perl, created from strings in
Python using the "re" module).

No surprise of course that I would choose Python.  Mainly because of what
it provides beyond regular expressions. Many simple cases can be handled
with string methods in Python (check the Sequence types information in the
built-ins section of the Library Reference -- also look at the "string" module,
though it's usually easier to use the string methods approach).

You will probably end up with more readable code using Python and
take less time to develop sufficient proficiency to do the job with it. 


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Dealing with marketing types...

2005-06-11 Thread Andrew Dalke
Paul Rubin replied to me:
> If you're running a web site with 100k users (about 1/3 of the size of
> Slashdot) that begins to be the range where I'd say LAMP starts
> running out of gas.

Let me elaborate a bit.  That claim of 100K from me is the
entire population of people who would use bioinformatics or
chemical informatics.  It's the extreme upper bound of the
capacity I ever expect.  It's much more likely I'll only
need to handle a few thousand users.


> I believe
> LiveJournal (which has something more like a million users) uses
> methods like that, as does ezboard.  There was a thread about it here
> a year or so ago.

I know little about it, though I read at
http://goathack.livejournal.org/docs.html
] LiveJournal source is lots of Perl mixed up with lots of MySQL

I found more details at
http://jeremy.zawodny.com/blog/archives/001866.html

It's a bunch of things - Perl, C, MySQL-InnoDB, MyISAM, Akamai,
memcached.  The linked slides say "lots of MySQL usage."
60 servers.

I don't see that example as validating your statement that
LAMP doesn't scale for mega-numbers of hits any better than
whatever you might call "printing press" systems.

> As a simple example, that article's advice of putting all fine grained
> session state into the database (so that every single browser hit sets
> off SQL queries) is crazy.

To be fair, it does say "database plus cache" though the author
suggests the place for the cache is at the HTTP level and not
at the DB level.  I would have considered something like memcached
perhaps backed by an asychronous write to a db if you want the
user state saved even after the cache is cleared/reset.

How permanent though does the history need to be?  Your
approach wipes history when the user clears the cookie and it
might not be obvious that doing so should clear the history.

In any case, the implementation cost for this is likely
higher than what you did.  I mention it to suggest an
alternative.


> As for "big", hmm, I'd say as production web sites go, 100k users is
> medium sized, Slashdot is "largish", Ebay is "big", Google is huge.

I'ld say that few sites have >100k users, much less
daily users with personalized information. As a totally made-up
number, only few dozens of sites (maybe a couple hundred?) would
need to worry about those issues.

If that's indeed the case then I'll also argue that each of
them is going to have app-specific choke points which are best
hand-optimized and not framework optimized.  Is there enough
real-world experience to design a EnterpriseWeb-o-Rama (your
"printing press") which can handle those examples you gave
any better than starting off with a LAMP system and hand-caching
the parts that need it?

Andrew
[EMAIL PROTECTED]

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


Re: TKinter -- '' event executing more than once?

2005-06-11 Thread Christopher Subich
[EMAIL PROTECTED] wrote:

> Bindings created on a Toplevel or Tk widget apply to *all* widgets in
> the same toplevel. So you're seeing a  event for each widget
> you create...

Oh. :)   Is there a way of binding the event just to the window itself,
or should I just check that the widget referenced in the 'event'?
[update: not even sure how I'd do this anyway, since the widget returned
in the event "is not" the root widget]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: case/switch statement?

2005-06-11 Thread Terry Hancock
On Saturday 11 June 2005 07:35 pm, Steven D'Aprano wrote:
> On Sat, 11 Jun 2005 16:15:42 +, Joe Stevenson wrote:
> > I skimmed through the docs for Python, and I did not find anything like 
> > a case or switch statement.  I assume there is one and that I just 
> > missed it.  Can someone please point me to the appropriate document, or 
> > post an example?  I don't relish the idea especially long if-else 
> > statements.
> 
[...]
> There is no case statement in Python. If you don't care about
> readability, one alternative is to use a dictionary:
> 
> case = {5: do_this, 6: do_that}
> case.get(x, do_something_else)()

The really nice thing about using dictionaries for this kind of thing
in Python is that what was previously hardcoded is now (dynamic)
data.  That makes alterations like adding a new case extremely
trivial (you could load it from a config file for example, or it could
be altered by plugin code which simply updates the dictionary to
register itself).  In my experience with C, this kind of change always
comes up with switch statements, so it's nice to neatly sidestep
the problem with dictionaries in Python.

And perhaps that removal of a false lead is the real reason Python
doesn't have a switch/case construct -- it encourages you to
use a smarter solution which you'll be glad of later on.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


What language to manipulate text files

2005-06-11 Thread ross
I want to do some tricky text file manipulation on many files, but have
only a little programming knowledge.

What are the ideal languages for the following examples?

1. Starting from a certain folder, look in the subfolders for all
filenames matching *FOOD*.txt Any files matching in each folder should
be copied to a new subfolder within the current folder called EATING
with a new name of *FOOD*COPY.txt

2. Process each file as follows:
Here is a simplified example of what I want as input and output.

- input
. 'several unknown lines of text file
Get apples from apples shop
Get oranges from oranges shop
Get plums from plums shop
Get pears from pears shop
Eat from apples, oranges,
  plums, pears'whitespace at start of line is unimportant
. 'more unknown lines of text file
Chapter 1
  Several lines of text about apples in here
Chapter 2
  Several lines of text about oranges in here
Chapter 3
  Several lines of text about plums in here
Chapter 4
  Several lines of text about pears in here

- output
. 'several unknown lines of text file
Get apples from apples shop
Get oranges from oranges shop
Get plums from plums shop
Get pears from pears shop
Get bagels from bagels shop  'the Get lines...
Get donuts from donuts shop  'can be in any order
Eat from apples, bagels, oranges,
  plums, donuts, pears'whitespace at start of line is unimportant
. 'more unknown lines of text file
Chapter 1
  Several lines of text about apples in here
Chapter 2
  Several lines of text about bagels in here
Chapter 3
  Several lines of text about oranges in here
Chapter 4
  Several lines of text about plums in here
Chapter 5
  Several lines of text about donuts in here
Chapter 6
  Several lines of text about pears in here

Summary:
I have added two new items to Get;
I have put them into the comma-delimited list after searching for a
particular fruit to put each one after;
The Chapters are renumbered to match their position in the
comma-delimited list.
The "several lines of text" about each new item can be pulled from a
new_foods.txt file (or a bagels.txt and a donuts.txt file).

My first objective is to process the files as described.
My second objective is to learn the best language for this sort of text
manipulation. The language should run on Windows 98, XP and Linux.

Would Python be best, or would a macro-scripting thing like AutoHotKey
work?
I thought about Perl, but think I would learn bad habits and have hard
to read code.

Thanks, Ross

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


Re: What is different with Python ?

2005-06-11 Thread John Machin
Roy Smith wrote:
> "Philippe C. Martin" <[EMAIL PROTECTED]> wrote:
> 
>>Yet, many issues that a future software engineer should know are
>>mostly hidden by Python (ex: memory management) and that could be
>>detrimental.
> 
> 
> I know I'm going out on a limb by asking this, but why do you think future 
> software engineers should know about memory management?

Perhaps we have a terminology problem here i.e. different meanings of 
"software engineer". Philippe started talking about "CS" courses, 
whereas you may be referring to people who have done an "IT" course or 
achieved a certification in the use of app development tool X.

> 
> I used to worry about register allocation.  Today, I don't even know how 
> many registers any machine I work on has.  I used to worry about word size, 
> and byte order.  I used to worry about whether stacks grew up or down and 
> addressing modes and floating point formats.  Sure, somebody's got to worry 
> about those things, but most people who write software can be blissfully 
> ignorant (or, at best, dimly aware) of these issues because somebody else 
> (compiler writer, hardware designer, operating system writer, etc) has 
> already done the worrying.

You would hope they'd done more than worry about it. However sometimes 
one's fondest hopes are dashed. You must have noticed the anguish in the 
timbot's posts that mention Windows 95 memory management.

> 
> There used to be a time when you had to worry about how many tracks to 
> allocate when you created a disk file.  When's the last time you worried 
> about that?

Seeing you asked: early 1970s, on an IBM 1800. But much more recently it 
certainly helped if one were slightly more than dimly aware of the 
difference between a FAT filesystem and an NTFS filesystem :-)

Cheers,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to receive events (eg. user mouse clicks) from IE

2005-06-11 Thread cal_2pac
Resurrecting an old thread..
It seems that this solution does not return events on objects within
frames in webpages eg . if you go to www.andersondirect.com - the page
is composed of three frames called as topFrame main and address. Now
when I click on say 'Select a Vehicle' which is within main - I do not
get any Onclick event. I also do not get an OnMousemove event if I move
the mouse. However, I do get on Mousemove event on a tag called as
frameset (which is part of the top page).
How does one get events from the frames then?
As always thanks a lot.

Roger Upole wrote:
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> ...
> > The problem is that msdn documentation says that in order to identify
> > the element that was clicked - one has to query on IHTMLWindow2::event
> > property on iHTMLWindow2 interface to get IEventOBj interface and then
> > from there - use query interfce to get to the id of the element.
> >
> > How do I do this in python? ie. I have this code
> > class Doc_Events(doc_mod.HTMLDocumentEvents):
> >def Ononclick(self):
> >print 'onClick fired '
> > and I see onClick being trapped.
> > Now I need to go and get a reference to the iHTMLWindow2 interface. For
> > this I need to get a reference to doc_mod (as far as I can see). How do
> > I get that in the OnonClick method above.
>
> To get the IHTMLWindow2, you can just use self.parentWindow
> inside the event hander, and then get the event from it.  And then
> the event's srcElement should be what you need.
>
> class Doc_Events(doc_mod.HTMLDocumentEvents):
> def Ononclick(self):
> print 'onclick'
> ev=self.parentWindow.event
> src=ev.srcElement
> print 'tagName:',src.tagName,'name:',src.getAttribute('name')
>
> For clicking on google's input field, this yields
> tagName: INPUT name: q
>
> >
> > b) You had mentioned PumpWaitingMessages in the previous posting. I
> > first encountered this on newsgroup postings. None of the standard
> > books (python on win32 / python developer) seem to explain this in
> > detail although this seems to be commonly used. Though I understand
> > this now - my problem is that there seems to be a lack of cohesive
> > explanation on how python ties up with COM (despite a good chapter 12
>
> PumpWaitingMessages is just a way to ensure that normal message processing
> (window messages, events, dde, etc) happens while python code is running.
> Normally you don't need it, but every once in a while you hit a situation
> where
> blocking occurs.
>
> For how exactly python interacts with COM, the source is your best bet.
>
> Roger
>
>
>
>
>
> == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet 
> News==
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
> Newsgroups
> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

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


Re: TKinter -- '' event executing more than once?

2005-06-11 Thread jepler
Bindings created on a Toplevel or Tk widget apply to *all* widgets in the same
toplevel.  

So you're seeing a  event for each widget you create...

Jeff


pgpTtTjOZWFaW.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: What is different with Python ?

2005-06-11 Thread Roy Smith
"Philippe C. Martin" <[EMAIL PROTECTED]> wrote:
> Yet, many issues that a future software engineer should know are
> mostly hidden by Python (ex: memory management) and that could be
> detrimental.

I know I'm going out on a limb by asking this, but why do you think future 
software engineers should know about memory management?

I used to worry about register allocation.  Today, I don't even know how 
many registers any machine I work on has.  I used to worry about word size, 
and byte order.  I used to worry about whether stacks grew up or down and 
addressing modes and floating point formats.  Sure, somebody's got to worry 
about those things, but most people who write software can be blissfully 
ignorant (or, at best, dimly aware) of these issues because somebody else 
(compiler writer, hardware designer, operating system writer, etc) has 
already done the worrying.

There used to be a time when you had to worry about how many tracks to 
allocate when you created a disk file.  When's the last time you worried 
about that?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread Peter Hansen
Philippe C. Martin wrote:
> too. I'm actually pushing the few CS professors I know to use Python for CS
> 101. Yet, many issues that a future software engineer should know are
> mostly hidden by Python (ex: memory management) and that could be
> detrimental.

I think new CS students have more than enough to learn with their 
*first* language without having to discover the trials and tribulations 
of memory management (or those other things that Python hides so well).

Simple concepts like variables, control structures, input and output are 
more than enough to start with.  In fact, I suspect any course that 
attempts to teach with a language that requires things like manual 
memory management will be failing to provide an effective grounding in 
computer science because of all the noise.  Seeing the forest for the 
trees and all that...

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


Re: SMTP Test Rig ( SMTPRIG.PY v1.0 )

2005-06-11 Thread richard
Tim Williams wrote:
> After a few posts recently,  I have put together an SMTP test rig that
> will
> receive emails and either store them to a file,  write them to a console,
> or both.
> 
> Does anyone have any suggestions on where I can get it hosted  as a
> utility for general public use?

http://www.python.org/pypi


Richard

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


Re: Dealing with marketing types...

2005-06-11 Thread Paul Rubin
Andrew Dalke <[EMAIL PROTECTED]> writes:
> My question to you is - what is "something big"?  I've not been
> on any project for which "LAMP" can't be used, and nor do I
> expect to be.  After all, there's only about 100,000 people in
> the world who might possibly interested using my software.  (Well,
> the software I get paid to do; not, say, the couple of patches I've
> sent in to Python).

If you're running a web site with 100k users (about 1/3 of the size of
Slashdot) that begins to be the range where I'd say LAMP starts
running out of gas.  Yes, Slashdot is a LAMP site, but it's split
across a rack full of servers and is spending kilobucks a month on
colo space and hosting fees.  Other similarly sized sites face similar
expenses.  It seems to me that by using implementation methods that
map more directly onto the hardware, a site with Slashdot's traffic
levels could run on a single modest PC (maybe a laptop).  I believe
LiveJournal (which has something more like a million users) uses
methods like that, as does ezboard.  There was a thread about it here
a year or so ago.

As a simple example, that article's advice of putting all fine grained
session state into the database (so that every single browser hit sets
off SQL queries) is crazy.  One site I worked on got a huge speedup by
simply storing the most frequently used stuff from the user session in
a browser cookie.  That required zero extra work to handle multiple
servers (whichever server got the query, got the cookie) and it saved
a ton of SQL traffic.

As for "big", hmm, I'd say as production web sites go, 100k users is
medium sized, Slashdot is "largish", Ebay is "big", Google is huge.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to operate the excel by python?

2005-06-11 Thread Rune Strand
John,

I wrote a script that autmates the conversion from XLS to CSV. It's
easy. But your points are still good. Thanks for making me aware the
xlrd module!

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


Re: Dealing with marketing types...

2005-06-11 Thread Andrew Dalke
Paul Rubin wrote:
> That article makes a lot of bogus claims and is full of hype.  LAMP is
> a nice way to throw a small site together without much fuss, sort of
> like fancy xerox machines are a nice way to print a small-run
> publication without much fuss.  If you want to do something big, you
> still need an actual printing press.

In the comments the author does say he's trying to be provocative.

My question to you is - what is "something big"?  I've not been
on any project for which "LAMP" can't be used, and nor do I
expect to be.  After all, there's only about 100,000 people in
the world who might possibly interested using my software.  (Well,
the software I get paid to do; not, say, the couple of patches I've
sent in to Python).

I had one client consider moving from Python/CGI/flat files to
Java/WebLogic/Oracle.  The old code took nearly 10 seconds to
display a page (!).  They were convinced that they had gone past
the point where Python/CGI was useful, and they needed to use a
more scalable enterprise solution.  The conviction meant they
didn't profile the system.  With about a day of work I got the
performance down to under a second by removing some needless imports,
delaying others until they were needed, making sure all the
.pyc files existed, etc.

I could have gotten more performance switching to a persistent
Python web server and using a database instead of a bunch of
flat files in a directory, but that wasn't worth the time.

Andrew
[EMAIL PROTECTED]

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


Re: using python from c/c++

2005-06-11 Thread Chris Smith
> "alexandr" == alexandr  <[EMAIL PROTECTED]> writes:

alexandr> Is it possible to create a library from my python module
alexandr> that can be used from c/c++ application?

http://boost.org/libs/python/doc/index.html


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


Re: how to operate the excel by python?

2005-06-11 Thread John Machin
Rune Strand wrote:
> The key is Python for Windows :
> http://starship.python.net/crew/mhammond/win32/
> 
> See here for an Excel dispatch example:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325735
> 
> When doing such operations, I generally save all the Excel files to CSV
> files and do the operations on them using the csv module.
> 

Problems with that approach:

1. Unfortunately, "save as CSV" is very much a WYSIWYG operation. If the 
"number formats" are not sensible, loss of information can result.

Example: user gets (text) data file which needs extra columns added. 
User loads it into Excel, adds extra data, saves as csv. One column is 
an identifier which just happens to be numeric -- say a 12-digit credit 
card number 123456789012. The user doesn't care that this is showing on 
the Excel screen as 1.23457E+11 (default format) as he is using the 
6-digit customer account number 654321 to find the extra data he needs 
to add. He may not even see the 1.23457E+11 because it's in column BQ 
and he's inserting 3 columns in front of column E.

To avoid that problem, one has to check all the columns and reformat 
those that do not display all the data. This is not something that a 
user can be relied on to do, even when stated clearly in a procedure manual.

2. The tedium and error-proneness of "saving as": (a) you get given a 
file named "fubar.csv" but it was "fubar.csv.xls" before the user 
renamed it. (b) Excel files can have multiple worksheets, which have to 
be saved each as a separate csv file.

Consequently, an approach which reads the .XLS file directly has 
attractions.

One such approach, which unlike the COM approach doesn't need Excel to 
be on the reading machine, and doesn't even need Windows, is the free 
"xlrd" module [of which I am the author] -- see 
http://www.lexicon.net/sjmachin/xlrd.htm
or
http://www.python.org/pypi/xlrd/

Regards,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: case/switch statement?

2005-06-11 Thread Skip Montanaro

Steven> I've never understood why something like:

Steven> if x = 5:
Steven> do_this
Steven> elif x = 6:
Steven> do_that
Steven> else:
Steven> do_something_else

Steven> is supposed to be "bad", but

Steven> case of:
Steven> x = 5:
Steven> do_this
Steven> x = 6:
Steven> do_that
Steven> otherwise:
Steven> do_something_else

Steven> is supposed to be "good".

...

Steven> Arguably, a case statement *might* allow the compiler to
Steven> optimize the code, maybe, sometimes. 

If the case values are constants known to the compiler, it can generate O(1)
code to take the correct branch.  (In fact, that could be done by the
compiler for if statements such as in your example today.  It just isn't.)
It is precisely this behavior that is desired in many situations.  See PEP
275 for details:

http://www.python.org/peps/pep-0275.html

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


Re: case/switch statement?

2005-06-11 Thread Steven D'Aprano
On Sat, 11 Jun 2005 16:15:42 +, Joe Stevenson wrote:

> Hi all,
> 
> I skimmed through the docs for Python, and I did not find anything like 
> a case or switch statement.  I assume there is one and that I just 
> missed it.  Can someone please point me to the appropriate document, or 
> post an example?  I don't relish the idea especially long if-else 
> statements.

I don't relish the idea of especially long case statements.

I've never understood why something like:

if x = 5:
do_this
elif x = 6:
do_that
else:
do_something_else

is supposed to be "bad", but

case of:
x = 5:
do_this
x = 6:
do_that
otherwise:
do_something_else

is supposed to be "good".

(Choose whatever syntax you prefer for case statements, the principle
remains.)

Arguably, a case statement *might* allow the compiler to optimize the
code, maybe, sometimes. But in general, no such optimization is possible,
so a case statement is merely equivalent to a series of if...elif...
statements.

There is no case statement in Python. If you don't care about
readability, one alternative is to use a dictionary:

case = {5: do_this, 6: do_that}
case.get(x, do_something_else)()



-- 
Steven.

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Thomas Lotze
Peter Hansen wrote:

> Fair enough, but who cares what the generator code thinks?  It's what the
> programmer has to deal with that matters, and an object is going to have a
> cleaner interface than a generator-plus-mutable-object.

That's right, and among the choices discussed, the object is the one I do
prefer. I just don't feel really satisfied...

>> It does, however, require a lot of attribute access, which does cost
>> some cycles.
> 
> Hmm... "premature optimization" is all I have to say about that.

But when is the right time to optimize? There's a point when the thing
runs, does the right thing and - by the token of "make it run, make it
right, make it fast" - might get optimized. And if there are places in a
PDF library that might justly be optimized, the tokenizer is certainly one
of them as it gets called really often.

Still, I'm going to focus on cleaner code and, first and foremost, a clean
API if it comes to a decision between these goals and optimization - at
least as long as I'm talking about pure Python code.

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Thomas Lotze
Mike Meyer wrote:

> Yes, such a switch gets the desired behavior as a side effect. Then again,
> a generator that returns tokens has a desired behavior (advancing to the
> next token) as a side effect(*).

That's certainly true.

> If you think about these things as the
> state of the object, rather than "side effects", it won't seem nearly as
> ugly. In fact, part of the point of using a class is to encapsulate the
> state required for some activity in one place.
> 
> Wanting to do everything via parameters to methods is a very top-down way
> of looking at the problem. It's not necessarily correct in an OO
> environment.

What worries me about the approach of changing state before making a
next() call instead of doing it at the same time by passing a parameter is
that the state change is meant to affect only a single call. The picture
might fit better (IMO) if it didn't look so much like working around the
fact that the next() call can't take parameters for some technical reason.

I agree that decoupling state changes and next() calls would be perfectly
beautiful if they were decoupled in the problem one wants to model. They
aren't.

> *) It's noticable that some OO languages/libraries avoid this side
> effect: the read method updates an attribute, so you do the read then
> get the object read from the attribute. That's very OO, but not very
> pythonic.

Just out of curiosity: What makes you state that that behaviour isn't
pythonic? Is it because Python happens to do it differently, because of a
gut feeling, or because of some design principle behind Python I fail to
see right now?

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


TKinter -- '' event executing more than once?

2005-06-11 Thread Christopher Subich
I'm building an application involving both twisted and Tkinter.  Since 
twisted co-opts .mainloop() in its reactor.run(), and since it 
behaves very badly if the application quits without reactor.stop() 
running, I attach the following function to '' in the main 
window (root = Tk()):

def stop_reactor_bind(x):
reactor.stop()

Then:
root.bind('',stop_reactor_bind)

The problem, however, comes that when I add a Text widget inside the 
root window, upon destroying the window (closing it) the callback seems 
to execute twice.  In interactive testing, it's executed once per widget 
inside the root window.  Since twisted doesn't take multiple 
reactor.stop()s gracefully, how (short of wrapping this inside a 
class/scope that keeps state) can I ensure that the callback executes 
only once? Am I attaching to the wrong signal?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread Philippe C. Martin
> PS: http://jove.prohosting.com/~zahlman/cpp.html

So you're saying they only use perl in Taiwan ;-)



Tom Anderson wrote:

> On Sat, 11 Jun 2005, Philippe C. Martin wrote:
> 
>> Yet for the first time I get (most) of my questions answered by a
>> language I did not know 1 year ago.
> 
> Amazing, isn't it? Rest assured that you're not alone in feeling this way.
> I don't know quite why, but python is just makes writing programs
> immensely easier than any other language i've ever used; i think it's the
> very minimal amount of boilerplate it requires, the clean and powerful set
> of builtin types and functions and, for me, the higher-order functions. I
> can do in a few lines of python what would have taken me pages and pages
> of java.
> 
> tom
> 
> PS: http://jove.prohosting.com/~zahlman/cpp.html
> 

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


Re: anygui,anydb, any opinions?

2005-06-11 Thread Renato Ramonda
Tim Roberts ha scritto:

> Hardly.  Sizers have been the primary method of placing multiple controls
> in wx for as long as I've been using it, which goes back to 2.3.  In fact,
> it's hard to create a non-trivial wx app WITHOUT using sizers.  All of the
> wx GUIs place controls in nested sets of sizers.

Dunno... I'll take your word on this. In my experience though wx apps 
have awfully ugly laid out interfaces, often non resizable ones. Maybe 
is't only bad luck :-)

-- 
Renato

Usi Fedora? Fai un salto da noi:
http://www.fedoraitalia.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How many threads are too many?

2005-06-11 Thread Aahz
In article <[EMAIL PROTECTED]>,
rbt  <[EMAIL PROTECTED]> wrote:
>
>When designing a threaded application, is there a pratical limit on  the 
>number of threads that one should use or is there a way to set it up so 
>that the OS handles the number of threads automatically? I am developing 
>on 32-bit x86 Intel systems with python 2.4.1. The OS will be Linux and 
>Windows.

The practical limit is somewhere between five and a hundred threads,
depending on what you're doing.  The more I/O you're doing, the more
greater numbers of threads will benefit you.

>I have an older app that used to work fine (254 threads) on early 2.3 
>Pythons, but now, I get this error with 2.4.1 and 2.3.5:
>
>Traceback (most recent call last):
>   File "net_queue_and_threads.py", line 124, in ?
> thread.start()
>   File "/usr/lib/python2.3/threading.py", line 416, in start
> _start_new_thread(self.__bootstrap, ())
>thread.error: can't start new thread

That's rather odd.  Which OS is this?  Did you build Python yourself or
did you download it?
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread Tom Anderson
On Sat, 11 Jun 2005, Philippe C. Martin wrote:

> Yet for the first time I get (most) of my questions answered by a 
> language I did not know 1 year ago.

Amazing, isn't it? Rest assured that you're not alone in feeling this way. 
I don't know quite why, but python is just makes writing programs 
immensely easier than any other language i've ever used; i think it's the 
very minimal amount of boilerplate it requires, the clean and powerful set 
of builtin types and functions and, for me, the higher-order functions. I 
can do in a few lines of python what would have taken me pages and pages 
of java.

tom

PS: http://jove.prohosting.com/~zahlman/cpp.html

-- 
Jim-Jammity Jesus Krispy Kreme Christ on a twat-rocket!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with marketing types...

2005-06-11 Thread Drazen Gemic
On Sat, 11 Jun 2005 11:51:02 -0500, tom wrote:

> The sequence goes like this:
> 1) When there is little or no money to be made, you start out with an
> implied status as a partner. This means you work long + extra hours for
> little pay on the promise that you will be rewarded when/if success comes.

Well, customers are NOT partners. You need a contract when you deal with
customers. It is not a team work, it is selling and buying. And you are
selling. This is a third year that I am working as a freelance, and,
during unofficial conversations with customers representatives,  
I have heard many phrases like: 
"I am your ally", "covering your back", "we are the team", and I never fell
for any of them. I agreed in general, never been impolite, but went on my
way.  And I never forgot, neither let customers forget, that I am selling, and 
they are
buying, and we are not the team.

DG

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


Re: What is different with Python ?

2005-06-11 Thread Philippe C. Martin
I agree '...choice for the very beginners ...': a hundred year ago I was a
Pascal TA, and although I like the language, I find/found people stuggled
as much with the language as with the algorithm they were supposed to
implement.

"...mostly variants of Basic..." What I truly liked going from Basic (which
has greatly evolved) to Pascal was the fact I found a definite risk not
having to declare variable/ or rather I understood the lack of danger in
doing so: The one (so I thought) glitch with Python that almost made me
stop playing with was that very fact. yet I agree a complete beginner would
simply the approach most meaningful "why should I write int i = 1 since I
know 1 is an int". Since the "dangers" of old basic are gone from Python
(can't do i=y if y has not ever been initialized). I must agree with that
too. I'm actually pushing the few CS professors I know to use Python for CS
101. Yet, many issues that a future software engineer should know are
mostly hidden by Python (ex: memory management) and that could be
detrimental.

Regards,

Philippe






Claudio Grondi wrote:

>> 4) Yes I agree a mix ("... well spiced soup ...")
>> seems to be the answer but
>> my brain somehow wants to formalize it.
> 
> Here one further suggestion trying to point out, that
> it probably can't generally be formalized, because
> the experience one developes after going through
> the story of "assembly, basic, cobol, lisp,
> JAVA, c, c++, perl, Tcl, Java, JavaCard" has
> in my opinion a vital impact on shortcuts one uses
> and the way of doing things. I mean, that the concept
> of Python has raised from such experience, so anyone
> who went through all this, will get the core ideas
> implemented in Python without any effort, because
> they were already there as a kind of meta-language
> used in thinking, unconsciously looking for the
> chance of beeing  expressed in formalized form
> as a new programming language.
> To support my thesis I can mention here, that
> from my experience, Python seems not to be
> the language of choice for the very beginners,
> who prefere another approaches which are
> mostly variants of Basic.
> 
> Claudio
> 
> "Philippe C. Martin" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
>> Thanks ,
>> I have gotten many answers already, some not posted.
>>
>> 1) Typing is not the issue - even with RT-Kernels, people use C++
>> 2) Yes I find dynamic binding very nice
>> 3) "... you didn't give many examples of what you did for the
>> last 18 years (except that that also included RT kernels). " assembly
>> (losts) , basic, cobol, lisp, JAVA, c, c++, perl, Tcl, Java, JavaCard
> .
>>
>> I know the "interactive" aspect helps also, the runtime error/exception
>> checking, the many libraries/tools, the responsiveness of the people on
>> this newsgroup, the "introspectiveness" of the system, the cross-platform
>> it deals with, the way it "pushes" people to code in a clean way, the GUI
>> support, the stability, the extensibility (in and out)  I'm sure
> you'll
>> agree none of that can explain why after 1 week of playing with, I was
> more
>> productive in Python than C/C++ just as I know my product (I will not
>> describe it here as I am not marketing) would not exist today were it not
>> for Python.
>> 4) Yes I agree a mix ("... well spiced soup ...") seems to be the answer
> but
>> my brain somehow wants to formalize it.
>>
>> Regards,
>>
>> Philippe
>>
>>
>>
>>
>>
>> Philippe C. Martin wrote:
>>
>> > I apologize in advance for launching this post but I might get
> enlightment
>> > somehow (PS: I am _very_ agnostic ;-).
>> >
>> > - 1) I do not consider my intelligence/education above average
>> > - 2) I am very pragmatic
>> > - 3) I usually move forward when I get the gut feeling I am correct
>> > - 4) Most likely because of 1), I usually do not manage to fully
>> > explain 3) when it comes true.
>> > - 5) I have developed for many years (>18) in many different
> environments,
>> > languages, and O/S's (including realtime kernels) .
>> >
>> >
>> > Yet for the first time I get (most) of my questions answered by a
> language
>> > I did not know 1 year ago.
>> >
>> > As I do try to understand concepts when I'm able to, I wish to try and
>> > find out why Python seems different.
>> >
>> > Having followed this newsgroup for sometimes, I now have the gut
>> > feeling (see 3)) other people have that feeling too.
>> >
>> >
>> > Quid ?
>> >
>> > Regards,
>> >
>> > Philippe
>>

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread nephish
Great Advice, can see that saving me a few headaches
thanks

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


Re: What is different with Python ?

2005-06-11 Thread Claudio Grondi
> 4) Yes I agree a mix ("... well spiced soup ...")
> seems to be the answer but
> my brain somehow wants to formalize it.

Here one further suggestion trying to point out, that
it probably can't generally be formalized, because
the experience one developes after going through
the story of "assembly, basic, cobol, lisp,
JAVA, c, c++, perl, Tcl, Java, JavaCard" has
in my opinion a vital impact on shortcuts one uses
and the way of doing things. I mean, that the concept
of Python has raised from such experience, so anyone
who went through all this, will get the core ideas
implemented in Python without any effort, because
they were already there as a kind of meta-language
used in thinking, unconsciously looking for the
chance of beeing  expressed in formalized form
as a new programming language.
To support my thesis I can mention here, that
from my experience, Python seems not to be
the language of choice for the very beginners,
who prefere another approaches which are
mostly variants of Basic.

Claudio

"Philippe C. Martin" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Thanks ,
> I have gotten many answers already, some not posted.
>
> 1) Typing is not the issue - even with RT-Kernels, people use C++
> 2) Yes I find dynamic binding very nice
> 3) "... you didn't give many examples of what you did for the
> last 18 years (except that that also included RT kernels). " assembly
> (losts) , basic, cobol, lisp, JAVA, c, c++, perl, Tcl, Java, JavaCard
.
>
> I know the "interactive" aspect helps also, the runtime error/exception
> checking, the many libraries/tools, the responsiveness of the people on
> this newsgroup, the "introspectiveness" of the system, the cross-platform
> it deals with, the way it "pushes" people to code in a clean way, the GUI
> support, the stability, the extensibility (in and out)  I'm sure
you'll
> agree none of that can explain why after 1 week of playing with, I was
more
> productive in Python than C/C++ just as I know my product (I will not
> describe it here as I am not marketing) would not exist today were it not
> for Python.
> 4) Yes I agree a mix ("... well spiced soup ...") seems to be the answer
but
> my brain somehow wants to formalize it.
>
> Regards,
>
> Philippe
>
>
>
>
>
> Philippe C. Martin wrote:
>
> > I apologize in advance for launching this post but I might get
enlightment
> > somehow (PS: I am _very_ agnostic ;-).
> >
> > - 1) I do not consider my intelligence/education above average
> > - 2) I am very pragmatic
> > - 3) I usually move forward when I get the gut feeling I am correct
> > - 4) Most likely because of 1), I usually do not manage to fully explain
> > 3) when it comes true.
> > - 5) I have developed for many years (>18) in many different
environments,
> > languages, and O/S's (including realtime kernels) .
> >
> >
> > Yet for the first time I get (most) of my questions answered by a
language
> > I did not know 1 year ago.
> >
> > As I do try to understand concepts when I'm able to, I wish to try and
> > find out why Python seems different.
> >
> > Having followed this newsgroup for sometimes, I now have the gut feeling
> > (see 3)) other people have that feeling too.
> >
> >
> > Quid ?
> >
> > Regards,
> >
> > Philippe
>




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


BBC R&D White Paper on Kamaelia Published (Essentially a framework using communicating python generators)

2005-06-11 Thread Michael Sparks
Hi,


I'm posting a link to this since I hope it's of interest to people here :)

I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework,
and it's been published as a BBC R&D White Paper and is available here:

   * http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml

Essentially it provides a means of a) communicating to python generators b)
linking these communications between generators (the result is calling these
components), c) building interesting systems using it. (Next release will
include some interesting things like a shell, introspection tool, and
pygame related components)

Essentially the key tenet of the project is that of trying to make scalable
concurrent and network systems easy to build and reuse.

We're using it for network research purposes, but the system should be
sufficiently general to be of use for all sorts of uses. (Though for
production systems I'd probably recommend Twisted over Kamaelia for now,
just for perspective :)

Any comments, criticisms/etc very welcome!


Michael.
--
http://kamaelia.sourceforge.net/

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


Re: Best Web dev language

2005-06-11 Thread John Roth

"Mike Meyer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Jon Slaughter" <[EMAIL PROTECTED]> writes:
>
>
> Someone mentioned that you might "require JavaScript on the client
> side". I recommend against that - people and organizations disable
> JavaScript for security reasons, and browsers on portable devices may
> not have JavaScript at all. Why limit your audience? If you understand
> HTML, it's possible to write a web page that uses JavaScript (or any
> other such technology) for flashy effects, but still functions
> properly if the user has disabled JavaScript, or doesn't have it
> available. But that's a long discussion - see  http://www.mired.org/home/mwm/papers.green.html > for more
> information.

I would have said that at one time, but then the world changed
with AJAX, expecially with Google using very script heavy applications
for all of their new work. It leads to very responsive web applications.

John Roth

>
>
>-- 
> Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/
> Independent WWW/Perforce/FreeBSD/Unix consultant, email for more 
> information. 

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


Re: What is different with Python ?

2005-06-11 Thread Philippe C. Martin
Thanks , 
I have gotten many answers already, some not posted.

1) Typing is not the issue - even with RT-Kernels, people use C++
2) Yes I find dynamic binding very nice
3) "... you didn't give many examples of what you did for the
last 18 years (except that that also included RT kernels). " assembly
(losts) , basic, cobol, lisp, JAVA, c, c++, perl, Tcl, Java, JavaCard . 

I know the "interactive" aspect helps also, the runtime error/exception
checking, the many libraries/tools, the responsiveness of the people on
this newsgroup, the "introspectiveness" of the system, the cross-platform
it deals with, the way it "pushes" people to code in a clean way, the GUI
support, the stability, the extensibility (in and out)  I'm sure you'll
agree none of that can explain why after 1 week of playing with, I was more
productive in Python than C/C++ just as I know my product (I will not
describe it here as I am not marketing) would not exist today were it not
for Python.
4) Yes I agree a mix ("... well spiced soup ...") seems to be the answer but
my brain somehow wants to formalize it.

Regards,

Philippe





Philippe C. Martin wrote:

> I apologize in advance for launching this post but I might get enlightment
> somehow (PS: I am _very_ agnostic ;-).
> 
> - 1) I do not consider my intelligence/education above average
> - 2) I am very pragmatic
> - 3) I usually move forward when I get the gut feeling I am correct
> - 4) Most likely because of 1), I usually do not manage to fully explain
> 3) when it comes true.
> - 5) I have developed for many years (>18) in many different environments,
> languages, and O/S's (including realtime kernels) .
> 
> 
> Yet for the first time I get (most) of my questions answered by a language
> I did not know 1 year ago.
> 
> As I do try to understand concepts when I'm able to, I wish to try and
> find out why Python seems different.
> 
> Having followed this newsgroup for sometimes, I now have the gut feeling
> (see 3)) other people have that feeling too.
> 
> 
> Quid ?
> 
> Regards,
> 
> Philippe

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


Re: Sending mail from 'current user' in Python

2005-06-11 Thread Grig Gheorghiu
There may have been a reason for the win32 stuff at some pointbut I
don't remember and you're right, it does seem like getpass by itself
would do the job.

Grig

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Mike Meyer
Thomas Lotze <[EMAIL PROTECTED]> writes:
> A related problem is skipping whitespace. Sometimes you don't care about
> whitespace tokens, sometimes you do. Using generators, you can either set
> a state variable, say on the object the generator is an attribute of,
> before each call that requires a deviation from the default, or you can
> have a second generator for filtering the output of the first. Again, both
> solutions are ugly (the second more so than the first). One uses
> side-effects instead of passing parameters, which is what one really
> wants, while the other is dumb and slow (filtering can be done without
> taking a second look at things).

I wouldn't call the first method ugly; I'd say it's *very* OO.

Think of an object instance as a machine. It has various knobs,
switches and dials you can use to control it's behavior, and displays
you can use to read data from it, or parts of its state . A switch
labelled "ignore whitespace" is a perfectly reasonable thing for a
tokenizing machine to have.

Yes, such a switch gets the desired behavior as a side effect. Then
again, a generator that returns tokens has a desired behavior
(advancing to the next token) as a side effect(*). If you think about
these things as the state of the object, rather than "side effects",
it won't seem nearly as ugly. In fact, part of the point of using a
class is to encapsulate the state required for some activity in one
place.

Wanting to do everything via parameters to methods is a very top-down
way of looking at the problem. It's not necessarily correct in an OO
environment.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread Claudio Grondi
Re: What is different with Python ?

from my point of view, to be honest, nothing
except mixing a well spiced soup of what
was available within other programming
languages.

I think, that what currently makes a real
difference is not the language as such,
but the people using it, posting here and
writing new modules for it.

I can imagine, that with becoming more
popular and less supported by the
core development team (following a
special kind of programming philosophy
called "Pythonic way" of approaching
things) this can change, so I can only hope,
that this won't happen.

Don't ask _me_ what "Pythonic way" is -
I think, you have to feel it yourself in order to
understand it (I haven't yet seen any definition
of it different from what is already also known
from other programming languages, but maybe
someone can provide it?).

by the way: I see a contradiction between
> - 1) I do not consider my intelligence/education above average
and
> - 5) I have developed for many years (>18) in many different environments,
> languages, and O/S's (including realtime kernels) .
because - 5) is the story many of programmers choosing Python
as a tool or programming language of their choice went through
and because of the fact you are here asking that question.

Claudio

"Philippe C. Martin" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> I apologize in advance for launching this post but I might get enlightment
> somehow (PS: I am _very_ agnostic ;-).
>
> - 1) I do not consider my intelligence/education above average
> - 2) I am very pragmatic
> - 3) I usually move forward when I get the gut feeling I am correct
> - 4) Most likely because of 1), I usually do not manage to fully explain
3)
> when it comes true.
> - 5) I have developed for many years (>18) in many different environments,
> languages, and O/S's (including realtime kernels) .
>
>
> Yet for the first time I get (most) of my questions answered by a language
I
> did not know 1 year ago.
>
> As I do try to understand concepts when I'm able to, I wish to try and
find
> out why Python seems different.
>
> Having followed this newsgroup for sometimes, I now have the gut feeling
> (see 3)) other people have that feeling too.
>
>
> Quid ?
>
> Regards,
>
> Philippe
>
>
>
>
>
>
>
>
>
>


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


Re: What is different with Python ?

2005-06-11 Thread Peter Hansen
Martin v. Löwis wrote:
> Philippe C. Martin wrote:
>>- 5) I have developed for many years (>18) in many different environments,
>>languages, and O/S's (including realtime kernels) .
> 
> 2. You may not have dealt with a weakly-typed language before. If
>that is the case, your feeling of "something being different"
>most likely comes from that difference.

If he's done realtime kernels, he's most definitely worked with a weakly 
typed language before (assembly most likely), but I think you meant to 
say (or should have said) "dynamically typed".

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread Mike Meyer
[EMAIL PROTECTED] writes:

> fixed, thanks for all of your help.
> i am pouring over python texts and the problem is
> html... duh

Right. To get HTML that will work in any browser, http://www.anybrowser.org/campaign/ >, you really need to validate
your HTML. w3.org provides a public validator at http://validator.w3.org/ > (as well as validators for CSS, RDF, XML
Schema and link checking). If you're going to be doing a lot of work
with such formats, you probably want to install a validator
locally. Lots of options for that, depending on what kind of system
you're using.

BTW, practical experience is that you write your application to follow
the standards, then go back and work around the bugs in various
versions of IE.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Philippe C. Martin wrote:
> I apologize in advance for launching this post but I might get enlightment
> somehow (PS: I am _very_ agnostic ;-).
> 
> - 1) I do not consider my intelligence/education above average
> - 2) I am very pragmatic
> - 3) I usually move forward when I get the gut feeling I am correct
> - 4) Most likely because of 1), I usually do not manage to fully explain 3)
> when it comes true.
> - 5) I have developed for many years (>18) in many different environments,
> languages, and O/S's (including realtime kernels) .
> 
> 
> Yet for the first time I get (most) of my questions answered by a language I
> did not know 1 year ago.
> 
> As I do try to understand concepts when I'm able to, I wish to try and find
> out why Python seems different. 

Unfortunately, you didn't give many examples of what you did for the
last 18 years (except that that also included RT kernels).

So let me guess two aspects:

1. In these 18 years, you got acquainted to a variety of concepts
   in various languages. When dealing with Python, you could easily
   correlate between Python concepts and the ones you are familiar
   with. This is one of Python's strenghts: it tries not to be
   surprising, but builds on what most people consider standard.
   Try "import this" some time; you may be experiencing the Zen:

   Readability counts.
   ...
   Special cases aren't special enough to break the rules.
   Although practicality beats purity.
   ...
   In the face of ambiguity, refuse the temptation to guess.

2. You may not have dealt with a weakly-typed language before. If
   that is the case, your feeling of "something being different"
   most likely comes from that difference.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-11 Thread Robert Kern
Philippe C. Martin wrote:
> I apologize in advance for launching this post but I might get enlightment
> somehow (PS: I am _very_ agnostic ;-).
> 
> - 1) I do not consider my intelligence/education above average
> - 2) I am very pragmatic
> - 3) I usually move forward when I get the gut feeling I am correct
> - 4) Most likely because of 1), I usually do not manage to fully explain 3)
> when it comes true.
> - 5) I have developed for many years (>18) in many different environments,
> languages, and O/S's (including realtime kernels) .
> 
> Yet for the first time I get (most) of my questions answered by a language I
> did not know 1 year ago.

I cannot understand this sentence. What questions? Which language?

Do you mean that, currently, when you need to solve a problem, you 
usually use Python even though you are relatively new to it? And that 
before learning Python you usually used a variety of languages, none 
dominating the others?

> As I do try to understand concepts when I'm able to, I wish to try and find
> out why Python seems different. 

Python is my language of choice because it doesn't get in the way. I 
don't have to contort my problem into strict class heirarchies or 
recursive functions. I don't have to construct the whole system to test 
just a part of it. The interactive prompt has become vital to my 
workflow. By and large, I just Get It Done.

The "one and preferably only one obvious way to do it" principle and 
Python's emphasis on readability means that I gain knowledge and 
capability as I write code. When I need to do a similar task six months 
later, I don't have to spend an inordinate amount of time figuring out 
what the hell I was thinking back then. In the same vein, I can also 
read and learn from others' code much more than I could from, say, Perl.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


Re: Best Web dev language

2005-06-11 Thread Mike Meyer
"Jon Slaughter" <[EMAIL PROTECTED]> writes:

> Also, can anyone recommend any book or web page that gives an introduction 
> to the method in which one programs web sites? I am not clear on who one, 
> for instance, would use C++ as the language for a web site except by using 
> it to create html... I'm not sure if basicaly all languages goal is creating 
> html dynamically or if there is more to do.  What I mean is that basicaly 
> one is using some other language to wrap the html code or possibly generate 
> it at run-time for dynamic results. (so all client based web interfaces are 
> really just html readers but all this "extra" stuff is used to make certain 
> things easier and dynamic(just as generating tables and forms and all that).

That's one way to look at it.

Personally, I prefer to think of HTML as the "UI toolkit" for web
development. It's more like CLI code that GUI code, in that you have
three distinct phases of "process, display, await response" rather
than waiting for UI events which trigger data processing and a display
update.

As such, you can use pretty much any language that can connect to the
toolkit. CGI is pretty low-level, and pretty much anything can be
used. C++ and Java both certainly get used. Others have mentioned LISP
variants. I've used the shell and Rexx. These days, I prefer Python,
but that's what you'd expect from somene reading c.l.python. Anything
you're comfortable with should work. In particular, since the user is
going to spend time waiting on network delays, any performance issues
the language implementation may have will be negligible for a single
user.

Someone mentioned that you might "require JavaScript on the client
side". I recommend against that - people and organizations disable
JavaScript for security reasons, and browsers on portable devices may
not have JavaScript at all. Why limit your audience? If you understand
HTML, it's possible to write a web page that uses JavaScript (or any
other such technology) for flashy effects, but still functions
properly if the user has disabled JavaScript, or doesn't have it
available. But that's a long discussion - see http://www.mired.org/home/mwm/papers.green.html > for more
information.


 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: identifying 64-bit Windows from 2.3.5?

2005-06-11 Thread =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
Steven Knight wrote:
> Can some Windows-savvy Pythonista point me to some way to distinguish
> between these two?

I would look at the environment variable PROCESSOR_ARCHITECTURE. On
the Win64 machine I use, its value is "IA64".

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pyton for me?

2005-06-11 Thread Mike Meyer
Peter Hansen <[EMAIL PROTECTED]> writes:

> Kirk Job Sluder wrote:
>> I agree with this approach.  For me, there has to be a certain level of
>> complexity before I reach for python as a tool.
>
> For me as well.  In my case, the key question is "is this bash script
> going to be longer than two lines?".  If it would be, the Python
> approach will be done faster and will be more maintainable, since I
> often don't look at those scripts again for months and would tend to
> forget any bash syntax that I've learned in the meantime.

I tend to switch from sh to python when I start writing a loop. A long
list of repeated commands - even with conditionals - isn't to bad. But
when you start forking processes in a loop, it's time to use a more
powerful tool.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with marketing types...

2005-06-11 Thread Philippe C. Martin
This is the never ending story of the cyclic (I'm being redundant) life
cycle of many companies: R&D driven versus Marketing driver.

My belief is that none work as the trades do not attempt to reach the same
goal:
1) R&D should not try to define products
2) Marketing should not try to impose the tools/means necessary to implement
the products they have defined.

I know that does not help



flyingfred0 wrote:

> A small software team (developers, leads and even the manager when he's
> had time) has been using (wx)Python/PostgreSQL for over 2 years and
> developed a successful 1.0 release of a client/server product.
> 
> A marketing/product manager has brought in additional management and
> "architecture" experts to propose moving the entire thing to a Java
> (application server) platform for the next release.  They want a
> "scalable, enterprise solution" (though they don't really know what that
> means) and are going crazy throwing around the Java buzzwords (not to
> mention XML).
> 
> The developers (including myself) are growing uneasy; the management is
> continuing to push their requirements and ignore the engineers.  I think
> there's still hope, but I'm at a loss for ideas beyond pointing out the
> success stories of Python and Zope and language comparisons between
> Python and Java.
> 
> What experiences have those in the Python community had in these kinds
> of situations?

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


What is different with Python ?

2005-06-11 Thread Philippe C. Martin
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).

- 1) I do not consider my intelligence/education above average
- 2) I am very pragmatic
- 3) I usually move forward when I get the gut feeling I am correct
- 4) Most likely because of 1), I usually do not manage to fully explain 3)
when it comes true.
- 5) I have developed for many years (>18) in many different environments,
languages, and O/S's (including realtime kernels) .


Yet for the first time I get (most) of my questions answered by a language I
did not know 1 year ago.

As I do try to understand concepts when I'm able to, I wish to try and find
out why Python seems different. 

Having followed this newsgroup for sometimes, I now have the gut feeling
(see 3)) other people have that feeling too.


Quid ?

Regards,

Philippe










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


Re: Dealing with marketing types...

2005-06-11 Thread Paul Rubin
"Terry Reedy" <[EMAIL PROTECTED]> writes:
> > http://naeblis.cx/rtomayko/2005/05/28/ibm-poop-heads
> > which is probably what you meant.
> Thanks for digging this up.  It solidified my understanding of why LAMP.

That article makes a lot of bogus claims and is full of hype.  LAMP is
a nice way to throw a small site together without much fuss, sort of
like fancy xerox machines are a nice way to print a small-run
publication without much fuss.  If you want to do something big, you
still need an actual printing press.  Hint: Google.com is not a LAMP
site despite that article's insinuation.  Yes, Google uses Python for
lots of internal projects and maybe administrative pages.  The search
engine is not a Python app.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with marketing types...

2005-06-11 Thread Stephen Kellett
In message <[EMAIL PROTECTED]>, EP 
<[EMAIL PROTECTED]> writes
>> that means) and are going crazy throwing around the Java buzzwords (not to
>> mention XML).

Sounds like someone has read about AJAX and decided that is what is 
next. They probably put 2 and 2 together and came up with 5 thinking the 
J stands for Java rather than Javascript and that your sever end must be 
Java. Well if they really want performance play the C++ (or assembler!) 
trump card and watch them squirm :-)

I think you best approach is some serious education of upper management 
on the benefits and pitfalls of each language, and of switching 
languages. Also point out the huge costs:

o Total write-off of all development costs of V1.0.

o Total write off of all intellectual property assets of V1.0 (well if 
you are building V2.0 on something else, you've put V1.0 in the bin with 
zero re-use)

o Total slap in the face and moral-crusher to the development team and 
support staff for V1.0. You will most likely see an exodus of talented 
staff after the change, if it happens.

o Effectively starting from ground-zero, making the cost for 
implementing V2.0 the entire development cost, rather than the 
incremental cost for the jump to V2.0 from V1.0 using the existing 
language.

The costs in human, timescale and financial terms for what these people 
are proposing are huge. This company may not survive the change. If they 
change you may want to consider the "abandon ship" approach and find a 
more reliable place to devote you skills to.

Finally, read "The Peter Principle" and realise there are people like 
these with their sights set on getting to the top of the greasy pole 
without any consideration for the damage they cause to others. You need 
to identify such people and steer clear of them (they generally do not 
infect all companies).

All the best.

Stephen
-- 
Stephen Kellett
Object Media Limitedhttp://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with marketing types...

2005-06-11 Thread Terry Reedy

"Terry Hancock" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> http://naeblis.cx/rtomayko/2005/05/28/ibm-poop-heads
>
> which is probably what you meant.

Thanks for digging this up.  It solidified my understanding of why LAMP.

TJR



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


Re: case/switch statement?

2005-06-11 Thread Philippe C. Martin
I _love_ Python!


Leif K-Brooks wrote:

> Joe Stevenson wrote:
>> I skimmed through the docs for Python, and I did not find anything like
>> a case or switch statement.  I assume there is one and that I just
>> missed it.  Can someone please point me to the appropriate document, or
>> post an example?  I don't relish the idea especially long if-else
>> statements.
> 
> If you really want one, you could use
> .

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread nephish
fixed, thanks for all of your help.
i am pouring over python texts and the problem is
html... duh

looking for a more efficient way to jerk all of the hair outta my head.


thanks a whole lot. your awesome

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


Re: case/switch statement?

2005-06-11 Thread Leif K-Brooks
Joe Stevenson wrote:
> I skimmed through the docs for Python, and I did not find anything like 
> a case or switch statement.  I assume there is one and that I just 
> missed it.  Can someone please point me to the appropriate document, or 
> post an example?  I don't relish the idea especially long if-else 
> statements.

If you really want one, you could use
.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any way to not create .pyc files?

2005-06-11 Thread Terry Hancock
On Saturday 11 June 2005 06:14 am, Piet van Oostrum wrote:
> > Terry Hancock <[EMAIL PROTECTED]> (TH) wrote:
> >TH> It looks to me like Python just deleted a read-only file owned by
> >TH> root in order to replace it with a new pyc file.  Can somebody
> >TH> explain that to me?!  Isn't that supposed to be impossible?
> 
> If the directory is writable, you can delete a file and write a new one
> with the same name. The permissions of the file itself are of no importance
> in this case.

Yeah, I guess that must be so.  I wonder why I never noticed it, though.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: How to overcome automatic cyrillic-to-/hex convert

2005-06-11 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> But when I enter some Bulgarian (actually cyrillic) text as a string,
> it
> seems that Python automatically converts it to '\x00..\x00 ' and once
> converted that way I can't get it back into its original look. The only
> way to get it right is using print :
>
 a = 'ÌÀÌÀ' # 'Mam' in Bulgarian
 print a
> 'ÌÀÌÀ'
>
> but
>
 a
> '\xcc\xe0\xec\xe0'

There is a difference between internal data and external presentation. 
Print a calls str(a) to get a 'nice' presentation.  Echoing 'a' calls 
repr(a) to get an invertible presentation (eval(repr(somestring)) == 
somestring).  Internally, 'a' is the 4 bytes indicated by the repr 
presentation, not the 16 chars displayed in that presentation.  There is no 
conversion until that presentation.

I cannot comment about wxGrid and how to get it to display the nice version 
you want.

Terry J. Reedy



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

Re: Dynamic Lists, or...?

2005-06-11 Thread tiissa
Lorn wrote:
> I'm trying to figure out a way to create dynamic lists or possibly
> antother solution for the following problem. I have multiple lines in a
> text file (every line is the same format) that are iterated over and
> which need to be compared to previous lines in the file in order to
> perform some simple math. Each line contains 3 fileds: a descriptor and
> two integers. Here is an example:
> 
> rose, 1, 500
> lilac, 1, 300
> lilly, 1, 400
> rose, 0, 100

Do you have to maintain a list or just the current value?
Also I did not find it clear why you have to compare with previous line?

Anyway, I think dictionnary may be useful there:


  >>> input = """rose, 1, 500
  ... lilac, 1, 300
  ... lilly, 1, 400
  ... rose, 0, 100"""
  >>>
  >>> entries = [l.split(',') for l in input.split('\n')]
  >>>
  >>> d = {}
  >>> for k, op, n in entries:
  ... if int(op) == 1:
  ... d[k] = d.get(k, 0) + int(n)
  ... else:
  ... d[k] = d.get(k, 0) - int(n)
  ...
  >>> print d
  {'rose': 400, 'lilly': 400, 'lilac': 300}
  >>>


That may not be what you want but there may be some things for you to use.
And you can of course keep the full list of operation in d.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Dealing with marketing types...

2005-06-11 Thread tom
On Sat, 11 Jun 2005 10:27:26 -0700, bruce wrote:

> i don't know what the original thread is/was...
> 
> but.. if you are part of an initial project.. get in writing what your role
> is if you're as a partner, get it in writing... if you're as a hired
> gun.. get it in writing... if you can't get anything in writing.. then make
> sure you have your own copies of any/all code that you're created/been a
> part of...
> 
> in this day/age, you need to protect yourself
> 
> and trust me, if your code is valuable, and you walk away with it because
> you feel you've been treated in an unfair manner (assuimng no written
> statement of your role), then let the other guy come after you... things get
> resolved in a much more equitable manner when the concerned parties are
> reasonably equal...
> 
> -bruce

I agree completely and you do need to read the original post.
Thomas Bartkus

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


wx ListCtrl with combobox...

2005-06-11 Thread Fabio Pliger
Hi all,
i'm working on a very large project using wx 2.5... On one frame i have a
wx.lib.mixins.listctrl widget, wich is a listctrl extended with the
possibility to edit the columns text entrys Anyone know if it's possible
(or if there's a widget...) to have also the possbility to have a comboBox
in the list (with the text edit entry)? The final result i need is a list
with 2 columns, one with the text entry editable, and the other with a
comboBox in it... Anyone know to do it?
TNX a lot...

F.P.



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


Dynamic Lists, or...?

2005-06-11 Thread Lorn
I'm trying to figure out a way to create dynamic lists or possibly
antother solution for the following problem. I have multiple lines in a
text file (every line is the same format) that are iterated over and
which need to be compared to previous lines in the file in order to
perform some simple math. Each line contains 3 fileds: a descriptor and
two integers. Here is an example:

rose, 1, 500
lilac, 1, 300
lilly, 1, 400
rose, 0, 100

The idea is that the 0/1 values are there to let the program know
wether to add or subtract the second integer value for a specific
descriptor (flower in this case). So the program comes upon rose, adds
the 500 to an empty list, waits for the next appearance of the rose
descriptor and then (in this case) subtracts 100 from 500 and prints
the value. If the next rose was a 1 then it would have added 100.

I'm uncertain on how to approach doing this though. My idea was to
somehow be able to create lists dynamically upon each new occurence of
a descriptor that currently has no list and then perform the
calculations from there. Unfortunately, the list of descriptors is
potentially infinte, so I'm unable to previously create lists with the
descriptor names. Could anyonw give any suggestions on how to best
approach this problem, hopefully I've been clear enough? Any help would
be very gratly appreciated.

Best regards,
Lorn

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Peter Hansen
Thomas Lotze wrote:
> Which is, as far as the generator code is concerned, basically the same as
> passing a mutable object to a (possibly standalone) generator. The object
> will likely be called self, and the value is stored in an attribute of it.

Fair enough, but who cares what the generator code thinks?  It's what 
the programmer has to deal with that matters, and an object is going to 
have a cleaner interface than a generator-plus-mutable-object.

> Probably this is indeed the best way as it doesn't require the programmer
> to remember any side-effects.
> 
> It does, however, require a lot of attribute access, which does cost some
> cycles.

Hmm... "premature optimization" is all I have to say about that.

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


Re: Abstract and concrete syntax

2005-06-11 Thread David Baelde
>>> You can do stuff like this: lambda x: x and 2 or 3
>>lambda x: {True:2,False:3}.get(bool(a))

And by the way, I just noticed that this kind of hack is essentially
"pushing the control (statement) inside expressions"... People should
really admit that statements are expressions and stop twist their mind.

I sure can write unreadable python without statement-as-expressions, and
this is an example of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Dealing with marketing types...

2005-06-11 Thread bruce
i don't know what the original thread is/was...

but.. if you are part of an initial project.. get in writing what your role
is if you're as a partner, get it in writing... if you're as a hired
gun.. get it in writing... if you can't get anything in writing.. then make
sure you have your own copies of any/all code that you're created/been a
part of...

in this day/age, you need to protect yourself

and trust me, if your code is valuable, and you walk away with it because
you feel you've been treated in an unfair manner (assuimng no written
statement of your role), then let the other guy come after you... things get
resolved in a much more equitable manner when the concerned parties are
reasonably equal...

-bruce


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of tom
Sent: Saturday, June 11, 2005 9:51 AM
To: python-list@python.org
Subject: Re: Dealing with marketing types...


On Fri, 10 Jun 2005 21:57:40 -0700, fuzzylollipop wrote:

> I was completely serious, he is _NOT_ going to win this one. He has
> already lost. I have been on both sides of this scenario, the "new guys"
> were brought in and will win since they are the new "experts from out of
> town".

Not only do I take you seriously - I agree!

I also have been on both sides of this scenario although my take on it is
slightly different.  It's not so much the "experts from out of town" as it
is the tendency to dump the guy(s) that brought them to the party.

The sequence goes like this:
1) When there is little or no money to be made, you start out with an
implied status as a partner. This means you work long + extra hours for
little pay on the promise that you will be rewarded when/if success comes.

2) Then the product gets out the door and it's more long hours with little
pay.  Much massaging and tweaking and still little money incoming.

3) Success & money start to roll in. Now your status drops from partner to
hired hand. An overpaid hired hand at that.  Now that the heavy lifting is
done, managment is wondering whether they need to actually reward the
guy(s) who brought them to the party.  The rational parts of their brains
shut down while every fiber of their larcenous beings wants them to
believe they can now dispense with the high priced talent (you!) for some
low bucks commodity labor.  There scads of outsourcing firms tripping over
one another to sell them the latter.

> There may be some other _VALID_ business reason that management has
> already made up their mind to hire these Java people. Probably because
> they want to sell the company or merge with someone or something and
> having a Java product would make them more attractive.

Yes, there is a possible _VALID_ reason. That would be the perception,
probably accurate, that a technology like Java will shelter them from
total dependency on some individual developer (you!).  In other words,
there is a greater likelihood that they can find replacement talent should
they need it.  Thats the optimistic view.  More often it sinks to the
sleazy when they decide to stiff the original guys who did all the extra
work up front.  If they can replace them, there will be no need to "pay
off" on the extra work they did up front.

I have had this happen to me as an employee.  Later, as an outside
consultant, I was frequently disgusted to realize how many manager/owners
were merely seeking to avoid the payoff for the guys who went the extra
mile to give them a profitable product. Tis business in the USA, sad to
say.

> There are 2 things he can do.
>
> 1. Get your resume ready and approach the CEO or whomever and say. Why
> is this happening? Since I can guarantee you they have already decided
> to port this app to Java.

Resume ready is certainly wise and I concur with your gaurantee.

> 2. Be quiet, keep his head down, learn Java fatt, start agreeing
> with the new party line and get on the bandwagon if he really wants to
> stay at this company ( I wouldn't )

I disgree here.  The party line is nothing but a cover.  The goal is to
break the dependency on the guru(s) who did the developement or worse,
outright replacement.  The likelihood of staying on is slim and will
become increasingly unpleasant unless the employer is so lacking in
concience as to fire him outright.

Let me add an Item #3 -
If you have some entrepeneurial savvy and can keep your emotions out of
it tou can simply tell them you have decided strike out on your own and
tell them that you will be available. They will be happy to hear you are
leaving and happier still to hear you can be available for backup.
Their goals and fears are addressed at the same time.  AND there is a very
high possibility that they will *need* you at a later date for which you
can charge them dearly.

That last item #3 has actually worked for me with (2) prior employers.
I did have to eat my indignation and keep it friendly but it did pay off
in the end.
Thomas Bartkus


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

Re: Dealing with marketing types...

2005-06-11 Thread tom
On Fri, 10 Jun 2005 21:57:40 -0700, fuzzylollipop wrote:

> I was completely serious, he is _NOT_ going to win this one. He has
> already lost. I have been on both sides of this scenario, the "new guys"
> were brought in and will win since they are the new "experts from out of
> town".

Not only do I take you seriously - I agree!

I also have been on both sides of this scenario although my take on it is
slightly different.  It's not so much the "experts from out of town" as it
is the tendency to dump the guy(s) that brought them to the party.

The sequence goes like this:
1) When there is little or no money to be made, you start out with an
implied status as a partner. This means you work long + extra hours for
little pay on the promise that you will be rewarded when/if success comes.

2) Then the product gets out the door and it's more long hours with little
pay.  Much massaging and tweaking and still little money incoming.

3) Success & money start to roll in. Now your status drops from partner to
hired hand. An overpaid hired hand at that.  Now that the heavy lifting is
done, managment is wondering whether they need to actually reward the
guy(s) who brought them to the party.  The rational parts of their brains
shut down while every fiber of their larcenous beings wants them to
believe they can now dispense with the high priced talent (you!) for some
low bucks commodity labor.  There scads of outsourcing firms tripping over
one another to sell them the latter.

> There may be some other _VALID_ business reason that management has
> already made up their mind to hire these Java people. Probably because
> they want to sell the company or merge with someone or something and
> having a Java product would make them more attractive.

Yes, there is a possible _VALID_ reason. That would be the perception,
probably accurate, that a technology like Java will shelter them from
total dependency on some individual developer (you!).  In other words,
there is a greater likelihood that they can find replacement talent should
they need it.  Thats the optimistic view.  More often it sinks to the
sleazy when they decide to stiff the original guys who did all the extra
work up front.  If they can replace them, there will be no need to "pay
off" on the extra work they did up front.

I have had this happen to me as an employee.  Later, as an outside
consultant, I was frequently disgusted to realize how many manager/owners
were merely seeking to avoid the payoff for the guys who went the extra
mile to give them a profitable product. Tis business in the USA, sad to
say.

> There are 2 things he can do.
> 
> 1. Get your resume ready and approach the CEO or whomever and say. Why
> is this happening? Since I can guarantee you they have already decided
> to port this app to Java.

Resume ready is certainly wise and I concur with your gaurantee.

> 2. Be quiet, keep his head down, learn Java fatt, start agreeing
> with the new party line and get on the bandwagon if he really wants to
> stay at this company ( I wouldn't )

I disgree here.  The party line is nothing but a cover.  The goal is to
break the dependency on the guru(s) who did the developement or worse,
outright replacement.  The likelihood of staying on is slim and will
become increasingly unpleasant unless the employer is so lacking in
concience as to fire him outright.

Let me add an Item #3 -
If you have some entrepeneurial savvy and can keep your emotions out of
it tou can simply tell them you have decided strike out on your own and
tell them that you will be available. They will be happy to hear you are
leaving and happier still to hear you can be available for backup. 
Their goals and fears are addressed at the same time.  AND there is a very
high possibility that they will *need* you at a later date for which you
can charge them dearly.

That last item #3 has actually worked for me with (2) prior employers. 
I did have to eat my indignation and keep it friendly but it did pay off
in the end.
Thomas Bartkus


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


Re: case/switch statement?

2005-06-11 Thread deelan
Joe Stevenson wrote:
> Hi all,
> 
> I skimmed through the docs for Python, and I did not find anything like 
> a case or switch statement.  I assume there is one and that I just 
> missed it.  

strictly speaking, python does not
have a switch stamenent.

"Why isn't there a switch or case statement in Python?"


> Can someone please point me to the appropriate document, or 
> post an example?  I don't relish the idea especially long if-else 
> statements.

topic already beated to death, feel
free to browse the group archives:


HTH.

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Thomas Lotze
Peter Hansen wrote:

> Thomas Lotze wrote:
>> I can see two possibilities to do this: either the current file position
>> has to be read from somewhere (say, a mutable object passed to the
>> generator) after each yield, [...]
> 
> The third approach, which is certain to be cleanest for this situation, is
> to have a custom class which stores the state information you need, and
> have the generator simply be a method in that class.

Which is, as far as the generator code is concerned, basically the same as
passing a mutable object to a (possibly standalone) generator. The object
will likely be called self, and the value is stored in an attribute of it.

Probably this is indeed the best way as it doesn't require the programmer
to remember any side-effects.

It does, however, require a lot of attribute access, which does cost some
cycles.

A related problem is skipping whitespace. Sometimes you don't care about
whitespace tokens, sometimes you do. Using generators, you can either set
a state variable, say on the object the generator is an attribute of,
before each call that requires a deviation from the default, or you can
have a second generator for filtering the output of the first. Again, both
solutions are ugly (the second more so than the first). One uses
side-effects instead of passing parameters, which is what one really
wants, while the other is dumb and slow (filtering can be done without
taking a second look at things).

All of this makes me wonder whether more elaborate generator semantics
(maybe even allowing for passing arguments in the next() call) would not
be useful. And yes, I have read the recent postings on PEP 343 - sigh.

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


case/switch statement?

2005-06-11 Thread Joe Stevenson
Hi all,

I skimmed through the docs for Python, and I did not find anything like 
a case or switch statement.  I assume there is one and that I just 
missed it.  Can someone please point me to the appropriate document, or 
post an example?  I don't relish the idea especially long if-else 
statements.

Joe



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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread nephish
Ok, i made a change in the source. now here is the source from Opera,
still cant get firefox to work with me.


 Customer Data


Watkins Crop Consulting


1915 Cherokee 
Dalhart, Tx 79022333-5943
gandalf

Field field one


Crop crop one


GS growing, yep



Weeds many weeds


Water lots o water


Incects lots o insects



Remarks comment block, could be
short, could be long, however will we know?





Field another field


Crop another crop


GS another growth stage



Weeds many many weeds


Water lots more water


Incects lots more insects



Remarks ok , short comment this
time







maybe there is another place i have gakked up the source.

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


Re: Controlling a generator the pythonic way

2005-06-11 Thread Peter Hansen
Thomas Lotze wrote:
> I can see two possibilities to do this: either the current file position
> has to be read from somewhere (say, a mutable object passed to the
> generator) after each yield, or a new generator needs to be instantiated
> every time the tokenizer is pointed to a new file position.
>... 
> Does anybody here have a third way of dealing with this? Otherwise,
> which ugliness is the more pythonic one?

The third approach, which is certain to be cleanest for this situation, 
is to have a custom class which stores the state information you need, 
and have the generator simply be a method in that class.  There's no 
reason that a generator has to be a standalone function.

class PdfTokenizer:
 def __init__(self, ...):
 # set up initial state

 def getTokens(self):
 while whatever:
 yield token

 def seek(self, newPosition):
 # change state here

# usage:
pdf = PdfTokenizer('myfile.pdf', ...)
for token in pdf.getTokens():
 # do stuff...

 if I need to change position:
 pdf.seek(...)

Easy as pie! :-)

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


Re: Python Developers Handbook - Mistake done and corrected.

2005-06-11 Thread Maxwell Hammer
On Fri, 10 Jun 2005 04:52:12 -0700, wooks wrote:

> 
> Your understanding of Usenet is that a post has to "appeal" (for the
> want of a better word) to the majority of the NG readership.
> 
> Look over a hundred people took a look (and the hits are steadily
> going up whether despite or because of this thread). I am not going to
> posit either way as to whether that amounts to vindication  but it does
> suggsest that I have not comitted the heinous crime against netiquette
> that some people are making out.

Actually you're making a mistake there:
Maybe 100 people took a look at Wook's book, but a lot more than 100 people
were pissed off at yet another Commercial post.
Next time use the "announce" NG.

Always ask youself...so if 2 billion people did what I'm about to do,
will it make a big stink? Most times the answer is: a huge stink.

Cheers.

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


Re: Best Web dev language

2005-06-11 Thread D H
Jon Slaughter wrote:
> I'm trying to get into web development for creating a professional web site 
> and I'm confused on which language I should use.  I've read some comparisons 
> between the major languages and I was thinking that python might be the way 
> to go for the most powerful and general language but I am not sure.  Does 
> anyone know of any detailed and objective comparisons between the major 
> languages(perl, php, java, javascript, etc...) that might help me get a 
> clearer picture?

The one that is most popular and has by far the most open source example 
applications out there is PHP (plus MySQL for databases).  It's been 
that way for many years now.  It is also much cheaper and easier to find 
PHP/MySQL hosting.  Search sourceforge.net for many example PHP web 
applications.

I hope you realize that by posting your question on the Python newsgroup 
instead of a general web development newgroup, you're going to get 
extremely biased answers.  If you do go with Python, check out the 
mod_python module for the Apache web server.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dealing with marketing types...

2005-06-11 Thread Aahz
In article <[EMAIL PROTECTED]>,
flyingfred0  <[EMAIL PROTECTED]> wrote:
>
>A small software team (developers, leads and even the manager when he's 
>had time) has been using (wx)Python/PostgreSQL for over 2 years and 
>developed a successful 1.0 release of a client/server product.
>
>A marketing/product manager has brought in additional management and 
>"architecture" experts to propose moving the entire thing to a Java 
>(application server) platform for the next release.  They want a 
>"scalable, enterprise solution" (though they don't really know what that
>means) and are going crazy throwing around the Java buzzwords (not to 
>mention XML).

Point out that pushing this means they're almost certainly going to lose
at least some of their development team, which means the next release is
going to start from ground zero without the necessary expertise.  Even
if that doesn't happen, switching to Java is going to take much more time
than improving the current product:

http://www.JoelOnSoftware.com/articles/fog69.html
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Web dev language

2005-06-11 Thread Stefan Nobis
"Jon Slaughter" <[EMAIL PROTECTED]> writes:

> Does anyone know of any detailed and objective comparisons
> between the major languages(perl, php, java, javascript, etc...)
> that might help me get a clearer picture?

I don't know of any (really good) comparisions, but anyway here
are my opinion:

Don't look only at something someone calls "major language". The
not-so-well-known one may offer you quite some nice extras.

If you have to deal with medium to complex application give
continuation based approches (Seaside (Smalltalk), PLT/Scheme,
Cocoon (Java), UncommonWeb (Common Lisp) and others; to get an
idea look at http://lisp.tech.coop/Web/Continuation ).

What language do i seem interesting to look at for web
development? Hmmm... let's see (listing in random order):

- Common Lisp (my personal favorite)
- Scheme (PLT/Scheme, Bigloo,...)
- Scala (http://scala.epfl.ch/)
- Nice (http://nice.sourceforge.net/)
- Squeak (http://www.squeak.org/index.html)
- Python

Scala and Nice compiles to Java-Bytecode and you have access to
the complete Java-World (AFAIK there are such JVM-Compilers for
Common Lisp and some Scheme, too and there is JPython).

I don't like Perl syntax much, so it's not on the list, and PHP is
a rather chaotic language with (personal view!) at least a couple
of new security issues eacht month, so it's the worst choice one
can make (i think).

Hope that helps a little bit.

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


Re: Dealing with marketing types...

2005-06-11 Thread Drazen Gemic
On Fri, 10 Jun 2005 13:41:13 -0500, phil wrote:

> 
>> 
>> What experiences have those in the Python community had in these kinds 
>> of situations?
>> 
> Ive had lots of experience updating my resume and
> 
> developing software at home.  In Python.
> 
> Java is a clumsy kludge.  And the java environment has gone to hell.

I am a freelance developer and I prefer to do job in Java over anything
else. I love Python, and it is my favourite language, but there are some
problems.

With Java I depend very little on customers IT staff, sysadmins, etc. If
I need additional functionality in form library, extension, whatever, all
I need is to drop another JAR in, and that does it. 

With Python, the situation is different. Often, some kind of modules are 
required to be compiled, or packages installed. Generaly, I do not have 
sufficient
privileges on customers system to do that. IT personell might be willing
and capable to do that, and might be not. There could be some
inter-department politics and/or friction involved at customers side 
which may turn into serious obstacle. 

Thnks, but I stick with Java. And considering Jython in the future.

DG

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread Brian
Bingo, found it!  Notice that you accidentally close the document before 
displaying any information...


[EMAIL PROTECTED] wrote:

> 
>  Customer Data
> 
> 
> Watkins Crop Consulting
> 
> 


  Notice the  tag above.  There's the problem!

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread nephish
Well, i don't have an app that will automaticlly check a page for
errors,
unless bluefish will do it, i am not sure.

the page it is supposed to print out is a response to a form entry.

here is the source from Opera if one of you guys want to look at it.


 Customer Data


Watkins Crop Consulting


1915 Cherokee 
Dalhart, Tx 79022333-5943
gandalf

Field field one


Crop crop one


GS growing, yep



Weeds many weeds


Water lots o water


Incects lots o insects



Remarks comment block, could be
short, could be long, however will we know?





Field another field


Crop another crop


GS another growth stage



Weeds many many weeds


Water lots more water


Incects lots more insects



Remarks ok , short comment this
time







this is all generated by the cgi module of python and the script that
responds to the
form.

thanks.

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


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread Brian
Yes, I agree that it is best to check the HTML source code of the page 
that is being generated.  The server is obviously generating the code, 
but the difference here is how the two browsers are interpreting the 
HTML data.

Check the source code for the HTML document.  I bet the problem resides 
in the page itself.

Brian
---


[EMAIL PROTECTED] wrote:
> Hey there,
> i have a python cgi script that prints out html just fine in the Opera
> browser
> but doesnt print at all under FireFox.
> weird, eh?
> i am getting nothing in the apache logs about any error.
> perhaps its a firefox issue, but i doubt it.
> 
> any suggestions. simple script here..
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Developers Handbook

2005-06-11 Thread Aahz
In article <[EMAIL PROTECTED]>,
wooks <[EMAIL PROTECTED]> wrote:
>
>Thank you for the long lecture on netiquette which I didn't really
>need.

You obviously do need it given your improper quoting and attributions.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi script runs under Opera, but not firefox

2005-06-11 Thread James Carroll
Try  View Source under Firefox, you should see everything that you're
printing from your CGI on the server.  The server side CGI will do the
same thing no matter what browser is requesting the page.

Next, take that source and paste into into some app that will look for
problems like tags that aren't balanced (Dreamweaver is what I'd use.)

-Jim

On 11 Jun 2005 07:00:39 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hey there,
> i have a python cgi script that prints out html just fine in the Opera
> browser
> but doesnt print at all under FireFox.
> weird, eh?
> i am getting nothing in the apache logs about any error.
> perhaps its a firefox issue, but i doubt it.
> 
> any suggestions. simple script here..
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Controlling a generator the pythonic way

2005-06-11 Thread Thomas Lotze
Hi,

I'm trying to figure out what is the most pythonic way to interact with
a generator.

The task I'm trying to accomplish is writing a PDF tokenizer, and I want
to implement it as a Python generator. Suppose all the ugly details of
toknizing PDF can be handled (such as embedded streams of arbitrary
binary content). There remains one problem, though: In order to get
random file access, the tokenizer should not simply spit out a series of
tokens read from the file sequentially; it should rather be possible to
point it at places in the file at random.

I can see two possibilities to do this: either the current file position
has to be read from somewhere (say, a mutable object passed to the
generator) after each yield, or a new generator needs to be instantiated
every time the tokenizer is pointed to a new file position.

The first approach has both the disadvantage that the pointer value is
exposed and that due to the complex rules for hacking a PDF to tokens,
there will be a lot of yield statements in the generator code, which
would make for a lot of pointer assignments. This seems ugly to me.

The second approach is cleaner in that respect, but pointing the
tokenizer to some place has now the added semantics of creating a whole
new generator instance. The programmer using the tokenizer now needs to
remember to throw away any references to the generator each time the
pointer is reset, which is also ugly.

Does anybody here have a third way of dealing with this? Otherwise,
which ugliness is the more pythonic one?

Thanks a lot for any ideas.

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


cgi script runs under Opera, but not firefox

2005-06-11 Thread nephish
Hey there,
i have a python cgi script that prints out html just fine in the Opera
browser
but doesnt print at all under FireFox.
weird, eh?
i am getting nothing in the apache logs about any error.
perhaps its a firefox issue, but i doubt it.

any suggestions. simple script here..

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


Re: Sending mail from 'current user' in Python

2005-06-11 Thread Irmen de Jong
Grig Gheorghiu wrote:
> I use this function as a platform-independent way of finding out the
> current user name:
> 
> def get_username():
> if sys.platform == 'win32':
> return win32api.GetUserName()
> else:
> return getpass.getuser()
> 


[e:\]python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import getpass
 >>> getpass.getuser()
'idj'

So why bother with the win32api??

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


Re: Best Web dev language

2005-06-11 Thread Brian
Hi Jon,

Yes, there are a variety of tutorials on the Internet that can help you 
learning how to use Python with the web.  Two of the best ones you can 
get for free by clicking on the link below.


  1) http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/
  2) http://www.devshed.com/c/a/Python/Python-on-the-Web/


However, in order to understand the tutorials above, it is important to 
first have a basic understanding of the Python programming language. 
Python is not hard to learn, but it might take you a few hours to learn 
it, if you have not done so already.

  1) http://www.greenteapress.com/thinkpython/
  2) http://www.devshed.com/c/a/Python/


Hope this helps,
Brian :-)
---




Jon Slaughter wrote:
> I'm trying to get into web development for creating a professional web site 
> and I'm confused on which language I should use.  I've read some comparisons 
> between the major languages and I was thinking that python might be the way 
> to go for the most powerful and general language but I am not sure.  Does 
> anyone know of any detailed and objective comparisons between the major 
> languages(perl, php, java, javascript, etc...) that might help me get a 
> clearer picture?
> 
> I have some experience with C/C++ but it has been some time since I have 
> done any real programming... I'd prefer to use C++ style so I would no thave 
> to learn a new language completely.  I've also read that one can use C/C++ 
> to develop just as one would use any other language and I'm wondering if 
> this is advisable? (since it seems most web pages are done in perl, python, 
> or php?)
> 
> Also, can anyone recommend any book or web page that gives an introduction 
> to the method in which one programs web sites? I am not clear on who one, 
> for instance, would use C++ as the language for a web site except by using 
> it to create html... I'm not sure if basicaly all languages goal is creating 
> html dynamically or if there is more to do.  What I mean is that basicaly 
> one is using some other language to wrap the html code or possibly generate 
> it at run-time for dynamic results. (so all client based web interfaces are 
> really just html readers but all this "extra" stuff is used to make certain 
> things easier and dynamic(just as generating tables and forms and all that).
> 
> Thanks for any help,
> Jon 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Web dev language

2005-06-11 Thread Peter Hansen
Jon Slaughter wrote:
> I'm trying to get into web development for creating a professional web site 
> and I'm confused on which language I should use.  I've read some comparisons 
> between the major languages and I was thinking that python might be the way 
> to go for the most powerful and general language but I am not sure.  

If you are really interested in the "most powerful and general", then 
Python is one of only perhaps several options.  I wouldn't bother 
counting something like C++ in the mix, personally... I'd say doing web 
development with C++ would warrant a quick visit from those nice, young 
men in their clean, white coats.

Perhaps the following pages will be of some assistance, not directly in 
comparing Python with something else, but with giving the flavour (and, 
unfortunate or not, diversity!) of Python approaches:

http://www.fredshack.com/docs/pythonweb.html
http://www.boddie.org.uk/python/web_frameworks.html

Michelle Levesque has been comparing several of the most popular in a 
"bakeoff" at http://pyre.third-bit.com/pyweb/index.html .

 > Does
> anyone know of any detailed and objective comparisons between the major 
> languages(perl, php, java, javascript, etc...) that might help me get a 
> clearer picture?

No, sorry.  I can say, however, that if you want "general purpose" you 
do not want PHP.  In fact, if you're a real programmer you probably 
don't want PHP.  Perl... well, enough has been written about the 
unreadability of Perl code and the number of ways its arbitrariness can 
get you into trouble that I'm not going to waste time adding to it. 
Javascript shouldn't be considered a serious contender for the 
server-side stuff, though you will quite likely _require_ it for the 
client side stuff, so keep it in mind but try to minimize your use of it 
and postpone it as long as you can.  (It's not actually that bad a 
language in many ways, and even has a bit of the same flavour as Python 
from time to time, in its dynamic nature.)  Java?  Well, a large number 
of us here (me included) have spent a fair bit of time with Java and, 
well, we're here now.  (Really, Java is likely a much better candidate 
than C++ for many reasons.  If you are down to a choice of two to make, 
I suspect it will be between Java and Python, or perhaps Ruby thrown 
into the mix.)

> Also, can anyone recommend any book or web page that gives an introduction 
> to the method in which one programs web sites? I am not clear on who one, 
> for instance, would use C++ as the language for a web site except by using 
> it to create html... I'm not sure if basicaly all languages goal is creating 
> html dynamically or if there is more to do.  What I mean is that basicaly 
> one is using some other language to wrap the html code or possibly generate 
> it at run-time for dynamic results. (so all client based web interfaces are 
> really just html readers but all this "extra" stuff is used to make certain 
> things easier and dynamic(just as generating tables and forms and all that).

That's not a particular bad description.  You're really starting from 
scratch here, aren't you?   My advice, since you have such a long 
way to travel, is to use an "agile" approach and start with some small 
subset of your overall requirements, the most critical/valuable part, 
and pick any of the favourite Python frameworks and see how far you can 
get.  If you like the way it went, pick the next most valuable part and 
then do it.  (Keep these down to only a day or two of programming or 
you'll get bogged down.)  The "PyWebOff" page above is actually an 
excellent demonstration of the approach you should take, and it's 
already been done by someone else for three or four different frameworks!

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


Re: Is pyton for me?

2005-06-11 Thread Peter Hansen
Kirk Job Sluder wrote:
> I agree with this approach.  For me, there has to be a certain level of
> complexity before I reach for python as a tool.  

For me as well.  In my case, the key question is "is this bash script 
going to be longer than two lines?".  If it would be, the Python 
approach will be done faster and will be more maintainable, since I 
often don't look at those scripts again for months and would tend to 
forget any bash syntax that I've learned in the meantime.

:-)

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


Re: help with sending mail in Program

2005-06-11 Thread Tim Williams

- Original Message - 
From: "Ivan Shevanski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 11, 2005 3:32 AM
Subject: Re: help with sending mail in Program
>
> >>from smtplib import SMTP
> >
> >>def sendToMe(subject, body):
> >>   me = '"Kent Johnson" <[EMAIL PROTECTED]>'
> >>   send(me, me, subject, body)
> >>
> >>
> >>def send(frm, to, subject, body):
> >>   s = SMTP()
> >>#s.set_debuglevel(1)
> >>   s.connect('mail.mycompany.com')
> >>   s.ehlo('10.0.3.160') # IP address of my computer, I don't remember
>why I needed this
> >>
> >>   msg = '''From: %s
> >>Subject: %s
> >>To: %s
> >>
> >>%s
> >>''' % (frm, subject, to, body)
> >>
> >>   s.sendmail(frm, to, msg)
> >
> >
> > s.sendmail(frm, [to], msg)
> >
> >
> >>   s.quit()
> >>
> >>
> >>if __name__ == '__main__':
> >>   sendToMe('Testing', 'This is a test')

> >From: "Tim Williams" <[EMAIL PROTECTED]>
> >To: "Ivan Shevanski" <[EMAIL PROTECTED]>
> >Subject: Re: help with sending mail in Program
> >Date: Thu, 9 Jun 2005 22:48:38 +0100
> >
> >Hi Ivan,   did you have any luck with the email source I sent you ?
> >
> >The hotmail server would have been overly sensitive to "fake" emails,  if
> >you were using a different server your original code would probably work.
> >
> >HTH
> >
> >Tim
> >-

> Nope no luck. . .What server do you suggest I use? Yahoo doesnt have one,
> and I don't feel like downloading gmail. . .What do you think?
>
> -Ivan

Ivan,  the MIMEText module should create a properly constructed email from
your own text,try something like this (untested)


from email.MIMEText import MIMEText
from smtplib import SMTP

def sendToMe(subject, body):
   me = '"Kent Johnson" <[EMAIL PROTECTED]>'
  send(me, me, subject, body)

def send(frm, to, subject, body):
   s = SMTP()
   s.set_debuglevel(1)
   s.connect('mail.mycompany.com')
   s.ehlo('10.0.3.160')

msg = MIMEText(body)
msg['To'] = to #  '"Text Name" '
msg['Subject'] = subject
msg['From'] = frm # '"Kent Johnson" <[EMAIL PROTECTED]>'

to2 = to.split()[-1]  # = 
frm2 = frm.split()[-1]  # can use rsplit() in 2.4

s.sendmail(frm2, [to2], msg.as_string())
s.quit()

if __name__ == '__main__':
   sendToMe('Testing', 'This is a test')



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


Re: Hiding X windows

2005-06-11 Thread Jeff Epler
You may want to use a standalone program to do this.  "xwit" has the
ability to iconify a window which can be selected in a variety of ways.
http://hpux.connect.org.uk/hppd/hpux/X11/Misc/xwit-1.0/man.html

There's a direct Python interface to the X protocol in python-xlib.  You
could re-write the common function "Select_Window()" from dsimple.c in
the X source distribution.  One (old) copy is here:
http://ftp.rge.com/pub/X/X11R6.4/xc/programs/xwininfo/dsimple.c

Having done that, I'm not entirely sure how you proceed to hide the
window.  You might follow the directions in the ICCCM on how to iconify
or withdraw a window (http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4),
or you might follow the EWMH document
(http://standards.freedesktop.org/wm-spec/wm-spec-1.4.html#id2507242)

Jeff


pgp14degfeFns.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Hiding X windows

2005-06-11 Thread dirk dierickx
All,

I'm looking for a way to hide opened windows in X, these windows can be
using any widget-set so it will not target gtk, qt, motif, etc directly
(I know how to do it in gtk for example, but this will only work for gtk
apps ofcourse).

Just an easy way to select a certain window and hide it, is anything like
this possible?

thanks,
-- 
Don't let your mind wander -- it's too little to be let out alone.

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


Re: Any way to not create .pyc files?

2005-06-11 Thread Piet van Oostrum
> Terry Hancock <[EMAIL PROTECTED]> (TH) wrote:


>TH> It looks to me like Python just deleted a read-only file owned by
>TH> root in order to replace it with a new pyc file.  Can somebody
>TH> explain that to me?!  Isn't that supposed to be impossible?

If the directory is writable, you can delete a file and write a new one
with the same name. The permissions of the file itself are of no importance
in this case.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: If - Or statements

2005-06-11 Thread tiissa
Patrick Down wrote:
> What about:
> 
> if True in [thefile.endswith(x) for x in
> ('mp3','mp4','ogg','aac','wma')]:

That will catch (widely used) file names such as 'tmp3' or 
'i_cant_spell_frogg'. ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abstract and concrete syntax

2005-06-11 Thread Robert Kern
Terry Reedy wrote:

> Beauty is in the eye of the beholder.  It seems that relative pythonicity 
> sometimes is also ;-).

Ah, the curse of Pythonicity Relativism! What has society come to that 
it cannot recognize Absolute Pythonicness and Absolute Perlishness? The 
measure of Pythonicness was given to us in the inerrant Gospel of Tim! 
Every word of it is literally True! Incant the words "import this" and 
you shall see in glowing letters before you the Gospel of Tim. Count the 
number of verses For and the number Against. If the For verses outnumber 
the Against, the construct is Pythonic, absolutely and without 
equivocation for all people as Guido indented.

ask-me-how-to-calculate-the-age-of-the-universe-ly y'rs,
Acolyte Kern

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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