Re: PyEphem on winXP

2005-09-21 Thread vincent wehren
<[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hi,
|
| I'm a (sort of) newbie to python and would like to install the PyEphem
| extension to Python.  I'm using Python 2.4
| I obtained PyEphem from:
|  http://rhodesmill.org/brandon/projects/pyephem.html
|
| When i ran python setup.py install my error was:
|  "error: Python was built with version 7.1 of Visual Studio, and
| extensions need to be built with the same version of the compiler, but
| it isn't installed"
|
| Browsing this group led me to the following URL where I could get (for
| free) the Visual C++ Toolkit 2003:
| 
http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-49FD-9CB0-4BFA122FA91B&displaylang=en
|
| However I still see the same error when running
|  python setup.py install.
| I know that Visual C++ Toolkit 2003 is the same as version 7.1, but is
| this the same as Visual Studio 7.1?

It should work.

Did you follow the instructions as per
http://www.vrplumber.com/programming/mstoolkit/ ?

I've had success using that approach...


HTH,
--

Vincent Wehren


|
| If so, can Visual Studio 7.1 be obtained for free?
| If not, is there a workaround?
|
| I've seen suggestions in the group that you can recompile Python 2.4
| using MinGW or some other c compiler.  I'd be willing to do that, but
| do not know how to go about recompiling python.  Advice on this would
| also be helpful.
|
| Thanks,
| James
| 


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


Re: Code to read Cobol data files

2005-09-21 Thread Al Christians
none wrote:
> Hi,
> Any one know of some code to read cobol data files
> 
> thanks
> timb

I posted some here maybe 5+ years ago that would convert COBOL comp-3, 
comp-4, and comp-5 fields (as from Realia) to  whatever.  I suppose you 
can still find it in google somewhere.

There was some help for cracking one of the other COBOL file formats at 
a site called Wotsit's file formats or something like that.  This helped 
me access data out of ISAM files from one of the non-Realia desktop 
COBOLs.  It was one of the more popular COBOL versions way back in the 
1980's, but I don't recall anymore which one it was, but I'd guess RM 
Cobol if I had to.

COBOL has/had an indexed file type defined in the language, and the 
COBOL vendors each implemented it independently, I think.  So there are 
variations in both the coding of various field/record types and the way 
that the files are put together.  But Python can handle it if you can 
figure out the rules.


Al

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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Martijn Iseger
Hello Michael,


> The alternate point is that during computing history, many, many, many
> promises were made for many, many, many, technologies based on the
> same principle of raising the abstraction level. Many, many, many of
> those technologies promised much and failed to deliver on their claims
> when used beyond the people inventing/using those technologies.

True, DSM however is not so much a new method for develping software. It's 
been used since the early 1990ies as far as I know and seen many sccessful 
implementations of it in varying sectors of industry: From mobile phones 
(Nokia uses it to develop the software running in all their phones) to IP 
switching platforms (Lucent), CRM systems, pacemakers, home automation systems, 
J2EE-based B2B portals (insurance industry), car infotainment systems (Audi 
A6), messaging systems (USAF), enterprise apps on smartphones (Nokia series60), 
Tooling industry and many more. Success with DSM depends on several factors 
like a common platform used for developing applications or variants of 
applications 
and the presence of domain-expertise: That leaves out one-time projects.

> One thing is relatively clear - your approach appears to include a
> graphical approach to systems building. Personally I suspect that the
> fact people are able to engage other parts of their brain when
> building these systems beyond linguistic is the real reason you see
> benefits, rather than actually the specific thing that led to the
> visual approach being possible.

It is actually based on the graphical approach. The important thing I see 
here is that specific instances of this approach are defined by a company's 
expert developer instead of by a standards-body or a vendor, this puts the 
expert in the driver-seat so to say, he/she gets the ability to formalize 
(changing) development practices in his/her problem domain for the rest of 
the (less experienced) developers to follow automatically. Instead of adopting 
a one-size-fits-all approach companies/developers get to tailor the approach 
to the specific needs of their unique problem domain. It does not eliminate 
coding but attempts to minimize the need for it and leave it to the people 
who are really good at it.

> (On a sad note it looks like you're reinvented how hardware is
> designed and made, but not made the intuitive leap :-/ )

I suppose you mean software here? It seems I fail to make the "leap" towards 
understanding what you mean with this, feel free to elaborate.

Regards,

Martijn


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


Re: Intermediate to expert book

2005-09-21 Thread Tonguc Yumruk
Tony Houghton <[EMAIL PROTECTED]> writes:

> Can anyone recommend a good book for intermediate up to expert level?
...
> 2.4 would be a bonus.
>
> I've heard good things about "Dive Into Python". I see it can be
> downloaded or read online, and on a very quick browse it seems to be
> suitably to the point and cover some useful stuff that was missing from
> or too deeply buried in Learning Python. I find it easier to read
> printed material though, so I'd consider buying it. What sort of
> opinions do people here have of it?
>
> -- 
> The address in the Reply-To is genuine and should not be edited.
> See  for more reliable contact
> addresses.

Dive Into Python is really a great book about doing nifty tricks in a
pythonic way. Since you are already a programmer and learn the classic
things about python just by reading the tutorial, it's better to read
Dive Into Python and learn the python way of doing things.

-- 
Love Respect GNU/Linux

Magpie, n.:
A bird whose theivish disposition suggested to someone that it
might be taught to talk.
-- Ambrose Bierce, "The Devil's Dictionary"

Tonguç Yumruk
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python win32com com_error: (-2147418113

2005-09-21 Thread Roger Upole
Usually this means the COM object has to run in a full ActiveX container.
You can host it in IE, or Pythonwin can act as a container with some effort.
See \pythonwin\pywin\Demos\ocx for some examples of using OCX objects
that require a container.

Roger

"g.franzkowiak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I'm trying to use a proprietary windows software with COM and win32com.
> The result is everytime the error message
>
> com_error: (-2147418113, 'Catastrophic failure', None, None)
>
> I've read this in some e-mails, but can't find the solution and I have
> not enough experience with Windows and COM.
>
> Can anybody help ?
>
> This ist the test script.
>
> #--
> import sys
> from win32com.client import gencache
> import win32com.client
>
> if __name__=='__main__':
>
>flag = None
> gencache.EnsureModule('{A5FE85B0-D562-11D3-A8E8-00609727A3F3}', 0, 1, 0)
> o =
> win32com.client.Dispatch('VISIONP400DATACONTROL.VisionP400DataControlCtrl.1')
>
> """
> Debug output:
> o   ==>
> 
> o.connectToVisionP400 ==>
> 
> """
>
>try:
>  flag = o.connectToVisionP400()
>
> """
> Error by function call ==>
> >>> Unhandled exception while debugging...
> Traceback (most recent call last):
>   File "S:\Python\DCOM\test.py", line , in ?
> flag = o.connectToVisionP400()
>   File
> "C:\Programme\Python\Python2.4\lib\site-packages\win32com\gen_py\A5FE85B0-D562-11D3-A8E8-00609727A3F3x0x1x0.py",
> line 60, in connectToVisionP400
> return self._oleobj_.InvokeTypes(12, LCID, 1, (11, 0), (),)
> com_error: (-2147418113, 'Catastrophic failure', None, None)
> """
>
>except:
>   flag = "*** - The connection not possible !"
>
>print flag
>
>
>
> Regards
> gerd 




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help w/ easy python problem

2005-09-21 Thread r2_r2
Actually, it is not a sin curve i need to plot, it is dots running down
the page in the shape of a sin curve like this

.
  .
   .
etc...

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


Re: Help w/ easy python problem

2005-09-21 Thread r2_r2
Actually, it is not a sin curve i need to plot, it is dots running down
the page in the shape of a sin curve like this

.
  .
   .
etc...

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


Re: Windows paths, Java, and command-line arguments, oh my!

2005-09-21 Thread Steve M
Thank you. I was able to fix it by putting the '-Dwhatever=x' bit
before the '-jar y.jar' bit. I had no idea this could matter.
Thanks all for the help.

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


Help w/ easy python problem

2005-09-21 Thread r2_r2
I am very much a beginner to python.  I have been working on writing a
very simple program and cannot get it and was hoping someone could help
me out.  Basically i need to write a code to print a sin curve running
down the page from top to bottom.  The trick is I have to do this using
only 7-8 lines of code.  Any ideas?

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


Re: print there!

2005-09-21 Thread Godwin Burby
i didn't notice it and i'm really sorry. it works beautifully!  thanks
once again :)

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


Code to read Cobol data files

2005-09-21 Thread none
Hi,
Any one know of some code to read cobol data files

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


Re: Intermediate to expert book

2005-09-21 Thread Paul Rubin
Tony Houghton <[EMAIL PROTECTED]> writes:
> Can anyone recommend a good book for intermediate up to expert level?

Python Cookbook (2nd ed.) by Alex Martelli, if you really want a dead
tree book.  It's not so much about Python itself, as how to accomplish
various things with it.  If you just want to learn the language, use
the standard tutorial and reference manuals and read some source code
and PEP's.  Books aren't that much help.

Dive Into Python is a pretty good book and as you noted, you can
browse it online enough to form your own impressions.  I think if you
have experience with other languages then you don't really need a book
to learn Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Intermediate to expert book

2005-09-21 Thread George Sakkis
"Tony Houghton" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Can anyone recommend a good book for intermediate up to expert level?
> I'm an experienced C programmer and I learnt Python from the "Learning
> Python" O'Reilly book because it had good reviews. I was disappointed
> though. It was difficult to read because it was so verbose. It would
> sometimes take more than a page to explain something where all the
> information I needed could have been conveyed in one sentence. If
> anyone's seen Leendert Ammeraal's "C For Programmers", that's more the
> sort of style I'm after. Something that covers 2.3 and preferably even
> 2.4 would be a bonus.
>
> I've heard good things about "Dive Into Python". I see it can be
> downloaded or read online, and on a very quick browse it seems to be
> suitably to the point and cover some useful stuff that was missing from
> or too deeply buried in Learning Python. I find it easier to read
> printed material though, so I'd consider buying it. What sort of
> opinions do people here have of it?

If you would give a chance to a task-oriented intermediate to advanced book, 
check the second
edition of the python cookbook. It has over 200 practical recipes, covers 2.3 
and 2.4 and has taken
excellent reviews.

George


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


Re: unusual exponential formatting puzzle

2005-09-21 Thread Paul Rubin
Neal Becker <[EMAIL PROTECTED]> writes:
> Like a puzzle?  I need to interface python output to some strange old
> program.  It wants to see numbers formatted as:
> 
> e.g.: 0.23456789E01

Yeah, that was normal with FORTRAN.  

> My solution is to print to a string with the '% 16.9E' format, then
> parse it with re to pick off the pieces and fix it up.  Pretty ugly.
> Any better ideas?

That's probably the simplest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Tony Houghton wrote:
> 
> I'm using pygame to write a game called Bombz which needs to save some
> data in a directory associated with it. In Unix/Linux I'd probably use
> "~/.bombz", in Windows something like
> "C:\Documents And Settings\\Applicacation Data\Bombz".
> 
> There are plenty of messages in the archives for this group about how to
> find the correct location in Windows, but what about Mac OS? There I
> don't know the correct location for this sort of thing at all. And there
> are other, more obscure systems like RISC OS (it may not have pygame but
> it definitely has python). Surely this is something that's crying out
> for an official function in os or sys.


This works on Win XP.  Not sure if it will work on Linux.

import os

parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0]
file = parent + os.sep + '.bombz'

Cheers,
Ron

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


best solution to for loop

2005-09-21 Thread Mauricio Tellez
Hi, I have several apps which connect to a database,  fetch some
data an put this into a gtk.TreeStore, but if the result set is 1500
row long, the app response slowly, how can optimize this? here is an
example of what I do:

cur.execute("SELECT * FROM clients")data = "">

for row in data:
   treeStore.append(row[0], row[1], row[4], "Ohio", row[5])

I read Guido's  An Optimization Anecdote ( http://www.python.org/doc/essays/list2str.html)
 and perhaps filter() or something like that could help. Any clue?

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

Re: Calling python scripts from C# programs

2005-09-21 Thread Benji York
[EMAIL PROTECTED] wrote:
> I want to call (execute) some python scripts from my C# program.

See http://www.zope.org/Members/Brian/PythonNet.
--
Benji York

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


Re: testing a website from python

2005-09-21 Thread Benji York
Achim Domma (SyynX Solutions GmbH) wrote:
> Benji York wrote:
>>If there is any interest I'll try to package up a stand-alone version in 
>>the next few days.
> 
> I think that would be a very usefull tool. Currently I'm using httpunit 
> with Jython but a python only tool would be much nicer.

I put a first cut at http://benjiyork.com/zope.testbrowser-0.1.tgz). 
See the README.txt for general info and over_the_wire.txt for how to use 
it to access web sites.  It requires the zope.interface package from 
http://www.zope.org/Products/ZopeInterface (version 3.0.1 should work).
--
Benji York

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


Calling python scripts from C# programs

2005-09-21 Thread soumitra . mishra
Hi All,

I want to call (execute) some python scripts from my C# program. I know
that this can be done but have not idea how. The other option that I
can think of is developing python web services and then calling them
from from C# program. I just wanted to know what is the best option and
how it can be achieved. In the end all I want is to trigger some python
scripts from my C# code. The is NO remote execution involved here
therefore I am not too keen on web services.

I am very new to python. Now lets see what the  geeks have to say about
this :).

Thanks,

Soumitra

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


Re: send mail through webmail

2005-09-21 Thread Benji York
Benji York wrote:
> You can also try the almost-publicly-available package zope.testbrowser 
> (http://svn.zope.org/Zope3/branches/testbrowser-integration/src/zope/testbrowser/
>  
> and http://benjiyork.com/zope.testbrowser-0.1.tgz).

I forgot to mention that it requires the ZopeInterface package from
http://www.zope.org/Products/ZopeInterface.
--
Benji York

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


Re: Finding where to store application data portably

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote:

> On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote:
> 
> 
>> > I wish the Linux Standard Base folks would specify that settings files
>> > should all go into a subdirectory like ~/settings rather than filling up
>> > the home directory with cruft. That was acceptable in the days when 
>> > people
>> > only looked at their files with ls, but in these days of GUI file
>> > managers, it is ridiculous that there are more than 100 dot files and
>> > directories in my home directory.
>>
>>Don't all file managers have an option to hide files beginning with '.'?
> 
> 
> I don't want to hide them. I just don't want them in my face when I open
> my home directory.

+1

This has been a gripe of mine on windows as well, and hiding files (or 
extensions) is definitely not the answer.

Personally I think hidden files do more harm than good. It's not a 
substitute for good file management, and it not an acceptable 
alternative to good security either.

Cheers,
Ron

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


Noobie Starting New Project

2005-09-21 Thread [EMAIL PROTECTED]
I've have an idea for a personal project. I want to access my car's
OBD-II port via serial to query engine paramters and represent them on
my PC monitor. The various methods to represent them would be any of
the following: analog gauge (speedometer), digital readout, and X Y
Plots/Charts (HP vs RPM, timing advance vs time, etc) - all on the same
screen. Its probably been done before, but I have a Subaru, which
allows me to use Subaru Select Monitor Protocol, which is faster (and
easier to implement) than OBD-II. I also have a small 7" Widescreen VGA
LCD in my dash, so I need to make sure everything is visable on a small
screen and "unsqueeze" the image.

I hope to keep developing the project to do a "virtual dyno", taking
physical estimates of the car to calculate HP, torque as well as
logging data to a text file, and other ideas like possibly
incorporating GPS thru another serial port and maybe even some
accelerometers (for Tilt and g's)

I did find software that kinda does some of what I want, but its a case
of "if you want it done right..."

I've started using python 2 weeks ago to generate a "command line" file
parsing program to allow me to take memory data from my excel file
(saved as text) and generate FORTH commands for my ISOPOD (embedded
DSP).

I realy like the python language and all the modules that are
available, but before I start, I just wanted to get some advice on
which modules I should be using for the GUI and making charts, or if
anyone has any examples that might help me along.

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


Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote:

> Ah, that's a good example, thanks, except I notice you didn't actually
> cast to bool in them, eg: (min < value < max) * value

It wasn't needed in these particular examples.  But it could be needed 
if several comparisons with 'and' between them are used.

It just seems odd to me that:

 3 and 2 and 1  -> 1
 1 and 2 and 3  -> 3

But that may be because I learned boolean algebra as part of an 
electronics logic (computer tech) course dealing with gates in the early 
80's.


>>In boolean math it is useful to add and subtract.
>> >>> a = b = True
>> >>> a + b
>>2   # Non boolean result.

> I presume you mean Boolean algebra by "Boolean math". I have to disagree
> with you there. It is *not* useful to do addition, subtraction,
> multiplication or division in Boolean algebra. 
(clip)

Yes, but not quite as strict as True BA would be and not with the strict 
type checking other languages have.


> I'm not saying that it can't be useful to treat Booleans as if they were
> the integers 0 and 1, but in mathematics Booleans are abstract values
> distinct from the integers (even when they use the symbols 0 and 1) and
> the concept "True plus True is two" is meaningless.
> 
> It is useful to read the comments here:
> 
> http://www.python.org/doc/2.3/whatsnew/section-bool.html

Thanks and the PEP link from there was useful too.


> eg "Python's Booleans were not added for the sake of strict type-checking.
> A very strict language such as Pascal would also prevent you performing
> arithmetic with Booleans, and would require that the expression in an if
> statement always evaluate to a Boolean result."

It doesn't need to be that strict.  But a few changes could resolve and 
reduce the chance of errors especially for beginners, while not limiting 
more advanced uses.  These would be Python 3k changes most likely if at all.

 1.  'and', 'or', and 'not' always return bool values.

Lots of discussion on this one already. From the look of it, I don't 
think it will change.  But Guido seemed to suggest its possible with the 
addition of a trinary operation.  But even with that it wouldn't be done 
any time soon.

 2.  bool == value to be the same as bool == value.__nonzero__()

By doing this comparisons with Bool types will match the behavior of if 
conditions without restricting if to strictly bools.

 3.  Math with bools as both arguments should return bools.

This wouldn't prevent adding bools and ints, or doing other operations 
on them.  But bools would remain bool types until an operation with a 
non bool type.

 True * True  -> True  instead of 1
 True * False  -> False  instead of 0
 False * True -> False  instead of 0
 False * False -> False  instead of 0
 True * 10 -> 10
 False * 10 -> 0
 True * 0 -> 0

 True + True -> True instead of 2  **changed**
 True + False -> True instead of 1
 False + True -> True instead of 1
 False + False -> False instead of 0
 True + 1 = 2
 False + 0 = 0

 -True -> False instead of -1  **changed**
 -False -> True instead of 0   **changed**
 1-True -> 0
 1-False -> 1
 2-True -> 1
 2-False -> 2
 True-1 -> 0
 False-1 -> -1

Notice there is only three places above where the change would be 
significantly different than now.  All other cases would just exchange 
True of 1 or False for 0.

Some operation would need a trinary operation in place of the current 
and/or.

 person.name = (if name then name else 'default name')

Not my favorite syntax, but I can live with it.  It might be possible to 
have a short form.

 person.name = (name else 'default name')


>>Should bool type act like bools as expressed here?
>>
>> http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/
> 
> That is only one possible Boolean algebra, the simplest one. Strictly
> speaking, Booleans aren't limited to two values. See
> http://en.wikipedia.org/wiki/Boolean_algebra for more detail.

I look at those earlier and was surprised at how complex some Boolean 
algebra concepts were.  Interesting though, and I'll probably go back 
and study it a bit more.


> Python's bools aren't Booleans. They are merely aliases for 0 and 1.

Yes, and according to the PEP they were introduced to help reduce 
errors.  ;-)

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


Re: Chronological Processing of Files

2005-09-21 Thread George Sakkis
"Peter Hansen" <[EMAIL PROTECTED]> wrote:

> yoda wrote:
> > This feels like a stupid question but I'll ask it anyway.
> >
> > How can I process files chronologically (newest last) when using
> > os.walk()?
>
> Do you want the ordering to apply just to files within each directory,
> or to all the files found (recursively) during the entire walk?  Define
> "newest" (most recent modified date or something else?).  Is there any
> reason why sorting with the results of os.access().st_mtime as the key
> is not possible or sufficient?
>
> -Peter

You can make your life easier using the non-standard (yet ?) path module:

from path import path

top = path('.')
sort_kwds = dict(key=path.mtime.__get__, reverse=True)

# sort all files together
sorted_all = sorted(top.walkfiles(), **sort_kwds)

# sort files by directory

sorted_by_dir = sorted(top.files(), **sort_kwds) \
 + sum((sorted(dir.files(), **sort_kwds)
for dir in path(top).walkdirs()), [])

George


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


Re: send mail through webmail

2005-09-21 Thread Benji York
Chris Curvey wrote:
> If you have to do it thru the web, I would use one of the "browser"
> packages (mechanize, mechanoid, PAMIE, or IshyBrowser).   Then you can
> scrape the site, fill out the forms, press the buttons, etc.

You can also try the almost-publicly-available package zope.testbrowser 
(http://svn.zope.org/Zope3/branches/testbrowser-integration/src/zope/testbrowser/
 
and http://benjiyork.com/zope.testbrowser-0.1.tgz).  See the README.txt 
for general info and over_the_wire.txt for how to use it to access web 
sites.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send mail through webmail

2005-09-21 Thread Chris Curvey
If you have to do it thru the web, I would use one of the "browser"
packages (mechanize, mechanoid, PAMIE, or IshyBrowser).   Then you can
scrape the site, fill out the forms, press the buttons, etc.

This will be a *lot* more painful than using SMTP

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


Re: distutils and decorators

2005-09-21 Thread Benji York
Robert Brewer wrote:
> Actually, in this case we most definitely want to test 2.4's "@" syntax. 
> The decorator in question is an aliaser, and therefore is one of the few 
> decorators which must be implemented differently for the 2.3-style 
> decoration and the 2.4-style. See the "expose" function at: 
> http://www.cherrypy.org/file/trunk/cherrypy/__init__.py?rev=654

I extracted "expose" from the above URL and wrote this test script (mind 
the wrapping):

import sys, types

def expose(func=None, alias=None):
 """Expose the function, optionally providing an alias or set of 
aliases."""

 def expose_(func):
 func.exposed = True
 if alias is not None:
 if isinstance(alias, basestring):
 parentDict[alias] = func
 else:
 for a in alias:
 parentDict[a] = func
 return func

 parentDict = sys._getframe(1).f_locals
 if isinstance(func, (types.FunctionType, types.MethodType)):
 # expose is being called directly, before the method has been bound
 print 'direct'
 return expose_(func)
 else:
 # expose is being called as a decorator
 print 'decorator'
 if alias is None:
 alias = func
 return expose_

print 'before decorator (no args)'

@expose
def foo():
 pass

print 'before decorator (with args)'

@expose("1")
def foo():
 pass

print 'before direct 1'

def bar():
 pass

baz = expose(bar)

print 'before direct 2'

bux = expose("1")(bar)



Here's it's output (2.4.1 on Linux):

% python /tmp/1.py
before decorator (no args)
direct
before decorator (with args)
decorator
before direct 1
direct
before direct 2
decorator

What am I missing?
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for system/network monitoring tool written in Python

2005-09-21 Thread Mike Meyer
I've found a fair number of systems/network monitoring tools (things
like Big Brother, Big Sister, cricket, etc.) written in Perl. I'm
curious if there are any written in Python.

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


Re: Threading, real or simulated?

2005-09-21 Thread Sam

Jp Calderone writes:


On Wed, 21 Sep 2005 18:23:33 -0500, Sam <[EMAIL PROTECTED]> wrote:
I'm using Python 2.3.5 with pygtk 2.4.1, and I'm using the second threading 
approach from pygtk's FAQ 20.6 - invoking "gtk.gdk.threads_init()", and 
wrapping all gtk/gdk function calls with 
gtk.threads_enter()/gtk.threads_leave()


I start a thread, via thread.Threading.start().  The thread then calls a 
particularly time consuming C function, from an extension module.  I find 
that when the thread is running the C code, the GUI hangs even though I'm 
not inside the threads_enter/threads_leave territory.




  Does the extension module release the GIL?  It sounds like it does not.  Of 
course, there are a dozen other mistakes that could be made which would have 
roughly this symptom.  It's difficult to say which is the problem without 
actually seeing any code.


What's the GIL?.  The extension module is invoked outside of 
threads_enter/threads_leave().


It looks like thread.Threading() only simulates threading, by having the 
python interpreter multiplex between running threads.  Is real threading 
possible, so that I do something time-consuming in the thread, without 
hanging the GUI?




Assuming you mean threading.Thread, this is a native thread.  It is not a 
simulation.  Something else is going wrong.


Then I must have something locked.  Here's what I do:

   gtk.gdk.threads_init()
   mainwindow=MainWindow()
   gtk.threads_enter()
   gtk.main()
   gtk.threads_leave()


The code in MainWindow.__init__() does this:

   self.__window=gtk.Window(gtk.WINDOW_TOPLEVEL)
   self.__window.set_default_size(600, 600)

   [ some more initialization ]

   self.__window.show_all()
   self.__window.connect("delete-event", self.delete_event)
   self.__window.connect("destroy", self.destroy)

   t=self.initializationThread()
   t.packageLayout=packageLayout
   t.start()

Here's the definition of my initializationThread class:

   class initializationThread(threading.Thread):
   def run(self):
   gtk.threads_enter()
   busy_cursor=gtk.gdk.Cursor(gtk.gdk.WATCH)
   self.packageLayout.window.set_cursor(busy_cursor)
   gtk.threads_leave()


I do get a busy cursor at this point, so I know that this thread is running. 
initializationThread.run() continues, as follows:


   try:
   sysrep=lpm.getSystemRepository()
   pkgs=sysrep.getPackages()
   pkgs.sort()
   for i in pkgs:
   icon=sysrep.getManifest(i).header("Icon")
   gtk.threads_enter()
   try:
   if self.packageLayout.window == None:
   break  # Someone was impatient
   self.packageLayout.addPackage(i, icon)
   finally:
   gtk.threads_leave()


lpm.getSystemRepository() instantiates an object of an extension-defined 
type.  It's getPackages() method returns a list of objects that are also of 
an extension-defined type, which I then iterate over.  Each iteration 
invokes the getManifest() method of an extension-defined type.


All the stuff between gtk.threads_enter() and gtk.threads_leave() runs pure 
python code, and should be nearly instantaneous.  Furthermore, gtk functions 
that end up being invoked in the addPackage() method, provide some GUI 
feedback.  Each addPackage() iteration adds a new widget in the main window.


Occasionally, there's a noticeable delay, before a new widget appears, 
because there's a lot on getManifest()'s plate.  I get no response from any 
GUI activity, during the delay.  getManifest() gets invoked outside the 
threads_enter/threads_leave lock, but the GUI is still hanging when that 
happens.





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

RE: distutils and decorators

2005-09-21 Thread Robert Brewer
Title: RE: distutils and decorators






I wrote:
> We're trying to get CherryPy 2.1 RC 1 out the door, but setup.py is
> giving us some problems.
> In our test suite, we want to test a decorator
> that we provide. Of course, decorators won't work in Python 2.3

and Benji York replied:
> More accurately, the special "@" decorator syntax doesn't work in 2.3.
> I would propose that you *do not* want to test the syntax (that's what
> the Python test suite is for), but instead test the functionality of the
> decorator.  Therefore I'd switch to 2.3 compatible syntax instead.

Actually, in this case we most definitely want to test 2.4's "@" syntax. The decorator in question is an aliaser, and therefore is one of the few decorators which must be implemented differently for the 2.3-style decoration and the 2.4-style. See the "expose" function at: http://www.cherrypy.org/file/trunk/cherrypy/__init__.py?rev=654


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]



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

