Re: print there!

2005-09-21 Thread Fredrik Lundh
Godwin Burby wrote:

> i think u've misunderstood my question. Your solution will print on a
> new line as below:
> c:\godwin\bl.csv 1
> c:\godwin\bl.csv 2
> c:\godwin\bl.csv 3
> But i want this number to diplay their value increase on the same line
> on the same sport itself without printing the filename multiple times
> on multiple lines:

I think u've misunderstood the answer.

filename = 'c:\\godwin\\bl.csv'
for i,row in enumerate(reader):
# inserts or updates the database
print "\r" + filename, i, # <-- notice the trailing comma
print





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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Fredrik Lundh
Martijn Iseger wrote:

> >> Domain-specific modeling makes software development 5-10 times faster
> >> than approaches based on UML or MDA. It accelerates development and
> >> reduces complexity by automatically generating full code from
> >> higher-abstraction design models.
> >>
> > Wow, look everyone!  A silver bullet!
> >
> Before slashing down in ignorance - educate yourself on www.dsmforum.org.
> After that: feel free to comment.  I will make you look a lot more intelligent
> Peter Hansen.

if you don't understand the "silver bullet" reference, you're not qualified to 
use
phrases like "makes software development 5-10 times faster".





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


Re: webbrowser failing

2005-09-21 Thread Fredrik Lundh
Thomas Thomas wrote:

> import webbrowser
> url='http://www.cnn.com'
> webbrowser.open(url)
>
> giving the error

> WindowsError: [Errno 2] The system cannot find the file specified: 
> 'http://www.cnn.com'

So you have a Windows install that don't understand HTTP paths, most
likely because you (or someone else) has tinkered with the registry.

Possible solutions:

1. fire up your browser and use the browser's "make this browser the default
browser" feature, if available

2. run the  Set Program Access and Default






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


Re: print there!

2005-09-21 Thread davbrow
It's possible you will need to run python -u for this to behave as
expected.  Otherwise python may buffer the output until it sees a
newline so you only see the last result.

-- David

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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread bryan rasmussen
I just wonder about that 5-10 times faster. that's a really wide range. :)


On 9/21/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Martijn Iseger wrote:
> 
> > >> Domain-specific modeling makes software development 5-10 times faster
> > >> than approaches based on UML or MDA. It accelerates development and
> > >> reduces complexity by automatically generating full code from
> > >> higher-abstraction design models.
> > >>
> > > Wow, look everyone!  A silver bullet!
> > >
> > Before slashing down in ignorance - educate yourself on www.dsmforum.org.
> > After that: feel free to comment.  I will make you look a lot more 
> > intelligent
> > Peter Hansen.
> 
> if you don't understand the "silver bullet" reference, you're not qualified 
> to use
> phrases like "makes software development 5-10 times faster".
> 
> 
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webbrowser failing

2005-09-21 Thread Fredrik Lundh
(trying again)

Thomas Thomas wrote:

> import webbrowser
> url='http://www.cnn.com'
> webbrowser.open(url)
>
> giving the error

> WindowsError: [Errno 2] The system cannot find the file specified: 
> 'http://www.cnn.com'

you have a Windows install that don't understand HTTP paths, most likely
because you (or someone else) has tinkered with the registry.

Possible solutions:

1. fire up your browser and use the browser's "make this browser the default
browser" feature, if available

2. use the "Set Program Access and Default" menu (on the start menu) to
   select what browser to use

or

3. use Jem Berkes' SetBrowser tool:

http://www.pc-tools.net/win32/setbrowser/

   (make sure you read the warnings on that page before you proceed),





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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Martijn Iseger
> if you don't understand the "silver bullet" reference, you're not
> qualified to use phrases like "makes software development 5-10 times
> faster".

You could reverse that as well: http://www.dsmforum.org 


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


Re: Object default value

2005-09-21 Thread Fredrik Lundh
"ago" <[EMAIL PROTECTED]> 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)

No.

You can overload certain methods to make an object behave like one
of its attributes in certain contexts (e.g. comparisions, math operations,
conversions), but you cannot do it for all operations.

Especially not the "assignment operator", since there is no such thing in
Python.  (assignment is a statement, and it's an operation on the target
namespace, not the source object).

(As always, Python works better if you use it to write Python programs)





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


Re: Premature wakeup of time.sleep()

2005-09-21 Thread Erich Schreiber
Thank you every body for your comments.

Especially Jeff Epler for your hint about NTP. You're right. I see a
(constant but somewhat huge)time drift of about 1 ms/min which I can
correct for.

Thank you Steve Horsley for the clarification of the interrupts that
would end the delay. I didn't think of something as trivial as ^C.

And thank you Nick Craig-Wood for the shell script to get hands on the
HZ value. I had to modify it a little as I do not have
/proc/interrupts, but I've got the idea. I measure about 100 and so I
have a 10 ms granularity in my VPS as you predicted.

Erich


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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Steve Holden
Martijn Iseger wrote:
>>if you don't understand the "silver bullet" reference, you're not
>>qualified to use phrases like "makes software development 5-10 times
>>faster".
> 
> 
> You could reverse that as well: http://www.dsmforum.org 
> 
> 
Having taken the time to educate myself (following the repeated spamming 
to promote a seminar) I can offer the following observations, but I am 
omitting the URLs as I believe you've already had far more publicity 
than the site really merits.

1. Any organisation that can talk about "a leap in productivity of 400% 
from Assembler to BASIC" as though nothing occurred in between suffers 
such a total disconnect from computing history that it's hard to take 
other utterances seriously.

2. "The last OOPSLA ... put forward Domain-Specific Modeling as a 
solution. Similar statements have been uttered recently by Bill Gates 
and Grady Booch, among others." The fact that a technique is promoted at 
a conference doesn't mean the book about it came down from a mountain 
carried by a prophet. The technologies the dsmforum site rubbishes were 
similarly promoted. If you *have* to choose a prophet then I'd stick 
with Booch, as Gates has proved many times that he's a far better (or 
anyway more ruthless) businessman than he is a software architect.

3. "Domain-Specific Modeling is only possible because it narrows down 
the design space or domain" presumably means that component-based 
approaches are more successful when the components are created with the 
problem domain in mind. What a surprise.

And so on. Please note I am not saying that DSM has nothing to offer, 
simply that it isn't marketing itself any more effectively (or IMHO any 
more convincingly) than any other comparable technological advance.

Since you appear to be an account or channel manager perhaps the best 
advice I can give you is to leave c.l.py to your technical staff and 
avoid such blatant self-promotion. DSM might seem like a silver bullet 
to you, but others have seen similar claims come and go without major 
changes in software methodology.

You might also like to look up "flowchart" in your dictionary ;-)

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: Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-21 Thread Michael Sparks
Michael J. Fromberger wrote:
...
> Since ARC4 is a stream cipher, the keystream changes over time -- with
> ARC4, after each character enciphered.  To decrypt successfully, you
> need to make sure the decrypting keystream exactly matches the
> encrypting one.
...
 from Crypto.Cipher import ARC4 as cipher
 enc = cipher.new("abcdefgh")
 dec = cipher.new("abcdefgh")
 x = enc.encrypt("This is some random text")
 x
> "\x05o\xd5XH|\xa4\xfc\xf7z\xecd\xe92\xfb\x05rR'\xbf\xc0F\xfc\xde"
 y = dec.decrypt(x)
 y
> 'This is some random text'
 enc.decrypt(x)
> 'M|[bI\x1ciG6A]\x13Hz\xb0\x19\xca\xf1-\x9a\x1a2\x9e%'
> 
> I hope this helps clear up your confusion.

Hi Michael,


Thanks for this, much appreciated. 


Michael
-- 
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.

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


Re: Digest MD5 authentication over using ZSI

2005-09-21 Thread Jakob Simon-Gaarde
Just for the record. After accepting that pythons build-in digest
authentication (HTTPDigestAuthHandler)  does *NOT* work, I made my own
digest authentication handler and built it into ZSI, they have recieved
and accepted the patch so it should be part of the next ZSI release
(current 1.7).

I have tested the implementation with Microsoft MapPoint services,
seems OK:

#-
#Usage example (MapPoint SOAP Services):
#-
from CommonService_services import *
loc = FindServiceLocator()
import sys
import ZSI
kw={'tracefile':sys.stdout, 'auth' : (
ZSI.AUTH.httpdigest, 'username', 'passwd') }
portType = loc.getFindServiceSoap(**kw)

AddressLine='Lergravsvej 28'
PostalCode='8660'
CountryRegion='DK'
InputAddress = ns1.Address_Def()
InputAddress._AddressLine = AddressLine
InputAddress._PostalCode = PostalCode
InputAddress._CountryRegion = CountryRegion

specification = ns1.FindAddressSpecification_Def()
specification._InputAddress = InputAddress
specification._DataSourceName = 'MapPoint.EU'
request = FindAddressSoapInWrapper()

request._specification = specification

res = portType.FindAddress(request)
#-

Best regards 
Jakob Simon-Gaarde

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


spe stani collapse all method?

2005-09-21 Thread [EMAIL PROTECTED]
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: Crypto.Cipher.ARC4, bust or me doing something wrong?

2005-09-21 Thread Paul Rubin
Michael Sparks <[EMAIL PROTECTED]> writes:
> I'm looking at using this library and to familiarise myself writing
> small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
> found that I can't get it to decode what it encodes. This might be a
> case of PEBKAC, but I'm trying the following:

You have to reinitialize the cipher state for decryption, as someone
else explained.  You also have to make sure that keys are unique and
independent for separate messages.  For most applications you probably
want to think about adding authentication.  In general you shouldn't
use arc4 unless you know what you're doing.  What's the application?
-- 
http://mail.python.org/mailman/listinfo/python-list


