A question about thrift performance.

2013-01-05 Thread Vincent
Hi, all

I have issue of thrift-performance in python, does anyone has an experience on 
thrift-in-python?

My question in stackoverflow:

http://stackoverflow.com/questions/14171227/why-is-thrift-binary-protocol-serialization-so-much-slow


Copy the question to here(open stackoverflow to check pretty-print question 
content):

I'm newbie on thrift. I wrote a thrift server in python, also client in python 
too.

Here is my thrift defination:
struct RatingByReport {
1: required string ticker,
2: required i32 cnt_institution,
3: optional list strong_buy,
4: optional list buy,
5: optional list neutral,
6: optional list sell,
7: optional list strong_sell,
8: optional i32 cnt_maintain,
9: optional i32 cnt_upgrade,
10: optional i32 cnt_downgrade,
11: optional i32 avg_score,
12: optional string adjustment
}

struct TableRatingByReport {
1: required list head,
2: required list body,
3: optional struct.CadaTranslation translation
}



service china{
void ping(),
TableRatingByReport rating_byreport(1:string ticker) throws 
(1:struct.CadaInternalError error)
}
Here is my server side:
handler = StockChinaHandler()
processor = china.Processor(handler)
#startup()

transport = TSocket.TServerSocket(port=30303)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()

server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
#server = TProcessPoolServer.TProcessPoolServer(processor, transport,
#tfactory, pfactory)

print "Start server..."
import cProfile
print >>open('/tmp/test.log', 'w'), cProfile.run('server.serve()',
sort='cumulative')
#server.serve()
print "done!"
Client side:
# Make socket
transport = TSocket.TSocket('localhost', 30303)

# Buffering is critical. Raw sockets are very slow
transport = TTransport.TBufferedTransport(transport)

# Wrap in a protocol
protocol = TBinaryProtocol.TBinaryProtocol(transport)

# Create a client to use the protocol encoder
client = china.Client(protocol)

# Connect!
transport.open()

client.ping()
print "ping()"

print msg
msg = client.rating_byreport('2012-01-04')
print msg
transport.close()
cProfile result:
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
10.0000.000  230.968  230.968 :1()
10.0000.000  230.968  230.968 TServer.py:74(serve)
30.0000.000  225.967   75.322 TSocket.py:172(accept)
30.0000.000  225.967   75.322 socket.py:194(accept)
3  225.967   75.322  225.967   75.322 {method 'accept' of 
'_socket.socket' objects}
50.0030.0014.9930.999 china.py:140(process)
10.0000.0003.2003.200 
china.py:177(process_rating_byreport)
10.0000.0002.3662.366 china.py:500(write)
10.0030.0032.3662.366 ttypes.py:515(write)
 14550.2610.0002.3630.002 ttypes.py:364(write)
   160.2460.0001.9950.000 TCompactProtocol.py:38(nested)
   1458800.2980.0001.6400.000 
TCompactProtocol.py:255(__writeString)
   181.3700.0761.3700.076 {method 'recv' of 
'_socket.socket' objects}
50.0000.0001.2920.258 
TCompactProtocol.py:306(readMessageBegin)
   130.0000.0001.2920.099 
TCompactProtocol.py:286(__readUByte)
   260.0000.0001.2910.050 TTransport.py:54(readAll)
   260.0000.0001.2910.050 TTransport.py:154(read)
50.0000.0001.2910.258 TSocket.py:101(read)
In my case, TableRatingByReport instance got a body with 1400 rows(list\), and 
It cost over 3 seconds(function *process_rating_byreport*, which is auto 
generate by thift) to generate binnary content. I don't know why it is so slow.

Using json to serialize the same data, It's only spend less than 200 ms.

I'm wondering did I use the uncorrect way to manipulate thrift?

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


Re: Deadlock and a rather weird stacktrace

2011-03-10 Thread Vincent
Can nobody explain this? Please. how can a sleep() continue in a
__bootstrap() ?

Regards,
Vincent

On 4 feb, 13:39, Vincent van Beveren 
wrote:
> Hi everyone,
>
> I'm currently working on a multithreaded GUI system in Python 2.6. In this 
> system I use conditions to coordinate synchronization. However, one condition 
> suddenly locks, without any cause. As a last resort I have written a small 
> routine to dump all the stack traces.
>
>     def dumpAllStacks(self):
>         for threadId, stack in sys._current_frames().items():
>             print "Thread with Id: %s" % threadId
>             traceback.print_stack(stack)
>
> When the system is dead-locked, I invoke this method. One stack-trace strikes 
> me as odd:
>
> Thread with Id: 1568
>   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
>     self.__bootstrap_inner()
>   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
>     self.run()
>   File "c:\PYTHON26\lib\threading.py", line 477, in run
>     self.__target(*self.__args, **self.__kwargs)
>   File "c:\PYTHON26\lib\site-packages\magnum\gui\autogui.py", line 2558, in 
> __sendDataLoop
>     self.__sendDataCondition.wait(1)
>   File "c:\PYTHON26\lib\threading.py", line 256, in wait
>     _sleep(delay)
>   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
>     self.__bootstrap_inner()                     <<= What?
>   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
>     self.run()
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2242, 
> in run
>     self.updateTask()
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2214, 
> in updateTask
>     
> self.statusServerModule.updateTaskWithConnection(self.statusServerConnection)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 2450, in updateTaskWithConnection
>     self.updateDataWithConnection(connection, updateAll)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 2488, in updateDataWithConnection
>     self.updateVariableData(varDataDict, frozenset(varDataDict))
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 796, in updateVariableData
>     self.cmdMgr.updateVariableData(self.moduleId, varDataDict, forceVarIdSet) 
> # after this varMgr makes deepcopy
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
> 441, in updateVariableData
>     self.notifyUpdateReport(updatedData)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
> 493, in notifyUpdateReport
>     with self.updateReportCondition:
>   File "c:\PYTHON26\lib\threading.py", line 205, in __enter__
>     return self.__lock.__enter__()
>   File "c:\PYTHON26\lib\threading.py", line 121, in acquire
>     rc = self.__block.acquire(blocking)
>
> Can someone tell me how the sleep of one thread can continue as the 'run' of 
> another? Is this normal? Thanks in advance!
>
> Regards,Vincentvan Beveren
>
> ___
> Ing. V. van Beveren
> Software Engineer, FOM Rijnhuizen
> T: +31 (0) 30-6096769
> E: v.vanbeve...@rijnhuizen.nl

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


Re: how to make python socket server work with the app.MainLoop() in wxpython?

2006-07-31 Thread Vincent
I think you should use thread.
I just write a similar program using thread. It works well
You can try it, good luck!

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


Is there a python system to admin MySQL database online?

2006-08-20 Thread vincent
Just like the phpMySQLadmin?

Thanks for reply!

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


Re: String to unicode - duplicating by function the effect of u prefix

2009-06-19 Thread Vincent
On Jun 18, 3:23 pm, CiTro  wrote:
> Thank you, Peter. That solved my problem.

the another way is,

codecs.raw_unicode_escape_decode(stringOne) == stringTwo

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


Re: Python class gotcha with scope?

2009-06-20 Thread Vincent
On Jun 21, 2:32 pm, billy  wrote:
> I don't quite understand why this happens. Why doesn't b have its own
> version of r? If r was just an int instead of a dict, then it would.
>
> >>> class foo:
>
> ...     r = {}
> ...     def setn(self, n):
> ...             self.r["f"] = n
> ...>>> a = foo()
> >>> a.setn(4)
>
> >>> b = foo()
> >>> b.r
>
> {'f': 4}
>
> thanks,
>
> billy


class Foo:
def __init__(self):
self.r = {}
def setn(self,n):
self.r['f'] = n

a = Foo()
a.setn(3)
a.r
{'f': 3}
b = Foo()
b.r
{}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python class gotcha with scope?

2009-06-20 Thread Vincent
On Jun 21, 2:38 pm, Vincent  wrote:
> On Jun 21, 2:32 pm, billy  wrote:
>
>
>
> > I don't quite understand why this happens. Why doesn't b have its own
> > version of r? If r was just an int instead of a dict, then it would.
>
> > >>> class foo:
>
> > ...     r = {}
> > ...     def setn(self, n):
> > ...             self.r["f"] = n
> > ...>>> a = foo()
> > >>> a.setn(4)
>
> > >>> b = foo()
> > >>> b.r
>
> > {'f': 4}
>
> > thanks,
>
> > billy
>
> class Foo:
>     def __init__(self):
>         self.r = {}
>     def setn(self,n):
>         self.r['f'] = n
>
> a = Foo()
> a.setn(3)
> a.r
> {'f': 3}
> b = Foo()
> b.r
> {}

you defined r as class-level variable.
and i defined r as instance-level variable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: error when use libgmail with proxy

2009-06-22 Thread Vincent
On Jun 22, 3:33 pm, 马不停蹄的猪  wrote:
> Hi all,
> Does anybody use libgmail with proxy?  I met error here.
>
> Below is code snip:
>
> libgmail.PROXY_URL = G_PROXY # the proxy url
> self.ga = libgmail.GmailAccount(account,pwd)
> self.ga.login()
>
> Error information:
>   ga.login
> ()
> File "C:\Python25\Lib\site-packages\libgmail.py", line 305, in
> login
>  pageData = self._retrievePage
> (req)
> File "C:\Python25\Lib\site-packages\libgmail.py", line 348, in
> _retrievePage
>resp = self.opener.open
> (req)
> File "build\bdist.win32\egg\mechanize\_opener.py", line 191, in
> open
> File "C:\Python25\lib\urllib2.py", line 399, in
> _open
> '_open',
> req)
> File "C:\Python25\lib\urllib2.py", line 360, in
> _call_chain
> result = func
> (*args)
> File "build\bdist.win32\egg\mechanize\_http.py", line 751, in
> https_open
> AttributeError: 'int' object has no attribute
> 'find_key_cert'
>
> Is it possible the issue of mechanize?

I do not know why you need proxy.

i have used gdata do the same work like you.

then i descript it in my blog: vincent-w.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


problem about cx_Oracle

2009-07-15 Thread Vincent
hi, all:

i am using cx_oracle now.

i write code as below:

def __getfields_by_tbname(self,tbname):
cursor = self.ora_db.cursor()
print tbname
sql = 'select * from %s where rownum <=2' % tbname
print sql
cursor = cursor.execute(sql)
return self.getfields(cursor)

and i got a error, it's message is :
JRYZCFZB_X_ZQY
select * from JRYZCFZB_X_ZQY where rownum <=2
Traceback (most recent call last):
  File "", line 1, in 
  File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 107, in convert
    self.convert_table(tbname)
  File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 94, in convert_table
field_list = self.__getfields_by_tbname(tbname)
  File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
\data_convert.py", line 38, in __getfields_by_tbname
cursor = cursor.execute(sql)
TypeError: expecting None or a string

i'm sure the cursor instance is not None.
could anybody give me sussgestion? i will apreciate it.

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


Re: problem about cx_Oracle

2009-07-15 Thread Vincent
On Jul 16, 12:18 pm, Vincent  wrote:
> hi, all:
>
> i am using cx_oracle now.
>
> i write code as below:
>
> def __getfields_by_tbname(self,tbname):
>         cursor = self.ora_db.cursor()
>         print tbname
>         sql = 'select * from %s where rownum <=2' % tbname
>         print sql
>         cursor = cursor.execute(sql)
>         return self.getfields(cursor)
>
> and i got a error, it's message is :
> JRYZCFZB_X_ZQY
> select * from JRYZCFZB_X_ZQY where rownum <=2
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 107, in convert
>     self.convert_table(tbname)
>   File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 94, in convert_table
>     field_list = self.__getfields_by_tbname(tbname)
>   File "c:/vincent/wd/django/mysite/mysite\..\mysite\tools
> \data_convert.py", line 38, in __getfields_by_tbname
>     cursor = cursor.execute(sql)
> TypeError: expecting None or a string
>
> i'm sure the cursor instance is not None.
> could anybody give me sussgestion? i will apreciate it.
>
> vincent

i have the answer now.

the variant sql is unicode.

i neet to convert it to string.

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


? get negative from prod(x) when x is positive integers

2013-06-28 Thread Vincent Davis
I have a list of a list of integers. The lists are long so i cant really
show an actual example of on of the lists, but I know that they contain
only the integers 1,2,3,4. so for example.
s2 = [[1,2,2,3,2,1,4,4],[2,4,3,2,3,1]]

I am calculating the product, sum, max, min of each list in s2 but I
get negative or 0 for the product for a lot of the lists. (I am doing this
in ipython)

for x in s2:
print('len = ', len(x), 'sum = ', sum(x), 'prod = ', prod(x), 'max = ',
max(x), 'min = ', min(x))

...