Re: Chronological Processing of Files

2005-09-21 Thread Jeremy Jones
yoda wrote:

>This feels like a stupid question but I'll ask it anyway.
>  
>
Definitely not a stupid question.

>How can I process files chronologically (newest last) when using
>os.walk()?
>
>  
>

Try this:

In [16]:  file_list = [(os.stat(f)[8], f) for f in [os.path.join(i[0], 
j) for i in os.walk("/home/jmjones/public_html") for j in i[2]]]

In [17]:  file_list.sort()

In [18]:  sorted_file_list = [f[1] for f in file_list]


I *think* os.stat()[8] is the modification time element...but this 
should probably work for you.  That first list comprehension looks like 
a booger if you're not familiar with them.  If you have any trouble with 
it, just shoot a message back to the list and I'll decypher it for you.

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


Re: unusual exponential formatting puzzle

2005-09-21 Thread Michael Spencer
Michael Spencer wrote:
> Neal Becker wrote:
> 
>>Like a puzzle?  I need to interface python output to some strange old
>>program.  It wants to see numbers formatted as:
>>
>>e.g.: 0.23456789E01
>>
>>That is, the leading digit is always 0, instead of the first significant
>>digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
>>quite.
>>
>>My solution is to print to a string with the '% 16.9E' format, then parse it
>>with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
>>ideas?
>>
>>
> 
> Does this do what you want?

Not, if the input is 0 or 1.  Here's a correction, with a more comprehensive 
test

from math import log10, modf, fabs

def format(n, mantplaces = 9, expplaces = 2):
 """Formats n as '0.mEee'"""
 if n:
 sign, absn = n/fabs(n), fabs(n)
 f, i = modf(log10(absn))
 mant, exp = sign * 10** (f - (f>=0)), i + (f>=0)
 else:
 mant, exp = 0, 0
 return "%.*fE%0*d" % (mantplaces, mant, expplaces, exp)

def test_format(N = 1, step = 1):
 """Verifies format(n) and format(1/n) for -N < n < N"""
 assert format(0,9) == '0.0E00'
 assert format(0, 7, 3) == '0.000E000'

 def verify(n):
 DIGITS = '123456789'
 try:
 f = format(n)
 assert round(float(format(n)),6) == round(n, 6)
 assert f[0] == "-" and f[3] in DIGITS or f[2] in DIGITS
 except AssertionError:
 raise AssertionError("Failed on: %f, formatted as %s" % (n, f))

 for  n in xrange(-N, N, step):
 if n:
 verify(n)
 verify(1.0/n)


Michael

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


Re: Threading, real or simulated?

2005-09-21 Thread Jp Calderone
On Wed, 21 Sep 2005 18:23:33 -0500, Sam <[EMAIL PROTECTED]> wrote:
>I'm using Python 2.3.5 with pygtk 2.4.1, and I'm using the second threading 
>approach from pygtk's FAQ 20.6 - invoking "gtk.gdk.threads_init()", and 
>wrapping all gtk/gdk function calls with 
>gtk.threads_enter()/gtk.threads_leave()
>
>I start a thread, via thread.Threading.start().  The thread then calls a 
>particularly time consuming C function, from an extension module.  I find 
>that when the thread is running the C code, the GUI hangs even though I'm 
>not inside the threads_enter/threads_leave territory.
>

  Does the extension module release the GIL?  It sounds like it does not.  Of 
course, there are a dozen other mistakes that could be made which would have 
roughly this symptom.  It's difficult to say which is the problem without 
actually seeing any code.

>It looks like thread.Threading() only simulates threading, by having the 
>python interpreter multiplex between running threads.  Is real threading 
>possible, so that I do something time-consuming in the thread, without 
>hanging the GUI?
>

Assuming you mean threading.Thread, this is a native thread.  It is not a 
simulation.  Something else is going wrong.

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


Threading, real or simulated?

2005-09-21 Thread Sam
I'm using Python 2.3.5 with pygtk 2.4.1, and I'm using the second threading 
approach from pygtk's FAQ 20.6 - invoking "gtk.gdk.threads_init()", and 
wrapping all gtk/gdk function calls with 
gtk.threads_enter()/gtk.threads_leave()


I start a thread, via thread.Threading.start().  The thread then calls a 
particularly time consuming C function, from an extension module.  I find 
that when the thread is running the C code, the GUI hangs even though I'm 
not inside the threads_enter/threads_leave territory.


It looks like thread.Threading() only simulates threading, by having the 
python interpreter multiplex between running threads.  Is real threading 
possible, so that I do something time-consuming in the thread, without 
hanging the GUI?





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

Re: Finding where to store application data portably

2005-09-21 Thread Steven D'Aprano
On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote:

>  > I wish the Linux Standard Base folks would specify that settings files
>  > should all go into a subdirectory like ~/settings rather than filling up
>  > the home directory with cruft. That was acceptable in the days when 
>  > people
>  > only looked at their files with ls, but in these days of GUI file
>  > managers, it is ridiculous that there are more than 100 dot files and
>  > directories in my home directory.
> 
> Don't all file managers have an option to hide files beginning with '.'?

I don't want to hide them. I just don't want them in my face when I open
my home directory.


-- 
Steven.

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


Re: Question About Logic In Python

2005-09-21 Thread Steven D'Aprano
On Wed, 21 Sep 2005 18:53:34 +, Ron Adam wrote:

> Steven D'Aprano wrote:
> 
>>>So..
>>>
>>>bool(a and b) * value
>>>
>>>Would return value or zero, which is usually what I want when I do this 
>>>type of expression.
> 
>> That's all very interesting, and valuable advice for somebody who doesn't
>> understand how Python's logical operators work, but the question is, when
>> would you actually want that type of expression?
> 
> It's a filter which returns a value or zero depending on conditions a and b.

Ah, that's a good example, thanks, except I notice you didn't actually
cast to bool in them, eg: (min < value < max) * value

You also said:

> In boolean math it is useful to add and subtract.
>  >>> a = b = True
>  >>> a + b
> 2   # Non boolean result.

I presume you mean Boolean algebra by "Boolean math". I have to disagree
with you there. It is *not* useful to do addition, subtraction,
multiplication or division in Boolean algebra. Those operations aren't
defined on Booleans, because they return results which aren't Booleans. If
you wanted to extend arithmetic operations on Booleans, you would need to
either redefine addition and multiplication as XOR and AND (as
mathematicians do when they extend Boolean algebras to rings), or do your
arithmetic modulo 2.

I'm not saying that it can't be useful to treat Booleans as if they were
the integers 0 and 1, but in mathematics Booleans are abstract values
distinct from the integers (even when they use the symbols 0 and 1) and
the concept "True plus True is two" is meaningless.

It is useful to read the comments here:

http://www.python.org/doc/2.3/whatsnew/section-bool.html

eg "Python's Booleans were not added for the sake of strict type-checking.
A very strict language such as Pascal would also prevent you performing
arithmetic with Booleans, and would require that the expression in an if
statement always evaluate to a Boolean result."

> Should bool type act like bools as expressed here?
> 
>  http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/

That is only one possible Boolean algebra, the simplest one. Strictly
speaking, Booleans aren't limited to two values. See
http://en.wikipedia.org/wiki/Boolean_algebra for more detail.

