Re: python vs java eclipse

2006-12-02 Thread Philippe Martin
Amir  Michail wrote:

 Hi,
 
 It seems to me that measuring productivity in a programming language
 must take into account available tools and libraries.
 
 Eclipse for example provides such an amazing IDE for java that it is no
 longer obvious to me that one would be much more productive in python
 for medium sized projects.
 
 Sure, all that Java static typing can be painful, but Eclipse takes
 some of that pain away. Moreover, static typing can result in better
 on-the-fly error detection and refactoring support.
 
 Any thoughts on this?
 
 Amir

FYI: http://showmedo.com/videos/series?name=PyDevEclipseList

hg

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


Re: key not found in dictionary

2006-08-22 Thread Philippe Martin
KraftDiner wrote:

 I have a dictionary and sometime the lookup fails...
 it seems to raise an exception when this happens.
 What should I do to fix/catch this problem?
 
 desc = self.numericDict[k][2]
 KeyError: 589824    This is the error that is being produced,
 because there is no key
 589824.

If you agree that the key is not there, then just catch the exception
(try ... except)

Philippe

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


Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread Philippe Martin
many_years_after wrote:

 Hi,everyone:
 
  Have you any ideas?
 
  Say whatever you know about this.
 
 
 thanks.
Hi,

You mean unicode I assume:
http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml

Regards,

Philippe

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


Re: text editor suggestion?

2006-08-19 Thread Philippe Martin
John Salerno wrote:

 Ok, I know it's been asked a million times, but I have a more specific
 question so hopefully this won't be just the same old post. I've tried a
 few different editors, and I really like UltraEdit, but it's
 Windows-only and I'm working more on Linux nowadays.
 
 Here are my criteria:
 
 1. syntax highlighting (highly customizable)
 2. auto/smart indenting
 3. ability to run script
 4. light-weight text editor, not an IDE
 5. cross-platform (not really necessary, but nice)
 
 That's pretty much all I need. It's nice when you can customize a bunch
 of other stuff too, but those are the most important.
 
 I've tried vim, but I really don't feel like taking the time to learn
 how to use it, given that I just like to casually program (not to
 mention that I prefer to use the mouse when navigating a document
 sometimes).
 
 I also just started using Scite, and I really like it, except I find its
 syntax highlighting to be very inflexible. You aren't able to define
 your own groups of words -- you have to use what's given, basically. One
 thing I like about UltraEdit is that you simply define as many groups of
 keywords as you want and then assign a style to each one. Scite has a
 very strange and rigid method of highlighting.
 
 So hopefully some of you might have some suggestions. My requirements
 are minimal, but I'm still not happy with the syntax highlighting I'm
 seeing in a lot of editors out there.


Emacs would be my choice.

Philippe

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


Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread Philippe Martin
Philippe Martin wrote:

 many_years_after wrote:
 
 Hi,everyone:
 
  Have you any ideas?
 
  Say whatever you know about this.
 
 
 thanks.
 Hi,
 
 You mean unicode I assume:
 http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml
 
 Regards,
 
 Philippe

Hi, 

I have received a personnal email on this:

Kanji is indeed a Japanese subset of the Chinese Character set.

I just thought it would be relevant as it includes ~47000 characters.

If I hurt any feeling, sorry.

Regards,

Philippe

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


Re: write eof without closing

2006-08-19 Thread Philippe Martin
cage wrote:

 hello
 
 can i write a eof to a file descriptor without closing it?
 like:
 fd.write(EOF)
 or something
 
 grts,
 ruben

No but there is an EOF to the file anyway, even if it is open.

I recall under MS-DOS, you could create a file of size N without writing to
it (some INT21 or 9 ? call to modify the FAT) ... not really possible
anymore.

Philippe


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


Re: The Semicolon Wars as a software industry and human condition

2006-08-17 Thread Philippe Martin


It was philosophers that got us out of that Dark Ages mess, and no small
number of them lost their lives in doing so. And today, the philosophy
majors are the butts of the most jokes, because after the philosophers
succeeded in opening our minds, we forgot why we needed them.

Look east Xah, we're still in the Dark Ages mess.


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


Re: How to fill a form

2006-08-17 Thread Philippe Martin
Sulsa wrote:

 On Tue, 15 Aug 2006 03:37:02 -
 Grant Edwards [EMAIL PROTECTED] wrote:
 
 On 2006-08-15, Sulsa [EMAIL PROTECTED] wrote:
 
  I want to fill only one smiple form so i would like not to use
  any non standard libraries.
 
 Then just send the HTTP POST request containing the fields
 and data you want to submit.
 
 but i don't know how to post these data if i knew there there would
 be no topic.
You forgot thanks and regards

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


Re: hide python code !

2006-08-15 Thread Philippe Martin
Bayazee wrote:

 
 Armin Steinhoff wrote:
 Bayazee wrote:
  hi
  can we hide a python code ?
  if i want to write a commercial software can i hide my source code from
  users access ?
  we can conver it to pyc but this file can decompiled ... so ...!!
  do you have any idea about this ...?

 Use Pyrex in order to build C-Modules from the critical parts of your
 software.

 
  ---
  First Iranian Open Source Community : www.python.ir

 Interesting ... but you are not a member of this community. Right?

 --Armin
 
 
 Hi
 thanx for your answers . i read all of your replys carefully ...
 i am an open source Programmer ! i love to distribute my sources and
 use other ideas ! but asking a question is't reason of using it ! i
 want to find a way to hide python source codes ! can we do it ? how ?
 but i dont want to use it 
 this is a question that i must be answer to a friend !

Then the answer could be a question: can we hide any source/binary ?

Hardware tokens (ex: smart cards) are used just for that purpose. So as long
as you distribute a PC with your package and are certain it cannot be
tempered with (the correct O/S, administrative rights, encrypted
partitions .) ... but I do not think there is such a PC out there.

You might want to read this:

http://www.commoncriteriaportal.org/
www.commoncriteriaportal.org/public/files/ccintroduction.pdf
http://en.wikipedia.org/wiki/Common_Criteria


Philippe







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


Re: Compiling wxPython app for Windows; Single EXE

2006-08-14 Thread Philippe Martin
Vincent Delporte wrote:

 Hi
 
 I browsed the archives, but since some messages date back a bit, I
 wanted to make sure that
 
 - py2exe is still the best tool in town to compile Python scripts to
 run on a Windows host that doesn't have Python installed, including
 wxWidgets/wxPython
 
 - there's no way to build a single EXE, to make deployment easier (if
 multiple files, I need to build an installer with eg. NSIS or
 InnoSetup)?
 
 Thank you.

Hi,

Yes there is a way to make one .exe/.msi for everything ... but it does
require purchasing a tool such as VC++.

I have python + wxWindows + my stuff + many other libraries in one installer
(takes 120 Megs (sigh))

Philippe

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


Re: Tkinter module not found

2006-08-11 Thread Philippe Martin
Shuaib wrote:

 Hey,
 
 Even though I freshly installed Tcl and Tk, python still seem to have
 problems accessing Tkinter module. Here is what says when I do import
 Tkinter
 
 ==
 Traceback (most recent call last):
   File stdin, line 1, in ?
 ImportError: No module named Tkinter
 ==
 
 Any ideas how to fix this problem? (Gentoo distribution)
 
 Thanks.
That happened once to me when I compiled python without tcl/tk installed
(prior to compiling)


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


Re: hide python code !

2006-08-11 Thread Philippe Martin
Bayazee wrote:

 hi
 can we hide a python code ?
 if i want to write a commercial software can i hide my source code from
 users access ?
 we can conver it to pyc but this file can decompiled ... so ...!!
 do you have any idea about this ...?
 
 ---
 First Iranian Open Source Community : www.python.ir

Unless you have some very specific (patent-prone) algo in your code, I do
not think you really have an issue there: *.pyc is enough to disturb most
people.

The real danger I see is a company trying to copy your concept as the real
IP (assuming the above is true) is in your specifications ... which can be
re-designed from looking at your application: I buy one legal copy of your
stuff, put a few smart guys on the deal and come up with a competitive
application some time later (I've seen companies do that).




Philippe

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


Re: hide python code !

2006-08-11 Thread Philippe Martin
Bayazee wrote:

 Hi,
 ThnaX for Your Answers ...
 i am an open source programmer ... ! and i never like to write a closed
 source app or hide my codes ! it just a question that i must
 answer/solve it!
 one of site ( www.python.ir ) users asked this question ! but
 unfortunately i have't any solution  to it ! so i ask it here to know
 your concepts ...
 so sorry for my inferior question
 but i realy want to know a way to do it(if it possible) ! and it is't
 mean that i want to do it !
 Best Regard's

Is there such a thing as inferior questions ? only fools do not ask
questions, you clearly do not qualify ... heads up !!!


Philippe

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


Re: New to Python-- Help

2006-08-08 Thread Philippe Martin
John  Mary Cook wrote:

 I just installed Python on Windows XP Pro.  When I enter 'python' at the
  prompt in Pythonwin IDE I get the following:
 
 Traceback (most recent call last):
File interactive input, line 1, in ?
 Name Error: name 'python' is not defined
 
 Can anyone help?
 
 Thank you,
 
 J. T. Cook

Did you install Python, or Pythonwin ?

Cannot use #2 without #1.

Philippe

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


Re: why did wxpython MakeActiveXclass stopped working?!?!!?!?

2006-08-06 Thread Philippe Martin
jojoba wrote:

 HI
 I wrote a little wxpython program with an embedded windows media
 player.
 It worked great. Recently, I reinstalled windows and then wxpython
 (most likely a newer version than i had before). Now when i run the
 exact same code, i get this error:
 
   File C:\Documents and
 Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
 ts\sr.py, line 353, in __init__
 self.CreateActiveXplayer()
   File C:\Documents and
 Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
 ts\sr.py, line 363, in CreateActiveXplayer
 self.Player   = PlayerActiveXClass(self, -1)
   File
 C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\lib\activexwrapper.py,
  line 108, in axw__init__
 (0, 0, sz.width, sz.height), self._wnd, ID)
   File C:\Python24\Lib\site-packages\pythonwin\pywin\mfc\activex.py,
 line 23,
 in CreateControl
 self.__dict__[_obj_] = win32ui.CreateControl(clsid, windowTitle,
 style, re
 ct, parent, id, None, False, lic_string)
 win32ui: The window can not be created as it has an invalid handle
 
 
 Here is a snippet from my code:
 
 from wxPython.lib.activexwrapper import MakeActiveXClass
 import win32com
 from win32com import client
 
 class wxWMPlayer(wxPanel):
 def __init__(self, parent):
 wxPanel.__init__(self, parent, -1,
 style=wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE)
 self.MixMaster = parent
 self.ID3data   = {}
 self.InitWindowProperties()
 self.CreateActiveXplayer()
 
 def InitWindowProperties(self):
 self.WindowsMediaPlayerTopSizer = wxBoxSizer(wxVERTICAL)
 self.SetSizer(self.WindowsMediaPlayerTopSizer)
 self.SetAutoLayout(1)
 
 def CreateActiveXplayer(self):
 PlayerModule  =

win32com.client.gencache.EnsureModule('{6BF52A50-394A-11D3-B153-00C04F79FAA6}',
 0,1,0)
 PlayerActiveXClass=
 MakeActiveXClass(PlayerModule.WindowsMediaPlayer, eventObj = self)
 self.Player   = PlayerActiveXClass(self, -1)
 self.Player.isPlaying = 0
 self.Player.uiMode= 'full'
 self.WindowsMediaPlayerTopSizer.Add(self.Player, 1, wxEXPAND)
 
 
 Any ideas anyone...i have reinstalled wxpython to no availPlease
 help anyone
 thanks,
 jojoba


Did you reinstall pywin32 ?

Philippe


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


Re: why did wxpython MakeActiveXclass stopped working?!?!!?!?

2006-08-06 Thread Philippe Martin
Philippe Martin wrote:

 jojoba wrote:
 
 HI
 I wrote a little wxpython program with an embedded windows media
 player.
 It worked great. Recently, I reinstalled windows and then wxpython
 (most likely a newer version than i had before). Now when i run the
 exact same code, i get this error:
 
   File C:\Documents and
 Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
 ts\sr.py, line 353, in __init__
 self.CreateActiveXplayer()
   File C:\Documents and
 Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
 ts\sr.py, line 363, in CreateActiveXplayer
 self.Player   = PlayerActiveXClass(self, -1)
   File
 C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\lib\activexwrapper.py,
  line 108, in axw__init__
 (0, 0, sz.width, sz.height), self._wnd, ID)
   File C:\Python24\Lib\site-packages\pythonwin\pywin\mfc\activex.py,
 line 23,
 in CreateControl
 self.__dict__[_obj_] = win32ui.CreateControl(clsid, windowTitle,
 style, re
 ct, parent, id, None, False, lic_string)
 win32ui: The window can not be created as it has an invalid handle
 
 
 Here is a snippet from my code:
 
 from wxPython.lib.activexwrapper import MakeActiveXClass
 import win32com
 from win32com import client
 
 class wxWMPlayer(wxPanel):
 def __init__(self, parent):
 wxPanel.__init__(self, parent, -1,
 style=wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE)
 self.MixMaster = parent
 self.ID3data   = {}
 self.InitWindowProperties()
 self.CreateActiveXplayer()
 
 def InitWindowProperties(self):
 self.WindowsMediaPlayerTopSizer = wxBoxSizer(wxVERTICAL)
 self.SetSizer(self.WindowsMediaPlayerTopSizer)
 self.SetAutoLayout(1)
 
 def CreateActiveXplayer(self):
 PlayerModule  =


