Re: Cannot install python under Win32

2008-06-10 Thread Martin v. Löwis
> Hello, I have tried to install python 2.5.1 and 2.5.2 with the same
> error. The installer starts fine, but when it gets to the part that
> says "Status: Copying new files" it terminates with an error code of
> 2356.
> 
> Does anyone have a clue to what to do?

Run the installer with

msiexec /i  /l*v py.log,

then study py.log to find out what went wrong.

Are you by any chance running the installer from a SUBSTed drive?

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


Re: Cannot install python under Win32

2008-06-10 Thread Payala
On Jun 10, 8:56 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > Hello, I have tried to install python 2.5.1 and 2.5.2 with the same
> > error. The installer starts fine, but when it gets to the part that
> > says "Status: Copying new files" it terminates with an error code of
> > 2356.
>
> > Does anyone have a clue to what to do?
>
> Run the installer with
>
> msiexec /i  /l*v py.log,
>
> then study py.log to find out what went wrong.
>
> Are you by any chance running the installer from a SUBSTed drive?
>
> Regards,
> Martin

Thanks for your fast reply Martin, I have done what you said and
digging in the log for the error code I found the following lines,
which sound bad but doesn't give me a clue:

"Action 9:04:50: InstallFiles. Copying new files
MSI (s) (78:54) [09:04:50:250]: Executing op:
ProgressTotal(Total=34700741,Type=0,ByteEquivalent=1)
MSI (s) (78:54) [09:04:50:250]: Executing op: SetTargetFolder(Folder=C:
\Python25\)
MSI (s) (78:54) [09:04:50:250]: Executing op:
SetSourceFolder(Folder=1\)
MSI (s) (78:54) [09:04:50:250]: Executing op:
ChangeMedia(,MediaPrompt=Please insert the
disk: ,MediaCabinet=python,BytesPerTick=32768,CopierType=2,ModuleFileName=C:
\WINDOWS\Installer\4f36b5.msi,IsFirstPhysicalMedia=1)
MSI (s) (78:54) [09:04:50:250]: Executing op:
FileCopy(SourceName=W9XPOPEN.EXE|
w9xpopen.exe,SourceCabKey=w9xpopen.exe,DestName=w9xpopen.exe,Attributes=512,FileSize=4608,PerTick=32768,,VerifyMedia=1,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=-1158250844,HashPart2=-457781963,HashPart3=862897926,HashPart4=-733767670,,)
MSI (s) (78:54) [09:04:50:250]: File: C:\Python25\w9xpopen.exe; To be
installed;  Won't patch;No existing file
MSI (s) (78:54) [09:04:50:250]: Source for file 'w9xpopen.exe' is
compressed
InstallFiles: File: w9xpopen.exe,  Directory: C:\Python25\,  Size:
4608
MSI (s) (78:54) [09:04:50:265]: SOFTWARE RESTRICTION POLICY: Verifying
object --> 'C:\WINDOWS\Installer\4f36b5.msi' against software
restriction policy
MSI (s) (78:54) [09:04:50:265]: Note: 1: 2262 2: DigitalSignature 3:
-2147287038
MSI (s) (78:54) [09:04:50:265]: SOFTWARE RESTRICTION POLICY: C:\WINDOWS
\Installer\4f36b5.msi is not digitally signed
MSI (s) (78:54) [09:04:50:265]: SOFTWARE RESTRICTION POLICY: C:\WINDOWS
\Installer\4f36b5.msi is permitted to run at the 'unrestricted'
authorization level.
MSI (s) (78:54) [09:04:50:265]: Note: 1: 2356 2: python
MSI (s) (78:54) [09:04:50:265]: Note: 1: 2262 2: Error 3: -2147287038
DEBUG: Error 2356:  Couldn't locate cabinet in stream: python.
The installer has encountered an unexpected error installing this
package. This may indicate a problem with this package. The error code
is 2356. The arguments are: python, ,
MSI (s) (78:54) [09:04:51:843]: Note: 1: 2262 2: Error 3: -2147287038
MSI (s) (78:54) [09:04:51:843]: Product: Python 2.5.2 -- The installer
has encountered an unexpected error installing this package. This may
indicate a problem with this package. The error code is 2356. The
arguments are: python, , "
--
http://mail.python.org/mailman/listinfo/python-list


Re: Cannot install python under Win32

2008-06-10 Thread Payala
On Jun 10, 8:56 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > Hello, I have tried to install python 2.5.1 and 2.5.2 with the same
> > error. The installer starts fine, but when it gets to the part that
> > says "Status: Copying new files" it terminates with an error code of
> > 2356.
>
> > Does anyone have a clue to what to do?
>
> Run the installer with
>
> msiexec /i  /l*v py.log,
>
> then study py.log to find out what went wrong.
>
> Are you by any chance running the installer from a SUBSTed drive?
>
> Regards,
> Martin

I forgot to tell you that I believe I am not installing from a SUBSTed
drive, the installer is in a directory under the "My Documents"
folder.

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


Re: Getting current screen resolution

2008-06-10 Thread Thomas Morton


Yeh that's not such an issue - this is for some basic image analysis for a 
document / report. It's not HUGELY important data (it can be wrong with no 
real come back) but it has to be roughly accurate...


The idea is I have an image and I need to work out how big it displays on 
the monitor of the computer running the script :)


Thanks for the replies so far ppl :) I think I might have it...

Tom
--
From: "Larry Bates" <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2008 11:16 PM
Newsgroups: comp.lang.python
To: 
Subject: Re: Getting current screen resolution


Thomas Morton wrote:

This is a "thing" that has been annoying me all morning: and I can't
work out how to do it.

I need a way to get the DPI or screen resolution of the monitor that a
script is currently runnign on.

I have a way in Windows but it doesnt port to Unix (which is important).

Any ideas?



warning - be very careful about trying to come up with something like 
this.
Today it is common for people to have more than one monitor, so you will 
need to take that into account.  Just getting resolution of one monitor 
might not be enough (but then I don't know EXACTLY what is is that you are 
doing with the
resolution).  I see a lot of software that ignores the dual-monitor 
possibility.


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


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


Re: Does the python library of Google Data API is truly free?

2008-06-10 Thread Kless
On 9 jun, 22:46, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Kless schrieb:
>
> > On 9 jun, 21:40, Lie <[EMAIL PROTECTED]> wrote:
> >> Do you notice that the terms are for the SERVICE not for the SOFTWARE.
> >> The terms for the service is quite reasonable, as I see it.
> >> The software itself is governed by the Apache License 2.0, detailed
> >> here:http://www.apache.org/licenses/LICENSE-2.0
>
> > Well, it's used a free license to access to a service that is not free
> > -it's owner and too restrictive-. And it isn't nothing reasonable that
> > Google get many rights about your content, and that you have not any
> > right about the rest of the content.
>
> > This goes against the free software, considering that a service is
> > software.
>
> This is nonsense. If a hosting provider offers you free hosting based on
> linux - and then goes out of business or is forced to charge money - do
> you say "that's against free software?"
I don't speak about hosting else rights about data, data that are
entered by people:

"By submitting, posting or displaying the content you give
Google a perpetual, irrevocable, worldwide, royalty-free, and non-
exclusive license to reproduce, adapt, modify, translate, publish,
publicly perform, publicly display and distribute any Content which
you submit, post or display on or through, the Services..."

"You agree that this license includes a right for Google to make
such Content available to other companies, organizations or
individuals with whom Google has relationships for the provision of
syndicated services..."

> Or if they prohibit you to host malicious, offending or otherwise
> problematic content served by the free apache - is that "against free
> software?"
Please, don't be demagogue.

> A service is a service. It is offered as is, under whatever conditions
> the provider likes it.
A service or web service to follows being software. A software where
is more easy to add restrictions, in this case those restrictions goes
against the freedoms of the free software.

> Offering a convenient way to access the service using a FOSS license is
> good style. But you aren't forced to use that, you can write your own.
> But that doesn't change the terms and conditions of the service itself.
Offering access via Apache 2.0 -wich is not compatible with GPLv2- to
a non-free service is a mortal trap where people are falling.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to kill a thread?

2008-06-10 Thread Antoon Pardon
On 2008-06-09, Rhamphoryncus <[EMAIL PROTECTED]> wrote:
> On Jun 9, 5:33 am, Antoon Pardon <[EMAIL PROTECTED]> wrote:
>> On 2008-06-07, Rhamphoryncus <[EMAIL PROTECTED]> wrote:
>>
>> > On Jun 6, 12:44 pm, The Pythonista <[EMAIL PROTECTED]> wrote:
>> >> It's always been my understanding that you can't forcibly kill a thread
>> >> in Python (at least not in a portable way).  The best you can do is
>> >> politely ask it to die, IIRC.
>>
>> > Inherently, the best you can do in most languages is ask them politely
>> > to die.  Otherwise you'll leave locks and various other datastructures
>> > in an inconvenient state, which is too complex to handle correctly.
>> > The exception is certain functional languages, which aren't capable of
>> > having threads and complex state in the same sense.
>>
>> Well it would of course depend on what is considered asking politely?
>>
>> If one thread could cause an exception being thrown in an other thread,
>> would this be considered a polite way to ask? Would it be considered
>> an acceptable way?
>
> The exception must not be raised until a point explicitly designed as
> safe is hit.  Otherwise, any function that manipulates data you'll
> still use will potentially be buggered.  Consider sys.stdout: codecs,
> buffering, lots to go wrong.

I don't see the point. Exceptions are raised now without the ability
of an explicitly designed safe point. If something unexpected happens
your code can raise an exception and leave your data buggered too if
you didn't anticipate it propely.

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


Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Bruno Desthuilliers

Russ P. a écrit :

On Jun 9, 2:10 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:


But if it takes 6 month to get the mentioned developer to release
something I can use, I'm screwed up. Fine.


I've lost track of how many times I've said this now, but my
suggestion for a "priv" keyword allowed for "indirect" access to
private data through some name-mangling scheme. 


And I've lost track of how many times I've said this now, but we already 
have this. While we're at it, why not a 'prot' keyword that would 
restrict name-mangling to the addition of a single leading underscore ?



That could be your
temporary fix while you are waiting for the developer to release a
corrected version. And even if that option were not available, you
could simply open up the relevant source file in the editor of your
choice and remove the offending "priv" declaration.


Yes. And I can always edit the source code and add the methods I need 
etc. You probably never used monkeypatching, so I guess you just can't 
understand the difference between maintaining a monkeypatch and 
maintaining a fork.



I completely fail
to see how you are "screwed."



Sorry, but when I have to keep repeating the same basic points over
and over, I can't help but think I might be wasting my time.


If you hope to get a general agreement here in favor of a useless 
keyword that don't bring anything to the language, then yes, I'm afraid 
you're wasting your time.


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


eric4 wont start

2008-06-10 Thread dusans
Hi i took a look at eric4, its nice, cuz u have the script output and
console in the same window, which is why i love pyscripter.
Then i upgradet eric4 to newest version: eric4-4.0.4, it doesnt start,
even when i installed the old version:

The error massage is:
Warning: translation file 'qt_en_US'could not be loaded.
Using default.
Warning: translation file 'eric4_en_US'could not be loaded.
Using default.
Warning: translation file 'qscintilla_en_US'could not be loaded.
Using default.


It just stopes and doesnt go on. Anyone got an idea how to solve this,
cuz i really like eric4
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Antoon Pardon
On 2008-06-09, Lie <[EMAIL PROTECTED]> wrote:
>>
>> That seems strange to me. The and-or simulation that was offerd in the
>> FAQ allowed for about the same kind of structures as the ternary
>> operator in C and was used in the standard library IIRC.
>>
>> So the same unreadable was already possible to write, plus that it
>> could cause bugs and had to be made even more unreadable in order
>> to work correctly. Considering this it I find it odd that hurting
>> readability was a motivation not to have it.
>
> In case you didn't notice, the and-or simulation is a hack, it is not
> to be used by anyone writing real code (instead of for an entry to
> Obfuscated Python Code Contest) to substitute it for inline if. If
> inline if is "formalized", that means the language encourages the use
> of inline if, which we don't want to have.

Who is we? The last poll I know about had a majority in favor of a
ternary operator.

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


Re: help on self._dir

2008-06-10 Thread Kaushik
On Jun 9, 8:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Kaushik wrote:
> > Hi,
> > i'm new to python , and i came across a code like
>
> > if ("on_%s" % handler ) in self._dir:
>
> > i tried use the a similar method in my class it errors out like
>
> > AttributeError: bot instance has no attribute '_dir'
>
> > what am i doing wrong?
>
> self._dir is just an attribute that has previously been set somewhere. For
> example, like this:
>
> class Foo(object):
>    def __init__(self):
>        self._dir = "I'm a fancy value"
>
> So without you providing more code I presume you try to subclass something
> and didn't properly set up the base-class - probably missing a call to the
> super class' constructor.
>
> Diez

Thanks Diez! that explains a lot :)

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


Re: Write to file and see content on screen

2008-06-10 Thread MRAB
On Jun 10, 2:01 am, [EMAIL PROTECTED] wrote:
> Hello all,
>
> New user to python.   I can write to a file, however, I would like to
> do both...whatever I do on the screen, I'd like to write it to a file.
>
> any pointers on where I can find this info.
>
> thanks,

Something like this, perhaps?

class Storage(object):
def __init__(self, the_file):
self.the_file = the_file
def write(self, message):
import sys
sys.stdout.write(message)
self.the_file.write(message)

my_file = open("my_text.txt", "w")
store = Storage(my_file)
print >> store, "Hello world!"
my_file.close()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question by someone coming from C...

2008-06-10 Thread Bruno Desthuilliers

Skye a écrit :

Writing this app in Python, not sure what the "best practice" would
be.

I want a bitfield global logging level that allows me to turn specific
debugging modules on and off.  If I was doing this in C, I'd just use
some globals like:

unsigned int debug_level = 0;
#define DEBUG_GENERAL 0x0001
#define DEBUG_CONFIG 0x0002
#define DEBUG_OPTIONS 0x0004
etc etc

So I guess my questions are:

1. there doesn't seem to be a way to define global constants like in
other languages?
2. any  special voodoo to use bitfields in Python?


Others already gave you the best advises (namely: using the logging 
module). But let's answer your questions anyway:


1/ by convention, anything named ALL_UPPER is considered a constant. 
Anyone breaking your code by messing with a PSEUDO_CONSTANT is on it's 
own and has no right to complain. Consider it as a "warranty void if 
unsealed" warning.



2/ just use plain integers and bitwise operators. But we're usually more 
concerned about readability than about saving bits, and I've rarely 
(maybe twice ?) seen bitfields used that way in Python.


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


Re: Separators inside a var name

2008-06-10 Thread MRAB
On Jun 10, 6:59 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Mon, 9 Jun 2008 17:53:58 -0700 (PDT), Rainy <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>
>
> > This is actually pretty nice. I think I like this much better
> > than C/Java/etc convention. I wouldn't use pipes but I'd pick
> > something that's easy to type and is nicely readable. Not
> > sure what..
>
> I think the only available punctuation mark left for Python is the ?
> -- though didn't I read something about ` becoming free (probably for
> Python 4000)
>
> Access/JET uses [xx xxx] for table/column names

There are also ! and $, although you couldn't really use ! as an infix
operator because != already has a meaning. How about using $ or %% for
Python 3's new string formatting? :-)
--
http://mail.python.org/mailman/listinfo/python-list


Py2exe and name space package

2008-06-10 Thread Yuan HOng
Hi,

I used to freeze my application into Windows executibles using py2exe.
Lately I started using several zope packages in my application, like
zope.interface. Now the freezed program can't run properly. Like the
following example shows:

My setup.py file:

from distutils.core import setup
import py2exe

setup(name='test',
  zipfile=None,
  console=[
  {
'script': 'main.py',
  }
  ])

The main.py test code:

from zope.interface import Interface
print Interface

During the freezing process, the following warning is shown:

*** copy dlls ***
copying 
c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\run.exe
-> C:\temp\dist\main.exe
The following modules appear to be missing
['pkg_resources', 'zope.interface']

Running main.exe gives me an import Error.

C:\temp\dist>main.exe
Traceback (most recent call last):
  File "main.py", line 1, in 
ImportError: No module named interface

What should I do to make py2exe recognize and include zope.interface
in the binary distribution?

Thanks.

-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
--
http://mail.python.org/mailman/listinfo/python-list

EXE is very slow by starting (>10sec.) (build with PyInstaller)

2008-06-10 Thread Mark Delon
Hi,

My Python executable created with PyInstaller is too slow by starting...
It takes about 15 secs.!!!

I am  using PyQt4 libraries for creating my very simple GUI-application.

-> How can I SPEED UP my executable ???
-> Do you know some GOOD build switches?

Thank you very much for every idea...

Best Regards

Mark


-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
--
http://mail.python.org/mailman/listinfo/python-list


Re: TWITTER API and urllib2

2008-06-10 Thread Mike
On Tue, Jun 10, 2008 at 10:42 PM, Mike <[EMAIL PROTECTED]> wrote:

> Hello,
>
> I've spent the last couple of nights hacking away at a Python wrapper for
> the Twitter API that I can use for various things.
>
> I'm having trouble with one of the methods: user_timeline. (
> http://groups.google.com/group/twitter-development-talk/web/api-documentation#HelpMethods
> ).
>
> This is the only method that is returning a HTTP 401. It seems strange and
> I'm not sure how to debug it further as the other methods requring
> authentication work.
>
> Please keep in mind the code is missing alot of polish :) - Though I'm open
> to suggestions on improvements.
>
> If anyone is familiar with this I'd really appreciate a hint as it has me
> stumped! (I really need this method for my functionality too!)
>
> ---
>
> import urllib2, urllib, urlparse
>
> class TwitterMethods(object):
> def __init__(self):
>pass
>
> def url_request(self,uri,authentication=None):
> auth = urllib2.HTTPBasicAuthHandler()
> netlock  = urlparse.urlparse(uri)
> if authentication:
> passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
>
> passwdMgr.add_password(None,netlock[1],authentication.username,authentication.password)
>
> auth = urllib2.HTTPBasicAuthHandler(passwdMgr)
> req = urllib2.Request(uri)
> o = urllib2.build_opener(auth)
> try:
> f = o.open(req)
> print f.readlines([0])
> except o.error:
> print "error"
> #except:
> #print "unknown error"
> return
>
> def UserTimeline(self,authentication):
> self.url_request("http://twitter.com/statuses/user_timeline.xml
> ",authentication)
>
> class TwitterAuth(object):
> def __init__(self,username,password):
> self.username = username
> self.password = password
>
> p = TwitterMethods()
> auth = TwitterAuth('[EMAIL PROTECTED]','password')
> p.UserTimeline(auth)
>
>
>
I did come across this post:
http://twitterpatter.wordpress.com/2008/02/11/twitterpatter-update-making-progress-accessing-twitter-timelines/Which
only mentions it, does not offer a solution.
--
http://mail.python.org/mailman/listinfo/python-list

TWITTER API and urllib2

2008-06-10 Thread Mike
Hello,

I've spent the last couple of nights hacking away at a Python wrapper for
the Twitter API that I can use for various things.

I'm having trouble with one of the methods: user_timeline. (
http://groups.google.com/group/twitter-development-talk/web/api-documentation#HelpMethods
).

This is the only method that is returning a HTTP 401. It seems strange and
I'm not sure how to debug it further as the other methods requring
authentication work.

Please keep in mind the code is missing alot of polish :) - Though I'm open
to suggestions on improvements.

If anyone is familiar with this I'd really appreciate a hint as it has me
stumped! (I really need this method for my functionality too!)

---

import urllib2, urllib, urlparse

class TwitterMethods(object):
def __init__(self):
   pass

def url_request(self,uri,authentication=None):
auth = urllib2.HTTPBasicAuthHandler()
netlock  = urlparse.urlparse(uri)
if authentication:
passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()

passwdMgr.add_password(None,netlock[1],authentication.username,authentication.password)

auth = urllib2.HTTPBasicAuthHandler(passwdMgr)
req = urllib2.Request(uri)
o = urllib2.build_opener(auth)
try:
f = o.open(req)
print f.readlines([0])
except o.error:
print "error"
#except:
#print "unknown error"
return

def UserTimeline(self,authentication):
self.url_request("http://twitter.com/statuses/user_timeline.xml
",authentication)

class TwitterAuth(object):
def __init__(self,username,password):
self.username = username
self.password = password

p = TwitterMethods()
auth = TwitterAuth('[EMAIL PROTECTED]','password')
p.UserTimeline(auth)
--
http://mail.python.org/mailman/listinfo/python-list

DICOM library

2008-06-10 Thread ustrum
Hi everybody!
I've been looking for a python library wich allows me to work with
with DICOM files, for medical image processing. Finding nothing at
first, evenctually i've find the gdcm library, wich is suposed to be
for c developement, but they say that you can use it with python, as
"It is automatically wrapped to python (using swig)". So, the cuestion
is: how can I use this kind of library, wich is suposed to be used
with c, in python? When I download the tarball there ae only 2 .py
files. shall I install the whole library for using in C, and then try
to import the gdcm module in python? becouse i'm afraid it won't work.
Thanks in advance, and sorry for my english, wich is not very good
actually. Sorry for asking for something before trying everything, but
i'm almost desperate to find a library like that.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, subprocess, dump, gzip and Cron

2008-06-10 Thread Sebastian "lunar" Wiesner
 Aidan <[EMAIL PROTECTED]> at Dienstag 10 Juni 2008 07:21:

> TT wrote:
>> On Jun 10, 2:37 pm, Aidan <[EMAIL PROTECTED]> wrote:
>>> Hi,
>>>
>>> I'm having a bit of trouble with a python script I wrote, though I'm not
>>> sure if it's related directly to python, or one of the other software
>>> packages...
>>>
>>> The situation is that I'm trying to create a system backup script that
>>> creates an image of the system, filters the output though gzip, and then
>>> uploads the data (via ftp) to a remote site.
>>>
>>> The problem is that when I run the script from the command line, it
>>> works as I expect it, but when it is run by cron I only get a 20 byte
>>> file where the compressed image should be...  does anyone have any idea
>>> as to why this might be happening?  Code follows
>>>
>>> 
>>>
>>> #!/usr/bin/python
>>>
>>> from subprocess import PIPE, Popen
>>> from ftplib import FTP
>>>
>>> host = 'box'
>>>
>>> filename = '%s.img.gz' % host
>>> ftp_host = '192.168.1.250'
>>> ftpuser, ftppass = 'admin', 'admin'
>>> dest_dir = '/share/%s' % host
>>>
>>> dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE)
You should avoid the use of ``shell=True`` here and use a argument list
instead:

dump = Popen(['dump', '0uaf', '-', '/'], stdout=PIPE)

This results in an exception thrown if the executable doesn't exist.  This
exception can be caught and handle for instance with the logging module.

>>> gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE)

Same here, but why don't you use the gzip functionality from the standard
library?

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Separators inside a var name

2008-06-10 Thread Sebastian "lunar" Wiesner
 [EMAIL PROTECTED] <[EMAIL PROTECTED]> at Montag 09
Juni 2008 23:39:

> On 9 juin, 20:05, "Sebastian \"lunar\" Wiesner"
> <[EMAIL PROTECTED]> wrote:
>>  Rainy <[EMAIL PROTECTED]> at Montag 09 Juni 2008 19:29:
>>
> (snip)
>> > From what I understand, scheme can have variables like var-name. I'm
>> > curious about reasons that python chose to disallow this.
>>
>> "-" is an operator in Python.  How should the parser know,
>> whether "var-name" means "the object bound to var_dash_name" or "subtract
>> the object bound to name from the object bound to var"?
>>
>> Scheme can allows such names, because its a functional programming
>> language.
> 
> Nope. Scheme and most lisps AFAICT allow such names because of lisp's
> syntax, period. Scheme being (more or less) a functional language is
> mostly unrelated. FWIW, there are pure functional languages that use
> an infix operator syntax just like Python (and FWIW, Python itselfs
> uses functions to implement operators) and don't accept dashes in
> identifiers for the same reasons as Python : parsing ambiguity.

Of course, you're right.  My words were badly chosen, I just wanted to point
out, that scheme can allow such names, because it doesn't use operators but
functions for things like subtraction.  My bad, sorry

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Separators inside a var name

2008-06-10 Thread Sebastian "lunar" Wiesner
 Rainy <[EMAIL PROTECTED]> at Dienstag 10 Juni 2008 02:53:

> Well, I agree, this is terrible. If I were Guido I'd
> make a very explicit rule that a certain naming
> scheme is preferred and other schemes are very bad.

FWIW, there is a preferred naming scheme outlined in PEP 8.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Python for the web

2008-06-10 Thread Noorhan Abbas
Hello,
I have developed a python tool that basically does two things:
1. Allow the user to search for a keyword or a group of Keywords in a 
specailized collection of text files.  This search option is part of a massive 
custom tree control that was developed using wxpython.
2. The rest of the tree control is in the form of concepts (labels for 
the concepts) that the user chooses from to get some text displayed as well.
 
I have been adviced to use AppEngine but do you think that as my application 
sends a lot of user requests to the server(to ask for some pieces of text to be 
displayed), using CGI will be too slow? Is there a better way of doing it? If 
you can advice me on which tools to use to develop my web page that will 
include a tree structure, I would be very grateful.
 
Thank you very much in advance,
Nora.



  __
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html--
http://mail.python.org/mailman/listinfo/python-list

unable to import modules from other folders

2008-06-10 Thread moijes12
Hi friends

I have a module "bigbee" in folder C:\MyDocs\BigBee and another module
"foo" needs to import from this.however, "foo" is in D:\foo.

foo.py :

from bigbee import *

The error i get is:

ImportError: No Module bigbee.

Please provide a solution.
--
http://mail.python.org/mailman/listinfo/python-list


Re: unable to import modules from other folders

2008-06-10 Thread morton . thomas
C:\MyDocs needs to be in the sys.path variable for python to include
it in it's search for modules

Try this:

import sys
sys.path.append('C:\MyDocs')

If you are packaging your program for reuse or later move that folder
bear in mind it will *break*

A better method would be to place the module into site-packages OR in
the same directory as the Py script that uses it.

:)

Tom

On 6/10/08, moijes12 <[EMAIL PROTECTED]> wrote:
> Hi friends
>
> I have a module "bigbee" in folder C:\MyDocs\BigBee and another module
> "foo" needs to import from this.however, "foo" is in D:\foo.
>
> foo.py :
>
> from bigbee import *
>
> The error i get is:
>
> ImportError: No Module bigbee.
>
> Please provide a solution.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Thomas Morton

Lead Developer || Founder
TomNRob Web Services
www.tomnrob.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a path to components

2008-06-10 Thread Scott David Daniels

eliben wrote:
... a prety good try ...

def parse_path(path):
"""..."""

By the way, the comment is fine.  I am going for brevity here.

lst = []
while 1:
head, tail = os.path.split(path)
if tail == '':
if head != '': lst.insert(0, head)
break
else:
lst.insert(0, tail)
path = head
return lst
--

Did I miss something and there is a way to do this standardly ?

Nope, the requirement is rare.


Is this function valid, or will there be cases that will confuse it ?

parse_path('/a/b/c//d/')

Try something like:
def parse_path(path):
'''...same comment...'''
head, tail = os.path.split(path)
result = []
if not tail:
if head == path:
return [head]
# Perhaps result = [''] here to an indicate ends-in-sep
head, tail = os.path.split(head)
while head and tail:
result.append(tail)
head, tail = os.path.split(head)
result.append(head or tail)
result.reverse()
return result

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


h2py.py bug?

2008-06-10 Thread Gabriel Rossetti

Hello everyone,

I wanted to use the h2py.py script (Tools/scripts/h2py.py) and it didn't 
like char litterals :


Skipping: PC_ERROR = ord()

where my *.h file contained :

#define PC_ERROR '0'

I searched the web and found a post with the same error :

http://mail.python.org/pipermail/python-list/2005-September/340608.html

but it got no replies, I tried the fix and it works. I have the 
following questions:


1) Why did it not get any attention, is something wrong with it?
2) If nothing is wrong, did the fix not get applied because a bug report 
wasn't filed?
3) Isn't turning a char literal into the ordinal value not contrary to 
what a C programmer had in mind when he/she defined it? I mean if you 
define a char literal then in python you would have used a string value :


