Re: Awkwardness of C API for making tuples

2005-02-03 Thread Fredrik Lundh
Steve Holden wrote:

>> in theory, if PyInt_FromLong succeeds, and PyTuple_SetItem fails, you'll leak
>> an object.
>
> And in practice this will only happen during a period when you are relying 
> critically on it *not* 
> to ...

yeah, but if PyTuple_SetItem fails in this case, you better move that
computer out of the radiation chamber.

 



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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Tim Daneliuk <[EMAIL PROTECTED]> writes:
> [other good stuff from Tim snipped]
> > Today I think most seeks can be eliminated by just using ram or SSD
> > (solid state disks) instead of rotating disks.  But yeah, you wouldn't
> > do that on a laptop.
> 
> But that still does not solve the latency problem of session
> establishment/ teardown over network fabric which is the Achilles
> Heel of the web and web services.

Well, HTTP 1.1 keepalives takes care of some of that, but really,
really, most of this problem is server side, like when you browse a
Wikipedia page it might take a few seconds, which isn't good, but when
you update it, it takes most of a minute, which is awful.  The
difference is that editing means server side web cache misses followed
by a database update that affects numerous indices.

Wikipedia keeps having these fundraising drives to buy more server CPU
iron (I've donated a few times) but I wonder if they'd be better off
spending it on solid state disks and/or software reorganization.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-03 Thread Fredrik Lundh
Markus Wankus wrote:

> Google his name - he has been banned from Netbeans and Eclipse (and 
> Hibernate, and others...) for 
> good reason.  Can you imagine how much of a Troll you need to be to 
> *actually* get "banned" from 
> the newsgroups of open source projects such as those?

have Pythoneers ever "banned" anyone from a public forum?  it's not like
we haven't seen trolls and crackpots before, you know.

 



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


Re: Possible additions to the standard library? (WAS: About standard library improvement)

2005-02-03 Thread Fredrik Lundh
Daniel Bickett wrote:

> [2] I'm currently unaware if _winreg is a c extension module or pure
> python, but I'm assuming it's C, so I don't know how possible it is to
> add pure python to it...

from the documentation:

This module exposes a very low-level interface to the Windows registry;
it is expected that in the future a new winreg module will be created
offering a higher-level interface to the registry API.

your DeleteKeyAll operation would fit nicely in such an interface, but I'm not
sure it belongs in the low-level interface, and a higher-level interface 
consisting
of just one helper would seem a bit odd.on the other hand, it's about time
someone wrote that "winreg" module... (hint).

 



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


Re: managing multiple subprocesses

2005-02-03 Thread Donn Cave
Quoth Skip Montanaro <[EMAIL PROTECTED]>:
| > "Marcos" == Marcos  <[EMAIL PROTECTED]> writes:
|
| Marcos> I have tried all sorts of popens / excevs / os.systems /
| Marcos> commands etc etc. 
|
| I think os.spawn* and os.wait will do what you want.  I have trouble with
| os.spawn* myself, so may just fall back to fork/exec + os.wait in the
| parent.

That's probably the ticket.  There are endless variations on how you
can use these functions (especially if you include pipe() and the dup
fcntls), and in a way it may be simpler to write your own variation
than work with a packaged one that does approximately what you need.
As long as it doesn't need to run on Windows.

By the way, I never ever use the *p versions of these functions, and
always specify the full path of the executable.  I don't use the the
C library versions, and I don't use the Python versions.  The latter
aren't actually C library function wrappers, but rather like I think
most shells they contrive to look through PATH themselves, and at any
rate it's difficult to deal with the lookup failure in a useful way
in the child fork.  No doubt there are situations where a path lookup
is essential, but it just hasn't been happening to me.

Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exporting mesh from image data

2005-02-03 Thread Fernando Perez
John Hunter wrote:

> 
> I am trying to generate a mesh for a finite volume solver (gambit,
> fluent) from 3D image data (CT, MRI).  To generate the fluent msh
> file, you need not only a list of vertices and polygons, much like
> what is available in the vtk file format, but also the volume elements
> in the mesh that the polygons abut.  Eg for a given triangle in the
> mesh, you would have a line like

[...]

I hope you posted this on the VTK list with a CC to Prabhu as well...  The hopes
of a positive reply there are, I suspect, a fair bit higher.  The scipy list
would be a good idea, too.

I don't have an answer, but I recall seeing something about a finite volume
solver implemented in python recently.  Interestingly, a quick googling on
those terms turned this up:

http://math.nist.gov/mcsd/Seminars/2005/2005-03-01-wheeler.html

Note the March 1 Boulder meeting :)  (the coordinated times suggest a
videoconference of sorts).

I'll most likely attend the talk, let me know if you still don't have a solution
by then and I can try to talk to Wheeler (if he's physically here instead of in
Gaithesburg).  For all we know, their code might provide an implementation,
have a look (I'd be quite interested in your opinion if you've already looked
at it).

Cheers,

f

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


Re: Computing class variable on demand?

2005-02-03 Thread fortepianissimo
Thank you so much about this useful tip! I learned the new decorator
feature of 2.4 simply because of your post.

Unfortunately I don't have luxury right now to run Python 2.4 (for what
I'm doing anyways). You mentioned the way to do decorator in 2.3. Still
I have a question here. Here is Scott David Daniels's code for lazy
initialization:

class Lazy (object):
def __init__ (self, calculate_function):
self._calculate = calculate_function

def __get__ (self, obj, _=None):
if obj is None:
return self
value = self._calculate(obj)
setattr(obj, self._calculate.func_name, value)
return value

The problem I run into using this for *instance* variables is: the
setattr() call won't work with a class with __slots__ defined - it
simply produces error that the attribute we want to modify is
read-only. Is there a workaround of this problem?

By the way this implementation is indeed better than the __getattr__
since in the latter I need to do a series of if... elif... else to
decide what to do with different attribute names. In the solution
above, I imagine the attribute names are hashed so it should have
better performance (the first time anyways).

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


Re: advice needed for simple python web app

2005-02-03 Thread Paul Rubin
"Dan Perl" <[EMAIL PROTECTED]> writes:
> This is exactly the kind of summary that I think should be in a
> WebProgrammingShootOut (see another one of my postings in this
> thread) but I failed to find such a summary.  Thanks, Brian!  Anyone
> can add to the list?

If you're just trying to get a conceptual understanding of web
programming, I suggest you start with cgi.

Next you might want to read Philip and Alex's Guide to Web Publishing:

  http://philip.greenspun.com/panda/

It's out of date and the examples use Tcl and Oracle instead of
Python, but it's still a good explanation of how database-driven web
sites work.  The rest (like languages frameworks) is just a matter of
picking some implementation parameters.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IPython colors in windows

2005-02-03 Thread Fernando Perez
Ashot wrote:

> I am using IPython in windows and the LightBG setting doesn't correctly
> because the background of the text is black even if the console background
> is white.  Anyone know whats going on?  Thanks.

It's quite possible that it's a bug in the UNC readline implementation proper. 
How do you set the background to white?  Is this something that can be done for
the normal winxp terminal, or do you use a different terminal emulator?

I'd like to have more detailed info before I contact the readline author.  He's
done a great job of providing ANSI-compliant color escape handling for the
piece of junk which MS ships as a terminal, but it's quite possible that he may
have missed something for the case of light backgrounds.

Regards,

f (ipython author)

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


Re: advice needed for simple python web app

2005-02-03 Thread Dan Perl

"Brian Beck" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> From my experience, this appears to be the order from low-level to 
> high-level interfaces:
>
> 1. mod_python: As complex as you need it to be, since you can control 
> anything about the request & response process. But more up-front work and 
> decisions to make than CherryPy.
> 2. mod_python with Vampire: Directs you toward a specific publishing 
> framework that is similar to CherryPy.
> 3. CherryPy: Like Vampire but simpler and doesn't require mod_python. The 
> simplest blend between low-level server interface and ease-of-publishing.
> 4. Twisted: Seems like this is a big package to work with, not sure how 
> easy it makes publishing once you get started-- better that someone else 
> comment on this.
> 5. Zope: The most complex solution, doesn't necessarily make the 'easy 
> things easy.' But covers all fronts in terms of what a user would ever 
> need.
> 6. Zope with Plone: Adds a ton of publishing functionality. Has many ways 
> to extend, but none of them are fun. You'll have to learn such complex 
> APIs that Python will rarely help you.

This is exactly the kind of summary that I think should be in a 
WebProgrammingShootOut (see another one of my postings in this thread) but I 
failed to find such a summary.  Thanks, Brian!  Anyone can add to the list?

BTW, there are other people who seem to have been also confused by the wide 
spectrum of choices for this problem: 
http://pyre.third-bit.com/hippoblog/archives/58.html 


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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Tim Daneliuk
Paul Rubin wrote:
Tim Daneliuk <[EMAIL PROTECTED]> writes:
I worked for an Airline computer reservation system (CRS) for almost a
decade. There is nothing about today's laptops that remotely comes close
to the power of those CRS systems, even the old ones. CRS systems are
optimized for extremely high performance I/O and use an operating system
(TPF) specifically designed for high-performance transaction processing.

Yeah, I've been interested for a while in learning a little bit about
how TPF worked.  Does Gray's book that you mention say much about it?
I honestly do not recall.  TPF/PAARS is an odd critter unto itself
that may not be covered by much of anything other than IBM docs.
I think that the raw hardware of today's laptops dwarfs the old big
iron.  An S/360 channel controller may have basically been a mainframe
in its own right, but even a mainframe in those days was just a few
MIPS.  The i/o systems and memory are lots faster too, though not by
nearly the ratio by which storage capacity and cpu speed have
increased.  E.g., a laptop disk these days has around 10 msec latency
and 20 MB/sec native transfer speed, vs 50+ msec and a few MB/sec for
a 3330-level drive (does that sound about right?.  
Again, I don't know.  The stuff we had was much newer (and faster) than
that.

Web servers are very sessions oriented: make a connection-pass the
unit of work-drop the connection. This is inherently slow (and not
how high performance TP is done). Moreover, really high perfomance
requires a very fine level of I/O tuning on the server - at the CRS
I worked for, they performance people actually only populated part
of the hard drives to minimize head seeks.

Today I think most seeks can be eliminated by just using ram or SSD
(solid state disks) instead of rotating disks.  But yeah, you wouldn't
do that on a laptop.
But that still does not solve the latency problem of session establishment/
teardown over network fabric which is the Achilles Heel of
the web and web services.

For a good overview of TP design, see Jim Gray's book, "Transaction
Processing: Concepts and Techniques".

Thanks, I'll look for this book.  Gray of course is one of the
all-time database gurus and that book is probably something every
serious nerd should read.  I've probably been a bad boy just for
having not gotten around to it years ago.

P.S. AFAIK the first CRS systems of any note came into being in the 1970s not
 the 1960s, but I may be incorrect in the matter.

From :
The system [SABRE] was created by American Airlines and IBM in the
1950s, after AA president C. R. Smith sat next to an IBM sales
representative on a transcontinental flight in 1953. Sabre's first
mainframe in Briarcliff Manor, New York went online in 1960. By
1964, Sabre was the largest private data processing system in the
world. Its mainframe was moved to an underground location in
Tulsa, Oklahoma in 1972.
Originally used only by American, the system was expanded to travel
agents in 1976. It is currently used by a number of companies,
including Eurostar, SNCF, and US Airways. The Travelocity website is
owned by Sabre and serves as a consumer interface to the system.
I stand (sit) corrected ;)
--

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: advice needed for simple python web app

2005-02-03 Thread Paul Rubin
"Dan Perl" <[EMAIL PROTECTED]> writes:
> > Be careful of exposing that script to the internet.  Spammers will
> > exploit it.
> 
> Do you mean publishing the script for other people to copy it or exposing 
> the web app so that other people may access it?

I mean installing the script on a server where spammers can run it and
stick you with the blame for people getting unwanted mail.  There used
to be some similar perl scripts running all over the place until that 
happened.

> Don't worry anyway, I won't do either and I'm running 2 firewalls on
> my PC.  It would be really naive to expose the web app, wouldn't it?

Well, you should have some kind of user authentication if you expose
it, and you should read up a bit about security for web apps.  Python
is actually not such a great language for this, but you certainly get
more readable code than you would with perl.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advice needed for simple python web app

2005-02-03 Thread Dan Perl

"Michele Simionato" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Dan Perl:
>> The application is just something I'm playing with to learn a little
> bit on
>> web apps.  It uses an HTML form to send an email.  The form takes
> inputs
>> like the From:, To: and Subject: fields and a text field.
>
> It is difficult to beat CGI + CGIHTTPServer for conceptual simplificity
> and easy of use: however, Quixote comes close and it has a *much*
> better support for forms.

So Quixote is another framework I will have to look into.  Best of all, 
though, after adding Quixote to the list I decided I have enough words to do 
a search.  There were a few interesting finds, but one single link that 
points to the best of them is: 
http://www.python.org/moin/WebProgrammingShootOut 


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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Jeremy Bowers
On Thu, 03 Feb 2005 20:50:16 -0800, Paul Rubin wrote:
> I understood the Twisted suggestion as meaning avoiding database
> traffic by keeping both user and server state resident in the
> application.  Yes, if you use a database for that, you get multiple
> app servers instead of a heavily loaded centralized one.  But you now
> have a heavily loaded centralized database server instead.  You
> haven't really solved your scaling problem, you've just moved it back
> a layer.

True, but my understanding is that there are load balancing solutions for
database servers too, so in this case moving the problem back one level
actually can be progress.

But I have no experience with this, so I have no idea how well it works.

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


Re: advice needed for simple python web app

2005-02-03 Thread Brian Beck
Dan Perl wrote:
Basically, what I'm looking for is a web server that accepts an HTTP request 
and invokes a python script.  But I would like a "pythonic" solution so a 
web server like Apache is a solution that I would like to avoid.  The server 
should also be as simple as possible to administrate.
As M.E.Farmer suggested, CherryPy is definitely what you are looking 
for. I have done a bit of shopping around and this is pretty much as 
straightforward as you can get.

From my experience, this appears to be the order from low-level to 
high-level interfaces:

1. mod_python: As complex as you need it to be, since you can control 
anything about the request & response process. But more up-front work 
and decisions to make than CherryPy.
2. mod_python with Vampire: Directs you toward a specific publishing 
framework that is similar to CherryPy.
3. CherryPy: Like Vampire but simpler and doesn't require mod_python. 
The simplest blend between low-level server interface and 
ease-of-publishing.
4. Twisted: Seems like this is a big package to work with, not sure how 
easy it makes publishing once you get started-- better that someone else 
comment on this.
5. Zope: The most complex solution, doesn't necessarily make the 'easy 
things easy.' But covers all fronts in terms of what a user would ever need.
6. Zope with Plone: Adds a ton of publishing functionality. Has many 
ways to extend, but none of them are fun. You'll have to learn such 
complex APIs that Python will rarely help you.

Of course there are more, like Webware, but you didn't mention that and 
I don't have experience with it.

--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


Re: advice needed for simple python web app

2005-02-03 Thread Dan Perl