How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
Hi there,

I would like to copy a file from one machine (machine #01) to another 
(machine #02).

machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
machine #02: Windows Machine, Destination Dir: \temp\files\

Both machines are in one network so they can communicate each other. In 
order to be able to write a file in the directory on Machine #02 I need 
to be the user "myadmin".

In a short Python program I create the source file on Machine #01 like this:

filecontent = 'This is just a test...'
# my own helper method to generate a unique filename
filename = createUniqueFilename()
f = open('/var/files/' + filename, 'w')
f.write(filecontent)
f.close()


Every time a new source file has been created it needs to be copied or 
moved from machine #01 to machine #02.
Are there Python modules which help me doing this job? Any examples how 
to do that would be very helpful.

Kind regards and many thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Would you pls tell me a tool to step debug python program?

2005-09-21 Thread Stephen Kellett
>Johnny Lee wrote:
>> Hi,
>>I've met a problem to understand the code at hand. And I wonder
>> whether there is any useful tools to provide me a way of step debug?
>> Just like the F10 in VC...

Not single stepping, but flow tracing, complete with variables,
parameters and return values. Python Bug Validator.

http://www.softwareverify.com

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


send mail through webmail

2005-09-21 Thread Enrique Palomo Jiménez
Hello all,

i'd like to send mails from my account.
At office it's easy because, i can access directly to the mail server and smpt 
works fine.

but now, i'm working out of office and i can access via web, login, ...

is there a way to send mails by microsoft outlook web access?


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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Martijn Iseger
Hello Steve,

> 1. Any organisation that can talk about "a leap in productivity of
> 400% from Assembler to BASIC" as though nothing occurred in between
> suffers such a total disconnect from computing history that it's hard
> to take other utterances seriously.

I believe the point being made by the organization is that during computing 
history the most successful shifts in productivity were achieved by similar 
shifts in raising the abstraction level on which developers specify solutions. 
According to Capers Jones Software Productivity research Fortran is 4.5 times 
more productive than Assembler. Looking at chronology I'd say it is not 
incorrect 
to refer to the advent of compilers as a leap.

> 2. "The last OOPSLA ... put forward Domain-Specific Modeling as a
> solution. Similar statements have been uttered recently by Bill Gates
> and Grady Booch, among others." The fact that a technique is promoted
> at a conference doesn't mean the book about it came down from a
> mountain carried by a prophet. 

Absolutely. Fact is that both (prophets?) as well as a growing number of 
experts (other prophets?) see this approach as a viable one, hence the 
increased 
interest at a growing number of events.

> 3. "Domain-Specific Modeling is only possible because it narrows down
> the design space or domain" presumably means that component-based
> approaches are more successful when the components are created with
> the problem domain in mind. What a surprise.

Nope, it means that instead of using generic languages (programming or 
modeling) 
to specify solutions on top of your platform/component framework, in many 
cases it makes more sense to use a language that better fits your problem 
domain.
Using components is one way of raising abstraction from the "bottom up" and 
narrowing your design space. Why stop there?
Depending on how the language has been created, a good DSM language is on 
a higher abstraction level than for example C, Java, Python etc. Still, from 
model instances you can generate all the lower level code (which in turn 
interfaces with your component framework). Wouldn't you agree this makes 
development faster and more mature?

> You might also like to look up "flowchart" in your dictionary ;-)
Maybe I will!

Regards,

Martijn


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


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

2005-09-21 Thread Neil Benn
Steve M wrote:

>Well, apparently I fried my brain trying to sort this out. There is a
>typo in my example code in the post but not in my real program. (I know
>it is a no-no when asking help on c.l.py but I simplified some details
>from the real code in order not to confuse the issues. Probably
>backfired by this point.) Below is the post with the error fixed and
>one sentence added (to clarify why the error in my original post really
>was not the problem). Thanks for any advice.
>---
>I'm trying to invoke a Java command-line program from my Python program
>on Windows XP. I cannot get the paths in one of the arguments to work
>right.
>
>The instructions for the program describe the following for the
>command-line arguments:
>
>java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFIG_DIRECTORY
>
>They also give an example:
>
>java -Dsalesforce.config.dir=c:\config -jar sforcedataloader.jar
>
>If I type the example above at the cmd.exe command line the thing works
>(assuming I have the config file in c:\config). What doesn't work is
>these two lines:
>
>cmd = r'java -jar sforcedataloader.jar
>-Dsalesforce.config.dir=c:\config'
>os.system(cmd)
>
>
>  
>
Unless you have fixed your typo in a different place, you have the same 
problem as before.  There are two issues, you need to escape the 
backslash and you have the java properties line in the wrong place.  
Instead of:

cmd = r'java -jar sforcedataloader.jar -Dsalesforce.config.dir=c:\config' 
os.system(cmd)

use

cmd = r'java -Dsalesforce.config.dir=c:\\config -jar sforcedataloader.jar'
os.system(cmd)

Neil

-- 

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : [EMAIL PROTECTED]
Cenix Website : http://www.cenix-bioscience.com

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


Re: /usr/lib/python2.3/site-packages/_mysql.so: undefined symbol: mysql_rollback

2005-09-21 Thread thomas Armstrong
Hi Skip. Thank you very much for your answer.

If LDD:
[EMAIL PROTECTED] /]# ldd /usr/lib/python2.3/site-packages/_mysql.so
libmysqlclient.so.10 => /usr/lib/mysql/libmysqlclient.so.10
(0xf6fb3000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0xf6f84000)
libnsl.so.1 => /lib/libnsl.so.1 (0xf6f6e000)
libm.so.6 => /lib/tls/libm.so.6 (0xf6f4b000)
libz.so.1 => /usr/lib/libz.so.1 (0xf6f3b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0xf6f29000)
libc.so.6 => /lib/tls/libc.so.6 (0xf6e02000)
/lib/ld-linux.so.2 (0x001d8000)

There is no libmysql, but I've got no idea where it is:
[EMAIL PROTECTED] /]# find . -name "*libmysql.so*"
(no results)

In addition, on my PC (where MySQL-python works ok), there is no libmysql:
--
[EMAIL PROTECTED] /]# ldd /usr/lib/python2.3/site-packages/_mysql.so
linux-gate.so.1 =>  (0x00883000)
libmysqlclient.so.10 =>
/usr/local/mysql/lib/mysql/libmysqlclient.so.10 (0x00cbf000)
libz.so.1 => /usr/lib/libz.so.1 (0x00d52000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x0092c000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00ed6000)
libm.so.6 => /lib/tls/libm.so.6 (0x00558000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00db3000)
libc.so.6 => /lib/tls/libc.so.6 (0x0037c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00753000)
[EMAIL PROTECTED] /] find . -name "*libmysql.so*"
(no results)
-

Must I install some extra tool? Thank you very much.


2005/9/16, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> 
> thomas> ImportError: /usr/lib/python2.3/site-packages/_mysql.so: undefined
> thomas> symbol: mysql_rollback
> 
> skip> Is your libmysql.so installed in an odd place?
> 
> Oh, also, try executing
> 
> ldd /usr/lib/python2.3/site-packages/_mysql.so
> 
> If that shows libmysql as undefined.  Find out where it is and set
> LD_LIBRARY_PATH to refer to it, then try again.  If that succeeds, either
> retain the LD_LIBRARY_PATH setting or relink _mysql.so with the -R stuff I
> referred to in my first message.
> 
> Skip
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Would you pls tell me a tool to step debug python program?

2005-09-21 Thread Steve Holden
Johnny Lee wrote:
> Hi,
>I've met a problem to understand the code at hand. And I wonder
> whether there is any useful tools to provide me a way of step debug?
> Just like the F10 in VC...
> 
> Thanks for your help.
> 
> Regards,
> Johnny
> 

The pdb module is a basic starting point for Python's debugging 
features, and can be useful for a single attack on a single truculent bug.

Wing IDE has a stepping debugger. It's not the only tool with this 
feature, but I've found it very convenient, and use it daily. You can 
download a one-month evaluation, as with many similar products.

   http://www.wingware.com/

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: How to copy a file from one machine to another machine

2005-09-21 Thread Tim Golden
[Nico Grubert]