win32com.client.gencache.EnsureModule('{6BF52A50-394A-11D3-B153-00C04F79FAA6}',
 0,1,0)
 PlayerActiveXClass=
 MakeActiveXClass(PlayerModule.WindowsMediaPlayer, eventObj = self)
 self.Player   = PlayerActiveXClass(self, -1)
 self.Player.isPlaying = 0
 self.Player.uiMode= 'full'
 self.WindowsMediaPlayerTopSizer.Add(self.Player, 1, wxEXPAND)
 
 
 Any ideas anyone...i have reinstalled wxpython to no availPlease
 help anyone
 thanks,
 jojoba
 
 
 Did you reinstall pywin32 ?
 
 Philippe

Well I'm silly: it would not import.




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


Re: embedding console in wxpython app

2006-08-06 Thread Philippe Martin
Janto Dreijer wrote:

 I'm writing a Linux filemanager using wxPython. I'd like to embed a
 bash console inside it. I have found the Logilab pyqonsole
 (http://www.logilab.org/projects/pyqonsole), but it uses PyQT.
 
 Does anyone know how to do this from wx?
 Is it possible to embed a PyQT widget inside wxPython?
 
 Thanks!
 Janto


How about just using bash and rerouting stdin/stdout ?

Philippe

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


Re: why did wxpython MakeActiveXclass stopped working?!?!!?!?

2006-08-06 Thread Philippe Martin
jojoba wrote:

 Hi Phillipe!
 Thanks for the response!
 
 Unfortunately, i have also reinstalled pywin32, and i still get the
 same error.
 
 Isn't this weird?
 You know what else.
 
 I have a py2exe version of this code, that actually runs fine, using
 the embedded windows media player. But Im guessing i made that py2exe
 distributable with older pywin32 and older wxpython.
 This makes me think that one of the newer versions of pywin32 or
 wxpython is giving me that error trouble.
 
 Any other ideas on how to rectify this?
 Thanks again,
 jojoba
 
 
 Philippe Martin wrote:
 Philippe Martin wrote:

  jojoba wrote:
 
  HI
  I wrote a little wxpython program with an embedded windows media
  player.
  It worked great. Recently, I reinstalled windows and then wxpython
  (most likely a newer version than i had before). Now when i run the
  exact same code, i get this error:
 
File C:\Documents and
  Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
  ts\sr.py, line 353, in __init__
  self.CreateActiveXplayer()
File C:\Documents and
  Settings\jojoba.DEMO-019591FB22\Desktop\Projects\SrAsse
  ts\sr.py, line 363, in CreateActiveXplayer
  self.Player   = PlayerActiveXClass(self, -1)
File
  C
\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\lib\activexwrapper.py,
   line 108, in axw__init__
  (0, 0, sz.width, sz.height), self._wnd, ID)
File C:\Python24\Lib\site-packages\pythonwin\pywin\mfc\activex.py,
  line 23,
  in CreateControl
  self.__dict__[_obj_] = win32ui.CreateControl(clsid, windowTitle,
  style, re
  ct, parent, id, None, False, lic_string)
  win32ui: The window can not be created as it has an invalid handle
 
 
  Here is a snippet from my code:
 
  from wxPython.lib.activexwrapper import MakeActiveXClass
  import win32com
  from win32com import client
 
  class wxWMPlayer(wxPanel):
  def __init__(self, parent):
  wxPanel.__init__(self, parent, -1,
  style=wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE)
  self.MixMaster = parent
  self.ID3data   = {}
  self.InitWindowProperties()
  self.CreateActiveXplayer()
 
  def InitWindowProperties(self):
  self.WindowsMediaPlayerTopSizer = wxBoxSizer(wxVERTICAL)
  self.SetSizer(self.WindowsMediaPlayerTopSizer)
  self.SetAutoLayout(1)
 
  def CreateActiveXplayer(self):
  PlayerModule  =
 
 

win32com.client.gencache.EnsureModule('{6BF52A50-394A-11D3-B153-00C04F79FAA6}',
  0,1,0)
  PlayerActiveXClass=
  MakeActiveXClass(PlayerModule.WindowsMediaPlayer, eventObj = self)
  self.Player   = PlayerActiveXClass(self, -1)
  self.Player.isPlaying = 0
  self.Player.uiMode= 'full'
  self.WindowsMediaPlayerTopSizer.Add(self.Player, 1, wxEXPAND)
 
 
  Any ideas anyone...i have reinstalled wxpython to no availPlease
  help anyone
  thanks,
  jojoba
 
 
  Did you reinstall pywin32 ?
  
  Philippe
 
 Well I'm silly: it would not import.

Hi,

I'd post this to [EMAIL PROTECTED]

Philippe





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


Re: [Linux] What toolkit for a good grid/spreadsheet widget?

2006-08-04 Thread Philippe Martin
jean-michel bain-cornu wrote:

 Hi,
 Thx for the two pointers. Are those widgets more than just tables, ie.
 can I edit the contents, including displaying a combo box, can items
 be grouped or hierarchized, or are they just basic, read-only tables
 to display results?
 
 I need this kind of widget to build a 2+ column interface to let users
 type entries into the application as an alternative to MS Access-style
 complicated entry masks.
 
 Wx have got an excellent one. I was succesful to use it with editable
 cells and to include a choice in a cell. However, it was pretty hard to
 reach that, ie to extract a working sample from the demo. Once done
 that, no more problems with it.
 What I suggest you is to have a look on the demo, in the chapter Core
 Windows/Controls - Grid - wx.Grid showing Editors and Renderers.
 Rgds,
 jm

Yes, I can also select which cell can be edited on the cell level.


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


Re: [Linux] What toolkit for a good grid/spreadsheet widget?