"Paul Rubin"  wrote in message 
news:[EMAIL PROTECTED]
> "Dan Perl" <[EMAIL PROTECTED]> writes:
>> The application is just something I'm playing with to learn a little bit 
>> on
>> web apps.  It uses an HTML form to send an email.  The form takes inputs
>> like the From:, To: and Subject: fields and a text field.
>
> Be careful of exposing that script to the internet.  Spammers will
> exploit it.

Do you mean publishing the script for other people to copy it or exposing 
the web app so that other people may access it?  Don't worry anyway, I won't 
do either and I'm running 2 firewalls on my PC.  It would be really naive to 
expose the web app, wouldn't it? 


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


Re: Printing Filenames with non-Ascii-Characters

2005-02-03 Thread vincent wehren
Marian Aldenhövel wrote:
Hi,
 > Python's drive towards uncompromising explicitness pays off
big time when you're dealing with multilingual data.

Except for the very implicit choice of 'ascii' as an encoding when
it cannot make a good guess of course :-).
Since 'ascii' is a legal subset Unicode and of most prevailing 
encodings, this is the only sensible thing to do. It is outside of the 
ascii range where characters become ambigious and need additional 
interpretation. Where other languages might ignore the problem at hand 
and send garbled data or replace characters to the output, Python at 
least let's you respond to conversion problems/errors.

All in all I agree, however.
That's good to hear ;)
--
Vincent Wehren

Ciao, MM
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
aurora <[EMAIL PROTECTED]> writes:
> I'm lost. So what do you compares against when you said LAMP is slow?
> What  is the reference point? Is it just a general observation that
> slashdot is  slower than we like it to be?

Yes, that's the basic observation, not specifically Slashdot but for
lots of LAMP sites (some PHPBB sites are other examples) have the same
behavior.  You send a url and the server has to grind for quite a
while coming up with the page, even though it's pretty obvious what
kinds of dynamic stuff it needs to find.  Just taking a naive approach
with no databases but just doing everything with in-memory structures
(better not ever crash!) would make me expect a radically faster site.
For a site like Slashdot, which gets maybe 10 MB of comments a day,
keeping them all in RAM isn't excessive.  (You'd also dump them
serially to a log file, no seeking or index overhead as this happened.
On server restart you'd just read the log file back into ram).

> If you mean MySQL or SQL database in general is slow, there are truth
> in  it. The best thing about SQL database is concurrent access,
> transactional  semantics and versatile querying. Turns out a lot of
> application can  really live without that. If you can rearchitect the
> application using  flat files instead of database it can often be a
> big bloom.

This is the kind of answer I had in mind.

> A lot of these is just implementation. Find the right tool and the
> right design for the job. I still don't see a case that LAMP based
> solution is inherently slow.

I don't mean LAMP is inherently slow, I just mean that a lot of
existing LAMP sites are observably slow.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
"M.E.Farmer" <[EMAIL PROTECTED]> writes:
> To emulate a table you use the div and span tag.
> (really you can do just about anything with div and span)

Hmm, that's pretty interesting, I didn't realize you could specify
width's with CSS.  Thanks.  http://glish.com/css/9.asp shows a
2-column example.

I don't know that the browser necessarily renders that faster than it
renders a table, but there's surely less crap in the HTML, which is
always good.  I may start using that method.

I remember seeing something a long time ago where someone used normal
html tags to create something like tab stops, so he could just place
things where he wanted them without the browser having to read the
whole page to automatically size the columns.  But I haven't been able
to figure out what tags he used for that, and don't remember where I
saw it.

As you can probably tell, I'm ok with basic HTML but am no wizard.
I'm more interested in backend implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread aurora
aurora <[EMAIL PROTECTED]> writes:
Slow compares to what? For a large commerical site with bigger budget,
better infrastructure, better implementation, it is not surprising
that  they come out ahead compares to hobbyist sites.
Hmm, as mentioned, I'm not sure what the commercial sites do that's
different.  I take the view that the free software world is capable of
anything that the commercial world is capable of, so I'm not awed just
because a site is commercial.  And sites like Slashdot have pretty big
budgets by hobbyist standards.
Putting implementation aside, is LAMP inherently performing worst than
commerical alternatives like IIS, ColdFusion, Sun ONE or DB2? Sounds
like  that's your perposition.
I wouldn't say that.  I don't think Apache is a bottleneck compared
with other web servers.  Similarly I don't see an inherent reason for
Python (or whatever) to be seriously slower than Java servlets.  I
have heard that MySQL doesn't handle concurrent updates nearly as well
as DB2 or Oracle, or for that matter PostgreSQL, so I wonder if busier
LAMP sites might benefit from switching to PostgreSQL (LAMP => LAPP?).
I'm lost. So what do you compares against when you said LAMP is slow? What  
is the reference point? Is it just a general observation that slashdot is  
slower than we like it to be?

If you are talking about slashdot, there are many ideas to make it faster.  
For example they can send all 600 comments to the client and let the user  
do querying using DHTML on the client side. This leave the server serving  
mostly static files and will certainly boost the performance tremendously.

If you mean MySQL or SQL database in general is slow, there are truth in  
it. The best thing about SQL database is concurrent access, transactional  
semantics and versatile querying. Turns out a lot of application can  
really live without that. If you can rearchitect the application using  
flat files instead of database it can often be a big bloom.

A lot of these is just implementation. Find the right tool and the right  
design for the job. I still don't see a case that LAMP based solution is  
inherently slow.
--
http://mail.python.org/mailman/listinfo/python-list


Re: advice needed for simple python web app

2005-02-03 Thread Paul Rubin
"Dan Perl" <[EMAIL PROTECTED]> writes:
> The application is just something I'm playing with to learn a little bit on 
> web apps.  It uses an HTML form to send an email.  The form takes inputs 
> like the From:, To: and Subject: fields and a text field.

Be careful of exposing that script to the internet.  Spammers will
exploit it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advice needed for simple python web app

2005-02-03 Thread Michele Simionato
Dan Perl:
> The application is just something I'm playing with to learn a little
bit on
> web apps.  It uses an HTML form to send an email.  The form takes
inputs
> like the From:, To: and Subject: fields and a text field.

It is difficult to beat CGI + CGIHTTPServer for conceptual simplificity
and easy of use: however, Quixote comes close and it has a *much*
better support for forms. Here is an
example from the minidemo in the distribution, so you have an idea of
how the code looks
like:

> from quixote.publish import Publisher
> from quixote.directory import Directory

> class RootDirectory(Directory):

>_q_exports = ['', 'hello']

>def _q_index(self):
>return '''
>Welcome to the Quixote demo.  Here is a
>link.
>
>  
>'''

>def hello(self):
>return 'Hello world!'


> def create_publisher():
>return Publisher(RootDirectory(),
> display_exceptions='plain')


> if __name__ == '__main__':
>from quixote.server.simple_server import run
>print 'creating demo listening on http://localhost:8080/'
>run(create_publisher, host='localhost', port=8080)

The exported methods of your directory class corresponds to Web pages;
_q_index
returns the main page, hello an hello word page. This works out of the
box with
no configuration at all, you don't need to create a cgi-bin directory,
nothing.
It is trivial to replace simple_server with a more serious server
(twisted_server,
scgi_server, etc. )

Notice: this example works in Quixote 2.0 which is currently in alpha.
Don't let
the "alpha" scares you: that means that the documentation is still a
bit rough and
few things are not fully settled down, but the framework is very much
usable.


  Michele Simionato

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


Re: advice needed for simple python web app

2005-02-03 Thread Dan Perl

"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I am no web expert but have recently used cherrypy to 'webify' a
> script. It is very easy to get going and has its own server or can be
> run behind Apache.
> The only real problem I see is that the docs are still a little lite
> for the new 2.0 series ,but they do have a newsgroup where the author
> still answers questions.
> Cherrypy2 is fairly logical and most of it is covered in the examples
> on there website.
> I can not speak for the other packages,have not used them yet ;)
> hth,
> M.E.Farmer

Thanks.  I am no web expert either so I appreciate advice coming from 
someone who was in a similar situation.

Twisted and CherryPy seemed to me to be the main choices based on what I 
understand from their front pages with my limited knowledge on web apps. 
Twisted feels more "developed" but also more complex at the same time.  I 
wanted opinions before I invest the time in studying either one of them. 
Your opinion helps.

Dan 


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


Re: advice needed for simple python web app

2005-02-03 Thread Dan Perl