| I would like to copy a file from one machine (machine #01) to another 
| (machine #02).
| 
| machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
| machine #02: Windows Machine, Destination Dir: \temp\files\
| 
| Both machines are in one network so they can communicate each 
| other. In order to be able to write a file in the directory on Machine 
| #02 I need to be the user "myadmin".

| Every time a new source file has been created it needs to be 
| copied or moved from machine #01 to machine #02.

There are several possibilities, depending on what you're happy
to run and where, but perhaps the simplest is to have the share
on the Win32 machine mounted on your Linux box under the appropriate
username and to copy the files there. From your description I assume 
you're in control of the files' creation, but even if you're not
you could use something like python-fam to detect additions.

Is there anything I've missed?

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: How to copy a file from one machine to another machine

2005-09-21 Thread Steve Holden
Nico Grubert wrote:
> Hi there,
> 
> I would like to copy a file from one machine (machine #01) to another 
> (machine #02).
> 
> machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
> machine #02: Windows Machine, Destination Dir: \temp\files\
> 
> Both machines are in one network so they can communicate each other. In 
> order to be able to write a file in the directory on Machine #02 I need 
> to be the user "myadmin".
> 
> In a short Python program I create the source file on Machine #01 like this:
> 
> filecontent = 'This is just a test...'
> # my own helper method to generate a unique filename
> filename = createUniqueFilename()
> f = open('/var/files/' + filename, 'w')
> f.write(filecontent)
> f.close()
> 
> 
> Every time a new source file has been created it needs to be copied or 
> moved from machine #01 to machine #02.
> Are there Python modules which help me doing this job? Any examples how 
> to do that would be very helpful.
> 
This isn't really a Python question, as this problem would exist 
irrespective of the language you are using.

One possibility would be to run Samba (www.smaba.org) on the Linux 
machine so it offered a share to the Windows machine. Then you could 
just write to a UNC path (\\server\path\to\file) from Windows and have 
the file appear on the Linux machine.

Another way would be to use CIFS client on Linux to access the share 
from the Windows machine.

There are many other file sharing solutions, and you can of course also 
consider using FTP to send the file to the Linux server.

Some ideas to start with, anyway.

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


scipy for python 2.4 on windows

2005-09-21 Thread Z.L.
I am a newbie to python, and have not so much experiences on package
installation and related issues. I am looking for Scipy binaries for
python 2.4 on windows.

Could somebody here kindly give some suggestion to this?

Thanks in advance.

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


Re: slicing functionality for strings / Python suitability forbioinformatics

2005-09-21 Thread Tom Anderson
On Wed, 21 Sep 2005, Steven D'Aprano wrote:

> On Mon, 19 Sep 2005 19:40:12 -0700, jbperez808 wrote:
>
>> Having to do an array.array('c',...):
>>
>>  >>> x=array.array('c','ATCTGACGTC')
>>  >>> x[1:9:2]=array.array('c','')
>>  >>> x.tostring()
>>   'AACAGACATC'
>>
>> is a bit klunkier than one would want, but I guess the efficient 
>> performance is the silver lining here.
>
> There are a number of ways to streamline that. The simplest is to merely
> create an alias to array.array:
>
> from array import array as str
>
> Then you can say x = str('c', 'ATCTGACGTC').
>
> A little more sophisticated would be to use currying:
>
> def str(value):
>return array.array('c', value)
>
> x = str('ATCTGACGTC')

There's a special hell for people who override builtins.

> although to be frank I'm not sure that something as simple as this
> deserves to be dignified with the name currying.

It's definitely not currying - it doesn't create a new function. Currying 
would be:

def arraytype(kind):
def mkarray(value):
return array.array(kind, value)
return mkarray

chars = arraytype('c')
seq = chars("tacatcgtcgacgtcgatcagtaccc")

> Lastly, you could create a wrapper class that implements everything you 
> want. For a serious application, this is probably what you want to do 
> anyway:

Definitely - there are lots of things to know about DNA molecules or parts 
of them that aren't captured by the sequence.

tom

-- 
If it ain't Alberta, it ain't beef.
-- 
http://mail.python.org/mailman/listinfo/python-list


Perl's documentation come of age

2005-09-21 Thread Xah Lee
Perl's documentation has come of age: http://perldoc.perl.org/

Python morons really need to learn:

• ample example codes.

• example codes are linked to the appropriate doc location for each
code word in the example.

• written in a task-oriented style, or manifest-functionality style.
That is, it does not have fucking pretensions of a computer science
mode or fucking clean aloofness. It either is oriented towards tasks
programers need to do, as in module documentations, or document the
language as it manifestly functions. (e.g. input, output, side effects;
concrete description of object's methods and variables.)

The Python docs (docs.python.org), is organized in some
incomprehensible computer sciency structure that is impossible to find
anything. And the entire doc go to the extra mile to avoid any
task-oriented writing or examples as if those are pests that can lower
their fucking status. And when the Python docs tries to document its
functions, it doesn't talk straight but instead throwing fucking bunch
of abstract objects and models jargons.

--
The Perl documentations, at least in its presentation (organization,
focus) and technology (DHTML...) aspects, has come of age.

However, the Perl doc's content and writing per se, remains the worst
garbage possible. (and Python's is in the same ball park) The negative
aspects people want to avoid are:

• do not tech geek. Both perlers and pythoners do tech geeking. That
is, mentioning of extraneous jargons, warnings, implementation details,
little style guide here and there, unconscious opportunistic OpenSource
propaganda pitch-ins, historic information provisions, insider jokes,
author masturbation on language design and comparisons... etc. (with
Perl, this may be understandable or irrelevant because it is their
nature and design to be juvenile. They revel in it. But with Python, of
its people's computer sciency aloofness and cleanness pretensions
meanwhile don't really exhibit any ability to think and write better,
are one fucking assholes.)

• Do think clearly before writing. Both Perl and Python docs's
writing quality are extremely bad. What they primarily lack is the
ability to think clearly before writing. Perl docs write in the fashion
of happy-go-lucky juvenile ramble, and Pythoner's in the fashion of
computer sciency confoundedness. Both are incomprehensible.

One easy way to test this, is for Pythoners to read Perl docs and vice
versa.

Pythoners will find that, you really don't know what the fuck the
Perlers are talking about. Same with Perler with Python docs. However,
you will not get the same feeling on well written docs, such as Java or
Mathematica. (assume that the people here have been in the programing
industry for several years, and are not familiar with the other
languages in question.)

What the Perlers & Pythoners need to do, is to horn their skills
outside of coding. Study philosophy, study economics, history, social
sciences, and mathematics. Also, study functional programing or hang
out in functional programing communities or hardcore GNU community many
also improve vastly your critical thinking and doc writing abilities.


More about documentation can be found here:
http://www.xahlee.org/UnixResource_dir/writ/gubni_papri.html

 Xah
 [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: Free seminar on domain-specific modeling

2005-09-21 Thread Steve Holden
Martijn Iseger wrote:
> Hello Steve,
> 
> 
>>1. Any organisation that can talk about "a leap in productivity of
>>400% from Assembler to BASIC" as though nothing occurred in between
>>suffers such a total disconnect from computing history that it's hard
>>to take other utterances seriously.
> 
> 
> I believe the point being made by the organization is that during computing 
> history the most successful shifts in productivity were achieved by similar 
> shifts in raising the abstraction level on which developers specify 
> solutions. 
> According to Capers Jones Software Productivity research Fortran is 4.5 times 
> more productive than Assembler. Looking at chronology I'd say it is not 
> incorrect 
> to refer to the advent of compilers as a leap.
> 
Neither would I. I was simply pointing out that BASIC wasn't the next 
thing after assembly language. Even before Fortran there were a whole 
bunch of what were usually called "autocodes", one of the more popular 
ones in Britain at least being EMA (extended Mercury autocode. So it 
wasn't really a leap, more a sequence of steps.

I could promote nuclear weapons as being a quantum leap above 
rock-throwing (millions of percent more kill efficiency), but I'd be 
falsifying the picture by omitting depressing centuries of weapons 
development in doing so.

Most BASICs weren't compiled languages anyway: BASIC's primary feature 
was the introduction of interactive execution modes and immediate 
edit/run cycling. The addition of compilation to machine code is a 
relatively recent phenomenon for (only some) BASICs, unlike other 
high-level languages.

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: How to copy a file from one machine to another machine

2005-09-21 Thread Tim Golden
[Steve Holden]

| Nico Grubert wrote:
| > Hi there,
| > 
| > I would like to copy a file from one machine (machine #01) 
| to another (machine #02).
| > 
| > machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
| > machine #02: Windows Machine, Destination Dir: \temp\files\

| One possibility would be to run Samba (www.smaba.org) on the Linux 
| machine so it offered a share to the Windows machine. Then you could 
| just write to a UNC path (\\server\path\to\file) from Windows 
| and have the file appear on the Linux machine.

Quite true. The only things are that: he's already running Samba
on the Linux box (see machine #01 above); and he wants to copy *onto* 
the Windows box (machine #02 above). That said, I entirely agree that
it's more of an O/S thing than a language thing and there are no few
possible solutions. (Of course, you could implement a Python-only
solution using, say, Pyro or some home-grown SocketServer, but there
would be an element of wheel-reinvention involved).

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


epydoc, variables and encoding

2005-09-21 Thread Michele Petrazzo
I found a "problem" on epydoc. If I specify an encoding, epydoc not find 
my global variables, and if I remove it, it work well.

code.py:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

MY_VAR = None

class foo(object):
def __init__(self, foo):
"""
Some text
@param foo: Pass me what you want
@type foo: A type
@return: The object
"""
return foo

This not work (MY_VAR is silently skipped), but if I remove:
# -*- coding: utf-8 -*-

it see MY_VAR and put it to my html file.

Is it normal?

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


Re: How to copy a file from one machine to another machine

2005-09-21 Thread Markus Rosenstihl
Hi
I think scp is also a solution. I am sure there exist free sshserveres 
for windows. THat would make the stuff a bit more secure, and the login 
can be automated via public-key.

Regards
Markus

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


Re: Perl's documentation come of age

2005-09-21 Thread Rudy Schockaert
• Do think clearly before writing. 
You should start thinking before you write something. Do you really think anyone takes you serious the way you talk?I haven't seen anything constructive yet from your side. You always have to comment, why don't you start writing documentation yourself if it bothers you so much. Write it the way you think it should be written and show the rest of the community you are capable of doing anything else but fucking qwasting others peoples time.
Rudy
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Free seminar on domain-specific modeling

2005-09-21 Thread Magnus Lycka
Martijn Iseger wrote:
> Before slashing down in ignorance - educate yourself on 
> www.dsmforum.org. After that: feel free to comment. I will make you look 
> a lot more intelligent Peter Hansen.

Talk about throwing stones in glass houses!
-- 
http://mail.python.org/mailman/listinfo/python-list


Writing a parser the right way?

2005-09-21 Thread beza1e1
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.

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


Re: scipy for python 2.4 on windows

2005-09-21 Thread beliavsky
Z.L. wrote:
> I am a newbie to python, and have not so much experiences on package
> installation and related issues. I am looking for Scipy binaries for
> python 2.4 on windows.

Please see the recent thread "use SciPy with Python 2.4.1?" for
discussion of this.

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


Re: slicing functionality for strings / Python suitabilityforbioinformatics

2005-09-21 Thread Fredrik Lundh
Tom Anderson wrote:

> There's a special hell for people who override builtins.

which is, most likely, chock full of highly experienced python programmers.

 



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


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

2005-09-21 Thread Neil Benn
Neil Benn wrote:

>Steve M wrote:
>
>  
>
>>Well, apparently I fried my brain trying to sort this out. There is a
>>typo in my example code in the post but not in my real program. (I know
>>it is a no-no when asking help on c.l.py but I simplified some details
>>
>>
>>from the real code in order not to confuse the issues. Probably
>  
>
>>backfired by this point.) Below is the post with the error fixed and
>>one sentence added (to clarify why the error in my original post really
>>was not the problem). Thanks for any advice.
>>---
>>I'm trying to invoke a Java command-line program from my Python program
>>on Windows XP. I cannot get the paths in one of the arguments to work
>>right.
>>
>>The instructions for the program describe the following for the
>>command-line arguments:
>>
>>java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFIG_DIRECTORY
>>
>>They also give an example:
>>
>>java -Dsalesforce.config.dir=c:\config -jar sforcedataloader.jar
>>
>>If I type the example above at the cmd.exe command line the thing works
>>(assuming I have the config file in c:\config). What doesn't work is
>>these two lines:
>>
>>cmd = r'java -jar sforcedataloader.jar
>>-Dsalesforce.config.dir=c:\config'
>>os.system(cmd)
>>
>>
>> 
>>
>>
>>
>Unless you have fixed your typo in a different place, you have the same 
>problem as before.  There are two issues, you need to escape the 
>backslash and you have the java properties line in the wrong place.  
>Instead of:
>
>cmd = r'java -jar sforcedataloader.jar -Dsalesforce.config.dir=c:\config' 
>os.system(cmd)
>
>use
>
>cmd = r'java -Dsalesforce.config.dir=c:\\config -jar sforcedataloader.jar'
>os.system(cmd)
>
>Neil
>
>  
>
Whoops you are using a raw string - you only need one backslash - the 
java thing is still the same though

Cheers,

Neil

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


Re: Perl's documentation come of age

2005-09-21 Thread Steve Holden
Rudy Schockaert wrote:
> 
> 
> 
> • Do think clearly before writing. 
> 
> 
> 
> You should start thinking before you write something. Do you really 
> think anyone takes you serious the way you talk?
> I haven't seen anything constructive yet from your side. You always have 
> to comment, why don't you start writing documentation yourself if it 
> bothers you so much. Write it the way you think it should be written and 
> show the rest of the community you are capable of doing anything else 
> but fucking qwasting others peoples time.

1. Do not feed the trolls.

2. I offered $100 for a rewrite of the "re" documentation if he could 
persuade 5 regular readers of c.l.py to tell me his version was 
superior. Emails received: 0. 'Nuff said :-)

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: C#3.0 and lambdas

2005-09-21 Thread Serhiy Storchaka
Roel Schroeven wrote:
> Fredrik Lundh schreef:
>>meanwhile, over in python-dev land:
>>
>>"Is anyone truly attached to nested tuple function parameters; 'def
>>fxn((a,b)): print a,b'?  /.../
>>
>>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 for one would not like to see that disappear. I like being able to
> write, for example:
> 
> def drawline((x1, y1), (x2, y2)):
> # draw a line from x1, y1 to x2, y2
> foo(x1, y1)
> bar(x2, y2)
> 
> instead of
> 
> def drawline(p1, p2):
> x1, y1 = p1
> x2, y2 = p2
> # draw a line from x1, y1 to x2, y2
> foo(x1, y1)
> bar(x2, y2)
> 
> or
> 
> def drawline(p1, p2):
> # draw a line from p1[0], p1[1] to p2[0], p2[1]
> foo(p1[0], p1[1])
> bar(p2[0], p2[1])

  def drawline(p1, p2):
  # draw a line from p1 to p2
  foo(*p1)
  bar(*p2)

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


Re: How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
> This isn't really a Python question, as this problem would exist 
> irrespective of the language you are using.
> 
> One possibility would be to run Samba (www.smaba.org) on the Linux 
> machine so it offered a share to the Windows machine. Then you could 
> just write to a UNC path (\\server\path\to\file) from Windows and have 
> the file appear on the Linux machine.
> 
> Another way would be to use CIFS client on Linux to access the share 
> from the Windows machine.
> 
> There are many other file sharing solutions, and you can of course also 
> consider using FTP to send the file to the Linux server.

Hello Steve,

Samba is already installed and configured on the Linux machine. Can I 
just use file=open(,'w') in Python to mount 
the windows share and create the file?
By the way, your book "Python Web Programming" is one of the best python 
books I have read! Really good work!

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


Re: scipy for python 2.4 on windows

2005-09-21 Thread Z.L.
Thank you.

But that thread cannot provide the information on Scipy binaries for
python 2.4 on  Windows. And the python interpreter installed on my
machine is downloaded from www.python.org, not the cygwin version.

In fact, all I need is just weave part of Scipy, not all bundle of
whole Scipy.
Could you give me some suggestions to get weave installed on python
2.4?


[EMAIL PROTECTED] wrote:
> Z.L. wrote:
> > I am a newbie to python, and have not so much experiences on package
> > installation and related issues. I am looking for Scipy binaries for
> > python 2.4 on windows.
>
> Please see the recent thread "use SciPy with Python 2.4.1?" for
> discussion of this.

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


Re: C#3.0 and lambdas

2005-09-21 Thread Christophe
Serhiy Storchaka a écrit :
> Roel Schroeven wrote:
> 
>> Fredrik Lundh schreef:
>>
>>> meanwhile, over in python-dev land:
>>>
>>>"Is anyone truly attached to nested tuple function parameters; 'def
>>>fxn((a,b)): print a,b'?  /.../
>>>
>>>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 for one would not like to see that disappear. I like being able to
>> write, for example:
>>
>> def drawline((x1, y1), (x2, y2)):
>> # draw a line from x1, y1 to x2, y2
>> foo(x1, y1)
>> bar(x2, y2)
>>
>> instead of
>>
>> def drawline(p1, p2):
>> x1, y1 = p1
>> x2, y2 = p2
>> # draw a line from x1, y1 to x2, y2
>> foo(x1, y1)
>> bar(x2, y2)
>>
>> or
>>
>> def drawline(p1, p2):
>> # draw a line from p1[0], p1[1] to p2[0], p2[1]
>> foo(p1[0], p1[1])
>> bar(p2[0], p2[1])
> 
> 
>  def drawline(p1, p2):
>  # draw a line from p1 to p2
>  foo(*p1)
>  bar(*p2)
> 

That one is stupid. I don't see how you can make it work without some 
global storing the p1 information in foo which I would consider as very 
ugly code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a parser the right way?

2005-09-21 Thread Ben Sizer
beza1e1 wrote:
> 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

As far as the parser is concerned, making these separate classes is
unnecessary when you could just store the sentence type as a normal
data member of Sentence. So the answer to your question is no, in my
opinion.

However, when you come to actually use the resulting Sentence objects,
perhaps the behaviour is different? If you're looking to use a standard
interface to Sentences but are going to be doing substantially
different processing depending on which sentence type you have, then
yes, this class hierarchy may be useful to you.

-- 
Ben Sizer

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


Re: C#3.0 and lambdas

2005-09-21 Thread Fredrik Lundh
Christophe wrote:

> >  def drawline(p1, p2):
> >  # draw a line from p1 to p2
> >  foo(*p1)
> >  bar(*p2)
> >
>
> That one is stupid. I don't see how you can make it work without some
> global storing the p1 information in foo which I would consider as very
> ugly code.

if you cannot see how that can work, you clearly haven't done much graphics
programming in your days...

 



-- 
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:
>> I'm looking at using this library and to familiarise myself writing
>> small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4
>> I've found that I can't get it to decode what it encodes. This might
>> be a case of PEBKAC, but I'm trying the following:
> 
> You have to reinitialize the cipher state for decryption, as someone
> else explained.  You also have to make sure that keys are unique and
> independent for separate messages.  

Hmm... Thanks for this.

> For most applications you probably 
> want to think about adding authentication.  

Indeed - though I'm working bottom up. How a key gets transfered
from a to b safely will be another step. Another one will be how to
trust that exchange, for how long, and how much, etc. I'm well aware
that this is a well trod area though, hence why I'm working bottom up.

> In general you shouldn't 
> use arc4 unless you know what you're doing. 

Having looked at how it works from a user perspective, it's fairly
inappropriate anyway, due to wanting to work over unreliable
channels anyway.

> What's the application? 

Components for secure communications and identity confirmation.
Use cases:
   * Signing content multicast by the BBC to indicate that it came from
  the BBC. (ohh, so many issues :-)
   * Signing content captured on a mobile device such that we know that
  it came from that mobile. Specific high level use case of that is
  to be able to accept contributions from people from arbitrary
  devices and know who they came from. Perhaps embedded in the
  essence.
   * Related to that would be the ability to tag content with rights [1]
  information, and to know it's not been tampered with.

[1] eg Who created it. When? Has it been published/broadcast or not?
When? Have additional rights over and above fair use/dealing
been granted (eg creative commons attribution license).

   * Similarly people want the ability to protect data in transit
 between trusted end points. 

Some people using the system would probably be looking to build
restrictions management as well, but that's largely beyond the scope
of our system. Indeed restrictions management would require breaking
our system.

For these use cases to work, encryption & digest tools are clearly an
option, and hence having components that support encryption and
digest are (to say the least) useful. They're obviously not the only
techniques though.

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

Given the pycrypt library docs page starts off with:
   "This documentation assumes you have some basic knowledge about
the Python language, but not necessarily about cryptography."

I do for example know enough about cryptography to know that me
devising my own approach is foolhardy. Thus the statement above
appealed :)

As a result I decided to sit down and learn how to use this to form some
basic components for encryption/decryption. Given another part early in
the docs was """A central goal of the author's has been to provide a
simple, consistent interface for similar classes of algorithms.""" I
decided to start off with "sketches"  implementing minimal examples for
each digest and cipher. I'm now working through the Public Key
examples.

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. 

I supsect we'll end up looking at or wrapping some other library
instead/as well, but it struck me as a nice starting point.

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. 

Thanks for the comments,


Michael.
-- 
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.

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


Re: C#3.0 and lambdas

2005-09-21 Thread Steve Holden
Christophe wrote:
> Serhiy Storchaka a écrit :
> 
>>Roel Schroeven wrote:
[...]

>>>or
>>>
>>>def drawline(p1, p2):
>>># draw a line from p1[0], p1[1] to p2[0], p2[1]
>>>foo(p1[0], p1[1])
>>>bar(p2[0], p2[1])
>>
>>
>> def drawline(p1, p2):
>> # draw a line from p1 to p2
>> foo(*p1)
>> bar(*p2)
>>
> 
> 
> That one is stupid. I don't see how you can make it work without some 
> global storing the p1 information in foo which I would consider as very 
> ugly code.

In which case perhaps you should actually try the code. Then once you 
realise it works you can start to figure out why :-). Hint: f(*p1) 
appears as len(p1) separate arguments to the called function.

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: Using Python with COM to communicate with proprietary Windows software

2005-09-21 Thread Paul Casteels
Joakim Persson wrote:
> On Tue, 13 Sep 2005 10:15:18 +0200, Thomas Heller <[EMAIL PROTECTED]>
> wrote:
> 
> 
>>>This _shouldn't_ be too difficult -- I know which methods must be
>>>implemented (basically just some kind of event handling to deal with
>>>randomly arriving log points, should be implemented as "onMsg()" on my
>>>COM server side, and some other similar methods), but I don't really
>>>know how. I have tried doing simple COM servers using win32com, but is
>>>it equally possible to implement such a simple thing in comtypes? I
>>>didn't find any server side examples in comtypes, but perhaps there is
>>>a way?
>>
>>There is not yet any server support in comtypes, but it will be added.
>>In the meantime you could use the ctypes.com package that is included in
>>ctypes itself, there are even samples.
>>
>>Thomas
> 
> 
> Thank you, I will try that. Right now I've been trying to use win32com
> for the server creation, but I haven't been successful yet (have not
> explored it that much yet though). 
> 
> I have registered a COM server (it should only implement two methods,
> "onMsg()" and "onNotify()", which should print whatever is sent to
> them directly to stdout), but I need to create an interface which is
> not an IDispatch interface and pass it on to the proprietary COM
> server. This connection is needed so that the proprietary COM server
> knows where to send the log and control data. 
> 
> Registering the COM object in the registry works fine, but how do I
> make it look like a custom interface from the proprietary COM servers
> point of view? Oh well, I will look at it some more tomorrow and
> hopefully come up with a solution...
> 
Hi Joakim,

  This server I wrote for the Palm Desktop with win32com, it creates a none 
IDispatch COMserver.
  Maybe it can be of help. I am interested in what you find out on this.

Regards,

Paul Casteels


import pythoncom
import pywintypes
import winerror
import types,time,string
import win32com
import win32ui,win32con
import rfc822
import XmlWriter

from win32com.server.exception import COMException
from win32com.server.util import wrap
from win32com.client import gencache,Dispatch,constants
from win32com import universal



# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing and pythoncom.Empty
defaultNamedOptArg=pythoncom.Missing
defaultNamedNotOptArg=pythoncom.Missing
defaultUnnamedArg=pythoncom.Missing

palmApp = 0
outfileName = r'c:\Documents And Settings\paul\My Documents\Python\PDA\cal2.xml'

universal.RegisterInterfaces('{C9B354D8-4A1C-11D5-81D2-00C04FA03755}', 0, 1, 0, 
["IDesktopAddin"])
universal.RegisterInterfaces('{C9B354D8-4A1C-11D5-81D2-00C04FA03755}', 0, 1, 0, 
["IDesktopCommand"])

def d2s(inDate):
 return rfc822.mktime_tz(rfc822.parsedate_tz(inDate))
def s2d(inDate):
 return time.asctime(time.localtime(inDate))



class DesktopCommand:
 global palmApp

 _public_methods_ = ['OnCommand']
 _com_interfaces_ = ['IDesktopCommand']

 def OnCommand(self):
 print "Hello, command"
 print palmApp
 win32ui.MessageBox("PC-Hello","PC-Title",win32con.MB_OK )

class DesktopAddin:
 _public_methods_ = ['GetFrameworkVersion',
 'OnInitialize',
 'OnUninitialize',
 'ShowAboutBox',
 'ShowProperties']
 _reg_progid_ = "PythonPalm.DesktopAddin"
 _reg_clsid_ = "{6F36C1D4-571C-484E-B47B-61297761B3D1}"
 _com_interfaces_ = ['IDesktopAddin']

 def GetFrameworkVersion(self, plVersion=defaultNamedNotOptArg):
 """method GetFrameworkVersion"""
 return 2

 def OnInitialize(self, pUnk=defaultNamedNotOptArg, 
dwCookie=defaultNamedNotOptArg, \
  dwDesktopVersion=defaultNamedNotOptArg, 
lParam=defaultNamedNotOptArg, \
  pbSuccess=defaultNamedNotOptArg):
 """method OnInitialize"""
 global palmApp
 self.cookie = dwCookie
 palmApp = Dispatch(pUnk)
 # add a command
 self.cmd = wrap(DesktopCommand())
 addinMgr = palmApp.AddinManager
 cmdId = 0
 cmdId = addinMgr.AddAddinCommand(self.cookie, "AddressCommand", \
 self.cmd, cmdId)
 cmdDesc = "&Address Command"
#& vbTab & _
#  "Displays a list of 10 contacts." & vbTab & _
#  "Displays 10 contacts"

 addinMgr.AddAddinCommandDetails(cmdId, 0, 0, cmdDesc, 
constants.ePimAddressBook)

 # no data here yet available
 return 1

 def OnUninitialize(self):
 """method OnUninitialize"""
 global palmApp

 of = XmlWriter.XmlFile(outfileName,palmApp.CurrentUser.Name)

 dbPim = palmApp.DateBookPim
 startDate = '1 Jan 2000 0:0:0'
 endDate = '1 Jan 2010 0:0:0'
 events = dbPim.Events(d2s(startDate),d2s(endDate))
 for j in range(events.Count):
 st

Re: Perl's documentation come of age

2005-09-21 Thread Ed Hotchkiss
please feed the trolls.
On 9/21/05, Steve Holden <[EMAIL PROTECTED]> wrote:
Rudy Schockaert wrote:>> >> • Do think clearly before writing.
>> >> You should start thinking before you write something. Do you really> think anyone takes you serious the way you talk?> I haven't seen anything constructive yet from your side. You always have
> to comment, why don't you start writing documentation yourself if it> bothers you so much. Write it the way you think it should be written and> show the rest of the community you are capable of doing anything else
> but fucking qwasting others peoples time.1. Do not feed the trolls.2. I offered $100 for a rewrite of the "re" documentation if he couldpersuade 5 regular readers of 
c.l.py to tell me his version wassuperior. Emails received: 0. 'Nuff said :-)regardsSteve--Steve Holden   +44 150 684 7255  +1 800 494 3119Holden Web LLC 
www.holdenweb.comPyCon TX 2006  www.pycon.org--http://mail.python.org/mailman/listinfo/python-list
-- edward hotchkiss 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: C#3.0 and lambdas

2005-09-21 Thread Christophe
Fredrik Lundh a écrit :
> Christophe wrote:
> 
> 
>>> def drawline(p1, p2):
>>> # draw a line from p1 to p2
>>> foo(*p1)
>>> bar(*p2)
>>>
>>
>>That one is stupid. I don't see how you can make it work without some
>>global storing the p1 information in foo which I would consider as very
>>ugly code.
> 
> 
> if you cannot see how that can work, you clearly haven't done much graphics
> programming in your days...

You should probably notice that graphics library have changed a lot in 
the last 20 years. Also, that one was an example but it could have been :

def draw_circle(c, p):
 """Draws a circle centered on c and which goes through p"""
 pass
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C#3.0 and lambdas

2005-09-21 Thread Christophe
Steve Holden a écrit :
> Christophe wrote:
> 
>> Serhiy Storchaka a écrit :
>>
>>> Roel Schroeven wrote:
> 
> [...]
> 
 or

 def drawline(p1, p2):
# draw a line from p1[0], p1[1] to p2[0], p2[1]
foo(p1[0], p1[1])
bar(p2[0], p2[1])
>>>
>>>
>>>
>>> def drawline(p1, p2):
>>> # draw a line from p1 to p2
>>> foo(*p1)
>>> bar(*p2)
>>>
>>
>>
>> That one is stupid. I don't see how you can make it work without some 
>> global storing the p1 information in foo which I would consider as 
>> very ugly code.
> 
> 
> In which case perhaps you should actually try the code. Then once you 
> realise it works you can start to figure out why :-). Hint: f(*p1) 
> appears as len(p1) separate arguments to the called function.

You should also notice that foo knows the starting point of the line but 
not the ending point and so it can't draw the line. On the other hand, 
bar knows the end point but not the starting point so it can't do the 
job either.

And what about a function which computes the line length ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Benji York
matt wrote:
> Here's something I did recently at work.  
> It contains unittest code and is using
> urllib2.
> http://blog.spikesource.com/pyhton_testcases.htm

If you want to test web sites, you might be interested in 
zope.testbrowser (currently Zope 3 only, but fixing that is on my to do 
list).

You can see an example testbrowser test (which is also both its README 
and its unit tests) at 
http://svn.zope.org/*checkout*/Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt?rev=38050

If there is any interest I'll try to package up a stand-alone version in 
the next few days.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Perl's documentation come of age

2005-09-21 Thread Michael Ekstrand
On Wednesday 21 September 2005 05:41, Xah Lee wrote:
> One easy way to test this, is for Pythoners to read Perl docs and
> vice versa.
>
> Pythoners will find that, you really don't know what the fuck the
> Perlers are talking about. Same with Perler with Python docs.

At the risk of feeding the troll here... point defeated. I learned 
Python before I learned Perl, but consider myself to now be fluent in 
both. And I find the docs for both to be immensely useful and fairly 
well-organized (OK, so sometimes I have to hunt a bit longer than I'd 
like in the Perl docs, but perldoc.perl.org looks promising). And in my 
early stages of Python from C++, and Perl from Python, shell, and C, I 
really didn't have any trouble figuring out what was going on.

So, Guido, Fred Drake, and everyone else involved in writing Python 
docs: done well you have. Keep up the good work. Python IMHO has some 
of the best docs in the open-source world (on a par with Vim).

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


Python win32com com_error: (-2147418113

2005-09-21 Thread g.franzkowiak
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting tuples...

2005-09-21 Thread nidhog

Thank you very much.

I'll look into this immediately.

I edited my code earlier and came up with stringing the groups
(200501202010, sender, message_string) into one string delimited by
'%%%'.

I could then sort the messages with the date string at the beginning as
the one being sorted with the big string in its "tail" being sorted
too.

200501202010%%%sender%%%message_string
200502160821%%%sender%%%message_string
...

After sorting this list of long strings, I could then split them up
using the '%%%' delimiter and arrange them properly for output.

It's crude but at least I achieve what I wanted done.

But both posters gave good advices, if not a bit too advanced for me.
I'll play with them and keep tweaking my code.

Thanks so much!

--
/nh

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


Re: What am I doing wrong?

2005-09-21 Thread Larry Bates
You have been bitten by a well known "feature".  You used
a mutable as default value in your argument list for __init__.

See:
http://www.nexedi.org/sections/education/python/tips_and_tricks/python_and_mutable_n/view


It would be better to write:

class structure:
def __init__(self, folders = None):
self.folders=folders or []

-Larry Bates


keithlackey wrote:
> I'm relatively new to python and I've run into this problem.
> 
> 
> DECLARING CLASS
> 
>   class structure:
>   def __init__(self, folders = []):
>   self.folders = folders
> 
>   def add_folder(self, folder):
>   self.folders.append(tuple(folder))
> 
> 
> 
> Now I try to make an instance of this class
> 
>   structure1 = structure()
>   structure1.add_folder([('foo'),])
>   print structure1.folders
> 
> This returns: [('foo',)]
> 
> This works fine. But when I try to make another instance of that class...
> 
>   structure2 = structure()
>   print structure2.folders
> 
> This now also returns: [('foo',)]
> Even though I haven't added any folders to this new instance
> 
> What am I doing wrong?
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Leo 4.3.3 released

2005-09-21 Thread Edward K. Ream
Leo 4.3.3 final is now available at:

http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.3.3 fixes several bugs reported in Leo 4.3.2 final.

To learn about Leo, see: http://webpages.charter.net/edreamleo/intro.html

The highlights of 4.3.3 (and 4.3.2)
---

- Improved Leo's documentation:
- A tutorial introduction to Leo:
  http://webpages.charter.net/edreamleo/intro.html
- A 5-minute guide to programming with Leo:
  
http://webpages.charter.net/edreamleo/intro.html#quick-start-for-programmers

- The new rst3 plugin creates .html and .tex files from reStructuredText
  embedded in Leo files. Any node of the source outline may contain options 
for
  the rst3 plugin, which makes this plugin much more useful and flexible 
than
  the previous rst plugins. All of Leo's documentation was created using 
this
  plugin from sources in LeoDocs.leo. For full documentation for rst3 see:
  http://webpages.charter.net/edreamleo/rstplugin3.html.

- The spellpyx (spell checking) plugin is now much easier to use.

- The vim and openWith plugins now use Python's subprocess module if it is 
present.

- Improved the Pretty Printing command.

- The usual assortment of bug fixes.

Edward

Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html



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


Re: /usr/lib/python2.3/site-packages/_mysql.so: undefined symbol: mysql_rollback

2005-09-21 Thread skip

thomas> There is no libmysql, but I've got no idea where it is:

Sorry, libmysqlclient.so is the right beastie.

So, look in libmysqlclient.so for a mysql_rollback function (using the nm
command).  Is it possible you have a _mysql.so file that was built with
MySQL 4.x include files but is now linking against MySQL 3.x shared objects?
That's just a guess, but MySQL became more transaction-aware in the 3.x->4.x
transition.  I would guess mysql_rollback is available in 4.x but not 3.x.

Actually, a better place to ask would be on the help forum for the
mysql-python project at Sourceforge:

http://sourceforge.net/projects/mysql-python

Andy Dustman, the author, is generally quite quick to respond.

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


Re: Free seminar on domain-specific modeling

2005-09-21 Thread Michael Sparks
Martijn Iseger wrote:
...
> I believe the point being made by the organization is that during
> computing history the most successful shifts in productivity were
> achieved by similar shifts in raising the abstraction level on which
> developers specify solutions.

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.

Furthermore, virtually all of them get marketed as being the next big
thing that Will Change The World. As a result anyone marketing an idea
in this way meets skepticism. From my perspective your site talks a lot
about general ideas but has little on specifics.

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.

Maybe your approach will change the world. Maybe it won't. If it's
better and it does, good. If it's not better and it does, that's a lot
of effort for no gain. Unfortunately that latter point is a common
result.

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

Best Regards,


Michael.
-- 
This message (and any attachments) contains personal views
which are not the views of the BBC.

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


Syntax error in files with with 'iso-8859-15' coding header

2005-09-21 Thread Berthold Höllmann
I have a default coding header 

# -*- coding: iso-8859-15 -*-

in my python files. I now have Problems with this settings. I
swithched to Python 2.4.1 under Windows. When I import files with the
above coding header I get frequent syntax errors with files that work
flawlessly under Linux. The Syntax error usually appear near
continuation lines of the form

   func(arg1,
arg2,
(list,
 list))

When I change this call to 

   func(arg1, arg2, (list, list))

syntax error goes away as well when I change the coding cookie from:

# -*- coding: iso-8859-15 -*-

to:

# -*- coding: iso-8859-1 -*-

I have these problems only on WinNT with 2.4.1 from python org, not
with my selfcompiled 2.4.1 under Linux. The .py files come from a CVS
repository, so the line endings are converted on checkout.

Is this a known problem or am I doing something totally wrong.

Kind regards
Berthold
-- 
__   Address:
 G /  \ L Germanischer Lloyd
phone: +49-40-36149-7374 -++- Vorsetzen 35   P.O.Box 111606
fax  : +49-40-36149-7320   \__/   D-20459 HamburgD-20416 Hamburg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding where to store application data portably

2005-09-21 Thread Steven D'Aprano
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.

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.



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?




-- 
Steven.

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


wxPython Notebook crash when pressing alt key

2005-09-21 Thread Kreedz
Hi

I've got some really weird issue with a sizer, a text field and a
notebook. Here's an example:

import wx

class A(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent)
self.noteBook = wx.Notebook(self, -1)
self.panel = wx.Panel(self.noteBook, -1)
self.noteBook.AddPage(self.panel, "Page 1", False)
self.text = wx.TextCtrl(self, -1)
sizerMain = wx.BoxSizer(wx.VERTICAL)
sizerMain.Add(self.text, 0)
sizerMain.Add(self.noteBook, 0, wx.EXPAND)
self.SetSizer(sizerMain)

class TRL(wx.Frame):
def __init__(self, parent, id, title="App"):
wx.Frame.__init__(self, None, -1, title, size=(640,480))
self.content = A(self, -1)

app = wx.App()
app.frame = TRL(None, -1)
app.frame.Show(True)
app.MainLoop()

Run this, press ALT+F or ALT+(any other key) and try closing the
application (Its totally frozen) Anybody have a solution to this? Or
have an idea whats hapening and what I am doing wrong?

Thanks

- Kreedz

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


Re: slicing functionality for strings / Python suitability forbioinformatics

2005-09-21 Thread Steven D'Aprano
On Wed, 21 Sep 2005 11:37:38 +0100, Tom Anderson wrote:

> There's a special hell for people who override builtins.

[slaps head]

Of course there is, and I will burn in it for ever...

-- 
Steven.

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


Re: Classes derived from dict and eval

2005-09-21 Thread Kent Johnson
Jeremy Sanders wrote:
> Hi -
> 
> I'm trying to subclass a dict which is used as the globals environment of
> an eval expression. For instance:
> 
> class Foo(dict):
> def __init__(self):
> self.update(globals())
> self['val'] = 42
>  
> def __getitem__(self, item):
> # this doesn't get called from the eval statement
> print "*", item
> return dict.__getitem__(self, item)
> 
> a = Foo()
> 
> print a['val']
> print eval('val*2+6', a)
> 
> The first print statements also prints "* val", but __getitem__ is never
> called by the evaluation in the eval statement.
> 
> Is this a bug? Does anyone have an idea for a workaround? I'm using
> Python 2.3.3.

Try Python 2.4.1:
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> class Foo(dict):
 ... def __init__(self):
 ... self.update(globals())
 ... self['val'] = 42
 ... def __getitem__(self, item):
 ... # this doesn't get called from the eval statement
 ... print "*", item
 ... return dict.__getitem__(self, item)
 ...
 >>> a = Foo()
 >>>
 >>> print a['val']
* val
42
 >>> print eval('val*2+6', a)
* val
90

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


Re: C#3.0 and lambdas

2005-09-21 Thread Steve Holden
Christophe wrote:
> Steve Holden a écrit :
> 
>>Christophe wrote:
>>
>>
>>>Serhiy Storchaka a écrit :
>>>
>>>
Roel Schroeven wrote:
>>
>>[...]
>>
>>
>or
>
>def drawline(p1, p2):
>   # draw a line from p1[0], p1[1] to p2[0], p2[1]
>   foo(p1[0], p1[1])
>   bar(p2[0], p2[1])



def drawline(p1, p2):
# draw a line from p1 to p2
foo(*p1)
bar(*p2)

>>>
>>>
>>>That one is stupid. I don't see how you can make it work without some 
>>>global storing the p1 information in foo which I would consider as 
>>>very ugly code.
>>
>>
>>In which case perhaps you should actually try the code. Then once you 
>>realise it works you can start to figure out why :-). Hint: f(*p1) 
>>appears as len(p1) separate arguments to the called function.
> 
> 
> You should also notice that foo knows the starting point of the line but 
> not the ending point and so it can't draw the line. On the other hand, 
> bar knows the end point but not the starting point so it can't do the 
> job either.
> 
This is rubbish.

   foo(*p1)

is *exactly* equivalent to

   foo(p1[0], p1[1])

and similarly

   bar(p2)

is *exactly* equivalent to

   bar(p2[0], p2[1])

and consequently the second version of drawline is exactly equivalent to 
the first. So, if the second one is useless then so is the first.

> And what about a function which computes the line length ?

I'm not sure what point you are trying to make here. Can you explain?

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: Finding where to store application data portably

2005-09-21 Thread Steve Holden
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.
> 
> 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.
> 
> 
> 
> 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?
> 
> 
> 
> 
While we're asking for the improbable, perhaps we could make that

   ~/.settings/app-name

Ssh has used the ~/.ssh directory for a long time to avoid the need for 
lots of little dot files, and this works quite well. Good luck in your 
campaign!

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: wxPython Notebook crash when pressing alt key

2005-09-21 Thread Steve Holden
Kreedz wrote:
> Hi
> 
> I've got some really weird issue with a sizer, a text field and a
> notebook. Here's an example:
> 
> import wx
> 
> class A(wx.Panel):
> def __init__(self, parent, id):
> wx.Panel.__init__(self, parent)
> self.noteBook = wx.Notebook(self, -1)
> self.panel = wx.Panel(self.noteBook, -1)
> self.noteBook.AddPage(self.panel, "Page 1", False)
> self.text = wx.TextCtrl(self, -1)
> sizerMain = wx.BoxSizer(wx.VERTICAL)
> sizerMain.Add(self.text, 0)
> sizerMain.Add(self.noteBook, 0, wx.EXPAND)
> self.SetSizer(sizerMain)
> 
> class TRL(wx.Frame):
> def __init__(self, parent, id, title="App"):
> wx.Frame.__init__(self, None, -1, title, size=(640,480))
> self.content = A(self, -1)
> 
> app = wx.App()
> app.frame = TRL(None, -1)
> app.frame.Show(True)
> app.MainLoop()
> 
> Run this, press ALT+F or ALT+(any other key) and try closing the
> application (Its totally frozen) Anybody have a solution to this? Or
> have an idea whats hapening and what I am doing wrong?
> 
> Thanks
> 
> - Kreedz
> 
This code works fine for me (once I add an "import wx" at the top).

Python 2.4.1, wxPython 2..5.3.1

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


distutils and decorators

2005-09-21 Thread Robert Brewer
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, so I
put the actual decorated functions into a separate module, and import it
into the test suite only when running Python 2.4:

if sys.hexversion > 0x020400A2:
from cp_decorator_tests import Exposing, ExposingNewStyle

Now "setup.py install" is complaining when run under Python 2.3, since
it tries to byte-compile every .py file. Output from a second install
run:

C:\Python23\Lib\site-packages\cptrunk>python setup.py install
running install
running build
running build_py
running install_lib
byte-compiling
C:\Python23\Lib\site-packages\cherrypy\test\cp_decorator_tests.py to
cp_decorator_tests.pyc
  File
"C:\Python23\Lib\site-packages\cherrypy\test\cp_decorator_tests.py",
line 4
@cherrypy.expose("1")
^
SyntaxError: invalid syntax
running install_data


1. Is there some way to tell setup to skip the byte-compiling on that
single file, or

2. Is there some way to only ship cp_decorator_tests.py if you're
running 2.4, or

3. Is there some better way to optionally test decorators, like using
eval, or

4. other...?


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C#3.0 and lambdas

2005-09-21 Thread Roel Schroeven
Christophe schreef:
> Steve Holden a écrit :
> 
>> Christophe wrote:
>>
>>> Serhiy Storchaka a écrit :
>>>
 Roel Schroeven wrote:
>>
>>
>> [...]
>>
> or
>
> def drawline(p1, p2):
># draw a line from p1[0], p1[1] to p2[0], p2[1]
>foo(p1[0], p1[1])
>bar(p2[0], p2[1])




 def drawline(p1, p2):
 # draw a line from p1 to p2
 foo(*p1)
 bar(*p2)

>>>
>>>
>>> That one is stupid. I don't see how you can make it work without some
>>> global storing the p1 information in foo which I would consider as
>>> very ugly code.
>>
>>
>>
>> In which case perhaps you should actually try the code. Then once you
>> realise it works you can start to figure out why :-). Hint: f(*p1)
>> appears as len(p1) separate arguments to the called function.
> 
> 
> You should also notice that foo knows the starting point of the line but
> not the ending point and so it can't draw the line. On the other hand,
> bar knows the end point but not the starting point so it can't do the
> job either.

It was just an example of tuples as arguments to a function and doing
something with the values of the tuples in the function itself. Even so,
many graphical environments offer MoveTo(x, y) and LineTo(x, y) or
equivalents. MoveTo moves some internal cursor to the specified position
without drawing a line; LineTo draws a line from the stored cursor
position to the specified position and moves the internal cursor to that
 new position.

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


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


using variable-value

2005-09-21 Thread Tor Erik Sønvisen
Hi

In php I can assign a value to a variable and use this varaible to access a 
property in some object:

$var = 'property';
$object->{$var}

This will transelate to $object->property...
Is this possible in Python?

# Prints help on methods in Canvas-instance
for method in dir(self.canvas):
print method
print help(self.canvas.method)

gives me " AttributeError: Canvas instance has no attribute 'method' "...

regards tores 


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


Re: C#3.0 and lambdas

2005-09-21 Thread Christophe
Steve Holden a écrit :
> Christophe wrote:
> 
>> Steve Holden a écrit :
>>
>>> Christophe wrote:
>>>
>>>
 Serhiy Storchaka a écrit :


> Roel Schroeven wrote:
>>>
>>>
>>> [...]
>>>
>>>
>> or
>>
>> def drawline(p1, p2):
>>   # draw a line from p1[0], p1[1] to p2[0], p2[1]
>>   foo(p1[0], p1[1])
>>   bar(p2[0], p2[1])
>
>
>
>
> def drawline(p1, p2):
># draw a line from p1 to p2
>foo(*p1)
>bar(*p2)
>


 That one is stupid. I don't see how you can make it work without 
 some global storing the p1 information in foo which I would consider 
 as very ugly code.
>>>
>>>
>>>
>>> In which case perhaps you should actually try the code. Then once you 
>>> realise it works you can start to figure out why :-). Hint: f(*p1) 
>>> appears as len(p1) separate arguments to the called function.
>>
>>
>>
>> You should also notice that foo knows the starting point of the line 
>> but not the ending point and so it can't draw the line. On the other 
>> hand, bar knows the end point but not the starting point so it can't 
>> do the job either.
>>
> This is rubbish.
> 
>   foo(*p1)
> 
> is *exactly* equivalent to
> 
>   foo(p1[0], p1[1])
> 
> and similarly
> 
>   bar(p2)
> 
> is *exactly* equivalent to
> 
>   bar(p2[0], p2[1])
> 
> and consequently the second version of drawline is exactly equivalent to 
> the first. So, if the second one is useless then so is the first.

Well, sorry about that but you are perfectly right. The point I was 
trying to defend though was that such construct is very uncommon. It 
isn't always possible to unpack the tuples like that because you usually 
need all the info at once.

>> And what about a function which computes the line length ?
> 
> 
> I'm not sure what point you are trying to make here. Can you explain?

As I said, the point was that in that specific case, you can do it like 
that, but most of the time you need the unpack info for all the data in 
the same function. For example to compute the line length.

def length((x1,y1),(x2,y2)):
 return math.hypot(x1-x2,y1-y2)

No unpack trick ( that I know of ) can be used here. You only have 1 way 
to do it without the unpack in function parameters syntax :

def length(p1, p2):
 x1, y1 = p1
 x2, y2 = p2
 return math.hypot(x1-x2,y1-y2)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using variable-value

2005-09-21 Thread bruno modulix
Tor Erik Sønvisen wrote:
> Hi
> 
> In php I can assign a value to a variable and use this varaible to access a 
> property in some object:
> 
> $var = 'property';
> $object->{$var}
> 
> This will transelate to $object->property...
> Is this possible in Python?

Not directly, but there's a way: getattr(obj, attname, [,default])

> # Prints help on methods in Canvas-instance
> for method in dir(self.canvas):
> print method
> print help(self.canvas.method)
> 
> gives me " AttributeError: Canvas instance has no attribute 'method' "...

Try this
 for method in dir(self.canvas):
 print method
 print help(getattr(self.canvas, "method"))

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distutils and decorators

2005-09-21 Thread Benji York
Robert Brewer wrote:
> We're trying to get CherryPy 2.1 RC 1 out the door, but setup.py is
> giving us some problems. 

I don't know anything about distutils, so I can't help you there, but I 
never-the-less can't resist speaking up...

> In our test suite, we want to test a decorator
> that we provide. Of course, decorators won't work in Python 2.3

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. 
Something like:

def foo():
 pass

foo = cherrypy.expose("1")(foo)
--
Benji York


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


Re: Question About Logic In Python

2005-09-21 Thread Bengt Richter
On Wed, 21 Sep 2005 09:03:00 +1000, Steven D'Aprano <[EMAIL PROTECTED]> wrote:

>On Tue, 20 Sep 2005 03:03:15 +, Ron Adam wrote:
>
>> Steven D'Aprano wrote:
>>> Are there actually any usage cases for *needing* a Boolean value? Any
>>> object can be used for truth testing, eg:
>
>[snip]
>
>> Of course if any of the default False or True conditions are 
>> inconsistent with the logic you use, you need to do explicit truth testing.
>
>[snip]
>
>> 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?
>
>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?
>
When you want to use the value as an index fed to something that has a
__getitem__ for which only the values 0 and 1 are valid, e.g., a list
or tuple of length 2, as I tried to illustrate before ;-)

Also, since values 0 and 1 are the values of a bit, you can shift it
and create a mask that encodes many logical values at once, which can
be handy for truth table stuff or perhaps indexing a 2**nbits table
rather than using a tree of nested if/elses to select values.

BTW, you asked
"Are there actually any usage cases for *needing* a Boolean value?"
^^^ ;-)
AFAIK, "one" is enough to make the answer "yes" ;-)

Of course you can use other expressions than bool(x) to get the boolean
value, but you may have to think more about whether (x and 1) will
do it, or whether you should write (x!=0) or, in case x can be None,
perhaps settle on (x and 1 or 0) as an idiom to play safe.
Well, bool(x) is safe, and less typing ;-) OTOH, it's not a hammer for all 
nails.

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


Re: What am I doing wrong?

2005-09-21 Thread Scott David Daniels
keithlackey wrote:
> I'm relatively new to python and I've run into this problem.
This has two very standard mistakes:
First, as noted by Sybren, messages should just use spaces in order to 
be readable.

After correcting that one:
>class structure:
>def __init__(self, folders = []):
>self.folders = folders
 >...

Here is the second one.  Default args are not rebuilt, but shared.
The correct way to do this is:
  class structure:
  def __init__(self, folders=None):
  if folders is None:
  self.folders = []
  else:
  self.folders = folders
  ...

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


Calling Access module functions from python

2005-09-21 Thread kayakerjess
Hi,

I have an Access Data Project (.adp) that I am trying to open and
execute from Python.  I am using the win32com.client, and I have
successfully opened the application, but I'm getting an exception when
I try to execute the function (actually a "Sub" that returns void, but
that shouldn't matter).  Here's what I have so far:


conn=win32com.client.Dispatch('Access.Application')
conn.OpenAccessProject("C:/path/to/file/filename.adp")
conn.Visible = 1
# works so far

conn.Run("test_interface")

# Exception is thrown here.
# com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
0, -2147352562), None)

The 'test_interface' function takes no arguments, but I've tried the
same thing with another function that does take arguments and gotten
the same result.

Any help would be appreciated.

Thanks,
kayakerjess

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


Re: wxPython Notebook crash when pressing alt key

2005-09-21 Thread Kreedz
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

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


Calling Access module functions from python

2005-09-21 Thread kayakerjess
Hi,

I have an Access Data Project (.adp) that I am trying to open and
execute from Python.  I am using the win32com.client, and I have
successfully opened the application, but I'm getting an exception when
I try to execute the function (actually a "Sub" that returns void, but
that shouldn't matter).  Here's what I have so far:


conn=win32com.client.Dispatch('Access.Application')
conn.OpenAccessProject("C:/path/to/file/filename.adp")
conn.Visible = 1
# works so far

conn.Run("test_interface")

# Exception is thrown here.
# com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
0, -2147352562), None)