Python's bools aren't Booleans. They are merely aliases for 0 and 1.


-- 
Steven.

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


Re: Intermediate to expert book

2005-09-21 Thread Steve Bergman
I'm waiting for the release of the next edition of "Programming Python" 
from O'Reilly.  It's due out in December.  The current edition is rather 
oldish.  From 2001, I believe.

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


Intermediate to expert book

2005-09-21 Thread Tony Houghton

Can anyone recommend a good book for intermediate up to expert level?
I'm an experienced C programmer and I learnt Python from the "Learning
Python" O'Reilly book because it had good reviews. I was disappointed
though. It was difficult to read because it was so verbose. It would
sometimes take more than a page to explain something where all the
information I needed could have been conveyed in one sentence. If
anyone's seen Leendert Ammeraal's "C For Programmers", that's more the
sort of style I'm after. Something that covers 2.3 and preferably even
2.4 would be a bonus.

I've heard good things about "Dive Into Python". I see it can be
downloaded or read online, and on a very quick browse it seems to be
suitably to the point and cover some useful stuff that was missing from
or too deeply buried in Learning Python. I find it easier to read
printed material though, so I'd consider buying it. What sort of
opinions do people here have of it?

-- 
The address in the Reply-To is genuine and should not be edited.
See  for more reliable contact 
addresses.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C#3.0 and lambdas

2005-09-21 Thread Steven Bethard
Steven D'Aprano wrote:
> I would love to see your test code and profiling results that demonstrate
> that explicit tuple unpacking in the body of a function is faster than
> tuple unpacking (implicit or explicit) in the header of a function.

Should be pretty close.  I believe the byte-code is nearly identical:

py> def f1((x, y)):
... pass
...
py> def f2(x_y):
... x, y = x_y
...
py> dis.dis(f1)
   1   0 LOAD_FAST0 (.0)
   3 UNPACK_SEQUENCE  2
   6 STORE_FAST   1 (x)
   9 STORE_FAST   2 (y)

   2  12 LOAD_CONST   0 (None)
  15 RETURN_VALUE
py> dis.dis(f2)
   2   0 LOAD_FAST0 (x_y)
   3 UNPACK_SEQUENCE  2
   6 STORE_FAST   2 (x)
   9 STORE_FAST   1 (y)
  12 LOAD_CONST   0 (None)
  15 RETURN_VALUE

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


Re: Object default value

2005-09-21 Thread James Stroud
On Tuesday 20 September 2005 12:31, ago wrote:
> Is it possible to have a default value associated python objects? I.e.
> to flag an attribute in such a way that the assignment operator for the
> object returns the default attribute instead of the object itself, but
> calls to other object attributes are properly resolved? (I don't think
> so, but I am not sure)

I was thinking about this last night and it seemed an interesting problem. I 
thought you might want to change the way you look at it, using the python 
equivalent to type casting (maybe its called "coercing", sorry for my poor 
command of python vocabulary). I have overridden __int__ and __float__ for 
this example. You might want to look into __coerce__. This should have the 
behavior you desire while having the explicit syntax expected of good python 
code.

Inheriting from list allows you to use a stack-like behavior you described in 
a previous email. You can further modify __getattribute__, __setattribute__, 
__delattribute__, etc. Overriding __iter__ gives you the history in "correct" 
order, but may begin to embark on a non-intuitive interface--you be the 
judge. I think this is about as close as you can get in python to what you 
are thinking (don't know the oldest python version this is backwards 
compatible with):


py> class Thing(list):
...def __init__(self, start_value):
... list.__init__(self)
... self.append(start_value)
...def __setattr__(self, anattr, aval):
...  if (anattr == 'top'):
...self.append(aval)
...  else:
...list.__setattr__(self, anattr, aval)
...def __getattr__(self, anattr):
...  if (anattr == 'top'):
...return self[-1]
...  elif (anattr == 'old'):
...try:
...  return self[-2]
...except IndexError:
...  raise NameError, "No old value yet"
...  else:
...list.__getattr__(self, anattr)
...def __iter__(self):
...  return list.__iter__(self[::-1])
...def __int__(self):
...  return int(self.top)
...def __float__(self):
...  return float(self.top)
...def __str__(self):
...  return str(self.top)
...
py> athing = Thing(5)# should init with a reasonable value
py> athing.top   # __getattr__
5
py> int(athing)  # __int__
5
py> print athing # __str__
5
py> float(athing)# __float__
5.0
py> athing.top = 4   # __setattr__
py> print athing
4
py> athing.old   # __getattr__
5
py> athing.top = 42  # __setattr__
py> [x for x in athing]  # __iter__
[42, 4, 5]
py> y = float(athing)# closest you can get to assignment overloading
py> print y  # y is a float
42.0
py> athing # Thing inherits from list, so you get list.__repr__() here
[5, 4, 42]



Here it is without the prompts:

class Thing(list):
   def __init__(self, start_value):
list.__init__(self)
self.append(start_value)
   def __setattr__(self, anattr, aval):
 if (anattr == 'top'):
   self.append(aval)
 else:
   list.__setattr__(self, anattr, aval)
   def __getattr__(self, anattr):
 if (anattr == 'top'):
   return self[-1]
 elif (anattr == 'old'):
   try:
 return self[-2]
   except IndexError:
 raise NameError, "No old value yet"
 else:
   list.__getattr__(self, anattr)
   def __iter__(self):
 return list.__iter__(self[::-1])
   def __int__(self):
 return int(self.top)
   def __float__(self):
 return float(self.top)
   def __str__(self):
 return str(self.top)

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Chronological Processing of Files

2005-09-21 Thread Paul
untested, ugly, but something like this would sort all the files in the
directory on os.path.getctime (not using os.walk() though). I'm sure
there is probably better ways to do it :)

filelist = []

def walkdir(currdir):
for files in os.listdir(currdir):
path = os.path.join(currdir, files)
if not os.path.isdir(path):
filelist.append([os.path.getctime(path), path])
else:
walkdir(path)

walkdir(r'c:\somedirectory')

filelist.sort()

for item in filelist:
dosomething(item[1])

dosomething is whatever function to process the files

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


Re: Chronological Processing of Files

2005-09-21 Thread Peter Hansen
yoda wrote:
> This feels like a stupid question but I'll ask it anyway.
> 
> How can I process files chronologically (newest last) when using
> os.walk()?

Do you want the ordering to apply just to files within each directory, 
or to all the files found (recursively) during the entire walk?  Define 
"newest" (most recent modified date or something else?).  Is there any 
reason why sorting with the results of os.access().st_mtime as the key 
is not possible or sufficient?

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


Re: Getting tired with py2exe

2005-09-21 Thread Lucas Raab
Scott David Daniels wrote:
> Steve Holden wrote:
> 
>> Thomas Heller wrote:
>>
>>> I'm slowly getting tired maintaining py2exe.  It is far from perfect,
>>> although it has interesting features (I would say).
> 
> 
>> Ignoring all the philosophical questions I'd like to thank you for all 
>> your hard work on py2exe over the years, which has benefited the 
>> Windows Python community immeasurably.
> 
> 
> I second this.
> 
> --Scott David Daniels
> [EMAIL PROTECTED]

*motion passed for entry into Python Hall of Fame*

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C#3.0 and lambdas

2005-09-21 Thread Steven D'Aprano
On Wed, 21 Sep 2005 18:48:22 +0200, Christophe wrote:

> Well, I prefer the explicit tuple unpack anyway. It gives better results 
> than using tuple indexing ( and better performance too most of the time )


I would love to see your test code and profiling results that demonstrate
that explicit tuple unpacking in the body of a function is faster than
tuple unpacking (implicit or explicit) in the header of a function.


-- 
Steven.

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


Re: very high-level IO functions?

2005-09-21 Thread York
Thank you, Tom.


-York


Tom Anderson wrote:
> On Mon, 19 Sep 2005, Bruno Desthuilliers wrote:
> 
>> York a écrit :
>> (snip)
>>
>>> I love python. However, as a biologist, I like some high-levels 
>>> functions in R. I don't want to spend my time on parse a data file.
>>
>>
>> http://www.python.org/doc/current/lib/module-csv.html
>>
>>> Then in my python script, I call R to read data file and write them 
>>> into an MySQL table. If python can do this easily, I don't need R at 
>>> all.
>>
>>
>> So you don't need R at all.
> 
> 
> Did you even read the OP's post? Specifically, this bit:
> 
> R language has very high-level IO functions, its read.table can read a 
> total .csv file and recogonize the types of each column.
> ^^^
> 
> Python's csv module gives you tuples of strings; it makes no effort to 
> recognise the types of the data. AFAIK, python doesn't have any IO 
> facilities like this.
> 
> Larry's point that automagical type detection is risky because it can 
> make mistakes is a good one, but that doesn't mean that magic is useless 
> - on the contrary, for the majority of cases, it works fine, and is 
> extremely convenient.
> 
> The good news is that it's reasonably easy to write such a function: you 
> just need a function 'type_convert' which takes a string and returns an 
> object of the right type; then you can do:
> 
> import csv
> 
> def read_table(f):
> for row in csv.reader(f):
> yield map(type_convert, row)
> 
> This is a very, very rough cut - it doesn't do comment stripping, 
> skipping blank lines, dealing with the presence of a header line or the 
> use of different separators, etc, but all that's pretty easy to add. 
> Also, note that this returns an iterator rather than a list; use 
> list(read_table(f)) if you want an actual list, or change the 
> implementation of the function.
> 
> type_convert is itself fairly simple:
> 
> def _bool(s): # helper method for booleans
> s = s.lower()
> if (s == "true"): return True
> elif (s == "false"): return False
> else: raise ValueError, s
> 
> types = (int, float, complex, _bool, str)
> 
> def type_convert(s):
> for type in types:
> try:
> return type(s)
> except ValueError:
> pass
> raise ValueError, s
> 
> This whole thing isn't quite as sophisticated as R's table.convert; R 
> reads the whole table in, then tries to find a type for each column 
> which will fit all the values in that column, whereas i do each cell 
> individually. Again, it wouldn't be too hard to do this the other way 
> round.
> 
> Anyway, hope this helps. Bear in mind that there are python bindings for 
> the R engine, so you could just use R's version of read.table in python.
> 
> tom
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Josef Meile
Hi,

> I just want to test that a given website is up or not from a python 
> script.  I thought of using wget as an os command.  Any better ideas?
Here is how I did it:

import urllib2
import socket
def checkUrl(url, timeout=1):
   """Checks an url for a python version greater
  than 2.3.3.

  Note: For me isn't important the kind of
HTTP Error. If you want to know it,
then take a look at the existent
solutions like CMFLinkChecker and
see how they extract the code from
the error message.
   """
   error={'code':1, 'msg':'Success'}
   defTimeOut=socket.getdefaulttimeout()
   socket.setdefaulttimeout(timeout)
   try:
 urllib2.urlopen(url)
   except (urllib2.HTTPError, urllib2.URLError,
   socket.error, socket.sslerror):
 error['code']=-2
 error['msg']="The link: \"${link}\" couldn't be validated"
   except:
 socket.setdefaulttimeout(defTimeOut)
 raise

   socket.setdefaulttimeout(defTimeOut)
   return error

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


Re: testing a website from python

2005-09-21 Thread Grig Gheorghiu
Achim,

Have you looked into twill? It's available at


Grig

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


Chronological Processing of Files

2005-09-21 Thread yoda
This feels like a stupid question but I'll ask it anyway.

How can I process files chronologically (newest last) when using
os.walk()?

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


Re: unusual exponential formatting puzzle

