Re: Puzzled

2015-11-06 Thread Chris Gonnerman

Wendy said:

I installed Python 3.5.0 64-bit for Windows yesterday and tried some basic 
programs successfully.
This morning I rebooted my computer and can't get a single one to work.  The interpreter 
seems to be fine and the environment variables look correct.  But every py file I try to 
run at the >>> prompt gives me a NameError.
But that's not how the Python interpreter works.  You say you are trying 
to run "py files" at the >>> prompt.  If what you are doing is this:


>>> test.py

Well, no, that's not going to work.  If you want to run "test.py" as a 
script, from the CMD prompt you type:


python test.py

If test.py is a module meant to be imported, then from the Python prompt 
you do this:


import test

Hope this helps.

-- Chris.

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


Re: Shebang line on Windows?

2013-02-25 Thread Chris Gonnerman

On 02/25/2013 06:35 AM, Sells, Fred wrote:

When moving from windows to unix you need to run dos2unix   on any programs 
that use shebang (at least with python 2.6)   that is installed on some platforms but 
must be installed on others like CentOs but it is in their repository.

Or edit it in Vim and do

:se ff=unix

and then save it.

dos2unix is handy if you don't plan to edit the file for any other 
reason.  I'm assuming other editors provide similar features, but I've 
been a vi/vim user FOREVER.


Or, borrowed from a Stack Overflow thread here: 
http://stackoverflow.com/questions/800030/remove-carriage-return-in-unix


|sed 's/\r\n$/\n/' mymodule.py  mymodule-unix.py|




-Original Message-
From: Python-list 
[mailto:python-list-bounces+frsells=adventistcare@python.org] On Behalf Of 
James Harris
Sent: Friday, February 22, 2013 5:53 PM
To: python-list@python.org
Subject: [Python] Re: Shebang line on Windows?

On Feb 22, 6:40 pm, Zachary Ware zachary.ware+pyl...@gmail.com
wrote:


On Fri, Feb 22, 2013 at 12:16 PM, Walter Hurry walterhu...@lavabit.com wrote:

I use FreeBSD or Linux, but my son is learning Python and is using
Windows.
My question is this: Would it be good practice for him to put
#!/usr/bin/ env python at the top of his scripts, so that if made
executable on *nix they will be OK? As I understand it this will
have no effect on Windows itself.

Adding the shebang line on Windows would be excellent practice.

A word of warning unless this has since been resolved: Whenever I have tried 
adding the shebang line on Windows and running it on Unix the latter has 
complained about the carriage return at the end of the line. This means that 
Unix does not work when invoked as follows.
(And, yes, the file has had chmod +x applied.)

   ./program.py

It is, of course, OK when run as

   python program.py

but that removes some of the benefit of the shebang line.

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



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


Re: cannot concatenate 'str' and 'list' objects

2012-09-15 Thread Chris Gonnerman

I moved to HostGaot because i heard there were the best in the hosting
business.
They are pretty good.  However, you have to understand the site layout 
to do CGI safely.


So long as your script are .cgi, putting them in ~/public_html is fine.  
If you need to deploy .py files, you need to put them in a different 
folder outside ~/public_html, for example ~/lib or ~/python, then in 
your CGI scripts you need to add that to the path.


For example:

#!/usr/bin/python

import sys
sys.path.append(../python)

import MyModule, MyPackage.OtherModule

This is more or less how all my CGI scripts on HostGator are done.

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


Re: cannot concatenate 'str' and 'list' objects

2012-09-15 Thread Chris Gonnerman

On 09/15/2012 10:23 AM, Νικόλαος Κούρας wrote:

I swicthed back my code to:  f = open( '../' + page )

and http://superhost.gr works which means that line gets parsed correctly.

Only when i post data to the text area boxes iam getting the error:

cannot concatenate 'str' and 'list' objects

how is this possible to work before and NOT work when i enter data to the page 
for storing to the database?
You really need to add some print-type diagnostics to your script 
temporarily, just to see what you are actually getting for parameters. 
For example, put this:


print Content-type: text/plain\n

near the top so you can get a source printout, then add

print `page`