('len = ', 100, 'sum = ', 247, 'prod = ', 0, 'max = ', 4, 'min = ', 1)
('len = ', 100, 'sum = ', 230, 'prod = ', -4611686018427387904, 'max =
', 4, 'min = ', 1)
('len = ', 100, 'sum = ', 261, 'prod = ', 0, 'max = ', 4, 'min = ', 1)

.

('prod =', 0, 'max =', 4, 'min =', 1)
('prod =', 1729382256910270464, 'max =', 4, 'min =', 1)
('prod =', 0, 'max =', 4, 'min =', 1)




Whats going on?



Vincent Davis
720-301-3003
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ? get negative from prod(x) when x is positive integers

2013-06-28 Thread Vincent Davis
@Joshua
"You are using numpy.prod()"
Wow, since sum([1,2,3,4]) worked I tried prod([1,2,3,4]) and got the right
answer so I just used that. Confusing that it would use numpy.prod(), I
realize now there is no python prod(). At no point do I "import numpy" in
my code. The seems to be a result of using ipython, or at least how I am
using it "ipython notebook --pylab inline".

Thanks

Vincent Davis
720-301-3003


On Fri, Jun 28, 2013 at 4:04 PM, Joshua Landau
wrote:

> On 28 June 2013 15:38, Vincent Davis  wrote:
> > I have a list of a list of integers. The lists are long so i cant really
> > show an actual example of on of the lists, but I know that they contain
> only
> > the integers 1,2,3,4. so for example.
> > s2 = [[1,2,2,3,2,1,4,4],[2,4,3,2,3,1]]
> >
> > I am calculating the product, sum, max, min of each list in s2 but I
> get
> > negative or 0 for the product for a lot of the lists. (I am doing this in
> > ipython)
> >
> > for x in s2:
> > print('len = ', len(x), 'sum = ', sum(x), 'prod = ', prod(x), 'max =
> ',
> > max(x), 'min = ', min(x))
> >
> > ...
> >
> > ('len = ', 100, 'sum = ', 247, 'prod = ', 0, 'max = ', 4, 'min = ', 1)
> > ('len = ', 100, 'sum = ', 230, 'prod = ', -4611686018427387904, 'max =
> ', 4,
> > 'min = ', 1)
> > ('len = ', 100, 'sum = ', 261, 'prod = ', 0, 'max = ', 4, 'min = ', 1)
> >
> > .
> >
> > ('prod =', 0, 'max =', 4, 'min =', 1)
> > ('prod =', 1729382256910270464, 'max =', 4, 'min =', 1)
> > ('prod =', 0, 'max =', 4, 'min =', 1)
> >
> > 
> >
> >
> > Whats going on?
>
> Let me guess.
> These are your lists (sorted):
>
> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
> 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> 4, 4, 4, 4, 4, 4, 4, 4]
>
> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> 4, 4, 4, 4, 4, 4, 4, 4]
>
> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
> 4, 4, 4, 4, 4, 4, 4, 4]
>
> You are using numpy.prod()
>
> Numpy.prod overflows:
>
> >>> numpy.prod([-9223372036854775808, 2])
> ... 0
>
> You want to use something that doesn't such as:
>
> def prod(iter):
> p = 1
> for elem in iter:
> p *= elem
> return p
>
> and then you get your correct products:
>
> 8002414661101704746694488837062656
> 3907429033741066770846918377472
> 682872717747345471717929714096013312
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Segfault when setting an instance property on 2.7.3

2012-08-25 Thread Vincent Pelletier
Hi.

(please keep me in CC for replies, I'm not subscribed)

I wrote a ctypes-(wait, read on)-based binding[1] for libusb1, in which I'm 
triggering a segfault from an application[2] I wrote.

I've been through several segfault caused by ctypes mis-usage, this one seems 
different enough. I think there is something else (maybe ultimately caused by 
some ctypes effect, but I don't see the relation yet).

The Python line causing the segfault:
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L192

C stack at segfault (with -dbg package installed):
http://pastebin.com/rVUPsSrU

#0
(gdb) print *op
$1 = {ob_refcnt = -4247522206314328575, ob_type = 0xcf0dc50ec50dc50e}
(gdb) up
#1
(gdb) print *obj
$2 = {ob_refcnt = 6, ob_type = 0x9c5f70}
(gdb) print obj
$3 = 

The program using python-libusb1 which triggers the segfault:
https://github.com/vpelletier/ITI1480A-linux/blob/master/iti1480a/capture.py
The event loop is at the bottom: allocate USB transfers, submit them, loop on 
libusb1 event handling until there is no more submitted transfer, libusb uses 
callback which resubmits transfer, ...

ctypes possible segfault causes checklist:
- callback is cast into a ctype CFUNCTYPE type instance
  See:
https://github.com/vpelletier/python-libusb1/blob/master/libusb1.py#L587
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L133
- a strong ref to it is kept on USBTransfer instance so it is not GC'ed
  See:
https://github.com/vpelletier/python-libusb1/blob/master/usb1.py#L808
- application is single-threaded (libusb1 doesn't create any C thread either)
  so even if there were missing GIL acquisitions, it shouldn't be a problem
  Also, a strong ref to USBTransfer is kept on USBDeviceHandle instance. When
  an USBDeviceHandle is GC'ed, it cancels any pending transfer, waits for
  completion (=libusb1 callback is executed) and then allow them to be GC'ed.
- we are not accessing unallocated memory in this traceback (although it could
  be that memory got overwritten somehow)

I couldn't trigger the bug while under valgrind (which reported some 
"Conditional jump or move depends on uninitialized value(s)" & "Use of 
uninitialized value of size 8" in PyObject_Free, but reading the code I guess 
they are harmless and unrelated).

Any idea of ways to debug this problem further ?

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


Re: Segfault when setting an instance property on 2.7.3

2012-08-26 Thread Vincent Pelletier
Le samedi 25 août 2012 11:38:47, Vincent Pelletier a écrit :
> Any idea of ways to debug this problem further ?

Trying with pypy ("just to see"), I got even more reproductible segfaults - 
even with valgrind.

Turns out, I was not keeping strong references to ctypes buffers, which get 
very quickly collected with pypy and memory reused for something else, leading 
to a quick crash.

Now, I don't get yet why cpython was not crashing more often, even if I forced 
gc.collect() . Less memory recycling maybe ?

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


Understanding and dealing with an exception

2012-10-13 Thread Vincent Davis
I am working on a script to find bad image files. I am using PIL
and specifically image.verify() I have a set of known to be bad image files
to test. I also what to be able to test any file for example a .txt and
deal with the exception.
Currently my code is basically

try:
im = Image.open(ifile)
try:
print(im.verify())
except:
print('Pil image.verify() failed: ' + afile)
except IOError:
print('PIL cannot identify image file: ' + afile)
except:
print(ifile)
print("Unexpected error doing PIL.Image.open():", sys.exc_info()[0])
raise

I have a lot of file that have an IOError.  I would expect this error for
any non image file.
I have yet to have image.verify() All failures have been IOError.

Then I got this error (below). Which to me to me is a bug in PIL?
The file seems ok when I open it for editing in an external editor.

So my question, I don't what to raise this exception thereby stoping the
script nor record the image as bad or good. This would possibly lead to
false positives or negatives.
Then again I assume it would be possible to get this error because the file
is corrupt.
I am not really sure how to deal with this. Any advise.

fixed-width.psd
('Unexpected error doing PIL.Image.open():', )



OverflowError: Python int too large to convert to C long
File "/Volumes/Hafnium/Google Drive/bad images/untitled-2.py", line 21, in

  im = Image.open(ifile)
File
"/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/PIL/Image.py",
line 1965, in open
  return factory(fp, filename)
File
"/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/PIL/ImageFile.py",
line 91, in __init__
  self._open()
File
"/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/PIL/PsdImagePlugin.py",
line 123, in _open
  self.layers = _layerinfo(self.fp)
File
"/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/PIL/PsdImagePlugin.py",
line 230, in _layerinfo
  t = _maketile(file, m, bbox, 1)
File
"/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/PIL/PsdImagePlugin.py",
line 266, in _maketile
  bytecount = read(channels * ysize * 2)

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


Re: Understanding and dealing with an exception

2012-10-13 Thread Vincent Davis
Oops, I was going to make note of the file size. 1.2MB

Vincent



On Sat, Oct 13, 2012 at 10:31 PM, Chris Angelico  wrote:

> On Sun, Oct 14, 2012 at 3:23 PM, Vincent Davis 
> wrote:
> > OverflowError: Python int too large to convert to C long
> > line 266, in _maketile
> >   bytecount = read(channels * ysize * 2)
>
> Is the file over 2GB? Might be a limitation, more than a bug, and one
> that could possibly be raised by using a 64-bit build.
>
> Alternatively, you could deem them invalid for exceeding your file
> size limit (either before passing to PIL, or on catching this
> exception).
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding and dealing with an exception

2012-10-13 Thread Vincent Davis
I can open it is and all looks good using Pixelmator (I don't have
Photoshop installed). I don't think there is anything wrong with the image.

Part of my question is a result of being new to actually using exceptions
in my programs and dealing with the exceptions is a primary part of what I
need to do with this program. When I get an exception that seems to be an
issue with PIL (i.e. not my program or a problem with the image) I am not
sure what the "right" or conventional way to deal with it is.

Vincent


On Sat, Oct 13, 2012 at 10:49 PM, Chris Angelico  wrote:

> On Sun, Oct 14, 2012 at 3:36 PM, Vincent Davis 
> wrote:
> > Oops, I was going to make note of the file size. 1.2MB
>
> Then I'd definitely declare the file bad; I don't know what the valid
> ranges for channels and ysize are, but my reading of that is that your
> file's completely corrupt, maybe even malicious. PIL probably ought to
> check these things, so there may be a tracker issue coming from this,
> but I'd be inclined to declare any thrown exception as meaning it's a
> bad file. Call it "failed a security check" perhaps.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding and dealing with an exception

2012-10-14 Thread Vincent Davis
Yes afile is the file name and extension, ifile is the full file name and
path.

Thanks
Vincent

On Sunday, October 14, 2012, MRAB wrote:

> On 2012-10-14 05:23, Vincent Davis wrote:
>
>> I am working on a script to find bad image files. I am using PIL
>> and specifically image.verify() I have a set of known to be bad image
>> files to test. I also what to be able to test any file for example a
>> .txt and deal with the exception.
>> Currently my code is basically
>>
>> try:
>>  im = Image.open(ifile)
>>  try:
>>  print(im.verify())
>>  except:
>>  print('Pil image.verify() failed: ' + afile)
>> except IOError:
>>  print('PIL cannot identify image file: ' + afile)
>> except:
>>  print(ifile)
>>  print("Unexpected error doing PIL.Image.open():", sys.exc_info()[0])
>>  raise
>>
>>  [snip]
> I notice that you have both "ifile" and "afile". Is that correct?
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>


-- 
Vincent Davis
720-301-3003
-- 
http://mail.python.org/mailman/listinfo/python-list


get each pair from a string.

2012-10-21 Thread Vincent Davis
I am looking for a good way to get every pair from a string. For example,
input:
x = 'apple'
output
'ap'
'pp'
'pl'
'le'

I am not seeing a obvious way to do this without multiple for loops, but
maybe there is not :-)
In the end I am going to what to get triples, quads... also.

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


Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
@Emile,
I feel a little stupid, in my mind it was more difficult than in reality.

x = 'apple'
for f in range(len(x)-1):
print(x[f:f+2])

@Ian,
Thanks for that I was just looking in to that. I wonder which is faster I
have a large set of strings to process. I'll try some timings if I get a
chance later today.


Thanks again!
Vincent




On Mon, Oct 22, 2012 at 12:45 AM, Emile van Sebille  wrote:

> On 10/21/2012 11:33 AM, Vincent Davis wrote:
>
>> I am looking for a good way to get every pair from a string. For example,
>> input:
>> x = 'apple'
>> output
>> 'ap'
>> 'pp'
>> 'pl'
>> 'le'
>>
>> I am not seeing a obvious way to do this without multiple for loops, but
>> maybe there is not :-)
>> In the end I am going to what to get triples, quads... also.
>>
>>
> How far have you gotten?  Show us the loops you're trying now and any
> errors you're getting.
>
> Emile
>
>
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
@vbr
Thats interesting. I would never have come up with that.

Vincent



On Sun, Oct 21, 2012 at 3:48 PM, Vlastimil Brom wrote:

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


Re: get each pair from a string.

2012-10-21 Thread Vincent Davis
To All,
I appreciate the range of answers and the time each of you take to think
about and answer my question. Whether or not I use them I find them all
educational.
Thanks again.

Vincent



On Mon, Oct 22, 2012 at 2:03 AM, Emile van Sebille  wrote:

> On 10/21/2012 12:06 PM, Ian Kelly wrote:
>
>> On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis
>>  wrote:
>>
>>> x = 'apple'
>>> for f in range(len(x)-1):
>>>  print(x[f:f+2])
>>>
>>> @Ian,
>>> Thanks for that I was just looking in to that. I wonder which is faster I
>>> have a large set of strings to process. I'll try some timings if I get a
>>> chance later today.
>>>
>>
>> The solution you came up with is probably faster, but less general --
>> it will only work on sliceable sequences like strings, not arbitrary
>> iterables.
>>
>>
> So the simple loop is the right answer for sliceable sequences like
> strings, but not if your code needs to deal with arbitrary iterables such
> as those that the standard library authors are expected to handle.
>
> So, as OP's a self confessed newbie asking about slicing, why provide an
> example requiring knowledge of tee, enumerate, next and izip?
>
>
> def nwise(iterable, n=2):
> iters = tee(iterable, n)
> for i, it in enumerate(iters):
> for _ in range(i):
> next(it, None)
> return izip(*iters)
>
> It's good that the standard library provides these tools as a convenience,
> but when all you need is a derringer, why reach for a howitzer?
>
> Emile
>
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Check email header for RFC 822 standard and match emails between imap servers.

2011-08-18 Thread Vincent Davis
The sort story, I have been attempting to use the Google Migration assistant
to migrate emails from one google account to another, about 80,000 emails.
I have two problems.
1. Many emails that fail to transfer because of errors like "Invalid RFC 822
Message: Date header "Mon Feb 05 22:07:16 2007" is invalid." See
full error below.
 emails that.