2006-08-03 Thread Philippe Martin
Vincent Delporte wrote:

 Hello
 
 I'd like to use Python under Linux to write a business application,
 and I'll need a good grid/spreadsheet editable widget, maybe not on
 par with eg. ComponentOne's excellent VSFlexGrid
 (http://www.componentone.com/newimages/flexgrid_02_lg.gif), but
 somewhat professional-grade.
 
 Any recommendation? GTK doesn't seem to have one that is good enough
 (GTKSheet http://gtkextra.sourceforge.net/ looks like a basic table),
 so I was wondering about QT/PyQt and wxWidgets/wxPython. Any
 recommendation?
 
 Thank you
 VD.


http://www.wxpython.org/

Search for Grid here: http://www.wxpython.org/onlinedocs.php

Regards,

Philippe


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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
  Why are you avoiding naming the chip and its compiler?
 
 I must disagree on that one: There are many threads on this site where
 people just have fun talking algorithm. I'm not an algo. expert and I
 know there are many here.
 
 This is just like the very common situation here and on sci.crypt,
 where a person has a programming or algorithm question and gets asked
 what the application is, and when they answer, it turns out that what
 they need is not anything like what they thought they needed.
 
 on one device, the processor in an 8-bit arm and the X-compiler is made
 by epson
 
 on the other device, the processor is unknown to me and the environment
 is a subset of java made for smartcards called javacard.
 
  You mean ARM?? There is no such thing as an 8-bit ARM; they are
 32-bit cpu's that (in some models) support a 16-bit instruction
 format.
 
 Javacard is an interpreter that runs in many 8-bit processors.  The
 interpreter supports 32-bit arithmetic.

I checked the processor and it is an EPSON 8 bit (SC88 I think).

If you check the javacard specs, you'll see that not all VM support 32 bits.

Regards,
Philipped


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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote:

 
 Philippe Martin wrote:
 
  3. How does the device manage to compute the 8-decimal-digit number
  that is your input??

 What device manager ? think about it before being rude

 
 No device manager [noun] was mentioned. You may have inferred rudeness
 where astonishment was being implied. I'll try again:
 
 How does the [8-bit] device manage [verb, as in how is it able] to
 compute the [32-bit] 8-decimal-digit number that is [split up one
 decimal digit per array element thus becoming] your input??

I get keystrokes from the device keyboard and append to the array as needed.

I actually need numbers much larger than 32 bits.

Regards,

Philippe


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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote:

 Philippe Martin wrote:
 

 Yes I had arm in mind (for some reason) while it is the Smc8831

(http://www.google.com/url?sa=Ustart=1q=http://www.epsondevice.com/www/PDFS/epdoc_ic.nsf/5388db40b5eee4f949256a9c001d589f/944b73008b0bad33492570a00015d6ba/%24FILE/S5U1C88000C_2Ev3.pdfe=9797)
 
 That appears to be volume 2 of the 2-volume set of manuals that come
 with the tools package. It says that vol 1 has details about the C
 compiler.
 
 This appears to be volume 1:

http://www.epsondevice.com/www/PDFS/epdoc_ic.nsf/5388db40b5eee4f949256a9c001d589f/1410881ddee374f7492570a00015d65e/$FILE/C88000C_1Ev3.pdf
 
 Section 1.2.3 Data Types mentions unsigned and signed long (32-bit)
 data types. There are several references to long later, including
 declarations in sample C code, and details of how long (32-bit)
 function args are passed.
 
 There appears to be a fundamental disconnection here somewhere ...

Just trust me John, I do not have access to 32 bit ints/longs.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 I actually need numbers much larger than 32 bits.
 
 What is the max size hex number you need?  What is the application if
 you don't mind my asking?

Well I am under NDA so I cannot tell you what the application is - I need
numbers (dec) with up to 24 digits.

As I said, I went the other way - more data on the line (from dev 1 to dev
2) - but I feel there is no speed issue at this stage.

Seems to work.


Regards,

Philippe



 PYTHON **
l2 = [1,2,3,4]
l1 = [0,2,5,9]


def sup (l1, l2): #assume same length
for i in range(len(l1) ):
if l1[i]  l2[i]:
return 1
if l1[i]  l2[i]:
return -1
return 0



def add (l1, l2): #assume same length
r = []
idx =  range (len(l1))
idx.reverse()
carry = 0
for i in idx:

if l1[i] + l2[i]  10:
carry = 1
r.insert(0,(l1[i] + l2[i]) % 10)
else:
r.insert(0,l1[i] + l2[i] + carry)
carry = 0
return r



def sub (l1,l2): #assume same length - sub l1 from l2
r = []
idx =  range (len(l1))
idx.reverse()
carry = 0
for i in idx:
print l1[i] + carry, l2[i]
if ((l2[i]) - (l1[i]+carry)  0) :
print 'CARRY'
r.insert(0,(((10 + l2[i])  - (l1[i]+carry
carry = 1
else:
r.insert(0,(l2[i]) - (l1[i]+ carry))
carry = 0
return r


print sub (l1,l2)

* AND AM JUST TESTING IT IN JAVACARD **


   
//
public byte CmpD(byte[] p_op1, byte[] p_op2,  byte p_len) {
byte l_count = (byte)0;
for (; l_count  p_len; l_count += 1) {
short C = (short)(p_op1[l_count]);
short D = (short)(p_op2[l_count]);

if (C  D) return 1;
if (C  D) return -1;
}

return 0;

}

//
public static void SubD(byte[] p_op1, byte[] p_op2, byte[] p_dest, byte
p_len) {
byte l_count = (byte)0;
byte l_carry = (byte)0;
for (l_count = (byte)(p_len - (byte)1); l_count = (byte)0; l_count
-= (byte)1) {
if ((p_op2[l_count] - (byte)(p_op1[l_count]+l_carry) )  0) {
p_dest[l_count] = (byte)(  ((byte)10 + p_op2[l_count]) -
(byte)(p_op1[l_count] + l_carry)) ;
l_carry = (byte)1;
}
else {
p_dest[l_count] = (byte)(  p_op2[l_count] - (byte)(p_op
[l_count] + l_carry)) ;
l_carry = -(byte)0;
}
}

}

//
public static void AddD(byte[] p_op1, byte[] p_op2, byte[] p_dest, byte
p_len) {
byte l_count = (byte)0;
byte l_carry = (byte)0;
for (l_count = (byte)(p_len - (byte)1); l_count = (byte)0; l_count
-= (byte)1) {
if (p_op2[l_count] + (byte)(p_op1[l_count])  10) {
p_dest[l_count] = (byte)( ( p_op2[l_count] + p_op
[l_count] )% 10) ;
l_carry = (byte)1;
}
else {
p_dest[l_count] = (byte)(  p_op2[l_count] + p_op1[l_count] +
l_carry) ;
l_carry = -(byte)0;
}
}

}   








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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 Well I am under NDA so I cannot tell you what the application is - I need
 numbers (dec) with up to 24 digits.
 
 You actually need to represent numbers up to 10**24??
 
 As I said, I went the other way - more data on the line (from dev 1 to
 dev 2) - but I feel there is no speed issue at this stage.
 
 What are your memory constraints?

On device #1 no constraint for my purpose. On the smartcard, the tradeoff is
between using EEPROM (plenty + slow + small life expectancy) for temp
variables versus RAM (very little) ... but I do not think it is an issue
eather in my case. Speed is what worries me most (crypto takes time).

But so far so good.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 Well I am under NDA so I cannot tell you what the application is - I need
 numbers (dec) with up to 24 digits.
 
 You actually need to represent numbers up to 10**24??
 
 As I said, I went the other way - more data on the line (from dev 1 to
 dev 2) - but I feel there is no speed issue at this stage.
 
 What are your memory constraints?
PS: in smart cards, you count RAM in hundreds of bytes and EEPROM in
K-bytes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 On device #1 no constraint for my purpose. On the smartcard, the tradeoff
 is between using EEPROM (plenty + slow + small life expectancy) for temp
 variables versus RAM (very little) ... but I do not think it is an issue
 eather in my case. Speed is what worries me most (crypto takes time).
 
 You should not have to do this decimal-hex conversion repeatedly in a
 crypto operation.  Do you have a public-key accelerator (or MAC unit)
 on that cpu?  Do you really care about speed?  I had thought up a cute
 O(n**3) scheme that might have been ok for 8 digits but probably not
 for 24.

I did not explain myself correctly, the decimal operations are done in
clear mode as they are made within the cards which by definition cannot
be broken, requests and results that go to/from the devices are
encrypted/signed with diversified keys ... but that another story ;-)

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
[EMAIL PROTECTED] wrote:

 
 Philippe Martin wrote:
 Yes, I came here for the algorithm question, not the code result.
 
 To turn BCD x to binary integer y,
 
   set y to zero
   for each nibble n of x:
 y = (((y shifted left 2) + y) shifted left 1) + n
 
 Do you need instruction on extracting nibbles, and shifting and
 adding integers?
 
 A problem this small and simple does not call for a prototype.
 
 
 --
 --Bryan
'cause you're smart

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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote:

 So why don't you get a freely available bignum package, throw away
 the bits you don' t want, and just compile it and use it, instead of
 writing your own bug-ridden (see below) routines? Oh yeah, the bignum
 package might use long and you think that you don't have access to
 32-bit longs in the C compiler for the 8-bit device that you mistook
 for an arm but then said is an Smc8831 [Google can't find it] with a
 CPU that you think is a SC88 [but the manual whose URL you gave is for
 an S1C88] ...
 

Thanks for the fixes - still looking at it.

You are correct, all bignum packages I found needed 32 bits.

Yes I still see from my documentation that there is no long handled by my
compiler.

I did make a mistake on the CPU (and I really do not care what it is) - you
wanted some ref (I still do not see why) and I googled S1C88 and sent you a
link as that is the name of the compiler's directory.

The reason I first came here was to not have to write my ... own
bug-ridden ... (how nice) ... I have plenty of other bugs to write first.



 *** WHAT HAPPENS IF arg1  arg2?

cmp is called first.

Regards,


Philippe



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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
Sorry forgot a few answers/comments:

John Machin wrote:
 SHOULD BE =
currently add([6, 6], [4, 4] - [10, 10]

True, thanks

 *** try - 10 instead of % 10
 If the first operand is  19, you have a bug!
 This might save a few CPU cycles on your smartcard

can it ? each array value will be [0..9]

 SHOULD CHECK FOR CARRY AT END
currently add([9], [8]) - [7]
should return [1, 7] or handle overflow somehow

True, this actually should become an error from the card to the calling
device. That would be a pretty large number though.


 MINUS ZERO?
I just do not want to leave it at one(1) if it is.


Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote:


 Have you actually tried it? Do you mean it barfs on the word long
 [meaning that it's not an ANSI-compliant C compiler], or that long is
 only 16 bits?

:-) if the documentation tells me there is no 32 bit support, why should I
not believe it ?

 because (1) [like I said before] gcc appears to be able to generate
 code for a vast number of different CPUs (2) because I find it very
 difficult to believe that a C compiler for the CPU on a device in
 current use won't support 32-bit longs -- and so far you have presented
 no credible evidence to the contrary

I can recall working on a sparclite many years ago (32 bits) with a
x-compiler called g++ (supported by cygnus) that handled the type long
long = 64 bits.

As far as the credible evidence ... you're hurting my feelings ;-)

 
  and I googled S1C88 and sent you a
 link as that is the name of the compiler's directory.
 
 and is that or is it not the correct link for the documentation for the
 compiler that you are using??
 

Neither can I ! - never found any documentation online ... got it from my
device supplier.

Regards,

Philippe


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


Re: BCD List to HEX List

2006-07-31 Thread Philippe Martin
John Machin wrote:

 
 Simon Forman wrote:
 Philippe, please!  The suspense is killing me.  What's the cpu!?

 For the love of God,  what's the CPU?

 I-can't-take-it-anymore-it's-such-a-simple-question-ingly yours,
 
 Yes, please .
 
 I've found a C compiler manual on the web for the Epson S1C33 CPU as
 well as the one for the S1C88 that Philippe pointed me at. They have
 two things in common:
 (1) explicitly mention support for 32-bit longs
 (2) in the bottom right corner of most pages, it has the part number
 (which includes S1Cxx) and the version number.
 
 Philippe has what he believes to be the manual for the C compiler for
 the CPU in the device,  but couldn't find it on the web.
 
 Perhaps if Philippe could divulge the part number that's in the bottom
 right corner of the manual that he has, and/or any part number that
 might be mentioned in the first few pages of that manual, enlightenment
 may ensue 
 
 Cheers,
 John


That was cute ... over and out !

Long live Python.

A+

Philippe

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


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

2006-07-30 Thread Philippe Martin
zxo102 wrote:

 Hi everyone,
 I am using a python socket server to collect data from a socket
 client and then control a image location ( wxpython) with the data,
 i.e. moving the image around in the wxpython frame.
But  the app.MainLoop() in wxpython looks like conflicting with
 the while 1: in socket server. After I commented the
 app.MainLoop(), everything is working except two things:
  1. if I click anywhere on the screen with the mouse, the image is
 gong and only the empty frame( or panel) is left.
  2. if I don't  touch anything, the image is being moved around but
 the previous images are left behind in the panel.
 I guess that may be caused by app.MainLoop() commented.
Anybody knows how to make the two things work together? I really
 appreciate your help.
My sample code is modified based on the wxpython demo: image.py.
 socket client is also attached for your reference.
 
 Ouyang
 
  socket server with wxpython ##
 
 from Main import opj
 import wx,string
 class MMCS(wx.Frame):
 def __init__(self):
 self.bmp = wx.Image(opj('bitmaps/image.bmp'),
 wx.BITMAP_TYPE_BMP)
 self.bmp.SetMask(True)
 wx.Frame.__init__(self, parent=None, title='monitoring system',
 size=(500,600))
 self.panel = wx.Panel(self,-1)
 
 def monitor(self,x,y,angle):
 bmp = self.bmp.Rotate(angle, (x,y), True,None)
 bmp = bmp.ConvertToBitmap()
 
 wx.StaticBitmap(self.panel, -1, bmp, (x, y), (bmp.GetWidth(),
 bmp.GetHeight()))
 del bmp
 
 app = wx.PySimpleApp()
 frame = MMCS()
 frame.Show()
 frame.monitor(50,10,0.0)
 #app.MainLoop()
 
 # Server program
 from socket import *
 # Set the socket parameters
 host = 192.168.0.2
 port = 21567
 buf = 1024
 addr = (host,port)
 
 # Create socket and bind to address
 UDPSock = socket(AF_INET,SOCK_DGRAM)
 UDPSock.bind(addr)
 
 # Receive messages
 while 1:
 data,addr = UDPSock.recvfrom(buf)
 if not data:
 print Client has exited!
 break
 else:
 print \nReceived message ', data,'
  d = string.split(data, '-')
 
 frame.monitor(string.atoi(d[0]),string.atoi(d[1]),string.atof(d[2]))
 if data == 'END':
 print end of moving the ship
 
 # Close socket
 UDPSock.close()
 
 # socket client ##
 rom socket import *
 import time
 
 # Set the socket parameters
 host = 192.168.0.2
 port = 21567
 buf = 1024
 addr = (host,port)
 
 # Create socket
 UDPSock = socket(AF_INET,SOCK_DGRAM)
 def_msg = ===Enter message to send to server===;
 print \n,def_msg
 
 # Send messages
 while (1):
   for i in range(100):
time.sleep(1)
 data = 50-100-%s%(0.1*i)
 if(UDPSock.sendto(data,addr)):
 print Sending message ',data,'.
 # Close socket
 UDPSock.close()


If you get rid of app.MaiLoop(), you basically get rid of all GUI events.
You need to have you server in a separate thread.

Philippe


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


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

2006-07-30 Thread Philippe Martin
Philippe Martin wrote:

 zxo102 wrote:
 
 Hi everyone,
 I am using a python socket server to collect data from a socket
 client and then control a image location ( wxpython) with the data,
 i.e. moving the image around in the wxpython frame.
But  the app.MainLoop() in wxpython looks like conflicting with
 the while 1: in socket server. After I commented the
 app.MainLoop(), everything is working except two things:
  1. if I click anywhere on the screen with the mouse, the image is
 gong and only the empty frame( or panel) is left.
  2. if I don't  touch anything, the image is being moved around but
 the previous images are left behind in the panel.
 I guess that may be caused by app.MainLoop() commented.
Anybody knows how to make the two things work together? I really
 appreciate your help.
My sample code is modified based on the wxpython demo: image.py.
 socket client is also attached for your reference.
 
 Ouyang
 
  socket server with wxpython ##
 
 from Main import opj
 import wx,string
 class MMCS(wx.Frame):
 def __init__(self):
 self.bmp = wx.Image(opj('bitmaps/image.bmp'),
 wx.BITMAP_TYPE_BMP)
 self.bmp.SetMask(True)
 wx.Frame.__init__(self, parent=None, title='monitoring system',
 size=(500,600))
 self.panel = wx.Panel(self,-1)
 
 def monitor(self,x,y,angle):
 bmp = self.bmp.Rotate(angle, (x,y), True,None)
 bmp = bmp.ConvertToBitmap()
 
 wx.StaticBitmap(self.panel, -1, bmp, (x, y), (bmp.GetWidth(),
 bmp.GetHeight()))
 del bmp
 
 app = wx.PySimpleApp()
 frame = MMCS()
 frame.Show()
 frame.monitor(50,10,0.0)
 #app.MainLoop()
 
 # Server program
 from socket import *
 # Set the socket parameters
 host = 192.168.0.2
 port = 21567
 buf = 1024
 addr = (host,port)
 
 # Create socket and bind to address
 UDPSock = socket(AF_INET,SOCK_DGRAM)
 UDPSock.bind(addr)
 
 # Receive messages
 while 1:
 data,addr = UDPSock.recvfrom(buf)
 if not data:
 print Client has exited!
 break
 else:
 print \nReceived message ', data,'
  d = string.split(data, '-')
 
 frame.monitor(string.atoi(d[0]),string.atoi(d[1]),string.atof(d[2]))
 if data == 'END':
 print end of moving the ship
 
 # Close socket
 UDPSock.close()
 
 # socket client ##
 rom socket import *
 import time
 
 # Set the socket parameters
 host = 192.168.0.2
 port = 21567
 buf = 1024
 addr = (host,port)
 
 # Create socket
 UDPSock = socket(AF_INET,SOCK_DGRAM)
 def_msg = ===Enter message to send to server===;
 print \n,def_msg
 
 # Send messages
 while (1):
   for i in range(100):
time.sleep(1)
 data = 50-100-%s%(0.1*i)
 if(UDPSock.sendto(data,addr)):
 print Sending message ',data,'.
 # Close socket
 UDPSock.close()
 
 
 If you get rid of app.MaiLoop(), you basically get rid of all GUI events.
 You need to have you server in a separate thread.
 
 Philippe
PS:

http://wiki.wxpython.org/index.cgi/LongRunningTasks

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


BCD List to HEX List

2006-07-30 Thread Philippe Martin
Hi,

I'm looking for an algo that would convert a list such as:

I'm using python to prototype the algo: this will move to C in an embedded
system where an int has 16 bits - I do not wish to use any python library.

l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
l2 = func (l1)
# l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687


Regards,

Philippe

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


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

2006-07-30 Thread Philippe Martin
Grant Edwards wrote:

 On 2006-07-30, Philippe Martin [EMAIL PROTECTED] wrote:
 
 If you get rid of app.MaiLoop(), you basically get rid of all GUI events.
 You need to have you server in a separate thread.
 
 Isn't there any way to use wxWidgets socket callbacks in wxPython?
 
 --
 Grant Edwards   grante Yow!  I'm wearing
 PAMPERS!!
   at
visi.com

If I understand correctly, I guess you can send an event to the main thread
to tell it there was data received.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Marc 'BlackJack' Rintsch wrote:

 In [EMAIL PROTECTED], Philippe Martin wrote:
 
 I'm looking for an algo that would convert a list such as:
 
 I'm using python to prototype the algo: this will move to C in an
 embedded system where an int has 16 bits - I do not wish to use any
 python library.
 
 l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
 l2 = func (l1)
 # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
 
 def func(x):
 result = list(x)
 result[2:4] = [0xd]
 result[-1], result[-2] = result[-2], result[-1]
 return result
 
 l1 = [1, 2, 3, 4, 6, 7, 8]
 l2 = func(l1)
 print l2
 
 And now please describe you problem a little better.  ;-)
 
 Ciao,
 Marc 'BlackJack' Rintsch

I'll try.

first of all python is not going to be used for my purpose (sigh)

I have device A which holds a binary coded decimal array [N1,N2,Nn]
where the array represents a decimal number.

In C: unsigned char dec[] = {1,2,3,4,5,6,7,8};

I need that array converted for device B into an array where each element
represents the actual byte value.

In C: the result would be unsigned char hex[] = {0x1,0x2,0xD,0x6,0x8,0x7};

I guess any pocket calculator goes through that process for dec/hex
conversion.

Hope that's clearer.

Regards,

Philippe



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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Marc 'BlackJack' Rintsch wrote:

 In [EMAIL PROTECTED], Philippe Martin wrote:
 
 Marc 'BlackJack' Rintsch wrote:
 
 And now please describe you problem a little better.  ;-)
 
 I'll try.
 
 first of all python is not going to be used for my purpose (sigh)
 
 I have device A which holds a binary coded decimal array [N1,N2,Nn]
 where the array represents a decimal number.
 
 In C: unsigned char dec[] = {1,2,3,4,5,6,7,8};
 
 I need that array converted for device B into an array where each element
 represents the actual byte value.
 
 In C: the result would be unsigned char hex[] =
 {0x1,0x2,0xD,0x6,0x8,0x7};
 
 I guess any pocket calculator goes through that process for dec/hex
 conversion.
 
 Hope that's clearer.
 
 Not really.  Maybe I'm missing something obvious but I don't see the link
 between your `dec` and `hex` values.  12345678 converted to hex is
 bc614e.  Do you need such a conversion?  And should the result really be
 one nibble (4 bit)/hex digit per array entry!?
 
 Ciao,
 Marc 'BlackJack' Rintsch

My apologies, I clearly made a mistake with my calculator, yes the resulting
array I would need is [0xb,0xc,0x6,0x1,0x4,0xe]

Regards,

Philippe



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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 Philippe Martin wrote:
 Hi,

 I'm looking for an algo that would convert a list such as:
 
 Such as what?
 

 I'm using python to prototype the algo: this will move to C in an
 embedded system where an int has 16 bits - I do not wish to use any
 python library.

 l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
 
 Does it??? How do you represent the decimal number 12349678, then?
 
 l2 = func (l1)
 # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687

 
 I'm sorry, but very little of that makes any sense to me:
 
 1. I thought BCD meant something very much like this:
 http://en.wikipedia.org/wiki/Binary-coded_decimal
 
 2.  [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
 [1, 2, 13, 6, 8, 7]
 
 So [1], [2], [6] are unchanged, [3, 4] - [13] (or maybe [3, 4, 5] -
 13),  and [7, 8] - [8,7].
 
 I doubt very much that there's an algorithm to do that. What is the
 relationship between 1234(maybe 5)678 and 0x12D687??? I would expect
 something like this::
 
 0x12345678 (stored in 4 bytes 0x12, ..., 0x78)  -- or 0x21436587
 or
 0x012345678s (where s is a sign nibble; stored in 5 bytes 0x01,
 ..., 0x8s)
 
 IOW something regular and explicable ...
 
 3. Perhaps it might be a good idea if you told us what the *real*
 problem is, including *exact* quotes from the manual for the embedded
 system. You evidently need/want to convert from one representation of
 signed? unsigned? integers to another. Once we all understand *what*
 those representations are, *then* we can undoubtedly help you with
 pseudocode in the form of Python code manipulating lists or whatever.
 
 Cheers,
 John


Hi,

From my answer to Marc:

My apologies, I clearly made a mistake with my calculator, yes the
resulting
array I would need is [0xb,0xc,0x6,0x1,0x4,0xe]



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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 I'm using python to prototype the algo: this will move to C in an
 embedded system where an int has 16 bits - I do not wish to use any
 python library.
 
 l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
 
 This is untested, but should give you the idea:
 
 First, convert that list to a decimal digit string:
 
s = ''.join(map(str, l1))
 
 Then convert the string to an integer:
 
n = int(s)# base 10 is the default
 
 Then convert the integer to a hex digit string:
 
h = '%X' % n
 
 Finally, convert the hex digit string to a list of integer values of the
 individual digits:
 
vlist = [int(d, 16) for d in h]
 
 This is the list you want.
 
 If you prefer, You can do it all in one line:
 
vlist = [int(d, 16) for d in ('%X' % int(''.join(map(str, l1]

Thanks Paul,

I'm just using Python to prototype, so I cannot use any of these great
features of the language.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 Philippe Martin wrote:
 John Machin wrote:

  Philippe Martin wrote:
  Hi,
 
  I'm looking for an algo that would convert a list such as:
 
  Such as what?
 
 
  I'm using python to prototype the algo: this will move to C in an
  embedded system where an int has 16 bits - I do not wish to use any
  python library.
 
  l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
 
  Does it??? How do you represent the decimal number 12349678, then?
 
  l2 = func (l1)
  # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
 
 
  I'm sorry, but very little of that makes any sense to me:
 
  1. I thought BCD meant something very much like this:
  http://en.wikipedia.org/wiki/Binary-coded_decimal
 
  2.  [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
  [1, 2, 13, 6, 8, 7]
 
  So [1], [2], [6] are unchanged, [3, 4] - [13] (or maybe [3, 4, 5] -
  13),  and [7, 8] - [8,7].
 
  I doubt very much that there's an algorithm to do that. What is the
  relationship between 1234(maybe 5)678 and 0x12D687??? I would expect
  something like this::
 
  0x12345678 (stored in 4 bytes 0x12, ..., 0x78)  -- or 0x21436587
  or
  0x012345678s (where s is a sign nibble; stored in 5 bytes 0x01,
  ..., 0x8s)
 
  IOW something regular and explicable ...
 
  3. Perhaps it might be a good idea if you told us what the *real*
  problem is, including *exact* quotes from the manual for the embedded
  system. You evidently need/want to convert from one representation of
  signed? unsigned? integers to another. Once we all understand *what*
  those representations are, *then* we can undoubtedly help you with
  pseudocode in the form of Python code manipulating lists or whatever.
 
  Cheers,
  John


 Hi,

 From my answer to Marc:

 My apologies, I clearly made a mistake with my calculator, yes the
 resulting
 array I would need is [0xb,0xc,0x6,0x1,0x4,0xe]

 
 Clearly? I don't think that word means what you think it means :-)
 
 All you need is something like the following. You will need to use
 long if the C int is only 16 bits.
 
 C:\junktype bcd.py
 def reconstitute_int(alist):
 reg = 0 # reg needs to be 32-bits (or more)
 for digit in alist:
 assert 0 = digit = 9
 reg = reg * 10 + digit
 return reg
 
 def make_hex(anint):
 # anint needs to be 32-bits (or more)
 result = []
 while anint:
 result.append(anint  0xF)
 anint = 4
 return result
 
 def reverse_list(alist):
 n = len(alist)
 for i in xrange(n  1):
 reg1 = alist[n - 1 - i]
 reg2 = alist[i]
 alist[i] = reg1
 alist[n - 1 - i] = reg2
 
 C:\junk
 C:\junkpython
 Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
 on win32
 Type help, copyright, credits or license for more information.
 import bcd
 num = bcd.reconstitute_int([1,2,3,4,5,6,7,8])
 num
 12345678
 result = bcd.make_hex(num)
 result
 [14, 4, 1, 6, 12, 11]
 bcd.reverse_list(result)
 result
 [11, 12, 6, 1, 4, 14]
 ['0x%x' % digit for digit in result]
 ['0xb', '0xc', '0x6', '0x1', '0x4', '0xe']
 ^Z
 
 HTH,
 John

Thanks John, I do not have a long available on the device: stuck with 16
bits.

Regards,

Philippe



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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Dennis Lee Bieber wrote:

 On Sun, 30 Jul 2006 16:39:47 -0500, Philippe Martin
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 
 My apologies, I clearly made a mistake with my calculator, yes the
 resulting array I would need is [0xb,0xc,0x6,0x1,0x4,0xe]

 Take note that this is NOT a BCD form for 12345678. BCD (typically
 packed) uses four bits per decimal digit. That would make 12345678 =
 0x12, 0x34, 0x56, 0x78 (ignoring matters of big/little end).
 
 The binary representation of 12345678, in bytes, is 0xBC, 0x61, 0x4E
 
 0xb, 0xc... is really 0x0B, 0x0C... 8-bits per byte, with MSB set to
 .
 
 Compare:
 BCD   00010010 00110100 01010110 0000
 binary1000 0111 01001110
 your  1011 1100 0110 0001 0100 1110
 --
 Wulfraed  Dennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff: [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/
Yes I realized that after writing it.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Paul Rubin wrote:

 Philippe Martin [EMAIL PROTECTED] writes:
 I'm just using Python to prototype, so I cannot use any of these great
 features of the language.
 
 I think when writing a prototype, you should use whatever features you
 want, except maybe at the upper levels of program organization.  The
 idea of prototyping is to get something done quickly, that you can use
 for integration and user testing earlier in the development cycle.  So
 you should use whatever Python features are available to make
 prototyping faster.  You shouldn't expect the prototype code to
 closely match the final C code, if that slows you down.  If you want
 code that closely resembles C code, you might as well write in C
 directly.


Some truth in that.

Thanks,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 Philippe Martin wrote:
 

 Thanks John, I do not have a long available on the device: stuck with 16
 bits.

 
 What does available on the device mean? Having a long is a property
 of a C complier, not a device. What is the CPU in the device? What is
 the C compiler you are using? N.B. Last time I looked, gcc would
 generate code for just about any CPU since Babbage's. I would expect
 *any* C compiler that is targetting a 16-bit CPU to provide a 32-bit
 long and generate reasonably efficient code for most simple operations.
 Is there no library of utility routines for *elementary* base
 conversions such as you need? Is there no 32-bit-arithmetic-simulation
 package?

Hi John,

I'm working on an embedded 8 bit device and have no choice as to which
cross-compiler to use: in this case the guy knows up to short and that's
it.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Philippe Martin wrote:

 Hi,
 
 I'm looking for an algo that would convert a list such as:
 
 I'm using python to prototype the algo: this will move to C in an embedded
 system where an int has 16 bits - I do not wish to use any python library.
 
 l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
 l2 = func (l1)
 # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
 
 
 Regards,
 
 Philippe

Thanks to all,

I decided to attack the problem another way and change the code in device #2
so it can now take the output from device #1.

As device #2 only needs to compare, add, and subtract the stuff .. it makes
my life much simpler.

Sample (potentially buggy):


l1 = [1,2,3,4]
l2 = [0,2,3,9]


def sup (l1, l2): #assume same length
for i in range(len(l1) ):
if l1[i]  l2[i]:
return 1
if l1[i]  l2[i]:
return -1
return 0



def add (l1, l2): #assume same length
r = []
idx =  range (len(l1))
idx.reverse()
carry = 0
for i in idx:

if l1[i] + l2[i]  10:
carry = 1
r.insert(0,(l1[i] + l2[i]) % 10)
else:
r.insert(0,l1[i] + l2[i] + carry)
carry = 0
return r





print sup(l1,l2)
print add (l1,l2)

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 Have you considered asking on a newsgroup where your problem might
 actually be on-topic, like:
 comp.lang.c

Yes, I came here for the algorithm question, not the code result.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 
 Philippe Martin wrote:
 Philippe Martin wrote:

  Hi,
 
  I'm looking for an algo that would convert a list such as:
 
  I'm using python to prototype the algo: this will move to C in an
  embedded system where an int has 16 bits - I do not wish to use any
  python library.
 
  l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
  l2 = func (l1)
  # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
 
 
  Regards,
 
  Philippe

 Thanks to all,

 I decided to attack the problem another way and change the code in device
 #2 so it can now take the output from device #1.

 As device #2 only needs to compare, add, and subtract the stuff .. it
 makes my life much simpler.

 
 I'm confused.
 1. Was the original device #1 or #2?
 2. How many bits does the non-original device's C compiler support?
 3. If the original device is device #1, please explain where *it*
 obtained an 8-digit decimal number expressed as 1 digit per byte (or
 int) ...


Well I don't want to bore you guys more than needed ;-) but:

Device #1 has an 8 bit processor - uses a C cross-compiler that does not
know anything above a 16 bit integer. I use this device to get information
from users 1234

Device #2 has an 8 bit processor - uses a subset of Java ... that does not
know anything above a 16 bit integer.


The information gathered in device number #1 must then be sent to device #2
(after being encrypted  ) to be compared, subtracted or added.

The code I already have in device #2 makes the assumption that the
information received is an array of bytes of length N which represents an
actual value. ex: 0x67DF5 == [0x6, 0x7, 0xD, 0xF, 0x5] ... so it can
compare/add/subtract values ... and do its job.

As a python fan, I figured (back to my initial not very clear request), that
I could prototype the above without making any major assumption as to the
capabilities of the interpreter.


I still believe that to be true.

Regards,

Philippe














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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 
 Philippe Martin wrote:
 John Machin wrote:

  Have you considered asking on a newsgroup where your problem might
  actually be on-topic, like:
  comp.lang.c

 Yes, I came here for the algorithm question, not the code result.

 
 This is comp.lang.python, not comp.algorithms
 
 Why are you avoiding naming the chip and its compiler?


I must disagree on that one: There are many threads on this site where
people just have fun talking algorithm. I'm not an algo. expert and I know
there are many here.


 Why are you avoiding naming the chip and its compiler?
I am not but I do not see what that brings to the discussion: but if you
wish ==

on one device, the processor in an 8-bit arm and the X-compiler is made by
epson 

on the other device, the processor is unknown to me and the environment is a
subset of java made for smartcards called javacard.

Regards,

Philippe

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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Dennis Lee Bieber wrote:

 On Sun, 30 Jul 2006 17:07:57 -0500, Philippe Martin
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 Paul Rubin wrote:
 
  
  If you prefer, You can do it all in one line:
  
 vlist = [int(d, 16) for d in ('%X' % int(''.join(map(str, l1]
 
 Thanks Paul,
 
 I'm just using Python to prototype, so I cannot use any of these great
 features of the language.

 
 You asked for algorithm... The above can be translated to C fairly
 easily without changing the algorithm... The array handling requires
 some thought, but...
 
 Or did you want a literal recipe
 
 for each integer in list I1:
 convert to string representation
 join the resultant strings into one string
 convert result to binary integer
 print the integer to string using Hex format code
 for each hex-digit in the string representation:
 convert to binary representation
 
 But then, that description was given to you... G
 
 That /is/ the algorithm... Implementation is a detail for the
 student G
 --
 Wulfraed  Dennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff: [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/


Thank you very much 


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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Grant Edwards wrote:

 On 2006-07-31, John Machin [EMAIL PROTECTED] wrote:
 
 but if you
 wish ==

 on one device, the processor in an 8-bit arm and the X-compiler is made
 by epson

 1. You still haven't *NAMED* the CPU and the compiler!!
 
 He obviously doesn't want to have to kill all of us.
 
 2. Do you mean ARM as in Acorn/Advanced RISC Machines??
 
 That's the only arm processor I know about.
 
 They make 8-bit CPUs
 
 Nope.
 
 3. How does the device manage to compute the 8-decimal-digit number
 that is your input??
 
 
 --
 Grant Edwards   grante Yow!  Yow! Maybe I
 should
   at   have asked for my
   Neutron
visi.comBomb in PAISLEY--

Yes I had arm in mind (for some reason) while it is the Smc8831
(http://www.google.com/url?sa=Ustart=1q=http://www.epsondevice.com/www/PDFS/epdoc_ic.nsf/5388db40b5eee4f949256a9c001d589f/944b73008b0bad33492570a00015d6ba/%24FILE/S5U1C88000C_2Ev3.pdfe=9797)


 3. How does the device manage to compute the 8-decimal-digit number
 that is your input??

What device manager ? think about it before being rude

Regards,

Philippe






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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
Philippe Martin wrote:

 Grant Edwards wrote:
 
 On 2006-07-31, John Machin [EMAIL PROTECTED] wrote:
 
 but if you
 wish ==

 on one device, the processor in an 8-bit arm and the X-compiler is made
 by epson

 1. You still haven't *NAMED* the CPU and the compiler!!
 
 He obviously doesn't want to have to kill all of us.
 
 2. Do you mean ARM as in Acorn/Advanced RISC Machines??
 
 That's the only arm processor I know about.
 
 They make 8-bit CPUs
 
 Nope.
 
 3. How does the device manage to compute the 8-decimal-digit number
 that is your input??
 
 
 --
 Grant Edwards   grante Yow!  Yow! Maybe I
 should
   at   have asked for my
   Neutron
visi.comBomb in PAISLEY--
 
 Yes I had arm in mind (for some reason) while it is the Smc8831

(http://www.google.com/url?sa=Ustart=1q=http://www.epsondevice.com/www/PDFS/epdoc_ic.nsf/5388db40b5eee4f949256a9c001d589f/944b73008b0bad33492570a00015d6ba/%24FILE/S5U1C88000C_2Ev3.pdfe=9797)
 
 
 3. How does the device manage to compute the 8-decimal-digit number
 that is your input??
 
 What device manager ? think about it before being rude
 
 Regards,
 
 Philippe



PS:

That is the first time I feel insulted posting on this list in _many_
years ... but I'm certain it is my fault.



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


Re: BCD List to HEX List

2006-07-30 Thread Philippe Martin
John Machin wrote:

 Philippe Martin wrote:
 John Machin wrote:

 
  Philippe Martin wrote:
  Philippe Martin wrote:
 
   Hi,
  
   I'm looking for an algo that would convert a list such as:
  
   I'm using python to prototype the algo: this will move to C in an
   embedded system where an int has 16 bits - I do not wish to use any
   python library.
  
   l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
   l2 = func (l1)
   # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
  
  
   Regards,
  
   Philippe
 
  Thanks to all,
 
  I decided to attack the problem another way and change the code in
  device
  #2 so it can now take the output from device #1.
 
  As device #2 only needs to compare, add, and subtract the stuff .. it
  makes my life much simpler.
 
 
  I'm confused.
  1. Was the original device #1 or #2?
  2. How many bits does the non-original device's C compiler support?
  3. If the original device is device #1, please explain where *it*
  obtained an 8-digit decimal number expressed as 1 digit per byte (or
  int) ...


 Well I don't want to bore you guys more than needed ;-) but:

 Device #1 has an 8 bit processor - uses a C cross-compiler that does not
 know anything above a 16 bit integer. I use this device to get
 information from users 1234

 Device #2 has an 8 bit processor - uses a subset of Java ... that does
 not know anything above a 16 bit integer.


 The information gathered in device number #1 must then be sent to device
 #2 (after being encrypted  ) to be compared, subtracted or added.

 The code I already have in device #2 makes the assumption that the
 information received is an array of bytes of length N which represents an
 actual value. ex: 0x67DF5 == [0x6, 0x7, 0xD, 0xF, 0x5] ... so it can
 compare/add/subtract values ... and do its job.

 As a python fan, I figured (back to my initial not very clear request),
 that I could prototype the above without making any major assumption as
 to the capabilities of the interpreter.


 I still believe that to be true.

 
 Try this:
 C:\junktype bcd.py
 def reconstitute_int(alist):
 reghi, reglo = 0, 0
 for digit in alist:
 assert 0 = digit = 9
 reghi, reglo = mul32by10(reghi, reglo)
 reghi, reglo = add32(reghi, reglo, 0, digit)
 return reghi, reglo
 
 def uadd16(a, b):
 return (a + b)  0x
 
 def shr32by4(hi, lo):
 newhi = (hi  4)  0x
 newlo = ((lo  4) | ((hi  0xF)  12))  0x
 
 return newhi, newlo
 
 def add32(hia, loa, hib, lob):
 lox = uadd16(loa, lob)
 hix = uadd16(hia, hib)
 inx = ((lox  0x8000)  13) + ((lob  0x8000)  14) + ((loa 
 0x8000)  1
 5)
 carry = [0, 1, 1, 1, 0, 0, 0, 1][inx]
 # The above is admittedly ugly but sheesh I haven't even had my
 # second cup of coffee yet today :-)
 # Anybody who's good at solving equations in Boolean algebra,
 # pls beautify this!!
 if carry:
 hix = uadd16(hix, 1)
 expected = (hia+hib)*65536 + loa + lob
 actual = hix*65536 + lox
 if actual != expected:
 print (hia, loa), (hib, lob), (hix, lox), actual, expected,
 inx, carry
 return hix, lox
 
 def mul32by10(hi, lo):
 tmphi, tmplo = add32(hi, lo, hi, lo) # 2 times
 tmphi, tmplo = add32(tmphi, tmplo, tmphi, tmplo) # 4 times
 tmphi, tmplo = add32(tmphi, tmplo, hi, lo) # 5 times
 tmphi, tmplo = add32(tmphi, tmplo, tmphi, tmplo) # 10 times
 return tmphi, tmplo
 
 def make_hex32(aninthi, anintlo):
 result = []
 while aninthi or anintlo:
 result.append(anintlo  0xF)
 aninthi, anintlo = shr32by4(aninthi, anintlo)
 return result
 
 def reverse_list(alist):
 n = len(alist)
 for i in xrange(n  1):
 reg1 = alist[n - 1 - i]
 reg2 = alist[i]
 alist[i] = reg1
 alist[n - 1 - i] = reg2
 
 
 C:\junkpython
 Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
 on win32
 Type help, copyright, credits or license for more information.
 import bcd
 num = bcd.reconstitute_int([1,2,3,4,5,6,7,8])
 num
 (188, 24910)
 num[0]*65536 + num[1]
 12345678
 result = bcd.make_hex32(*num)
 result
 [14, 4, 1, 6, 12, 11]
 bcd.reverse_list(result)
 result
 [11, 12, 6, 1, 4, 14]
 ['0x%x' % digit for digit in result]
 ['0xb', '0xc', '0x6', '0x1', '0x4', '0xe']
 ^Z


Thanks John,

I will give it a good look.

Regards,

Philippe

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


Re: simple question

2006-07-26 Thread Philippe Martin
Maxine Weill wrote:

 I need to install Python Imaging Library (PIL) - imaging-1.1.5.tar.gz
 (source ) onto Suse Linux 10.1 system in order for (latest) Scribus
 1.3.3.2 to install and work.
 
 Plesae indicate how I perform PIL install (exact commands/procedures)  in
 manner where files are automatically placed in proper directories, etc.
 
 Your urgent assistance is appreciated.
 Thanks,
 
 
 Wendell Anderson
 [EMAIL PROTECTED]
 
 or
 [EMAIL PROTECTED]

content of file BUILDME:

python setup.py build_ext -i
python selftest.py

Philippe

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


Re: About Embedding PyWin or wxPython

2006-07-25 Thread Philippe Martin
Mr. Roboto wrote:

 
 Folks:  I want to embark on a project to add Python (actually, wxPython
 or PythonWin) to a new Windows app I want to start writing soon.
 Essentially, I want to take VB6 (or pos Delphi) and construct the app
 framework/core functionality using one of those languages, then extend
 the app w/ Python, the same way one can extend the MS Office apps
 using VBA.  The core Python docs provide the fundamental info one
 needs to get started.  But, I've been looking for some pointers to
 articles/web pages that will bootstrap the effort, so I won't have to
 completely reinvent the wheel.  So far, the c.l.p ngroup traffic (and
 the web in general) that speaks to this subject is apparently pretty
 sparse.  Since I'm a one-man show, it would be helpful if anyone could
 offer pointers to sites/pages/books that address some of these issues:
 
 1)  To COM or not ?  From an implementation standpoint, it seems
 worthwhile to build the host app as a series of COM objects, which
 could then be ref'd/manipulated via external Python code.  Not sure if
 this makes sense from a performance-perspective, but I doubt the apps
 I'm thinking about (mostly desk accessory utils kinda, sorta) are
 going to be compute-intensive at all.
 
 2)  SWIG or not ?  Have never used it, but know that SWIG has been
 ref'd many times in the ngroup as an tool for facilitating the use of
 Python as an embedded language.  Is SWIG worth the effort for a
 relatively small (10 KLOC) app ?
 
 3)  Handling exceptions.  I want to start from Day One with a sensible
 approach to debugging and testing both host objects and external
 scripts.
 
 4)  Deployment.  Size (30 - 50MB for wxPython or PyWin alone) and a
 silent install of either pkg prior to installing the host app.
 
 Regardless of the conversation in this group, I plan to get started in
 the next few days.  This is how I'm currently looking at the above
 issues:
 
 1)  COM:  Yes, since COM seems like an easy fit w/o writing lotsa
 glue code because of built-in support via PyWin
 
 2)  SWIG:  Not for a 1st cut, at least not to get one's feet wet, so
 to speak
 
 3)  Exceptions:  No clue.  Need to closely read Extending/Embedding
 Python for more guidance
 
 4) Deployment: Bite the disk space bullet and use PyWin or wxPython as
 is
 
 Anyway, that's the beginning of the conversation.  If you have any
 observations or suggestions, please feel free.  Later...MR


Do you have major performances issues ? why not write everything in
Python/WxPython ?


I used to write my applications in VB6 with python com objects ... and
decided there was no gain there.

Regards,

Philippe




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


Re: About Embedding PyWin or wxPython

2006-07-25 Thread Philippe Martin
Mr. Roboto wrote:

 Phillipe:  Actually, it's not performance of the core app that concerns
 me.  I'm thinking more about UI/form *design* productivity.  I've done
 a lot of Access work over the years and while the stand-alone VB form
 designer isn't quite as thorough, it's still one of the slickest out
 there.  Unfortunately, there's no designer for PyWin and wxPython's
 XRC is nice but not in the same league as what can be done w/ Delphi
 or VB.  Yes, I'm aware that wxWidgets has a real form designer, but
 that's yet another story, for another day.
 
 Making XRC into a more fully-featured tool (more on par w/ the
 aforementioned) is a way nice project unto itself, but not right now.
 However, the desk accessory I've mentioned is an excellent 1st step
 towards *possibly* doing something much bigger
 
 Philippe Martin wrote:
 Do you have major performances issues ? why not write everything in
 Python/WxPython ?


 I used to write my applications in VB6 with python com objects ... and
 decided there was no gain there.
 
 Regards,
 
 Philippe

I personally _really_ like wxDesigner (http://www.roebling.de/)  and as
under VB6, I always avoided having the tables filled for me (bound forms if
I recall) I have not found my productivity go down ... but then again, I
never was a VB expert.

1)
As others have said, it is very easy to make a Python com object (thank you
Mark!) - and as long as Windows keeps supporting COM 

2)
I chose the COM option

3)
If your script does not handle exceptions, you'll have a fairly cryptic VB
dialog box telling you about your python com object unhapiness - I find it
more easy to handle the expections in the script

4)
Yes it takes space - I have an application that uses Python, wxPython,
Gadfly, pyserial, HTMLGen . and the whole thing takes 120M

I used visual studio to buld a single install for everything- works well.


The one open issue I have about wxPython in a com object is how the main
event loop (in your core application) will react if a com object with GUI
pops-up ... never tried it.

Regards,

Philippe






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


Re: what's wrong with this if statement?

2006-07-21 Thread Philippe Martin
John Salerno wrote:

 Here's the full code, but you can probably safely ignore most of it,
 especially the wxPython stuff:
 
 ---
 
 import wx
 
 
 class MyFrame(wx.Frame):
 
  def __init__(self):
  wx.Frame.__init__(self, parent=None, id=wx.ID_ANY)
  panel = wx.Panel(self)
 
  mainSizer = wx.BoxSizer(wx.VERTICAL)
  inputSizer = wx.BoxSizer(wx.HORIZONTAL)
 
  self.count = 0
  self.progress = wx.Gauge(panel, wx.ID_ANY, 100, size=(300, 20))
  self.status = wx.StaticText(panel, wx.ID_ANY, 'test')
  prompt = wx.StaticText(panel, wx.ID_ANY, 'Time:')
  self.input = wx.TextCtrl(panel, wx.ID_ANY, size=(20, 20))
  self.start = wx.Button(panel, wx.ID_ANY, 'Start')
  self.timer = wx.Timer(self)
 
  mainSizer.Add(self.progress, flag=wx.ALIGN_CENTER | wx.TOP,
 border=10)
  mainSizer.Add(self.status, flag=wx.ALIGN_CENTER | wx.ALL,
 border=10)
  mainSizer.Add(inputSizer, flag=wx.ALIGN_CENTER)
  inputSizer.Add(prompt, flag=wx.ALIGN_CENTER)
  inputSizer.Add(self.input, flag=wx.ALL, border=10)
  inputSizer.Add(self.start, flag=wx.ALIGN_CENTER)
 
  self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
  self.Bind(wx.EVT_BUTTON, self.OnStart, self.start)
 
  panel.SetSizer(mainSizer)
 
  def OnStart(self, event):
  self.time = self.input.GetValue()
  self.timer.Start(1000)
 
  def OnTimer(self, event):
  self.count += 1
  if self.count  self.time:
  self.progress.SetValue(self.count)
  self.status.SetLabel(str(self.count))
 
 
 class MyApp(wx.App):
 
  def OnInit(self):
  frame = MyFrame()
  self.SetTopWindow(frame)
  frame.Show()
  return True
 
 
 if __name__ == '__main__':
  app = MyApp(redirect=False)
  app.MainLoop()
 
 
 
 The code in question is mainly this:
 
 def OnTimer(self, event):
  self.count += 1
  if self.count  self.time:
  self.progress.SetValue(self.count)
  self.status.SetLabel(str(self.count))
 
 When I run the program, the progress bar and the status label continue
 to increase even after self.count has (presumably) become larger than
 self.time. Why is this? All I do is enter in '10' as the value to test
 it, and it keeps counting even beyond 10.



Check the type of self.time: unicode - you need to convert it to int
first ... plus your timer will need to be shutdown when you're done.

Regards,

Philippe


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


Re: first book about python

2006-07-08 Thread Philippe Martin
I don't know, if I were the genious that made up Python I would not believe
in any bible (small b)





IOANNIS MANOLOUDIS wrote:

 I want to learn python.
 I plan to buy a book. I always find printed material more convenient than
 reading on-line tutorials.
 I don't know PERL or any other scripting language. I only know some BASH
 programming. I am looking for a book which will help me get started and
 should contain the foundations. I am not looking for the Python bible.
 Any recommendations?
 Ioannis

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


Re: Icono en wxpython

2006-06-29 Thread Philippe Martin
Try Sourceforge.

(si j'ai bien compris)

Regards,

Philippe



Bruno Desthuilliers wrote:

 Gabriel wrote:
 Hola:
 He echo un programa en wxpython. Se trata de un programa para
 desarrollos con microcontroladores como PIC's etc. en cuanto a
 transmisión RS232 se refiere.
 
 El programa es GNU y quiero publicarlo pronto pero no se como poner el
 ícono a la ventana y al archivo en si...
 
 ¿Alguien puede darme una mano con esto?
 
 Otra cosa ¿dónde puedo publicar el programa una vez que este terminado?
 
 Desde ya muchas gracias
 
 Bonjour. Je n'ai pas compris un seul mot de ton post, à part qu'il
 concernait une appli wxPython, des microcontrolleurs, et des
 transmission RS232. Peut-être que si tu postais la question in English,
 ça aiderait un peu ?-)
 
 
 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

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


Web transaction server in Python

2006-06-28 Thread Philippe Martin
Hi,

I know a bit Python as application programming, but very little as a web
server.

I need to get one server to accept connection requests from many devices
(not all PC-Based) and then have a bi-lateral conversation with those
devices prior to closing the connection.

The said devices have at least a tcp-ip stack (socket level).

Is Zope something for me ? what else ?

Thanks,

Philippe

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


Re: USB and Python

2006-06-25 Thread Philippe Martin
Many thanks,


Philippe



Philippe Martin wrote:

 Hi,
 
 I need to talk to a USB device (PC or other) from Python - I am not
 talking about mounting a file system but sharing information as you would
 though a TCP-IP socket layer or an RS232 interface.
 
 Is there such low-level module available for Windows / Linux ?
 
 Thanks,
 
 Philippe

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


USB and Python

2006-06-23 Thread Philippe Martin
Hi,

I need to talk to a USB device (PC or other) from Python - I am not talking
about mounting a file system but sharing information as you would though a
TCP-IP socket layer or an RS232 interface.

Is there such low-level module available for Windows / Linux ?

Thanks,

Philippe

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


Re: Python with Eclipse

2006-06-20 Thread Philippe Martin
Dennis Benzinger wrote:

 Philippe Martin wrote:
 Dennis Benzinger wrote:
 
 Stan Cook wrote:
 I've been trying to use Eclipse with Python on Linux for a while and
 have noticed something odd.  After running the code or debugging a few
 times, its responsiveness gets really bad.  Upon checking the
 equivalent
 of the task manager, I find several instances of Python running.  When
 I
 kill these instances, the responsiveness comes back.  I'm not sure if
 there is a better place to post this, but it is Python related.  Is
 this just an issue with Eclipse or is there something else I should
 inspect?

 Any help would be appreciated.

 Regards,

 S Cook
 Which Python plugin are you using? PyDev?


 Bye,
 Dennis
 
 Hi,
 
 What other plugins are there ?
 
 Regards,
 
 Philippe
 
 
 
 In the Python wiki there is a page about Eclipse plugins for Python:
 
 http://wiki.python.org/moin/EclipsePythonIntegration
 
 
 Bye,
 Dennis
Thanks,

Philippe

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


Re: Python with Eclipse

2006-06-19 Thread Philippe Martin
Dennis Benzinger wrote:

 Stan Cook wrote:
 I've been trying to use Eclipse with Python on Linux for a while and
 have noticed something odd.  After running the code or debugging a few
 times, its responsiveness gets really bad.  Upon checking the equivalent
 of the task manager, I find several instances of Python running.  When I
 kill these instances, the responsiveness comes back.  I'm not sure if
 there is a better place to post this, but it is Python related.  Is this
 just an issue with Eclipse or is there something else I should inspect?
 
 Any help would be appreciated.
 
 Regards,
 
 S Cook
 
 Which Python plugin are you using? PyDev?
 
 
 Bye,
 Dennis

Hi,

What other plugins are there ?

Regards,

Philippe

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


Re: Pycrypto

2006-06-16 Thread Philippe Martin
Hi,

Look at the bin2ascii module.

Philippe


luca72 wrote:

 
 Excuse me  again,
 If the string is not a sting but hex number how i have to proced :
 
 look this page:
 http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html
 
 Regards Luca

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


Re: Software Needs Philosophers

2006-05-21 Thread Philippe Martin
Xah Lee wrote:

 Software Needs Philosophers
 
 by Steve Yegge, 2006-04-15.
 
 Software needs philosophers.
 
 This thought has been nagging at me for a year now, and recently it's
 been growing like a tumor. One that plenty of folks on the 'net would
 love to see kill me.
 
 People don't put much stock in philosophers these days. The popular
 impression of philosophy is that it's just rhetoric, just frivolous
 debating about stuff that can never properly be answered. ?Spare me
 the philosophy; let's stick to the facts!?
 
 The funny thing is, it's philosophers who gave us the ability to think
 rationally, to stick to the facts. If it weren't for the work of
 countless philosophers, facts would still be getting people tortured
 and killed for discovering and sharing them.
 
 Does it ever strike you as just a teeny bit odd that after a brief
 period where philosophy flourished, from maybe 400 B.C.E. to ~100 C.E.,
 we went through a follow-on period of well over one thousand five
 hundred years during which the Roman Catholic Church enslaved
 everyone's minds and killed anyone who dared think differently?
 
 What's weirder is that we tend to pretend it didn't really happen. We
 like to just skip right over the dominance of religion over our minds
 for a hundred generations, and think of religion today as a kindly old
 grandpa who's just looking out for us kids. No harm, no foul. Let
 bygones be bygones. Sure, there were massacres and crusades and
 genocides and torture chambers with teeth grinding and eyes bleeding
 and intestines torn out in the name of God. But we were all just kids
 then, right? Nobody does that kind of thing today, at least not in
 civilized countries.
 
 We try not to think about the uncivilized ones.
 
 It was philosophers that got us out of that Dark Ages mess, and no
 small number of them lost their lives in doing so. And today, the
 philosophy majors are the butts of the most jokes, because after the
 philosophers succeeded in opening our minds, we forgot why we needed
 them.
 
 And if we stop to think about it at all, we think that it was other
 people, people who are very unlike us, who committed those atrocities
 in the name of Faith (regardless of whether it's faith in a god, or in
 a political party, or any other form of mind control carried out by
 force).
 
 We like to think we live in an enlightened age, but we don't. Humans
 haven't changed significantly in 10,000 years. We're still killing and
 torturing each other. It's apparently incredibly easy to decide to kill
 someone and then do it. Happens every day, all around the world.
 Torture, too.
 
 But those people are just people. If they had been born down the street
 from you, they'd have gone to school with you, been friends with you,
 learned to program with you, written blogs and comments, never tortured
 or killed anyone in the name of an idea. They'd have been you. Which
 means they are you; you just got lucky in where you were born.
 
 One of the commenters on my last blog entry expressed the fervent wish
 that I drop dead. To be sure, they qualified it with ?on the
 internet?. But if they really feel that way, especially about
 something as hilariously and absurdly unimportant in the Grand Scheme
 as whether the Lisp programming language has any acceptable
 implementations, then what does it say about us?
 
 Everyone who commented angrily on that blog entry was caught. I caught
 you, anonymous or not, being a religious fanatic. The only
 ?negative? commenter who doesn't appear to be a religious zombie
 was Paul Costanza (ironic, since he claims to be the opinionated one),
 who relegated his comments to pedantic technical corrections. They're
 welcome, of course; I'm always looking to correct any technical
 misconceptions I harbor. But they're moot, since even if I was wrong
 about every single technical point I brought up in that entry, my
 overall point ? Lisp is not an acceptable Lisp ? remains largely
 uncontested by the commenters.
 
 Some of them just don't get it, which is fine; no harm in that. If
 you've been using Lisp for years and years, and you've written books
 and articles and zillions of lines of Lisp code, then you're unlikely
 to remember anything about what it's like coming to Lisp for the first
 time. They're religious because they've forgotten what it's like to be
 a skeptic.
 
 But make no mistake; a substantial percentage of people who take a side
 in any programming language discussion that devolves into a flamewar
 know exactly what the other side means, and they want to invoke the
 Ultimate Censorship: drop dead! Killing someone, after all, is one of
 the best ways to silence them. You also have to burn all their
 writings, which is getting harder these days; hence the increased
 vehemence on the 'net.
 
 Those of you who've followed what I've written over the past year or so
 know where I'm going. I'm taking a stand, all right, and it's a very
 definite one. I'm finding myself drawn 

Re: Unable to extract Python source code using Windows

2006-05-17 Thread Philippe Martin
John Machin wrote:

 http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2
 
 And the reason for posting that would be what? WinZip doesn't support
 bzip2 compression.
 
 http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tgz (a gzipped tar
 file) is what the OP would be better pointed at.
 
 FWIW, I have just downloaded the above tgz file and successfully
 unpacked it with WinZip versions 9 and 10, and with 7-Zip.
 
 FWIW2, 7-Zip is *free* and handles bz2 files.
 
 I would suggest that the OP's copy of WinZip v10 is stuffed, or his
 whole download mechanism is stuffed. If he were to investigate properly
 (as suggested by ScottDD) instead of thrashing about, 


I never declared myself a winzip expert since I do not use it



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


Re: creating a new database with mysqldb

2006-05-17 Thread Philippe Martin
John Salerno wrote:

 Since the connect method of mysqldb requires a database name, it seems
 like you can't use it without having a database already created. So is
 there a way to connect to your mysql server (without a specified
 database) in order to create a new database (i.e., the CREATE DATABASE
 query)?
 
 Thanks.

I'm no expert but: can't you spawn mysql with a script/scheme ?

Philippe

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


Re: Unable to extract Python source code using Windows

2006-05-16 Thread Philippe Martin
[EMAIL PROTECTED] wrote:

You can get Python sources from python.org
 
 I'm unable to locate a source file brings that will work with WinZip.
 Can anybody please point me to the exact URL that will get me to the
 source code? but it it is tar ball format or a gzip format, than that
 will work for me as WinZip is not open.


http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2



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


nix logon in Python

2006-05-12 Thread Philippe Martin
Hi,

Are there any (even prototypes/proof of concept) gdm/kdm/xdm.../-style
packages written in Python ?

Regards,

Philippe

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


Re: nix logon in Python

2006-05-12 Thread Philippe Martin
Philippe Martin wrote:

 Hi,
 
 Are there any (even prototypes/proof of concept) gdm/kdm/xdm.../-style
 packages written in Python ?
 
 Regards,
 
 Philippe


I guess to further define my problem:

I am looking for clues as to how to launch an X11 session (remote or not)
from a Python-TKinter-based application.

I got (a few months ago) this hint from this NG but had to work on another
project ... I'm now back into it and would like to know how to learn the
basics.

Thanks.


There should be no problem with this.  After all, even the greeter is just
an
X application.  Depending on which login manager you use
(xdm/kdm/gdm/whatever)
the details of getting your Tkinter app to actually be run will vary,
though.
In gdm, it looks like adding it to the file /etc/X11/gdm/Init/default may be
the ticket.

It is probably best to run
app.tk.call(rename, send, )
in your program, for the reasons outlined in the send(n) manpage:
SECURITY
The  send  command is potentially a serious security loophole. On
Unix,
any application that can connect to your X server can send  scripts 
to
your  applications.   These  incoming  scripts  can use Tcl to read
and
write your files and invoke subprocesses under your  name.

Jeff



Regards,


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


Re: Python editor recommendation.

2006-05-11 Thread Philippe Martin
Looking at their flash demo made me want to try it, but after all
dependencies installed, I get Fatal Python error: can't initialise module
gtksourceview Aborted (core dumped)

Is it stable ?

Philippe







mystilleef wrote:

 The powerful no-nonsense, no-frills, no-hassle, no-fuzz editor,
 Scribes. Supports everything you'd want in an editor, it's nimble, fast
 and agile, and it has virtually no learning curve.
 
 http://scribes.sourceforge.net/
 
 http://scribes.sourceforge.net/snippets.htm (Flash Demo)
 
 http://www.minds.nuim.ie/~dez/images/blog/scribes.html (GIF Demo)

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


Re: How can I do this with python ?

2006-05-08 Thread Philippe Martin
Xiao Jianfeng wrote:

 Tim N. van der Leeuw wrote:
 Your question is insufficiently clear for me to answer.

 Do you want to know how to read from standard-input in a Python
 program?

 Do you want to know how to start an external program from Python, and
 then connect something to that programs standard input?

 Do you want to know something else?

 Please specify!

 Cheers,

 --Tim

   
 Thanks.
 
 For example, I can call vim and do something like this in a shell script,
 
 #!/bin/sh
 
 vim a.file-EOF
 :some_vim_command
 :some_vim_command
 :w
 :q
 EOF
 
 I want to know how to call vim and to the same thing with python.
 
 Regrads,

hi,

os.popen should do that.

Philippe


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


Re: List Ctrl

2006-05-08 Thread Philippe Martin
[EMAIL PROTECTED] wrote:

 
 Hello together !!
 
 I have programmed a List Control and I introduced information in several
 rows. What I want to do is, modify this information when i select a row
 and press a button.
 There two options:
 - when i do this, a window appears and asks me to introduce the
 information. - or in the selected row , the last information is removed
 and lets me to overwrite.
 
 Thank you
 
 

--oOo-oOo--
 
 Servicio de acceso ó correo electrónico vía web da Universidade de Vigo
 Servicio de acceso al correo electrónico vía web de la Universidad de Vigo
 
 Servicios Informáticos [ http://si.uvigo.es ]
 Universidade de Vigo [ http://www.uvigo.es ]
 
 URL: https://correoweb.uvigo.es


TkInter, wx Widgets , ., ?

What exactly is it that you do not know how to do ?

Philippe


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


Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
Hi,

This code works, but is it appropriate ?

l_init = False

if True == l_init and 1234 = l_value:
 print 'l_value is initialized'

I know I can do this with a try but ...

Philippe


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


Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
I'm sorry (typo):



l_init = False

if True == l_init and 1234 == l_value:
 print 'l_value is initialized'


Note that 1234 == l_value does not get evaluated.

Philippe




vbgunz wrote:

 you don't have to say:
 
 if True == l_init
 
 it is suggested you simply say:
 
 if l_init:
 
 Remember the and operator requires expressions on both sides to be true
 to continue. If you notice, your expression on the right side of the
 'and' is an assignment and so this is forbidden (SyntaxError).
 assignments only work on lines by themselves and no where else.
 
 if you meant == rather than = remember this, l_value doesn't exist and
 would pull up a NameError *but* because the first expression evaluates
 as false the second expression is never evaluated.
 
 refactor your code ASAP. good luck!

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


Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin


Larry Bates wrote:

 Philippe Martin wrote:
 Hi,
 
 This code works, but is it appropriate ?
 
 l_init = False
 
 if True == l_init and 1234 = l_value:
  print 'l_value is initialized'
 
 I know I can do this with a try but ...
 
 Philippe
 
 
 1) You have a syntax error 1234 == l_value (note ==)
 2) This doesn't test to see if l_value is initialized
because if it isn't you get:
 
 Traceback (most recent call last):
   File
   C
\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py,
 line 310, in RunScript
 exec codeObject in __main__.__dict__
   File junk.py, line 1, in ?
 if True == l_init and 1234 == l_value:
 NameError: name 'l_init' is not defined
 
 3) It is unclear what l_init is used for in this context.
Setting it to True doesn't tell you anything about l_value.
 
 Normally you do something like:
 
 l_value=None
 .
 . Intervening code
 .
 if l_value is None:
 print l_value uninitialized
 
 Or (something I never use):
 
 if not locals().has_key('l_value'):
 print l_value uninitialized
 
 
 -Larry Bates


l_init really is a boolean parameter and l_value a value that _might_ exist
in a shelve.

So I just want to have a parameter to a method so if the first value tested
is false (l_init) then the second (l_value) does not get tested ... because
it is the second in the statement and only seems to get evaluated if the
first one is true.

Philippe




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


Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
bruno at modulix wrote:

 Philippe Martin wrote:
 (snip)
 
 l_init really is a boolean parameter and l_value a value that _might_
 exist in a shelve.
 
 So I just want to have a parameter to a method so if the first value
 tested is false (l_init) then the second (l_value) does not get tested
 ... because it is the second in the statement and only seems to get
 evaluated if the first one is true.
 
 s/seems to get/is/
 
 But this is a really unpythonic way to do things IMHO. Either use a
 try/except block (probably the most straightforward solution), or, as in
 Larry's post, test for the existence of 'l_value' in locals().
 
 My 2 cents...
 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

Well, that was the question - I wanted to avoid that because I'm already in
a try/except and do not like to imbricate them too much.

Philippe


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


Re: Active Directory Authentication

2006-05-05 Thread Philippe Martin
Benji York wrote:

 D wrote:
 Is it possible to have Python authenticate with Active Directory?
 Specifically what I'd like to do is have a user enter a
 username/password, then have Python check the credentials with AD - if
 what they entered is valid, for example, it returns a 1, otherwise a
 0..  Thanks!
 
 Install the Win32 extensions from
 http://starship.python.net/crew/skippy/win32/Downloads.html and do
 something like this:
 
 try:
  handle=win32security.LogonUser(username, None, password,
win32security.LOGON32_LOGON_NETWORK,
win32security.LOGON32_PROVIDER_DEFAULT)
 
  # We're not going to use the handle, just seeing if we can get it.
  handle.Close()
  return True
 except pywintypes.error, e:
  # Because of the sheer number of Windows-specific errors that can
  # occur here, we have to assume any of them mean that the
  # credentials were not valid.
  return False
 --
 Benji York

I assume then that you can also change user information using the same
principle ? I'm trying to switch some VB6 code to python.

Philippe

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


Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
bruno at modulix wrote:

 Philippe Martin wrote:
 bruno at modulix wrote:
 
 
Philippe Martin wrote:
(snip)

l_init really is a boolean parameter and l_value a value that _might_
exist in a shelve.

So I just want to have a parameter to a method so if the first value
tested is false (l_init) then the second (l_value) does not get tested
... because it is the second in the statement and only seems to get
evaluated if the first one is true.

s/seems to get/is/

But this is a really unpythonic way to do things IMHO. Either use a
try/except block (probably the most straightforward solution), or, as in
Larry's post, test for the existence of 'l_value' in locals().

My 2 cents...
--
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
 
 
 Well, that was the question - I wanted to avoid that because I'm already
 in a try/except and do not like to imbricate them too much.
 
 Then reads Fredrik's answer and this:
 '''
 Help on module shelve:
 
 (...)
 
 DESCRIPTION
 A shelf is a persistent, dictionary-like object.
 (...)
 
 
 What about :
 
 if shelf.has_key('l_value'):
   ...
 
 ?-)
 
 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

Yes that would make sense.

Philippe

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


Re: Is this a legal / acceptable statement ?

2006-05-05 Thread Philippe Martin
Fredrik Lundh wrote:

 Philippe Martin wrote:
 
 l_init really is a boolean parameter and l_value a value that _might_
 exist in a shelve.

 So I just want to have a parameter to a method so if the first value
 tested is false (l_init) then the second (l_value) does not get tested
 ... because it is the second in the statement and only seems to get
 evaluated if the
 
 how do you look things up in the shelve ?
 
 /F


l_value = m_data['MY_KEY']

Philippe



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


Re: cross platform libraries

2006-05-05 Thread Philippe Martin
Through Wine maybe ?

Philippe


Dennis Lee Bieber wrote:

 On 4 May 2006 09:57:15 -0700, [EMAIL PROTECTED] declaimed the
 following in comp.lang.python:
 
 I am using python on a linux terminal.
 
 I want to shutdown a remote windows box. I found a script which does
 something like this. My question is can we use windows libraries in
 linux as follows 
 
 import win32api
 import win32con
 import win32netcon
 import win32security
 import win32wnet
 
 That set... HIGHLY UNLIKELY... They all rely upon having the M$
 kernel DLLs available...
 
 Now, if the remote box is running a telnet server, you might be able
 to telnet over (logging in as the boxes admin account) and initiate a
 shutdown from it... (I seem to have a shutdown.exe on my system).
 --
 Wulfraed  Dennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff: [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

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


Re: Gettings subdirectories

2006-05-04 Thread Philippe Martin
Hi,

The second edition of Programming Python - O'REILLY - Mark Lutz shows how
to do that using os.path.walk

Philippe





Florian Lindner wrote:

 Hello,
 how can I get all subdirectories of a given directories? os.listdir()
 gives me all entries and I've found no way to tell if an object is a file
 or a directory.
 
 Thanks,
 
 Florian

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


Re: Progamming python without a keyboard

2006-05-04 Thread Philippe Martin
That reminds me a session in an RD lab a long time ago

One of the guys kept talking to himself, commenting code, bugs . he
drove me nuts

Eventually (weeks later) another guy silently stood up, went to the first
guy, and without a word attempted to strangle him.

He got stopped ... but did not get fired (I guess even the management was
tired of the first guy rambling)

We should be aware of all types of RSI.

(I'm still laughing)

Philippe





Rony Steelandt wrote:

 http://www.newscientisttech.com/article/dn9066
 
 To nice to be true ?
 
 R_
 
 --
 ---
 Rony Steelandt
 BuCodi
 rony dot steelandt (at) bucodi dot com
 
 Visit the python blog at http://360.yahoo.com/bucodi

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


Re: wxPython, wxcombobox opening

2006-05-02 Thread Philippe Martin
Hi,

From the wxPython list:

 Hi,
 
 Which event must I catch to be called when the user clicks on the combo 
 button to make the drop down list to appear ?

No, there isn't a specific event for the opening of the drop-down box.


Regards,

Philippe





Philippe Martin wrote:

 Hi,
 
 I do not have the answer but am very interested in the issue. I tried
 this:
 
 l_ev = wx.MouseEvent(wx.wxEVT_LEFT_DOWN)
 l_ev.SetEventObject(self.GetCombo())
 self.GetEventHandler().ProcessEvent(l_ev)
 
 Which did send the event to the combo (which is in a pannel in my case) ..
 but that is apparently not the event that triggers the dropping of the
 list.
 
 I posed elsewhere and will forward here any hint.
 
 Philippe
 
 
 
 Rony Steelandt wrote:
 
 Hi,
 
 Does somebody knows a way to automaticely open the list part of a
 wxCombobox when it gets the focus ?
 
 tia,
 
 Rony

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


Re: OOP techniques in Python

2006-05-01 Thread Philippe Martin
Thanks,

Did not know that.

Philippe



Dennis Lee Bieber wrote:

 On Thu, 27 Apr 2006 14:32:15 -0500, Philippe Martin
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 
 What then is the point of the double underscore (if any) ?:
 
 To prevent masking/shadowing of inherited attributes...
 
 class A(object):
 ...   def __init__(self):
 ...   self.__WhoMe = From A
 ...   print A : , dir(self)
 ...   super(A, self).__init__()
 ...
 class B(object):
 ...   def __init__(self):
 ...   self.__WhoMe = 42
 ...   print B : , dir(self)
 ...   super(B, self).__init__()
 ...
 class Confusion(A, B):
 ...   def __init__(self):
 ...   self.__WhoMe = I'm confuzzled
 ...   print Confusion: , dir(self)
 ...   super(Confusion, self).__init__()
 ...
 cab = Confusion()
 Confusion:  ['_Confusion__WhoMe', '__class__', '__delattr__',
 '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__',
 '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
 '__setattr__', '__str__', '__weakref__']
 A :  ['_A__WhoMe', '_Confusion__WhoMe', '__class__', '__delattr__',
 '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__',
 '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
 '__setattr__', '__str__', '__weakref__']
 B :  ['_A__WhoMe', '_B__WhoMe', '_Confusion__WhoMe', '__class__',
 '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__',
 '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
 '__repr__', '__setattr__', '__str__', '__weakref__']
 
 
 Note that A, B, and Confusion each have __WhoMe. Also notice how
 each __init__ invokes the parent module __init__; each one adds its
 __WhoMe to the object without masking those defined in others.
 
 Without the __, you'd have only ONE attribute after all of that; as
 shown next...
 
 class A(object):
 ...   def __init__(self):
 ...   self._WhoMe = From A
 ...   print A : , dir(self)
 ...   super(A, self).__init__()
 ...
 class B(object):
 ...   def __init__(self):
 ...   self._WhoMe = 42
 ...   print B : , dir(self)
 ...   super(B, self).__init__()
 ...
 class Confusion(A, B):
 ...   def __init__(self):
 ...   self._WhoMe = I'm confuzzled
 ...   print Confusion: , dir(self)
 ...   super(Confusion, self).__init__()
 ...
 cab2 = Confusion()
 Confusion:  ['_WhoMe', '__class__', '__delattr__', '__dict__',
 '__doc__', '__getattribute__', '__hash__', '__init__', '__module__',
 '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
 '__str__', '__weakref__']
 A :  ['_WhoMe', '__class__', '__delattr__', '__dict__', '__doc__',
 '__getattribute__', '__hash__', '__init__', '__module__', '__new__',
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
 '__weakref__']
 B :  ['_WhoMe', '__class__', '__delattr__', '__dict__', '__doc__',
 '__getattribute__', '__hash__', '__init__', '__module__', '__new__',
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
 '__weakref__']
 
 --
   == 
 [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG 
[EMAIL PROTECTED] |   Bestiaria Support Staff   
   == 
 Home Page: http://www.dm.net/~wulfraed/
  Overflow Page: http://wlfraed.home.netcom.com/

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


Re: wxPython, wxcombobox opening

2006-04-29 Thread Philippe Martin
Hi,

I do not have the answer but am very interested in the issue. I tried this:

l_ev = wx.MouseEvent(wx.wxEVT_LEFT_DOWN)
l_ev.SetEventObject(self.GetCombo())
self.GetEventHandler().ProcessEvent(l_ev)

Which did send the event to the combo (which is in a pannel in my case) ..
but that is apparently not the event that triggers the dropping of the
list.

I posed elsewhere and will forward here any hint.

Philippe



Rony Steelandt wrote:

 Hi,
 
 Does somebody knows a way to automaticely open the list part of a
 wxCombobox when it gets the focus ?
 
 tia,
 
 Rony

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


Re: print names of dictionaries

2006-04-27 Thread Philippe Martin
Hi,

I do not know if there is a way to overload the instantiation of all objects
in Python but I thought of something like this to fetch any object with its
name:

g_dict = {}


def create_object (v,s):
   p = v
   g_dict[s] = id(p)
   return p

#ex
object = create_object ([1,2,3,4], 'A LIST')

Philippe





Thomas Nelson wrote:

 Here's an OO way that may do what you want:
 class MyD(dict):
 ... def __init__(self,dic,rep):
 ... dict.__init__(self,dic)
 ... self.rep = rep
 ... def __repr__(self):
 ... return self.rep
 ...
 apps = MyD({'alpha':1,'beta':2},'apps')
 apps
 apps
 apps.keys()
 ['alpha', 'beta']
 
 Of course, the easiest way is just to use a tuple (dict,string).
 
 THN

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


Re: print names of dictionaries

2006-04-27 Thread Philippe Martin
OK, totally dumb !

g_dict[s] = p




Philippe Martin wrote:

 Hi,
 
 I do not know if there is a way to overload the instantiation of all
 objects in Python but I thought of something like this to fetch any object
 with its name:
 
 g_dict = {}
 
 
 def create_object (v,s):
p = v
g_dict[s] = id(p)
return p
 
 #ex
 object = create_object ([1,2,3,4], 'A LIST')
 
 Philippe
 
 
 
 
 
 Thomas Nelson wrote:
 
 Here's an OO way that may do what you want:
 class MyD(dict):
 ... def __init__(self,dic,rep):
 ... dict.__init__(self,dic)
 ... self.rep = rep
 ... def __repr__(self):
 ... return self.rep
 ...
 apps = MyD({'alpha':1,'beta':2},'apps')
 apps
 apps
 apps.keys()
 ['alpha', 'beta']
 
 Of course, the easiest way is just to use a tuple (dict,string).
 
 THN

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


Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Why is that ? to me it makes sense when I see self.__m_var that I'm dealing
with a member variable taht derived classes will not see/access.

Philippe




Steven Bethard wrote:

 Panos Laganakos wrote:
 we usually define private properties and provide public functions
 to access them, in the form of:
 get { ... } set { ... }
 
 Should we do the same in Python:
 
 self.__privateAttr = 'some val'
 
 def getPrivateAttr(self):
 return self.__privateAttr
 
 Or there's no point in doing so?
 
 There is no point in doing so.  You should use plain attributes whenever
 possible (that is, whenever you're really just doing a get or a set,
 with no computation).  The only reason to use getters and setters is so
 that you can change the implementation later if you need to.  But python
 allows you to do this with properties:
 
   class C(object):
 ... def __init__(self, x):
 ... self.x = x
 ...
   C(42).x
 42
   class C(object):
 ... def _get_x(self):
 ... return self._x * 2
 ... def _set_x(self, value):
 ... self._x = value / 2
 ... x = property(_get_x, _set_x)
 ... def __init__(self, x):
 ... self.x = x
 ...
   C(42).x
 42
 
 Which should not be interpreted as saying you should start writing a
 bunch of properties now. ;) Instead, only introduce a property when you
 find that something must remain an attribute (presumably for backwards
 compatibility reasons) but for whatever reason it now needs some
 additional computation.
 
 STeVe

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


Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Steven Bethard wrote:

 [Please don't top-post]
 
 Steven Bethard wrote:
   Panos Laganakos wrote:
   we usually define private properties and provide public functions
   to access them, in the form of:
   get { ... } set { ... }
  
   Should we do the same in Python:
  
   self.__privateAttr = 'some val'
  
   def getPrivateAttr(self):
   return self.__privateAttr
  
   Or there's no point in doing so?
  
   There is no point in doing so.  You should use plain attributes
   whenever possible (that is, whenever you're really just doing a get or
   a set, with no computation).  The only reason to use getters and
   setters is so that you can change the implementation later if you need
   to.  But python allows you to do this with properties:
 [snip]
   Which should not be interpreted as saying you should start writing a
   bunch of properties now. ;) Instead, only introduce a property when
   you find that something must remain an attribute (presumably for
   backwards compatibility reasons) but for whatever reason it now needs
   some additional computation.
 
 Philippe Martin top-posted:
 Why is that ? to me it makes sense when I see self.__m_var that I'm
 dealing with a member variable taht derived classes will not see/access.
 
 If the OP uses a private attribute in combination with a getter and a
 setter, he's basically still exposing the attribute as public, but
 making it harder to get and set.  There's no reason to do that.  If
 you're going to expose a public API to part of the class that just
 assigns and returns a value (with no computation), you might as well
 make that API an attribute instead of a pair of methods.
 
 STeVe


 [Please don't top-post]

OK I won't, is that a general rule? (I've been top posting for quite some
time now and it is the first time I see that warning)

Philippe




-- 
---
Poignée trop essorée, moulin bien rincé
Pierre Lafouine
---

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


Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Edward Elliott wrote:

 Panos Laganakos wrote:
 i.e. we usually define private properties and provide public functions
 to access them, in the form of:
 get { ... } set { ... }
 
 Should we do the same in Python:
 Or there's no point in doing so?
 
 Some other techniques come to mind, but I think that Python tends to
 allow the programmer to access stuff he wants even though he shouldn't
 or in the form of a dict or list, rather than a method to do so.
 
 There's no point.  Private access can only be advisory anyway -- there are
 ways around it in every language.  Convention serves just as well, people
 know that touching _foo is done at their own risk.  It's not creating
 extra hoops to jump through the few times you really do need to touch a
 private var.
 
 Others already mentioned how to transparently change attributes to
 properties.
 
 If you're worried about enforcing restrictions in your code base, get a
 lint checker to flag any expression of the form name._foo where name isn't
 'self'.  Yes you can still access _foo other ways, but you'll never get
 perfect enforcement anyway.  Maybe the extra step will make you think
 twice, if that's what you want (and it seems to be).

-- 

What then is the point of the double underscore (if any) ?:


In [2]:class test:
   .2.: _one_underscore=1
   .2.: __two_underscores=2
   .2.:

In [3]:t = test()

In [4]:t._one_underscore=2

In [5]:t.__two_underscores=3

In [6]:t.__two_underscores
Out[6]:3

In [7]:dir (test)
Out[7]:['__doc__', '__module__', '_one_underscore',
'_test__two_underscores']

In [8]:test._one_underscore
Out[8]:1

In [9]:test.__two_underscores
---
exceptions.AttributeErrorTraceback (most recent
call last)

/home/philippe/ipython console

AttributeError: class test has no attribute '__two_underscores'



-
Poignée trop essorée, moulin bien rincé
Pierre Lafouine
---







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


Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Edward Elliott wrote:

 Philippe Martin wrote:
 ''
 
 On the other hand, foo.__doc__ and foo.__name__ work fine.
 
 (I was going to quote your post but my reader interprets everything after
 the two dashes as your sig and ignores it.  And I won't bother to fix it.)


I'm not sure I understand what you mean ... I did get a strange new message
from my email client and disabled the signature.


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


Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Duncan Booth wrote:

 Philippe Martin wrote:
 Steven Bethard wrote:
 [Please don't top-post]
 
 OK I won't, is that a general rule? (I've been top posting for quite some
 time now and it is the first time I see that warning)
 
 Yes. Other suggestions you might get are not to bottom post, and certainly
 not (as you did elsewhere) to post your response as a signature (i.e.
 following a line containing only two dashes and a space).
 
 The accepted way to follow up is to trim the post to which you are
 responding so as to maintain sufficient context to make the post
 intelligible on its own, but not to quote the entire post: most newsreader
 programs will help you in this by either warning or indeed refusing to
 post responses which have too many quoted lines compared with new content.
 
 It is perfectly reasonable if you are making several points to intersperse
 your comments with other quoted sections.
 
 Some newsgroups use a different convention and expect top-posting without
 trimming of the quoted posts, but these very much are in the minority.

:-) I did try the signature for the first time today, and stopped as I get
weird errors from my client and certainly do not wish to get flame just
because I like a cute message.

My assumption always was:
1) keep all data in the post so new viewers can understand get the full
content, including the initial post
 
2) write on top because when you open a file, you want the chronological
info on top instead of at the very bottom ... since because of 1) this
could be miles away.

But if the rules are otherwise then I'll just follow them.


Regards,

Philippe




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


Re: wxpython warnings

2006-04-26 Thread Philippe Martin
I had a similar but simple problem (the file was missing) and had to check
by hand before calling wxPython.

Can you check the tag by hand before calling wxPython ?


Philippe




Iain King wrote:

 I have a wxpython program that displays TIF images.  Sometimes it will
 encounter a tag the tiff loader cant handle.  Rather than silently
 ignoring it, it pops up a window:
 
 Python Warning
 unknown field with tag blah blah
 
 I don't want it to do this, but I can't work out how to turn it off.
 Anyone know?
 
 Iain

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


Re: Inherit from array

2006-04-26 Thread Philippe Martin
I think he did

from array import *


Philippe




bruno at modulix wrote:

 TG wrote:
 Hi there.
 
 I'm trying to create a simple class called Vector which inherit from
 array.
 
 Which array ?
 
 [EMAIL PROTECTED] ~ $ python
 Python 2.4.2 (#1, Feb  9 2006, 02:40:32)
 [GCC 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
 Type help, copyright, credits or license for more information.
 array
 Traceback (most recent call last):
   File stdin, line 1, in ?
 NameError: name 'array' is not defined
 
 
 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

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


Re: Events in Python?

2006-04-26 Thread Philippe Martin
Besides the other anwsers, you might want to check the signal module.

Regards,

Philippe



[EMAIL PROTECTED] wrote:

 Here is another non-pythonic question from the Java Developer. (I beg
 for forgiveness...)
 
 Does Python have a mechanism for events/event-driven programming?
 
 I'm not necessarily talking about just GUIs either, I'm interested in
 using events for other parts of an application as well.
 
 If there isn't some sort of event mechanism built into Python, where
 might I find some information about implementing one?
 
 Thanks,
 
 Scott Huey

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


Re: wxpython warnings

2006-04-26 Thread Philippe Martin
Hi,

This is an answer I got from the wxPython NG:


If it is a wxLog message (I think it is) then you can temporarily 
disable log messages by creating an instance of wx.LogNull.  Or you can 
do something like set the log target to some other object than the 
default wx.LogGui, or set the log level to a higher level so those 
messages are not logged.


Regards,

Philippe



Iain King wrote:

 I have a wxpython program that displays TIF images.  Sometimes it will
 encounter a tag the tiff loader cant handle.  Rather than silently
 ignoring it, it pops up a window:
 
 Python Warning
 unknown field with tag blah blah
 
 I don't want it to do this, but I can't work out how to turn it off.
 Anyone know?
 
 Iain

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


Re: MinGW and Python

2006-04-26 Thread Philippe Martin
This might relevant.

http://www.aceshardware.com/read.jsp?id=153

Philippe



Robert Kern wrote:

 Martin v. Löwis wrote:
 Srijit Kumar Bhadra wrote:
 
Is there any specific reason for not using MinGW to build the official
distribution of Python for Win32?
 
 What could be the reasons to use MinGW?
 
 As for reasons not to do that:
 - there is no build process available to do that
 - people building extensions to Python must be able to do so with
   Microsoft C++, since some of these extensions are written using MFC.
 - developing Python itself in Visual Studio is quite convenient; in
   particular, the debugger works better than gdb.
 
 - gcc does not optimize particularly well.
 
 --
 Robert Kern
 [EMAIL PROTECTED]
 
 I have come to believe that the whole world is an enigma, a harmless
 enigma
  that is made terrible by our own mad attempt to interpret it as though it
  had an underlying truth.
   -- Umberto Eco

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


Re: Multiple hierarchies and method overloading

2006-04-25 Thread Philippe Martin
Well, the whole point was to clean up my code:

Actually this is what I have:

Class A:
def A_Func(self, p_param):
 .
Class B:
def A_Func(self):
 .

Class C (A,B):
A.__init__(self)
B.__init__(self)

Class D (A,B):
A.__init__(self)
B.__init__(self)


Where A is a wxWidget class and B a Common/utility class which I wanted to
factorize (and yes, inheritance was not mandatory here, just simpler)

My common class does have an A_Func(self) while wxWidget an A_Func(self,
p_param) == I actually got the error calling A_Func(self) as it was
checked against A_Func(self, p_param).

Regards,

Philippe







Lawrence D'Oliveiro wrote:

 In article [EMAIL PROTECTED],
  Ben Cartwright [EMAIL PROTECTED] wrote:
 
Philippe Martin wrote:

 I renamed A_Func(self) to fix that ... but is there a cleaner way around
 ?

When using multiple inheritence, the order of the base classes matters!
 
 When you have to start worrying about complications like this, isn't
 that a sign that you're taking the whole OO thing a little too seriously?
 
 After all, technology is supposed to _solve_ problems, not create them.
 If the complications of OO are making you lose sight of your original
 problem, then maybe you should put them aside.

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


Re: Multiple hierarchie and method overloading

2006-04-25 Thread Philippe Martin
Thanks,

I'll try that.

Philippe


Ben Cartwright wrote:

 Philippe Martin wrote:
 I have something like this:

 Class A:
 def A_Func(self, p_param):
  .
 Class B:
 def A_Func(self):
  .

 Class C (A,B):
 A.__init__(self)
 B.__init__(self)

 .

 self.A_Func() #HERE I GET AN EXCEPTION ... takes at least 2
 arguments (1
 given).


 I renamed A_Func(self) to fix that ... but is there a cleaner way around
 ?
 
 When using multiple inheritence, the order of the base classes matters!
  E.g.:
 
   class A(object):
   def f(self):
   print 'in A.f()'
   class B(object):
   def f(self):
   print 'in B.f()'
   class X(A, B):
   pass
   class Y(B, A):
   pass
 
x = X()
x.f()
   in A.f()
y = Y()
y.f()
   in B.f()
 
 If you want to call B.f() instead of A.f() for an X instance, you can
 either rename B.f() like you've done, or do this:
 
B.f(x)
   in B.f()
 
 --Ben

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


  1   2   >