just before you attempt your open() call so you can see what the exact 
Python representation of page is. Do similarly for other problems in 
your code. Don't leave such an instrumented copy of your CGI script on 
your site for very long and you should be safe.


Also, consider using the built-in cgi traceback feature in your scripts, 
at least while you are debugging them (though you probably want to 
remove the traceback after you are in production).


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


Re: [Python] Re: PyPI question, or, maybe I'm just stupid

2012-07-30 Thread Chris Gonnerman

On 07/30/2012 04:20 AM, Dieter Maurer wrote:

CHANGES.txt is not automatically presented.
If necessary, you must integrate it into the long description.

However, personally, I am not interested in all the details (typically
found in CHANGES.txt) but some (often implicit) information is
sufficient for me: something like major API change, minor bug
fixes. Thus, think carefully what you put on the overview page.
I see your point.  I'm just lazy, I guess.  I already put a description 
of what I've changed into git, so why, I muse, must I also edit the 
overview page separately?  I was hoping there was an automatic way that 
setup.py sdist upload could handle it for me.



I find it very stupid to see several window scrolls of changes for
a package but to learn how to install the package, I have to download its
source...
Not sure I get this.  The installation procedure for PollyReports is the 
same as for, what, 99% of Python source packages?


sudo python setup.py install

What else are you saying I should do?

-- Chris.

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


Re: [Python] Re: PyPI question, or, maybe I'm just stupid

2012-07-30 Thread Chris Gonnerman

On 07/29/2012 11:00 PM, Ben Finney wrote:
Your post is showing up as a reply to a thread about IEEE-784 floats, 
because you created your message as a reply. Consequently, it's rather 
confusing why you suddenly start talking about PollyReports. If you 
want to attract attention to an unrelated topic, it's best if you 
don't reply to an existing thread; instead, start a new thread by 
composing a new message to the forum. 
My apologies.  I did not consider that headers I can't see might be 
being sent along.

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


PyPI question, or, maybe I'm just stupid

2012-07-29 Thread Chris Gonnerman
I've been making some minor updates to the PollyReports module I 
announced a while back, and I've noticed that when I upload it to PyPI, 
my changelog (CHANGES.txt) doesn't appear to be integrated into the site 
at all.  Do I have to put the changes into the README, or have I missed 
something here?  It seems that there should be some automatic method 
whereby PyPI users could easily see what I've changed without 
downloading it first.

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


Re: [Python] RE: How to safely maintain a status file

2012-07-13 Thread Chris Gonnerman

On 07/13/2012 11:00 AM, Prasad, Ramit wrote:

Well neat tricks aside, I am of the firm belief that deleting files should
never be possible whilst they are open.

This is one of the few instances I think Windows does something better
than OS X. Windows will check before you attempt to delete (i.e. move
to Recycling Bin) while OS X will move a file to Trash quite happily
only tell me it cannot remove the file when I try to empty the Trash.
While I was trained in the Unix way, and believe it is entirely 
appropriate to delete an open file.  Even if I my program is the opener. 
 It's just too handy to have temp files that disappear on their own.


As opposed to periodically going to %TEMP% and deleting them manually.  Gah.

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


RE: How to safely maintain a status file

2012-07-13 Thread Chris Gonnerman

On 07/13/2012 12:59 PM, Prasad, Ramit wrote:
I lean slightly towards the POSIX handling with the addition that any 
additional write should throw an error. You are now saving to a file 
that will not exist the moment you close it and that is probably not 
expected. Ramit
But if I created, then deleted it while holding an open file descriptor, 
it is entirely likely that I intend to write to it. I'll admit, these 
days there are those in the Unix/Linux community that consider using an 
anonymous file a bad idea; I'm just not one of them.


-- Chris.


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


Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-12 Thread Chris Gonnerman
Apparently my test hasn't kept up with my update.  I'll get it revised 
soon and make a new release.