2. I need to delete the emails from the old account that have been
transferred.

And the Two question are:
1:
I am able to connect and get an email. But I am not clear how I would check
that the header is valid or identify the problem.
grl = imaplib.IMAP4_SSL('imap.gmail.com', 993)
grl.login('n...@domain.com', 'password')
grl.fetch(17006, 'uid')
# So now I have an email how do I check the header, I know how to view it
but not check it for RFC 822.

2:
Since I don't know which emails have been transferred I want to delete all
the email that have. To be more correct I don't know which ones on the old
account, when they are moved to the new account they get the label as
transferred. How should I compare emails? The uid is different on each
server so I think using the TO: FROM: and DATE: TIME: would work.
How do I compare emails in this way?
How to I get the TO: FROM: DATE: TIME: from one email to reach for the same
email in the other account.


Sample error from google migration app.

2011-08-16T16:47:47.141-06:00  808 E:Network
ExchangeMigration!WinHttp::ExecuteHttpRequestIStreamResponse @ 696 (
gmetan...@domain.com )> Response:

Invalid RFC 822 Message: Date header "Mon Feb 05 22:07:16 2007" is
invalid.

2011-08-16T16:47:47.141-06:00  808 E:Migration
ExchangeMigration!EmailUploader::HandleStatus @ 462
(gmetan...@domain.com)>
Permanent Message Failure, skipping the message!.

2011-08-16T16:47:47.328-06:00  808 E:Migration
ExchangeMigration!IMAPMessageWrapper::GetMessageSentTime @ 154 (
gmetan...@domain.com )> Failed with 0x80004005, last
successful line = 151.

2011-08-16T16:47:47.328-06:00  808 E:Migration
ExchangeMigration!IMAPMessageWrapper::GetMessageReceivedTime @ 170 (
gmetan...@domain.com )> Failed with 0x80004001, last
successful line = 168.

2011-08-16T16:47:47.328-06:00  808 E:Migration
ExchangeMigration!GetMessageDescription @ 198
(gmetan...@domain.com)>
Sent: 2011-08-16T22:47:47.000Z. Received: 2011-08-16T22:47:47.000Z. Size:
196114. Subject RE: ppt templates.


-- 
Thanks
Vincent Davis
720-301-3003
-- 
http://mail.python.org/mailman/listinfo/python-list


questions about multiprocessing

2011-03-04 Thread Vincent Ren
Hello, everyone, recently I am trying to learn python's
multiprocessing, but
I got confused as a beginner.

If I run the code below:

from multiprocessing import Pool
import urllib2
otasks = [
 'http://www.php.net'
 'http://www.python.org'
 'http://www.perl.org'
 'http://www.gnu.org'
 ]

def f(url):
 return urllib2.urlopen(url).read()

pool = Pool(processes = 2)
print pool.map(f, tasks)


I'll receive this message:

Traceback (most recent call last):
   File "", line 14, in 
   File "/usr/lib/python2.6/multiprocessing/pool.py", line 148, in map
 return self.map_async(func, iterable, chunksize).get()
   File "/usr/lib/python2.6/multiprocessing/pool.py", line 422, in get
 raise self._value
httplib.InvalidURL: nonnumeric port: ''



I run Python 2.6 on Ubuntu 10.10


Regards
Vincent


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


Re: questions about multiprocessing

2011-03-05 Thread Vincent Ren
Got it.
After putting commas, it works (The 'o' was a mistake when I posted,
sorry about it ).

Thanks to all of you :)