#define PC_ERROR '0'

would become :

PC_ERROR = '0'

in python, and if you intended to use the char type for an 8 bit 
numerical value you would have done :


#define PC_ERROR 0x30

where 0x30 is the '0' ascii hex value, so shouldn'it the line in the 
diff (see the post) be :


body = p_char.sub("'\\1'", body)

instead of :

body = p_char.sub("ord('\\1')", body)

?

Thank you,
Gabriel

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


Re: EXE is very slow by starting (>10sec.) (build with PyInstaller)

2008-06-10 Thread Diez B. Roggisch
Mark Delon wrote:

> Hi,
> 
> My Python executable created with PyInstaller is too slow by starting...
> It takes about 15 secs.!!!
> 
> I am  using PyQt4 libraries for creating my very simple GUI-application.
> 
> -> How can I SPEED UP my executable ???

Try profiling it. I'm not an PyInstaller-user, but I could imagine that
loading Qt is pretty heavy. So you might try & import as few dependencies
as possible, as late as possible. That won't reduce the overall time
needed, but maybe get you going a bit faster so the user feedback is there.
In doubt - create a fancy splashscreen :P

> -> Do you know some GOOD build switches?

There is no such thing I fear.

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


chm file for download?

2008-06-10 Thread John Salerno
Is the chm doc file available for download from the Python website? I can't 
seem to find it. It would be nice to read through while I'm at work (where I 
don't have Python installed).

Also, is it possible to use a chm file on Linux?

Thanks. 


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


Re: chm file for download?

2008-06-10 Thread Mike Driscoll
On Jun 10, 8:15 am, "John Salerno" <[EMAIL PROTECTED]> wrote:
> Is the chm doc file available for download from the Python website? I can't
> seem to find it. It would be nice to read through while I'm at work (where I
> don't have Python installed).
>
> Also, is it possible to use a chm file on Linux?
>
> Thanks.

Looks like the chm file is in the Documentation section on the main
download page:

http://www.python.org/download/releases/2.5.2/

Direct link:

http://www.python.org/ftp/python/2.5.2/Python25.chm

See Google for reading chm files on Linux...or you can check out this
link I found through Google:

http://ayaz.wordpress.com/2006/10/27/reading-chm-chm-files-on-linux/

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


Re: Do this as a list comprehension?

2008-06-10 Thread John Salerno
"Mensanator" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
On Jun 8, 9:40 pm, John Salerno <[EMAIL PROTECTED]> wrote:
> Mensanator wrote:

> Heh heh, don't worry. Every time I see a range function, I immediately
> think "creates a list". Not sure how I got into that habit, but it
> happens every time! :)

You probably got into that habit because that's
what it does in 2.x, create a list. Now, if
you're expecting that to happen you'll in for
a surprise when you switch to Py3, won't you?

Nah, I know about the change.It might be a slight adjustment at first, but 
probably a good one. 


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


Re: Python, subprocess, dump, gzip and Cron

2008-06-10 Thread Aidan

Sebastian "lunar" Wiesner wrote:

 Aidan <[EMAIL PROTECTED]> at Dienstag 10 Juni 2008 07:21:


TT wrote:

On Jun 10, 2:37 pm, Aidan <[EMAIL PROTECTED]> wrote:

Hi,

I'm having a bit of trouble with a python script I wrote, though I'm not
sure if it's related directly to python, or one of the other software
packages...

The situation is that I'm trying to create a system backup script that
creates an image of the system, filters the output though gzip, and then
uploads the data (via ftp) to a remote site.

The problem is that when I run the script from the command line, it
works as I expect it, but when it is run by cron I only get a 20 byte
file where the compressed image should be...  does anyone have any idea
as to why this might be happening?  Code follows



#!/usr/bin/python

from subprocess import PIPE, Popen
from ftplib import FTP

host = 'box'

filename = '%s.img.gz' % host
ftp_host = '192.168.1.250'
ftpuser, ftppass = 'admin', 'admin'
dest_dir = '/share/%s' % host

dump = Popen('dump 0uaf - /',shell=True,stdout=PIPE)

You should avoid the use of ``shell=True`` here and use a argument list
instead:

dump = Popen(['dump', '0uaf', '-', '/'], stdout=PIPE)

This results in an exception thrown if the executable doesn't exist.  This
exception can be caught and handle for instance with the logging module.



thanks.  That exception certainly would have helped me...


gzip = Popen('gzip',shell=True,stdin=dump.stdout,stdout=PIPE)


Same here, but why don't you use the gzip functionality from the standard
library?


is there a way I can create a gzip file-like object which can read the 
output from the dump subprocess, and has a read method which outputs the 
compressed data, which will not write to disk first?  With the above 
code python doesn't have to write the system image data to disk at all, 
which helps when there is not enough disk space to hold an intermediate 
image (at least, that is my understanding of it...).


I had a look at the gzip module, but eventually just fell back to using 
the stdin and stdout of a gzip subprocess.  I'd be interested to know 
how it could be done using the python standard lib though.

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


Re: chm file for download?

2008-06-10 Thread John Salerno
"Mike Driscoll" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
On Jun 10, 8:15 am, "John Salerno" <[EMAIL PROTECTED]> wrote:

---
Looks like the chm file is in the Documentation section on the main
download page:

http://www.python.org/download/releases/2.5.2/
---

Ah, thanks! I guess my problem was that I was looking in the Documentation 
section instead of Download section! Go figure! :) 


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


Re: Alternative to Decimal type

2008-06-10 Thread Ethan Furman

Mel wrote:

Frank Millman wrote:


Hi all

I have a standard requirement for a 'decimal' type, to instantiate and
manipulate numeric data that is stored in a database. I came up with a
solution long before the introduction of the Decimal type, which has
been working well for me. I know the 'scale' (number of decimal
places) of the number in advance. When I read the number in from the
database I scale it up to an integer. When I write it back I scale it
down again. All arithmetic is done using integers, so I do not lose
accuracy.

[snip]


from __future__ import division

class Number(object):
def __init__(self,value,scale):
self.factor = 10.0**scale
if isinstance(value,Number):
value = value.value / value.factor


I think this could lead to trouble.  One complaint against binary floating
point is that it messes up low-order decimal digits, and this ensures that
all calculations are effectively done in binary floating point.  Better, I
think would be

if isinstance (value, Number):
self.value = value.value
self.scale = scale + value.scale

and be done with it.  Of course, this means self.scale no longer gives the
preferred number of fractional digits.  My bias: I did a DecimalFloat class
way back when, when Decimal was being discussed, and separated the exponent
for calculations from the rounding precision for display.


What about a little rewrite so the current implementation is like the 
original, and all calculations are done as integers?  Or is this just 
getting closer and closer to what Decimal does?


[only lightly tested]

from __future__ import division

class Number(object):
def __init__(self, value, scale):
if isinstance(value, Number):
delta = value.scale - scale
if delta > 0:
self.value = value.value // 10**delta
elif delta < 0:
self.value = value.value * 10**abs(delta)
else:
self.value = value.value
else:
if not scale:
scale += 1
self.scale = scale
self.factor = 10**self.scale
self.value = long(round(value * self.factor))

def __add__(self, other):
answer = Number(other, self.scale)
answer.value += self.value
return answer

def __sub__(self, rhs):
answer = Number(rhs, self.scale)
answer.value = self.value - answer.value
return answer

def __mul__(self, other):
answer = Number(other, self.scale)
answer.value *= self.value
answer.value //= answer.factor
return answer