BTW... who is Simon?  I wrote the tutorial.  (Solomoriah is an old 
handle I still use a lot since it's less common than Chris.)


-- Chris.


On 07/12/2012 03:32 AM, Johann Spies wrote:
On 12 July 2012 10:27, Johann Spies johann.sp...@gmail.com 
mailto:johann.sp...@gmail.com wrote:



I get the same error when running the example code from
Simon's tutorial (sample02 - sample07).


Thanks Simon for your tutorial.

Changing 'right = 1'  in all the example code to 'align = right '  
solved the problem.


I suspect the example code was not updated after recent changes.

Regards
Johann
--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)



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


Re: ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-12 Thread Chris Gonnerman
Wow, I posted this on Github weeks ago, and got no feedback; put it on 
PyPI at the same time, with the same results; but one day on the Python 
list and I have lots of excellent feedback.


I've just posted PollyReports 1.5.1, with no operational changes. The 
package includes a corrected testpolly.py file as well as corrected 
sample*.py files with right = 1 changed to align = 'right'.  The 
license information has been revised to include the text BSD 2-Clause 
License so that no one has to think about whether or not it's actually 
a BSD license.


If you downloaded the previous version, you don't really need the new 
one unless you're going through the tutorial.


Thanks!

-- Chris.

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


ANN: PollyReports 1.5 -- Band-oriented PDF Report Generator

2012-07-11 Thread Chris Gonnerman
I've held off announcing this until I was sure it was really stable; 
it's been 19 days since I made the last change to it, so here goes. 
PollyReports is my Python module for report generation. It is designed 
to be, quite literally, the simplest thing that can possibly work in 
the field of PDF generation from a database record set.  There is a 
somewhat vague resemblance to GeraldoReports; I had problems with 
Geraldo's pagination which led me to develop PollyReports in a brief 
flurry of intense activity.


It's on PyPI: http://pypi.python.org/pypi/PollyReports
and on Github: https://github.com/Solomoriah/PollyReports
and I have a blog where I talk about it (like anyone cares): 
http://opensource.gonnerman.org/?cat=4


Here's the README:

PollyReports.py
Copyright (c) 2012 Chris Gonnerman
All Rights Reserved
See the LICENSE file for more information. (Note: BSD licensed)
-

PollyReports.py provides a set of classes for database report writing.  
It assumes that you are using Reportlab to do PDF generation, but can 
work with any canvas-like object as desired.


PollyReports provides the following framework for report generation:

A Report object has a data source bound to it at instantiation.  One or 
more Band objects (at least, a detail Band) must be added to it, and 
then the generate() method will be called to process the data source.  
The data source
must be an iterator that produces objects that can be accessed via [] 
operations, meaning mainly dict, list, and tuple types, i.e. the most 
common types of records returned by standard database modules. The 
detail band is

generated() once for each row.

Band objects contain a list of Elements (generally at least one) which 
define how data from the row should be printed.  An Element may print 
any normal data item or label and may be subclassed to handle other 
things like images. Generating a band in turn calls Element.generate() 
for each element, producing a list of Renderers with the first item in 
the list being the overall height of the band.  The height is used to 
decide if the band will fit on the current page; if not, a new page will 
be created first.  When the page is finally ready for the band, 
Renderer.render() will be called for each Renderer in the element list 
in order to actually render the data.


As noted above, PollyReports expects a Reportlab-like canvas interface.  
The module has been kept as clean as possible, so that, though I don't 
actually recommend it, it would not be insane to say


from PollyReports import *

Importing only what you expect to use is still a better idea, of course.

--
---
Chris Gonnerman ch...@newcenturycomputers.net
Owner, New Century Computers
Phone 660-213-3822   Fax 660-213-3339

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


Re: [Python] Why I need the parameter when the call doesn't use it?

2011-08-28 Thread Chris Gonnerman

On 08/28/2011 07:26 PM, Niklas Rosencrantz wrote:

I modularize code for a webapp and I want to know what python makes that a need to define 
an argument called self? Here's some code where I'm modularizing a recaptcha test to a 
function and the I must add the parameter self to the function 
is_submitter_human:


class A(BaseHandler, blobstore_handlers.BlobstoreUploadHandler):
 def is_submitter_human(self):
is_submitter_human() isn't a function, it's a method.  Methods are 
always called with a reference to the class instance (i.e. the object) 
that the method belongs to; this reference is the first argument, and is 
conventionally called self.


