Re: Python use growing fast

2011-01-10 Thread Gerry Reno
On 01/10/2011 08:31 PM, Katie T wrote:
> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle  wrote:
>   
>> On 1/10/2011 1:02 PM, MRAB wrote:
>> 
>>> On 10/01/2011 20:29, Dan Stromberg wrote:
>>>   
 I invite folks to check out Tiobe's Language Popularity Rankings:

 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
 
>>   That's somehow derived from web searches, not from any real data
>> source.  Look how far down JavaScript is.
>> 
> Any measure is arbitrary and subject to biases, what methodology would
> you prefer ?
>
>
> Katie
>   

Measuring the "Buzz" about a language is actually a pretty good way to
gauge its popularity.

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


Re: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac?

2011-01-06 Thread Gerry Reno
On 01/06/2011 02:44 PM, Bill Felton wrote:
> Hi All,
> I'm new to python, trying to learn it from a variety of resources, including 
> references posted recently to this list.
> I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes use 
> of gasp, which apparently is not compatible with 3.1.
> I've also seen various resources indicate that one can install both Python 
> 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the 
> 2.7 install.  IDLE, in particular, fails rather spectacularly, even if I 
> launch it directly from the Python 2.7 directory in which it resides.
> So, either I've been misled and should only try to have one or the other.  OR 
> I'm missing some (probably simple) step that's mucking me up.
> Help?
>
> Thanks,
> Bill
>
>
>   

You probably want to use 'virtualenv' for keeping things separated.



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


Re: CPython on the Web

2011-01-04 Thread Gerry Reno
On 01/04/2011 12:38 PM, gry wrote:
> On Jan 4, 1:11 am, John Nagle  wrote:
>   
>> On 1/1/2011 11:26 PM, azakai wrote:
>>
>> 
>>> Hello, I hope this will be interesting to people here: CPython running
>>> on the web,
>>>   
>> 
>>> http://syntensity.com/static/python.html
>>>   
>> 
>>> That isn't a new implementation of Python, but rather CPython 2.7.1,
>>> compiled from C to JavaScript using Emscripten and LLVM. For more
>>> details on the conversion process, seehttp://emscripten.org
>>>   
> On loading, I "get script stack space quota is exhausted" under
> firefox 3.5.12, under linux.
> Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907
> Fedora/3.5.12-1.fc12 Firefox/3.5.12
>   


It's a Firefox bug apparently fixed in Firefox 4.x.

Some versions of Firefox 3.6.x do work but most do not.


Regards,
Gerry

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


Re: CPython on the Web

2011-01-03 Thread Gerry Reno
On 01/03/2011 05:55 PM, Diez B. Roggisch wrote:
> Gerry Reno  writes:
>
>   
>> On 01/03/2011 03:13 PM, Diez B. Roggisch wrote:
>> 
>>> A fun hack. Have you bothered to compare it to the PyPy javascript
>>> backend - perfomance-wise, that is?
>>>
>>> Diez
>>>   
>>>   
>> I don't think that exists anymore.  Didn't that get removed from PyPy
>> about 2 years ago?
>> 
> Ah, didn't know that. I was under the impression pyjamas was done with
> it. Apparently, that's wrong:
>
>  http://pyjs.org/
>
> But then I re-phrase my question: how does this relate to pyjamas/pyjs?
>
> Diez
>   

>From what I've seen so far:

Pyjamas is taking your python code and converting it into javascript so
that your python code (converted to javascript) can run in a browser.

CPotW is taking the whole python interpreter and converting the
interpreter into javascript so that the python interpreter runs in the
browser.  Your python code remains as python code.


Regards,
Gerry

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


Re: CPython on the Web

2011-01-03 Thread Gerry Reno
On 01/03/2011 03:13 PM, Diez B. Roggisch wrote:
>
> A fun hack. Have you bothered to compare it to the PyPy javascript
> backend - perfomance-wise, that is?
>
> Diez
>   

I don't think that exists anymore.  Didn't that get removed from PyPy
about 2 years ago?


Regards,
Gerry

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


Re: CPython on the Web

2011-01-03 Thread Gerry Reno
On 01/03/2011 03:10 PM, azakai wrote:
> On Jan 2, 5:55 pm, Gerry Reno  wrote:
>   
>> I tried printing sys.path and here is the output:
>>
>> ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/',
>> '/usr/local/lib/python2.7/plat-linux2',
>> '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old',
>> '/usr/local/lib/lib-dynload']
>>
>> Now, those paths must be on your machine because they are not on my
>> client machine.  But the interpreter is now running on MY machine.  Well
>> in a sandbox really.  So how is that going to work?
>>
>> 
> Yeah, those are the paths on the machine where the binary was compiled
> (so, they are the standard paths on ubuntu).
>
> Anyhow the filesystem can't (and shouldn't) be accessed from inside a
> browser page. 

Well, the local filesystem could be accessible with the user's
permission and this should be an option.


Regards,
Gerry

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


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
I tried printing sys.path and here is the output:

['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/lib-dynload']

Now, those paths must be on your machine because they are not on my
client machine.  But the interpreter is now running on MY machine.  Well
in a sandbox really.  So how is that going to work?


Regards,
Gerry

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


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
On 01/02/2011 05:53 PM, azakai wrote:
> On Jan 2, 1:01 pm, Gerry Reno  wrote:
>   
>> Ok, visiting this page:
>>
>> http://syntensity.com/static/python.html
>>
>> I do not see anything happen when I click 'execute' button.  I'm running
>> Firefox 3.6.3.
>>
>> 
> I've only tested with Firefox 4. I'm surprised though that it wouldn't
> work on 3.6.3. Can you see what errors appear in the error console
> (control-shift-J)?
>
>   

Errors when using Firefox 3.6.3:

script stack space quota is exhausted
Module is not defined  ...  line 56


Regards,
Gerry



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


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
On 01/02/2011 02:26 AM, azakai wrote:
> Hello, I hope this will be interesting to people here: CPython running
> on the web,
>
> http://syntensity.com/static/python.html
>
> That isn't a new implementation of Python, but rather CPython 2.7.1,
> compiled from C to JavaScript using Emscripten and LLVM. For more
> details on the conversion process, see http://emscripten.org
>
> This is a work in progress, main issues right now are that the code
> isn't optimized (so don't expect good performance), and importing non-
> static modules doesn't work. Otherwise, though, it seems to run
> properly, in particular it runs all the examples in
> http://wiki.python.org/moin/SimplePrograms that don't rely on
> importing modules or receiving input from the user (with perhaps some
> minor formatting errors). The demo runs fine on recent versions of
> Firefox, Chrome and Safari, but has problems on IE9 and Opera
> (hopefully those will be resolved soon).
>
> The idea is that by compiling CPython itself, all the features of the
> language are immediately present, and at the latest version, unlike
> writing a new implementation which takes time and tends to lag behind.
> As to why run it on the web, there could be various uses, for example
> it could allow a simple learning environment for Python, which since
> it's on the web can be entered immediately without any download (and
> would run even in places where Python normally can't, like say an
> iPad).
>
> Feedback would be very welcome!
>
> - azakai
>   