2005-09-21 Thread Michael Spencer
Neal Becker wrote:
> Like a puzzle?  I need to interface python output to some strange old
> program.  It wants to see numbers formatted as:
> 
> e.g.: 0.23456789E01
> 
> That is, the leading digit is always 0, instead of the first significant
> digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
> quite.
> 
> My solution is to print to a string with the '% 16.9E' format, then parse it
> with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
> ideas?
> 
> 
Does this do what you want?

  >>> from math import log10, modf, fabs
  >>> def format(n, mantplaces = 9, expplaces = 2):
  ... sign, n = n/fabs(n), fabs(n)# preserve the sign
  ... c, m = modf(log10(n))
  ... c, m = c - (c>0), m + (c>0) # redistribute mantissa to exponent
  ... return "%.*fE%0*d" % (mantplaces, sign * 10**c, expplaces, m)
  ...
  >>>
  >>> def test_format(n):
  ... for  exp in range(-5, 5):
  ... N = n*(10**exp)
  ... print format(n*(10**exp))
  ...
  >>> test_format(234.56789)
  0.234567890E-2
  0.234567890E-1
  0.234567890E00
  0.234567890E01
  0.234567890E02
  0.234567890E03
  0.234567890E04
  0.234567890E05
  0.234567890E06
  0.234567890E07
  >>>

Michael

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


PyEphem on winXP

2005-09-21 Thread jbattat
Hi,

I'm a (sort of) newbie to python and would like to install the PyEphem
extension to Python.  I'm using Python 2.4
I obtained PyEphem from:
  http://rhodesmill.org/brandon/projects/pyephem.html

When i ran python setup.py install my error was:
  "error: Python was built with version 7.1 of Visual Studio, and
extensions need to be built with the same version of the compiler, but
it isn't installed"

Browsing this group led me to the following URL where I could get (for
free) the Visual C++ Toolkit 2003:
http://www.microsoft.com/downloads/details.aspx?FamilyId=272BE09D-40BB-49FD-9CB0-4BFA122FA91B&displaylang=en

However I still see the same error when running
  python setup.py install.
I know that Visual C++ Toolkit 2003 is the same as version 7.1, but is
this the same as Visual Studio 7.1?

If so, can Visual Studio 7.1 be obtained for free?
If not, is there a workaround?

I've seen suggestions in the group that you can recompile Python 2.4
using MinGW or some other c compiler.  I'd be willing to do that, but
do not know how to go about recompiling python.  Advice on this would
also be helpful. 

Thanks,
James

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


Re: strange import phenomenon

2005-09-21 Thread Dieter Maurer
Christoph Zwerschke <[EMAIL PROTECTED]> writes on Tue, 20 Sep 2005 11:20:37 
+0200:
> Just hitting a strange problem with Python import behavior. It is the
> same on all Python 2.x versions and it is probably correct, but I
> currently don't understand why this happens.
> ...
> --- dir/__init__.py ---
> print "init"
> ---
> 
> 
> --- dir/hello.py --
> print "hello world"
> ---
> 
> 
> --- dir/test2.py --
> import sys
> sys.path = []
> 
> import hello
> ---
> 
> 
> The script test2.py removes all entries from the sys.path. So when I
> run test2.py directly, I get an ImportError because the hello module
> cannot be imported. This is as expected.
> 
> 
> However, if I run test1, the hello module *is* imported and I get the
> "hello world" message. Why is that??

Because Python tries to resolve modules inside a package ("dir" in
your example) locally first. This local resolution does not
involve "sys.path" but "package.__path__".
Only when the local lookup fails, a global lookup (using "sys.path")
is tried.

In your case, the local lookup succeeds.


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