Though I've hacked it out, your code sample includes calls to other 
methods of the object, by calling self.methodname().  Without the first 
parameter, how else would you do it?


-- Chris.


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


Re: [Python] Re: Windows service in production?

2011-08-18 Thread Chris Gonnerman
Chiming in late here, but I've been running a very simple Python service 
for some time now on a number of computers.  It's my Raw Print Server, 
available at 
http://newcenturycomputers.net/projects/rawprintserver.html, and I have 
instructions on the page for installing the Windows service version.  
It's really quite simple to do in plain Python; the only reason to use 
py2exe is if you don't want to install a full Python interpreter on the 
computer.  But since I generally do anyway, it doesn't matter to me.


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


Re: [Python] Re: Windows service in production?

2011-08-18 Thread Chris Gonnerman
Chiming in late here, but I've been running a very simple Python service 
for some time now on a number of computers.  It's my Raw Print Server, 
available at 
http://newcenturycomputers.net/projects/rawprintserver.html, and I have 
instructions on the page for installing the Windows service version. 
It's really quite simple to do in plain Python; the only reason to use 
py2exe is if you don't want to install a full Python interpreter on the 
computer.  But since I generally do anyway, it doesn't matter to me.


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


International translation of docs - is it a scam?

2011-06-07 Thread Chris Gonnerman
On the 30th of May, I received an email from a man (I'll leave out his 
name, but it was properly male) offering to translate the docs for the 
gdmodule (which I maintain) into Belorussian.  He wanted my approval, 
and a link from my page to his.  This seemed fair, so I told him to tell 
me when it was ready.


This morning, I received an email from him that it was done.  I looked 
at the page, and it looked good.  Of course, I don't read Belorussian, 
but it had the right shape and linked to my downloads.  But at the 
same time, I received an email with a female sender name on it.  It was 
worded almost identically to the first email, but was offering to 
translate my WConio page into Belorussian.


The Belorussian gdmodule page is here:

http://webhostingrating.com/libs/gdmodule-be

Now, webhostingrating.com is a site that rates web hosting providers, 
and at least on the surface seems legitimate.  I can't find any links 
from their front page to the section with the Belorussian 
translation(s), which strikes me odd.


What's going on here?  Has anyone else been approached by these people?

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


Re: [Python] how to tell if cursor is sqlite.Cursor or psycopg2.Cursor

2011-01-24 Thread Chris Gonnerman
You're looking at it wrong.  It doesn't matter what type of cursor it 
is, only if you can get the correct number.  So use a try...except:


try:
cursor.execute(
select last_insert_rowid()
)
except:
cursor.execute(
select currval('my_sequence')
)

That's just a quick-and-dirty example; you might need to pretty it up, 
or actually declare the type of exception you're expecting (always a 
good idea, but I didn't feel like looking up the right sqlite exception).


Good luck!
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python] How can a function find the function that called it?

2010-12-24 Thread Chris Gonnerman

On 12/24/2010 10:24 AM, kj wrote:

I want to implement a frozen and ordered dict.

I thought I'd implement it as a subclass of collections.OrderedDict
that prohibits all modifications to the dictionary after it has
been initialized.

In particular, calling this frozen subclass's update method should,
in general, trigger an exception (object is not mutable).

But OrderedDict's functionality *requires* that its __init__ be
run, and this __init__, in turn, does part of its initialization
by calling the update method.
Use a flag, private to your new class, to indicate whether 
initialization is complete or not; your update method would see that 
initialization is not yet complete when called by __init__, and so it 
would do its business (calling the class method).  At the end of the 
__init__ function, set the initialized property to true.  If your update 
is called with the initialized property already set to true, it will 
raise the exception.


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


Re: [Python] scipy code runs in empty directory, not another

2010-11-13 Thread Chris Gonnerman

On 11/13/2010 07:52 AM, Beliavsky wrote:

After installing numpy, scipy, and matplotlib for python 2.6 and
running the code from http://www.scipy.org/Cookbook/OptimizationDemo1
(stored as xoptimize.py) in a directory with other python codes, I got
the error messages