The 'test_interface' function takes no arguments, but I've tried the
same thing with another function that does take arguments and gotten
the same result.

Any help would be appreciated.

Thanks,
kayakerjess

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


Re: Perl's documentation come of age

2005-09-21 Thread Ed Hotchkiss
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?
 
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.
 
***/me puts on Monty Python and turns the computer off***
 
-edward
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: C#3.0 and lambdas

2005-09-21 Thread Fredrik Lundh
Christophe wrote:

> > if you cannot see how that can work, you clearly haven't done much graphics
> > programming in your days...
>
> You should probably notice that graphics library have changed a lot in
> the last 20 years.

yeah, nobody uses things like OpenGL and PDF and SVG and similar APIs
these days...





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


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

2005-09-21 Thread Paul Rubin
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.

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

> 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, to
have any chance of getting fancy protocol designs correct.  

 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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Perl's documentation come of age

2005-09-21 Thread Benji York
Ed Hotchkiss wrote:
> I'm new to Python, not programming. I agree with the point regarding the 
> interpreter. 

I couldn't (with a quick skimming) find any references to the 
interpreter in the thread, so I'll guess the original assertion was 
something like "showing new-comers the interpreter is stupid and wastes 
their time".

> what is that? who uses that!? 

As a (more than) full time Python programmer, I can say that I use the 
interactive interpreter daily, and it contributes significantly to my 
prototyping of new code and reverse-engineering of existing code.  I 
could imagine that other people might not find it that useful, but the 
"who uses that!?" response is hard for me to understand.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C#3.0 and lambdas