"Paul Rubin"  wrote in message 
news:[EMAIL PROTECTED]
> "Dan Perl" <[EMAIL PROTECTED]> writes:
>> Basically, what I'm looking for is a web server that accepts an HTTP
>> request and invokes a python script.  But I would like a "pythonic"
>> solution so a web server like Apache is a solution that I would like
>> to avoid.  The server should also be as simple as possible to
>> administrate.
>
> CGI and CGIHTTPServer (or whatever it's called) is conceptually the
>> simplest.  What does your app do?

The application is just something I'm playing with to learn a little bit on 
web apps.  It uses an HTML form to send an email.  The form takes inputs 
like the From:, To: and Subject: fields and a text field.

I found the "Internet Protocols and Support" chapter in the Library 
Reference that covers also the CGIHTTPServer.  It's definitely something I 
will have to read.  Thanks.

Dan 


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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
Paul Rubin wrote:
> Yes, good point about html tables, though I'm concerned primarily
> about server response.  (It's off-topic, but how do you use CSS to
get
> the effect of tables?)
To emulate a table you use the div and span tag.
(really you can do just about anything with div and span)
Div is a block level tag and span isn't.
You can also group them  together and nest them.
div and span have little meaning but the can be styled.
In the CSS declaration we create styles and then just use them later as
needed.
Try to always focus on layout first and actual style later. (CSS is all
about seperation of concerns)
You will find the verbosity of CSS is not as annoying as you might
think it might be, it is quite easy to learn and well worth the effort.
Ok here is a bad example ( do a search on Google for CSS tables ).
( this was torn out of a webapp I am working on )
.
.  
.Archive
.Entry Date
.
.  
.  
.%s
.%s
.%s
.  
.  
.        posted by: %s
.
.text 
. %s
.
.  
.
And here is some of the CSS
( these are classes the dot in front of the name tells you that, when
combined with div or span just about anything is possible. )
.  .panel {
.border: solid thin #77;
.margin: 2em 4em 2em 4em;}
.  .leftspaces {
.letter-spacing:.5em;
.text-decoration:none;
.color:#ff;}
.  .rightspaces {
.letter-spacing:.5em;
.position: absolute;
.right: 5em;
.text-decoration: none;
.color:#ff;}
.
.  .archivehead {
. text-indent:.5em;
. background-color:#33;}
.  .archivelite {
. color:#77;
. text-indent:.5em;
. background-color:#22;}
.  .archivedark {
. color:#77; text-indent:.5em;
. background-color:#11;}
.  .archivelite a{
. color:#DD;
. text-decortation:none;
. background-color:#22;}
.  .archivedark a{
. color:#DD;
. text-decortation:none;
. background-color:#11;}
hth,
M.E.Farmer

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
Paul Rubin wrote:
> Yes, good point about html tables, though I'm concerned primarily
> about server response.  (It's off-topic, but how do you use CSS to
get
> the effect of tables?)
To emulate a table you use the div and span tag.
(really you can do just about anything with div and span)
Div is a block level tag and span isn't.
You can also group them  together and nest them.
div and span have little meaning but the can be styled.
In the CSS declaration we create styles and then just use them later as
needed.
Try to always focus on layout first and actual style later. (CSS is all
about seperation of concerns)
You will find the verbosity of CSS is not as annoying as you might
think it might be, it is quite easy to learn and well worth the effort.
Ok here is a bad example ( do a search on Google for CSS tables ).
( this was torn out of a webapp I am working on )
.
.  
.Archive
.Entry Date
.
.  
.  
.%s
.%s
.%s
.  
.  
.        posted by: %s
.
.text 
. %s
.
.  
.
And here is some of the CSS
( these are classes the dot in front of the name tells you that, when
combined with div or span just about anything is possible. )
.  .panel {
.border: solid thin #77;
.margin: 2em 4em 2em 4em;}
.  .leftspaces {
.letter-spacing:.5em;
.text-decoration:none;
.color:#ff;}
.  .rightspaces {
.letter-spacing:.5em;
.position: absolute;
.right: 5em;
.text-decoration: none;
.color:#ff;}
.
.  .archivehead {
. text-indent:.5em;
. background-color:#33;}
.  .archivelite {
. color:#77;
. text-indent:.5em;
. background-color:#22;}
.  .archivedark {
. color:#77; text-indent:.5em;
. background-color:#11;}
.  .archivelite a{
. color:#DD;
. text-decortation:none;
. background-color:#22;}
.  .archivedark a{
. color:#DD;
. text-decortation:none;
. background-color:#11;}
hth,
M.E.Farmer

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
Paul Rubin wrote:
> Yes, good point about html tables, though I'm concerned primarily
> about server response.  (It's off-topic, but how do you use CSS to
get
> the effect of tables?)
To emulate a table you use the div and span tag.
(really you can do just about anything with div and span)
Div is a block level tag and span isn't.
You can also group them  together and nest them.
div and span have little meaning but the can be styled.
In the CSS declaration we create styles and then just use them later as
needed.
Try to always focus on layout first and actual style later. (CSS is all
about seperation of concerns)
You will find the verbosity of CSS is not as annoying as you might
think it might be, it is quite easy to learn and well worth the effort.
Ok here is a bad example ( do a search on Google for CSS tables ).
( this was torn out of a webapp I am working on )
.
.  
.Archive
.Entry Date
.
.  
.  
.%s
.%s
.%s
.  
.  
.        posted by: %s
.
.text 
. %s
.
.  
.
And here is some of the CSS
( these are classes the dot in front of the name tells you that, when
combined with div or span just about anything is possible. )
.  .panel {
.border: solid thin #77;
.margin: 2em 4em 2em 4em;}
.  .leftspaces {
.letter-spacing:.5em;
.text-decoration:none;
.color:#ff;}
.  .rightspaces {
.letter-spacing:.5em;
.position: absolute;
.right: 5em;
.text-decoration: none;
.color:#ff;}
.
.  .archivehead {
. text-indent:.5em;
. background-color:#33;}
.  .archivelite {
. color:#77;
. text-indent:.5em;
. background-color:#22;}
.  .archivedark {
. color:#77; text-indent:.5em;
. background-color:#11;}
.  .archivelite a{
. color:#DD;
. text-decortation:none;
. background-color:#22;}
.  .archivedark a{
. color:#DD;
. text-decortation:none;
. background-color:#11;}
hth,
M.E.Farmer

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread M.E.Farmer
Paul Rubin wrote:
> Yes, good point about html tables, though I'm concerned primarily
> about server response.  (It's off-topic, but how do you use CSS to
get
> the effect of tables?)
To emulate a table you use the div and span tag.
(really you can do just about anything with div and span)
Div is a block level tag and span isn't.
You can also group them  together and nest them.
div and span have little meaning but the can be styled.
In the CSS declaration we create styles and then just use them later as
needed.
Try to always focus on layout first and actual style later. (CSS is all
about seperation of concerns)
You will find the verbosity of CSS is not as annoying as you might
think it might be, it is quite easy to learn and well worth the effort.
Ok here is a bad example ( do a search on Google for CSS tables ).
( this was torn out of a webapp I am working on )
.
.  
.Archive
.Entry Date
.
.  
.  
.%s
.%s
.%s
.  
.  
.        posted by: %s
.
.text 
. %s
.
.  
.
And here is some of the CSS
( these are classes the dot in front of the name tells you that, when
combined with div or span just about anything is possible. )
.  .panel {
.border: solid thin #77;
.margin: 2em 4em 2em 4em;}
.  .leftspaces {
.letter-spacing:.5em;
.text-decoration:none;
.color:#ff;}
.  .rightspaces {
.letter-spacing:.5em;
.position: absolute;
.right: 5em;
.text-decoration: none;
.color:#ff;}
.
.  .archivehead {
. text-indent:.5em;
. background-color:#33;}
.  .archivelite {
. color:#77;
. text-indent:.5em;
. background-color:#22;}
.  .archivedark {
. color:#77; text-indent:.5em;
. background-color:#11;}
.  .archivelite a{
. color:#DD;
. text-decortation:none;
. background-color:#22;}
.  .archivedark a{
. color:#DD;
. text-decortation:none;
. background-color:#11;}
hth,
M.E.Farmer

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Jeremy Bowers <[EMAIL PROTECTED]> writes:
> > Hmm, I'm not familiar with Nevow.  Twisted is pretty neat, though
> > confusing.  I don't see how to scale it to multiple servers though.
> 
> Same way you'd scale any webserver, load balancing in hardware, store all
> user state in a database, and tell the load balancer to try to "persist"
> a user's connection to a machine, so Twisted doesn't even have to go back
> to the server then?

I understood the Twisted suggestion as meaning avoiding database
traffic by keeping both user and server state resident in the
application.  Yes, if you use a database for that, you get multiple
app servers instead of a heavily loaded centralized one.  But you now
have a heavily loaded centralized database server instead.  You
haven't really solved your scaling problem, you've just moved it back
a layer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where are list methods documented?

2005-02-03 Thread Terry Reedy

"Nelson Minar" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> You're not the only one with a hard time finding the list
> documentation. It's even crazier for string docs.

To repeat the advice I gave someone asking about dict methods:

Read or at least skim thru chapter 2 of the Library Reference Manual on 
builtin functions and types so you have a general idea of what is where. 
And either before or after, look at the table of contents for general 
organization and index availability

Terry J. Reedy



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


Re: advice needed for simple python web app

2005-02-03 Thread Paul Rubin
"Dan Perl" <[EMAIL PROTECTED]> writes:
> Basically, what I'm looking for is a web server that accepts an HTTP
> request and invokes a python script.  But I would like a "pythonic"
> solution so a web server like Apache is a solution that I would like
> to avoid.  The server should also be as simple as possible to
> administrate.

CGI and CGIHTTPServer (or whatever it's called) is conceptually the
> simplest.  What does your app do?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Skip Montanaro <[EMAIL PROTECTED]> writes:
> It's more than a bit unfair to compare Wikipedia with Ebay or
> Google.  Even though Wikipedia may be running on high-performance
> hardware, it's unlikely that they have anything like the underlying
> network structure (replication, connection speed, etc), total number
> of cpus or monetary resources to throw at the problem that both Ebay
> and Google have.  I suspect money trumps LAMP every time.

I certainly agree about the money and hardware resource comparison,
which is why I thought the comparison with 1960's mainframes was
possibly more interesting.  You could not get anywhere near the
performance of today's servers back then, no matter how much money you
spent.  Re connectivity, I wonder what kind of network speed is
available to sites like Ebay that's not available to Jane Webmaster
with a colo rack at some random big ISP.  Also, you and Tim Danieliuk
both mentioned caching in the network (e.g. Akamai).  I'd be
interested to know exactly how that works and how much difference it
makes.

But the problems I'm thinking of are really obviously with the server
itself.  This is clear when you try to load a page and your browser
immediately get the static text on the page, followed by a pause while
the server waits for the dynamic stuff to come back from the database.
Serving a Slashdotting-level load of pure static pages on a small box
with Apache isn't too terrible ("Slashdotting" = the spike in hits
that a web site gets when Slashdot's front page links to it).  Doing
that with dynamic pages seems to be much harder.  Something is just
bugging me about this.  SQL servers provide a lot of capability (ACID
for complicated queries and transactions, etc). that most web sites
don't really need.  They pay the price in performance anyway.

> We also know Google has thousands of CPUs (I heard 5,000 at one point and
> that was a couple years ago).

It's at least 100,000 and probably several times that ;-).  I've heard
every that search query does billions of cpu operations and crunches
through 100's of megabytes of data (search on "apple banana" and there
are hundreds of millions of pages with each word, so two lists of that
size must be intersected).  100,000 was the published number of
servers several years ago, and there were reasons to believe that they
were purposely understating the real number.
-- 
http://mail.python.org/mailman/listinfo/python-list


Weekly Python Patch/Bug Summary

2005-02-03 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  284 open ( +4) /  2748 closed ( +1) /  3032 total ( +5)
Bugs:  804 open ( +1) /  4812 closed (+13) /  5616 total (+14)
RFE :  167 open ( +0) /   142 closed ( +1) /   309 total ( +1)

New / Reopened Patches
__

Patch for Lib/bsddb/__init__.py to work with modulefinder  (2005-01-31)
   http://python.org/sf/1112812  opened by  Tony Meyer

New tutorial tests in test_generators.py  (2005-01-31)
   http://python.org/sf/1113421  opened by  Francis Girard

Add SSL certificate validation  (2005-02-01)
   http://python.org/sf/1114345  opened by  James Eagan

support PY_LONGLONG in structmember  (2005-02-02)
   http://python.org/sf/1115086  opened by  Sam Rushing

Add SSL certificate validation  (2005-02-03)
   http://python.org/sf/1115631  opened by  James Eagan

Patches Closed
__

Make history recall a-cyclic  (2004-03-11)
   http://python.org/sf/914546  closed by  kbk

New / Reopened Bugs
___

Cannot ./configure on FC3 with gcc 3.4.2  (2005-01-26)
CLOSED http://python.org/sf/1110007  reopened by  liturgist

cgi.FieldStorage memory usage can spike in line-oriented ops  (2005-01-30)
   http://python.org/sf/1112549  opened by  Chris McDonough

patch 1079734 broke cgi.FieldStorage w/ multipart post req.  (2005-01-31)
   http://python.org/sf/1112856  opened by  Irmen de Jong

ioctl has problems on 64 bit machines  (2005-01-31)
   http://python.org/sf/1112949  opened by  Stephen Norris

move_file()'s return value when dry_run=1 unclear  (2005-01-31)
   http://python.org/sf/1112955  opened by  Eelis

Please add do-while guard to Py_DECREF etc.  (2005-01-31)
   http://python.org/sf/1113244  opened by  Richard Kettlewell

OSATerminology still semi-broken  (2005-01-31)
   http://python.org/sf/1113328  opened by  has

document {m} regex matcher wrt empty matches  (2005-01-31)
   http://python.org/sf/1113484  opened by  Wummel

keywords in keyword_arguments not possible  (2005-02-01)
CLOSED http://python.org/sf/1113984  opened by  Christoph Zwerschke

inicode.decode  (2005-02-01)
CLOSED http://python.org/sf/1114093  opened by  Manlio Perillo

copy.py bug  (2005-02-02)
   http://python.org/sf/1114776  opened by  Vincenzo Di Somma

webbrowser doesn't start default Gnome browser by default  (2005-02-02)
   http://python.org/sf/1114929  opened by  Jeremy Sanders

eval !  (2005-02-02)
CLOSED http://python.org/sf/1115039  opened by  Andrew Collier

Built-in compile function with PEP 0263 encoding bug  (2005-02-03)
   http://python.org/sf/1115379  opened by  Christoph Zwerschke

os.path.splitext don't handle unix hidden file correctly  (2005-02-04)
   http://python.org/sf/1115886  opened by  Jeong-Min Lee

Bugs Closed
___

broken link in tkinter docs  (2005-01-24)
   http://python.org/sf/1108490  closed by  jlgijsbers

recursion core dumps  (2005-01-26)
   http://python.org/sf/1110055  closed by  tim_one

install_lib fails under Python 2.1  (2004-11-02)
   http://python.org/sf/1058960  closed by  loewis

Double __init__.py executing  (2004-06-22)
   http://python.org/sf/977250  closed by  loewis

Cannot ./configure on FC3 with gcc 3.4.2  (2005-01-26)
   http://python.org/sf/1110007  closed by  liturgist

IDLE hangs due to subprocess  (2004-12-28)
   http://python.org/sf/1092225  closed by  kbk

Empty curses module is loaded in win32  (2004-07-12)
   http://python.org/sf/989333  closed by  tebeka

Tab / Space Configuration Does Not Work in IDLE  (2003-08-05)
   http://python.org/sf/783887  closed by  kbk

Negative numbers to os.read() cause segfault  (2004-12-01)
   http://python.org/sf/1077106  closed by  mwh

Time module missing from latest module index  (2005-01-25)
   http://python.org/sf/1109523  closed by  montanaro

keywords in keyword_arguments not possible  (2005-02-01)
   http://python.org/sf/1113984  closed by  rhettinger

unicode.decode  (2005-02-01)
   http://python.org/sf/1114093  closed by  lemburg

eval !  (2005-02-02)
   http://python.org/sf/1115039  closed by  rhettinger

New / Reopened RFE
__

All Statements Should Have Return Values (Syntax Proposal)  (2005-02-01)
CLOSED http://python.org/sf/1114404  opened by  Lenny Domnitser

RFE Closed
__

All Statements Should Have Return Values (Syntax Proposal)  (2005-02-01)
   http://python.org/sf/1114404  closed by  goodger

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


Re: advice needed for simple python web app

2005-02-03 Thread M.E.Farmer
I am no web expert but have recently used cherrypy to 'webify' a
script. It is very easy to get going and has its own server or can be
run behind Apache.
The only real problem I see is that the docs are still a little lite
for the new 2.0 series ,but they do have a newsgroup where the author
still answers questions.
Cherrypy2 is fairly logical and most of it is covered in the examples
on there website.
I can not speak for the other packages,have not used them yet ;)
hth,
M.E.Farmer

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Jeremy Bowers
On Thu, 03 Feb 2005 19:00:30 -0800, Paul Rubin wrote:
> Hmm, I'm not familiar with Nevow.  Twisted is pretty neat, though
> confusing.  I don't see how to scale it to multiple servers though.

Same way you'd scale any webserver, load balancing in hardware, store all
user state in a database, and tell the load balancer to try to "persist"
a user's connection to a machine, so Twisted doesn't even have to go back
to the server then?

I'm going to assume you know about this if you deal with large websites
professionally, so I'm curious as to why this is inadequate for your
needs? (If it's too detailed, no answer requested then, but if it's fast
to explain I'm intrigued.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a market for python developers?

2005-02-03 Thread David Fraser
Mabon Dane wrote:
I am new to python and took my first attempts at working with this
language today.  Is there a market for people who work with Python?
Slavery is outlawed in most parts of the world these days :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-03 Thread Jeremy Bowers
On Thu, 03 Feb 2005 22:46:24 -0500, Markus Wankus wrote:
> I realize your admirable intentions and the fact that you are simply 
> trying to help (the beauty of this community), but I beg you all 
> now...PLEASE...do not feed this troll.  Any responses to his posts will 
> simply snowball into the biggest waste of time and energy this newsgroup 
> has ever seen.I'll let Google fill in the rest of the picture.  You 
> can decide whether or not you want to respond to his posts.

Actually, based on the web pages I had already been thinking that from
this point on out I'd only cover highly specific questions about actual
code; you can smell that in the last paragraph, and the general theme that
what you want exists but you're going to have to put it together yourself.

Thanks for the warning, though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IPython colors in windows

2005-02-03 Thread DogWalker
"Ashot" <[EMAIL PROTECTED]> said:

>On 3 Feb 2005 19:18:33 -0800, James <[EMAIL PROTECTED]> wrote:
>
>>
>> Ashot wrote:
>>> I am using IPython in windows and the LightBG setting doesn't
>> correctly
>>> because the background of the text is black even if the console
>> background
>>> is white.  Anyone know whats going on?  Thanks.
>>>
>>> --
>>> ==
>>> Ashot Petrosian
>>> University of Texas at Austin, Computer Sciences
>>> (views expressed are solely my own)
>>> ==
>>
>> Did you try installing readline for windows?
>> http://newcenturycomputers.net/projects/readline.html
>>
>
>yea I've installed that and ctypes.  The color and tab completion work,  
>its just that colored get displayed with black background, it almost works  
>so its very frustrating..
>

Did you try the following (from the manual)?:

Input/Output prompts and exception tracebacks 


You can test whether the colored prompts and tracebacks work on your system 
interactively by typing '%colors Linux' at the prompt (use '%colors LightBG' if 
your terminal has a light background). If the input prompt shows garbage like: 
[0;32mIn [[1;32m1[0;32m]: [0;00m 
 instead of (in color) something like: 
 In [1]: 
  this means that your terminal doesn't properly handle color escape sequences. 
You can go to a 'no color' mode by typing '%colors NoColor'. 


  You can try using a different terminal emulator program. To permanently set 
your color preferences, edit the file $HOME/.ipython/ipythonrc and set the 
colors option to the desired value. 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: IPython colors in windows

2005-02-03 Thread Ashot
On 3 Feb 2005 19:18:33 -0800, James <[EMAIL PROTECTED]> wrote:
Ashot wrote:
I am using IPython in windows and the LightBG setting doesn't
correctly
because the background of the text is black even if the console
background
is white.  Anyone know whats going on?  Thanks.
--
==
Ashot Petrosian
University of Texas at Austin, Computer Sciences
(views expressed are solely my own)
==
Did you try installing readline for windows?
http://newcenturycomputers.net/projects/readline.html
yea I've installed that and ctypes.  The color and tab completion work,  
its just that colored get displayed with black background, it almost works  
so its very frustrating..

--
==
Ashot Petrosian
University of Texas at Austin, Computer Sciences
(views expressed are solely my own)
==
--
http://mail.python.org/mailman/listinfo/python-list


advice needed for simple python web app

2005-02-03 Thread Dan Perl
I have a pretty simple python script and I would like to turn it into a web 
application but web apps are a domain I know very little about.  I know that 
Twisted, CherryPy, Plone and Zope exist but not exactly what they do.  I 
need only advice on a direction to take.  For instance a suggestion on which 
application/framework to use would be great.

Basically, what I'm looking for is a web server that accepts an HTTP request 
and invokes a python script.  But I would like a "pythonic" solution so a 
web server like Apache is a solution that I would like to avoid.  The server 
should also be as simple as possible to administrate.

I would be even interested in building a very simple web app server if there 
is a framework that has all the basic components and there is good 
documentation for how to use it.

Thanks,

Dan 


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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Skip Montanaro

Paul> I'm talking about the very familiar experience of clicking a link
Paul> and then waiting, waiting, waiting for the page to load.  You
Paul> rarely see that happen with Ebay or Google.  It happens all the
Paul> time with Wikipedia.

It's more than a bit unfair to compare Wikipedia with Ebay or Google.  Even
though Wikipedia may be running on high-performance hardware, it's unlikely
that they have anything like the underlying network structure (replication,
connection speed, etc), total number of cpus or monetary resources to throw
at the problem that both Ebay and Google have.  I suspect money trumps LAMP
every time.

Just as a quick comparison, I executed

host www.wikipedia.org
host www.google.com

on two different machines, my laptop here on Comcast's network in Chicago,
and at Mojam's co-lo server in Colorado Springs.  I got the same results for
Wikipedia:

www.wikipedia.org has address 207.142.131.203
www.wikipedia.org has address 207.142.131.204
www.wikipedia.org has address 207.142.131.205
www.wikipedia.org has address 207.142.131.202

but different results for Google.  Laptop/Chicago:

www.google.com is a nickname for www.google.akadns.net
www.google.akadns.net has address 64.233.161.104
www.google.akadns.net has address 64.233.161.99
www.google.akadns.net has address 64.233.161.147

Co-Lo server/Colorado Springs:

www.google.com is an alias for www.google.akadns.net.
www.google.akadns.net has address 64.233.187.99
www.google.akadns.net has address 64.233.187.104

We also know Google has thousands of CPUs (I heard 5,000 at one point and
that was a couple years ago).  I doubt Wikipedia has more than a handful of
CPUs and they are probably all located in the same facility.  Google's
front-end web servers are clearly distributed around the Internet.  I
wouldn't be surprised if their back-end servers were widely distributed as
well.

Here's a link to an IEEE Micro article about Google's cluster architecture:


http://www.search3w.com/Siteresources/data/MediaArchive/files/Google%2015000%20servers%20secrest.pdf

It was published in 2003 and gives a figure of 15,000 commodity PCs.

Here's one quote from the beginning of the article:

To provide sufficient capacity to handle query traffic, our service
consists of multiple clusters distributed worldwide. Each cluster has
around a few thousand machines, and the geographically distributed setup
protects us against catastrophic data center failures (like those
arising from earthquakes and large-scale power failures).

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


Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-03 Thread Markus Wankus
OH GOD!  I cannot believe Ilias has shown up here...
Google his name - he has been banned from Netbeans and Eclipse (and 
Hibernate, and others...) for good reason.  Can you imagine how much of 
a Troll you need to be to *actually* get "banned" from the newsgroups of 
open source projects such as those?

I realize your admirable intentions and the fact that you are simply 
trying to help (the beauty of this community), but I beg you all 
now...PLEASE...do not feed this troll.  Any responses to his posts will 
simply snowball into the biggest waste of time and energy this newsgroup 
has ever seen.I'll let Google fill in the rest of the picture.  You 
can decide whether or not you want to respond to his posts.

Markus.
Jeremy Bowers wrote:
On Thu, 03 Feb 2005 09:26:08 +0200, Ilias Lazaridis wrote:
My question is essentially:
How many of those constructs are already supported by python (and the 
surrounding open-source-projects):

http://lazaridis.com/case/stack/index.html

This post is hard to follow, but I'm going to assume this is the core
question, as it is labelled as such.
The first thing that leaps to mind is that you need to play with Python
for a bit to get a full analysis of it. Due to the nature of Python, some
of the things you have in that list don't really apply. 

The most obvious example of this is "code generation": Assuming you mean
what I think you mean, the sort of thing you have in the C++ or Java world
where you click a couple of boxes, push "next" a few times, and have
several hundred kilobytes of impenetrable source code pop out as your
project's "framework", it doesn't generally apply. In Python, you can
actually write frameworks that can be made to do useful things in a small
handful of lines.
For a good example of that, I'd recommend the Twisted tutorial:
http://twistedmatrix.com/documents/current/howto/tutorial/index . In
Python, if a framework makes you write reams of boilerplate... it's
probably because someone just came from Java and isn't thinking in Python
yet. :-) Code generation in Python is generally a non-starter. (Few rare
counterexamples, but it's nothing like the Necessary Crutch it is in the
C++ world.) Generally, every line in that Twisted tutorial, even in the
final program, is *doing something*, not satisfying the framework with
necessary boilerplate.
As for the rest of your requirements, you have specified your "technology
stack" in terms of *goals*, not capabilities, so for quite a lot of them,
there is no answer except, "Yes, Python can do that, and generally easier
than most anything else". For instance, "Use of metadata within the design
(on text level [code file])" can mean a thousand things. For what it's
worth, Python tends to make it so easy I do it all the time, but for any
given way you mean it, I can't promise there exists a pre-rolled framework
for you.
So I can only speak generally. Given your list, you may find that Python
is weak in the "graphical programming" department; drop-and-drop GUI
generation isn't as well-tuned as VB. (I, for one, consider that
development methodology toxic and actively dangerous, but I can understand
why you miss it.)
Skipping down to your evaluation sequence:
* Create a class: Well, I'll show you this one:
class Something: pass
There, a class.
* Simple GUI: You may wish to check out Boa Constructor, as the closest
thing to the GUI generator you probably want. There are at least 3 major
viable GUI toolkits for Python and several other minor (but still capable)
ones.
* Embedded DBs: I don't know, Google for your embedded DB name + Python.
Failing that, there are several ways to wrap your embedded DB such that a
Python program can use it.
* Web GUI: There are more Python web frameworks than you can shake a stick
at, and I don't mean "some guys hacked together templating system" either;
there are a lot of very mature systems out there, expressing a lot of
different philosophies. Given some of your other requirements, for a
web-based application I'd recommend examining Zope.
* Deployment: I don't generally have enough problems with this to be worth
thinking about. I don't know what the state of the remote debugging is on
Python; Google "remote debugging Python".
* For your "complex updates", I see two distinct things there; half of the
depend on the database, not Python. For the other half, it depends on if
you mean "while the program is still running". If so, they are
challenging. If not, they are trivial.
* I'd recommend adding "testability" to your stack, and refer you to the
"unittest" module; others can suggest their preferred testing modules, but
I tend to stick with that as the general framework is available in a lot
of languages that I use. If by evolutive development you are including the
ideas behind "agile software development" (hard to tell if you mean that,
or a community open to change*)
Based on what I see here, I have two basic comments. First, yes, Python is
probably as close as you are going to get in an e

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-03 Thread Markus Wankus
I highly recommend trying pyDev.  0.9 just came out, and I find 0.85 
very usable and quite cool.  There is nice debug support, and 
context-sensitive code completion as well as real-time validation of 
your code.  This is an exciting project with a bright future in my opinion.

Markus.
Ashot wrote:
This is sort of both Python and Vim related (which is why I've posted 
to  both newsgroups).

Python related:
--
I have been frustrated for quite some time with a lack of a history  
command in IDLE (in fact with IDLE in general).  Often I'll develop new  
code at the command line, testing each line as I go.  Currently I have 
to  copy and paste, removing outputs and the ">>>" at each line.
Is it perhaps possible to make some kind of hack to do this (dump a  
command history)?

Idle in general isn't that great IMO, so I was wondering also if there 
are  better alternatives out there?  What do people use mostly?  I've 
tried  something called pyCrust, but this too didn't have history and 
some other  things I was looking for.  On a more general note, although 
the agility  and simplicity of Python make programming tools like an IDE 
less  necessary, it still seems that Python is lacking in this 
departement.  The  PyDev plug-in for Eclipse seems like good step in 
this direction, although  I haven't tried it yet.  Does anyone have any 
experience with this, or  perhaps can point me to other tools.

Vim related:
--
Ideally, it would be nice to have a command mapped to a keystroke that 
can  append the last executed command to a file.  Even better would be a 
system  that would integrate the file editing and interactive command 
line tool  more seamlessly.  Something along the lines of a debugger + 
file editor  + command line utility, where file editor = vim.  I know 
that vim has a  utility for running python commands from its command 
prompt, but I have  had a hard time getting this to work in windows and 
haven't explored it.   Has anyone seen/tried a system along these lines, 
perhaps incorporating  the python debugger (pdb)?  I can see something 
that will run the file you  are editing in vim up to the cursor or a 
mark with a set_trace at the line  you are editing.

Any info is appreciated, thanks.
--
Ashot Petrosian
University of Texas at Austin, Computer Sciences
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reinstall python 2.3 on OSX 10.3.5?

2005-02-03 Thread Robert Kern
Jorl Shefner wrote:
 I use a version of 2.3.4 on my Os X system that I installed myself 
without any apparent loss of functionality.  What extra advantages is 
the Apple installed version supposed to provide? 
Currently, Apple uses Python and the CoreGraphics wrappers (which aren't 
in the standard distribution) for it's fax software, I believe. If you 
don't use the fax software, you probably won't notice a difference while 
you continue to use Panther. Of course, Apple may utilize Python more in 
future versions of OS X, so I continue to strongly recommend not 
deleting the Python that they provide.

Future releases of Python should be easier to install *alongside* 
Apple's Python.

--
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


Possible additions to the standard library? (WAS: About standard library improvement)

2005-02-03 Thread Daniel Bickett
I was reading the thread by Frank Bello[1] about his offered addition
to the xmlrpclib module, and it reminded me of a few methods I had
made in the past that I considered worthy of being a part of the
standard library.

Rather than reiterate his question of how one gets one's patch into
the standard library -- as I can simply read the answers from his
thread -- I am posting here asking the opinion of the Python community
as to whether *you* consider these worthy of standard library
implementation.

The first one is a function I made for the _winreg module[2]. The
commentary, I think, explains what it does and why it had to be
written very clearly, so I'll just copy and paste it:[3]

|def DeleteKeyAll( key , subKey ):
|"""
|Since DeleteKey() can't remove keys that contain subkeys, this serves
|to iterate through a key and delete every single subkey, and then the
|key itself.
|
|Note: This function assumes that _winreg has been imported using:
|from _winreg import *
|  It can be easily converted by simply prepending all of the
|  applicable statements with `_winreg.' if you have imported
|  it otherwise.
|"""
|# try to open the specified key
|try:
|handle = OpenKey( key , subKey )
|except EnvironmentError:
|return False
|# now, iterate through the subkeys and remove
|# each of them (recursively)
|while True:
|nextKey = QueryInfoKey( handle )[0]
|if not nextKey:
|# if there aren't any more subkeys, delete the key at hand
|try:
|DeleteKey( key , subKey )
|return True
|except EnvironmentError:
|break
|else:
|# otherwise, recursively delete the subkeys
|DeleteKeyAll( key , subKey + "\\" + EnumKey( handle , 0 ) )

These next two are methods that I've applied to my own version of the
string object from time to time:

|class newstring( str ):
|def setreplace( self , set ):
|"""
|Do multiple replaces at once, using dictionary `set' as a legend,
|where each instance of each key is to be replaced with that key's
|value.
|"""
|if type( set ) == dict:
|result = self.__str__()
|for key, value in set.iteritems():
|if type( key ) == str and type( key ) == str:
|result = result.replace( key , value )
|else:
|raise TypeError, "All items of parameter set must
be strings"
|return result
|else:
|raise TypeError, "Parameter set must be a dictionary"
|
|def reverse( self ):
|"""
|Return a reversed copy of string.
|"""
|string = [ x for x in self.__str__() ]
|string.reverse()
|return ''.join( string )

In action:

>>> string = newstring("foo bar")
>>> string.reverse()
'rab oof'
>>> string.setreplace( { 'f' : 'b' , 'a' : 'o' } )
'boo bor'

I actually went on to write a method that reversed an integer
(inspired by an SAT question -- I had time to kill) using the
newstring's reverse() method, but it's hard enough justifying having a
string reverse method (though not impossible,) let alone an integer
reverse method, so I left that one on my hard drive :)

One more thing worth noting is that I'm not educated in the ways of
standard library etiquette, so I was more or less going out on the
limb doing type-checking in setreplace(). For all I know that's some
sort of paradox and you're supposed to let the user feel the pain, but
I did what I felt was right at the time.

This is basically all about commentary and criticism, and your opinion
of whether or not these deserve to be added to the library (or rather,
added as a patch, I presume). Thank you all for your time :)

P.S.:
I have included all of the methods in this post for the sake of
accessibility, and i have preceded all of the code with `|' because I
am unaware of the status of google's whitespace problem. If you want
to more easily copy and paste this code, I have posted it on nopaste:

DeleteKeyAll:http://rafb.net/paste/results/Yh6x0598.html
newstring methods:   http://rafb.net/paste/results/O51kja41.html

NOTES:
[1] http://tinyurl.com/4dkgw
[2] I'm currently unaware if _winreg is a c extension module or pure
python, but I'm assuming it's C, so I don't know how possible it is to
add pure python to it...
[3] I made a few quick edits after I pasted it in, so please bring to
my attention any errors or inconsistencies you see

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
aurora <[EMAIL PROTECTED]> writes:
> Slow compares to what? For a large commerical site with bigger budget,
> better infrastructure, better implementation, it is not surprising
> that  they come out ahead compares to hobbyist sites.

Hmm, as mentioned, I'm not sure what the commercial sites do that's
different.  I take the view that the free software world is capable of
anything that the commercial world is capable of, so I'm not awed just
because a site is commercial.  And sites like Slashdot have pretty big
budgets by hobbyist standards.

> Putting implementation aside, is LAMP inherently performing worst than
> commerical alternatives like IIS, ColdFusion, Sun ONE or DB2? Sounds
> like  that's your perposition.

I wouldn't say that.  I don't think Apache is a bottleneck compared
with other web servers.  Similarly I don't see an inherent reason for
Python (or whatever) to be seriously slower than Java servlets.  I
have heard that MySQL doesn't handle concurrent updates nearly as well
as DB2 or Oracle, or for that matter PostgreSQL, so I wonder if busier
LAMP sites might benefit from switching to PostgreSQL (LAMP => LAPP?).

> I don't know if there is any number to support this perposition. Note
> that  many largest site have open source components in them. Google,
> Amazon,  Yahoo all run on unix variants. Ebay is the notable
> exception, which uses  IIS. Can you really say ebay is performing
> better that amazon (or vice  versa)?

I don't know how much the OS matters.  I don't know how much the web
server matters.  My suspicion is that the big resource sink is the SQL
server.  But I'm wondering what people more experienced than I am say
about this.  Google certainly doesn't use SQL for its web search index.

> I think the chief factor that a site performing poorly is in the
> implementation. It is really easy to throw big money into expensive
> software and hardware and come out with a performance dog. Google's
> infrastructure relies on a large distributed network of commodity
> hardware, not a few expensive boxes. LAMP based infrastructure, if
> used  right, can support the most demanding applications.

Google sure doesn't use LAMP!  I've heard that when you enter a Google
query, about sixty different computers work on it.  The search index
is distributed all over the place and they use a supercomputer-like
interconnect strategy (but based on commodity ethernet switches) to
move stuff around between the processors.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IPython colors in windows

2005-02-03 Thread James

Ashot wrote:
> I am using IPython in windows and the LightBG setting doesn't
correctly
> because the background of the text is black even if the console
background
> is white.  Anyone know whats going on?  Thanks.
>
> --
> ==
> Ashot Petrosian
> University of Texas at Austin, Computer Sciences
> (views expressed are solely my own)
> ==

Did you try installing readline for windows?
http://newcenturycomputers.net/projects/readline.html

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Tim Daneliuk <[EMAIL PROTECTED]> writes:
> I worked for an Airline computer reservation system (CRS) for almost a
> decade. There is nothing about today's laptops that remotely comes close
> to the power of those CRS systems, even the old ones. CRS systems are
> optimized for extremely high performance I/O and use an operating system
> (TPF) specifically designed for high-performance transaction processing.

Yeah, I've been interested for a while in learning a little bit about
how TPF worked.  Does Gray's book that you mention say much about it?

I think that the raw hardware of today's laptops dwarfs the old big
iron.  An S/360 channel controller may have basically been a mainframe
in its own right, but even a mainframe in those days was just a few
MIPS.  The i/o systems and memory are lots faster too, though not by
nearly the ratio by which storage capacity and cpu speed have
increased.  E.g., a laptop disk these days has around 10 msec latency
and 20 MB/sec native transfer speed, vs 50+ msec and a few MB/sec for
a 3330-level drive (does that sound about right?.  

> Web servers are very sessions oriented: make a connection-pass the
> unit of work-drop the connection. This is inherently slow (and not
> how high performance TP is done). Moreover, really high perfomance
> requires a very fine level of I/O tuning on the server - at the CRS
> I worked for, they performance people actually only populated part
> of the hard drives to minimize head seeks.

Today I think most seeks can be eliminated by just using ram or SSD
(solid state disks) instead of rotating disks.  But yeah, you wouldn't
do that on a laptop.

> For a good overview of TP design, see Jim Gray's book, "Transaction
> Processing: Concepts and Techniques".

Thanks, I'll look for this book.  Gray of course is one of the
all-time database gurus and that book is probably something every
serious nerd should read.  I've probably been a bad boy just for
having not gotten around to it years ago.

> P.S. AFAIK the first CRS systems of any note came into being in the 1970s not
>   the 1960s, but I may be incorrect in the matter.

>From :

The system [SABRE] was created by American Airlines and IBM in the
1950s, after AA president C. R. Smith sat next to an IBM sales
representative on a transcontinental flight in 1953. Sabre's first
mainframe in Briarcliff Manor, New York went online in 1960. By
1964, Sabre was the largest private data processing system in the
world. Its mainframe was moved to an underground location in
Tulsa, Oklahoma in 1972.

Originally used only by American, the system was expanded to travel
agents in 1976. It is currently used by a number of companies,
including Eurostar, SNCF, and US Airways. The Travelocity website is
owned by Sabre and serves as a consumer interface to the system.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread aurora
Slow compares to what? For a large commerical site with bigger budget,  
better infrastructure, better implementation, it is not surprising that  
they come out ahead compares to hobbyist sites.

Putting implementation aside, is LAMP inherently performing worst than  
commerical alternatives like IIS, ColdFusion, Sun ONE or DB2? Sounds like  
that's your perposition.

I don't know if there is any number to support this perposition. Note that  
many largest site have open source components in them. Google, Amazon,  
Yahoo all run on unix variants. Ebay is the notable exception, which uses  
IIS. Can you really say ebay is performing better that amazon (or vice  
versa)?

I think the chief factor that a site performing poorly is in the  
implementation. It is really easy to throw big money into expensive  
software and hardware and come out with a performance dog. Google's  
infrastructure relies on a large distributed network of commodity  
hardware, not a few expensive boxes. LAMP based infrastructure, if used  
right, can support the most demanding applications.


LAMP = Linux/Apache/MySQL/P{ython,erl,HP}.  Refers to the general
class of database-backed web sites built using those components.  This
being c.l.py, if you want, you can limit your interest to the case the
P stands for Python.
I notice that lots of the medium-largish sites (from hobbyist BBS's to
sites like Slashdot, Wikipedia, etc.)  built using this approach are
painfully slow even using seriously powerful server hardware.  Yet
compared to a really large site like Ebay or Hotmail (to say nothing
of Google), the traffic levels on those sites is just chickenfeed.
I wonder what the webheads here see as the bottlenecks.  Is it the
application code?  Disk bandwidth at the database side, that could be
cured with more ram caches or solid state disks?  SQL just inherently
slow?
I've only worked on one serious site of this type and it was "SAJO"
(Solaris Apache Java Oracle) rather than LAMP, but the concepts are
the same.  I just feel like something bogus has to be going on.  I
think even sites like Slashdot handle fewer TPS than a 1960's airline
reservation that ran on hardware with a fraction of the power of one
of today's laptops.
How would you go about building such a site?  Is LAMP really the right
approach?
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-03 Thread John Hunter
> "Paul" == Paul Rubin <"http://phr.cx"@NOSPAM.invalid> writes:

Paul> Various possible candidates for such dragging have
Paul> apparently decided that their chances weren't too good.

Or simply that it wasn't worth the cost to go to court, even if they
presumed they would eventually win.

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


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Kartic <[EMAIL PROTECTED]> writes:
> And the reason for that I probably because of the way the language is
> used (PHP) (this is a shot in the dark as I have not looked into
> Mediawiki code), and compounded by probably an unoptimized database.

I have the idea that the Wikipedia implementers know what they're doing,
but I haven't looked into it super closely.

> I don't want to start flame wars here about PHP; I use PHP to build
> client sites and like it for the "easy building of dynamic sites"
> but the downside is that there is no "memory"...every page is
> compiled each time a request is made. I doubt if Wikipedia site uses
> an optimizer (like Zend) or caching mechanisms. Optimizers and/or
> PHP caches make a huge performance difference.

They do use an optimizer similar to Zend.  They also use Squid as a
static cache.

> Also, PHP has put dynamic sites within easy reach of several
> programmers who slap together sites in no time. These sites may have
> spaghetti code and even the best infrastructure is not enough to
> support shabby design (code, db setup and even server tuning). I have
> seen people become programmers overnight! There are also LAMP sites
> that use Apache 1.3 that is a resource hog; I guess production sites
> do not want to upgrade to Apache 2.x/PHP combo!

Hmm, I wasn't aware that Apache 2.x gave any significant speedups
over 1.3 except under Windows.  Am I missing something?

> The way to go is to build around application servers, IMHO. I like the
> Twisted.web/Nevow methodology, though for simple situations it may be
> an overkill. 

Hmm, I'm not familiar with Nevow.  Twisted is pretty neat, though
confusing.  I don't see how to scale it to multiple servers though.

I'm asking this question mainly as it relates to midrange or larger
sites, not the very simplest ones (e.g. on my personal site I just use
Python cgi's, which are fine for the few dozen or so hits a week that
they get).  So, the complexity of twisted is acceptable.

> From my experience it is an overall tuning thing. Usual culprits are
> untuned Linux boxes, unoptimized database design, poorly designed
> queries and/or poor application logic...and ah! table-driven
> pages. Pages built on tables for the layout kill the browser. CSS is
> the way to go.

Yes, good point about html tables, though I'm concerned primarily
about server response.  (It's off-topic, but how do you use CSS to get
the effect of tables?)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-03 Thread Paul Rubin
Tim Churches <[EMAIL PROTECTED]> writes:
> See also this article, in which Lawrence Rosen, the attorney for
> OSI, admits that it is impossible for anyone to properly interpret
> the application of various open source licenses under the various
> national laws: http://www.devx.com/opensource/Article/27171
> 
> I suspect that this issue applies equally to the FSF.

Correct.  Neither a GPL compliance engineer, the FSF's legal counsel,
an attorney for OSI, a defendant or potential defendant, or anyone
else except a judge presiding over a court of law having jurisdiction
over an actual case or controversy involving the license, can
interpret the application of a license under the law in a legally
binding way.

The FSF is sticking to its guns and has not yet had to drag anyone
before an actual judge to get the matter decided.  Various possible
candidates for such dragging have apparently decided that their
chances weren't too good.

As for the copying-from-disk doctrine, that's purely guesswork on my
part.  The FSF has not publicly disclosed its legal strategy for if
and when a case comes up.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding user's home dir

2005-02-03 Thread Peter Hansen
Nemesis wrote:
On my Win2000 box it returns "%USERPROFILE%". That's no surprise because
if you look at the code it try to use os.environ["HOME"] (as
os.path.expanduser() does). And on my Win2000 system this information
points to "%USERPROFILE%" field (I don't know why, I'm not the
administrator of that machine).
It looks a lot like somebody who didn't test things out
properly (the real administrator, not you), was trying
to do the equivalent of "set home=%userprofile%" but
managed to fail...  if you do that at the command line
or in a .CMD or .BAT file, it will expand the reference
out and you'd have a "HOME=C:\Documents and Settings\whatever"
just like you'd expect.
Probably they put that in a dialog box somewhere without
realizing it wouldn't be evaluated.  (At least, I don't
think environment variable substitution generally or
ever has "lazy evaluation" semantics...)
Now that I know how to do what Duncan described (thanks
Duncan!), either approach works for me.  Of course,
whether I'm a likely eventual user of your particular
program is an entirely different question. ;-)
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Kartic
Paul Rubin said the following on 2/3/2005 7:20 PM:
LAMP = Linux/Apache/MySQL/P{ython,erl,HP}.  Refers to the general
class of database-backed web sites built using those components.  This
being c.l.py, if you want, you can limit your interest to the case the
P stands for Python.
I notice that lots of the medium-largish sites (from hobbyist BBS's to
sites like Slashdot, Wikipedia, etc.)  built using this approach are
painfully slow even using seriously powerful server hardware.  Yet
compared to a really large site like Ebay or Hotmail (to say nothing
of Google), the traffic levels on those sites is just chickenfeed.
If you are talking about Wikipedia as a prime example, I agree with you 
that it is *painfully* slow.

And the reason for that I probably because of the way the language is 
used (PHP) (this is a shot in the dark as I have not looked into 
Mediawiki code), and compounded by probably an unoptimized database. I 
don't want to start flame wars here about PHP; I use PHP to build client 
sites and like it for the "easy building of dynamic sites" but the 
downside is that there is no "memory"...every page is compiled each time 
a request is made. I doubt if Wikipedia site uses an optimizer (like 
Zend) or caching mechanisms. Optimizers and/or PHP caches make a huge 
performance difference.

Also, PHP has put dynamic sites within easy reach of several programmers 
who slap together sites in no time. These sites may have spaghetti code 
and even the best infrastructure is not enough to support shabby design 
(code, db setup and even server tuning). I have seen people become 
programmers overnight! There are also LAMP sites that use Apache 1.3 
that is a resource hog; I guess production sites do not want to upgrade 
to Apache 2.x/PHP combo!

Coming to python, to be honest, I have not seen many LAMPy sites. I use 
blogspot.com frequently and it is pretty reliable; I hear that it is 
written in Python but I have no idea about the server and database software.

The way to go is to build around application servers, IMHO. I like the 
Twisted.web/Nevow methodology, though for simple situations it may be an 
overkill. I like the Webware with Apache-thru-Webware-Adapter setup - 
that is what I am considering implementing for my organization. (Even in 
the App Server arena, I have seen Websphere with JSP/Servelets sites to 
be s slow that I could finish my breakfast and still wait for the page)

From my experience it is an overall tuning thing. Usual culprits are 
untuned Linux boxes, unoptimized database design, poorly designed 
queries and/or poor application logic...and ah! table-driven pages. 
Pages built on tables for the layout kill the browser. CSS is the way to go.

Thanks,
-Kartic
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-03 Thread Tim Churches
Steve Holden <[EMAIL PROTECTED]> wrote:
> 
> In the absence of other information I Cc'd [EMAIL PROTECTED] to ask their 
> opinion about the relationship between GPL'd Python modules and 
> programs  that imported them
...
> > If a Python program imports a module licensed under the GPL, in your 
> > opinion does the Python program become a derivative work of the GPL'd 
> 
> > software?
> 
> Generally, yes.
> 
> -- 
> -Dave "Novalis" Turner
> GPL Compliance Engineer
> Free Software Foundation
> 
> So, there we have it, not a legal opinion but at least what a GPL 
> compliance engineer thinks. I must add, I can't remember when I saw a 
> dafter title.

Definitely not a legal opinion, which are characterised by an explanation of 
the logic 
and reasoning behind the opinion.

Perhaps you can ask the GPL Compliance Engineer how he responds to the 
following 
facts:

0) Section 0 of the GPL states: "Activities other than copying, distribution 
and 
modification are not covered by this License; they are outside its scope."

1) In Australia and Europe at least, loading program code from disc into memory 
in 
order to execute it is not considered as making an infringing copy under 
copyright law. 
Thus it is drawing a very long bow indeed to describe importing a third-party 
GPLed 
module at runtime as "copying" in these countries.

2) Importing a third-party GPLed Python module at runtime cannot be considered 
distribution, nor can it be considered modification, since the source or object 
code for 
that module is not being edited or modified.

Given these fatcs, under what possible interpretation (in Australia and Europe 
and 
probably elsewhere) can the act of importing a GPLed Python module at runtime 
be 
considered to fall under the scope of the GPL as set out in Section 0, quoted 
above?

See also this article, in which Lawrence Rosen, the attorney for OSI, admits 
that it is 
impossible for anyone to properly interpret the application of various open 
source 
licenses under the various national laws: 
http://www.devx.com/opensource/Article/27171 

I suspect that this issue applies equally to the FSF.

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


Re: Is there a market for python developers?

2005-02-03 Thread Luis M. Gonzalez

Peter Hansen wrote:
> Yes.

Man of few words...

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


Re: how to generate SQL SELECT pivot table string

2005-02-03 Thread John Machin
McBooCzech wrote:
> Hallo all,
>
> I am trying to generate SQL SELECT command which will return pivot
> table. The number of column in the pivot table depends on the data
> stored in the database. It means I do not know in advance how many
> columns the pivot table will have.
>
> For example I will test the database as following:
> SELECT DISTINCT T1.YEAR FROM T1
>
> The SELECT command will return:
> 2002
> 2003
> 2004
> 2005
>
> So I would like to construct following select:
>
> select T1.WEEK,
> SUM (case T1.YEAR when '2002' then T1.PRICE else 0 END) Y_02,
> SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
> SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
> SUM (case T1.YEAR when '2005' then T1.PRICE else 0 END) Y_05
> from T1
> group by T1.week
>
> which will return pivot table with 5 columns:
> WEEK, Y_02, Y_03, Y_04, Y_05,
>
> but if the command "SELECT DISTINCT T1.YEAR FROM T1" returns:
> 2003
> 2004
>
> I have to construct only following string:
>
> select T1.WEEK,
> SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
> SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
> from T1
> group by T1.week
>
> which will return pivot table with 3 columns:
> WEEK, Y_03, Y_04
>
> Can anyone help and give me a hand or just direct me, how to write a
> code which will generate SELECT string depending on the data stored
in
> the database as I described?

>>> step1result = ["2003", "2004"] # for example
>>> prologue = "select T1.WEEK, "
>>> template = "SUM (case T1.YEAR when '%s' then T1.PRICE else 0 END)
Y_%s"
>>> epilogue = " from T1 group by T1.week"
>>> step2sql = prologue + ", ".join([template % (x, x[-2:]) for x in
step1result]) + epilogue
>>> step2sql
"select T1.WEEK, SUM (case T1.YEAR when '2003' then T1.PRICE else 0
END) Y_03, SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04
from T1 group by T1.week"
>>>

Of course you may need to adjust the strings above to allow for your
local SQL syntax (line breaks, line continuations, semicolon at the end
maybe, ...).

A few quick silly questions:
Have you read the Python tutorial?
Do you read this newsgroup (other than answers to your own questions)?
Could you have done this yourself in a language other than Python?

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


Re: About standard library improvement

2005-02-03 Thread Steve Holden
BJörn Lindqvist wrote:
The process seem slow. I've submitted two patches and haven't gotten
any response so far, but it has only been three weeks. Other patches
seem to be idling for months. I'm not complaining, just want to know
why the process is so slow and what you can do when you submit
patches/bug reports to speed it up?
BJörn:
I suspect you should join the python-dev list - you may well be able to 
help much more effectively there.

regards
 Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005  http://www.pycon.org/
Steve Holden   http://www.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Tim Daneliuk
Paul Rubin wrote:
Simon Wittber <[EMAIL PROTECTED]> writes:
Slow is such an ambiguous term. Do you mean the pages are slow to
render in a browser, or slow to be fetched from the server, or the
server is slow to respond to requests? What is slow?

The server is slow to respond to requests.  Browser rendering is
independent of the server architecture and "slow to be fetched from
the server" sounds like it means low network speed.  I'm talking about
the very familiar experience of clicking a link and then waiting,
waiting, waiting for the page to load.  You rarely see that happen
with Ebay or Google.  It happens all the time with Wikipedia.
This has a lot to do with the latency and speed of the connecting
network. Sites like Ebay, Google, and Amazon are connected
to internet backbone nodes (for speed) and are cached throughout
the network using things like Akami (to reduce latency)...
--

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-03 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> In the absence of other information I Cc'd [EMAIL PROTECTED] to ask their
> opinion about the relationship between GPL'd Python modules and
> programs that imported them

In the OP's particular case, he got the agreement of the GPL'd
module's author, so it stopped being an issue for that particular
module.  However the FSF takes the view that dynamic linking a GPL'd
module does count as making a derivative work, and I'm pretty sure
they have enforced this view (i.e. convinced someone who was doing it
that they better stop) in the past.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Dave Brueck
Paul Rubin wrote:
How would you go about building such a site?  Is LAMP really the right
approach?
Two major problems I've noticed, don't know if they are universal, but they sure 
hurt the performance:

1) Some sites have not put any thought into caching - i.e. the application 
server is serving up images or every single page is dynamically generated even 
though all (or most) of it is static such that most of the requests just aren't 
cacheable.

2) Because a database is there, it gets used, even when it shouldn't, and it 
often gets used poorly - bad or no connection pooling, many trips to the 
database for each page generated, no table indices, bizarro database schemas.

Overall I'd say my first guess is that too much is being generated on the fly, 
often because it's just easier not to worry about cacheability, but a good web 
cache can provide orders of magnitude improvement in performance, so it's worth 
some extra thought.

One project we had involved the users navigating through a big set of data, 
narrowing down the set by making choices about different variables. At any point 
it would display the choices that had been made, the remaining choices, and the 
top few hits in the data set. We initially thought all the pages would have to 
be dynamically generated, but then we realized that each page really represented 
a distinct and finite state, so we went ahead and built the site with Zope + 
Postgres, but made it so that the URLs were input to Zope and told what state to 
generate.

The upshot of all this is that we then just ran a web spider against Zope any 
time the data changed (once a week or so), and so the site ended up "feeling" 
pretty dynamic to a user but pretty much everything came straight out of a cache.

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


[Fwd: [gnu.org #220719] Re: python and gpl]

2005-02-03 Thread Steve Holden
In the absence of other information I Cc'd [EMAIL PROTECTED] to ask their 
opinion about the relationship between GPL'd Python modules and programs 
that imported them

 Original Message 
[EMAIL PROTECTED] - Mon Jan 31 15:49:28 2005]:
Scott Robinson wrote:
> On 30 Jan 2005 21:59:25 -0800, Paul Rubin
>  wrote:
> 
> 
>>John Hunter <[EMAIL PROTECTED]> writes:
>>
>>>The question is: does shipping a backend which imports a module that
>>>links with GPL code make some or all of the library GPL.
>>
>>Literally speaking, no, not automatically, any more than driving a car
>>makes you into a licensed driver if you weren't one already.  But if
>>you weren't licensed, then you've broken the law by driving the car.
>>So your question should be: 1) is shipping that backend one of the
>>things you need the GPL to license you to legally do, and 2) if so,
>>does the GPL in fact give you that license?
>>
>>If you're asking in terms of legal enforcement, the answer is 1) maybe
>>and 2) almost certainly not.  I think it's better to ask in terms of
>>the GPL's spirit.  I would say that it's not in the GPL's spirit and
>>that GPL die-hards would consider that use objectionable, though they
>>might make exceptions for specific cases (so it doesn't hurt to ask).
>>Some authors who use the GPL are less strict about how they interpret
>>it, so again, the friendly thing to do is ask the author.
>>
>> * If a backend module somebackend does
>>
>>import somelib
>>
>>   where somelib is a python wrapper of GPL code, is somebackend GPLd?
>>
>>It's GPL'd if you GPL it.  If you don't GPL it, then distributing it
>>it may be a GPL violation that could get you taken to court.  I
>>believe the FSF's view is that it is fact a violation; however, the
>>courts have not yet established this.  The law doesn't have a
>>black-and-white boundary.  It's more like a fractal.  The only way to
>>find out what a court will decide is to actually try a case there.
>>
>>Rather than try to probe how closely you can dance around the
>>boundaries of the GPL, you might just ask the author of the GPL'd
>>library whether what you want to do is ok with him or her.  If s/he
>>says no and you do it anyway, you're both inviting trouble over the
>>possible infringement, and also inviting people to try to use your
>>code in ways you don't like.  Since the free software movement depends
>>on a spirit of cooperation, I think it's best to avoid trying to press
>>too hard against the boundaries of anyone's licenses.
>>
>>http://www.gnu.org/licenses/gpl-faq.html
> 
> 
> If you read the GPL, it claims everything it can (any "work" created
> using GPLed "work").  My guess is that anything that calls the code in
> a way not specifically allowed by the author is going to get you into
> trouble.  IANAL, but from what I can remember about earlier licensing
> issues, any code specific for a GPLed library (especially "import")
> will get you into to trouble.  Having a non-free library with an
> identical API and issuing 
> 	exec("import "+sys.argv[1])
> where the user can supply sys.argv as the name of the gpl'ed library
> will work (I think there is a free/non-free library out there that is
> never run, but exists for exactly this condition).
> 
> Scott Robinson
> 
I presume the appropriate way to answer this question is to ask the Gnu, 
since under these circumstances the Python zen would advise "refuse the 
temptation to guess". So I am Cc'ing [EMAIL PROTECTED] with a request for an 
answer to the (apparently relatively simple) question:

If a Python program imports a module licensed under the GPL, in your 
opinion does the Python program become a derivative work of the GPL'd 
software?
Generally, yes.
--
-Dave "Novalis" Turner
GPL Compliance Engineer
Free Software Foundation
So, there we have it, not a legal opinion but at least what a GPL 
compliance engineer thinks. I must add, I can't remember when I saw a 
dafter title.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Tim Daneliuk
Paul Rubin wrote:

I've only worked on one serious site of this type and it was "SAJO"
(Solaris Apache Java Oracle) rather than LAMP, but the concepts are
the same.  I just feel like something bogus has to be going on.  I
think even sites like Slashdot handle fewer TPS than a 1960's airline
reservation that ran on hardware with a fraction of the power of one
of today's laptops.
I worked for an Airline computer reservation system (CRS) for almost a
decade. There is nothing about today's laptops that remotely comes close
to the power of those CRS systems, even the old ones. CRS systems are
optimized for extremely high performance I/O and use an operating system
(TPF) specifically designed for high-performance transaction processing.
Web servers are very sessions oriented: make a connection-pass the unit
of work-drop the connection. This is inherently slow (and not how high
performance TP is done). Moreover, really high perfomance requires a
very fine level of I/O tuning on the server - at the CRS I worked for,
they performance people actually only populated part of the hard drives
to minimize head seeks.
The point is that *everything* has to be tuned for high performance
TP - the OS, the language constructs (we used assembler for most things),
the protocols, and the overall architecture.  THis is why, IMHO,
things like SOAP a laughable - RPC is a poor foundation for reliable,
durable, and high-performance TP.  It might be fine for sending an
order or invoice now and then, but sustained throughput of the sort
I think of as "high" performance is likely never going to be accomplished
with session-oriented architectures.
For a good overview of TP design, see Jim Gray's book, "Transaction Processing:
Concepts and Techniques".
P.S. AFAIK the first CRS systems of any note came into being in the 1970s not
 the 1960s, but I may be incorrect in the matter.
--

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
Simon Wittber <[EMAIL PROTECTED]> writes:
> Slow is such an ambiguous term. Do you mean the pages are slow to
> render in a browser, or slow to be fetched from the server, or the
> server is slow to respond to requests? What is slow?

The server is slow to respond to requests.  Browser rendering is
independent of the server architecture and "slow to be fetched from
the server" sounds like it means low network speed.  I'm talking about
the very familiar experience of clicking a link and then waiting,
waiting, waiting for the page to load.  You rarely see that happen
with Ebay or Google.  It happens all the time with Wikipedia.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Simon Wittber
> I notice that lots of the medium-largish sites (from hobbyist BBS's to
> sites like Slashdot, Wikipedia, etc.)  built using this approach are
> painfully slow even using seriously powerful server hardware.

Slow is such an ambiguous term. Do you mean the pages are slow to
render in a browser, or slow to be fetched from the server, or the
server is slow to respond to requests? What is slow?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to generate SQL SELECT pivot table string

2005-02-03 Thread McBooCzech
Thanks for your comment but I am NOT looking for the answer to the
question: "Which SQL command will return requested pivot table"(anyway
it will be an OFF TOPIC question here). My SQL SELECT statement works
fine with Firebird 1.5! What I am looking how to generate this SELECT
using Python. Anyway thanks for tyring to help :)

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


Re: how to generate SQL SELECT pivot table string

2005-02-03 Thread Michael Spencer
McBooCzech wrote:
Hallo all,
I am trying to generate SQL SELECT command which will return pivot
table. The number of column in the pivot table depends on the data
stored in the database. It means I do not know in advance how many
columns the pivot table will have.
For example I will test the database as following:
SELECT DISTINCT T1.YEAR FROM T1
The SELECT command will return:
2002
2003
2004
2005
So I would like to construct following select:
select T1.WEEK,
SUM (case T1.YEAR when '2002' then T1.PRICE else 0 END) Y_02,
SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
SUM (case T1.YEAR when '2005' then T1.PRICE else 0 END) Y_05
from T1
group by T1.week
which will return pivot table with 5 columns:
WEEK, Y_02, Y_03, Y_04, Y_05,
but if the command "SELECT DISTINCT T1.YEAR FROM T1" returns:
2003
2004
I have to construct only following string:
select T1.WEEK,
SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
from T1
group by T1.week
which will return pivot table with 3 columns:
WEEK, Y_03, Y_04
Can anyone help and give me a hand or just direct me, how to write a
code which will generate SELECT string depending on the data stored in
the database as I described?
Thanks
Petr McBooCzech
>>> step1result = """2000
... 2001
... 2002
... 2003""".splitlines()
>>> step1result
['2000', '2001', '2002', '2003']
>>> step2query = "Prefix " + ",".join(["Case %s" % year for year in 
step1result]) + " Postfix"
>>> step2query
'Prefix Case 2000,Case 2001,Case 2002,Case 2003 Postfix'

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


IPython colors in windows

2005-02-03 Thread Ashot
I am using IPython in windows and the LightBG setting doesn't correctly  
because the background of the text is black even if the console background  
is white.  Anyone know whats going on?  Thanks.

--
==
Ashot Petrosian
University of Texas at Austin, Computer Sciences
(views expressed are solely my own)
==
--
http://mail.python.org/mailman/listinfo/python-list


Re: dict indexed by lists - ?

2005-02-03 Thread Steven Bethard
Alexander Zatvornitskiy wrote:
Hello All!
I'am trying to make something like this:
CPT={ ['b0','c0']:1, ['b0','c1']:0, ['b1','c0']:3, ['b1','c1']:1 }
but python says "TypeError: list objects are unhashable"
I can replace list with touple: CPT={ ('b0','c0'):1, ('b0','c1'):0, ...and so
on. But, where is one problem: indexes (or, more precisely, keys) are generated
dynamically, like code below! I can't do it with touples.
key=[]
for up in uplinks:
  key.append(up.state(0))
and, later, modifying it like this:
  key[2]=up.next_state()
  ...
  print CPT[key]
Any suggestions?
You can manually add the tuple calls:
CPT = {('b0','c0'):1, ('b0','c1'):0, ('b1','c0'):3, ('b1','c1'):1}
...
key = [up.state(0) for up in uplinks]
...
key[2] = up.next_state()
...
print CPT[tuple(key)]
I've only added the tuple call when you actually access CPT, but 
depending on your code, you might find that you can make the tuple call 
earlier.  For example, the following code should work:

CPT={('b0','c0'):1, ('b0','c1'):0, ('b1','c0'):3, ('b1','c1'):1}
...
key = tuple([up.state(0) for up in uplinks])
...
print CPT[key]
where basically you convert key back to a tuple any time it's changed.
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: why are LAMP sites slow?

2005-02-03 Thread Aahz
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
>
>I've only worked on one serious site of this type and it was "SAJO"
>(Solaris Apache Java Oracle) rather than LAMP, but the concepts are
>the same.  I just feel like something bogus has to be going on.  I
>think even sites like Slashdot handle fewer TPS than a 1960's airline
>reservation that ran on hardware with a fraction of the power of one
>of today's laptops.

Something I saw recently was that XML has inherently horrid performance
for searching precisely because it isn't fixed-length records.  Yes, the
old platforms handled more TPS, but they also handled much less data of
a form much more amenable to indexing.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to generate SQL SELECT pivot table string

2005-02-03 Thread [EMAIL PROTECTED]
McBooCzech wrote:
> Hallo all,
>
> I am trying to generate SQL SELECT command which will return pivot
> table. The number of column in the pivot table depends on the data
> stored in the database. It means I do not know in advance how many
> columns the pivot table will have.
>
> For example I will test the database as following:
> SELECT DISTINCT T1.YEAR FROM T1
>
> The SELECT command will return:
> 2002
> 2003
> 2004
> 2005
>
> So I would like to construct following select:
>
> select T1.WEEK,
> SUM (case T1.YEAR when '2002' then T1.PRICE else 0 END) Y_02,
> SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
> SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
> SUM (case T1.YEAR when '2005' then T1.PRICE else 0 END) Y_05
> from T1
> group by T1.week
>
> which will return pivot table with 5 columns:
> WEEK, Y_02, Y_03, Y_04, Y_05,
>
> but if the command "SELECT DISTINCT T1.YEAR FROM T1" returns:
> 2003
> 2004
>
> I have to construct only following string:
>
> select T1.WEEK,
> SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
> SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
> from T1
> group by T1.week
>
> which will return pivot table with 3 columns:
> WEEK, Y_03, Y_04
>
> Can anyone help and give me a hand or just direct me, how to write a
> code which will generate SELECT string depending on the data stored
in
> the database as I described?
>
> Thanks
>
> Petr McBooCzech

In MS-Access, the appropriate SQL statement is

TRANSFORM Sum(T1.price) AS SumOfprice
SELECT T1.week
FROM T1
GROUP BY T1.week
PIVOT T1.year;

Note the keywords TRANSFORM and PIVOT. These change an
ordinary SELECT query into what Access calls a CROSSTAB
query. In such a query, the number of columns is created
automatically (subject to the limitation of a maximum of
256 columns).

For example, if your T1 table contains:

yearweekprice
20021   123
200210  456
200220  254
200230  253
200240  325
200250  111
20031   254
200310  256
200320  854
200330  125
200340  845
200350  562
20041   425
200410  123
200420  212
200430  555
200440  412
200450  852


The query shown will output:

week200220032004
1   123 254 425
10  456 256 123
20  254 854 212
30  253 125 555
40  325 845 412
50  111 562 852


Now, if you add another year's worth of data,

yearweekprice
20051   666
200510  555
200520  444
200530  333
200540  222
200550  111

the query (without any modiification) will now output

week2002200320042005
1   123 254 425 666
10  456 256 123 555
20  254 854 212 444
30  253 125 555 333
40  325 845 412 222
50  111 562 852 111


If you had multiple records for each year/week you would, of course,
see the aggregate result (in this case, Sum). Watch what happens
when I duplicate the 2005 records:

week2002200320042005
1   123 254 425 1332
10  456 256 123 1110
20  254 854 212 888
30  253 125 555 666
40  325 845 412 444
50  111 562 852 222

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


Re: CGI and HTTP Header Location redirects

2005-02-03 Thread Paul Rubin
Derek Basch <[EMAIL PROTECTED]> writes:
> Also, after enabling suEXEC on the apache server the script executes
> perfectly with the redirect. Can anyone explain this behavior? I
> would guess that it is related to apache user rights but I can't
> find any reference to such problems via Google.

Apache probably isn't able to run the cgi because of lack of exec
permission or something like that.  The best way to diagnose such
probs is by checking the apache error log, if you have access to it.

Best newsgroup for this type of question is
comp.infosystems.www.servers.unix.  Lots of apache experts hang out there.
-- 
http://mail.python.org/mailman/listinfo/python-list


dict indexed by lists - ?

2005-02-03 Thread Alexander Zatvornitskiy
Hello All!

I'am trying to make something like this:

CPT={ ['b0','c0']:1, ['b0','c1']:0, ['b1','c0']:3, ['b1','c1']:1 }

but python says "TypeError: list objects are unhashable"

I can replace list with touple: CPT={ ('b0','c0'):1, ('b0','c1'):0, ...and so
on. But, where is one problem: indexes (or, more precisely, keys) are generated
dynamically, like code below! I can't do it with touples.


key=[]
for up in uplinks:
  key.append(up.state(0))


and, later, modifying it like this:
  key[2]=up.next_state()
  ...
  print CPT[key]

Any suggestions?


Alexander, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


CGI and HTTP Header Location redirects

2005-02-03 Thread Derek Basch
Hello,

I have been dealing with some strange behavior using CGI, python and an HTTP
Header "Location:" redirect on an Apache 1.3 server.

If I call a CGI script and perform a "Location:" redirect the script seems to
silently run off the tracks immediately after the redirect. For example "0.xml"
and "1.xml" are created when there is no redirect and only "0.xml" is created
when a redirect does occur (see below).

Also, after enabling suEXEC on the apache server the script executes perfectly
with the redirect. Can anyone explain this behavior? I would guess that it is
related to apache user rights but I can't find any reference to such problems
via Google.

Thanks everyone!,
Derek Basch

-

#! /usr/bin/python

import sys
import cgitb

class Trainer:

def train(self):
fs = open("/tmp/0.xml", "w")
fs.close()
##  print "Location: " + "http://www.yahoo.com"; + "\n\n"
sys.stdout.flush()
fs = open("/tmp/1.xml", "w")
fs.close()

def main():
try:
cgitb.enable()  
trainer = Trainer()
trainer.train()

except Exception, inst:
cgitb.handler()

if __name__ == '__main__':
main()




__ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: why are LAMP sites slow?

2005-02-03 Thread Paul Rubin
LAMP = Linux/Apache/MySQL/P{ython,erl,HP}.  Refers to the general
class of database-backed web sites built using those components.  This
being c.l.py, if you want, you can limit your interest to the case the
P stands for Python.

I notice that lots of the medium-largish sites (from hobbyist BBS's to
sites like Slashdot, Wikipedia, etc.)  built using this approach are
painfully slow even using seriously powerful server hardware.  Yet
compared to a really large site like Ebay or Hotmail (to say nothing
of Google), the traffic levels on those sites is just chickenfeed.

I wonder what the webheads here see as the bottlenecks.  Is it the
application code?  Disk bandwidth at the database side, that could be
cured with more ram caches or solid state disks?  SQL just inherently
slow?

I've only worked on one serious site of this type and it was "SAJO"
(Solaris Apache Java Oracle) rather than LAMP, but the concepts are
the same.  I just feel like something bogus has to be going on.  I
think even sites like Slashdot handle fewer TPS than a 1960's airline
reservation that ran on hardware with a fraction of the power of one
of today's laptops.

How would you go about building such a site?  Is LAMP really the right
approach?
-- 
http://mail.python.org/mailman/listinfo/python-list


how to generate SQL SELECT pivot table string

2005-02-03 Thread McBooCzech
Hallo all,

I am trying to generate SQL SELECT command which will return pivot
table. The number of column in the pivot table depends on the data
stored in the database. It means I do not know in advance how many
columns the pivot table will have.

For example I will test the database as following:
SELECT DISTINCT T1.YEAR FROM T1

The SELECT command will return:
2002
2003
2004
2005

So I would like to construct following select:

select T1.WEEK,
SUM (case T1.YEAR when '2002' then T1.PRICE else 0 END) Y_02,
SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
SUM (case T1.YEAR when '2005' then T1.PRICE else 0 END) Y_05
from T1
group by T1.week

which will return pivot table with 5 columns:
WEEK, Y_02, Y_03, Y_04, Y_05,

but if the command "SELECT DISTINCT T1.YEAR FROM T1" returns:
2003
2004

I have to construct only following string:

select T1.WEEK,
SUM (case T1.YEAR when '2003' then T1.PRICE else 0 END) Y_03,
SUM (case T1.YEAR when '2004' then T1.PRICE else 0 END) Y_04,
from T1
group by T1.week

which will return pivot table with 3 columns:
WEEK, Y_03, Y_04

Can anyone help and give me a hand or just direct me, how to write a
code which will generate SELECT string depending on the data stored in
the database as I described?

Thanks

Petr McBooCzech

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


Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin

Leeuw van der, Tim wrote:
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED]
on behalf of John Machin
> > Sent: Thu 2/3/2005 12:00 PM
> > To: python-list@python.org
> > Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4,
2.3.5rc1,2.4.0)
> >
> >
> > Leeuw van der, Tim wrote:
> > >
> > >> > Do you have a file called drwtsn32.log anywhere on your
computer?
> > >
> > > No, unfortunately I cannot find such file anywhere on my
computer
> > >
> > > What do I do to get such file? Or anything equally useful?
> > >
> >
> > On my Windows 2000 box, just crash something :-)
> >
> >
> > Perhaps this may help:
> >
> >
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/RegistryTips/RegistryTools/DrWatson.html
> >
>
> Using this URL, I found the log file and it's about 1Gb big...

Yeah, well, it's a *LOG* file -- unless you fiddle with the registry
settings (not recommended), you get one lot of guff per crash. But 1
Gb

> I'll have to find out what is the useful part of it (or remove it and
crash again).

The useful part would be the tail of the file. Remove it? It may
contain evidence useful for other problems (that you didn't know you
were having). Try rename.

> I don't know why searching all drives using windows 'search' did not
find the file!

Possibilities:
1. You have a virus that renames the drwtsn32.log file for the duration
of a search.
2. Emanations from UFOs are affecting computer circuitry in your
neighbourhood.
3. Microsoft programmers stuffed up.
4. You had a typo.

>
> When I have a usefull crashdump, what should I do? Attach to e-mail
and post it here?

You could eyeball it to see if it gave you a clue first. Failing that,
just post a copy of the part(s) from just ONE crash that look something
like this:

*> Stack Back Trace <*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0012D6F8 77F8819B 7803A700 7C34F639 7803A730 7C36B42C
ntdll!RtlpWaitForCriticalSection
0012D73C 1E0A73CE 7803A710  00AE0900 
ntdll!ZwCreateThread
7C36C576 E87C3822 FFFD5D89 E80C75FF FFFE3081 FC658359
!PyTime_DoubleToTimet
B8680C6A      


> Should I include the user.dmp file too?

Look at it; how big is it? [my latest is 13MB for @#$% sake] Is it in
ascii or binary? Does it look useful? What proportion of people who get
this newsgroup/mailing-list via *E-MAIL* will be overjoyed to receive
it?
Are you sure you will not be splattering company-confidential data all
over the Internet?

>
> Should I do the same for both python 2.3.5r1 and python 2.4? Or is it
sufficient to do so for Python 2.4?

If you are sending only stack back trace snippets as above, then send
both just in case they are different.

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


Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin

Leeuw van der, Tim wrote:
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED]
on behalf of John Machin
> > Sent: Thu 2/3/2005 12:00 PM
> > To: python-list@python.org
> > Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4,
2.3.5rc1,2.4.0)
> >
> >
> > Leeuw van der, Tim wrote:
> > >
> > >> > Do you have a file called drwtsn32.log anywhere on your
computer?
> > >
> > > No, unfortunately I cannot find such file anywhere on my
computer
> > >
> > > What do I do to get such file? Or anything equally useful?
> > >
> >
> > On my Windows 2000 box, just crash something :-)
> >
> >
> > Perhaps this may help:
> >
> >
http://www.windowsnetworking.com/kbase/WindowsTips/Windows2000/RegistryTips/RegistryTools/DrWatson.html
> >
>
> Using this URL, I found the log file and it's about 1Gb big...

Yeah, well, it's a *LOG* file -- unless you fiddle with the registry
settings (not recommended), you get one lot of guff per crash. But 1
Gb

> I'll have to find out what is the useful part of it (or remove it and
crash again).

The useful part would be the tail of the file. Remove it? It may
contain evidence useful for other problems (that you didn't know you
were having). Try rename.

> I don't know why searching all drives using windows 'search' did not
find the file!

Possibilities:
1. You have a virus that renames the drwtsn32.log file for the duration
of a search.
2. Emanations from UFOs are affecting computer circuitry in your
neighbourhood.
3. Microsoft programmers stuffed up.
4. You had a typo.

>
> When I have a usefull crashdump, what should I do? Attach to e-mail
and post it here?

You could eyeball it to see if it gave you a clue first. Failing that,
just post a copy of the part(s) from just ONE crash that look something
like this:

*> Stack Back Trace <*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0012D6F8 77F8819B 7803A700 7C34F639 7803A730 7C36B42C
ntdll!RtlpWaitForCriticalSection
0012D73C 1E0A73CE 7803A710  00AE0900 
ntdll!ZwCreateThread
7C36C576 E87C3822 FFFD5D89 E80C75FF FFFE3081 FC658359
!PyTime_DoubleToTimet
B8680C6A      


> Should I include the user.dmp file too?

Look at it; how big is it? [my latest is 13MB for @#$% sake] Is it in
ascii or binary? Does it look useful? What proportion of people who get
this newsgroup/mailing-list via *E-MAIL* will be overjoyed to receive
it?
Are you sure you will not be splattering company-confidential data all
over the Internet?

>
> Should I do the same for both python 2.3.5r1 and python 2.4? Or is it
sufficient to do so for Python 2.4?

If you are sending only stack back trace snippets as above, then send
both just in case they are different.

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


Re: About standard library improvement

2005-02-03 Thread Steven Bethard
Lee Harr wrote:
On 2005-02-03, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
The process seem slow. I've submitted two patches and haven't gotten
any response so far, but it has only been three weeks. Other patches
seem to be idling for months. I'm not complaining, just want to know
why the process is so slow and what you can do when you submit
patches/bug reports to speed it up?
I am certainly no expert, but I follow the lists. I recall
reading something recently that a lot of the logjam is the
need for people to look over other patches that have been
submitted. Something along the lines of ... if everyone
who submits a patch will just go through and check over
10 other patches we will have this backup sorted quickly.
Yeah, a few of the python-devvers have agreed to this setup.  And the 
patch count has been lowered to 5.  So if you really want to get your 
patch reviewed, find 5 patches, look them over, test them out, and then 
post your recommendations on how these patches should be handled to 
python-dev.  Then point them to the patch you'd like reviewed, and when 
the generous python-devvers who have agreed to this setup get a chance, 
they will review your patch.

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


Regular expression match objects - compact syntax?

2005-02-03 Thread Johann C. Rocholl
Hello python-list,

I have a question about the match objects that are returned from the
match() method of compiled regular expression objects from the 're'
module. To parse Postscript T1 fonts that were disassembled into
plaintext, I came up with the following code:

import re
rmoveto = re.compile('^\s*(-?\d+)\s+(-?\d+)\s+rmoveto$')
rlineto = re.compile('^\s*(-?\d+)\s+(-?\d+)\s+rlineto$')
# ... other expressions with up to six paren groups

f = open(filename, 'r')
for line in f.readlines():

m = rmoveto.match(line)
if m:
x = x + int(m.group(1))
y = y + int(m.group(2))
glyph.append(('move', (x, y)))
continue

m = rlineto.match(line)
if m:
x = x + int(m.group(1))
y = y + int(m.group(2))
glyph.append(('line', (x, y)))
continue

# ... and so forth for the other expressions

Now here is my question: is there a simple way to join the following
two python code lines:
m = rmoveto.match(line)
if m:
into one single line like in the following:
if rmoveto.match(line):
x = x + int(rmoveto.group(1))
y = y + int(rmoveto.group(2))
glyph.append(('move', (x, y)))
elif rlineto.match(line):
# ...

The above syntax does not work because the compiled regular expression
object rmoveto doesn't provide a method called group(), as it comes
from module 're'. The obsolete package 'regex' did provide this, if I
read the docs correctly.

As a workaround, I also tried to use a nested function like this:

def match(expr):
m = expr.match(line)
return m

if match(rmoveto):
x = x + int(m.group(1))
# ...

This approach failed because the match function has its own local m,
so it didn't update the outer m. I couldn't use 'global m' either
because the whole thing, including the outer m, happens to be inside a
function, too.

How do you people handle this?

Thanks for your time,
Johann C. Rocholl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reinstall python 2.3 on OSX 10.3.5?

2005-02-03 Thread Dominique O. Martel
0) compile and install GNU readline 5.0 with the usual ./configure
method
ftp://ftp.cwru.edu/pub/bash/readline-5.0.tar.gz

1) as an administrator, remove the contents of
"/System/Library/Frameworks/Python.framework"

2) install Python from the standard distribution:
 ./configure --enable-framework=/System/Library/Frameworks
make
sudo make frameworkinstall

3) install the extras in /Applications if you want to:
sudo make frameworkinstallextras
Move them to /Developer/Applications/Utilities/MacPython-2.3

4) remove every python* from /usr/local/bin
Those in /usr/bin/ are OK for Python 2.3

5) replace
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages"
with a symbolic link to "/Library/Python/2.3". Name it "site-packages".

I have installed and used Python 2.3.x this way without any problem
whatsoever.

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


Re: bytecode obfuscation

2005-02-03 Thread snacktime
On Thu, 3 Feb 2005 17:28:50 -0500, Daniel Bickett <[EMAIL PROTECTED]> wrote:
> snacktime wrote:
> > How difficult is it to turn python bytecode into it's original source?
> >  Is it that much different than java (this is what they will probably
> > compare it to) ?
> 
> As far as I know, that depends on how much money you're willing to
> pour into it ;)
> 
> http://www.crazy-compilers.com/decompyle/
> 
> Other than that link, which I stumbled upon at some point (at
> python-eggs), I'm decidedly uninformed on this subject.

I just stumbled on Pyrex which seems to be exactly what I needed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-mode tab completion problem

2005-02-03 Thread Fernando Perez
Skip Montanaro wrote:

> 
> test1dellboy3> I am exploring python-mode on emacs. When I open foo.py
> test1dellboy3> in emacs and hit C-!, it starts the python interpreter in
> test1dellboy3> another window. Next, I execute -
> 
> ...
> 
> That's not really intended to be used as an interactive session with all
> sorts of bells and whistles.

Or he can use ipython, which with the special ipython.el companion file and a
recent (CVS) python-mode, will give him true tab completion (with options
listed in an emacs *completions* buffer) for all objects.

With ipython's %pdb active, it will also open up the source at any uncaught
exception, at the line of the exception.  Very handy for debugging.

Regards,

f

ps. All this fanciness is thanks to the sustained efforts of A. Schmolck and P.
Ramachandran, I'm just happy to use them (I can't code a line of elisp).

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


Re: Popularizing SimpleHTTPServer and CGIHTTPServer

2005-02-03 Thread Lee Harr
> Does anyone know how to use SimpleHTTPServer to:
>
> 1. Support virtual hosts?
>
> 2. Support SSL?
>
> I'd like to use SimpleHTTPServer to create some simple reporting utilities, 
> but can't get past these two points. Is there a NotSoSimpleHTTPServer?


I think I would point to twisted for that. It is another
dependency, but it has all you will ever need and more.

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


Re: List mapping question

2005-02-03 Thread Michael Spencer
Marc Huffnagle wrote:
I have a number of variables that I want to modify (a bunch of strings 
that I need to convert into ints).  Is there an easy way to do that 
other than saying:

 > a = int(a)
 > b = int(b)
 > c = int(c)
It may not matter to you, at the moment, but a = int(a) is not strictly 
'modifying a variable'.  Instead int(a) creates a new int object, if possible, 
from the object that a is currently bound to.  Then a is rebound to the new object.

I tried
 > [i = int(i) for i in [a, b, c]]
You can't make an assignment in a list comprehension.  If your 'variables' are 
object attributes, you could do: [setattr(obj,name,int(getattr(obj,name)) for 
name in [list of attribute names]]


but that didn't work because it was creating a list with the values of 
a, b and c instead of the actual variables themselves, then trying to 
set a string equal to an integer, which it really didn't like.

 Marc
For your problem as stated:
>>> a=b=c="1"
>>> for var in ["a","b","c"]:
... exec "%s = int(%s)" % (var,var)
...
>>> a,b,c
(1, 1, 1)
>>>
But don't do this, except as a "one-off" data crunching exercise
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: About standard library improvement

2005-02-03 Thread Lee Harr
On 2005-02-03, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
> The process seem slow. I've submitted two patches and haven't gotten
> any response so far, but it has only been three weeks. Other patches
> seem to be idling for months. I'm not complaining, just want to know
> why the process is so slow and what you can do when you submit
> patches/bug reports to speed it up?
>

I am certainly no expert, but I follow the lists. I recall
reading something recently that a lot of the logjam is the
need for people to look over other patches that have been
submitted. Something along the lines of ... if everyone
who submits a patch will just go through and check over
10 other patches we will have this backup sorted quickly.

So, if there are patches in the tracker that are in the
same general area as yours, or in another area about which
you have some knowledge, you chould check them out, and
comment on them and help out the process.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List mapping question

2005-02-03 Thread Steven Bethard
Marc Huffnagle wrote:
Steve Holden wrote:
 >>> a,b,c = 1.1, 2.2, 3.3
 >>> a,b,c = map(int, (a,b,c))
 >>> a,b,c
(1, 2, 3)
 >>> a,b,c = [int(x) for x in (a,b,c)]
 >>> a,b,c
(1, 2, 3)
regards
 Steve
Thanks ... so there's no way to pass an actual variable into a list 
mapping, instead of its value?  I guess I'm thinking of something the 
equivalent of call by reference.
No, not really.  You could do something like:
py> a, b, c = 1.1, 2.2, 3.3
py> mod = __import__(__name__)
py> for name in ('a', 'b', 'c'):
... setattr(mod, name, int(getattr(mod, name)))
...
py> a, b, c
(1, 2, 3)
where you use the namespace in which the name resides (the module), but 
I'd probably advise against it...  I would suggest doing something like:

py> myvars = dict(a=1.1, b=2.2, c=3.3)
py> for key, value in myvars.iteritems():
... myvars[key] = int(value)
...
py> myvars
{'a': 1, 'c': 3, 'b': 2}
If you want to pass around variables, it's generally better to put them 
in a dict, list, class instance or some other sort of container then 
mess around with them at the module level...

(another) STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: About standard library improvement

2005-02-03 Thread BJörn Lindqvist
The process seem slow. I've submitted two patches and haven't gotten
any response so far, but it has only been three weeks. Other patches
seem to be idling for months. I'm not complaining, just want to know
why the process is so slow and what you can do when you submit
patches/bug reports to speed it up?

-- 
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list


Re: Where are list methods documented?

2005-02-03 Thread Daniel Bickett
Simply as a general reply to the OP, I've found that some of the most
definitive documentation can be found using help() at the command
line:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(list)
Help on class list in module __builtin__:
[big snip]

It goes into good detail about all of the methods, etcetera.

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove duplicates from list *preserving order*

2005-02-03 Thread Michael Spencer
Steven Bethard wrote:
I'm sorry, I assume this has been discussed somewhere already, but I 
found only a few hits in Google Groups...  If you know where there's a 
good summary, please feel free to direct me there.

I have a list[1] of objects from which I need to remove duplicates.  I 
have to maintain the list order though, so solutions like set(lst), etc. 
will not work for me.  What are my options?  So far, I can see:

def filterdups(iterable):
result = []
for item in iterable:
if item not in result:
result.append(item)
return result
def filterdups(iterable):
result = []
seen = set()
for item in iterable:
if item not in seen:
result.append(item)
seen.add(item)
return result
def filterdups(iterable):
seen = set()
for item in iterable:
if item not in seen:
seen.add(item)
yield item
Does anyone have a better[2] solution?
STeve
[1] Well, actually it's an iterable of objects, but I can convert it to 
a list if that's helpful.

[2] Yes I know, "better" is ambiguous.  If it helps any, for my 
particular situation, speed is probably more important than memory, so 
I'm leaning towards the second or third implementation.
How about:
>>> def filterdups3(iterable):
... seen = set()
... def _seen(item):
... return item in seen or seen.add(item)
... return itertools.ifilterfalse(_seen,iterable)
...
>>> list(filterdups3([1,2,2,3,3,3,4,4,4,2,2,5]))
[1, 2, 3, 4, 5]
>>>
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: python-mode tab completion problem

2005-02-03 Thread Skip Montanaro

test1dellboy3> I am exploring python-mode on emacs. When I open foo.py
test1dellboy3> in emacs and hit C-!, it starts the python interpreter in
test1dellboy3> another window. Next, I execute -

...

That's not really intended to be used as an interactive session with all
sorts of bells and whistles.  If you want a true terminal emulator within
Emacs, try

M-x terminal-emulator RET

You can do tab completion and command recall just like a normal terminal.
(In fact, you can run Emacs within Emacs using terminal-emulator.)

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


Re: List mapping question

2005-02-03 Thread Steven Bethard
Marc Huffnagle wrote:
I have a number of variables that I want to modify (a bunch of strings 
that I need to convert into ints).  Is there an easy way to do that 
other than saying:

 > a = int(a)
 > b = int(b)
 > c = int(c)
I tried
 > [i = int(i) for i in [a, b, c]]
but that didn't work because it was creating a list with the values of 
a, b and c instead of the actual variables themselves, then trying to 
set a string equal to an integer, which it really didn't like.
Actually, that didn't work because it's a SyntaxError to have an 
assigment statement inside a list comprehension:

py> [i = int(i) for i in [a, b, c]]
Traceback (  File "", line 1
[i = int(i) for i in [a, b, c]]
   ^
SyntaxError: invalid syntax
You could try something like:
py> a, b, c
('1', '2', '3')
py> a, b, c = [int(i) for i in (a, b, c)]
py> a, b, c
(1, 2, 3)
For a few variables, this is probably a reasonable solution.  For more 
than 4 or 5 though, it's going to get unreadable.  Of course for that 
many variables, you should probably be keeping them in a list instead of 
as separate names anyway...

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


Re: List mapping question

2005-02-03 Thread Marc Huffnagle
Steve Holden wrote:
Marc Huffnagle wrote:
I have a number of variables that I want to modify (a bunch of strings 
that I need to convert into ints).  Is there an easy way to do that 
other than saying:

 > a = int(a)
 > b = int(b)
 > c = int(c)
I tried
 > [i = int(i) for i in [a, b, c]]
but that didn't work because it was creating a list with the values of 
a, b and c instead of the actual variables themselves, then trying to 
set a string equal to an integer, which it really didn't like.

 Marc
 >>> a,b,c = 1.1, 2.2, 3.3
 >>> a,b,c = map(int, (a,b,c))
 >>> a,b,c
(1, 2, 3)
 >>> a,b,c = [int(x) for x in (a,b,c)]
 >>> a,b,c
(1, 2, 3)
regards
 Steve
Thanks ... so there's no way to pass an actual variable into a list 
mapping, instead of its value?  I guess I'm thinking of something the 
equivalent of call by reference.

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


Re: List mapping question

2005-02-03 Thread Steve Holden
Marc Huffnagle wrote:
I have a number of variables that I want to modify (a bunch of strings 
that I need to convert into ints).  Is there an easy way to do that 
other than saying:

 > a = int(a)
 > b = int(b)
 > c = int(c)
I tried
 > [i = int(i) for i in [a, b, c]]
but that didn't work because it was creating a list with the values of 
a, b and c instead of the actual variables themselves, then trying to 
set a string equal to an integer, which it really didn't like.

 Marc
 >>> a,b,c = 1.1, 2.2, 3.3
 >>> a,b,c = map(int, (a,b,c))
 >>> a,b,c
(1, 2, 3)
 >>> a,b,c = [int(x) for x in (a,b,c)]
 >>> a,b,c
(1, 2, 3)
regards
 Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005  http://www.pycon.org/
Steve Holden   http://www.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: bytecode obfuscation

2005-02-03 Thread Daniel Bickett
snacktime wrote:
> How difficult is it to turn python bytecode into it's original source?
>  Is it that much different than java (this is what they will probably
> compare it to) ?

As far as I know, that depends on how much money you're willing to
pour into it ;)

http://www.crazy-compilers.com/decompyle/

Other than that link, which I stumbled upon at some point (at
python-eggs), I'm decidedly uninformed on this subject.

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Where are list methods documented?

2005-02-03 Thread Tony Meyer
> You're not the only one with a hard time finding the list
> documentation. It's even crazier for string docs.
> 
> If you want to see how to strip strings in Python you have to go to
> the library docs, then click "sequence types" (betcha don't think of
> strings as sequences), then scroll to the bottom, then click "String
> Methods", then scroll to find "strip()".

Does nobody use an index anymore?  If you type "strip" into the index of the
Windows HTML help, the first entry is "strip (string method)", which is
probably what you want.  Or you can use the pyhelp.cgi script linked from
 and search for "strip" and "strip (string method)"
is the second entry (the first, which is strip in the string module, would
tell you more-or-less the same, anyway).



Or you can go to the general index in the regular version of the HTML help.
As you might expect, "strip" can be found under "s".



I presume that there's some sort of index in the PDF and all the other
versions of the help, too.

=Tony.Meyer

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


Re: bytecode obfuscation

2005-02-03 Thread Skip Montanaro

snacktime> How difficult is it to turn python bytecode into it's
snacktime> original source?

Not very.  Google for "python decompyle".

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


Re: bytecode obfuscation

2005-02-03 Thread snacktime
> 
> > Everything except the libraries that actually connect to the
> > bank networks would be open source, and those libraries aren't
> > something that you would even want to touch anyways.
> 
> This sounds suspicious to me. Really. Normal payment clearance programs
> have open-spec API's.
> 

I think you might be thinking of api's from companies like Verisign,
which are online payment processors.  Online payment processors in
turn connect to direct processors such as Firstdata, Vital, Global
Payment, etc..  Those direct processors do not have open-spec API's,
at least none of them that I have worked with and I've certified with
most of them at one point or another.
-- 
http://mail.python.org/mailman/listinfo/python-list


mounting a filesystem?

2005-02-03 Thread Dan Stromberg

Is there a python module that can mount a filesystem?

More specifically, a loopback filesystem with a particular offset, under
linux?

Thanks!

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


Re: Where are list methods documented?

2005-02-03 Thread Nelson Minar
You're not the only one with a hard time finding the list
documentation. It's even crazier for string docs.

If you want to see how to strip strings in Python you have to go to
the library docs, then click "sequence types" (betcha don't think of
strings as sequences), then scroll to the bottom, then click "String
Methods", then scroll to find "strip()". This makes perfect sense if
you understand that strings are "mutable sequences". But if you're
coming from (say) Perl and are looking for the quick way to work with
strings, it's pretty deeply buried.

A simple internal link or two would help a lot. Say, something in
"built-in functions" which says "see also..."

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


  1   2   3   >