C:\python\code\mycodepython xoptimize.py
Traceback (most recent call last):
   File xoptimize.py, line 3, inmodule
 from pylab import *
   File c:\python26\lib\site-packages\pylab.py, line 1, inmodule
 from matplotlib.pylab import *
   File c:\python26\lib\site-packages\matplotlib\__init__.py, line
133, inmodule
 import sys, os, tempfile
   File c:\python26\lib\tempfile.py, line 34, inmodule
 from random import Random as _Random
   File C:\python\code\mycode\random.py, line 1, inmodule
 from RandomArray import standard_normal
   File C:\python\code\mycode\RandomArray.py, line 1, inmodule
 import ranlib
ImportError: No module named ranlib

When I create a new directory, copy xoptimize.py there, and run, the
program works. Can someone explain why other files are interfering
in the first case? Thanks.
You'd need to post a list of the files in the directory before we'd have 
any idea why this is happening.


-- Chris.

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


Re: [Python] Unsupported Format Character '' (0x26)

2010-08-19 Thread Chris Gonnerman

On 08/18/2010 06:35 PM, Andrew Evans wrote:
I get an error message Unsupported Format Character '' (0x26) I 
narrowed it down to these two variables


any idea how to fix it?

  SEARCH_URL_0 = 
http://search.yahoo.com/search;_ylt=A0oGdEf1XGxMJRoAUdml87UF;_ylc=X1MDMjE0MjQ3ODk0OARfcgMyBGZyA3NmcARuX2dwcwMxMARvcmlnaW4Dc3ljBHF1ZXJ5A3Rlc3QEc2FvAzE-?p=%(query)fr=sfpfr2=iscqry= 
http://search.yahoo.com/search;_ylt=A0oGdEf1XGxMJRoAUdml87UF;_ylc=X1MDMjE0MjQ3ODk0OARfcgMyBGZyA3NmcARuX2dwcwMxMARvcmlnaW4Dc3ljBHF1ZXJ5A3Rlc3QEc2FvAzE-?p=%%28query%29fr=sfpfr2=iscqry=
NEXT_PAGE_0 = 
http://search.yahoo.com/search;_ylt=A0oGdEEMXWxMnBAAiWhXNyoA?p=%(query)fr=sfpxargs=12KPjg1qNyy4-MkfqnfKqLCLLAhlMFta2Epstart=%(start)b=11 
http://search.yahoo.com/search;_ylt=A0oGdEEMXWxMnBAAiWhXNyoA?p=%%28query%29fr=sfpxargs=12KPjg1qNyy4-MkfqnfKqLCLLAhlMFta2Epstart=%%28start%29b=11



Not %(query)

Should be %(query)s

The 's' means string.

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


Re: [Python] favicon.ico problem

2010-08-09 Thread Chris Gonnerman

On 08/09/2010 11:32 PM, Navkirat Singh wrote:

I am having this strange problem. I have programmed a very basic 
multiprocessing webserver using low level sockets. Each time the server 
receives a request it spawns a new process to handle the request. Now when 
through a web browser I type http://localhost:8001/ it automatically creates 
two processes: One process to server the '/' path and another one to serve the 
'/favicon.ico' path. I have not programmed it to serve the latter. Infact I 
dont even know where that name '/favicon.ico' comes from. Any insight into this 
weird behavior would be greatly appreciated.
   
All modern browsers attempt to retrieve this file from any web server 
visited; it becomes the website's icon in any shortcut/deskcut, and 
appears on the address bar beside the URL.


Short answer:  You can safely ignore it.

-- Chris.

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


Re: [Python] Hashbang error

2010-06-01 Thread Chris Gonnerman

pradeepbpin wrote:

I use gVim as an editor to create python scripts on a windows machine.
To run the same script on my ubuntu machine, I added a hashbang line
to the script. Now when I run this script from command line of ubuntu,
I get a bad interpreter error, like below

/usr/bin/python^M: bad interpreter: No such file or directory

This, I understand, is due to the interpretation of newline character
at the end of the hashbang.

I have checked and found out that this does not happen if I create the
script in Ubuntu with gVim.