2005-09-21 Thread Scott David Daniels
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)

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


Re: Perl's documentation come of age

2005-09-21 Thread Robert Kern
Ed Hotchkiss wrote:
> I'm new to Python, not programming. I agree with the point regarding the
> interpreter. what is that? who uses that!?

I spend most of my work day at the interpreter. I don't write programs;
I write libraries which I control with the interpreter. It's a
fantastically useful and productive way to work.

> Why are most examples like
> that, rather than executed as .py files?

If all of the examples were .py files, then many of them would have to
have print statements sprinkled through them and a separate block to
show the output. For most of the examples, I'd rather see the input and
output interleaved so I know what corrseponds with what.

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

Is this really a significant problem for you?

-- 
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: Perl's documentation come of age

2005-09-21 Thread Jeremy Jones
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.

>  
> ***/me puts on Monty Python and turns the computer off***
>  
> -edward

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


Re: C#3.0 and lambdas

2005-09-21 Thread Robert Kern
Christophe wrote:
> Steve Holden a écrit :
>>and consequently the second version of drawline is exactly equivalent to 
>>the first. So, if the second one is useless then so is the first.
> 
> Well, sorry about that but you are perfectly right. The point I was 
> trying to defend though was that such construct is very uncommon. It 
> isn't always possible to unpack the tuples like that because you usually 
> need all the info at once.