On Mar 5, 5:12 pm, Dennis Lee Bieber  wrote:
> On Fri, 4 Mar 2011 20:08:21 -0800 (PST), Vincent Ren
>  declaimed the following in
> gmane.comp.python.general:
>
> > Hello, everyone, recently I am trying to learn python's
> > multiprocessing, but
> > I got confused as a beginner.
>
> > If I run the code below:
>
> > from multiprocessing import Pool
> > import urllib2
> > otasks = [
> >      'http://www.php.net'
> >      'http://www.python.org'
> >      'http://www.perl.org'
> >      'http://www.gnu.org'
> >      ]
>
>         You've just defined a list with ONE element -- a string of:
>
> "http://www.php.nethttp://www.python.orghttp://www.perl.orghttp://http...";
>
>         Python concatenates adjacent strings -- which includes those on
> multiple lines when inside an open ( [ { structure.
>
>         You need to put commas after the closing quotes on those lines.
>
> > def f(url):
> >      return urllib2.urlopen(url).read()
>
> > pool = Pool(processes = 2)
> > print pool.map(f, tasks)
>
>         And I'm presuming the others are correct -- and that should be
>
> (f, otasks)
>
> > httplib.InvalidURL: nonnumeric port: ''
>
>         No surprise... URL nomenclature expects a port number after the
> second : in URL, and with concatenation you've got four : in a single
> URL.
> --
>         Wulfraed                 Dennis Lee Bieber         AF6VN
>         wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Re: questions about multiprocessing

2011-03-06 Thread Vincent Ren
I've got some new problems and I tried to search on Google but got no
useful information.


I want to download some images with multiprocessing.pool
In my class named Renren, I defined two methods:

def getPotrait(self, url):
# get the current potraits of a friend on Renren.com
try:
r = urllib2.urlopen(url)
except urllib2.URLError:
print "Time out"

tmp = re.search('large_[\d\D]*.jpg', url)
image_name = tmp.group()

img = r.read()
output = open(image_name, 'wb')
output.write(img)
output.close()

def getLargePotraits(self):

tasks = self.makeTaskList()
pool = Pool(processes = 3)
pool.map(self.getPotrait, tasks)


tasks is a list of URLs of images, I want to download these images and
save them locally.

In another python file, I wrote this:

   from renren import Renren

   # get username and password for RenRen.com
   username = raw_input('Email: ')
   password = raw_input('Password: ')
   print


   a = Renren(username, password)
   a.login()
   a.getLargePotraits()



However, when I try to run this file, I received an error message:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in
__bootstrap_inner
self.run()
  File "/usr/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.6/multiprocessing/pool.py", line 225, in
_handle_tasks
put(task)
PicklingError: Can't pickle : attribute lookup
__builtin__.instancemethod failed


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


Re: questions about multiprocessing

2011-03-07 Thread Vincent Ren
On Mar 7, 9:21 pm, Jean-Michel Pichavant 
wrote:

> It's a mistake many beginners do, I don't understand why, but it's a
> very common thing. RTFM should stand for "Read The Formidable (error)
> Message" as  well.
> Your url is invalid, check your url definition.
>
> JM

I've fixed that problem. But I got a new one

  PicklingError: Can't pickle : attribute
lookup
  __builtin__.instancemethod failed

The details were listed in my last post in this thread.
Thanks for your reply :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: questions about multiprocessing

2011-03-07 Thread Vincent Ren
Got it, thanks.
But what should I do if I want to improve the efficiency of my
program?

On Mar 8, 11:37 am, Robert Kern  wrote:

> I'm afraid his response applies to this as well: you can't pass methods to
> pool.map() or any other such communication channel to your subprocesses.


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


Re: questions about multiprocessing

2011-03-07 Thread Vincent Ren
I'm just learning python. After changed it to a non-OOP program, it
works.
Thank you all for suggestions :)

On Mar 8, 1:38 pm, Benjamin Kaplan  wrote:

> Is there any particular reason you're using processes and not threads?
> Functions that wait for stuff to happen in C land, such as I/O calls,
> release the GIL so threads can be run in parallel. It's only stuff
> that happens in Python land (i.e. manipulating Python objects) that
> can't be run concurrently.

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


A problem about ipython

2011-03-31 Thread Vincent Ren
Hey, everyone, I'm trying to use ipython recently. It's very nice,
however, when I run this(from Programming Python 3rd) in ipython, I'll
get a NameError:


In [1]: import settime, timer, set

In [2]: import profile

In [3]: profile.run('timer.test(100, settime.setops, set.Set)')
---
NameError Traceback (most recent call
last)

/home/vincent/hacking/python/ in ()

/usr/lib/python2.6/profile.pyc in run(statement, filename, sort)
 68 prof = Profile()
 69 try:
---> 70 prof = prof.run(statement)
 71 except SystemExit:
 72 pass

/usr/lib/python2.6/profile.pyc in run(self, cmd)
454 import __main__
455 dict = __main__.__dict__
--> 456 return self.runctx(cmd, dict, dict)
457
458 def runctx(self, cmd, globals, locals):

/usr/lib/python2.6/profile.pyc in runctx(self, cmd, globals, locals)
460 sys.setprofile(self.dispatcher)
461 try:
--> 462 exec cmd in globals, locals
463 finally:
464 sys.setprofile(None)

/usr/lib/pymodules/python2.6/IPython/FakeModule.pyc in ()

NameError: name 'timer' is not defined



But when I use normal python shell, it works well

>>> import settime, timer, set
>>> import profile
>>> profile.run('timer.test(100, settime.setops, set.Set)')
^P^P 675906 function calls in 16.961 CPU seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall
filename:lineno(function)
   1185001.1440.0001.1440.000 :0(append)
20.0000.0000.0000.000 :0(clock)
  5000.0080.0000.0080.000 :0(range)
10.0040.0040.0040.004 :0(setprofile)
10.0000.000   16.957   16.957 :1()
00.000 0.000  profile:0(profiler)
10.0000.000   16.961   16.961 profile:
0(timer.test(100, settime.setops, set.Set))
 15000.3800.0002.5040.002 set.py:13(union)
 34000.0760.0002.6320.001 set.py:2(__init__)
 34001.6200.0002.5560.001 set.py:20(concat)
   5440005.9400.0005.9400.000 set.py:26(__getitem__)
 15000.0600.000   14.0410.009 set.py:27(__and__)
 15000.0600.0002.5640.002 set.py:28(__or__)
 15007.5640.005   13.9810.009 set.py:6(intersect)
  1000.1000.001   16.9530.170 settime.py:4(setops)
10.0040.004   16.957   16.957 timer.py:1(test)



What's going wrong here?


Regards
Wenshan Ren
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A problem about ipython

2011-04-02 Thread Vincent Ren
On Apr 1, 7:11 pm, "eryksun ()"  wrote:

> Try this instead:
>
> profile.runctx('timer.test(100, settime.setops, set.Set)', globals=globals(), 
> locals=locals())


It works! Thanks a lot
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A problem about ipython

2011-04-02 Thread Vincent Ren
On Apr 2, 1:16 am, Robert Kern  wrote:
>
> In order to support pickling and its %run feature, IPython makes a fake 
> __main__
> module. It looks like profile.run() explicitly imports __main__ to try to run
> the statement there. Honestly, it's been a thorn in our side for a long time,
> but it's a confusing bit of the code. Most interactive shells actually written
> in Python are going to have a similar need to do a workaround, since they
> already have a __main__. The regular shell is not written in Python, so it has
> no problem.
>
> You will want to ask on the IPython list for future IPython questions.
>
>    http://mail.scipy.org/mailman/listinfo/ipython-user
>
> --
> 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

Quite nice explanation and very useful link, thanks :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Standard config file format

2011-04-05 Thread Vincent Davis
I am working on a program to monitor directory file changes and am would
like a configuration file. This file would specify email addresses, file and
directory locations.. Is there a preferred format to use with python?
-- 
Thanks
Vincent Davis
-- 
http://mail.python.org/mailman/listinfo/python-list


set a breakpoint in malloc_error_break to debug?

2011-04-06 Thread Vincent Davis
Not sure what is going on here. the set "wset" is large I am sure but ... Is
this something I am going wrong?

def walked_dir(adir):
wdirset = set()
for dirpath, dirnames, filenames in os.walk(adir):
for name in filenames:
if isfile(dirpath+'/'+name):
fullfilename = dirpath+'/'+name
the_stats = stat(fullfilename)
wdirset.add((dirpath, tuple(dirnames), tuple(filenames),
fullfilename, name, the_stats))
if not len(filenames):
wdirset.add((dirpath, tuple(dirnames), tuple(filenames), None,
None, None))
return wdirset

directory = '/Users/vmd/Dropbox'
wset = walked_dir(directory)


>>> wset
Python(19914) malloc: *** mmap(size=1536290816) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Python(19914) malloc: *** mmap(size=1536290816) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Python(19914) malloc: *** mmap(size=1536290816) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Traceback (most recent call last):
  File "", line 1, in 
MemoryError:
>>>

Python 2.7.1 |EPD 7.0-2 (32-bit)| (r271:86832, Dec  3 2010, 15:41:32)
[GCC 4.0.1 (Apple Inc. build 5488)]

-- 
Thanks
Vincent Davis
720-301-3003
-- 
http://mail.python.org/mailman/listinfo/python-list


plot / graph connecting re ordered lists

2018-01-23 Thread Vincent Davis
Looking for suggestions. I have an ordered list of names these names will
be reordered. I am looking to make a plot, graph, with the two origins of
the names in separate columns and a line connecting them to visually
represent how much they have moved in the reordering.
Surely there is some great example code for this on the net an am not
finding a clean example.

Thanks
Vincent Davis
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: plot / graph connecting re ordered lists

2018-01-23 Thread Vincent Davis
On Tue, Jan 23, 2018 at 4:15 PM Dennis Lee Bieber 
wrote:

> On Tue, 23 Jan 2018 13:51:55 -0700, Vincent Davis
>  declaimed the following:
>
> >Looking for suggestions. I have an ordered list of names these names will
> >be reordered. I am looking to make a plot, graph, with the two origins of
>
> IE: you have two lists with the same items in different orders...
>
> >the names in separate columns and a line connecting them to visually
> >represent how much they have moved in the reordering.
> >Surely there is some great example code for this on the net an am not
> >finding a clean example.
> >
>
> Determine positions:
>
> pos = []
> for p, name in enumerate(first_list):
> np = second_list.index(name)
> pos.append( (name, p, np) )
>
> for (name, p, np) in pos:
> draw_line((1,p) , (2, np))
> label( (1, p), name)
>
> Exact details of graphics package and scaling left as an exercise


Actualy, it’s recomendations for a graphing package And an example using it
for such a graph that I am most interested in. I know how to relate the
names on the 2 lists.


> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Sent from mobile app. Vincent Davis 720-301-3003
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question - problem downloading Python

2021-01-14 Thread vincent . vandevyvre
On 14/01/21 07:52, Christine Tiscareno wrote:
>I installed in my lap-top your latest version of Python (3.9.1), yet when I
>go to cmd.exe   to check,  I get that I have Python 22.7.17 ???
>
>Why? What should I do to get the latest version?

>  I tried going back to fix problems and it does not fix it, that is how I
>got your email.

>How can I get the latest Python version (3.9.1), instead of what I'm
>getting (22.7.17)?

>Thank you for your time.

Please, copy-paste all the content of your terminal (I presume this is wht you 
name cmd.exe).

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


Re: clusters of numbers

2018-12-15 Thread Vincent Davis
Why not start with a histogram.

Vincent

On Sat, Dec 15, 2018 at 6:46 PM Marc Lucke  wrote:

> hey guys,
>
> I have a hobby project that sorts my email automatically for me & I want
> to improve it.  There's data science and statistical info that I'm
> missing, & I always enjoy reading about the pythonic way to do things too.
>
> I have a list of percentage scores:
>
>
> (1,11,1,7,5,7,2,2,2,10,10,1,2,2,1,7,2,1,7,5,3,8,2,6,3,2,7,2,12,3,1,2,19,3,5,1,1,7,8,8,1,5,6,7,3,14,6,1,6,7,6,15,6,3,7,2,6,23,2,7,1,21,21,8,8,3,2,20,1,3,12,3,1,2,10,16,16,15,6,5,3,2,2,11,1,14,6,3,7,1,5,3,3,14,3,7,3,5,8,3,6,17,1,1,7,3,1,2,6,1,7,7,12,6,6,2,1,6,3,6,2,1,5,1,8,10,2,6,1,7,3,5,7,7,5,7,2,5,1,19,19,1,12,5,10,2,19,1,3,19,6,1,5,11,2,1,2,5,2,5,8,2,2,2,5,3,1,21,2,3,7,10,1,8,1,3,17,17,1,5,3,10,14,1,2,14,14,1,15,6,3,2,17,17,1,1,1,2,2,3,3,2,2,7,7,2,1,2,8,2,20,3,2,3,12,7,6,5,12,2,3,11,3,1,1,8,16,10,1,6,6,6,11,1,6,5,2,5,11,1,2,10,6,14,6,3,3,5,2,6,17,15,1,2,2,17,5,3,3,5,8,1,6,3,14,3,2,1,7,2,8,11,5,14,3,19,1,3,7,3,3,8,8,6,1,3,1,14,14,10,3,2,1,12,2,3,1,2,2,6,6,7,10,10,12,24,1,21,21,5,11,12,12,2,1,19,8,6,2,1,1,19,10,6,2,15,15,7,10,14,12,14,5,11,7,12,2,1,14,10,7,10,3,17,25,10,5,5,3,12,5,2,14,5,8,1,11,5,29,2,7,20,12,14,1,10,6,17,16,6,7,11,12,3,1,23,11,10,11,5,10,6,2,17,15,20,5,10,1,17,3,7,15,5,11,6,19,14,15,7,1,2,17,8,15,10,26,6,1,2,10,6,14,12,6,1,16,6,12,10,10,14,1,6,1,6,6,12,6,6,1,2,5,10
 
,8,10,1,6,8,17,11,6,3,6,5,1,2,1,2,6,6,12,14,7,1,7,1,8,2,3,14,11,6,3,11,3,1,6,17,12,8,2,10,3,12,12,2,7,5,5,17,2,5,10,12,21,15,6,10,10,7,15,11,2,7,10,3,1,2,7,10,15,1,1,6,5,5,3,17,19,7,1,15,2,8,7,1,6,2,1,15,19,7,15,1,8,3,3,20,8,1,11,7,8,7,1,12,11,1,10,17,2,23,3,7,20,20,3,11,5,1,1,8,1,6,2,11,1,5,1,10,7,20,17,8,1,2,10,6,2,1,23,11,11,7,2,21,5,5,8,1,1,10,12,15,2,1,10,5,2,2,5,1,2,11,10,1,8,10,12,2,12,2,8,6,19,15,8,2,16,7,5,14,2,1,3,3,10,16,20,5,8,14,8,3,14,2,1,5,16,16,2,10,8,17,17,10,10,11,3,5,1,17,17,3,17,5,6,7,7,12,19,15,20,11,10,2,6,6,5,5,1,16,16,8,7,2,1,3,5,20,20,6,7,5,23,14,3,10,2,2,7,10,10,3,5,5,8,14,11,14,14,11,19,5,5,2,12,25,5,2,11,8,10,5,11,10,12,10,2,15,15,15,5,10,1,12,14,8,5,6,2,26,15,21,15,12,2,8,11,5,5,16,5,2,17,3,2,2,3,15,3,8,10,7,10,3,1,14,14,8,8,8,19,10,12,3,8,2,20,16,10,6,15,6,1,12,12,15,15,8,11,17,7,7,7,3,10,1,5,19,11,7,12,8,12,7,5,10,1,11,1,6,21,1,1,10,3,8,5,6,5,20,25,17,5,2,16,14,11,1,17,10,14,5,16,5,2,7,3,8,17,7,19,12,6,5,1,3,12,43,11,8,11,5,19,10,5,11,7,20,6,12,35,5,3,
 
17,10,2,12,6,5,21,24,15,5,10,3,15,1,12,6,3,17,3,2,3,5,5,14,11,8,1,8,10,5,25,8,7,2,6,3,11,1,11,7,3,10,7,12,10,8,6,1,1,17,3,1,1,2,19,6,10,2,2,7,5,16,3,2,11,10,7,10,21,3,5,2,21,3,14,6,7,2,24,3,17,3,21,8,5,11,17,5,6,10,5,20,1,12,2,3,20,6,11,12,14,6,6,1,14,15,12,15,6,20,7,7,19,3,7,5,16,12,6,7,2,10,3,2,11,8,6,6,5,1,11,1,15,21,14,6,3,2,2,5,6,1,3,5,3,6,20,1,15,12,2,3,3,7,1,16,5,24,10,7,1,12,16,8,26,16,15,10,19,11,6,6,5,6,5)
>
>   & I'd like to know know whether, & how the numbers are clustered.  In
> an extreme & illustrative example, 1..10 would have zero clusters;
> 1,1,1,2,2,2,7,7,7 would have 3 clusters (around 1,2 & 7);
> 17,22,20,45,47,51,82,84,83  would have 3 clusters. (around 20, 47 &
> 83).  In my set, when I scan it, I intuitively figure there's lots of
> numbers close to 0 & a lot close to 20 (or there abouts).
>
> I saw info about k-clusters but I'm not sure if I'm going down the right
> path.  I'm interested in k-clusters & will teach myself, but my priority
> is working out this problem.
>
> Do you know the name of the algorithm I'm trying to use?  If so, are
> there python libraries like numpy that I can leverage?  I imagine that I
> could iterate from 0 to 100% using that as an artificial mean, discard
> values that are over a standard deviation away, and count the number of
> scores for that mean; then at the end of that I could set a threshold
> for which the artificial mean would be kept something like (no attempt
> at correct syntax:
>
> means={}
> deviation=5
> threshold=int(0.25*len(list))
> for i in range 100:
>count=0
>for j in list:
>  if abs(j-i) > deviation:
>count+=1
>if count > threshold:
>  means[i]=count
>
> That algorithm is entirely untested & I think it could work, it's just I
> don't want to reinvent the wheel.  Any ideas kindly appreciated.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Won't Uninstall

2019-09-20 Thread Fred Vincent
Python 3.7.4 won’t uninstall, I have tried doing what I can such as going to 
the control panel and uninstalling the program there, but that did not work. 
Since I am unable to delete it I am unable to download a different version of 
python. How do I fix this and fully uninstall python?

Sent from Mail for Windows 10

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


Convert and analyze image data in a spreadsheet.

2020-06-11 Thread Vincent Davis
Looking for a little advise.
I have 6x6 color (CIELAB <https://en.wikipedia.org/wiki/CIELAB_color_space>)
data in a spreadsheet (color samples of clothing). I would like to
visualize this as an image on a per channel (l,a,b) and as a color image. I
can read the data from the spreadsheet. I am not sure the path a should
choose from there. I think the path is to read this data into a numpy array
and use scikit-image.

Questions:
1. I am not sure how to get the 3 color measurements into a color image
pixel.
2. I only kinda understand color spaces, this data is in CIELAB, do I want
to keep it in that color format? I think yes.
3. How can I visualize this data as a 6x6 color image and visualize each
color on a gray scale.
4. General hints or link of how to proceed would be helpful.

Thanks
Vincent Davis
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert and analyze image data in a spreadsheet.

2020-06-14 Thread Vincent Davis
Dennis,
Thanks for your ideas. The researcher I am working with just told me the
data is wrong and needs to send me new data and there are other problems
with exactly what their research questions is. So this goes nowhere for now.

Thanks
Vincent Davis
720-301-3003
*Want to get a hold of me?*


*SMS: awesome.phone: ok...*
*email: bad!*


On Thu, Jun 11, 2020 at 1:17 PM Dennis Lee Bieber 
wrote:

>
> My previous response hasn't made it through the
> gmane<>list<>usenet<>back cycle so I can't "talk to myself"...
>
> On Thu, 11 Jun 2020 07:44:25 -0600, Vincent Davis
>  declaimed the following:
>
> >Looking for a little advise.
> >I have 6x6 color (CIELAB <
> https://en.wikipedia.org/wiki/CIELAB_color_space>)
> >data in a spreadsheet (color samples of clothing). I would like to
> >visualize this as an image on a per channel (l,a,b) and as a color image.
> I
> >can read the data from the spreadsheet. I am not sure the path a should
> >choose from there. I think the path is to read this data into a numpy
> array
> >and use scikit-image.
> >
>
> I'm going to speak blasphemy and mention the R statistics package.
> It
> has
>
> https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/convertColor.html
> which includes L*a*b* as a color space. Though it does not seem to have
> Adobe RGB...
> """
> "XYZ", "sRGB", "Apple RGB", "CIE RGB", "Lab", "Luv".
> """
>
> Also links to the main page of a source of the math used in
> converting
>
> It also mentions something that wasn't obvious in other references:
> """
> The Lab and Luv spaces describe colors of objects, and so require the
> specification of a reference ‘white light’ color. Illuminant D65 is a
> standard indirect daylight, Illuminant D50 is close to direct sunlight, and
> Illuminant A is the light from a standard incandescent bulb. Other standard
> CIE illuminants supported are B, C, E and D55. RGB colour spaces are
> defined relative to a particular reference white, and can be only
> approximately translated to other reference whites.
> """
>
> ... hence conversions from L*a*b* to, say, sRGB, will differ based upon
> what illumination reference is used!
>
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.com
> http://wlfraed.microdiversity.freeddns.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to match scipy.spatial.distance results back to pandas df

2020-07-16 Thread Vincent Davis
I am trying to find points in the activity that are near points in segment.
I get the results from distance() and what to identify the points in
segment and activity that are within some value of each other .0001 for
example.
One idea I had was to append each array row (or column) to the
corresponding row in the df after converting it to a dict so that I can
lookup the point in the other df.

Any suggestions, ideas?

from scipy.spatial import distance
a = distance.cdist(segment[['Latitude', 'Longitude']],
activity[['Latitude', 'Longitude']], 'euclidean')
b = a[a < .0001]
b

array([8.83911760e-05, 6.31347765e-05, 3.89486842e-05, 2.13775583e-05,
   2.10950231e-05, 4.10487515e-05, 6.7000e-05, 9.10878697e-05,
   7.61183289e-05, 9.90050504e-05, 7.88162420e-05, 5.90931468e-05,
   4.50111097e-05, 4.97393205e-05, 6.78969808e-05, 8.52115016e-05,
...


Thanks
Vincent Davis
720-301-3003
*Want to get a hold of me?*


*SMS: awesome.phone: ok...*
*email: bad!*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fake news Detect

2020-07-18 Thread Vincent Davis
Data Sceptic has a couple podcast and some of the code is open source.
https://dataskeptic.com/blog/episodes/2018/algorithmic-detection-of-fake-news

Thanks
Vincent Davis
720-301-3003
*Want to get a hold of me?*


*SMS: awesome.phone: ok...*
*email: bad!*


On Fri, Jul 17, 2020 at 11:39 PM Mike Dewhirst 
wrote:

> On 18/07/2020 6:16 am, Grant Edwards wrote:
> > On 2020-07-17, Dennis Lee Bieber  wrote:
> >> On Fri, 17 Jul 2020 16:02:15 - (UTC), Gazu 
> declaimed
> >> the following:
> >>
> >>> Hey Guys I am new to python and i am building a fake news detection
> >>> system ...
> >>  I suspect that, if anyone had done this already, it would likely be
> >> found on some source code archive (github?) -- and you'd just be
> >> duplicating the effort.
> >>
> >>  Essentially, since the core of this functionality depends upon the
> >> algorithm, YOU will have to develop the algorithm.
> > Or he could do something easier like eliminating hunger, war and
> > Covid-19.
>
> Or like changing culture to give more weight to education, integrity
> etc. We need systems to automatically identify fake news and educate
> believers. News consumers have to do it.
>
> News consumers need a system where they can go to check news items to
> see if they are credible. Without the cooperation of news conduits - to
> label news items with the source - that will be difficult.
>
> However, that doesn't mean the crowd can't check credibility. So,
> culture change is needed. No-one wants to be outed as a fake news source.
>
> Here's a project. Build an automatic news aggregation site which
> collects all news in two pages per news item. Page 1 for the item and
> page 2 for the crowd credibility assessment and naming of the apparent
> source. Should work somewhat like Wikipedia. Except editors for page 2
> would need a threshold score for being correct. Everyone can criticise
> but you lose points for being on the wrong side of history.
>
> That'll be 2 cents
>
> Mike
>
> >
> > --
> > Grant
> >
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pickling issue.

2020-12-23 Thread vincent . vandevyvre
On 22/12/20 01:57, Bob Gailer wrote:
>
>
> On Mon, Dec 21, 2020, 3:03 PM Vincent Vande Vyvre 
>  wrote:
>
> Hi,
>
> I've an object that I want to serialise with pickle.
> When I reload the object the attributes of this object are correctly
> fixed except one of these.
>
> This attribute (value) define a simple string.
>
> Example:
> -
> tag =  XmpTag('Xmp.dc.form'image/jpeg')
>
>
> I am not familiar with XmpTag. Where might I get the containing module?
>
> ... skip
>
Yes, it's available with pip:
https://pypi.org/project/py3exiv2/
If you want to test it, just add from pyexiv2.xmp import XmpTag to my example.

and the source is here:
https://bazaar.launchpad.net/~vincent-vandevyvre/py3exiv2/trunk/view/head:/py3exiv2/src/pyexiv2/xmp.py

This is a Python-3 binding of the lib exiv2, the wrapper source code is here:
https://bazaar.launchpad.net/~vincent-vandevyvre/py3exiv2/trunk/view/head:/py3exiv2/src/exiv2wrapper.cpp#L359

exiv2 doc is here:
https://www.exiv2.org/doc/classExiv2_1_1Xmpdatum.html

Sorry for the late response but it seems a moderation problem with my account.

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


Spoiler to Python Challenge (help!!!)

2005-09-27 Thread Ian Vincent
Damn this is annoying me.

I have a webpage with a BZ2 compressed text embedded in it looking like:

'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M
\x07<]\xc9\x14\xe1BA\x06\xbe\x084'

Now, if I simply copy and paste this into Python and decompress it - it 
works a treat.

However, I want to read the file containing this data, extract the data 
and decompress it and this for some reason does not work.

I am doing the following (excuse the probably very long handed way of 
doing it):

file = urllib.urlopen(url, proxies=proxies)
line = file.readlines()
file.close()
line = line[20:]
line = line[:-1]
user = line[0]
password = line[1]
user = user[5:]
user = user[:-2]
user = str(user)
password = password[5:]
password = password[:-2]

This gives me a user string of:

BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M
\x07<]\xc9\x14\xe1BA\x06\xbe\x084

But if I put this into the decompression function, I get a error of 
'IOError: invalid data stream'.

I know it is the escape characters but how do I get these to be correctly 
converted into a string compatible with bz2.decompress()?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spoiler to Python Challenge (help!!!)

2005-09-28 Thread Ian Vincent
"Terry Reedy" <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:
> 
> please, line = line[20:-1], etc, is easier to read and understand ;-)

Thanks, i'll put that in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spoiler to Python Challenge (help!!!)

2005-09-28 Thread Ian Vincent
Terry Hancock <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 
> 
> Took me a long time to figure out what you meant. ;-)
> 
> So the string actually contains the backslashes, not the escaped
> characters. 
> 
> This works:
> 
 bz2.decompress(eval(repr(user)))
> 'huge'

Unfortunately, it doesn't. Get the same error.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spoiler to Python Challenge (help!!!)

2005-09-29 Thread Ian Vincent
Terry Hancock <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:
> 
 bz2.decompress(eval('"' + user + '"'))
> 
> Sorry about that.  I was trying the other as an alternative,
> but in fact, it doesn't work.  So ignore that.

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


Re: what does 0 mean in MyApp(0)

2005-09-30 Thread vincent wehren
"Alex" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| I'm looking at a tutorial with the code below
|
| from wxPython.wx import *
|
| class MyApp(wxApp):
|def OnInit(self):
|frame = wxFrame(NULL, -1, "winApp", size = (800,640))
|frame.Show(true)
|self.SetTopWindow(frame)
|return true
|
| app = MyApp(0)
| app.MainLoop()
|
| Everything is explained nicely except the zero parameter in MyApp(0).
| Anybody knows what that zero refers to?

See:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334620
|

--
Vincent Wehren
| Alex
| 


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


Re: what does 0 mean in MyApp(0)

2005-10-01 Thread vincent wehren
"Alex" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Thanks for the replies. It seems that I have three options
| 1. app=MyApp()
| 2. app=MyApp(0)
| 3. app=MyApp('myfile.txt')
|
| 1. In the first case the output stream will be set to stdout/stderr,
| which means that errors will be sent to a window which will be closed
| when the app crashes.
| 2. In the second case the output will be set to the command prompt
| window, which means that I will be able to catch the errors when my app
| crashes.
| 3. There is also a third alternative which is to set the output to  a
| file.
|
| Alterbnative 2 is simple and useful, so that's why everybody use that
| alternative.
|
| Is that correct?

Not entirely:

1. app=MyApp(): stdout/stderr is redirected to its own window, so you're
right here
2. app=MyApp(0): stdout/stderr is not redirected to a window.
Tracebacks will show up at  the console. So you're right here to...

But:
3(a). app=MyApp(1, 'some/file/name.txt'):
   stdout/stderr is redirected to to the file 'some/file/name.txt').

The arguments you pass to MyApp are named parameters, so for improved
readability you may want to use:

3(b). app=MyApp(redirect=1, filename='some/file/name'): will redirect stdout
  to 'filespec'

and instead of 2:

2(b). app=MyApp(redirect=0) # stdout/stderr will stay at the console...

Anyway, if you omit the parameter names, make sure you you position them 
correctly, i.e., a filename should only be positioned as /second/ argument.

HTH,
--

Vincent Wehren



| Alex
| 


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


Re: Upgrading 2.4.1 to 2.4.2

2005-10-25 Thread Vincent Gulinao
Hi, I'm new to python and just upgraded python on my system from 2.3 to
2.4. My platform is Linux-2.6.9-1.667smp-i686-with-redhat-3-Heidelberg.

Is there any way to inherit (share?) all extensions and additional
modules the my 2.3 have? (of course, beside re-installing everything)
On 19 Oct 2005 02:03:56 -0700, Ben Sizer <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:> Not sure that is a good idea on a linux system. MS should be fine, but> I actually tried that on linux. Didn't realize how much on a linux
> system depends on Python.I had that problem once, although to be fair it really does depend onwhich distribution you use as to how many problems you're going tohave.Perhaps the way to do it is to install the new Python version in
/usr/local/ (alongside the distro's version is in /usr/ ), then whenyou're sure your new version is installed and working, change thereferences over - perhaps it's possible to do this with just 1 symboliclink somewhere.
--Ben Sizer--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

How to use generators?

2005-11-09 Thread Ian Vincent




I have never used generators before but I might have now found a use for 
them. I have written a recursive function to solve a 640x640 maze but it 
crashes, due to exceeding the stack.  The only way around this I can 
think of is to use Generator but I have no idea how to.

The function is as below:

def solve_maze(x,y):
if y <= 0:
success = 1
elif x <= 0 or x > 640 or y >= 640:
success = 0
elif maze_array[x][y] == 1:
success = 0
elif im.getpixel((x,y)) == (255, 255, 255, 255):
success = 0
else:
maze_array[x][y] = 1
if solve_maze(x,y-1) == 1:
success = 1
elif solve_maze(x+1,y) == 1:
success = 1
elif solve_maze(x-1,y) == 1:
success = 1
else:
success = solve_maze(x,y+1)

if success == 1:
print im.getpixel((x,y))

return success

#Main
wibble = solve_maze(x,y)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use generators?

2005-11-10 Thread Ian Vincent
Tom Anderson <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 
> 
> Exactly - using a queue means you'll do a breadth-first rather than a 
> depth-first search, which will involve much less depth of recursion.
> See: 

Thanks for the answers but found a easier (admittedly cheating) way around 
the problemrun the code on my 64bit Linux system at home.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing pins to the RS232

2005-11-28 Thread Ian Vincent
Peter Hansen <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 
> 
> All true, but then Jay might get into electrical compatibility issues,
> and may not realize that the output levels of RS-232 serial hardware
> are not simply 0 and 5V levels, but rather +9V (or so) and -9V (and
> with variations from 6V up to 13V seen in the wild), and without much
> in the way of drive capability.  Using this to control custom hardware
> would probably be an exercise in frustration and kind of pointless in 
> comparison to using parallel hardware, which at least has more typical
> logic voltage levels.

You can get ICs that convert RS232 to TTL voltage levels.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Developing Commercial Applications in Python

2005-01-03 Thread vincent wehren
[EMAIL PROTECTED] wrote:
Hello All,
I am trying to convince my client to use Python in his new product. He
is worried about the license issues. Can somebody there to point me any
good commercial applications developed using python ?. The licence
clearly says Python can be used for commercial applications. Is there
any other implications like that of GPL to make the source open ?
Thanks for any help.
eeykay
At CSB-System AG, we use Python extensively as embedded scripting 
language throughout the ERP system we develop (fields of application: 
system automation, GUI scripting, programmable user exits, reporting, 
data access/replication, autotests, and apart from that, everywhere we 
need something done fast ;-).

I'm sure that its liberal license was among the main drivers to use it 
in the first place!

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


Re: exceptions and items in a list

2005-01-10 Thread vincent wehren
rbt wrote:
If I have a Python list that I'm iterating over and one of the objects 
in the list raises an exception and I have code like this:

try:
do something to object in list
except Exception:
pass
Does the code just skip the bad object and continue with the other 
objects in the list, or does it stop?

Thanks
Fire up a shell and try:
>>> seq = ["1", "2", "a", "4", "5", 6.0]
>>> for elem in seq:
... try:
...print int(elem)
... except ValueError:
...pass
and see what happens...
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: exceptions and items in a list

2005-01-10 Thread vincent wehren
Steve Holden wrote:
vincent wehren wrote:
rbt wrote:
If I have a Python list that I'm iterating over and one of the 
objects in the list raises an exception and I have code like this:

try:
do something to object in list
except Exception:
pass
Does the code just skip the bad object and continue with the other 
objects in the list, or does it stop?

Thanks

Fire up a shell and try:
 >>> seq = ["1", "2", "a", "4", "5", 6.0]
 >>> for elem in seq:
 try:
print int(elem)
     except ValueError:
pass
and see what happens...
--
Vincent Wehren

I suspect the more recent versions of Python allow a much more elegant 
solution. I can't remember precisely when we were allowed to use 
continue in an except suite, but I know we couldn't in Python 2.1.

Nowadays you can write:
Python 2.4 (#1, Dec  4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> for i in [1, 2, 3]:
 ...   try:
 ... print i
 ... if i == 2: raise AttributeError, "Bugger!"
 ...   except AttributeError:
 ... print "Caught exception"
 ... continue
 ...
1
2
Caught exception
3
 >>>
To terminate the loop on the exception you would use "break" instead of 
"continue".
What do you mean by a more elegant solution to the problem? I thought 
the question was if a well-handled exception would allow the iteration 
to continue with the next object or that it would stop. Why would you 
want to use the continue statement when in the above case that is 
obviously unnecessary?:

$ python
Python 2.4 (#1, Dec  4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in [1,2,3]:
... try:
... if i == 2: raise AttributeError, "Darn!"
...     except AttributeError:
... print "Caught Exception"
...
1
2
Caught Exception
3
>>>
Or do you mean that using "continue" is more elegant than using "pass" 
if there are no other statements in the except block?

Regards,
--
Vincent Wehren
regards
 Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe Excludes

2005-01-12 Thread vincent wehren
Ed Leafe wrote:
I'm trying to make a Windows runtime for Dabo, and I want to exclude 
the framework code itself from the exe file, so that people can update 
with new releases as they are made. The relevant section of setup.py has:

setup(
# The first three parameters are not required, if at least a
# 'version' is given, then a versioninfo resource is built from
# them and added to the executables.
version = "0.3.0",
description = "Dabo Runtime Engine",
name = "daborun",
# targets to build
console = ["daborun.py"],
#exclude the actual framework
options = { "py2exe": {"excludes" : ["dabo"]} },
)
Yet the generated library.zip still contains all of the Dabo module 
code. Why is this? What am I doing wrong?
Just a guess: What happens if you remove everything that's in the 
"build" directory before running setup.py? There may still be files 
around from an earlier build that *did* include the Dabo modules.

--
Vincent Wehren

 ___/
/
   __/
  /
 /
 Ed Leafe
 http://leafe.com/
 http://dabodev.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to find site-packages path

2005-01-17 Thread vincent wehren
Philippe C. Martin wrote:
Hi,
I am using my own install script for my software and am looking for a
flawless way to figure out where python, and more specifically
site-packages is installed.
You can take a look at how this is done in Lib/site.py.
Look for the bit of code that starts with
prefixes = [sys.prefix]
sitedir = None # make sure sitedir is initialized because of later 'del'
...
etc.
--
Vincent Wehren

Any clue ?
Regards,
Philippe

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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-17 Thread vincent wehren
Philippe C. Martin wrote:
The flawless way would be to use distutils. In fact you shouldn't even
need your own install script--it should do most of the work for you.

The reason I have not so far is I have not found a way to get what I
want done:
1) create directories in site-packages (I gather this shoudl be easy
enough)
2) copy already compiled (.pyc) and source (.py) files to those
directories
Why would you want to copy any *.pyc instead of compiling them on site?
--
Vincent Wehren

3) create directories and copy files in a directory kept in an
environment variable
Can distutils do this for me?


Regards,
Philippe


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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-18 Thread vincent wehren
Philippe C. Martin wrote:
Why would you want to copy any *.pyc instead of compiling them on
site?

I know that sounds terrible to the open source community, 

but I do not
intend to release the source code for my product 
That's not why I asked. I'll leave the politics up to you. The thing is, 
that the path info gets cached in the *.pyc file. This may lead to 
confusing tracebacks - might they occur - when the user does not install 
to the exact same drive/path as you did.

Additionally: if you *do* want to distribute *.pyc only, I personally 
wouldn't find it terribly neat if you stuck those into the site-packages 
directory of my Python installation. I - for one - would want to know 
what kind of source code you place along *my* sys.path.

Maybe you should consider using py2exe to distribute - keeping your 
*.pyc out of the user's Python directory tree, if any, entirely. Also, 
you may want to consider using Inno Setup as deployment tool (if Windows 
is your target platform). Using distutils for a *.py-less installer 
seems pretty pointless.


Regards,
--
Vincent Wehren
- pls go to
philippecmartin.com/applications.html for my _small_ contributions :-))

Regards,
Philippe

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


Re: module for 'po' files

2005-01-25 Thread vincent wehren
Sara Fwd wrote:
 Hi all
Is there a module for processing & handling  '.po'
files in python?
Don't know exactly what you mean by "processing & handling". What do you 
want to do?

--
Vincent Wehren



		
__ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 
--
http://mail.python.org/mailman/listinfo/python-list


Re:snakespell and myspell

2005-01-25 Thread vincent wehren
Fuzzyman wrote:
I'm looking to implement a plugin spell checker.
I'm probably going to go with PyEnchant, as it looks to be the most
promising currently maintained spell checker.
What I would like to know about PyEnchant is how to handle non-ascii 
input. Through trial & error I've noticed that let's say German Umlauts
are stored in the dictionary as using dead accents (is that the term?) 
(as in 'Mu"tter'), however French accented characters appear to be 
stored differently (as in '\xc3\xa9levage'. Anybody know what the 
"system" is?


I just wondered if anyone knew what happened to snakespell and myspell.
Don't know about that. But than there also is a pyrex-driven aspell 
binding at http://sourceforge.net/projects/uncpythontools

Regards,
--
Vincent Wehren

Both seem to have dissapeared from the net. People have reported good
results from both - and it seems a shame to lose them.

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: snakespell and myspell

2005-01-25 Thread vincent wehren
vincent wehren wrote:
Fuzzyman wrote:
I'm looking to implement a plugin spell checker.
I'm probably going to go with PyEnchant, as it looks to be the most
promising currently maintained spell checker.

What I would like to know about PyEnchant is how to handle non-ascii 
input. Through trial & error I've noticed that let's say German Umlauts
are stored in the dictionary as using dead accents (is that the term?) 
(as in 'Mu"tter'), however French accented characters appear to be 
stored differently (as in '\xc3\xa9levage')
The latter of course being utf-8...
--
Vincent
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open Folder in Desktop

2005-01-25 Thread vincent wehren
Jimmy Retzlaff wrote:
Kamilche wrote:

Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
extensions
(https://sourceforge.net/project/showfiles.php?group_id=78018) include a
way to get at this:
from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, 0, 0)
os.startfile(path)
Google for CSIDL to find the constants to use for other special folders.
Here's the exact link you'll need (warning, long url ahead ;)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp
--
Vincent Wehren


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


Re: tk global bindings

2005-01-29 Thread vincent wehren
Gabriel B. wrote:
I'm starting to write a POS application UI's module.
There's no mouse, just a bunch of global shortcuts.
the problem is that TK doesn't have global shortcuts! Is there a
work-around or i will have to attach 80 or so bindings for every input
element?
In Tk here are three levels of binding: instance binding, class binding, 
 and application binding represented by the bind, bind_class, and 
bind_all methods. You're probably looking for the the bind_all method, 
as in self.bind_all("", self.onSomeKey)

HTH,
--
Vincent Wehren

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


Re: tk global bindings

2005-01-29 Thread vincent wehren
vincent wehren wrote:
Gabriel B. wrote:
I'm starting to write a POS application UI's module.
In Tk here are three levels of binding: instance binding, class binding, 
 and application binding represented by the bind, bind_class, and 
bind_all methods. You're probably looking for the the bind_all method, 
as in self.bind_all("", self.onSomeKey)

HTH,
--
Vincent Wehren
Oh and you of course __must__ look at the (recently updated!) New Mexico 
Tech tkinter document at:
http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf

See page 75 and follwing for more info on keyboard bindings...
--
Vincent Wehren

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


Re: Printing Filenames with non-Ascii-Characters

2005-02-01 Thread vincent wehren
Marian Aldenhövel wrote:
Hi,
I am very new to Python and have run into the following problem. If I do
something like
  dir = os.listdir(somepath)
  for d in dir:
 print d

The program fails for filenames that contain non-ascii characters.

  'ascii' codec can't encode characters in position 33-34:
If you read this carefully, you'll notice that Python has tried and 
failed to *encode* a decoded ( = unicode) string using the 'ascii' 
codec. IOW, d seems to be bound to a unicode string. Which is unexpected 
unless maybe the argument passed to os.listdir (somepath) is a Unicode 
string, too. (If given a Unicode string as argument, os.listdir will 
return the list as a list of unicode names).

If you're printing to the console, modern Pythons will try to guess the 
console's encoding (e.g. cp850). I would expect a UnicodeEncodeError if 
the print fails because the characters do not map to the console's 
encoding, not the error you're seeing.

How *are* you running the program. In the console (cmd.exe)? Or from 
some IDE?

I have noticed that this seems to be a very common problem. I have read 
a lot
of postings regarding it but not really found a solution. Is there a simple
one?

What I specifically do not understand is why Python wants to interpret the
string as ASCII at all. Where is this setting hidden?
Don't be tempted to ever change sys.defaultencoding in site.py, this is 
site specific, meaning that if you ever distribute them, programs 
relying on this setting may fail on other people's Python installations.

--
Vincent Wehren
I am running Python 2.3.4 on Windows XP and I want to run the program on
Debian sarge later.
Ciao, MM
--
http://mail.python.org/mailman/listinfo/python-list


Re: Printing Filenames with non-Ascii-Characters

2005-02-02 Thread vincent wehren
Marian Aldenhövel wrote:
But wouldn't that be correct in my case?
This is what I get inside Eclipse using pydev when I run:

import os
dirname = "c:/test"
print dirname
for fname in os.listdir(dirname):
print fname
if os.path.isfile(fname):
print fname
:
c:/test
straßenschild.png
test.py
Übersetzung.rtf
This is what I get passing a unicode argument to os.listdir:

import os
dirname = u"c:/test"
print dirname # will print fine, all ascii subset compatible
for fname in os.listdir(dirname):
print fname
if os.path.isfile(fname):
print fname

c:/test
Traceback (most recent call last):
  File "C:\Programme\eclipse\workspace\myFirstProject\pythonFile.py", 
line 5, in ?
print fname
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in 
position 4: ordinal not in range(128)

which is probably what you are getting, right?
You are trying to write *Unicode* objects containing characters outside 
of the 0-128 to a multi byte-oriented output without telling Python the 
appropriate encoding to use. Inside eclipse, Python will always use 
ascii and never guess.

import os
dirname = u"c:/test"
print dirname
for fname in os.listdir(dirname):
print type(fname)
c:/test




so finally:

import os
dirname = u"c:/test"
print dirname
for fname in os.listdir(dirname):
print fname.encode("mbcs")

gives:
c:/test
straßenschild.png
test.py
Übersetzung.rtf
Instead of "mbcs", which should be available on all Windows systems, you 
could have used "cp1252" when working on a German locale; inside Eclipse 
even "utf-16-le" would work, underscoring that the way the 'output 
device' handles encodings is decisive. I know this all seems awkward at 
first, but Python's drive towards uncompromising explicitness pays off 
big time when you're dealing with multilingual data.

--
Vincent Wehren

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


Re: Generating .pyc/.pyo from a make file

2005-02-02 Thread vincent wehren
Tim Daneliuk wrote:
Steve Holden wrote:
Roland Heiber wrote:
Tim Daneliuk wrote:
Aha!  Exactly ... and that makes perfect sense too.  D'oh!  I guess a 
better
distribution strategy would be to have the installation program generate 
the pyo
file at installation time...

Thanks -
Also, the *.py? files contain the full pathname of the *.py they have 
been compiled from. Copying them to other path locations will give you 
the wrong __file___ information in tracebacks.

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


Re: Printing Filenames with non-Ascii-Characters

2005-02-03 Thread vincent wehren
Marian Aldenhövel wrote:
Hi,
 > Python's drive towards uncompromising explicitness pays off
big time when you're dealing with multilingual data.

Except for the very implicit choice of 'ascii' as an encoding when
it cannot make a good guess of course :-).
Since 'ascii' is a legal subset Unicode and of most prevailing 
encodings, this is the only sensible thing to do. It is outside of the 
ascii range where characters become ambigious and need additional 
interpretation. Where other languages might ignore the problem at hand 
and send garbled data or replace characters to the output, Python at 
least let's you respond to conversion problems/errors.

All in all I agree, however.
That's good to hear ;)
--
Vincent Wehren

Ciao, MM
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple constructors

2005-02-06 Thread vincent wehren
Philip Smith wrote:
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix 
class (ie to initialise either from a list of values or from 2 dimensions 
(rows/columns)).

Even if Python couldn't resolve the __init__ to use on the basis of argument 
types surely it could do so on the basis of argument numbers???

At any rate - any suggestions how I code this
Checking the number of arguments ain't all that hard:
class Klass:
   def __init__(*args):
   self.args = args
   if len(self.args) == 1:
   # etc.
This feels rather unpythonic, though. Maybe you could use factory 
functions, forgetting about  __init__ all together (2.2 or higher):

class Klass(object):
def fromList(seq):
result = Klass()
# populate attributes here
# and return the requested object
return result
fromList = staticmethod(fromList)
def fromDimensions(cols, rows):
result = Klass()
# populate attributes here
# and return the requested object
return result
   fromDimensions = staticmethod(fromDimensions)
   #more methods  here
k = Klass.fromList(seq)
etc..
Regards
--
Vincent Wehren



Thanks
Phil 


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


Re: Word for a non-iterator iterable?

2005-02-06 Thread vincent wehren
Leif K-Brooks wrote:
Is there a word for an iterable object which isn't also an iterator, and 
therefor can be iterated over multiple times without being exhausted? 
"Sequence" is close, but a non-iterator iterable could technically 
provide an __iter__ method without implementing the sequence protocol, 
so it's not quite right.
How about 'reiterable'?
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple constructors

2005-02-06 Thread vincent wehren
Reinhold Birkenfeld wrote:
vincent wehren wrote:
Philip Smith wrote:
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix 
class (ie to initialise either from a list of values or from 2 dimensions 
(rows/columns)).

Even if Python couldn't resolve the __init__ to use on the basis of argument 
types surely it could do so on the basis of argument numbers???

At any rate - any suggestions how I code this
Checking the number of arguments ain't all that hard:
class Klass:
   def __init__(*args):
   self.args = args
   if len(self.args) == 1:
   # etc.
This feels rather unpythonic, though. 

And it won't work, as `self' is not defined. ;)
You're right of course!
Note to self: Must stop shooting from the hip ;)
--
Vincent


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