Now, how can I avoid this error when I create the script on a windows
machine?
  

In gvim, type:

:se ff=unix

then resave the file.  Once it's in unix format, gvim won't change it 
back to dos unless you tell it to.


-- Chris.

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


Re: [Python] Re: Printing plain text with exact positioning on Windows

2010-01-06 Thread Chris Gonnerman

KvS wrote:

Ok, actually I quite like being able to print straightforward through
your code, i.e. without any extra modules installed. I understand that
sending text to the printer is in principle as simple as

dc.TextOut(scale_factor * 72,
-1 * scale_factor * 72,
Testing...)

I didn't see you do anything with adjusting margins in the code. Does
that mean that if I would e.g. do

dc.TextOut(0,
0,
Testing...)

the printout would appear in the upper left corner of the paper, as
close to the edges as the printer is capable of? (Sorry, but I only
have Ubuntu available at the moment, no Windows).
  
Actually, as I understand it (and I'll admit my understanding is a bit 
flawed in some areas), when you tell MSWinPrint.py to print at (0, 0), 
you are telling it to print at the actual paper edge; if that's outside 
the printable area (and it probably is for most printers), your printing 
will be cut off.


Best thing to do is to try it.

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


Re: [Python] Printing plain text with exact positioning on Windows

2010-01-05 Thread Chris Gonnerman

KvS wrote:

So now I'm looking for other ways to get this printing job done. I
know of Tim Goldens page about Windows printing:
http://timgolden.me.uk/python/win32_how_do_i/print.html and have been
googling a lot, but I'm still not convinced what the best way to go
is. E.g. I can't get clear whether the combination reportlab  Acrobat
Reader allows to print very close to the left and right edge of the
paper (without a user having to change something in a Print dialog
etc.).
  

I have a page, and a module, for Windows printing which gives a lot of
control.

http://newcenturycomputers.net/projects/pythonicwindowsprinting.html

But in your case, I think I'd consider ReportLab.  Also, it seems to me
that I've seen a simpler PDF generator module for Python.  Dunno where,
though.

-- Chris.


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


Re: [Python] Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread Chris Gonnerman

KvS wrote:

... can I adjust the options normally appearing in
the Printing Dialog through Python?
  
Yes, if you use my method or my module, as I gave in my previous post.  
If you use Adobe Reader to print, I'm not sure how to automate the print 
settings.

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


Re: [Python] Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread Chris Gonnerman

KvS wrote:
Sorry, one more. I completely forgot it's not exactly plain text, but 
occasionally also a limited number of non-ASCII characters (accents in 
names etc.). Would this be possible through your method?

If Windows can print it, then MSWinPrint.py should be able to also.

But I haven't tested that extensively.  YMMV.


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


Re: os.system('cls')

2008-12-25 Thread Chris Gonnerman
Depends on what operating system you are using.  The list of possible 
commands would be unbounded, if not truly infinite.



 From: Dennis van Oosterhout [mailto:de.slotenzwem...@gmail.com]

 Hi there! I was searching for a way to clear the 'DOS screen'/command
 screen etc. and found that os.system('cls') works for this. I was just
 wondering where I can find al the commands which can be used for
 os.system(). I searched with google but I didn't find an answer. In the
 official python tutorial it says os.system('command') executes the
 command, but it doesn't say which commands exist (or I'm just blind).

 Does anyone have an answer for this question?


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


Re: [Python] Re: efficient data loading with Python, is that possible possible?

2007-12-14 Thread Chris Gonnerman
Neil Cerutti wrote:
 An inefficient parsing technique is probably to blame. You first
 inspect the line to make sure it is valid, then you inspect it
 (number of column type) times to discover what data type it
 contains, and then you inspect it *again* to finally translate
 it.
   
I was thinking just that.  It is much more pythonic to simply attempt 
to convert the values in whatever fashion they are supposed to be 
converted, and handle errors in data format by means of exceptions.  
IMO, of course.  In the trivial case, where there are no errors in the 
data file, this is a heck of a lot faster.

-- Chris.

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


Re: Clearing a DOS terminal in a script