Ok, visiting this page:

http://syntensity.com/static/python.html

I do not see anything happen when I click 'execute' button.  I'm running
Firefox 3.6.3.

Here is what I see both before and after clicking 'execute':
=

This is CPython, the standard Python <http://www.python.org>
implementation, compiled from C to JavaScript using Emscripten
<http://emscripten.org>, running in your browser (without any plugins).

* Most core language stuff should work, except for importing
  non-static modules (in other words, |import sys| will work, but
  other modules won't).
* Please report bugs if you find them!
* Tested on Firefox 4 and Chrome 10.
* The editor is Skywriter <https://mozillalabs.com/skywriter/>.


*Enter some Python*:
import sys print 'Hello world! This is Python {} on
{}'.format(sys.version, sys.platform) print 'Here are some numbers:',
[2*x for x in range(5)][:4]

=


So what is happening is that the whole Python interpreter has been
converted to Javascript and is running the browser, is that correct?

Ok, but the usual browser 'sandbox' constraints would still apply would
they not?

And what is the build toolchain that you need if you want to convert
your modules to be importable with this "CPython on the Web"?


Regards,
Gerry



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


Re: Tkinter: The good, the bad, and the ugly!

2010-12-30 Thread Gerry Reno
On 12/30/2010 10:28 PM, rantingrick wrote:
>
> Hmm, wxPython is starting to look like the answer to all our problems.
> WxPython already has an IDE so there is no need to rewrite IDLE
> completely. What do we have to loose by integrating wx into the
> stdlib, really?
>
>   

In the spirit of "batteries included", Python needs to have "something"
in the stdlib as far as gui.  But it cannot be overwhelming.

The problem with wx is that it is BIG.  And so if we want something like
wx to be in the stdlib then it would have to be refactored so that there
was a small basic wx that was part of stdlib and then import
wx-the-whole-enchilada if you need heavy gui artillery.




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


Re: Tkinter: The good, the bad, and the ugly!

2010-12-30 Thread Gerry Reno
For those that are lurking, this might provide a little background:

http://journal.dedasys.com/2010/03/30/where-tcl-and-tk-went-wrong



Essentially, there is nothing "wrong" with Tcl and Tkinter.  They are
part of a long evolutionary chain of how we got to where we are today. 
They deserve to be respected for the contributions that they have made. 

The question now is whether Python needs to evolve its own GUI toolset.


Regards,
Gerry


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


Re: Tkinter: The good, the bad, and the ugly!

2010-12-29 Thread Gerry Reno
wxPython looks good but I don't see anyone developing support for things
like smartphones.

Also, what do you think about frameworks such as pyjamas?  It lets you
write in python and compiles everything down to Javascript so it can be
used across the Web as well as on the desktop. 
 

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


Re: Added Python, WSGI to XAMPP

2010-12-18 Thread Gerry Reno
On 12/17/2010 02:36 PM, Daniel Fetchinson wrote:
>>>>>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>>>>>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>
>>>>
>>>> Maybe, if there's no Zope.  Or we'll run away screaming...
>>>
>>> That is rather pathetically true...
>>>
>>> Ah well, each to their own...
>>>
>>> Chris
>>>
>> What I really don't like right off is that Pyramid is contorting the MVC
>> model just as Django did with their MTV model.  They are both making the
>> controller be the view and this confuses the hell out of people who come
>> from true MVC based projects.
>>
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.  The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code that is then fed to the engine
>> that then creates the view.  And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>
> In turbogears that is exactly what happens.
>
> Cheers,
> Daniel
>
>
>


How-To: Add VirtualEnv and TurboGears2 (WSGI frmwk) to XAMPP
http://www.apachefriends.org/f/viewtopic.php?f=17&t=43207


-Gerry

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


Re: Added Python, WSGI to XAMPP

2010-12-16 Thread Gerry Reno
On 12/16/2010 04:36 AM, Octavian Rasnita wrote:
> From: "Ian Kelly" 
>
> On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno  wrote:
>   
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser. 
>> 
> Why only to the user's browser? A web app could also offer the results in 
> formats that can be accessed with something else than a browser. The view 
> just offer the results, no matter what way.
>
>   
>> The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code that is then fed to the engine
>> that then creates the view. And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>> 
>   
>> In traditional MVC, the controller is the part that receives the user
>> input, decides how to react to it, and instructs the model to update
>> itself accordingly.  It is not supposed to be some sort of
>> intermediary between the model and the view, as many people seem to
>> make it; the view is supposed to gather the data it needs to render
>> itself directly from the model.  
>> 
> How can the view know what data it should render if the controller doesn't 
> inform it about it?
> It is less important if the view uses a smart templating system that doesn't 
> need to ask the controller for data but can access the model directly, but 
> the view or that templating system need to be informed by the controller what 
> data need to ask from the model, so we can say that the intermediary is still 
> the controller.
>
> And accessing the model directly from the view/templating system is not a 
> good idea, because MVC is also prefered because it decouples the programming 
> code and the web design, and in some cases it can be a security issue if the 
> web designer that might not know programming would be able to change by 
> mistake or with intention the code from the view/templating system that 
> access the model.
>
>   
>> In that light, I think that this
>> 
> quote from the Django FAQ is defensible:
>
>   
>>> In our interpretation of MVC, the “view” describes the data that gets 
>>> presented to the user. It’s not necessarily how the data looks, but which > 
>>> data is presented. The view describes which data you see, not how you see 
>>> it. It’s a subtle distinction.
>>>   
> But if the view doesn't decide how the data looks, who decide it? :-)
>
>   
>> Traditionally, the view would describe both of these things, but since
>> "how you see it" is ultimately decided by the user's browser, they are
>> fundamentally separated in the context of the web.  The Django
>> template-view split is in recognition of this fact.
>> 
> The same data can have any format that's not decided by the user browser. For 
> example it can be displayed in .csv format, or .xls, or .xlsx, or .pdf, or 
> .html, or it can be submitted by email, or sent to Twitter or another web 
> site...
>
>
>   
>> As for where the controller went, there are basically two decisions
>> that need to be made when input is received: how to update the model
>> as a result, and what data should be displayed next.  The former
>> decision belongs to the controller, the latter to the view.  
>> 
> The update of the model depends on the model and the display of results 
> depends on the view. But the decision is controlled by the... controller. 
> That's why it has that name, because it controls these things.
> Of course, the frontiers between the M and V and C might be subtle in some 
> cases, but it is a good idea to push as much logic to the base. It is not a 
> good idea to make the controller do the job of the model and imply in the 
> business logic or make the view do the job of the controller and do something 
> else than just present the data it receives.
>
>   
>> But in a
>> web app, these two things tend to be highly correlated, and there
>> seems to be little reason to separate them out into distinct
>> components.  This part then is both controller and view, and which
>> word we use for it is not terribly important.  
>> 
> Yes, but in that case such a program wouldn't use the MVC model. And as I 
> exemplified above, there are reasons why the view should only present the 
> data it receives and don't access the model directly. Some web developers 
> aren't even alowed to offer the ORM objects to the templates, although the 
> coding would be much easier that way, but need to generate other obj

Re: Added Python, WSGI to XAMPP

2010-12-15 Thread Gerry Reno
On 12/15/2010 07:36 PM, Ian Kelly wrote:
> On Mon, Dec 13, 2010 at 5:58 PM, Gerry Reno  wrote:
>   
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.  The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code that is then fed to the engine
>> that then creates the view.  And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>> 
> In traditional MVC, the controller is the part that receives the user
> input, decides how to react to it, and instructs the model to update
> itself accordingly.  It is not supposed to be some sort of
> intermediary between the model and the view, as many people seem to
> make it; the view is supposed to gather the data it needs to render
> itself directly from the model.  In that light, I think that this
> quote from the Django FAQ is defensible:
>
>   
>> In our interpretation of MVC, the “view” describes the data that gets 
>> presented to the user. It’s not necessarily how the data looks, but which 
>> data is presented. The view describes which data you see, not how you see 
>> it. It’s a subtle distinction.
>> 
> Traditionally, the view would describe both of these things, but since
> "how you see it" is ultimately decided by the user's browser, they are
> fundamentally separated in the context of the web.  The Django
> template-view split is in recognition of this fact.
>
> As for where the controller went, there are basically two decisions
> that need to be made when input is received: how to update the model
> as a result, and what data should be displayed next.  The former
> decision belongs to the controller, the latter to the view.  But in a
> web app, these two things tend to be highly correlated, and there
> seems to be little reason to separate them out into distinct
> components.  This part then is both controller and view, and which
> word we use for it is not terribly important.  I suppose that "view"
> tends to prevail since there are other components, such as URL
> dispatch, that are controllerish in nature.
>
> For these reasons, I find that in practice traditional MVC does not
> lend itself well to the HTTP request/response cycle, where the "view"
> as you define it has no access to the model and lacks any continuity
> whatsoever from one request to the next; but the Django MTV approach
> works just fine once you're willing to accept that it's not the same
> thing.
>
> Cheers,
> Ian
>
>   

Django can use whatever approach they like.  But don't call it an MVC
framework and that is what they did initially at least.  MTV is a
contorted MVC.  And it does not correlate very well with other MVC
documentation which is very confusing to people.

No doubt, the web is constraining.  Request/response makes it difficult
to have the Model independently notify the View that it needs to update
itself because some state in the model has changed.  That is why many of
the diagrams about MVC on the web show the Controller interceding
between the View and the Model.  That doesn't mean MVC does not work on
the web.  It just means that there is a constraint imposed by the nature
of the request/response stateless architecture. 

Maybe it's splitting hairs, but having things named 'View' on the server
implies especially to newbies that the View exists on the server.  The
View exists on the client.  And then later they discover that it's not
really View but Controller and that Templates are View.   I guess if we
were screen-scraping we could actually have a server-side View.  But
normal MVC has the View on the client, and the Model and Controller in
server capacities.  And I don't see the value in naming things View on
the server when for the most part the View (or view parts in the case of
Ajax) are merely the output of render processes.

-Gerry




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


Pyramid and MVC (split from: Re: Added Python, WSGI to XAMPP)

2010-12-15 Thread Gerry Reno
On 12/15/2010 05:03 PM, Chris Withers wrote:
> On 14/12/2010 00:58, Gerry Reno wrote:
>> What I really don't like right off is that Pyramid is contorting the MVC
>> model
>
> That specific pattern, I'm afraid, is a little antiquated nowadays,
> particularly when it comes to web apps...
>
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.
>
> Yep, and in Pyramid I guess this would be the template renderer, which
> is usually a decorator on the view function or class. The view's job
> is to process a request and turn it into a response dictionary. That
> sounds a lot like your controller to me ;-)
>
>> The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code
>
> Slightly scared as to what "constructed the python code" might mean :-S
>
>> that is then fed to the engine
>> that then creates the view.  And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>
> Well, for me, the MVC isn't really what happens anymore, here's my take:
>
> - the model nowadays has all the "business logic" in it, rather than
> just the data. The model is now a collection of objects that can be
> interacted on through many/any UIs needed, some of which may be web apps.
>
> - web apps are *always* a collection of request/response transactions.
> As such, the "control" layer does just become a "view" that does that.
>
> - singleton objects and other stuff that used to live in a "control"
> are now factored out into utilities and services (of which
> zope.component provides a pretty good abstraction, and doesn't really
> have anything to do with Zope, other than the fact that Zope makes use
> of it).
>
> Welcome to the 2nd decade in the new millenium ;-)
>
> Chris
>