def __truediv__(self, rhs):
answer = Number(rhs, self.scale)
quotient = 0
divisor = answer.value
dividend = self.value
for i in range(self.scale+1):
quotient = (quotient * 10) + (dividend // divisor)
dividend = (dividend % divisor) * 10
answer.value = quotient
return answer

def __radd__(self, lhs):
return self.__add__(lhs)

def __rsub__(self, lhs):
answer = Number(lhs, self.scale)
answer.value = answer.value - self.value
return answer

def __rmul__(self, lhs):
return self.__mul__(lhs)

def __rtruediv__(self, lhs):
answer = Number(lhs, self.scale)
quotient = 0
divisor = self.value
dividend = answer.value
for i in range(self.scale+1):
quotient = (quotient * 10) + (dividend // divisor)
dividend = (dividend % divisor) * 10
answer.value = quotient
return answer

def __cmp__(self, rhs):
other = Number(rhs, self.scale)
if self.value < other.value:
return -1
elif self.value > other.value:
return 1
else:
return 0

def __str__(self):
s = str(self.value)
if s[0] == '-':
minus = '-'
s = s[1:].zfill(self.scale+1)
else:
minus = ''
s = s.zfill(self.scale+1)
return '%s%s.%s' % (minus, s[:-self.scale], s[-self.scale:])

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


Re: Py2exe and name space package

2008-06-10 Thread Mike Driscoll
On Jun 10, 4:28 am, "Yuan HOng" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I used to freeze my application into Windows executibles using py2exe.
> Lately I started using several zope packages in my application, like
> zope.interface. Now the freezed program can't run properly. Like the
> following example shows:
>
> My setup.py file:
>
> from distutils.core import setup
> import py2exe
>
> setup(name='test',
>   zipfile=None,
>   console=[
>   {
> 'script': 'main.py',
>   }
>   ])
>
> The main.py test code:
>
> from zope.interface import Interface
> print Interface
>
> During the freezing process, the following warning is shown:
>
> *** copy dlls ***
> copying 
> c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\run.exe
> -> C:\temp\dist\main.exe
> The following modules appear to be missing
> ['pkg_resources', 'zope.interface']
>
> Running main.exe gives me an import Error.
>
> C:\temp\dist>main.exe
> Traceback (most recent call last):
>   File "main.py", line 1, in 
> ImportError: No module named interface
>
> What should I do to make py2exe recognize and include zope.interface
> in the binary distribution?
>
> Thanks.
>
> --
> Hong Yuan
>
> 大管家网上建材超市
> 装修装潢建材一站式购物http://www.homemaster.cn


I include the lxml package in some of my programs and I do so by
adding the following to the setup.py

packages = ['lxml']

However, I'm not sure if what you want to add is truly a package.
Yours might go into the "includes" directive. Currently, I use the
GUI2Exe wrapper for py2exe as I find it easier to make complex
executables. You can find it here:

http://xoomer.alice.it/infinity77/main/GUI2Exe.html

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

Re: PEP on breaking outer loops with StopIteration

2008-06-10 Thread nwinters3000
On Jun 9, 10:50 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
> On Jun 9, 8:07 pm, "Kris Kowal" <[EMAIL PROTECTED]> wrote:
>
> > I had a thought that might be pepworthy.  Might we be able to break
> > outer loops using an iter-instance specific StopIteration type?
>
>
> You can break out of outer loops now with the proper (ab)use of
> exceptions:
>
> class BreakInner(Exception):
> pass
> class BreakOuter(Exception):
> pass
> try:
> for letter in string.lowercase:
> try:
> for number in xrange(10):
> print letter, number
> if letter == 'a' and number == 5:
> raise BreakInner()
> if letter == 'b' and number == 5:
> raise BreakOuter()
> except BreakInner:
> pass
> except BreakOuter:
> pass

I prefer having a new function wrapping the inner loop and using both
break and return, but this doesn't allow you to "break 1 loop up and 2
loops up", and doesn't help to continue a particular loop further up

def innerLoop(letter):
   for number in xrange(10):
  print letter, number
  if letter == 'a' and number == 5:
 break
  if letter == 'b' and number == 5:
 return

for letter in string.lowercase:
   innerLoop(letter)


In response to the suggested syntax, I have found occasions where I
iterate through the same variable [say searching for duplicates within
some tolerance to merge into one item] in an inner loop.  I also don't
see how it would extend to something like:

for evenNumber in [x*2+1 for x in xrange(5)]: print evenNumber
--
http://mail.python.org/mailman/listinfo/python-list


Determining which things in 'from package import *' are actually used

2008-06-10 Thread Patrick Bouffard
I have a fairly large library of Python code, where 'from package import *' is
used rather liberally, and it's not uncommon for more than one of these to
appear in any given module. What I'd like to be able to do is to clean my code
up a bit and turn each of the 'from package import *' statements into 'from
package import thing_1, thing_2, ..., thing_n', where only thing_i's that are
actually _used_ in the module are imported. In this way I hope to make my code a
bit more understandable by future civilizations. :) (it needs all the help it
can get!)

Does anyone know of a package/recipe/whatever that does something like this
automatically, even in limited cases? Ideally it should be accomplished only by
looking at the source, or at most, importing the module.

TIA,

-Pat

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


Re: DICOM library

2008-06-10 Thread mathieu
On Jun 10, 1:05 pm, [EMAIL PROTECTED] wrote:
> Hi everybody!
> I've been looking for a python library wich allows me to work with
> with DICOM files, for medical image processing. Finding nothing at
> first, evenctually i've find thegdcmlibrary, wich is suposed to be
> for c developement, but they say that you can use it with python, as
> "It is automatically wrapped to python (using swig)". So, the cuestion
> is: how can I use this kind of library, wich is suposed to be used
> with c, in python? When I download the tarball there ae only 2 .py
> files. shall I install the whole library for using in C, and then try
> to import thegdcmmodule in python? becouse i'm afraid it won't work.
> Thanks in advance, and sorry for my english, wich is not very good
> actually. Sorry for asking for something before trying everything, but
> i'm almost desperate to find a library like that.

You will get a tons more help directly at GDCM ML:

https://lists.sourceforge.net/lists/listinfo/gdcm-developers

The process is quite simple, GDCM is written using a limited subset of
C++ (not C!) and using SWIG the API can be automagically wrap into
another target language (in your case: python).

If you download the binaries, you are all set (expect maybe adjusting
your PYTHONPATH).

Anyway this is highly GDCM oriented, and we should continue this
discussion directly on the GDCM ML.

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


str to float (rounded)

2008-06-10 Thread Nader
Hello,

I have a list of tuple with strin elements. These elements are number,
but they are save as string. Now I will change the string to number
which will be rounded. An example will make it more clear.

t = [('35.757', '-0.239'), ('33.332', '-2.707'), ('33.640', '-2.423')]

And I will have the next list:

t = [(35.76, -2.24), (33.33, -2.71), (33.64, -2.42)]

The elements of tuple are not more as string.

Would somebody tell me how I can do that?

Regards,
Nader

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


Re: str to float (rounded)

2008-06-10 Thread Diez B. Roggisch
Nader wrote:

> Hello,
> 
> I have a list of tuple with strin elements. These elements are number,
> but they are save as string. Now I will change the string to number
> which will be rounded. An example will make it more clear.
> 
> t = [('35.757', '-0.239'), ('33.332', '-2.707'), ('33.640', '-2.423')]
> 
> And I will have the next list:
> 
> t = [(35.76, -2.24), (33.33, -2.71), (33.64, -2.42)]
> 
> The elements of tuple are not more as string.
> 
> Would somebody tell me how I can do that?

use 

float("123.45")

to convert a string to a float.

Of course you need to do that on all your elements above by e.g. a
list-comprehension.

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


Re: Py2exe and name space package

2008-06-10 Thread Yuan HOng
On 6/10/08, Mike Driscoll <[EMAIL PROTECTED]> wrote:

>
> I include the lxml package in some of my programs and I do so by
> adding the following to the setup.py
>
> packages = ['lxml']
>
> However, I'm not sure if what you want to add is truly a package.
> Yours might go into the "includes" directive. Currently, I use the
> GUI2Exe wrapper for py2exe as I find it easier to make complex
> executables. You can find it here:
>

Thanks. When I modifed setup.py to include the 'includes' directive, as:

from distutils.core import setup
import py2exe

setup(name='test',
  zipfile=None,
  options={'py2exe': {'includes': ['zope.interface']}},
  console=[
  {
'script': 'main.py',
  }
  ])


The build process will not finish with the following error:

C:\temp>python setup.py py2exe
running py2exe
*** searching for required modules ***
Traceback (most recent call last):
  File "setup.py", line 9, in 
'script': 'main.py',
  File "c:\Python25\lib\distutils\core.py", line 151, in setup
dist.run_commands()
  File "c:\Python25\lib\distutils\dist.py", line 974, in run_commands
self.run_command(cmd)
  File "c:\Python25\lib\distutils\dist.py", line 994, in run_command
cmd_obj.run()
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\build_exe.py",
line 223, in run
self._run()
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\build_exe.py",
line 274, in _run
self.find_needed_modules(mf, required_files, required_modules)
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\build_exe.py",
line 1189, in find_needed_modules
mf.import_hook(mod)
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\mf.py",
line 649, in import_hook
return Base.import_hook(self,name,caller,fromlist)
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\mf.py",
line 131, in import_hook
m = self.load_tail(q, tail)
  File 
"c:\Python25\lib\site-packages\py2exe-0.6.6-py2.5-win32.egg\py2exe\mf.py",
line 197, in load_tail
raise ImportError, "No module named " + mname
ImportError: No module named zope.interface

> http://xoomer.alice.it/infinity77/main/GUI2Exe.html
>

I will try this one.

-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
--
http://mail.python.org/mailman/listinfo/python-list

Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread chardish
Hello,

I'm trying to build an executable with py2exe, but unfortunately the
version I have is 0.6.6, which has a rather annoying bug that doesn't
let you rename the executable file if you bundle everything in a
single executable. It seems fairly unacceptable to tell our customers
that they can't rename a file we send them.

I hear this problem is fixed in 0.6.8, but unfortunately there's no
standalone installer for py2exe 0.6.8 - the most recent version that
has an installer is 0.6.6 way back from 2006 (!). Is there a
standalone installer for py2exe 0.6.8 anywhere? If not, how do I build
it from source? (There's no instructions in the readme - it just says
"How to install: download the standalone installer" and doesn't
include building instructions.)

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


proposal: give delattr ability to ignore missing attribute

2008-06-10 Thread Gary Wilson
I would like to propose that functionality be added to delattr to
handle the case when the attribute does not exist.

First off, getattr handles this nicely with the default parameter:

value = getattr(obj, 'foo', False)

instead of:

try:
value = getattr(obj, 'foo')
except AttributeError:
value = False

or:

if hasattr(obj, 'foo'):
value = getattr(obj, 'foo')
else:
value = False


And I think it makes sense to have something similar for delattr (name
the argument as you wish):

delattr(obj, 'foo', allow_missing=True)

instead of:

try:
delattr(obj, 'foo')
except AttributeError:
pass

or:

try:
del obj.foo
except AttributeError:
pass

or:

if hasattr(obj, 'foo')
delattr(obj, 'foo')

For backwards compatibility, allow_missing would default to False.

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


Dumb idea?

2008-06-10 Thread Peter Hunt
Hi everyone -

I like playing around with language syntax and semantics. I'm thinking
about pulling down the PyPy code and messing around to see what I can
accomplish. My first idea is most succinctly described by example:

class IBlockProtocol:
def __block__(self, func):
# NO RETURN VALUES!
pass

# my_IBlockProtocol is an expression that evaluates to an implementor
of IBlockProtocol

my_IBlockProtocol: expr

# becomes:

my_IBlockProtocol.__block__(lambda: expr)

###

my_IBlockProtocol: expr

# becomes:

my_IBlockProtocol.__block__(lambda param1, paramN: expr)

###

my_IBlockProtocol:
stmt1
stmt2

# becomes:

def anon():
stmt1
stmt2

my_IBlockProtocol.__block__(anon)

###

my_IBlockProtocol:
stmt1
stmt2

# becomes:

def anon(param1, paramN):
stmt1
stmt2

my_IBlockProtocol.__block__(anon)

###

Has this already been done? Is it a stupid idea? I think it could be
used to simplify event handling and some Twisted stuff. I'm mainly
looking for reasons why I _wouldn't_ want to take the time to get my
hands dirty with the PyPy code (or even CPython) and try to implement
this syntax.

Thanks.

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


Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread Thomas Heller
[EMAIL PROTECTED] schrieb:
> Hello,
> 
> I'm trying to build an executable with py2exe, but unfortunately the
> version I have is 0.6.6, which has a rather annoying bug that doesn't
> let you rename the executable file if you bundle everything in a
> single executable. It seems fairly unacceptable to tell our customers
> that they can't rename a file we send them.
> 
> I hear this problem is fixed in 0.6.8, but unfortunately there's no
> standalone installer for py2exe 0.6.8 - the most recent version that
> has an installer is 0.6.6 way back from 2006 (!). Is there a
> standalone installer for py2exe 0.6.8 anywhere? If not, how do I build
> it from source? (There's no instructions in the readme - it just says
> "How to install: download the standalone installer" and doesn't
> include building instructions.)

Easy - download the sources, and enter 'python setup.py bdist_wininst' in the
top-level directory.  You need the same compiler that was used to build the
Python that you use.

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


Re: str to float (rounded)

2008-06-10 Thread Nader
On Jun 10, 4:30 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Nader wrote:
> > Hello,
>
> > I have a list of tuple with strin elements. These elements are number,
> > but they are save as string. Now I will change the string to number
> > which will be rounded. An example will make it more clear.
>
> > t = [('35.757', '-0.239'), ('33.332', '-2.707'), ('33.640', '-2.423')]
>
> > And I will have the next list:
>
> > t = [(35.76, -2.24), (33.33, -2.71), (33.64, -2.42)]
>
> > The elements of tuple are not more as string.
>
> > Would somebody tell me how I can do that?
>
> use
>
> float("123.45")
>
> to convert a string to a float.
>
> Of course you need to do that on all your elements above by e.g. a
> list-comprehension.
>
> Diez

If I do the next :

 t1 = [(round(float(x),1), round(float(y),2)) for x, y in t]

I get the long float as :

[(35.797, -0.23999), (33.297,
-2.71), (33.601,-2.4199)]

But I would have a float with 2 decimal numbers.


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


Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread chardish
On Jun 10, 11:07 am, Thomas Heller <[EMAIL PROTECTED]> wrote:
> You need the same compiler that was used to build the
> Python that you use.

Thanks for the tip. So if I downloaded a binary Python instead of
building it from sources, I'm out of luck?
--
http://mail.python.org/mailman/listinfo/python-list


Advice for a python newbie on parsing whois records?

2008-06-10 Thread Phillip B Oldham
Hi. I'm stretching my boundaries in programming with a little python
shell-script which is going to loop through a list of domain names,
grab the whois record, parse it, and put the results into a csv.

I've got the results coming back fine, but since I have *no*
experience with python I'm wondering what would be the preferred
"pythonic" way of parsing the whois string into a csv record.

Tips/thoughts/examples more than welcome!
--
http://mail.python.org/mailman/listinfo/python-list


Re: chm file for download?

2008-06-10 Thread member thudfoo
On 6/10/08, John Salerno <[EMAIL PROTECTED]> wrote:
> Is the chm doc file available for download from the Python website? I can't
>  seem to find it. It would be nice to read through while I'm at work (where I
>  don't have Python installed).
>
>  Also, is it possible to use a chm file on Linux?
>
[...]

I am using xCHM on SuSE 10.2: iirc, there were components I had to
find in order to build it.

I just downloaded and installed kchmviewer (
http://www.kchmviewer.net/) without incident. My initial reaction is
that kchmviewer is better in at least two significant ways: it uses
the same number of lines per scroll wheel movement as other
applications (xCHM uses more, unconfigurable afaik); kchmviewer moves
the page to the indexed item in the page (xCHM just shows the the top
of the page leaving the user to locate the item in the page).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does the python library of Google Data API is truly free?

2008-06-10 Thread Lie
On Jun 10, 2:49 pm, Kless <[EMAIL PROTECTED]> wrote:
> On 9 jun, 22:46, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>
> > Kless schrieb:
>
> > > On 9 jun, 21:40, Lie <[EMAIL PROTECTED]> wrote:
> > >> Do you notice that the terms are for the SERVICE not for the SOFTWARE.
> > >> The terms for the service is quite reasonable, as I see it.
> > >> The software itself is governed by the Apache License 2.0, detailed
> > >> here:http://www.apache.org/licenses/LICENSE-2.0
>
> > > Well, it's used a free license to access to a service that is not free
> > > -it's owner and too restrictive-. And it isn't nothing reasonable that
> > > Google get many rights about your content, and that you have not any
> > > right about the rest of the content.
>
> > > This goes against the free software, considering that a service is
> > > software.
>
> > This is nonsense. If a hosting provider offers you free hosting based on
> > linux - and then goes out of business or is forced to charge money - do
> > you say "that's against free software?"
>
> I don't speak about hosting else rights about data, data that are
> entered by people:
>

This shows you have not made any efforts to understand the difference
between software and service: SOFTWARE != SERVICE.

The freedom and the restriction of the software is governed by the
Apache License 2.0. On the other hand, the freedom and the restriction
of the service is governed by this rules, which has a pretty
reasonable terms for a service.


> "By submitting, posting or displaying the content you give
> Google a perpetual, irrevocable, worldwide, royalty-free, and non-
> exclusive license to reproduce, adapt, modify, translate, publish,
> publicly perform, publicly display and distribute any Content which
> you submit, post or display on or through, the Services..."

You have cut an important line to support your proposition:
This license is for the sole purpose of enabling Google to display,
distribute and promote the Services and may be revoked for certain
Services as defined in the Additional Terms of those Services.

> "You agree that this license includes a right for Google to make
> such Content available to other companies, organizations or
> individuals with whom Google has relationships for the provision of
> syndicated services..."

Without this line, there is no way the service could work, since
basically the service (GData) is all about making your data available
to other people.

> > Or if they prohibit you to host malicious, offending or otherwise
> > problematic content served by the free apache - is that "against free
> > software?"
>
> Please, don't be demagogue.
>
> > A service is a service. It is offered as is, under whatever conditions
> > the provider likes it.
>
> A service or web service to follows being software. A software where
> is more easy to add restrictions, in this case those restrictions goes
> against the freedoms of the free software.

Some companies advertise Software as a Service, in those case the
Service is equivalent to the Software. In this case, the service is
GData Service and the Software is the GData API.

> > Offering a convenient way to access the service using a FOSS license is
> > good style. But you aren't forced to use that, you can write your own.
> > But that doesn't change the terms and conditions of the service itself.
>
> Offering access via Apache 2.0 -wich is not compatible with GPLv2- to
> a non-free service is a mortal trap where people are falling.

Whether Apache 2.0 is GPLv2 compatible or not is irrelevant, GPL is
only one type of license, no more no less, it's not the Holy Grail of
free software spirit. The fact that many other softwares use GPL
license is because the license has been designed for general use and
many open source groups doesn't really have the knowledge, capability,
and/or time to create their own license (creating a license is not as
easy as it seems), most doesn't even care what their software is
licensed on and their exact terms. The use of a well-known license
also made it easy for the users to know the license he's agreeing to
without reading and reading and reading a license again and again and
again.
--
http://mail.python.org/mailman/listinfo/python-list


Re: str to float (rounded)

2008-06-10 Thread Diez B. Roggisch
> 
> If I do the next :
> 
>  t1 = [(round(float(x),1), round(float(y),2)) for x, y in t]
> 
> I get the long float as :
> 
> [(35.797, -0.23999), (33.297,
> -2.71), (33.601,-2.4199)]
> 
> But I would have a float with 2 decimal numbers.

There is no such thing as a float with only two decimal numbers. This has
been discussed on this ML a bazillion times - what you see above are
rounding errors due to the approximation of decimal values by binary
floating points. 

You can *convert a float to a string* and specify a precision when printing:

>>> print "%.2f" % 2.41999
2.42

Or you can use the module decimal to work with numbers base 10 - which you
can also limit to certain precisions. See a recent thread on this ML,
google for "Alternative to decimal type"


Diez


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


Building 64-bit Python on AIX

2008-06-10 Thread Michael Mabin
Hi all.  I am trying to rebuild Python on our AIX system in 64 bit so I can
use our installed 64-bit UnixODBC library.  Has anyone successfully done
this and can they share the configure options they used?
Thanks.

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

Re: Advice for a python newbie on parsing whois records?

2008-06-10 Thread Lie
On Jun 10, 9:47 pm, Phillip B Oldham <[EMAIL PROTECTED]> wrote:
> Hi. I'm stretching my boundaries in programming with a little python
> shell-script which is going to loop through a list of domain names,
> grab the whois record, parse it, and put the results into a csv.
>
> I've got the results coming back fine, but since I have *no*
> experience with python I'm wondering what would be the preferred
> "pythonic" way of parsing the whois string into a csv record.
>
> Tips/thoughts/examples more than welcome!

Generally, when doing a simple parsing you'd use re module (regular
expression).
More complex parsers would use pyparsing (3rd party module). I've
never used pyparsing myself though. You might download pyparsing
here:http://pyparsing.wikispaces.com/Download+and+Installation
--
http://mail.python.org/mailman/listinfo/python-list


Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread Mike Driscoll
On Jun 10, 10:04 am, [EMAIL PROTECTED] wrote:
> Hello,
>
> I'm trying to build an executable with py2exe, but unfortunately the
> version I have is 0.6.6, which has a rather annoying bug that doesn't
> let you rename the executable file if you bundle everything in a
> single executable. It seems fairly unacceptable to tell our customers
> that they can't rename a file we send them.
>
> I hear this problem is fixed in 0.6.8, but unfortunately there's no
> standalone installer for py2exe 0.6.8 - the most recent version that
> has an installer is 0.6.6 way back from 2006 (!). Is there a
> standalone installer for py2exe 0.6.8 anywhere? If not, how do I build
> it from source? (There's no instructions in the readme - it just says
> "How to install: download the standalone installer" and doesn't
> include building instructions.)
>
> Cheers,
> Evan

Maybe I'm missing something, but I can rename the executables I create
using py2exe 0.6.6 to anything I want after they're created.

Or are you talking about a Windows installer for the py2exe module
itself? Where are you finding this 0.6.8 version anyway? I can't find
it on www.py2exe.org

Anyway, what Thomas is talking about is that the only way to create a
usable installer of py2exe on Windows is to use the same compiler that
the Python you are using. As I understand it, Python 2.4 and 2.5 used
Visual Studio 2003. I think 2.3 used VS6. I have both, so I can try to
compile an installer for any of those versions if you can link me to
the source.

Mike

Python Extension Building Network: http:\\www.pythonlibrary.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Does the python library of Google Data API is truly free?

2008-06-10 Thread Diez B. Roggisch
> I don't speak about hosting else rights about data, data that are
> entered by people:
> 
> "By submitting, posting or displaying the content you give
> Google a perpetual, irrevocable, worldwide, royalty-free, and non-
> exclusive license to reproduce, adapt, modify, translate, publish,
> publicly perform, publicly display and distribute any Content which
> you submit, post or display on or through, the Services..."
> 
> "You agree that this license includes a right for Google to make
> such Content available to other companies, organizations or
> individuals with whom Google has relationships for the provision of
> syndicated services..."

This does not affect the distinction between a SERVICE that has it's own
terms and conditions with a SOFTWARE that provides the means to use that
service from a programmers or users point of view. Unless you rid yourself
of that misconception, this discussion is fruitless.
 
>> Or if they prohibit you to host malicious, offending or otherwise
>> problematic content served by the free apache - is that "against free
>> software?"
> Please, don't be demagogue.

It is not "demagogue" - it's a simple question that illustrates the same
issue: free software as means to access content that don't share anything
wrt to licensing or such.
 
>> A service is a service. It is offered as is, under whatever conditions
>> the provider likes it.
> A service or web service to follows being software. A software where
> is more easy to add restrictions, in this case those restrictions goes
> against the freedoms of the free software.

A service is a service. It might be IMPLEMENTED using software, free or not,
which is totally irrelevant for the discussion of the terms of the service.
 
>> Offering a convenient way to access the service using a FOSS license is
>> good style. But you aren't forced to use that, you can write your own.
>> But that doesn't change the terms and conditions of the service itself.
> Offering access via Apache 2.0 -wich is not compatible with GPLv2- to
> a non-free service is a mortal trap where people are falling.

What's that supposed to mean? Do you say that any site that is being served
by free software (under whatever license) has to do that for free? Like
ordering a 42" TV online on a apache hosted site requires them to give it
to me for free?


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


Re: Building 64-bit Python on AIX

2008-06-10 Thread Michael Mabin
Oops.  Forgot to mention this is AIX 5.3 and I'm trying to install Python
2.5.2. Using xlc compiler.

On Tue, Jun 10, 2008 at 10:34 AM, Michael Mabin <[EMAIL PROTECTED]> wrote:

> Hi all.  I am trying to rebuild Python on our AIX system in 64 bit so I can
> use our installed 64-bit UnixODBC library.  Has anyone successfully done
> this and can they share the configure options they used?
> Thanks.
>
> Mike
> --
>
>


-- 
| _ | * | _ |
| _ | _ | * |
| * | * | * |
--
http://mail.python.org/mailman/listinfo/python-list

Re: Does the python library of Google Data API is truly free?

2008-06-10 Thread Dan Upton
>> Or if they prohibit you to host malicious, offending or otherwise
>> problematic content served by the free apache - is that "against free
>> software?"
> Please, don't be demagogue.

Please don't be [a] troll?

I fail to see what is so hard to understand about the difference
between free software and services provided via free software.
--
http://mail.python.org/mailman/listinfo/python-list


Re: EXE is very slow by starting (>10sec.) (build with PyInstaller)

2008-06-10 Thread Lie
On Jun 10, 5:29 pm, "Mark Delon" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> My Python executable created with PyInstaller is too slow by starting...
> It takes about 15 secs.!!!
>
> I am  using PyQt4 libraries for creating my very simple GUI-application.
>
> -> How can I SPEED UP my executable ???
> -> Do you know some GOOD build switches?
>
> Thank you very much for every idea...
>
> Best Regards
>
> Mark
>
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN:http://www.gmx.net/de/go/smartsurfer

Possibly you could use a splash screen and as have been said, you
should load modules as late as possible (that means the some import
statement is not positioned in the beginning of the code). You should
reach the event loop as soon as possible.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread chardish
On Jun 10, 11:34 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> Maybe I'm missing something, but I can rename the executables I create
> using py2exe 0.6.6 to anything I want after they're created.
>
> Or are you talking about a Windows installer for the py2exe module
> itself? Where are you finding this 0.6.8 version anyway? I can't find
> it onwww.py2exe.org
>
> Anyway, what Thomas is talking about is that the only way to create a
> usable installer of py2exe on Windows is to use the same compiler that
> the Python you are using. As I understand it, Python 2.4 and 2.5 used
> Visual Studio 2003. I think 2.3 used VS6. I have both, so I can try to
> compile an installer for any of those versions if you can link me to
> the source.
>
> Mike
>
> Python Extension Building Network:     http:\\www.pythonlibrary.org

The issue with renaming executables only applies to single-file
executables, i.e. ones created with zipfile = None as an argument to
setup() and --bundle 1 as a command line argument. This is a known
issue as of 0.6.6: http://py2exe.org/index.cgi/ProblemsToBeFixed

I found sources for 0.6.8 on CVS at: http://sourceforge.net/cvs/?group_id=15583

A Windows installer for the 0.6.8 py2exe module would be ideal, but
somehow I doubt that's going to happen anytime soon since there hasn't
been a new installer since 2006. If you are willing to build that for
me (since I don't have VS) I'd really appreciate it : ) I'm using 32-
bit WinXP on this computer.
--
http://mail.python.org/mailman/listinfo/python-list


mysql to sqlite

2008-06-10 Thread Gandalf
I'm trying to convert mysql database to sqlite. is their any free tool
that does that?
I can convert my mysql db to XML file through phpmyadmin, will it be
easier to convert  from XML to SQlite then  from Mysql?
--
http://mail.python.org/mailman/listinfo/python-list


Re: proposal: give delattr ability to ignore missing attribute

2008-06-10 Thread Lie
On Jun 10, 10:06 pm, Gary Wilson <[EMAIL PROTECTED]> wrote:
> I would like to propose that functionality be added to delattr to
> handle the case when the attribute does not exist.
>
> First off, getattr handles this nicely with the default parameter:
>
> value = getattr(obj, 'foo', False)
>
> instead of:
>
> try:
>     value = getattr(obj, 'foo')
> except AttributeError:
>     value = False
>
> or:
>
> if hasattr(obj, 'foo'):
>     value = getattr(obj, 'foo')
> else:
>     value = False
>
> And I think it makes sense to have something similar for delattr (name
> the argument as you wish):
>
> delattr(obj, 'foo', allow_missing=True)
>
> instead of:
>
> try:
>     delattr(obj, 'foo')
> except AttributeError:
>     pass
>
> or:
>
> try:
>     del obj.foo
> except AttributeError:
>     pass
>
> or:
>
> if hasattr(obj, 'foo')
>     delattr(obj, 'foo')
>
> For backwards compatibility, allow_missing would default to False.
>
> Gary

That doesn't need to be implemented internally, you could do it
yourself in python.

def my_delattr(obj, attr):
try:
delattr(obj, attr)
except AttributeError:
pass
def my_getattr(obj, attr, default):
try:
return getattr(obj, attr)
except AttributeError:
return default
--
http://mail.python.org/mailman/listinfo/python-list


Python doesn't understand %userprofile%

2008-06-10 Thread bsagert
In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
bites back with "cannot find the path specified" Since my script has
to run on machines where the username is unspecified I need a fix.
Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python doesn't understand %userprofile%

2008-06-10 Thread bsagert
On Jun 10, 8:56 am, [EMAIL PROTECTED] wrote:
> In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> bites back with "cannot find the path specified" Since my script has
> to run on machines where the username is unspecified I need a fix.
> Thanks in advance.

oops that should be os.path.getmtime("%userprofile%/dir/file")
--
http://mail.python.org/mailman/listinfo/python-list


Re: Web Crawler - Python or Perl?

2008-06-10 Thread disappearedng
As to why as opposed to what, I am attempting to build a search engine
right now that plans to crawl not just html but other things too.

I am open to learning, and I don't want to learn anything that doesn't
really contribute to building my search engine for the moment. Hence I
want to see whether learning PERL will be helpful to the later parts
of my search engine.

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


Re: Python doesn't understand %userprofile%

2008-06-10 Thread Tim Golden

[EMAIL PROTECTED] wrote:

In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
bites back with "cannot find the path specified" Since my script has
to run on machines where the username is unspecified I need a fix.


Well I can see a few problems here. 

First is that putting percent signs around the whole path is 
never going to work anyway. You want something like:


"%USERPROFILE%/dir/file". 

Secondly, the expansion of environment variables like 
USERPROFILE is done for you by the shell or the command 
prompt. You have to do it for yourself if you're opening your 
own files. You want something like:


import os
print os.path.getmtime (os.path.join (os.environ['USERPROFILE'], "ntuser.ini"))

But finally, what do you mean "run on machines where the username is
unspecified"? If you mean: where no user is logged in, then you won't
have a (meaningful) userprofile in any case: it might be the Default User
profile; I'm not sure. But is that what you want?

You *can* use the functions in the win32profile module of the pywin32
packages to find out various things about profiles directories, but things
can get quite complicated if users have roaming profiles and the like.

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


chained exceptions

2008-06-10 Thread Rowland Smith
Is anyone aware of a module or recipe for defining a composite/chained  
exception superclass?  I've seen the PEP on chained exceptions wrt  
Python-3K, but I'm looking for something that is 2.5 compatible.


-Rowland

---
"The Dude abides."

- The Dude,
  The Big Lebowski
---






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


Re: Python doesn't understand %userprofile%

2008-06-10 Thread Lie
On Jun 10, 11:11 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> > bites back with "cannot find the path specified" Since my script has
> > to run on machines where the username is unspecified I need a fix.
>
> Well I can see a few problems here.
>
> First is that putting percent signs around the whole path is
> never going to work anyway. You want something like:
>
> "%USERPROFILE%/dir/file".
>
> Secondly, the expansion of environment variables like
> USERPROFILE is done for you by the shell or the command
> prompt. You have to do it for yourself if you're opening your
> own files. You want something like:
>
> import os
> print os.path.getmtime (os.path.join (os.environ['USERPROFILE'], 
> "ntuser.ini"))
>
> But finally, what do you mean "run on machines where the username is
> unspecified"? If you mean: where no user is logged in, then you won't
> have a (meaningful) userprofile in any case: it might be the Default User
> profile; I'm not sure. But is that what you want?

I think what he meant is where he doesn't know in advance the name of
the user name.

> You *can* use the functions in the win32profile module of the pywin32
> packages to find out various things about profiles directories, but things
> can get quite complicated if users have roaming profiles and the like.
>
> TJG

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


problems with opening files due to file's path

2008-06-10 Thread Alexnb

Okay, so what I want my program to do it open a file, a music file in
specific, and for this we will say it is an .mp3. Well, I am using the
system() command from the os class. The problem I am running into is that
when I send the path of the file to the system() command, which for those of
you who don't know the system command is the equivalent of typing one
command into command prompt or terminal depending on your system. But let's
say that the file is "C:\Music\01 - Track.mp3" or something like that where
the number 0 is next to the backslash. Another example is this
"C:\Music\track(single)\Track.mp3" The problem here is that the ")" at the
end of the single, is conflicting with the backslash as well. Now here is
the exact code I was trying to do and when I run it I get false returned. 

system("\"C:\Documents and Settings\Alex\My Documents\My
Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")

Okay, now as you can see it sends it to the system with quotes "\"" and
works if I change the file path and get rid of the "04" and the ")" it
works, so that is the problem no doubt. If anyone has a way to do this
please let me know, or even another way to open a music file like this.
Help?
-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17759531.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: mysql to sqlite

2008-06-10 Thread Gerhard Häring

Gandalf wrote:

I'm trying to convert mysql database to sqlite. is their any free tool
that does that?
I can convert my mysql db to XML file through phpmyadmin, will it be
easier to convert  from XML to SQlite then  from Mysql?


Did you look at http://www.sqlite.org/cvstrac/wiki?p=ConverterTools ?

I'd try one of these if I need it. Otherwise it seems easier for me to 
parse XML than to try out all the options of mysqladmin, which probably 
still won't produce anything that can directly be fed to sqlite3.


It would be a nice programming exercise. Hint: You can pretty safely 
ignore all type information you get from MySQL, because types in SQLite 
depend on the inserted values, and not the table definition.


-- Gerhard

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


Re: problems with opening files due to file's path

2008-06-10 Thread Gerhard Häring

Alexnb wrote:

Okay, so what I want my program to do it open a file, a music file in
specific, and for this we will say it is an .mp3. Well, I am using the
system() command from the os class. [...]

system("\"C:\Documents and Settings\Alex\My Documents\My
Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
[...]


Try os.startfile() instead. It should work better.

-- Gerhard

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


Re: problems with opening files due to file's path

2008-06-10 Thread Alexnb



Gerhard Häring wrote:
> 
> Alexnb wrote:
>> Okay, so what I want my program to do it open a file, a music file in
>> specific, and for this we will say it is an .mp3. Well, I am using the
>> system() command from the os class. [...]
>> 
>> system("\"C:\Documents and Settings\Alex\My Documents\My
>> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
>> [...]
> 
> Try os.startfile() instead. It should work better.
> 
> -- Gerhard
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 


No, it didn't work, but it gave me some interesting feedback when I ran it
in the shell. Heres what it told me:

>>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>>> Yours.wma")

Traceback (most recent call last):
  File "", line 1, in 
os.startfile("C:\Documents and Settings\Alex\My Documents\My
Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm Yours.wma")

WindowsError: [Error 2] The system cannot find the file specified:
"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
Yours.wma"

See it made each backslash into two, and the one by the parenthesis and the
0 turned into an x 
-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17759825.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: eric4 wont start

2008-06-10 Thread Detlev Offenbach
Hi,

please try with the latest release, which is 4.1.5, and report back.

Regards,
Detlev

dusans wrote:

> Hi i took a look at eric4, its nice, cuz u have the script output and
> console in the same window, which is why i love pyscripter.
> Then i upgradet eric4 to newest version: eric4-4.0.4, it doesnt start,
> even when i installed the old version:
> 
> The error massage is:
> Warning: translation file 'qt_en_US'could not be loaded.
> Using default.
> Warning: translation file 'eric4_en_US'could not be loaded.
> Using default.
> Warning: translation file 'qscintilla_en_US'could not be loaded.
> Using default.
> 
> 
> It just stopes and doesnt go on. Anyone got an idea how to solve this,
> cuz i really like eric4

-- 
Detlev Offenbach
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread Mike Driscoll
On Jun 10, 10:47 am, [EMAIL PROTECTED] wrote:
> On Jun 10, 11:34 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > Maybe I'm missing something, but I can rename the executables I create
> > using py2exe 0.6.6 to anything I want after they're created.
>
> > Or are you talking about a Windows installer for the py2exe module
> > itself? Where are you finding this 0.6.8 version anyway? I can't find
> > it onwww.py2exe.org
>
> > Anyway, what Thomas is talking about is that the only way to create a
> > usable installer of py2exe on Windows is to use the same compiler that
> > the Python you are using. As I understand it, Python 2.4 and 2.5 used
> > Visual Studio 2003. I think 2.3 used VS6. I have both, so I can try to
> > compile an installer for any of those versions if you can link me to
> > the source.
>
> > Mike
>
> > Python Extension Building Network:     http:\\www.pythonlibrary.org
>
> The issue with renaming executables only applies to single-file
> executables, i.e. ones created with zipfile = None as an argument to
> setup() and --bundle 1 as a command line argument. This is a known
> issue as of 0.6.6:http://py2exe.org/index.cgi/ProblemsToBeFixed


I'm using GUI2Exe to wrap my 0.6.6 version of py2exe. I use the bundle
into a single file option in it and have zipfile=None too. But maybe
one of my other switches is different.


>
> I found sources for 0.6.8 on CVS at:http://sourceforge.net/cvs/?group_id=15583
>
> A Windows installer for the 0.6.8 py2exe module would be ideal, but
> somehow I doubt that's going to happen anytime soon since there hasn't
> been a new installer since 2006. If you are willing to build that for
> me (since I don't have VS) I'd really appreciate it : ) I'm using 32-
> bit WinXP on this computer.


I finally figured out how to check out the code. I'm at work now,
where I only have VS2008 installed so I'll have to wait until I get
home this evening to try compiling it. I'll let you know if I have any
luck.

-
Mike

Python Extension Building Network: http:\\www.pythonlibrary.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with opening files due to file's path

2008-06-10 Thread Mike Driscoll
On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:
> Gerhard Häring wrote:
>
> > Alexnb wrote:
> >> Okay, so what I want my program to do it open a file, a music file in
> >> specific, and for this we will say it is an .mp3. Well, I am using the
> >> system() command from the os class. [...]
>
> >> system("\"C:\Documents and Settings\Alex\My Documents\My
> >> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
> >> [...]
>
> > Try os.startfile() instead. It should work better.
>
> > -- Gerhard
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> No, it didn't work, but it gave me some interesting feedback when I ran it
> in the shell. Heres what it told me:
>
> >>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
> >>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
> >>> Yours.wma")
>
> Traceback (most recent call last):
>   File "", line 1, in 
>     os.startfile("C:\Documents and Settings\Alex\My Documents\My
> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm Yours.wma")
>
> WindowsError: [Error 2] The system cannot find the file specified:
> "C:\\Documents and Settings\\Alex\\My Documents\\My
> Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
> Yours.wma"
>
> See it made each backslash into two, and the one by the parenthesis and the
> 0 turned into an x
> --
> View this message in 
> context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
> Sent from the Python - python-list mailing list archive at Nabble.com.

Yeah. You need to either double all the backslashes or make it a raw
string by adding an "r" to the beginning, like so:

os.startfile(r'C:\path\to\my\file')

HTH

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


Re: Python doesn't understand %userprofile%

2008-06-10 Thread Mike Driscoll
On Jun 10, 11:11 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> > bites back with "cannot find the path specified" Since my script has
> > to run on machines where the username is unspecified I need a fix.
>
> Well I can see a few problems here.
>
> First is that putting percent signs around the whole path is
> never going to work anyway. You want something like:
>
> "%USERPROFILE%/dir/file".
>
> Secondly, the expansion of environment variables like
> USERPROFILE is done for you by the shell or the command
> prompt. You have to do it for yourself if you're opening your
> own files. You want something like:
>
> import os
> print os.path.getmtime (os.path.join (os.environ['USERPROFILE'], 
> "ntuser.ini"))
>
> But finally, what do you mean "run on machines where the username is
> unspecified"? If you mean: where no user is logged in, then you won't
> have a (meaningful) userprofile in any case: it might be the Default User
> profile; I'm not sure. But is that what you want?
>
> You *can* use the functions in the win32profile module of the pywin32
> packages to find out various things about profiles directories, but things
> can get quite complicated if users have roaming profiles and the like.
>
> TJG

Tim,

I'm surprised you didn't mention your excellent winshell utility. I
use it for this sort of issue all the time where I need to update
files on login and I don't know the user's name beforehand.

The winshell.Desktop() one has been a life saver and I think the OP
could probably use winshell for their problem. Or I may be completely
off my rocker.

Either way, here's the link: http://timgolden.me.uk/python/winshell.html

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


make more money

2008-06-10 Thread kumarvs06561
make more money
internet jobs
easy way to make money

http://kumarpracticals.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: proposal: give delattr ability to ignore missing attribute

2008-06-10 Thread Fuzzyman
On Jun 10, 4:55 pm, Lie <[EMAIL PROTECTED]> wrote:
> On Jun 10, 10:06 pm, Gary Wilson <[EMAIL PROTECTED]> wrote:
>
>
>
> > I would like to propose that functionality be added to delattr to
> > handle the case when the attribute does not exist.
>

I've never once needed that functionality. In fact I very rarely use
delattr at all. I don't think there is a compelling enough use case
for adding this to Python.

Michael Foord
http://www.ironpythoninaction.com/


> > First off, getattr handles this nicely with the default parameter:
>
> > value = getattr(obj, 'foo', False)
>
> > instead of:
>
> > try:
> >     value = getattr(obj, 'foo')
> > except AttributeError:
> >     value = False
>
> > or:
>
> > if hasattr(obj, 'foo'):
> >     value = getattr(obj, 'foo')
> > else:
> >     value = False
>
> > And I think it makes sense to have something similar for delattr (name
> > the argument as you wish):
>
> > delattr(obj, 'foo', allow_missing=True)
>
> > instead of:
>
> > try:
> >     delattr(obj, 'foo')
> > except AttributeError:
> >     pass
>
> > or:
>
> > try:
> >     del obj.foo
> > except AttributeError:
> >     pass
>
> > or:
>
> > if hasattr(obj, 'foo')
> >     delattr(obj, 'foo')
>
> > For backwards compatibility, allow_missing would default to False.
>
> > Gary
>
> That doesn't need to be implemented internally, you could do it
> yourself in python.
>
> def my_delattr(obj, attr):
>     try:
>         delattr(obj, attr)
>     except AttributeError:
>         pass
> def my_getattr(obj, attr, default):
>     try:
>         return getattr(obj, attr)
>     except AttributeError:
>         return default

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


Re: problems with opening files due to file's path

2008-06-10 Thread Alexnb

Hey thanks!, both the raw and the double backslashes worked. You are a
gentleman and a scholar. 

Mike Driscoll wrote:
> 
> On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:
>> Gerhard Häring wrote:
>>
>> > Alexnb wrote:
>> >> Okay, so what I want my program to do it open a file, a music file in
>> >> specific, and for this we will say it is an .mp3. Well, I am using the
>> >> system() command from the os class. [...]
>>
>> >> system("\"C:\Documents and Settings\Alex\My Documents\My
>> >> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
>> >> [...]
>>
>> > Try os.startfile() instead. It should work better.
>>
>> > -- Gerhard
>>
>> > --
>> >http://mail.python.org/mailman/listinfo/python-list
>>
>> No, it didn't work, but it gave me some interesting feedback when I ran
>> it
>> in the shell. Heres what it told me:
>>
>> >>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>> >>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>> >>> Yours.wma")
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>> Yours.wma")
>>
>> WindowsError: [Error 2] The system cannot find the file specified:
>> "C:\\Documents and Settings\\Alex\\My Documents\\My
>> Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
>> Yours.wma"
>>
>> See it made each backslash into two, and the one by the parenthesis and
>> the
>> 0 turned into an x
>> --
>> View this message in
>> context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
>> Sent from the Python - python-list mailing list archive at Nabble.com.
> 
> Yeah. You need to either double all the backslashes or make it a raw
> string by adding an "r" to the beginning, like so:
> 
> os.startfile(r'C:\path\to\my\file')
> 
> HTH
> 
> Mike
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761126.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: Instructions on how to build py2exe 0.6.8 (or an installer would be nice, too!)

2008-06-10 Thread chardish
On Jun 10, 1:11 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Jun 10, 10:47 am, [EMAIL PROTECTED] wrote:
>
>
>
> > On Jun 10, 11:34 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
> > > Maybe I'm missing something, but I can rename the executables I create
> > > using py2exe 0.6.6 to anything I want after they're created.
>
> > > Or are you talking about a Windows installer for the py2exe module
> > > itself? Where are you finding this 0.6.8 version anyway? I can't find
> > > it onwww.py2exe.org
>
> > > Anyway, what Thomas is talking about is that the only way to create a
> > > usable installer of py2exe on Windows is to use the same compiler that
> > > the Python you are using. As I understand it, Python 2.4 and 2.5 used
> > > Visual Studio 2003. I think 2.3 used VS6. I have both, so I can try to
> > > compile an installer for any of those versions if you can link me to
> > > the source.
>
> > > Mike
>
> > > Python Extension Building Network:     http:\\www.pythonlibrary.org
>
> > The issue with renaming executables only applies to single-file
> > executables, i.e. ones created with zipfile = None as an argument to
> > setup() and --bundle 1 as a command line argument. This is a known
> > issue as of 0.6.6:http://py2exe.org/index.cgi/ProblemsToBeFixed
>
> I'm using GUI2Exe to wrap my 0.6.6 version of py2exe. I use the bundle
> into a single file option in it and have zipfile=None too. But maybe
> one of my other switches is different.
>
>
>
> > I found sources for 0.6.8 on CVS 
> > at:http://sourceforge.net/cvs/?group_id=15583
>
> > A Windows installer for the 0.6.8 py2exe module would be ideal, but
> > somehow I doubt that's going to happen anytime soon since there hasn't
> > been a new installer since 2006. If you are willing to build that for
> > me (since I don't have VS) I'd really appreciate it : ) I'm using 32-
> > bit WinXP on this computer.
>
> I finally figured out how to check out the code. I'm at work now,
> where I only have VS2008 installed so I'll have to wait until I get
> home this evening to try compiling it. I'll let you know if I have any
> luck.
>
> -
> Mike
>
> Python Extension Building Network:     http:\\www.pythonlibrary.org

Thanks, Mike. Hopefully you'll have more luck than I've had : )

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


Re: problems with opening files due to file's path

2008-06-10 Thread Alexnb

Well, now i've hit another problem, this time being that the path will be a
variable, and I can't figure out how to make startfile() make it raw with a
variable, if I put startfile(r variable), it doesn't work and
startfile(rvariable) obviously won't work, do you know how to make that work
or better yet, how to take a regular string that is given and make every
single "\" into a double "\\"?

Mike Driscoll wrote:
> 
> On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:
>> Gerhard Häring wrote:
>>
>> > Alexnb wrote:
>> >> Okay, so what I want my program to do it open a file, a music file in
>> >> specific, and for this we will say it is an .mp3. Well, I am using the
>> >> system() command from the os class. [...]
>>
>> >> system("\"C:\Documents and Settings\Alex\My Documents\My
>> >> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
>> >> [...]
>>
>> > Try os.startfile() instead. It should work better.
>>
>> > -- Gerhard
>>
>> > --
>> >http://mail.python.org/mailman/listinfo/python-list
>>
>> No, it didn't work, but it gave me some interesting feedback when I ran
>> it
>> in the shell. Heres what it told me:
>>
>> >>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>> >>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>> >>> Yours.wma")
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>> Yours.wma")
>>
>> WindowsError: [Error 2] The system cannot find the file specified:
>> "C:\\Documents and Settings\\Alex\\My Documents\\My
>> Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
>> Yours.wma"
>>
>> See it made each backslash into two, and the one by the parenthesis and
>> the
>> 0 turned into an x
>> --
>> View this message in
>> context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
>> Sent from the Python - python-list mailing list archive at Nabble.com.
> 
> Yeah. You need to either double all the backslashes or make it a raw
> string by adding an "r" to the beginning, like so:
> 
> os.startfile(r'C:\path\to\my\file')
> 
> HTH
> 
> Mike
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761338.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: Python doesn't understand %userprofile%

2008-06-10 Thread Duncan Booth
[EMAIL PROTECTED] wrote:

> In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> bites back with "cannot find the path specified" Since my script has
> to run on machines where the username is unspecified I need a fix.
> Thanks in advance.

>>> os.path.expanduser("~/dir/file")
'C:\\Documents and Settings\\Duncan/dir/file'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Russ P.
On Jun 10, 1:04 am, Bruno Desthuilliers  wrote:

> If you hope to get a general agreement here in favor of a useless
> keyword that don't bring anything to the language, then yes, I'm afraid
> you're wasting your time.

Actually, what I hope to do is to "take something away" from the
language, and that is the need to clutter my identifiers with leading
underscores.

I find that I spend the vast majority of my programming time working
on the "private" aspects of my code, and I just don't want to look at
leading underscores everywhere. So I usually just leave them off and
resort to a separate user guide to specify the public interface.

I'll bet many Python programmers do the same. How many Python
programmers do you think use leading underscores on every private data
member or method, or even most of them for that matter? I'll bet not
many. (See the original post on this thread.) That means that this
particular aspect of Python is basically encouraging sloppy
programming practices.

What I don't understand is your visceral hostility to the idea of a
"priv" or "private" keyword. If it offends you, you wouldn't need to
use it in your own code. You would be perfectly free to continue using
the leading-underscore convention (unless your employer tells you
otherwise, of course).

I get the impression that Python suits your own purposes and you
really don't care much about what purpose others might have for it. I
am using it to develop a research prototype of a major safety-critical
system. I chose Python because it enhances my productivity and has a
clean syntax, but my prototype will eventually have to be re-written
in another language. I took a risk in choosing Python, and I would
feel better about it if Python would move up to the next level with
more advanced features such as (optional) static typing and private
declarations. But every time I propose something like that, I get all
kinds of flak from people here who do their hacking and care little
about anyone else's needs.

With a few relatively small improvements, Python could expand its
domain considerably and make major inroads into territory that is now
dominated by C++, Java, and other statically compiled languages. But
that won't happen if reactionary hackers stand in the way.

Side note: I've been looking at Scala, and I like what I see.  It may
actually be more appropriate for my needs, but I have so much invested
in Python at this point that the switch will not be easy.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python doesn't understand %userprofile%

2008-06-10 Thread [EMAIL PROTECTED]
On Jun 10, 2:09 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> > bites back with "cannot find the path specified" Since my script has
> > to run on machines where the username is unspecified I need a fix.
> > Thanks in advance.
> >>> os.path.expanduser("~/dir/file")
>
> 'C:\\Documents and Settings\\Duncan/dir/file'

"~" appears to look first at the HOME environment variable.
That is not necessarily the same as "USERPROFILE". On my machine it is
not.
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with opening files due to file's path

2008-06-10 Thread Alexnb

No this time it perhaps gave me the worst of all heres what I entered, and
the output

>>> startfile(r"%s"%full)***full is the path***

startfile(r"%s"%full)

WindowsError: [Error 2] The system cannot find the file specified:
'"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I\'m Yours (Single)\x01 - I\'m
Yours.wma"'


Thomas Morton wrote:
> 
> maybe try string substitution... not sure if that's really the BEST way to 
> do it but it should work
> 
> startfile(r"%s"%variable)
> 
> --
> From: "Alexnb" <[EMAIL PROTECTED]>
> Sent: Tuesday, June 10, 2008 7:05 PM
> To: 
> Subject: Re: problems with opening files due to file's path
> 
>>
>> Well, now i've hit another problem, this time being that the path will be 
>> a
>> variable, and I can't figure out how to make startfile() make it raw with 
>> a
>> variable, if I put startfile(r variable), it doesn't work and
>> startfile(rvariable) obviously won't work, do you know how to make that 
>> work
>> or better yet, how to take a regular string that is given and make every
>> single "\" into a double "\\"?
>>
>> Mike Driscoll wrote:
>>>
>>> On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:
 Gerhard Häring wrote:

 > Alexnb wrote:
 >> Okay, so what I want my program to do it open a file, a music file
 in
 >> specific, and for this we will say it is an .mp3. Well, I am using 
 >> the
 >> system() command from the os class. [...]

 >> system("\"C:\Documents and Settings\Alex\My Documents\My
 >> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The
 Sun.wma\"")
 >> [...]

 > Try os.startfile() instead. It should work better.

 > -- Gerhard

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

 No, it didn't work, but it gave me some interesting feedback when I ran
 it
 in the shell. Heres what it told me:

 >>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
 >>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
 >>> Yours.wma")

 Traceback (most recent call last):
   File "", line 1, in 
 os.startfile("C:\Documents and Settings\Alex\My Documents\My
 Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
 Yours.wma")

 WindowsError: [Error 2] The system cannot find the file specified:
 "C:\\Documents and Settings\\Alex\\My Documents\\My
 Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
 Yours.wma"

 See it made each backslash into two, and the one by the parenthesis and
 the
 0 turned into an x
 --
 View this message in
 context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
 Sent from the Python - python-list mailing list archive at Nabble.com.
>>>
>>> Yeah. You need to either double all the backslashes or make it a raw
>>> string by adding an "r" to the beginning, like so:
>>>
>>> os.startfile(r'C:\path\to\my\file')
>>>
>>> HTH
>>>
>>> Mike
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>>
>> -- 
>> View this message in context: 
>> http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761338.html
>> Sent from the Python - python-list mailing list archive at Nabble.com.
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761946.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: problems with opening files due to file's path

2008-06-10 Thread Thomas Morton
maybe try string substitution... not sure if that's really the BEST way to 
do it but it should work


startfile(r"%s"%variable)

--
From: "Alexnb" <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2008 7:05 PM
To: 
Subject: Re: problems with opening files due to file's path



Well, now i've hit another problem, this time being that the path will be 
a
variable, and I can't figure out how to make startfile() make it raw with 
a

variable, if I put startfile(r variable), it doesn't work and
startfile(rvariable) obviously won't work, do you know how to make that 
work

or better yet, how to take a regular string that is given and make every
single "\" into a double "\\"?

Mike Driscoll wrote:


On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:

Gerhard Häring wrote:

> Alexnb wrote:
>> Okay, so what I want my program to do it open a file, a music file in
>> specific, and for this we will say it is an .mp3. Well, I am using 
>> the

>> system() command from the os class. [...]

>> system("\"C:\Documents and Settings\Alex\My Documents\My
>> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The Sun.wma\"")
>> [...]

> Try os.startfile() instead. It should work better.

> -- Gerhard

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

No, it didn't work, but it gave me some interesting feedback when I ran
it
in the shell. Heres what it told me:

>>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>>> Yours.wma")

Traceback (most recent call last):
  File "", line 1, in 
os.startfile("C:\Documents and Settings\Alex\My Documents\My
Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
Yours.wma")

WindowsError: [Error 2] The system cannot find the file specified:
"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
Yours.wma"

See it made each backslash into two, and the one by the parenthesis and
the
0 turned into an x
--
View this message in
context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
Sent from the Python - python-list mailing list archive at Nabble.com.


Yeah. You need to either double all the backslashes or make it a raw
string by adding an "r" to the beginning, like so:

os.startfile(r'C:\path\to\my\file')

HTH

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




--
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761338.html

Sent from the Python - python-list mailing list archive at Nabble.com.

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


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

Re: Python for the web

2008-06-10 Thread Daniel Fetchinson
> Hello,
> I have developed a python tool that basically does two things:
> 1. Allow the user to search for a keyword or a group of Keywords in a
> specailized collection of text files.  This search option is part of a
> massive custom tree control that was developed using wxpython.
> 2. The rest of the tree control is in the form of concepts (labels for
> the concepts) that the user chooses from to get some text displayed as well.
>
> I have been adviced to use AppEngine but do you think that as my application
> sends a lot of user requests to the server(to ask for some pieces of text to
> be displayed), using CGI will be too slow? Is there a better way of doing
> it? If you can advice me on which tools to use to develop my web page that
> will include a tree structure, I would be very grateful.
>
> Thank you very much in advance,
> Nora.

If you use the google appengine you probably won't have problems with
performance. Django [1] works with the appengine (as far as I know) so
you can build your app using that framework. If you don't insist on
the appengine you may want to check out turbogears [2] either the
stable version 1 [3] or the brand new but not yet released version 2
[4]. If you don't mind a steep learning curve there is zope [5] but
many tend to agree that for anything small to medium size it's an
overkill. If your app is really simple and any framework feels too
heavy weight you might just go ahead with plain CGI or fastCGI or use
mod_wsgi [6] directly assuming you use apache. The old mod_python [7]
module of apache is not very actively maintained and mod_wsgi is
favored over it but if what you do is a small in-house stuff nobody
will stop you from using it and it can actually be a good option.

[1] http://www.djangoproject.com/
[2] http://turbogears.org/
[3] http://docs.turbogears.org/1.0
[4] http://turbogears.org/2.0/docs/index.html
[5] http://zope.org/
[6] http://code.google.com/p/modwsgi/
[7] http://modpython.org/

Cheers,
Daniel
-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with opening files due to file's path

2008-06-10 Thread Mike Driscoll
On Jun 10, 1:25 pm, "Thomas Morton" <[EMAIL PROTECTED]>
wrote:
> maybe try string substitution... not sure if that's really the BEST way to
> do it but it should work
>
> startfile(r"%s"%variable)


I concur. That should work. A slightly more in depth example (assuming
Windows):

os.startfile(r'C:\Documents and Settings\%s\Desktop\myApp.exe' %
username)

or

os.startfile(r'C:\Program Files\%s' % myApp)

Hopefully this is what you are talking about. If you were referring to
passing in arguments, than you'll want to use the subprocess module
instead.


>
> --
> From: "Alexnb" <[EMAIL PROTECTED]>
> Sent: Tuesday, June 10, 2008 7:05 PM
> To: <[EMAIL PROTECTED]>
> Subject: Re: problems with opening files due to file's path
>
>
>
> > Well, now i've hit another problem, this time being that the path will be
> > a
> > variable, and I can't figure out how to make startfile() make it raw with
> > a
> > variable, if I put startfile(r variable), it doesn't work and
> > startfile(rvariable) obviously won't work, do you know how to make that
> > work
> > or better yet, how to take a regular string that is given and make every
> > single "\" into a double "\\"?
>



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


BANKRUPTCY LAWYER

2008-06-10 Thread MERLIN
**  
http://bankruptcylawyer1.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Patrick Mullen
Hi Russ,

Here are just some pragmatic considerations.  Personally I am against data
hiding, but I obviously won't convince you in that regard.  There are some
pros and cons as with anything, and I feel the cons outweight the pros
(namely that users of code should be able to use how they want, even if it
means shooting themselves in the foot; and the fact that priv somewhat
breaks the dynamics of python)

Even if your proposal were to go through, you are looking at probably 2
years before it can even be used.  Python3 is basically in freeze mode, and
it contains the biggest change in python syntax for a long time.  I know it
doesn't seem like a big change to you to add a priv keyword, but python very
rarely adds keywords, so it's a long shot merely for that reason.  This is
something that potentially would be under consideration for something like
3.2 or higher I think, so if you want to get the job done now, this topic or
trying to convince other long time python users isn't going to accomplish
your goals.

Leading underscore takes two keystrokes to type (shift, _) while priv,
private, etc takes many more.  If you are too lazy to type "_var" then how
come you aren't too lazy to type "priv var"?  Too me it seems like more
typing.  If the primary objection to leading underscores is looks, it seems
like you unnecesarily avoid them for a pointless reason.  There are ugly
aspects to every language, and there isn't really a better convention to use
that I can see.  Without of course implementing keywords, which are
conceptually difficult to think about in terms of python object model -
although you might be able to come up with a way.  But if you have a better
naming convention or strategy that you want to try on your code, nothing is
stopping you.

You can use one of the hacks found in this thread, or come up with your own
hack, to more or less accomplish what you want.  It should take 30 minutes
or less to set up, and you are done with it.  The internals of python make
it difficult to do more than that, but you are welcome to create your own
python fork if you think you are up to it.  Although I think that would be
more than 30 minutes of work.

And feel free to try other languages.  No one claimed python is the best for
every circumstance.  Well, if someone claimed that they are just fooling
themselves.  Python is a good hacker language that scales pretty well into
enterprise and web services; and can be used for other things as well.  I
don't believe that data prevention (we aren't really talking about just
hiding here) is necessary for 99% of tasks, but other people think
differently, so there are plenty of languages that implement these features.

Good luck finding a solution to fit your project.  However I don't think
trying to get a "priv" keyword into official python is feasable unless you
want to wait a very long time and go hoarse from shouting :)
--
http://mail.python.org/mailman/listinfo/python-list

Re: problems with opening files due to file's path

2008-06-10 Thread Alexnb

That would work, but not for what I want. See the file could be anywhere on
the user's system and so the entire path will be unique, and that didn't
work with a unique path. What is the subprocess module you are talking
about?

Mike Driscoll wrote:
> 
> On Jun 10, 1:25 pm, "Thomas Morton" <[EMAIL PROTECTED]>
> wrote:
>> maybe try string substitution... not sure if that's really the BEST way
>> to
>> do it but it should work
>>
>> startfile(r"%s"%variable)
> 
> 
> I concur. That should work. A slightly more in depth example (assuming
> Windows):
> 
> os.startfile(r'C:\Documents and Settings\%s\Desktop\myApp.exe' %
> username)
> 
> or
> 
> os.startfile(r'C:\Program Files\%s' % myApp)
> 
> Hopefully this is what you are talking about. If you were referring to
> passing in arguments, than you'll want to use the subprocess module
> instead.
> 
> 
>>
>> --
>> From: "Alexnb" <[EMAIL PROTECTED]>
>> Sent: Tuesday, June 10, 2008 7:05 PM
>> To: <[EMAIL PROTECTED]>
>> Subject: Re: problems with opening files due to file's path
>>
>>
>>
>> > Well, now i've hit another problem, this time being that the path will
>> be
>> > a
>> > variable, and I can't figure out how to make startfile() make it raw
>> with
>> > a
>> > variable, if I put startfile(r variable), it doesn't work and
>> > startfile(rvariable) obviously won't work, do you know how to make that
>> > work
>> > or better yet, how to take a regular string that is given and make
>> every
>> > single "\" into a double "\\"?
>>
> 
> 
> 
> Mike
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17762276.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: Web Crawler - Python or Perl?

2008-06-10 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
> As to why as opposed to what, I am attempting to build a search engine
> right now that plans to crawl not just html but other things too.
> 
> I am open to learning, and I don't want to learn anything that doesn't
> really contribute to building my search engine for the moment. Hence I
> want to see whether learning PERL will be helpful to the later parts
> of my search engine.

I honestly don't think there's anything useful in Perl that you can't do in
Python. There's tons of ugly ways to write unreadable code, though, so if you
prefer that, that's something that's harder to do in Python.

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


Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Jonathan Gardner
On Jun 10, 11:21 am, "Russ P." <[EMAIL PROTECTED]> wrote:
> I took a risk in choosing Python, and I would
> feel better about it if Python would move up to the next level with
> more advanced features such as (optional) static typing and private
> declarations. But every time I propose something like that, I get all
> kinds of flak from people here who do their hacking and care little
> about anyone else's needs.

Let me share my personal insight. I used Python for a mission-critical
application that needed, in effect, almost 100% uptime with superior
throughput. In other words, it was a very fine piece of art that
needed to be precise and correct. In the end, Python delivered, under
budget, under schedule, and with superbly low maintenance costs
(practically 0 compared to other systems written in Java and C). I
didn't have to use any of the features you mentioned, and I can't
imagine why you would need them. In fact, having them in the language
would encourage others to use them and make my software less reliable.

You may think we are all a bunch of hackers who are too stupid to
understand what you are saying, but that is your loss.

Now, let me try to explain something that perhaps the previous 166
post may not have thoroughly explained. If I am duplicating what
everyone else has already said, then it's my own fault.

Short answer: You don't need these features in Python. You do need to
use the right tools for the right tasks.

Long answer:

Who cares what the type of an object is? Only the machine. Being able
to tell, in advance, what the type of a variable is is a premature
optimization. Tools like psyco prove that computers (really,
programmers) nowadays are smart enough to figure things out the right
way without any hints from the developer. Static typing is no longer
necessary in today's world.

Who cares about private declarations, or interface declarations at
all? It is only a message to the developers. If you have a problem
with your users doing the right thing, that is a social problem, not a
technical one, and the solution is social, not technical. Yes, it is
work, but it is not coding---it is explaining to other living,
breathing human beings how to do a specific task, which is what you
should have been doing from the start.

When all you have is a hammer, the world seems full of nails. Think
about that. You have more tools than Python to solve these problems,
and Python will never be the panacea you wish it was. The panacea is
you, putting the right tools to use for the right tasks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with opening files due to file's path

2008-06-10 Thread Thomas Morton

heh thanks Mike - glad im not going mad :P

Just tested locally in IDLE (I know I know!) and it works for me like this:


test = os.path.join(os.getcwd(),"NEWS.txt")
test

'D:\\Python25\\NEWS.txt'

os.startfile(r"%s"%test)



And the file opens...

Does the file definitely exist?

Tom
--
From: "Alexnb" <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2008 7:37 PM
To: 
Subject: Re: problems with opening files due to file's path



No this time it perhaps gave me the worst of all heres what I entered, and
the output


startfile(r"%s"%full)***full is the path***


startfile(r"%s"%full)

WindowsError: [Error 2] The system cannot find the file specified:
'"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I\'m Yours (Single)\x01 - I\'m
Yours.wma"'


Thomas Morton wrote:


maybe try string substitution... not sure if that's really the BEST way 
to

do it but it should work

startfile(r"%s"%variable)

--
From: "Alexnb" <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2008 7:05 PM
To: 
Subject: Re: problems with opening files due to file's path



Well, now i've hit another problem, this time being that the path will 
be

a
variable, and I can't figure out how to make startfile() make it raw 
with

a
variable, if I put startfile(r variable), it doesn't work and
startfile(rvariable) obviously won't work, do you know how to make that
work
or better yet, how to take a regular string that is given and make every
single "\" into a double "\\"?

Mike Driscoll wrote:


On Jun 10, 11:45 am, Alexnb <[EMAIL PROTECTED]> wrote:

Gerhard Häring wrote:

> Alexnb wrote:
>> Okay, so what I want my program to do it open a file, a music file
in
>> specific, and for this we will say it is an .mp3. Well, I am using
>> the
>> system() command from the os class. [...]

>> system("\"C:\Documents and Settings\Alex\My Documents\My
>> Music\Rhapsody\Bryanbros\Weezer\(2001)\04 - Island In The
Sun.wma\"")
>> [...]

> Try os.startfile() instead. It should work better.

> -- Gerhard

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

No, it didn't work, but it gave me some interesting feedback when I 
ran

it
in the shell. Heres what it told me:

>>> os.startfile("C:\Documents and Settings\Alex\My Documents\My
>>> Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
>>> Yours.wma")

Traceback (most recent call last):
  File "", line 1, in 
os.startfile("C:\Documents and Settings\Alex\My Documents\My
Music\Rhapsody\Bryanbros\Jason Mraz\I'm Yours (Single)\01 - I'm
Yours.wma")

WindowsError: [Error 2] The system cannot find the file specified:
"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I'm Yours (Single)\x01 - I'm
Yours.wma"

See it made each backslash into two, and the one by the parenthesis 
and

the
0 turned into an x
--
View this message in
context:http://www.nabble.com/problems-with-opening-files-due-to-file%27s-pat...
Sent from the Python - python-list mailing list archive at Nabble.com.


Yeah. You need to either double all the backslashes or make it a raw
string by adding an "r" to the beginning, like so:

os.startfile(r'C:\path\to\my\file')

HTH

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




--
View this message in context:
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761338.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


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



--
View this message in context: 
http://www.nabble.com/problems-with-opening-files-due-to-file%27s-path-tp17759531p17761946.html

Sent from the Python - python-list mailing list archive at Nabble.com.

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


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

Re: Determining which things in 'from package import *' are actually used

2008-06-10 Thread Robert Kern

Patrick Bouffard wrote:

I have a fairly large library of Python code, where 'from package import *' is
used rather liberally, and it's not uncommon for more than one of these to
appear in any given module. What I'd like to be able to do is to clean my code
up a bit and turn each of the 'from package import *' statements into 'from
package import thing_1, thing_2, ..., thing_n', where only thing_i's that are
actually _used_ in the module are imported. In this way I hope to make my code a
bit more understandable by future civilizations. :) (it needs all the help it
can get!)

Does anyone know of a package/recipe/whatever that does something like this
automatically, even in limited cases? Ideally it should be accomplished only by
looking at the source, or at most, importing the module.


I don't know of any automatic tools. I usually comment out those import 
statements and use pyflakes to show me the undefined names.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Python doesn't understand %userprofile%

2008-06-10 Thread Tim Golden

[EMAIL PROTECTED] wrote:

On Jun 10, 2:09 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:

[EMAIL PROTECTED] wrote:

In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
bites back with "cannot find the path specified" Since my script has
to run on machines where the username is unspecified I need a fix.
Thanks in advance.

os.path.expanduser("~/dir/file")

'C:\\Documents and Settings\\Duncan/dir/file'


"~" appears to look first at the HOME environment variable.
That is not necessarily the same as "USERPROFILE". On my machine it is
not.


There was quite a debate over that on python-dev earlier
this year. In short, it's not easy to identify exactly what
"~" means on a Windows box. The implementer of that patch
took the view that HOME comes first and then USERPROFILE,
finally HOMEDRIVE/SHARE/PATH. On my machine at work,
the latter should take precedence as they are set via
my domain logon. Other people's mileage may vary. In addition,
the code assumes that the home for any *other* user can
always be derived from the *current* user's home.
Which will not always be the case.

All that is essentially why the user-specific functions
exposed in win32profile rely on a logon token to operate.

(Bit of a rant, but just to highlight that things are
seldom what they seem).

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


Re: problems with opening files due to file's path

2008-06-10 Thread Carsten Haese

Alexnb wrote:

No this time it perhaps gave me the worst of all heres what I entered, and
the output


startfile(r"%s"%full)***full is the path***


startfile(r"%s"%full)

WindowsError: [Error 2] The system cannot find the file specified:
'"C:\\Documents and Settings\\Alex\\My Documents\\My
Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I\'m Yours (Single)\x01 - I\'m
Yours.wma"'


Contrary to what other posters have asserted, doing the above can't make 
a difference. Putting 'r' in front of a string literal tells Python not 
to give backslashes in the string literal any special treatment. Since 
there are no backslashes in "%s", the 'r' does nothing.


Therefore, (r"%s"%full) is the same as ("%s"%full), which is the same as 
(full), assuming that `full` is the name of a string.


The real answer lies in fixing the code where you're assigning the 
pathname to 'full', which you haven't posted. Please post the code where 
you're assigning the pathname, or better yet, post the complete code 
you're running.


--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Advice for a python newbie on parsing whois records?

2008-06-10 Thread Miki
Hello,

> Hi. I'm stretching my boundaries in programming with a little python
> shell-script which is going to loop through a list of domain names,
> grab the whois record, parse it, and put the results into a csv.
>
> I've got the results coming back fine, but since I have *no*
> experience with python I'm wondering what would be the preferred
> "pythonic" way of parsing the whois string into a csv record.
>
> Tips/thoughts/examples more than welcome!

from os import popen
import re

find_record = re.compile("\s+([^:]+): (.*)\s*").match
for line in popen("whois google.com"):
match = find_record(line)
if not match:
continue
print "%s --> %s" % (match.groups()[0], match.groups()[1])

HTH,
--
Miki <[EMAIL PROTECTED]>
http://pythonwise.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: problems with opening files due to file's path

2008-06-10 Thread Mike Driscoll
On Jun 10, 2:09 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> Alexnb wrote:
> > No this time it perhaps gave me the worst of all heres what I entered, and
> > the output
>
>  startfile(r"%s"%full)    ***full is the path***
>
> > startfile(r"%s"%full)
>
> > WindowsError: [Error 2] The system cannot find the file specified:
> > '"C:\\Documents and Settings\\Alex\\My Documents\\My
> > Music\\Rhapsody\\Bryanbros\\Jason Mraz\\I\'m Yours (Single)\x01 - I\'m
> > Yours.wma"'
>
> Contrary to what other posters have asserted, doing the above can't make
> a difference. Putting 'r' in front of a string literal tells Python not
> to give backslashes in the string literal any special treatment. Since
> there are no backslashes in "%s", the 'r' does nothing.


I assumed the OP was trying to do the string substitution within a
path. If the OP is instead doing as you think, then you are quite
correct.

>
> Therefore, (r"%s"%full) is the same as ("%s"%full), which is the same as
> (full), assuming that `full` is the name of a string.
>
> The real answer lies in fixing the code where you're assigning the
> pathname to 'full', which you haven't posted. Please post the code where
> you're assigning the pathname, or better yet, post the complete code
> you're running.
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net


Sometimes I get too eager to help and don't do enough mental
processing before answering.

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


Re: problems with opening files due to file's path

2008-06-10 Thread Mike Driscoll
On Jun 10, 1:57 pm, Alexnb <[EMAIL PROTECTED]> wrote:
> That would work, but not for what I want. See the file could be anywhere on
> the user's system and so the entire path will be unique, and that didn't
> work with a unique path. What is the subprocess module you are talking
> about?
>




As Carsten pointed out, we don't really know what you're doing. Or at
least, I don't. Why do you even want to do string substitution? How
does the user navigate to the files that the user wants to open? Are
you using a GUI or a command line interface?

Anyway, Google is your friend. Searching for "python subprocess" gives
you this:

http://docs.python.org/lib/module-subprocess.html

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


Re: How to kill a thread?

2008-06-10 Thread Rhamphoryncus
On Jun 10, 1:55 am, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> On 2008-06-09, Rhamphoryncus <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jun 9, 5:33 am, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> >> On 2008-06-07, Rhamphoryncus <[EMAIL PROTECTED]> wrote:
>
> >> > On Jun 6, 12:44 pm, The Pythonista <[EMAIL PROTECTED]> wrote:
> >> >> It's always been my understanding that you can't forcibly kill a thread
> >> >> in Python (at least not in a portable way).  The best you can do is
> >> >> politely ask it to die, IIRC.
>
> >> > Inherently, the best you can do in most languages is ask them politely
> >> > to die.  Otherwise you'll leave locks and various other datastructures
> >> > in an inconvenient state, which is too complex to handle correctly.
> >> > The exception is certain functional languages, which aren't capable of
> >> > having threads and complex state in the same sense.
>
> >> Well it would of course depend on what is considered asking politely?
>
> >> If one thread could cause an exception being thrown in an other thread,
> >> would this be considered a polite way to ask? Would it be considered
> >> an acceptable way?
>
> > The exception must not be raised until a point explicitly designed as
> > safe is hit.  Otherwise, any function that manipulates data you'll
> > still use will potentially be buggered.  Consider sys.stdout: codecs,
> > buffering, lots to go wrong.
>
> I don't see the point. Exceptions are raised now without the ability
> of an explicitly designed safe point. If something unexpected happens
> your code can raise an exception and leave your data buggered too if
> you didn't anticipate it propely.

Although in theory you could get any exception at any point, in
practise you shouldn't unless your program is broken.  If it is broken
the exceptions shouldn't be caught and should cause the program to
terminate, so the harm is reduced.  The exceptions that should happen
(such as IOError) should be from predicted points, and anticipated.

A notable exception is MemoryError, which can show up from anywhere at
any time.  Nobody's come up with a solution to that one, so we usually
just let the program die.

Cancelling a thread implies your program will continue.  Otherwise
you'd just exit the whole process (either via _exit() or via daemon
threads.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: post-mortem from core dump

2008-06-10 Thread peter
Bump

Has noone ever needed this?

On Jun 9, 10:58 am, peter <[EMAIL PROTECTED]> wrote:
> AFAIK pdb only can do postmortem debugging if fed a Python stack
> trace. Is there any way to obtain such a stack trace if all you've got
> is a core dump?
>
> Or, put another way: can I do post-mortem debugging from a core dump?
>
> Thanks,
> peter.

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


  1   2   >