2007-12-14 Thread Chris Gonnerman
Stephen_B wrote:
 This doesn't seem to work in a dos terminal at the start of a script:

 from os import popen
 print popen('clear').read()

 Any idea why not? Thanks.
   
As others have mentioned, you should just do:

os.system(cls)

Or, you can use my WConio module for fancier work.

http://newcenturycomputers.net/projects/wconio.html

Good luck!

-- Chris.

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


Why Python 3?

2007-12-04 Thread Chris Gonnerman
I spent some time today reading about Python 3, and specifically the 
differences between Python 3 and Python 2, and I was left with a 
question... why?  Why bother to change to Python 3, when the CPython 
implementation is slower, and probably will be for a while?

When I learned Python, 1.5 was the current version.  Each new version 
from 2.0 on brought goodies to the table... I think I have made use of 
about half of the advancements that have come along since.  But I was 
swayed into taking Python seriously by Eric Raymond's article in Linux 
Journal, where he talked about how much easier it was to read his old 
code in Python than in Perl, and how the whole white space thing wasn't 
so bad.  I discovered I agreed with him.  Python has been my favorite 
language ever since.

But... almost all of my old 1.5 code ported painlessly to 2.x.  No need 
for a 1.5to2 script, whereas I see that there is a 2to3 script for 
converting modules.  Python 1.5 and 2.x are executable pseudocode, 
something that can be easily read by anyone with a modicum of 
programming knowledge.  In fact, the things I rarely or never use in 
Python tend to be those things I find hardest to read (like list 
comprehensions).  Few of the changes along the way have required me to 
change how I *write* code; probably the worst was the integer division 
change, which I disagreed with, but I went along with the community.

I don't see myself using Python 3 for a long time.  Probably as long as 
I can hold out.  Where are my goodies?  What is my payoff for learning 
how to write code the new way?  I can't see it.  Many things seem a lot 
less obvious... like, what was wrong with dict.keys() returning a 
list?  Now it returns some strange object type.

I don't think I can surely be the only one.  Certainly, I'm nobody 
important; it's not as if my opinion has any real bearing on the 
situation.  I suspect that many Python coders will stay with 2.x; after 
all, this is Open Source... there is no Micro$oft forcing us to upgrade 
to get more licenses.  If enough people stay with 2.x... will the 
project fork?  Will there be enough of us to maintain Python 2 
indefinitely?  Will module maintainers have to choose which version of 
Python to support?  It's already a pain for me to keep the GDmodule up 
with the current Python release... and it's a pretty small module.

I just don't see the point.  I feel like we already have all we need in 
Python 2.  I feel like the language is becoming less and less friendly 
and readable as it evolves.

Just my two cents, I guess.

-- Chris Gonnerman

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


Re: Python on Vista installation issues

2007-05-24 Thread Chris Gonnerman
Okay, I've figured it out.  It's easy (but stupid)... right click the 
extension installer program, and choose Run as Administrator.

Just posting this so the next Google search for an answer might actually 
find one.

-- 
---
Chris Gonnerman [EMAIL PROTECTED]
Owner, New Century Computers
Phone 660-213-3822   Fax 660-213-3339

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


Re: Python on Vista installation issues

2007-05-23 Thread Chris Gonnerman

Mattia Gentilini wrote:

will ha scritto:
  

Vista is a 64 bit OS and there is no port of pywin32 for either Vista
or 64-bit XP


Vista exists in BOTH 32 bit and 64 bit versions.
  
Indeed, and this is running on a Core 2 Duo laptop, a 32 bit platform.  
The problem is obvious (or seems to be)... the installer for Python 
(which is a professional installer) has set the c:\python25 folder 
privileges so that the installers for the extensions (which are the 
pocket-sized installers from the distutils) can't write files in that 
folder.  The site-packages folder is evidently marked public (however 
that is done) so that the installation of files into that folder by the 
extension installers works fine.  But then, there is also a restricted 
registry key that is blocking the win32all installer from working properly.


I hate Vista.  Does anyone like it?  Okay, that's off topic, but I had 
to vent.


--
---
Chris Gonnerman [EMAIL PROTECTED]
Owner, New Century Computers
Phone 660-213-3822   Fax 660-213-3339

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