It doesn't matter whether you are building a desktop app or a webapp. 
MVC still applies.  And that includes when things like Ajax are added to
the mix because Ajax just performs a mini-MVC transaction.  The problems
arise when people start rigidly thinking that M only meant database.  M
means model, model means any source that emits data.  A database,
another webapp, whatever, that is M.  The view as I said before is just
the bits streaming out of the webserver back to the client device. 
There should be NOTHING on the server call view-anything.  The view only
exists on the clients.  The view is the result of what the
controllers(servers) in conjunction with renderers emit as their work
product.

-Gerry


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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 11:13 PM, rusi wrote:
> On Dec 10, 2:29 am, Gerry Reno  wrote:
>   
>> If you have any need of a portable LAMP stack, I just finished writing
>> some How-To's for getting Python, VirtualEnv and WSGI frameworks running
>> with XAMPP:
>>
>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>
>>
>> How-To: Add VirtualEnv and Django (WSGI framework) to XAMPP
>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42992>
>>
>> How-To: Add Python and mod_wsgi to XAMPP
>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42975>
>>
>> -Gerry
>> 
> What does XAMPP give (on linux) that the distro apache,mysql dont?
>   

It is a portable LAMP stack that is basically independent of your distro. 

If you want to upgrade PHP or Apache or whatever without disturbing your
distro PHP or Apache you can do this. 

If you want to try out cutting edge releases of things you can do this
on XAMPP without bothering your distro. 

It's an environment and what you can do with it is only limited by your
imagination.


-Gerry


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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 07:12 PM, Chris Withers wrote:
> On 14/12/2010 00:14, Gerry Reno wrote:
>> On 12/13/2010 06:34 PM, Chris Withers wrote:
>>> On 09/12/2010 21:29, Gerry Reno wrote:
>>>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>>>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>
>>
>> Maybe, if there's no Zope.  Or we'll run away screaming...
>
> That is rather pathetically true...
>
> Ah well, each to their own...
>
> Chris
>
What I really don't like right off is that Pyramid is contorting the MVC
model just as Django did with their MTV model.  They are both making the
controller be the view and this confuses the hell out of people who come
from true MVC based projects.