Many, many drawing APIs use a Postscript-like model such that drawing a
line from p1 to p2 decomposes into something like this:

moveto(p1)
lineto(p2)

Almost always those are methods on some object that maintains the state
(no globals in sight):

gc.moveto(p1)
gc.lineto(p2)

I think it's much more common than you realize. You are right that there
are plenty of functions that you might want to call that would require
something like this:

   low_level_drawline(x1, y1, x2, y2)

that isn't amenable to *argument unpacking.

-- 
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: vendor-packages directory

2005-09-21 Thread Colin J. Williams
Terry Reedy wrote:
> "Rich Burridge" <[EMAIL PROTECTED]> wrote in message 

>>Until now we've been using "/usr/lib/python2.4/site-packages" as the
>>directory to install the various Python files that these packages use.
> 
> 
> My impression is that this is exactly the intended place for general-use 
> support packages.
> 
> 
+1

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


Re: Organising a python project

2005-09-21 Thread baoilleach
Thanks for the info, guys. Noel

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


Re: Organising a python project

2005-09-21 Thread baoilleach
Thanks for the info, guys. Noel

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


Re: C#3.0 and lambdas

2005-09-21 Thread Christophe
Dennis Lee Bieber a écrit :
> On Wed, 21 Sep 2005 17:08:14 +0200, Christophe <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
> 
> 
> 
>>No unpack trick ( that I know of ) can be used here. You only have 1 way 
>>to do it without the unpack in function parameters syntax :
>>
>>def length(p1, p2):
>> x1, y1 = p1
>> x2, y2 = p2
>> return math.hypot(x1-x2,y1-y2)
> 
> 
import math
def length(p1, p2):
> 
> ... return math.hypot(p1[0] - p2[0], p1[1] - p2[1])
> ...
> 
length((1,2),(4,6))
> 
> 5.0
> 
> 
>   Still no need for intermediate variables, you can index the tuple at
> need.

Well, I prefer the explicit tuple unpack anyway. It gives better results 
than using tuple indexing ( and better performance too most of the time )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding where to store application data portably

2005-09-21 Thread Jeff Schwab
Steven D'Aprano wrote:

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

What difference does it make whether one is using a GUI or a command 
line?  Anyway, the vast majority of Unix users I know still use ls a lot 
more often than GUI-based file managers.

I prefer to keep my settings in ~/etc, as a sort of intuitive parallel 
to the Filesystem Hierarchy Standard.

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

Better:  a user-specified $ETCDIR.
-- 
http://mail.python.org/mailman/listinfo/python-list


I am not able to setup pydb2 ! Any help !

2005-09-21 Thread vj
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.

Thanks in advance.

Vj

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


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


  1   2   >