Python on Vista installation issues

2007-05-22 Thread Chris Gonnerman
I'm having errors installing Python extensions on Vista.  I'm running 
Python 2.5, and every extension install produces cannot create 
errors.  For instance, win32all 210 says:

Could Not Create: pywin32-py2.5
Could Not Set Key Value: Python 2.5 pywin32-210
Could Not Set Key Value: (followed by the uninstaller command)

Other extensions produce similar errors.  I haven't thoroughly tested 
this system yet, so I don't know if any of this is really causing a 
problem.  Can anyone tell me how to fix or avoid this problem?

-- 
---
Chris Gonnerman [EMAIL PROTECTED]
Owner, New Century Computers
Phone 660-213-3822   Fax 660-213-3339

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


Re: some suggestions about GUI toolkits?

2005-12-28 Thread Chris Gonnerman
iclinux wrote:
 I have to build a GUI applicaiton that could run on different OS such
 as windows and *nix, which GUI toolkit is better?
   
I've had good luck with both Tkinter and PyGTK.  I don't really like the 
look and feel of Tkinter, though it has gotten better over time; but 
PyGTK involves a couple of extra installs on Windows (first a GTK+ 
runtime and then the PyGTK module).  I've had a LOT of people tell me 
how great WxPython is but I've never used it.  I think it may involve 
more prerequisite installations than PyGTK but frankly I don't know.

-- Chris.


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


Re: Will python never intend to support private, protected and public?

2005-09-28 Thread Chris Gonnerman
could ildg wrote:

If private and protected is supported, python will be perfect.

Python IS perfect.  Each new release makes it MORE perfect.  :)

There are two philosophies about programming:

-- Make it hard to do wrong.

-- Make it easy to do right.

What you are promoting is the first philosophy: Tie the programmer's
hands so he can't do wrong.  Python for the most part follows the
second philosophy, making writing good code so easy that the coder
is rarely tempted to commit any evil.

Like I said, Python IS perfect.

-- Chris.



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


[ANN] WConio 1.5 Binary Installer for Python 2.4

2005-03-05 Thread Chris Gonnerman
At long last I've upgraded to Python 2.4 on my Windows 
development host, and as a direct result I have released
a WConio 1.5 binary installer for Python 2.4.

WConio is my Windows CONsole I/O for Python module.  It
emulates the conio.h functionality of Turbo C 2.0.  This
module is based heavily on the TCCONIO package by Daniel 
Guerrero Miralles, and (like TCCONIO) is in the public
domain.

WConio may be downloaded from:
http://newcenturycomputers.net/projects/wconio.html
-- Chris.
--
http://mail.python.org/mailman/listinfo/python-list


[ANN] Alternative Readline for Windows -- Binary Installer for Python 2.4 released

2005-03-05 Thread Chris Gonnerman
This is to announce the release of a binary installer
for my Alternative Readline for Windows.  This module
provides interactive command-line editing for Python
on Windows.  I realize the console functions of Windows
2000, XP, and 2003 work in the newest Python versions, 
but it appears that many programmers still work at
least part time on Windows 95/98/Me.  This module is
for them.

The source archives and binary installers for Alternative
Readline are available for download here:
http://newcenturycomputers.net/projects/readline.html
-- Chris.
--
http://mail.python.org/mailman/listinfo/python-list


ANN: gdmodule 0.54

2005-03-03 Thread Chris Gonnerman
Announcing the release of version 0.54 of the gdmodule for Python.
gdmodule is the standard module providing access to Thomas
Boutell's GD Graphics Drawing library.  This release includes many
bugfixes, and paves the way for another update in the near future to
support the newest GD versions.
Thanks to Greg Hewgill, Christopher Stone, Matti Jagula, Sadruddin 
Rejeb, and Betty Li for assisting in this release, either in terms
of reporting bugs or actually providing patches.

Due to the constant change in the GD library API, I keep all the old 
versions of gdmodule on my website alongside the current version.
You can download gdmodule from:

   http://newcenturycomputers.net/projects/gdmodule.html
--
Chris Gonnerman

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