Removing nested tuple function parameters (was: C#3.0 and lambdas)

2005-09-21 Thread Dieter Maurer
"Fredrik Lundh" <[EMAIL PROTECTED]> writes on Mon, 19 Sep 2005 10:31:48 +0200:
> ...
> meanwhile, over in python-dev land:
> 
> "Is anyone truly attached to nested tuple function parameters; 'def
> fxn((a,b)): print a,b'?  /.../

Yes, I am...

> Would anyone really throw a huge fit if they went away?  I am willing
> to write a PEP for their removal in 2.6 with a deprecation in 2.5 if
> people are up for it."

I would think of it as a great stupidity.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simpler transition to PEP 3000 "Unicode only strings"?

2005-09-21 Thread Dieter Maurer
"Petr Prikryl" <[EMAIL PROTECTED]> writes on Tue, 20 Sep 2005 11:21:59 +0200:
> ...
> The idea:
> =
> 
> What do you think about the following proposal
> that goes the half way
> 
>   If the Python source file is stored in UTF-8 (or
>   other recognised Unicode file format), then the
>   encoding declaration must reflect the format or
>   can be omitted entirely. In such case, all
>   simple string literals will be treated as
>   unicode string literals.
>   
> Would this break any existing code?

Yes: modules that construct byte strings (i.e. strings
which should *not* be unicode strings).

Nevertheless, such a module may be stored in UTF-8.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unusual exponential formatting puzzle

2005-09-21 Thread Neal Becker
[EMAIL PROTECTED] wrote:

> 
> [EMAIL PROTECTED] wrote:
>> Neal Becker wrote:
>> > Like a puzzle?  I need to interface python output to some strange old
>> > program.  It wants to see numbers formatted as:
>> >
>> > e.g.: 0.23456789E01
>> >
>> > That is, the leading digit is always 0, instead of the first
>> > significant
>> > digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
>> > quite.
>> >
>> > My solution is to print to a string with the '% 16.9E' format, then
>> > parse it
>> > with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
>> > ideas?
>>
>> If you have gmpy available...
>>
>> >>> import gmpy
>>
>> ...and your floats are mpf's...
>>
>> >>> s = gmpy.pi(64)
>> >>> s
>> mpf('3.14159265358979323846e0',64)
>>
>> ...you can use the fdigits function
>>
>> >>> t = gmpy.fdigits(s,10,8,0,0,2)
>>
>> ...to create a seperate digit string and exponent...
>>
>> >>> print t
>> ('31415927', 1, 64)
>>
>> ...which can then be printed in the desired format.
>>
>> >>> print "0.%sE%02d" % (t[0],t[1])
>> 0.31415927E01
> 
> Unless your numbers are negative.
> 
 print "0.%sE%02d" % (t[0],t[1])
> 0.-31415927E03
> 
> Drat. Needs work.
> 
> 
> 
> And does the format permit large negative exponents (2 digits + sign)?
> 

I think the abs (exponent) < 10 for now

 print "0.%sE%02d" % (t[0],t[1])
> 0.31415927E-13
> 


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


Re: testing a website from python

2005-09-21 Thread Achim Domma (SyynX Solutions GmbH)
Benji York wrote:

> If there is any interest I'll try to package up a stand-alone version in 
> the next few days.

I think that would be a very usefull tool. Currently I'm using httpunit 
with Jython but a python only tool would be much nicer.

regards,
Achim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread Scott David Daniels
Fredrik Lundh wrote:
> Scott David Daniels wrote:
> 
>>MS is fairly determined to get you develop money; you may not
>>redistribute the C runtime with your app from the "free" stuff.
> 
> that's a myth, based on a flawed reading of the MS license.  to repeat
> myself from various other fora:
> 
> As long as you're using a standard Python build, you don't need to buy
> VC7 to [legally redistribute the C runtime]

Thanks for correcting me here.  I did try and give a flavor of that by
saying that, if you installed a Python installation from a standard
source you were OK, but this helps elucidate it.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unusual exponential formatting puzzle

2005-09-21 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:
> Neal Becker wrote:
> > Like a puzzle?  I need to interface python output to some strange old
> > program.  It wants to see numbers formatted as:
> >
> > e.g.: 0.23456789E01
> >
> > That is, the leading digit is always 0, instead of the first significant
> > digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
> > quite.
> >
> > My solution is to print to a string with the '% 16.9E' format, then parse it
> > with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
> > ideas?
>
> If you have gmpy available...
>
> >>> import gmpy
>
> ...and your floats are mpf's...
>
> >>> s = gmpy.pi(64)
> >>> s
> mpf('3.14159265358979323846e0',64)
>
> ...you can use the fdigits function
>
> >>> t = gmpy.fdigits(s,10,8,0,0,2)
>
> ...to create a seperate digit string and exponent...
>
> >>> print t
> ('31415927', 1, 64)
>
> ...which can then be printed in the desired format.
>
> >>> print "0.%sE%02d" % (t[0],t[1])
> 0.31415927E01

Unless your numbers are negative.

>>> print "0.%sE%02d" % (t[0],t[1])
0.-31415927E03

Drat. Needs work.



And does the format permit large negative exponents (2 digits + sign)?

>>> print "0.%sE%02d" % (t[0],t[1])
0.31415927E-13

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


Re: unusual exponential formatting puzzle

2005-09-21 Thread [EMAIL PROTECTED]

Neal Becker wrote:
> Like a puzzle?  I need to interface python output to some strange old
> program.  It wants to see numbers formatted as:
>
> e.g.: 0.23456789E01
>
> That is, the leading digit is always 0, instead of the first significant
> digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
> quite.
>
> My solution is to print to a string with the '% 16.9E' format, then parse it
> with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
> ideas?

If you have gmpy available...

>>> import gmpy

...and your floats are mpf's...

>>> s = gmpy.pi(64)
>>> s
mpf('3.14159265358979323846e0',64)

...you can use the fdigits function

>>> t = gmpy.fdigits(s,10,8,0,0,2)

...to create a seperate digit string and exponent...

>>> print t
('31415927', 1, 64)

...which can then be printed in the desired format.

>>> print "0.%sE%02d" % (t[0],t[1])
0.31415927E01

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


Re: Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-21 Thread Michael Sparks
Paul Rubin wrote:
> Michael Sparks <[EMAIL PROTECTED]> writes:
>> Rather than re-inventing wheels I thought I'd pick a library sit down
>> and see how pycrypt's meant to be used before actually going anyway.
>> (Amongst other reasons, this is why I suspected me, rather than the
>> library :-)
> 
> Pycrypt doesn't operate at anything like the level you need.  It just
> gives you low level cipher primitives.  You need higher level protocols.

Agreed. As I say I'm building up systems slowly on this front, and part of
the aim will be to show how outright dumb it is to build these things
without a decent understanding of the underlying tech.

Sadly there's many people (where I work) who don't understand how easy
it is to get these things wrong, and unfortunately practical demonstration
is one of the few languages people listen to :-/

This is where I border on being unprofessional so I'll be quiet at that
stage :-((

On a more positive note, as I say I picked something simple initially, and
have no intention at this stage of it being the primary approach.

>> FWIW, I'm well aware how easy it is to get cipher/digest/etc based
>> security/id systems wrong. I'm really starting with pycrypt because it
>> looked simple enough, low level enough and self contained enough to
>> act as a base for working with existing more complex systems.
> 
> Do yourself a favor and stick to something standard like TLS, rather
> than cook up your own protocol.  There are some Python wrappers for
> OpenSSL or GNU TLS, for example.

If those operated over multicast then they'd be an option... However...

Incidentally our primary use is to indicate *integrity* of data not to
prevent content being viewed. It's also obviously susceptible to attack
in many ways. Again, I'd say more offline about this - Usenet is just the
wrong place for it.

>> Anyway, once I've gone through all of the existing digests/ciphers/PK
>> ciphers, I'll post the snippets up on our site as raw examples for
>> pycrypto, which will hopefully be a) correct usage b) be useful to
>> others.
> 

> You really need to know a lot more than it sounds like you know, 

*shrug* It's not a matter of what I don't know it's a matter of showing how
things can be used, and I want to use it (internally) to demonstrate what
goes wrong when people try to design their own systems naively.

One way to learn is to build. 

> to have any chance of getting fancy protocol designs correct.

FWIW, I have little intention of inventing something new (in terms of
protocols) /if/ possible. What these components will be used for is to
demonstrate how they work inside, and what goes wrong if people try to
reinvent wheels.

Quite frankly we *should* be using a crypto professional, however that's
currently not a realistic option :-((( As a result currently it's up to me
to demonstrate here the risks involved in creating your own system.

>  http://www.cs.ucdavis.edu/~rogaway/classes/227/spring05/book/main.pdf
> 
> is a textbook that will show you how to do this, or at least give you
> an idea of what you're dealing with.  Watch out, it is rather theoretical.

That's fine/great :) - thanks for the reference :-)

FWIW, I *do* have a good idea of what I'm dealing with, //which is why// I'm
pessimistic about getting it right. I might have more experience with these
things than those I'm working with, however I am very aware of my
(current :) limits. Hopefully I'll be able to use these tools educate those
around me why rolling your own is an idea fraught with issues.

Best Regards,


Michael.

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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread Fredrik Lundh
Scott David Daniels wrote:

> MS is fairly determined to get you develop money; you may not
> redistribute the C runtime with your app from the "free" stuff.

that's a myth, based on a flawed reading of the MS license.  to repeat
myself from various other fora:

"As long as you're using a standard Python build, you don't need to buy
VC7 to [legally redistribute the C runtime]. The python.org team uses a
properly licensed VC7 to build Python, which turns Python into "licensee
software" and you into a "distributor" doing "further distribution" of Python
to end users (with your own stuff added on top, of course). And further
distribution is perfectly okay, as long as you only ship the MS components
together with proper "licensee software" (=Python), and that all parties
respect the relevant portions of the original EULA (this basically means
that you cannot use tricks to circumvent the MS EULA, e.g. by attempting
to relicense the MS DLL's under less restrictive licenses or "viral" licenses.
The same applies to all other licensed components, of course. You cannot
relicense the Python core either.)."
"(If in doubt, consult a real lawyer. If you do, make sure that he/she under-
stands the various levels here -- i.e. that "you" in the MS EULA applies to
the Python developers, not yourself)."

 



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


unusual exponential formatting puzzle

2005-09-21 Thread Neal Becker
Like a puzzle?  I need to interface python output to some strange old
program.  It wants to see numbers formatted as:

e.g.: 0.23456789E01

That is, the leading digit is always 0, instead of the first significant
digit.  It is fixed width.  I can almost get it with '% 16.9E', but not
quite.

My solution is to print to a string with the '% 16.9E' format, then parse it
with re to pick off the pieces and fix it up.  Pretty ugly.  Any better
ideas?


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


Re: Writing a parser the right way?

2005-09-21 Thread Steven Bethard
Christopher Subich wrote:
> beza1e1 wrote:
> 
>> Well, a declarative sentence is essentially subject-predicate-object,
>> while a question is predicate-subject-object. This is important in
>> further processing. So perhaps i should code this order into the
>> classes? I need to think a little bit more about this.
> 
> A question is subject-predicate-object?
> 
> That was unknown by me.
> 
> Honestly, if you're trying a general English parser, good luck.

I second that.  Have you read any of the natural language processing 
reasearch in this area?  There are a variety of English parsers already 
available?  Googling for "charniak parser" or "collins parser" should 
get you something.  I believe Dan Bikel has one too.  Those are trained 
on Wall Street Journal text.  You might also look into Minipar, which is 
rule-based and not as WSJ specific.

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


Re: Question About Logic In Python

2005-09-21 Thread Terry Reedy
> On Wed, 21 Sep 2005 09:03:00 +1000, Steven D'Aprano 
> <[EMAIL PROTECTED]> wrote:
>>In practice, how often do you really care that your truth values have the
>>specific values 0 and 1 rather than anything false and anything true? In
>>what circumstances?

Another example: you have an exam with N questions and score the answers 
True or False.  The number correct is the sum of the True/False scores.  I 
have done things like this in other languages with explicit 1/0 for 
True/False.

Terry J. Reedy



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


Re: Writing a parser the right way?

2005-09-21 Thread Paul McGuire
"beza1e1" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm writing a parser for english language. This is a simple function to
> identify, what kind of sentence we have. Do you think, this class
> wrapping is right to represent the result of the function? Further
> parsing then checks isinstance(text, Declarative).
>
> ---
> class Sentence(str): pass
> class Declarative(Sentence): pass
> class Question(Sentence): pass
> class Command(Sentence): pass
>
> def identify_sentence(text):
> text = text.strip()
> if text[-1] == '.':
> return Declarative(text)
> elif text[-1] == '!':
> return Command(text)
> elif text[-1] == '?':
> return Question(text)
> return text
> ---
>
> At first i just returned the class, then i decided to derive Sentence
> from str, so i can insert the text as well.
>
Andreas -

Are you trying to parse any English sentence, or just a limited form of
them?  Parsing *any* English sentence (or question or interjection or
command) is a ***huge*** undertaking - Google for "natural language" and you
will find many efforts (with substantial time and money and manpower
resources) working on this problem.  Applications range from automated
language translation to helpdesk automated analysis.  I really suggest you
do a bit of research on this topic, just to get an idea of how big this job
is.  Here's a Wikipedia link:
http://en.wikipedia.org/wiki/Natural_language_processing

Here are some simple examples, that quickly go beyond
subject-predicate-object:

I drive a truck.
I drive a red truck.
I drive a red truck to work.
I drive a red truck to the shop to work on it.
I drive a red truck to the shop to have some work done on it.
I drive a red truck very fast.
I drive a red truck through a red light.

Then factor in other sentences (past and future tenses, past and future
perfect tenses, figurative metaphors) and parsing general English is a major
job.  The favorite test case of the natural language folks is "Time flies
like an arrow," which early auto-translation software converted to "Temporal
insects enjoy a pointed projectile."

On the other hand, if you plan to limit the type and/or content of the
sentences being parsed (such as computer system commands or adventure game
inputs, or descriptions of physical objects), then you can scope out a
reasonable capability by choosing a vocabulary of known verbs and objects,
and avoiding ambiguities (such as "set", as in "I set the set of glasses
next to the TV set," or "lead" as in "Lead me to the store that sells lead
pencils.").

Hope this sheds some light on your task,
-- Paul


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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread Scott David Daniels
vincent wehren wrote:
> "vj" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
> news:[EMAIL PROTECTED]
> | Unfortunately I get another error
> |
> | Your DB2 root is: C:\Program Files\IBM\SQLLIB\
> | running install
> | running build
> | running build_py
> | creating build
> | creating build\lib.win32-2.4
> | copying DB2.py -> build\lib.win32-2.4
> | running build_ext
> | error: The .NET Framework SDK needs to be installed before building
> | extensions f
> | or Python.
> 
> You need the same compiler Python 2.4 was compiled with to compile CPython 
> extensions from source. Alternatively, you might look into getting some 
> precompiled Windows Binaries for pydb2 (try Googling for them or the pyDB2 
> mailing list).

Actually, "the same" is not necessary on Windows; you need a
"compatible" compiler.  MinGW, MS VC, and Intel's compiler are all
"compatible"  The big trick is that Python 2.4 switched versions,
and was built with VC 7.1 (previous Windows python editions were
built with 6.0).  So you need either VC 7.1, the ".Net" C compiler
available for direct download from MS (actually you need two large
downloads, but you may not "pass them around" after downloading),
a 7.1-compatible version for the Intel compiler, or a MinGW compiler
compatible with the 7.1 runtimes.  Note, this switch of compilers was
based in part on the fact that there is no longer any way to legally
buy a VC 6.0 compiler; MS no longer sells that version.  At least you
either buy the 7.1 compiler or download the packages yourself.

I have managed to get the VC stuff from the download to work, but I did
it in part by hacking the distutils code in Python 2.4.  I presume
that over time, we will get better about this.  Also note, if you
do intend to build products for delivery to customers on Windows,
MS is fairly determined to get you develop money; you may not
redistribute the C runtime with your app from the "free" stuff.
If you pay the fee for 7.1, you can get the redistribution rights.
However, by installing Python 2.4 on the customer machine, you
will have installed a working VC runtime.  The official Python 2.4
windows distribution, ActiveState's Python distribution, and probably
a few other distributions all will install the VC runtime if necessary,
and are built by people with the right to redistribute it.  So, at the
cost of a two-step install, you can legally build and distribute Python
2.4 apps.

In case you don't know: I am not a lawyer; don't regard my guesses about
the legal status of things as definitive; don't base a business model on
this without consulting a lawyer; your mileage may vary; objects in the
mirror may be closer than they appear.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUIs

2005-09-21 Thread Tuvas
Thank you very much! That managed to fix the problem!

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


Re: Python GUIs

2005-09-21 Thread Lonnie Princehouse
B is a tuple if it's assigned that way.  Tuples are immutable.
To make a list instead, you need square brackets:
   B = ['\x12', '\x32']

Regarding your original post, you'll probably have to ask more specific
questions if you want to get good answers.

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


set IDLE scrollback size?

2005-09-21 Thread hannibal_has_a_van
How may I increase the scrollback buffer size in IDLE? The amount I can
scroll up now in IDLE is nice, but I'd like to make the scroll buffer
larger. I've checked the docs, config files, and comp.lang.python
archive, but I have not found a way to resize the lines I can scroll up.

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


Re: Finding where to store application data portably

2005-09-21 Thread Tony Houghton
Steven D'Aprano wrote:
 > On Tue, 20 Sep 2005 23:03:52 +0100, Tony Houghton wrote:
 >
 >
 >>I'm using pygame to write a game called Bombz which needs to save some
 >>data in a directory associated with it. In Unix/Linux I'd probably use
 >>"~/.bombz", in Windows something like
 >>"C:\Documents And Settings\\Applicacation Data\Bombz".
 >
 > In Windows, you shouldn't hard-code the drive letter. I don't know 
how you
 > find out what the correct value is, but hard-coding it is just Bad.

That's why I said "something like". It seems there is a definitive way
of finding the correct value, but it needs extra W32 extensions
installed. You could also start from os.path.expanduser('~') I suppose.

 > As a Linux user, I really am sick of every damn application, script and
 > program under the sun filling the top level of my home directory with
 > dot-files.
 >
 > I wish the Linux Standard Base folks would specify that settings files
 > should all go into a subdirectory like ~/settings rather than filling up
 > the home directory with cruft. That was acceptable in the days when 
people
 > only looked at their files with ls, but in these days of GUI file
 > managers, it is ridiculous that there are more than 100 dot files and
 > directories in my home directory.

Don't all file managers have an option to hide files beginning with '.'?

 > 
 >
 > Can I ask developers to break with the obsolete and annoying habit of
 > creating user-specific config files as ~/.app-name and use
 > ~/settings/app-name instead?
 >
 > 

You'll probably like the XDG basedir spec then:


I suppose I should really use that, but the trouble is it can be very
difficult to decide whether some files are config or data, so it would
be nice to have a standard that doesn't segregate the two.

Thanks to everyone else who's replied. I've saved Trent Mick's script
for later reference.

-- 
The address in the Reply-To is genuine and should not be edited.
See  for more reliable contact 
addresses.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUIs

2005-09-21 Thread Dan
> B='\x12','\x32'
> B[0]='\x12'
>
> I cannot get this to work,

"B" is a tuple, which means it can't be assigned to. Try this:
  B=['\x12','\x32']

-- 
  Do I know what's in this bill? Are you kidding? Only God knows...
  - U.S. Senator Robert Byrd, when asked if he knew the
contents of a $520 billion, 4000-page spending bill


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


The .NET Framework SDK needs to be installed before building

2005-09-21 Thread vj
I have installed the .NET Framework SDK 1.1.
Yet I recieve this error message when I install PYDB2.

Could you please pour in your suggestions .
Thanks.

Vj.

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


Re: Question About Logic In Python

2005-09-21 Thread Ron Adam
Steven D'Aprano wrote:

>>So..
>>
>>bool(a and b) * value
>>
>>Would return value or zero, which is usually what I want when I do this 
>>type of expression.

> That's all very interesting, and valuable advice for somebody who doesn't
> understand how Python's logical operators work, but the question is, when
> would you actually want that type of expression?

It's a filter which returns a value or zero depending on conditions a and b.

Some examples...

High pass filter:

 (value > 0) * value

Low pass filter:

 (value < 0) * value

Band pass filter:

 (min < value < max) * value


Changing and and or to return bools only, doesn't prevent us from doing 
anything we can already do.  It just means changing the context to 
explicitly return a non bool when you want one as I did here.

> In practice, how often do you really care that your truth values have the
> specific values 0 and 1 rather than anything false and anything true? In
> what circumstances?

We can separate these into two groups...

1. True and false condition testing in which the result of the 
condition is not used in any further expressions.

You are correct in this case, it doesn't matter. Any True values would work.

2. Expressions that will be used in a calculation or another 
expression.

This matters because if you aren't careful your results may not be what 
you expect.

But group (2) can also be a part of group (1).  So then again it may 
matter there too.

This has more to do with clarity and separating function into forms that 
have the potential for least surprises.  Or to put it another way, forms 
that are predictable with no exceptional circumstances.

In boolean math it is useful to add and subtract.
 >>> a = b = True
 >>> a + b
2   # Non boolean result.

 >>> True * True
1   # Why not return True here as well?

This is like adding two integer types and getting a float.


There's the possibility of adding two (normally) True values and getting 
a False result.

 >>> a = True
 >>> b = -1
 >>> a + b  # True_value + True = False_value
0


Should bool type act like bools as expressed here?

 http://www.ee.surrey.ac.uk/Projects/Labview/boolalgebra/

 # P1: X = 0 or X = 1
 # P2: 0 . 0 = 0
 # P3: 1 + 1 = 1
 # P4: 0 + 0 = 0
 # P5: 1 . 1 = 1
 # P6: 1 . 0 = 0 . 1 = 0
 # P7: 1 + 0 = 0 + 1 = 1

 Table 1: Boolean Postulates

Python's bools work this way if you use 'and' and 'or' and always cast 
any non bools to bools first.  But it would be easier IMO if bool 
operations gave bool results so I wouldn't need to do:

bool_result = a and bool(b)

or

bool_result = bool(a and b)

On one hand these seem like little things, but little things is 
sometimes what will bite you the hardest as they are more likely to get 
by your guard.

Cheers,
Ron























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


Re: Python GUIs

2005-09-21 Thread Gerald Klix
if you write
B = '\x12','\x32'
you get an immutable tuple.

To get a mutable list use:
B = [ '\x12','\x32' ]

HTH,
Gerald

Tuvas schrieb:
> As a bit more of an update, I have decided to create a list of strings,
> but am having a problem. To illistrate this in a simple manner.
> 
> B='\x12','\x32'
> B[0]='\x12'
> 
> I cannot get this to work, and I need to get it to work somehow. How
> can I make it happen? Is there a function that I should use, a special
> trick, etc? Or is there just no way to make it work? Thanks!
> 

-- 
GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634

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


Re: Python GUIs

2005-09-21 Thread Tuvas
As a bit more of an update, I have decided to create a list of strings,
but am having a problem. To illistrate this in a simple manner.

B='\x12','\x32'
B[0]='\x12'

I cannot get this to work, and I need to get it to work somehow. How
can I make it happen? Is there a function that I should use, a special
trick, etc? Or is there just no way to make it work? Thanks!

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


Re: Writing a parser the right way?

2005-09-21 Thread Christopher Subich
beza1e1 wrote:
> Well, a declarative sentence is essentially subject-predicate-object,
> while a question is predicate-subject-object. This is important in
> further processing. So perhaps i should code this order into the
> classes? I need to think a little bit more about this.

A question is subject-predicate-object?

That was unknown by me.

Honestly, if you're trying a general English parser, good luck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Brute force sudoku cracker

2005-09-21 Thread Tom Anderson
On Mon, 19 Sep 2005, Antoon Pardon wrote:

> Op 2005-09-17, Tom Anderson schreef <[EMAIL PROTECTED]>:
>> On Fri, 16 Sep 2005, Bas wrote:
>>
>>> -any ideas how to easily incorporate advanced solving strategies? 
>>> solve(problem1) and solve(problem2) give solutions, but 
>>> solve(problem3) gets stuck...
>>
>> the only way to solve arbitrary sudoku problems is to guess.
>
> That is strange, in al the puzzles that I have solved untill now, I 
> never needed to guess, unless the puzzle had multiple solutions, which 
> personnally I find inferior.

Well, if we are to believe Lance Fortnow, a fairly expert comptational 
complexionist, that's probably not generally true:

http://weblog.fortnow.com/2005/08/sudoku-revisited.html

It's this bit:

"Since we don't believe that NP has fast probabilistic algorithms, we 
expect that there are no efficient procedures to completing a generalized 
Sudoku grid"

That makes me think that there probably isn't a non-backtracking method, 
since that would almost certainly be polynomial-time.

The thing is, the puzzles you encounter in the wild have been designed to 
be solved by humans, using non-backtracking methods; they're much easier 
to solve than the general class of Sudoku.

tom

-- 
everything from live chats and the Web, to the COOLEST DISGUSTING 
PORNOGRAPHY AND RADICAL MADNESS!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Python GUIs

2005-09-21 Thread Tuvas
I have a program that I am devoloping, that uses python as a GUI
interface for a camera that we am building. Our camera is controlled
using an 8 byte control squence, depending on the command, will have
several configurations for each byte. I need to be able to have some
way to manage all 8 bytes without interferance with the other. As the
commands we have developed are in hex, that would make life even easier
if I can somehow controll them using hex. The output is in a similar
manner. Any help that you could give me on how to go about doing this
would be greatly appreciated. Thanks!

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


Re: Brute force sudoku cracker

2005-09-21 Thread Tom Anderson
On Wed, 21 Sep 2005 [EMAIL PROTECTED] wrote:

> Excellent strategies are provided by Dan Rice's blog:
> http://sudokublog.typepad.com/sudokublog/2005/08/two_and_three_i.html

There's an interesting remark in this post:

http://sudokublog.typepad.com/sudokublog/2005/08/where_do_sudoko.html

"Some Sudoku generators skip the step of generating a board altogether. 
It's enough to place some random numbers in the board and see if it has a 
solution. For a backtracking solver, which can solve puzzles very quickly,
   ^^^
the time wasted analyzing impossible sets of clues will be minor. For a 
human-style solver, it seems reasonable to exclude the possibility of 
self-contradictory clues by first generating a consistent underlying 
board."

He seems to think that backtrackers are faster than reasoners. That's 
somewhat counter-intuitive; i wonder if it's really true. It would 
certainly be rather sad if it was.

> You won't find any better solver than this:
> http://sudoku.sourceforge.net/

That's a fairly straightforward backtracker. In fact, it's the solver 
which inspired me to write mine - which i believe has a more sophisticated 
heuristic (i haven't compared them formally, but my heuristic 
sophistication estimation heuristic - which is itself, of course, fairly 
sophisticated - suggests that it is). Clearly, what we need is a sudoku 
solver shootout.

tom

-- 
everything from live chats and the Web, to the COOLEST DISGUSTING PORNOGRAPHY 
AND RADICAL MADNESS!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: slicing functionality for strings / Python suitabilityforbioinformatics

2005-09-21 Thread Tom Anderson
On Wed, 21 Sep 2005, Fredrik Lundh wrote:

> Tom Anderson wrote:
>
>> There's a special hell for people who override builtins.
>
> which is, most likely, chock full of highly experienced python 
> programmers.

You reckon? I've never felt the need to do it myself, and instinctively, 
it seems like a bad idea. Perhaps i've been missing something, though - 
could you give me some examples of when overriding a builtin is a good 
thing to do?

tom

-- 
Fitter, Happier, More Productive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access CSV data by column name..

2005-09-21 Thread Larry Bates
The CSV module has a DictReader method that will read each
line into a dictionary with the keys being named by the
column names found on the first line.  If the file doesn't have
the first line, it appears you can provide the fieldnames
as a keyword argument to DictReader instead (haven't used this
feature).

<---test file--->
"name","address","city","state","zip","telephone"
"James R. Smith","1234 Vista Lane","Atlanta","GA","30301","4045551212"
"Bill G. Jones","555 Peachtree Lane","Atlanta","GA","30316","4045552323"
"Elanor Allen","7435 Cobb Drive","Atlanta","GA","30332","4045551212"
<--->

import csv
fp=open(r'c:\test.txt','r')
inputfile=csv.DictReader(fp)
for record in inputfile:
print record

fp.close()

{'city': 'Atlanta', 'name': 'James R. Smith', 'zip': '30301',
'telephone': '4045551212', 'state': 'GA', 'address': '1234 Vista Lane'}
{'city': 'Atlanta', 'name': 'Bill G. Jones', 'zip': '30316',
'telephone': '4045552323', 'state': 'GA', 'address': '555 Peachtree Lane'}
{'city': 'Atlanta', 'name': 'Elanor Allen', 'zip': '30332',
'telephone': '4045551212', 'state': 'GA', 'address': '7435 Cobb Drive'}

Larry Bates


Michael March wrote:
> I have seen a few recipes out there that allow for access to DB-API
> columns by their name instead of column number.. I was wondering if
> anyone knew of any code snippets that allow for the same thing with the
> CSV module?
> 
> thanks!
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Access CSV data by column name..

2005-09-21 Thread Michael March
I have seen a few recipes out there that allow for access to DB-API
columns by their name instead of column number.. I was wondering if
anyone knew of any code snippets that allow for the same thing with the
CSV module?

thanks!



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


Re: spe stani collapse all method?

2005-09-21 Thread SPE - Stani's Python Editor
It shouldn't be hard to implement. If you have a bit of python
knowledge you could contact me & write a patch. Otherwise file it as a
feature request.
Stani

http://pythonide.stani.be

[EMAIL PROTECTED] wrote:
> hello,
>
> I wonder if anyone used spe stani, I'm looking for how to collapse all
> code fold, but can't find.
> 
> pujo

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


Re: Perl's documentation come of age

2005-09-21 Thread Måns Rullgård
This guy deserves two ascii trolls:

  ___
  /|  /|  |  |
  ||__||  |  Please do   |
 /   O O\__ NOT  |
/  \ feed the|
   /  \ \ trolls |
  /   _\ \ __|
 /|\\ \ ||
/ | | | |\/ ||
   /   \|_|_|/   \__||
  /  /  \|| ||
 /   |   | /||  --|
 |   |   |// |  --|
  * _|  |_|_|_|  | \-/
   *-- _--\ _ \ //   |
 /  _ \\ _ //   |/
   *  /   \_ /- | - |   |
 *  ___ c_c_c_C/ \C_c_c_c


 +---+ .:\:\:/:/:.
 |   PLEASE DO NOT   |:.:\:\:/:/:.:
 |  FEED THE TROLLS  |   :=.' -   - '.=:
 |   |   '=(\ 9   9 /)='
 |   Thank you,  |  (  (_)  )
 |   Management  |  /`-vvv-'\
 +---+ / \
 |  |@@@  / /|,|\ \
 |  |@@@ /_//  /^\  \\_\
   @x@@x@|  | |/ WW(  (   )  )WW
   \/|  |\|   __\,,\ /,,/__
\||/ |  | |  jgs (__Y__)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
==

-- 
Måns Rullgård
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread Kreedz
Could Windows version have anything to do with this?? Else I've got
some really weird issue...

I'm on Windows 2000 Professional

- Kreedz

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


Re: Perl's documentation come of age

2005-09-21 Thread Keith Thompson
"Xah Lee" <[EMAIL PROTECTED]> writes:
[ the usual ]

 +---+ .:\:\:/:/:.
 |   PLEASE DO NOT   |:.:\:\:/:/:.:
 |  FEED THE TROLLS  |   :=.' -   - '.=:
 |   |   '=(\ 9   9 /)='
 |   Thank you,  |  (  (_)  )
 |   Management  |  /`-vvv-'\
 +---+ / \
 |  |@@@  / /|,|\ \
 |  |@@@ /_//  /^\  \\_\
   @x@@x@|  | |/ WW(  (   )  )WW
   \/|  |\|   __\,,\ /,,/__
\||/ |  | |  jgs (__Y__)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
==

-- 
Keith Thompson (The_Other_Keith) [EMAIL PROTECTED]  
San Diego Supercomputer Center <*>  
We must do something.  This is something.  Therefore, we must do this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread TheSeeker
Hi,

Works for me:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
wxPython 2.6.1.0

Duane

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


Re: Brute force sudoku cracker

2005-09-21 Thread david . blume
Bas, you and I are both a little late to the sudoku python experience.
Here's my feeble attempt:
http://home.earthlink.net/~daliblume/Download/sudoku/index.html
Inspired by this article: http://somethinkodd.com/oddthinking/?p=21

Excellent strategies are provided by Dan Rice's blog:
http://sudokublog.typepad.com/sudokublog/2005/08/two_and_three_i.html

You won't find any better solver than this:
http://sudoku.sourceforge.net/

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


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread Kreedz
Did it freeze for you too with the alt+f while focus on the tab?

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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren
"vj" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Unfortunately I get another error
|
| Your DB2 root is: C:\Program Files\IBM\SQLLIB\
| running install
| running build
| running build_py
| creating build
| creating build\lib.win32-2.4
| copying DB2.py -> build\lib.win32-2.4
| running build_ext
| error: The .NET Framework SDK needs to be installed before building
| extensions f
| or Python.

You need the same compiler Python 2.4 was compiled with to compile CPython 
extensions from source. Alternatively, you might look into getting some 
precompiled Windows Binaries for pydb2 (try Googling for them or the pyDB2 
mailing list).

HTH,
--

Vincent Wehren


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


Re: Organising a python project

2005-09-21 Thread beza1e1
I don't know about a typical python way, but i'd like to know as well
;)

Personally i have a project for my project foo, which has
foo/__init__.py# with all the other modules
doc/# documentation is always a good idea
script/ # everything executable, which later goes into 'bin'
directories by installing
setup.py
README, INSTALL, ... and other standard stuff

Of course often there is other stuff floating around in the base
directory, like some quick test scripts or sketches. And then my
version control system has an additional directory.

My tests are mostly within the modules.

def test():
   return True
if __name__ == "__main__":
   test()

My __init__.py tests every module, if executed directly. So far my
system works. It probably would be good to seperate tests, if they get
bigger.

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


Re: Writing a parser the right way?

2005-09-21 Thread beza1e1
Well, a declarative sentence is essentially subject-predicate-object,
while a question is predicate-subject-object. This is important in
further processing. So perhaps i should code this order into the
classes? I need to think a little bit more about this.

Thanks for your feed for thought! :)

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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vj
Unfortunately I get another error

Your DB2 root is: C:\Program Files\IBM\SQLLIB\
running install
running build
running build_py
creating build
creating build\lib.win32-2.4
copying DB2.py -> build\lib.win32-2.4
running build_ext
error: The .NET Framework SDK needs to be installed before building
extensions f
or Python.

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


Re: Finding where to store application data portably

2005-09-21 Thread Trent Mick
> > > I'm using pygame to write a game called Bombz which needs to save some
> > > data in a directory associated with it. In Unix/Linux I'd probably use
> > > "~/.bombz", in Windows something like
> > > "C:\Documents And Settings\\Applicacation Data\Bombz".
> > 
> > In Windows, you shouldn't hard-code the drive letter. I don't know how you
> > find out what the correct value is, but hard-coding it is just Bad.
> > 
>   XP Pro seems to take
> 
> >>> print os.environ["APPDATA"]
> C:\Documents and Settings\Dennis Lee Bieber\Application Data
> 
>   Though the more consistent might be to hit the registry:
> 
> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
> Folders\AppData
> 
> and to confuse matters, there is also a "Local AppData" entry

It isn't just the drive letter you shouldn't hardcode. In different
locales the phrases "Documents and Settings" and "Application Data"
are often different. The canonical way to get this dir on Windows is by
using the SHGetFolderPath Windows API call with the CSIDL_APPDATA
constant:


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp

In Python code that is:

from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)

Unfortunately that either means having the PyWin32 extensions installed
(which not all Python installations on Windows have) or building your
own small binary extension to make that call. Failing that, using the
registry location or the environment variable above might suffice
Note that on some older Windows flavours -- not sure exactly which --
the APPDATA env. var. might not be defined.

Also note that Windows app guidelines encourage you to have an
additional vendor/owner directory level before the app name. So:

%APPDATA%\\Bombz

I have a little working script that I use for this kind of stuff which
you are welcome too, if it helps. (attached)

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
# Copyright (c) 2005 ActiveState Corp.
# License: MIT
# Author:  Trent Mick ([EMAIL PROTECTED])

"""Cross-platform application utilities:

Utility Functions:
user_data_dir(...)  path to user-specific app data dir
site_data_dir(...)  path to all users shared app data dir
"""
#TODO:
# - Add cross-platform versions of other abstracted dir locations, like
#   a cache dir, prefs dir, something like bundle/Contents/SharedSupport
#   on OS X, etc.
#   
http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Concepts/UserPreferences.html
#   
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
#   
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
#

import sys
import os


class Error(Exception):
pass



def user_data_dir(appname, owner=None, version=None):
"""Return full path to the user-specific data dir for this application.

"appname" is the name of application.
"owner" (only required and used on Windows) is the name of the
owner or distributing body for this application. Typically
it is the owning company name.
"version" is an optional version path element to append to the
path. You might want to use this if you want multiple versions
of your app to be able to run independently. If used, this
would typically be ".".

Typical user data directories are:
Windows:C:\Documents and Settings\USER\Application 
Data\\
Mac OS X:   ~/Library/Application Support/
Unix:   ~/.
"""
if sys.platform.startswith("win"):
# Try to make this a unicode path because SHGetFolderPath does
# not return unicode strings when there is unicode data in the
# path.
if owner is None:
raise Error("must specify 'owner' on Windows")
from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
try:
path = unicode(path)
except UnicodeError:
pass
path = os.path.join(path, owner, appname)
elif sys.platform == 'darwin':
from Carbon import Folder, Folders
path = Folder.FSFindFolder(Folders.kUserDomain,
   Folders.kApplicationSupportFolderType,
   Folders.kDontCreateFolder)
path = os.path.join(path.FSRefMakePath(), appname)
else:
path = os.path.expanduser("~/." + appname.lower())
if version:
path = os.path.join(path, version)
return path


def site_data_dir(appname, owner=None, version=None):
"""Return full path to the user-shared data dir for this application.

"appname" is the name of application.
"owner" (only required and used on Windows) is the name of the
ow

Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren
"vj" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I am new to Python . Please let me where should I issue the command
| "setup.py install".
|
| I have been using the IDLE to run Python scripts.

You need to open the command prompt (e.g. by entering "cmd" in the "Run" 
input box). Now enter "cd C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0" 
to get into the right directory. Now enter "setup.py install" and you should 
be all set..

--
Vincent




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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread Robert Kern
vj wrote:
> When I run the setup.py script , it throws an error
> 
> Traceback (most recent call last):
>   File "C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0\setup.py",
> line 57, in -toplevel-
> libraries=[ db2lib ],
>   File "C:\Python24\lib\distutils\core.py", line 137, in setup
> raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
> SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
> [cmd2_opts] ...]
>or: setup.py --help [cmd1 cmd2 ...]
>or: setup.py --help-commands
>or: setup.py cmd --help
> 
> error: no commands supplied
> 
> 
> Please let me know , what should have been the issue.

You have to give it a command. You probably want

  python setup.py install

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: C#3.0 and lambdas

2005-09-21 Thread Bill Mill
On 9/21/05, Scott David Daniels <[EMAIL PROTECTED]> wrote:
> Roel Schroeven wrote:
> > ...
> > Christophe schreef:
> >> ...
> >>And what about a function which computes the line length ?
> >
> > That would have been a better example indeed, since the *p1 trick
> > doesn't work there.
> >
> > def euclidian_distance((x1, y1), (x2, y2)):
> > return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
> >
> > That's a lot nicer, I think, than this:
> >
> > def euclidian_distance(p1, p2):
> > return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
>
> But not massively nicer than:
>
>  def euclidian_distance(p1, p2):
>  (x1, y1), (x2, y2) = p1, p2
>  return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
>

But the question is - why go to the effort to remove the (by your
admission) slightly nicer version?

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread Steve Holden
Kreedz wrote:
> I have written the "import wx" in my message.
> 
> You press F key while holding down Alt while focusing on the tab?
> 
> Python 2.4.1, wxPython 2.6.1.0
> 
Nope. Just slightly incompetent at copy-and-paste when multitasking. 
Looks like you might need to report a bug to the wxPython folks.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.pycon.org

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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vj
I am new to Python . Please let me where should I issue the command
"setup.py install".

I have been using the IDLE to run Python scripts.

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


Re: Perl's documentation come of age

2005-09-21 Thread Steve Holden
Jeremy Jones wrote:
> Ed Hotchkiss wrote:
> 
> 
>>I'm new to Python, not programming. I agree with the point regarding 
>>the interpreter. what is that? who uses that!? Why are most examples 
>>like that, rather than executed as .py files?
> 
> 
> I think showing examples at the Python interpreter prompt is *very* 
> helpful and IMHO a preferred method in plenty of cases.  If I'm showing 
> someone a piece of code that returns some object the type of which 
> you're not really that familiar with, would you rather be running it in 
> a script, or on a command prompt (or, my preference is to either copy 
> and paste the example to a script an run it with ``python -i`` or paste 
> it to an edit in IPython)?  With IPython (or vanilla Python interpreter 
> with parse-and-bind tab completion turned on), you can inspect the 
> object quite easily.  Again, IMHO, much easier than from a script.
> 
> 
>> 
>>Another problem that I have (which does get annoying after awhile), is 
>>not using foo and bar. Spam and Eggs sucks. It's not funny, although 
>>Monty Python does rock. Why not use silly+walks instead.
> 
> 
> Eh.  Life's too short for me to get up in a roar about such as this.  
> And Python's too good of a language for me to be overly bothered by 
> example naming conventions.  YMMV.
> 
Jim Hugunin's keynote speech at this year's PyCon was accompanied by a 
projection if his interactive interpreter session, and I know I wasn't 
alone in finding this a convincing example of Microsoft's (well, Jim's, 
really) full integration of Python into the .net framework.

Modules are good, but the interactive interpreter is a brilliant way to 
show off what modules can do.

As for "Why not foo and bar rather than spam and eggs?", all I can think 
of to say is "Get over it".

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.pycon.org

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


Re: I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vincent wehren

"vj" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| When I run the setup.py script , it throws an error
|
| Traceback (most recent call last):
|  File "C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0\setup.py",
| line 57, in -toplevel-
|libraries=[ db2lib ],
|  File "C:\Python24\lib\distutils\core.py", line 137, in setup
|raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
| SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
| [cmd2_opts] ...]
|   or: setup.py --help [cmd1 cmd2 ...]
|   or: setup.py --help-commands
|   or: setup.py cmd --help
|
| error: no commands supplied
| >>>
|
| Please let me know , what should have been the issue.

You need to say "setup.py install" instead of just setup.py

HTH,
--

Vincent Wehren

|
| Thanks in advance.
|
| Vj
| 


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


  1   2   >