The VIEW is the bits that stream out of the webserver back to the users
browser.  The CONTROLLER is the code that gathers all the pieces from
the model and constructs the python code that is then fed to the engine
that then creates the view.  And just because the controller navigates
the logic to dynamically contruct/render a view, that does not make 'it'
the view.

-Gerry

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


Re: Added Python, WSGI to XAMPP

2010-12-13 Thread Gerry Reno
On 12/13/2010 06:34 PM, Chris Withers wrote:
> On 09/12/2010 21:29, Gerry Reno wrote:
>> How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
>> <http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>
>
> You mean Pyramid, right? ;-)
>
> Chris
>

Maybe, if there's no Zope.  Or we'll run away screaming...

Anyway, Pyramid is still only alpha.  But if it is a true WSGI framework
then as my technique shows it can certainly be made to work with XAMPP.


-Gerry


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


Added Python, WSGI to XAMPP

2010-12-09 Thread Gerry Reno
If you have any need of a portable LAMP stack, I just finished writing
some How-To's for getting Python, VirtualEnv and WSGI frameworks running
with XAMPP:

How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>

How-To: Add VirtualEnv and Django (WSGI framework) to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42992>

How-To: Add Python and mod_wsgi to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42975>


-Gerry

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


Re: A web site using Python

2010-12-06 Thread Gerry Reno
If you have any need of a portable LAMP stack, I just finished writing
some How-To's for getting Python, VirtualEnv and WSGI frameworks running
with XAMPP:

How-To: Add VirtualEnv and Pylons (WSGI framework) to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42981>

How-To: Add VirtualEnv and Django (WSGI framework) to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42992>

How-To: Add Python and mod_wsgi to XAMPP
<http://www.apachefriends.org/f/viewtopic.php?f=17&t=42975>


-Gerry