Re: tab 2 into tab 4 ?

2005-06-19 Thread vincent wehren

<[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Hello,
|
| I have python code which use tab=2. Recently I would like to change it
| into tab=4.
|
| Anyone has suggestion to convert easily and safely ?

Look at "reindent.py" in Tools\Scripts.

--

Vincent Wehren


|
| pujo
| 


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


Re: Running Python scripts under W2K with I/O redirection

2005-06-25 Thread vincent wehren

<[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I apologise if this is a well known problem. I've searched and can't
| find a clear description or fix. Hope someone can help.
|
| I am running my Python scripts under Windows 2000 using Python 2.4
| Build 243 from Activestate.
|
| If I want to specify a file as standard input to my script I can just
| enter a command like:
|
|  H:\> pyscript.py file.inp
|
| and that's what I get. All ok so far.
|
| However if I enter commands like:
|
|  H:\> type file.inp | pyscript.py
|
| or
|
|  H:\> pyscript.py < file.inp
|
| It doesn't work. I've also tried the variant of parsing for a command
| line argument of '-' or 'filename' and then specifically either copying
| the sys.stdin file object or opening the file specified, then using
| that file object. Same problem.
|
| Interestingly enough, if I specify my commands as:
|
|  H:\> type file.inp | python pyscript.py
|
| or
|
|  H:\> python pyscript.py < file.inp
|
| It all works the (unix-like) way I wanted it to. This leads me to
| suspect there is something wrong in the way that Python is being
| invoked by Windows in my problem situation rather than an inherent
| fault within Python itself.

Your suspicion is correct

see:

http://support.microsoft.com/default.aspx?kbid=321788

--

Vincent Wehren



|
| Does anyone have any idea what the problem could be and how to fix it?
| I know its a really minor niggle but it'd make this poor deprived
| unix-guy-forced-into-windows-servitude very happy.
|
| Thanks,  sub1ime_uk
|
| sub1ime_uk (at) yahoo (dot) com
| 


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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren

"Grant Edwards" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I have several python apps (some wxPython, some plain text-mode
| stuff) that I distribute internally for installation on Win32
| machines.  They're bundled/installed using py2exe and inno
| setup.
|
| I followed what I think is the normal procedure of installing
| each app in its own directory under /Program
| Files//.
|
| The problem is that the apps only run if they're started with
| the install directory as the current working directory.
| Otherwise they can't find the .dll's they use from the install
| directory.

AFAIK, Windows normally *does* search the directory where the executable 
module for the current process lives in for dlls. What sort of dlls are 
given you trouble?

--

Vincent Wehren




|
| Is there some way to temporarily add the app's install
| directory to the search path for .dll's?
|
| -- 
| Grant Edwards   grante Yow!  .. I think I'd
|  at   better go back to my 
DESK
|   visi.comand toy with a few 
common
|   MISAPPREHENSIONS... 


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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren
"Gregory Piñero" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]

|And here is how I make sure I'm always using the right directory in my 
scripts:
|
|Put this code at the top:
|import sys
|curdir=os.path.dirname(sys.argv[0])
|#print curdir
|Then I use curdir to build all of the paths in my app:
|For example let's get a list of files in a folder:
|lstresumes=os.listdir(os.path.join(curdir,resume_folder_path)) #get
|list of resumes



Greg,

If you need something that works both on a frozen app as well as an 
(unfrozen) python
script, you'd be better off using something like:

def getAppPrefix():
"""Return the location the app is running from
"""
isFrozen = False
try:
isFrozen = sys.frozen
except AttributeError:
pass
if isFrozen:
appPrefix = os.path.split(sys.executable)[0]
else:
appPrefix = os.path.split(os.path.abspath(sys.argv[0]))[0]
return appPrefix

Now you can use the return value of getAppPrefix() everywhere you need to 
calculate paths relative to your app, regardless if it involves a regular 
script or py2exe'ified one.

Regards,

--

Vincent Wehren


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

Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren
"Grant Edwards" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| On 2005-08-02, vincent wehren <[EMAIL PROTECTED]> wrote:
| >
| > "Grant Edwards" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
| > news:[EMAIL PROTECTED]
| >|I have several python apps (some wxPython, some plain text-mode
| >| stuff) that I distribute internally for installation on Win32
| >| machines.  They're bundled/installed using py2exe and inno
| >| setup.
| >|
| >| I followed what I think is the normal procedure of installing
| >| each app in its own directory under /Program
| >| Files//.
| >|
| >| The problem is that the apps only run if they're started with
| >| the install directory as the current working directory.
| >| Otherwise they can't find the .dll's they use from the install
| >| directory.
| >
| > AFAIK, Windows normally *does* search the directory where the executable
| > module for the current process lives in for dlls. What sort of dlls are
| > given you trouble?
|
| One's a "driver" for a CAN bus USB widget.  The other failure
| that springs to mind is that gnuplot-py couldn't find something
| (could have been an .exe) that was in the app directory.

Grant,

If you are building paths in you code that are relative to your app, please 
see my reply to Greg's post. If not, you may as a workaround want to try to 
add the frozen application's directory to the system path environment 
variable. Windows will look for dlls there, too.

To get the app's actual location, you will need something like the 
getAppPrefix() function as per my reply to Greg's reply. The getAppPrefix() 
function will also hold when the user adds your frozen app to his/her system 
path and call the app from any location from the command line - sys.argv[0] 
just won't do the trick in such a setting.


HTH,

--

Vincent Wehren










|
| -- 
| Grant Edwards   grante Yow!  HUGH BEAUMONT 
died
|  at   in 1982!!
|   visi.com 


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


Re: py2exe windows apps path question

2005-08-02 Thread vincent wehren

"Gregory Piñero" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> If you need something that works both on a frozen app as well as an
> (unfrozen) python
> script, you'd be better off using something like:
>
>> def getAppPrefix():
>> """Return the location the app is running from
>> """
>> isFrozen = False
>> try:
>> isFrozen = sys.frozen
>> except AttributeError:
>> pass
>> if isFrozen:
>> appPrefix = os.path.split(sys.executable)[0]
>> else:
>> appPrefix = os.path.split(os.path.abspath(sys.argv[0]))[0]
>> return appPrefix
>>
>
>Vincent,
>
>This sounds interesting.  A few questions for you:
>Why don't I see sys.frozen in interpreter?
>Does it only appear when it is frozen?

Yes. The sys.frozen attribute is added by py2exe.

>What do you mean by frozen, how does python know?

Python doesn't know - it is just told so ;)

>What does sys.executable do?

sys.executable gives you the path of the executing binary. Normally, this 
will be something like
"c:\\python24\\python.exe" - since the interpreter is the executing binary.
Once you have frozen your python application, it will return the path to 
your app.


--

Vincent

>
>Thanks,
>
>Greg 


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

Re: zlib + Windows 32 service problem (ImportError)

2005-08-15 Thread vincent wehren
"Laszlo Zsolt Nagy" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Sorry, I realized that the import zlib was not executed from my
| (working) service.
| So here is the question: why can't I use zlib from a win32 service? Is
| there any way to make it working?
|
| >-
| >Python could not import the service's module
| >  File "T:\Python\Projects\NamedConnector\Service.py", line 17, in ?
| >from Processor import *
| >  File "c:\Python\Projects\NamedConnector\Processor.py", line 35, in ?
| >from mess import MessageSocket
| >  File "T:\Python\Lib\mess\MessageSocket.py", line 31, in ?
| >import zlib
| >exceptions.ImportError: dynamic module does not define init function
| >(initzlib)
| >-
|
|
|
I had a similar problem where a zlib.dll that is *not a Python extension* is 
in sys.path *before* zlib.pyd. Python will try to import this zlib.dll and 
find the  dll doesn't export a initzlib:
for more info see 
http://mail.python.org/pipermail/python-list/2004-October/thread.html#248107

HTH,

Vincent Wehren




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


Re: zlib + Windows 32 service problem (ImportError)

2005-08-16 Thread vincent wehren

"Laszlo Zsolt Nagy" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| vincent wehren wrote:
|
| >"Laszlo Zsolt Nagy" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
| >news:[EMAIL PROTECTED]
| >| Sorry, I realized that the import zlib was not executed from my
| >| (working) service.
| >| So here is the question: why can't I use zlib from a win32 service? Is
| >| there any way to make it working?
| >|
| >| >-
| >| >Python could not import the service's module
| >| >  File "T:\Python\Projects\NamedConnector\Service.py", line 17, in ?
| >| >from Processor import *
| >| >  File "c:\Python\Projects\NamedConnector\Processor.py", line 35, in ?
| >| >from mess import MessageSocket
| >| >  File "T:\Python\Lib\mess\MessageSocket.py", line 31, in ?
| >| >import zlib
| >| >exceptions.ImportError: dynamic module does not define init function
| >| >(initzlib)
| >| >-
| >|
| >|
| >|
| >I had a similar problem where a zlib.dll that is *not a Python extension* 
is
| >in sys.path *before* zlib.pyd. Python will try to import this zlib.dll 
and
| >find the  dll doesn't export a initzlib:
| >for more info see
| 
 >http://mail.python.org/pipermail/python-list/2004-October/thread.html#248107
| >
| >
| Thanks. I set my system environment variable 'PATH' to this:
|
| 
C:\Python24;C:\Python24\DLLs;c:\Python24\Lib\site-packages\win32;c:\oracle\product\10.1.0\db_1\bin;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program
| Files\Common Files\GTK\2.0\bin
|
| Then I restarted my computer. It is still missing initzlib. :-(
| Please note that I can run the same program as an application, logged in
| as the same user.
|
|  Les

Changing the Windows dll search path doesn't make any difference. It is 
sys.path (Python's search path) that's causing you the headache. Please see 
the mentioned thread for proposed solutions.


Regards,
--

Vincent Wehren 


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


Re: Problems with Python for Windows extensions

2005-09-03 Thread vincent wehren
"KK" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| the code below is taken from M$ technet as an example on using vb
| script to do a replace all in word:
|
| Const wdReplaceAll  = 2
|
| Set objWord = CreateObject("Word.Application")
| objWord.Visible = True
|
| Set objDoc =
| objWord.Documents.Open("K:\Development\Fabricbase\prod\Test.doc")
| Set objSelection = objWord.Selection
|
| objSelection.Find.Text = "Contoso"
| objSelection.Find.Forward = True
| objSelection.Find.MatchWholeWord = True
|
| objSelection.Find.Replacement.Text = "Fabrikam"
| objSelection.Find.Execute ,,wdReplaceAll
|
|
|
|
| I did a rewrite and made it pythonic:
|
| from win32com.client import *
|
| wdReplaceAll  = 2
|
| objWord = Dispatch("Word.Application")
| objWord.Visible = True
|
| objDoc =
| objWord.Documents.Open("K:\Development\Fabricbase\prod\Test.doc")
| objSelection = objWord.Selection
|
| objSelection.Find.Text = "Contoso"
| objSelection.Find.Forward = True
| objSelection.Find.MatchWholeWord = True
|
| objSelection.Find.Replacement.Text = "Fabrikam"
| objSelection.Find.Execute (Replace = wdReplaceAll)
|
|
| However, the document juz loaded up in word but no action was taken. I
| am using Word 2003. Any ideas?

KK,

Your example seemed to work fine for me (Python2.4, Pythonwin build 204, 
Word 2003)

One thing: since you say your document loads up fine I don't know if it is 
just a typo, but make sure you follow the rules of backslash literals in 
path names. In other words:
"K:\Development\Fabricbase\prod\Test.doc" should read either

r"K:\Development\Fabricbase\prod\Test.doc" (note the leading r for raw 
string
or

"K:\\Development\\Fabricbase\\prod\\Test.doc"
or

"K:/Development/Fabricbase/prod/Test.doc"

--

Vincent Wehren





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


TKinter, Entry objects and dynamic naming

2005-09-13 Thread Ian Vincent
I am hoping someone may be able to help.

I am using Python and TKinter to create a GUI program that will 
eventually create an XML file for a project I am working on. Now, the XML 
file contents changes depending on the type of file it represents - so I 
am dynamically creating the TK Entry boxes. The problem is, I want the 
variable assigned to each of these boxes to be dynamically assigned as 
well but I cannot see how to do this (if it is indeed possible).

Example

If the file the XML is to represent is a spreadsheet - I want the first 
entry box to be:

spreadsheetField = StringVar()
value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=spreadsheetField)

however, if the file is a document - I want the first entry box to be:

documentField = StringVar()
value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=documentField)

I have quite a few Entry boxes for each file type (about 10) and a lot of 
filetypes (over 80), so I do not want to have a custom function for each 
filetype if I can help it.

I have looked at using a dictionary but I cannot get my head around how 
to do that either.

If anyone can give me any ideas, I would be very grateful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TKinter, Entry objects and dynamic naming

2005-09-13 Thread Ian Vincent
Ian Vincent <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 
> 
> I have looked at using a dictionary but I cannot get my head around
> how to do that either.

I have tried this now but the Entry field just does not seem to work:

def add_variable(self, root, varname):
 Label(root, text=varname + ': ').grid(row=self.row, column=0, 
sticky=E)
 self.properties[varname] = StringVar()
 value = Entry(root, relief=SUNKEN, justify=LEFT, 
textvariable=self.properties[varname])
 value.grid(row=self.row, column=1, sticky=E+W)
 self.row = self.row + 1
 return value


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


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

2005-09-21 Thread vincent wehren

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

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

HTH,
--

Vincent Wehren

|
| Thanks in advance.
|
| Vj
| 


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


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

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

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

--
Vincent




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


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

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

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

HTH,
--

Vincent Wehren


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


Re: PyEphem on winXP

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

It should work.

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

I've had success using that approach...


HTH,
--

Vincent Wehren


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


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


Re: Trouble with the encoding of os.getcwd() in Korean Windows

2005-02-09 Thread Vincent Wehren
Erik Bethke wrote:
Hello All,
I have found much help in the google archives but I am still stuck...
here is my code snippet:
path = os.getcwd()
path = path.decode('UTF8')
Now the trouble is I am getting that darn UnicodeDecodeError, where it
is tripping up on the Korean hangul for My Desktop.  Now I have tried
utf8 and utf16 and neither of these works.

So is this my question?:  What encoding does windows use for Korean
Windows?  
Try "mbcs". This is a built-in encoding avalaible only on Windows and 
that equals the system's default ANSI codepage. Using "mbcs", which is 
short for "multi-byte character set", the conversions to and from 
Unicode (decode/encode) are internally handled by the corresponding 
win32 api functions.

--
Vincent Wehren
I thought it might be and so I surfed around
(http://foundationstone.com.au/HtmlSupport/OnlineHelp/Localisation/SupportedEncodings.html)
and there appears to be an encoding called: windows-949 labeled to be
Korean Windows, which of couse is *not* one of the encodings to be
found in the encodings package... which would suck.
But then I thought about it some more, how could you make software to
do things like read the current directory work on different language
machines???  It would be madness to have a try statement for each and
every encoding under the sun...
Why isn't there a get system encoding method?
Or am I on the entirely wrong track?
Thanks,
-Erik
--
http://mail.python.org/mailman/listinfo/python-list


Re: Commerical graphing packages?

2005-02-12 Thread Vincent Wehren
Erik Johnson wrote:
I am aware of ChartDirector (http://www.advsofteng.com/ ) which
explicitly supports python and seems to be about the right level of
sophistication. I don't really know of any other packages in this space, do
you? I am seeking feedback and reccomendations from people who have used
this package or similar ones. I am particularly interested to hear about any
limitations or problems you ran into with whatever package you are using.
We use both the Python and C++ bindings of ChartDirector (although their 
license always spans /all/ supported bindings. It's all pretty 
straight-forward, well-documented, and the license fee is a bargain 
compared to other packages we've used in the past. What it is not 
suitable for is maybe allowing for 3d-views of data cubes - changeable 
on the fly.

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


Re: connecting to Sybase/MsSQL from python

2005-02-12 Thread vincent wehren

"John Fabiani" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
> Hi,
> I'm hoping someone on the list has connected to sybase/MsSQL with 
> something
> that works with DBAPI 2.0 from a linux box (SUSE 9.2) because I can't seem
> to get it done.  I found Object Craft's python code that uses FreeTDS. 
> But
> I can't get it compiled.  The code is looking for "sybdb.h" (first 
> error) -
> of course I don't have "sybdb.h".  It is not in Object Crafts code nor in
> the FreeTDS source.  I'm guessing that I need sybase develop lib's but I
> don't know where they are to be found.
>
> So is there a kind sole out there that can help with instructions on what 
> is
> needed to get python talking to MsSQL.
>
> jOHN

Use mxODBC?

--

Vincent Wehren


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


Re: win2k multiple versions config question

2005-02-17 Thread Vincent Wehren
[EMAIL PROTECTED] wrote:
I currently have both 2.3 and 2.4 on my Win2k computer. For the most
part, I've been able to run each version, but I'm not configured
completely correctly and I've run into a snafu. I downloaded LGT to try
it out today; it uses PyGame (which as far as I know doesn't work with
2.4 yet -- or am I wrong here?), and OpenGL, and maybe has other
dependencies. At any rate, the error I am seeing apparently involves
OpenGL, and looks like this:
Traceback (most recent call last):
  File "D:\Dld\LGT\doc\dev_pygame.py", line 3, in ?
import LGT
  File "..\LGT\__init__.py", line 2, in ?
import video
  File "..\LGT\video.py", line 1, in ?
from OpenGL.GL import *
  File "d:\Python23\lib\site-packages\OpenGL\__init__.py", line 26, in
?
from GL.GL__init___ import __numeric_present__, __numeric_support__
  File "d:\Python23\lib\site-packages\OpenGL\GL\__init__.py", line 2,
in ?
from GL__init__ import *
  File "d:\Python23\lib\site-packages\OpenGL\GL\GL__init__.py", line 2,
in ?
import GL__init___
ImportError: Module use of python23.dll conflicts with this version of
Python.
I'm not sure what "this version" of Python should be here. I have a
Pythonpath that refers to the 2.3 tree; neither 2.3 nor 2.4 is
referenced in my Path variable. There is no evident reference to 2.4
active (at least not that I can find). The message seems to be telling
me that the OpenGL module uses 2.3, which should be correct, but maybe
I'm reading it wrong. Can anybody set me on the right track here?
When you enter "python" in the command line, does python 2.4 appear, or
python 2.3? If it's 2.4, be explicit about wanting 2.3 and run the 
script like so:

d:\Python23\python name_of_scriptfile.py

HTH,
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to I access the filename with TkFileDialog?

2005-02-17 Thread Vincent Wehren
imphasing wrote:
I'm writing a python program to open a file, and display it onscreen,
but I can't seem to find the var that "tkOpenFileName" returns to. It's
not much use if you can't get the filename you just chose, so there
must be a way to get it. Could anyone help me?
Thanks,
Alex
openfilename=tkFileDialog.askopenfilename(filetypes=[("all files", "*")])
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Chart Director?

2005-02-18 Thread Vincent Wehren
[EMAIL PROTECTED] wrote:
Does anyone here have experience with Chart Director
(http://www.advsofteng.com/index.html)?   I'm thinking about purchasing
it and looking for any feedback from the Python community.  Thanks
Since ChartDirector is not exactly open source nor found its origin in a 
Python setting, my uneducated guess is that it will mostly be companies 
that use ChartDirector.

However, from that vantage-point, ChartDirector is well-documented, has 
lots of examples, and is great value for the money; it's pretty straight 
forward, it covers all Python versions from 1.52 - 2.4, and the license 
generally encompasses all other language bindings, too (all being at 
version 4.0 except for the C++ version which is currently still at 3.04).

Still, you should just try it for what you are planning to use it /for/ 
and see if it meets /your/ specific needs.

--
Vincent Wehren


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


Re: basic tkinter/Windows question

2005-02-22 Thread Vincent Wehren
Paul Rubin wrote:
I find myself having to write some code on Windows :-(.  To alleviate
the pain, at least I get to use Python for some of it.
I'm trying to write a simple application, say "eggs.py".  It pops a
tkinter gui and lets the user do some stuff.  The system has Python
installed so I don't care about wrapping it in a .exe file or anything
like that.  But I'd like to make a desktop icon for eggs.py and let the
user double-click it and run the app without also getting a DOS box on
the screen.
Rename the file "eggs.py" to "eggs.pyw" and create a shortcut to that 
file. The file will be opened using pythonw.exe instead of python.exe.

--
Vincent Wehren

Is there a simple way to do that?  I didn't see anything in the Python
docs about it.  I suspect that this is really a dumb Windows question,
but I avoid Windows whenever I can, so most anything I can ask about it
is probably dumb.
Thanks much.
--
http://mail.python.org/mailman/listinfo/python-list


Re: determine directories with wildcard

2005-03-08 Thread Vincent Wehren
Thomas Rademacher wrote:
Hello,
I want to collect with the wildcard '*' all existing directories.
For example:  /dir/dir/*/dir/*/dir/* or C:\dir\dir\*\dir\*\dir\*
How can I resolve this problem?
Thanks for your hints, Thomas.

You may want to check out the glob module. E.g. something like:
>> import glob, os
>> p = "c:/*/*/site-packages/*"
>> dirs = [d for d in glob.glob(p) if os.path.isdir(d)]
>> print dirs
['c:/Python23\\Lib\\site-packages\\atox', 
'c:/Python23\\Lib\\site-packages\\BDBStorage', 
'c:/Python23\\Lib\\site-packages\\BitTorrent', 
'c:/Python23\\Lib\\site-packages\\BTrees', 
'c:/Python23\\Lib\\site-packages\\ChartDirector', 
'c:/Python23\\Lib\\site-packages\\cjkcodecs', 
'c:/Python23\\Lib\\site-packages\\ctypes', 
'c:/Python23\\Lib\\site-packages\\CVS', 
'c:/Python23\\Lib\\site-packages\\elementtree', 
'c:/Python23\\Lib\\site-packages\\enchant', 
'c:/Python23\\Lib\\site-packages\\Ft', 
'c:/Python23\\Lib\\site-packages\\imdb', 
'c:/Python23\\Lib\\site-packages\\isapi', 
'c:/Python23\\Lib\\site-packages\\logilab', 
'c:/Python23\\Lib\\site-packages\\mx', 
'c:/Python23\\Lib\\site-packages\\MySQLdb', 
'c:/Python23\\Lib\\site-packages\\numarray', 
'c:/Python23\\Lib\\site-packages\\OpenGL', 
'c:/Python23\\Lib\\site-packages\\OpenGLContext', 
'c:/Python23\\Lib\\site-packages\\parallel', 
'c:/Python23\\Lib\\site-packages\\Persistence', 
'c:/Python23\\Lib\\site-packages\\PIL', 
'c:/Python23\\Lib\\site-packages\\psyco', 
'c:/Python23\\Lib\\site-packages\\py2exe', 
'c:/Python23\\Lib\\site-packages\\pychecker', 
'c:/Python23\\Lib\\site-packages\\pynsource', 
'c:/Python23\\Lib\\site-packages\\Pyrex', 
'c:/Python23\\Lib\\site-packages\\Pyro', 
'c:/Python23\\Lib\\site-packages\\pythonwin', 
'c:/Python23\\Lib\\site-packages\\pywin32_system32', 
'c:/Python23\\Lib\\site-packages\\pyXLWriter', 
'c:/Python23\\Lib\\site-packages\\reportlab', 
'c:/Python23\\Lib\\site-packages\\serial', 
'c:/Python23\\Lib\\site-packages\\spambayes', 
'c:/Python23\\Lib\\site-packages\\ThreadedAsync', 
'c:/Python23\\Lib\\site-packages\\vrml', 
'c:/Python23\\Lib\\site-packages\\win32', 
'c:/Python23\\Lib\\site-packages\\win32com', 
'c:/Python23\\Lib\\site-packages\\win32comext', 
'c:/Python23\\Lib\\site-packages\\wx', 
'c:/Python23\\Lib\\site-packages\\wxPython', 
'c:/Python23\\Lib\\site-packages\\ZConfig', 
'c:/Python23\\Lib\\site-packages\\zdaemon', 
'c:/Python23\\Lib\\site-packages\\ZEO', 
'c:/Python23\\Lib\\site-packages\\zLOG', 
'c:/Python23\\Lib\\site-packages\\ZODB', 
'c:/Python23\\Lib\\site-packages\\ZopeUndo', 
'c:/Python23\\Lib\\site-packages\\_xmlplus', 
'c:/Python24\\Lib\\site-packages\\ChartDirector', 
'c:/Python24\\Lib\\site-packages\\elementtidy', 
'c:/Python24\\Lib\\site-packages\\elementtree', 
'c:/Python24\\Lib\\site-packages\\isapi', 
'c:/Python24\\Lib\\site-packages\\py2exe', 
'c:/Python24\\Lib\\site-packages\\pythonwin', 
'c:/Python24\\Lib\\site-packages\\pywin32_system32', 
'c:/Python24\\Lib\\site-packages\\win32', 
'c:/Python24\\Lib\\site-packages\\win32com', 
'c:/Python24\\Lib\\site-packages\\win32comext', 
'c:/Python24\\Lib\\site-packages\\wx-2.5.3-msw-unicode']

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


Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-11 Thread Vincent Wehren
Martin v. Löwis wrote:
Anthony Baxter wrote:
On behalf of the Python development team and the Python community, I'm
happy to announce the release of Python 2.4.1 (release candidate 1).
Python 2.4.1 is a bug-fix release. See the release notes at the website
(also available as Misc/NEWS in the source distribution) for details of
the bugs squished in this release.

I'd like to encourage feedback on whether the Windows installer works
for people. It replaces the VBScript part in the MSI package with native
code, which ought to drop the dependency on VBScript, but might
introduce new incompatibilities.
Regards,
Martin
Hi Martin,
is there a reason why msiexec iterates through what looks like all (?) 
files and directories in/under the destination directory? There is 
massive file I/O going on there (OK, by now you know I didn't de-install 
2.4 before trying ;-)) which explains the 100% CPU usage and the time it 
takes for the Next button to respond.

--
Vincent Wehren

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


Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-11 Thread Vincent Wehren
steve wrote:
In a nutshell, my problem is that I am getting this runtime error, and
I have no clue why.  Please bear in mind its my first python program:
"localvariable 'currentAbility' referenced before asignment"
If you're assigning an object to a name, it will be assigned to that 
name in local namespace. So, in your case, you are doing augmented 
assignment on a local name that does not yet exist (hence the error 
message). You need to tell the interpreter that what you want is assign 
to that name in global namespace. You can do this by using the 'global' 
statement, as in:

>>> my_global = 1
>>> def some_func():
...global my_global
...my_global += 1
>> some_func()
>> my_global
2
--
Vincent Wehren
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-13 Thread Vincent Wehren
Martin v. Löwis wrote:
Vincent Wehren wrote:
is there a reason why msiexec iterates through what looks like all (?) 
files and directories in/under the destination directory? There is 
massive file I/O going on there (OK, by now you know I didn't 
de-install 2.4 before trying ;-)) which explains the 100% CPU usage 
and the time it takes for the Next button to respond.

I think it is trying to estimate disk usage. To compute the disk usage
correctly, you need to find out
- what files are new files
- what files are going to be deleted
- what files are goging to be replaced
- what files are going to stay

Ah! Thanks for explaining. So this also explains why the indicated 
required disk space on the Customize dialog with the "Python" item 
selected was a mere 673kb (or was it 637kb - don't recall exactly) - 
this must the size difference between 2.4.0 and 2.4.1 then...

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


  1   2   3   4   5   6   >