On 12/06/2010 07:42 PM, Alice Bevan–McGregor wrote:
>> 1. Pick a web framework, I'd suggest looking at:
>>
>>Django (http://www.djangoproject.com/)
>>
>>Pyramid (http://docs.pylonshq.com/pyramid/dev/)
>
> I'm biased, but I can highly recommend WebCore
> (http://www.web-core.org/) as it more easily supports small to
> mid-sized applications and actively encourages the use of standard
> Python idioms.
>
> A reasonable example (though it was hurried) would be the codebase
> behind tsatimeline.org:
>
> https://github.com/GothAlice/TSA-Timeline
>
> The important files are application.py (controllers), model.py (data
> model), and the templates (views) folder.  (The public folder is where
> CSS/JS/images go.)  Similar to Stef's comment on web2py, development
> with WebCore (or web2py, or WebPy, or… basically any micro-framework)
> is extremely rapid.
>
> — Alice.
>
>

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


Re: Strange factory pattern

2010-06-22 Thread Gerry Reno

This looks like a public class exposing an implementation private class.Jun 22, 2010 10:39:05 PM, zac...@gmail.com wrote:In the threading module there are several code bits following this convention:###def Class(*args, **kwargs):    return _Class(*args, **kwargs)class _Class(...###This is true for Event, RLock, and others.
Why do this? It seems to violate the rule of least astonishment (isinstance(Event(), Event) raises an exception). I assume there must be some trade-off that the designer intended to achieve. So, what is that trade-off and when should I follow this in my code?
--Zachary Burns(407)590-4814Aim - Zac256FLProduction EngineerZindagi Games
-- http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting up arrow in terminal to scroll thought history of python commands

2010-06-13 Thread Gerry Reno

sounds like your keymapping got messed with.you could just:set -o vipythonESC, Ctrl-jand now ESC-k and ESC-j will take you back and forth in history (std vi editing)-GerryJun 13, 2010 07:22:40 PM, vinc...@vincentdavis.net wrote:I just installed 2.6 and 3.1 from current maintenance source on MacOSx. When I am running as an interactive terminal session the up arrowdoes not scroll thought the history of the py commands I have enteredI just get ^[[A. When I install from a compiled source it works fine.Whats the fix for this?ThanksVincent-- http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: getting up arrow in terminal to scroll thought history of python commands

2010-06-13 Thread Gerry Reno

These command just allow you to use 'vi editing mode' within python.  If you've ever navigated a file with vi to go up and down the document you'll immediately know how it works.-GerryJun 13, 2010 07:39:35 PM, vinc...@vincentdavis.net wrote:On Sun, Jun 13, 2010 at 5:28 PM, Gerry Reno  wrote:> sounds like your keymapping got messed with.>> you could just:> set -o vi> python> ESC, Ctrl-j> and now ESC-k and ESC-j will take you back and forth in history (std vi> editing)This is done within python? Let make sure I am clear. This is only anissue within the interactive python for the python dist I have builtfrom source not other pythons or terminal in general. I look into thecommands you suggested more but ESC-k and ESC-j don't sound veryappealing to me.ThanksVincent>> -Gerry>>>> Jun 13, 2010 07:22:40 PM, vinc...@vincentdavis.net wrote:>> I just installed 2.6 and 3.1 from current maintenance source on Mac> OSx. When I am running as an interactive terminal session the up arrow> does not scroll thought the history of the py commands I have entered> I just get ^[[A. When I install from a compiled source it works fine.> Whats the fix for this?>> Thanks> Vincent> --> http://mail.python.org/mailman/listinfo/python-list>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing plain text with exact positioning on Windows

2010-01-06 Thread Gerry
If this is, by any chance, an HP printer, the printer may support PCL
5 (or a similar language).  I've written PCL scripts (in Pascal, so a
while ago) to precisely print points at the printer resolution (i.e.,
I picked which six-hundredth of an inch in height and width dimensions
to print a dot. PCL 5 absolutely would let you put text anywhere you
wanted, including the absolute limits on margins that the hardware
supports.  (PCL is printer control language).

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


Re: Command line arguments??

2009-11-17 Thread Gerry
On Nov 17, 2:26 pm, Nobody  wrote:
> On Mon, 16 Nov 2009 23:30:09 +, Rhodri James wrote:
> > Quote the filenames or escape the spaces:
>
> > C:\Python26\Python.exe C:\echo.py "C:\New Folder\text.txt"
>
> > We've been living with this pain ever since windowed GUIs encouraged users  
> > to put spaces in their file names (Apple, I'm looking at you!).  
> > Fundamentally, if people want the pretty they have to live with the  
> > consequences.
>
> We've been living with much worse ever since Unix allowed users to put
> not only spaces but even newlines in their filenames.
>
> At least, those of us who prefer "works" over "sort of works most of the
> time" have.
>
> Then Python 3 decides to pretend that argv and environ and stdin contain
> text rather than bytes, thereby ensuring that Python 2 will outlive Python
> 3.

How about this:

lastarg = " ".join(sys.argv[2:])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My own accounting python euler problem

2009-11-10 Thread Gerry
On Nov 8, 2:42 pm, Ozz  wrote:
> vsoler schreef:
>
And, of course, you'd want to take a look a this:  http://xkcd.com/287/

Gerry
>
> > Instead of subsets, do you mean permutations/combinations?  Since 2
> > invoices can have the same amount perhaps the terms permutation is
> > better.
>
> As some other poster already suggested 'powerset' 
> (http://en.wikipedia.org/wiki/Power_set) may be a better name, except
> for those duplicates, of course. On the other hand, I think viewing it
> as a powerset is the most 'natural' in this case. (imo permutations are
> about the order of objects, not about whether the objects are included
> in a set or not)
>
> cheers,
> Ozz

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


win32api install problem

2009-07-20 Thread Gerry
I'm running Python 2.6 under XP.

I've installed Windows 32 extensions for Python 2.6 version 1.4
(pywin32-214.win32-py2.6.exe).

But If I try to import win32api, I get:

  File "C:\python_projects\euler\driveletters.py", line 1, in 
import win32api
ImportError: DLL load failed: The specified module could not be found.

\Python26\Lib\site-packages has:

03/23/2009  08:35 AM  win32
07/20/2009  09:08 AM  win32com
02/18/2009  01:21 PM  win32comext

Can anyone offer a suggestion?

Thanks,

Gerry


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


Re: Distutils, bdist_XXX, rpmbuild issues

2009-01-07 Thread Gerry Reno

Ben Finney wrote:

Gerry Reno  writes:

  

We have an application, foo-5.0.0, and we want to put out some
pre-release candidates for testing, so we set the version to
"5.0.0_rc1" in setup.py.



That's where your problems start (as you no doubt surmised). If you
want version numbers to compare in a certain order, you should name
them so that the version string will trivially compare in that order.
  
In many instances we don't get to make that decision when we join 
projects already in motion.  Otherwise, I would not have bothered to 
post the problem to the list.  The fact is that many applications use 
version string constructs such as I illustrated, "5.0.0_rc1" when they 
create their release candidates.  And yes, the final release, "5.0.0", 
is not lexically superior.  But, as much as I might like that everyone 
would not do this, I cannot change the whole world which has developed a 
habit of such things.  So I am looking for a solution that works with 
the world as it is.


Regards,
Gerry

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


Distutils, bdist_XXX, rpmbuild issues

2009-01-07 Thread Gerry Reno
I've been trying to use the "built distribution" distutils commands such 
as bdist_rpm to create distro-specific packages for python applications 
but I'm running into some thorny issues specifically with pre-release 
versioning of source distributions and built distributions and how to 
get a "final" release to update these pre-release distributions.


For example:

We have an application, foo-5.0.0, and we want to put out some 
pre-release candidates for testing, so we set the version to "5.0.0_rc1" 
in setup.py.


We create the source distribution with:
$ python setup.py sdist
which creates a source archive, foo-5.0.0_rc1.tar.gz.

We extract this archive and 'cd' into the foo-5.0.0_rc1 directory and 
create a built distribution with:

$ python setup.py bdist_rpm
which creates source and binary RPMS in the form:  
foo-5.0.0_rc1-1.noarch.rpm.


So we think everything is fine.  Everyone installs and tests using the 
pre-release candidate and subsequent candidates but when you eventually 
get to the final release, foo-5.0.0, and build your final release RPMS, 
foo-5.0.0-1.noarch.rpm, you find that it will not update your last 
pre-release candidate RPM, foo-5.0.0_rcX-1.noarch.rpm because it is not 
"rpm newer".


So I've been working on this for a while but have not found a good way 
to do this by setting options in a setup.cfg file.  It seems like for 
RPM purposes we have to keep the version to "5.0.0" and set "release" to 
"0_rcX" for the pre-release candidates and this will work for RPM 
purposes but then "sdist" does not generate the correct tarball names 
for each pre-release candidate.  It always generates foo-5.0.0.tar.gz.


Has anyone managed to solve this issue or is distutils in need of some 
enhancement.  We need the "sdist" command to generate distinct 
pre-release candidate tarball names.  And we need the "bdist_XXX" 
commands to generate distro-specific package naming such that the 
pre-release candidate packages can be updated by the final release package.



Regards,
Gerry

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


Re: Why not Ruby?

2009-01-02 Thread Gerry Reno
There's been almost 50 responses to this rubbish post. Could you please 
all stop!

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


Re: Dictionary bidirectional

2008-07-14 Thread Gerry
If keys and values are unique, maybe just store both in the same
dictionary:

   mydict[a] = b
   mydict[b] = a

   ...

   Gerry

On Jul 14, 8:31 am, Impotent Verse <[EMAIL PROTECTED]> wrote:
> If keys and values are unique you could do this...
>
> --
>
> #         Left      : Right
> roman = { "One"     : "I",
>           "Two"     : "II",
>           "Three"   : "III",
>           "Four"    : "IV",
>           "Five"    : "V",
>           "Six"     : "VI",
>           "Seven"   : "VII",
>           "Eight"   : "VIII",
>           "Nine"    : "IX",
>           "Ten"     : "X" }
>
> left, right = zip( *roman.items() )
> left = list(left)
> right = list(right)
>
> print left[ right.index("VIII") ]
>
> --
>
> ... result is "Eight".
>
> Hmmm! zip returns tuples, which need to be turned into lists to do
> much with. Maybe not the best solution in this case.
>
> Verse.

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


Re: How to make python scripts .py executable, not bring up editor

2008-07-09 Thread Gerry
And if you've gotten this far, why not take the next step:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/476204

and just type tryme (as opposed to tryme.py)

Gerry

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


Re: Converting a simple python script to a simple windows executable

2008-06-12 Thread Gerry
On Jun 12, 4:04 am, William McBrine <[EMAIL PROTECTED]> wrote:
> On Wed, 11 Jun 2008 12:25:29 -0700, geoffbache wrote:
> > (1) py2exe. This is really for when python isn't installed on the remote
> > user's machine, so it requires you to distribute a large amount of DLLs
> > etc which are part of the python installation. A bit silly when I know
> > that the remote user has python anyway.
>
> If you know the target user has Python installed, why don't you just
> distribute the .pyw file? (Use ".pyw" instead of ".py" to avoid the extra
> console window.)
>
> --
> 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 -- pass it on

I really like cx_freeze:

http://python.net/crew/atuining/cx_Freeze/
--
http://mail.python.org/mailman/listinfo/python-list


Re: artificiall, agent, movement

2008-05-12 Thread Gerry
Many city travel surveys collect source destination trip-start data;
you might be able to find one of these studies.

I think each car in your simulation should have a destination.  Then
the simulation needs a route-finder, and cars can progress along their
routes as traffic permits -- or even change routes if traffic seems
too slow.

I think if you start with a very small city -- perhaps just a 5 by 5
grid, and generate sources and destinations at intersections randomly
along the perimeter, you'll have enough to prototype all of the
building blocks.

Gerry


On May 12, 6:37 am, Iman <[EMAIL PROTECTED]> wrote:
> hi
> i'm working on some simulation project . i'm going to simulate traffic
> of a city.
> this simulation has cars , passengers , non-movable objects and
> Traffic signals  .
> i've made cars as intelligent agent . it has thinking method ,
> changing states agents ...
> the main problem is i have problem to move my agents in world .
> it would be possible to add some method to agent which move  agent in
> random  destination .
> but i'm trying to find some patterns which is designed  for this
> problems .
> is there any sample source code in python or links, docs to help me ?
>  thanks for your attention .

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


Re: pop langs website ranking

2008-04-22 Thread Gerry Ford

"Paul McGuire" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
On Apr 22, 4:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> In February, i spent few hours researching the popularity of some
> computer language websites.
>
I seem to recall this exact same post from *last* February.

--->I remember it too.  Xah is quite the self-promoter.  Massive 
cross-posters don't have anything to say for me.
-- 
"Life in Lubbock, Texas, taught me two things: One is that God loves you
and you're going to burn in hell.  The other is that sex is the most
awful, filthy thing on earth and you should save it for someone you love."

~~  Butch Hancock 


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


Open source Web testing tool - cPAMIE 1.6b released

2008-04-16 Thread Gerry Paneda
Hi Rob,

I have been watching your videos in ShowMeDo and first of all thanks - I just 
started looking at Automation again and this got me started fairly easy.  I do 
have a question though.  2.0 does not seem to have getConfig and writeScript 
from the one I downloaded from sourceforge.  I went to the user group and 
applied as member but I haven't been approved yet so I can't download the file 
you mentioned on the thread in showmedo.

Can you help me out?

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

Re: Cool JavaScript game

2008-02-02 Thread Gerry Ford

"Hoss" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I created a cool game almost entirely with Javascript and wanted to
> see what people thought. See a screenshot at
>
> http://lh6.google.com/todd.freed/R4Q_gtqjtcI/AeI/eeNq2xOBxGw/beem.jpg
>
> Its kind of a puzzle game with time-based scoring and other things.
> Check it out.
>
> http://beem.awardspace.com
>
The game was as small as the link was large.


-- 
Gerry Ford

"The apple was really a peach."
-- Allison Dunn on the garden of eden 


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


Half-Broken filetype association in XP

2008-02-01 Thread Gerry
Under XP, until yesterday, I typed a.py in a dos box and a.py ran
fine; typed a.xls and opened an excel window; typed a.doc and opened a
word Document.

Type, all of those fail - if typed in a DOS window.  They all work --
if clicked in an explorer window.

The registry looks fine (to me, fwtw):

 assoc from a Dos prompt says:

.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pys=pysFile
.pyw=Python.NoConFile

and ftype says

Python.CompiledFile="C:\Python25\python.exe" "%1" %*
Python.File="C:\Python25\python.exe" "%1" %*
Python.NoConFile="C:\Python25\pythonw.exe" "%1" %*

which all look pretty good to me.

Typing \python25\python a.py succeeds, too.

I may be the victim of a corporate software overnight push.  (And so I
have no way to back it out.)

Can anyone help me out?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: readlines() reading incorrect number of lines?

2007-12-21 Thread Gerry
Something I've occasionally found helpful with problem text files is
to build a histogram of character counts, something like this:


"""
chist.py
print a histogram of character frequencies in a nemed input file
"""

import sys

whitespace  = ' \t\n\r\v\f'
lowercase   = 'abcdefghijklmnopqrstuvwxyz'
uppercase   = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
letters = lowercase + uppercase
ascii_lowercase = lowercase
ascii_uppercase = uppercase
ascii_letters   = ascii_lowercase + ascii_uppercase
digits  = '0123456789'
hexdigits   = digits + 'abcdef' + 'ABCDEF'
octdigits   = '01234567'
punctuation = """!"#$%&'()*+,-./:;<=>[EMAIL PROTECTED]|}~"""
printable   = digits + letters + punctuation

try:
fname   = sys.argv[1]
except:
print   "usage is chist yourfilename"
sys.exit()

chars   = {}

f   = open (fname, "rb")
lines   = f.readlines()
for line in lines:
for c in line:
try:
chars[ord(c)] += 1
except:
chars[ord(c)] = 1

ords = chars.keys()
ords.sort()

for o in ords:
if chr(o) in printable:
c   = chr(o)
else:
c =  "UNP"

print "%5d %-5s %10d" % (o, c, chars[o])
print "_" * 50


Gerry



On Dec 20, 5:47 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Dec 21, 8:13 am, Steven D'Aprano <[EMAIL PROTECTED]
>
>
>
> cybersource.com.au> wrote:
> > [Fixing top-posting.]
>
> > On Thu, 20 Dec 2007 12:41:44 -0800, Wojciech Gryc wrote:
> > > On Dec 20, 3:30 pm, John Machin <[EMAIL PROTECTED]> wrote:
> > [snip]
> > >> > However, when I use Python's various methods -- readline(),
> > >> > readlines(), or xreadlines() and loop through the lines of the file,
> > >> > the line program exits at 16,000 lines. No error output or anything
> > >> > -- it seems the end of the loop was reached, and the code was
> > >> > executed successfully.
> > ...
> > >> One possibility: you are running this on Windows and the file contains
> > >> Ctrl-Z aka chr(26) aka '\x1a'.
>
> > > Hi,
>
> > > Python 2.5, on Windows XP. Actually, I think you may be right about \x1a
> > > -- there's a few lines that definitely have some strange character
> > > sequences, so this would make sense... Would you happen to know how I
> > > can actually fix this (e.g. replace the character)? Since Python doesn't
> > > see the rest of the file, I don't even know how to get to it to fix the
> > > problem... Due to the nature of the data I'm working with, manual
> > > editing is also not an option.
>
> > > Thanks,
> > > Wojciech
>
> > Open the file in binary mode:
>
> > open(filename, 'rb')
>
> > and Windows should do no special handling of Ctrl-Z characters.
>
> > --
> > Steven
>
> I don't know whether it's a bug or a feature or just a dark corner,
> but using mode='rU' does no special handling of Ctrl-Z either.
>
> >>> x = 'foo\r\n\x1abar\r\n'
> >>> f = open('udcray.txt', 'wb')
> >>> f.write(x)
> >>> f.close()
> >>> open('udcray.txt', 'r').readlines()
> ['foo\n']
> >>> open('udcray.txt', 'rU').readlines()
>
> ['foo\n', '\x1abar\n']>>> for line in open('udcray.txt', 'rU'):
>
> ...print repr(line)
> ...
> 'foo\n'
> '\x1abar\n'
>
>
>
> Using 'rU' should make the OP's task of finding the strange character
> sequences a bit easier -- he won't have to read a block at a time and
> worry about the guff straddling a block boundary.

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


exporting from twiki

2007-11-28 Thread Gerry
I have a twiki, with documentation on 200 "things".  I'd like to
export the 200 pages, with their embedded graphs, to some static
version (word, pdf, ...) that I can give to a non-connected, reference
user community to "read" - i.e., no =navigation required beyond back
and forth to a table of contents.

I've found a plug-in that exports to PDF, but (while much better than
nothing) leaves a lot to be desired.  PDF editing seems to be pretty
minimal, and I'm not sure I can order the pages as I'd like
(alphabetically by their titles, say).  If I delete a few pages, I'm
not sure I can re-generate the table of contents, and renumber the
pages (in Acrobat).

Do any of you have any tips or code on automating exports from a
twiki?

Thanks,

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


Re: Question on SPE and pwintypes.dll

2007-08-17 Thread Gerry
On Aug 17, 10:14 am, [EMAIL PROTECTED] wrote:
> On Aug 17, 8:38 am, Gerry <[EMAIL PROTECTED]> wrote:
>
> >I'm running SPE 8.3.c under XP, on a new PC.
>
> >The files for SPE and Python were copied to the new machine, but
> > the OS wasn't migrated, so the registry didn't know about either.
>
> >I reinstalled Python 2.5.1, and Python seems fine.
>
> >I made a shortcut to SPE.pyw.  Clicking on the shortcut gives an
> > error pop-up, application failed to start cannot find pwintypes.dll.
> > When I click "OK", SPE seems to start normally.
>
> >Any idea what's up?  Googling for pwintypes.dll didn't give me any
> > hits.
>
> >Gerry
>
> Probably just need to do a search in the registry of the old PC for
> SPE or that dll file and then make the appropriate changes on your new
> PC. Or just reinstall SPE.
>
> Mike

Thanks -- I'll give that a try.

Gerry

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


Question on SPE and pwintypes.dll

2007-08-17 Thread Gerry
   I'm running SPE 8.3.c under XP, on a new PC.

   The files for SPE and Python were copied to the new machine, but
the OS wasn't migrated, so the registry didn't know about either.

   I reinstalled Python 2.5.1, and Python seems fine.

   I made a shortcut to SPE.pyw.  Clicking on the shortcut gives an
error pop-up, application failed to start cannot find pwintypes.dll.
When I click "OK", SPE seems to start normally.

   Any idea what's up?  Googling for pwintypes.dll didn't give me any
hits.

   Gerry

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


Re: file reading anomaly

2007-07-06 Thread Gerry
Final update: problem solved.  In the big script, the snippet was
reading depstats.txt which hadn't been closed.

Sorry for all the bother.

Gerry

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


Re: file reading anomaly

2007-07-06 Thread Gerry
Update:

   The PC seems to not be a factor (same problem exist on two PCs).

   The entire script does some computation and writes depstats.txt.
The code snippet below attempts to read depstats.txt and write another
file.  When the code below is run stand-alone, it succeeds.  When run
in-line as part of the program that wrote depstats.txt, there are
three possible outcomes:

it stops reading after 4096 bytes (not counting \r's); no error
messages
it stops reading after 8192 bytes (not counting \r's); no error
messages
or it succeeds.

The first two are much more likely.

Trying buffersize parameters of -1, 0, 1, 1000, 8192, 16384 in the
open call for m all had no apparent effect.

Any ideas what could possibly be wrong earlier to cause this?


m   = open("depstats.txt","r", 2)
n   = open("newds.txt",   "w")

linesout= 0
bytes   = 0

for line in m:
bytes   += len(line)
print   len(line), len(line.split()), bytes
t   = line.split()
if len(t) < 13:
print "not enough fields, only", len(t)
print t
sys.exit()
while len(t) < 43:
t.append(0)
t.append("F2")
t   = [str(x) for x in t]
print   >> n, " ".join(t)
    linesout+= 1

print "linesout", linesout

m.close()
n.close()



On Jul 6, 12:48 pm, Gerry <[EMAIL PROTECTED]> wrote:
> Python 2.5, Windows XP.
>
> I have a 48-line text file written by a Windows python script,
>
> I try to read it as follows:
>
> f   = open ("depstats.txt", "r", 0)

> for index, line in enumerate(f):
> print index, len(line), len(line.split())
> f.close()
>
> On one PC, this runs without any problem.
>
> On another, it appears to succeed (no run-time errors) but does not
> read all the lines.  If I print the lines and sum of the line lengths
> so far inside the loop, the program can be seen to have only read the
> first N bytes, where N is either 4096, or 8192.
>
> Any ideas?
>
> Thanks,
>
> Gerry




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


file reading anomaly

2007-07-06 Thread Gerry
Python 2.5, Windows XP.

I have a 48-line text file written by a Windows python script,

I try to read it as follows:



f   = open ("depstats.txt", "r", 0)
for index, line in enumerate(f):
print index, len(line), len(line.split())
f.close()

On one PC, this runs without any problem.

On another, it appears to succeed (no run-time errors) but does not
read all the lines.  If I print the lines and sum of the line lengths
so far inside the loop, the program can be seen to have only read the
first N bytes, where N is either 4096, or 8192.

Any ideas?

Thanks,

Gerry

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


Re: Unicode in Excel files

2007-03-21 Thread Gerry
On Mar 21, 6:07 am, "John Machin" <[EMAIL PROTECTED]> wrote:
> On Mar 21, 11:37 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
>
> > On Tue, 2007-03-20 at 16:47 -0700, Gerry wrote:
> > > I'm still mystified why:
> > >qno was ever unicode,
>
> > Thus quothhttp://www.lexicon.net/sjmachin/xlrd.html"This module
> > presents all text strings as Python unicode objects."
>
> And why would that be? As the next sentence in the referenced docs
> says, "From Excel 97 onwards, text in Excel spreadsheets has been
> stored as Unicode."
>
> Gerry, your "Q1" string was converted to Unicode when you wrote it
> using pyExcelerator's Worksheet.write() method.
>
> HTH,
> John

John,

   That helps a lot.  Thanks again!

   Gerry

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


Re: mysterious unicode

2007-03-20 Thread Gerry
On Mar 20, 7:29 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Tue, 20 Mar 2007 19:35:00 -0300, Gerry <[EMAIL PROTECTED]>
> escribió:
>
Thanks! - that helps a lot.

I'm still mystified why:
   qno was ever unicode, and why
   qno.encode("ascii", "replace") is still unicode.

Gerry




>
>
> py> qno = u"Q1"
> py> qno
> u'Q1'
> py> print qno
> Q1
> py> print (qno,2)
> (u'Q1', 2)
>
> --
> Gabriel Genellina




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


mysterious unicode

2007-03-20 Thread Gerry
I'm using pyExcelerator and xlrd to read and write data from and to
two spreadsheets.

I created the "read" spreadsheet by importing a text file - and I had
no unicode aspirations.

When I read a cell, it appears to be unicode u'Q1", say.

I can try cleaning it, like this:


try:
s.encode("ascii", "replace")
except AttributeError:
pass


which seems to work.  Here's the mysterious part (aside from why
anything was unicode in the first place):

print >> debug, "c=", col, "r=", row, "v=", value,
"qno=", qno
tuple = (qno, family)
try:
data[tuple].append(value)
except:
data[tuple] = [value]
print >> debug, "!!!", col, row, qno, family, tuple,
value, data[tuple]

which produces:

c= 1 r= 3 v= 4 qno= Q1
!!! 1 3 Q1 O (u'Q1', 'O') 4 [1, u' ', 4]

where qno seems to be a vanilla Q1, but a tuple using qno is
(u'Q1', ...).

Can somebody help me out?

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


PyExcelerator: how to set colours?

2006-12-22 Thread Gerry
I'd like some cell to be a Blue "ABCDE".

Here's come code thatv tries various values for pattern_for_colour and
font.colour_index, to no avail.

Can anyone suggest the right way to set colours?

Thanks!

Gerry

==

from pyExcelerator import *

w   = Workbook()
ws  = w.add_sheet('alpha')

style   = XFStyle()
fore_colour = style.pattern.pattern_fore_colour
back_colour = style.pattern.pattern_back_colour

ws.write (1, 1, "fore_colour")
ws.write (1, 2, fore_colour)

ws.write (2, 1, "back_colour")
ws.write (2, 2, back_colour)

text= "ABCDE"

row = 5



for offset in range(-32,512):

row += 1

style.font.colour_index = fore_colour + offset

ws.write(row,3, fore_colour + offset, style)

ws.write(row,5,text,style)

style.pattern.pattern_fore_colour = fore_colour + offset

ws.write(row,6,text,style)

w.save('test.xls')

=

shows no colour variation for any of these values of offset.

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


Re: pyExcelerator question

2006-12-19 Thread Gerry

Thanks!!!

Looks great.  Works for me.  I'll try to submit the patch.

Gerry

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


pyExcelerator question

2006-12-18 Thread Gerry

I'd like to word wrap some cells, but not others, in an Excel
spreadsheet, using pyExcelerator and Excel 2003, SP1, under XP.

The code below creates the spreadsheet, but both cells are
word-wrapped.

As far as I can tell, the second call to XFStyle() overwrites a GLOBAL
wrap setting, and affects even cells written before the call to
XFStyle.

Can anyone shed any light?

Thanks,

Gerry


from pyExcelerator import *


w   = Workbook()
ws  = w.add_sheet("alpha")

style   = XFStyle()
style.alignment.wrap= Alignment.NOT_WRAP_AT_RIGHT
ws.write(1,1,"Not wrapped" + "-" * 50, style)

style2   = XFStyle()
style2.alignment.wrap= Alignment.WRAP_AT_RIGHT
ws.write(2,1,"Wrapped" + "-" * 50, style2)

w.save("test.xls")

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


Re: Newbie Cygwin Q

2006-08-02 Thread Gerry Blais

Sorry - problem solved.

My #!/usr/Pyrthon2.4.exe was inadvertently on line 2...

Gerry

On Wed, 02 Aug 2006 13:04:10 -0400, Gerry Blais
<[EMAIL PROTECTED]> wrote:

>I'm trying to install and run, on XP,  a queueing analysis package,
>PDQ, which has a{ Python, swig, C library version}.
>
>I'm new to Cygwin (but not to Unix).
>
>After installing Cygwin and Python, there is a Python2.4.exe in /lib.
>
>If I have a file with
>
>#!/lib/Python2.4.exe
>
>Print "hello"
>
>and I do the chmod, and submit  ./hello.py
>
>I get a message "hello.py is currently being printed" and nothing
>happens, until I give up and ^C out.
>
>or, now, with no changes I can see, 
>
>Can't find file hello
>
>What am I missing?
>
>Thanks,
>
>Gerry
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie Cygwin Q

2006-08-02 Thread Gerry Blais
I'm trying to install and run, on XP,  a queueing analysis package,
PDQ, which has a{ Python, swig, C library version}.

I'm new to Cygwin (but not to Unix).

After installing Cygwin and Python, there is a Python2.4.exe in /lib.

If I have a file with

#!/lib/Python2.4.exe

Print "hello"

and I do the chmod, and submit  ./hello.py

I get a message "hello.py is currently being printed" and nothing
happens, until I give up and ^C out.

or, now, with no changes I can see, 

Can't find file hello

What am I missing?

Thanks,

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


windows paging Q

2005-11-29 Thread Gerry Blais
I'm running a Python program (1000 by 1000 grid, all source shortest
path, running time currently in days)  in Python 2.4 under XP. 

System memory usage according to the task manager is steady at 500 MB
out of 1 GB physical memory.  


My program has a memory usage of 30 MB according to the task manager,
and is doing 1000+ page faults / second (page fault delta, high speed
refresh rate).  

With memory available, any idea why I'm paging so much, and what I
might do about it?

The Python script's getting 97%+ CPU use according to the TM - maybe
that suggests  paging is not a factor in elapsed time, anyway?

Tx,

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


Python <=> Excel question

2005-09-30 Thread Gerry Blais

Newbie questions:

Suppose abc.xls has sheets a, b, c.

How can I find, in Python, the sheet names?

Given a sheet name, how can I export the sheet as a csv file?

Finally, how can I, in Python, make a .txt version of a Word document?

Thanks,

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


Problem when subclass instance changes base class instance variable

2005-04-15 Thread Gerry Sutton
Hi All!

I have noticed a strange behavior when using a constant identifier to 
initialize an instance list variable in a base class and then trying to 
modifying the list in subclasses by using either the list.extend method or 
even by having the subclass create a whole new list in the variable.

The following example illustrates the situation.



Lbase = ['Initial Base Data']

LSub1 = ['SubClass 1 data']

LSub2 = ['SubClass 2 data']



##

class BaseClass:



def __init__(self):

   self.data = Lbase #<  this fails??

#  self.data = ['Initial Base Data'] #<  this works

   def printData(self):

   print self.data



##

class SubClass1(BaseClass):



  def __init__(self):

   BaseClass.__init__(self)

   self.data.extend(LSub1)

# self.data += LSub1



##

class SubClass2(BaseClass):



  def __init__(self):

BaseClass.__init__(self)

self.data.extend(LSub2)

#   self.data += LSub2



s1 = SubClass1()

s1.printData()



s2 = SubClass2()

s2.printData()



s11 = SubClass1()

s11.printData()



s21 = SubClass2()

s21.printData()

s1.printData()



>>>

['Initial Base Data', 'SubClass 1 data']

['Initial Base Data', 'SubClass 1 data', 'SubClass 2 data']

['Initial Base Data', 'SubClass 1 data', 'SubClass 2 data', 'SubClass 1 
data']

['Initial Base Data', 'SubClass 1 data', 'SubClass 2 data', 'SubClass 1 
data', 'SubClass 2 data']

['Initial Base Data', 'SubClass 1 data', 'SubClass 2 data', 'SubClass 1 
data', 'SubClass 2 data']

>>>

It looks like the instance variable is acting like a class variable with all 
the subclass changes accumulating as more objects are created.

Does anyone have an explanation for this behavior?

Are other mutable sequence types affected the same way?

To fix the problem you simply use a literal list to initialize the variable 
in the base class instead of an identifier.

This problem does not exist if the data variable is a string, maybe because 
it is immutable?

I am using Python Ver 2.3.

Does this code behave the same way in 2.4,






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