Last chance to join the Summer of PyPy!

2006-11-09 Thread Michael Hudson
Hopefully by now you have heard of the Summer of PyPy, our program
for funding the expenses of attending a sprint for students.  If not,
you've just read the essence of the idea :-)

However, the PyPy EU funding period is drawing to an end and there is
now only one sprint left where we can sponsor the travel costs of
interested students within our program. This sprint will probably take
place in Leysin, Switzerland from 8th-14th of January 2007.

So, as explained in more detail at:

http://codespeak.net/pypy/dist/pypy/doc/summer-of-pypy.html

we would encourage any interested students to submit a proposal in the
next month or so.  If you're stuck for ideas, you can find some at

http://codespeak.net/pypy/dist/pypy/doc/project-ideas.html

but please do not feel limited in any way by this list!

Cheers,
mwh

... and the PyPy team

-- 
  This is an off-the-top-of-the-head-and-not-quite-sober suggestion,
  so is probably technically laughable.  I'll see how embarassed I
  feel tomorrow morning.-- Patrick Gosling, ucam.comp.misc
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[Ann] ctypes wiki

2006-11-09 Thread Thomas Heller
I have installed a wiki which could / should be used to document the ctypes 
package and
ctypes related packages (like comtypes, for example).

ctypes is a foreign function library for Python:

http://starship.python.net/crew/theller/ctypes/

I hope the wiki will evolve over time into a useful resource.

Currently there is no actual contents - so please contribute by adding tips, 
tricks,
and whatever you have to share about ctypes.

The wiki URL is:

  http://starship.python.net/crew/theller/wiki

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: ANN: wxPython 2.7.2.0

2006-11-09 Thread Kenneth Long
Is there a new version of Demo Docs released also?

I get this error from Sourceforge after clicking on
the  link at wxPython page.

Could not read file.

Go back.
/home/ftp/pub/sourceforge//w/wx/wxpython/wxPython2.7-win32-docs-demos-2.7.2.0.exe
Nov 08, 2006 07:10


--- Robin Dunn [EMAIL PROTECTED] wrote:

 Announcing
 --
 
 The 2.7.2.0 release of wxPython is now available for
 download at
 http://wxpython.org/download.php.  This is expected
 to be the last
 stepping stone in the path to the next stable
 release series,
 2.8.x. We're pushing full speed ahead in order to
 get 2.8.0 included
 with OSX 10.5, and so far we are very close to being
 on schedule. This
 release has some house-keeping style changes, as
 well as some
 user-contributed patches and also the usual crop of
 bug fixes.  Source
 and binaries are available for both Python 2.4 and
 2.5 for Windows and
 Mac, as well some pacakges for varous Linux
 distributions.  A summary
 of changes is listed below and also at
 http://wxpython.org/recentchanges.php.
 
 
 What is wxPython?
 -
 
 wxPython is a GUI toolkit for the Python programming
 language. It
 allows Python programmers to create programs with a
 robust, highly
 functional graphical user interface, simply and
 easily. It is
 implemented as a Python extension module that wraps
 the GUI components
 of the popular wxWidgets cross platform library,
 which is written in
 C++.
 
 wxPython is a cross-platform toolkit. This means
 that the same program
 will usually run on multiple platforms without
 modifications.
 Currently supported platforms are 32-bit Microsoft
 Windows, most Linux
 or other Unix-like systems using GTK2, and Mac OS X
 10.3+, in most
 cases the native widgets are used on each platform.
 
 
 Changes in 2.7.2.0
 --
 
 Patch [ 1583183 ] Fixes printing/print preview
 inconsistencies
 
 Add events API to wxHtmlWindow (patch #1504493 by
 Francesco Montorsi)
 
 Added wxTB_RIGHT style for right-aligned toolbars
 (Igor Korot)
 
 Added New Zealand NZST and NZDT timezone support to
 wx.DateTime.
 
 wx.Window.GetAdjustedBestSize is deprecated.  In
 every conceivable
 scenario GetEffectiveMinSize is probably what you
 want to use instead.
 
 wx.Image: Gained support for TGA image file format.
 
 wx.aui: The classes in the wx.aui module have been
 renamed to be more
 consistent with each other, and make it easier to
 recognize in the
 docs and etc. that they belong together.
 
  FrameManager --   AuiManager
  FrameManagerEvent --  AuiManagerEvent
  PaneInfo --   AuiPaneInfo
  FloatingPane --   AuiFloatingPane
  DockArt --AuiDockArt
  TabArt -- AuiTabArt
  AuiMultiNotebook --   AuiNotebook
  AuiNotebookEvent --   AuiNotebookEvent
 
 wx.lib.customtreectrl: A patch from Frame Niessink
 which adds an
 additional style (TR_AUTO_CHECK_PARENT) that
 (un)checks a parent when
 all children are (un)checked.
 
 wx.animate.AnimationCtrl fixed to display inactive
 bitmap at start
 (patch 1590192)
 
 Patch from Dj Gilcrease adding the
 FNB_HIDE_ON_SINGLE_TAB style flag
 for wx.lib.flatnotebook.
 
 wx.Window.GetBestFittingSize has been renamed to
 GetEffectiveMinSize.
 SetBestFittingSize has been renamed to
 SetInitialSize, since it is
 most often used only to set the initial (and
 minimal) size of a
 widget.
 
 The QuickTime backend for wx.media.MediaCtrl on MS
 Windows works
 again.  Just pass
 szBackend=wx.media.MEDIABACKEND_QUICKTIME to the
 constructor to use it instead of the default
 ActiveMovie backend,
 (assuming the quicktime DLLs are available on the
 system.)
 
 -- 
 Robin Dunn
 Software Craftsman
 http://wxPython.org  Java give you jitters?  Relax
 with wxPython!
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 


hello



 

Sponsored Link

Degrees online in as fast as 1 Yr - MBA, Bachelor's, Master's, Associate
Click now to apply http://yahoo.degrees.info
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Problem getting a file pathname with tkFileDialog

2006-11-09 Thread Eric Brunel
On Wed, 08 Nov 2006 20:01:08 +0100, [EMAIL PROTECTED] wrote:

 Hello,
 I am working on a school project that requires me to get the path of a
 filename for future treatment.
 I've tried getting a file with tkFileDialog.askopenfile.


 
 import tkFileDialog
 file = tkFileDialog.askopenfile()
 print file
 


 It prints the opened files stuff, but I just can not find how to get
 that path as a string. I've searched around google and the present
 group, and found no documentation on the file class used with
 tkFileDialog. Does someone have a solution for that?

Use tkFileDialog.askopenfilename?

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-09 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], skip wrote:

 
 Irmen So there. Finally back on the original subject ;-)
 
 And without satisfying Godwin's Law.  Pretty good.

Which was very hard with all those language nazis out there.  Ooops…

SCNR,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Problem getting a file pathname with tkFileDialog

2006-11-09 Thread Eric Brunel
On Wed, 08 Nov 2006 21:59:38 +0100, Tim Daneliuk [EMAIL PROTECTED]  
wrote:

 Sefyroth wrote:
 Thanks,
  but I get this error when I try this.
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
 position 12: ordinal not in range(128)
   I had encountered it with the askdirectory method as well. Is there an
 easy way to bypass this?
  Thanks again

 I believe you are running into a directory or file name that has
 non-ascii characters in it.  Python as shipped is set up to
 deal with ascii as its native encoding format.  You can change
 this by editing the site.py file - look in the Lib directory
 in your python installation.  Look for this code:

 ---
 def setencoding():
  Set the string encoding used by the Unicode implementation.  The
  default is 'ascii', but if you're willing to experiment, you can
  change this.
  encoding = ascii # Default value set by _PyUnicode_Init()
  if 0:
  # Enable to support locale aware default string encodings.
  import locale
  loc = locale.getdefaultlocale()
  if loc[1]:
  encoding = loc[1]
 ---



 Change the if 0: to if 1: and see if that doesn't fix the problem.

This is usually a bad idea, especially if the script must be distributed  
to other users in any way: since they probably never did this trick, the  
code will fail when they use it.

I know it's a pain, but you *have* to deal with encodings yourself, and  
not let the system guess what you might want.

In the OP's case, the problem just lies in the 'print' statement, that  
tries to encode the file name in ASCII before printing it. So just doing:
print repr(file.name)
would solve the problem.

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem getting a file pathname with tkFileDialog

2006-11-09 Thread jmdeschamps

Tim Daneliuk wrote:
 Sefyroth wrote:
  Thanks,
 
  but I get this error when I try this.
 
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
  position 12: ordinal not in range(128)
 
   I had encountered it with the askdirectory method as well. Is there an
  easy way to bypass this?
 
  Thanks again

 I believe you are running into a directory or file name that has
 non-ascii characters in it.  Python as shipped is set up to
 deal with ascii as its native encoding format.  You can change
 this by editing the site.py file - look in the Lib directory
 in your python installation.  Look for this code:

 ---
 def setencoding():
  Set the string encoding used by the Unicode implementation.  The
  default is 'ascii', but if you're willing to experiment, you can
  change this.
  encoding = ascii # Default value set by _PyUnicode_Init()
  if 0:
  # Enable to support locale aware default string encodings.
  import locale
  loc = locale.getdefaultlocale()
  if loc[1]:
  encoding = loc[1]
 ---



 Change the if 0: to if 1: and see if that doesn't fix the problem.



 --
 
 Tim Daneliuk [EMAIL PROTECTED]
 PGP Key: http://www.tundraware.com/PGP/

you could also use encode(iso-8859-1) to nterpret just the printed
name such as:
print myfilename.encode(iso-8859-1)

and by the way if you wanted the file NAME you could have used
openfilename() instead of openfile();-)

jean-marc

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


Re: opening excel

2006-11-09 Thread timmy
John Machin wrote:
 timmy wrote:
 
Hello,

has anybody got any experience opening and manilpulating excel
spreedsheets via python? it seems pythoncom allows this to happen but
i'm a total newb to it. (i usually work in the unix world)
all i need to do, is open the xls files and read values from it.
 
 
 If you really mean read rather than manipulate, have a look at the
 xlrd package (of which I'm the author).
 
 http://www.python.org/pypi/xlrd
 
 BTW, it's pure Python; you can run it on your unix box if you like :-)
 
 Cheers,
 John
 

sweet thats what i'd like to do
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: match for ImageMagick's display -ping

2006-11-09 Thread Mohammad Tayseer
 import Image im = Image.open('myimage.jpg') im.size(200, 100)PIL reads the header only in the Image.open() call above. 


Sponsored Link
Mortgage rates near 39yr lows. $420,000 Mortgage for $1,399/mo - Calculate new house payment-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Jogos

2006-11-09 Thread Douglas Soares de Andrade
Em Quarta 08 Novembro 2006 13:29, [EMAIL PROTECTED] escreveu:
 Jogo da velha
 Jogo do galo
 Codigos em python kem me arranja

 Please excuse me for talking in portuguese here, just want to show the 
better place for Manelito to ask this.

Olá Manelito,

O idioma usado nessa lista é o inglês, caso não se sinta a vontade em fazer 
pergutas em inglês, favor perguntar na lista do grupo pythonbrasil.

Acesse o site aí: www.pythonbrasil.com.br

Até

-- 
Douglas Soares de Andrade
msn: [EMAIL PROTECTED]
jabber: [EMAIL PROTECTED]
Quote: Real programmers don't die, they just GoSub and Return.
-- 
http://mail.python.org/mailman/listinfo/python-list


IndentationError: expected an indented block

2006-11-09 Thread Antonios Katsikadamos
hi all. I am using python 2.4. I have to run an older python code and when i run it i get the following messageIndentationError: expected an indented block.1)what does this mean?2)how can i overcome this problemThanks for any advice.kind regards,Antonios 
	




Sponsored LinkMortgage rates near historic lows: $150,000 loan as low as $579/mo. Intro-*Terms-- 
http://mail.python.org/mailman/listinfo/python-list

Re: tkFileDialog

2006-11-09 Thread Mohammad Tayseer
use askopenfilename() instead of askopenfile()  import tkFileDialog file = tkFileDialog.askopenfile() print file  


Access over 1 million songs - Yahoo! Music Unlimited.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python cgi Apache os.system()

2006-11-09 Thread naima . mans
Hello

thanks for your help..

it was a problem of path as you mentionned... my command was O:\\
ccm start and i have change it with the path of the drive O

thanks a lot
 have a good day

Tachi

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


Re: opening excel

2006-11-09 Thread wesley chun
 has anybody got any experience opening and manilpulating excel
 spreedsheets via python? it seems pythoncom allows this to happen


i posted a couple of snippets along with others in this earlier thread:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/a7ed60067ca5a8d4

the XLRD package is a platform-independent non-COM way to *extract*
Excel data. you mentioned opening and manipulating spreadsheets
*using* COM, so there are more examples targeted towards what you were
asking for at that link.

i added a small section on Win32 COM client programming to the Core
Python book, and although it doesn't go extremely in-depth, it's
perfectly targeted to newbs coming from the Unix world, as was i.

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Core Python Programming, Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: BayPIGgies, Thu Nov 9 @ 7:30p, Air Traffic Control

2006-11-09 Thread wesley chun
the silicon valley-san francisco bay area python users group meets at
the Googleplex once a month in mountain view, CA.
more info and directions available at http://baypiggies.net


-- Forwarded message --
From: Dennis Reinhardt
Date: Nov 2, 2006 9:03 PM
To: Python [EMAIL PROTECTED]

Thursday Nov. 9, 2006

7:30-8:50 p.m.   Technical Program

Title  Python for Prototyping in Air Traffic Control
Presenter  Russ Paielli (NASA Ames Research)
About the talk The talk will start with a high-level overview of the US air
traffic control system, then it will focus on tactical (i.e., short range)
conflict alerting and describe the prototype software that we are
developing to replace the legacy software that currently performs that
function. Examples of actual operational errors will be presented, and
the alerting performance of our system will be tested and compared with the
legacy system. The rationale for using Python for the prototype and its
testing will be briefly discussed.

8:50 p.m-...Mapping and Random Access
--
Mapping Moderator  Dennis Reinhardt (DAIR Computer Systems)
Mapping is a rapid-fire audience announcement open to all of topic headings
(one speaker at a time). Random Access session (everyone breaks up into
self-organized small-group discussion) follows immediately after Mapping.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python to tell what is the IP of my PC .

2006-11-09 Thread MC
http://monip.org/

-- 
@-salutations

Michel Claveau


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


Re: assigning values in __init__

2006-11-09 Thread Steven D'Aprano
On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:

 John Salerno [EMAIL PROTECTED] writes:
 
 Ben Finney wrote:
  If you pass a *mapping* of the
  I-might-want-to-add-more-in-the-future values, then you get both
  explicit *and* expandable, without an arbitrary unneeded sequence.

 Do you mean by using the **kwargs parameter?
 
 No. 

Well, that'll teach me to put words in your mouth.

[snip]
 If you have a group of named, semantically-related, unsequenced values,
 pass them into the function as a mapping object (a dict object).

Still, if you are doing this:

mapping_object = {strength: roll_dice(10),
intelligence:roll_dice(10),
dexterity:roll_dice(10)}
my_character = Character(mapping_object)

then there is little benefit to building the dict just for the purposes of
passing it to Character(), never to use it again, not when you can do this:

my_character = Character(strength: roll_dice(10), 
intelligence:roll_dice(10), dexterity:roll_dice(10))

If you happen to already have collected your character attributes in a
mapping object for some other reason, then well and good, pass it into the
function. Otherwise, well, I believe the correct container for
character attributes is a Character, not a dict.

-- 
Steven.

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


win32com/python different behavour.

2006-11-09 Thread bli
I have been developing an application driving a device through COM. I
used win32com (brilliant )
and was at a fairly advanced stage being able to access the functions
of the device and access/ retrieve its data.
A week or two ago I did some overdue upgrading to all the components of
the application.win32com, python to 2.4.4 and wxpy to latest.
Then the problem began (I think!).
My app still accesses the device and some functions still perform as
expected. Howeve some important data retrieval functions now behave
very differently.
Initially a tuple was returned, which was made into a list. This tuple
returned (true,'1234xyz'), the first element was the success or failure
of the operation, the second the required data.
Now all these functions return only the boolean, True or False.
I cannot seem to produce the tuple that initially worked extremely
well.

eg. initially

xx.GetMACAddr(param1,param2)  -- params as per 'intellisense' would
return
(True,'123xyz')

now
xx.GetMACAddr(param1,param2)  returns
True(type boolean)

I have exhausted my relative inexperience on this one.
Any Ideas  BTW VB extracts the data just fine , so I dont think that
the Device or firmware is at fault here.
Python has been great so far, I trust this problem is an oversight on
my part.

Thanks in keen anticipation for any ideas to get over this one!!

I am in the middle of returning to Python 2.4.3 just to be sure that
this is not the issue.

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


Sorted list - how to change it

2006-11-09 Thread Lad
I have a sorted list for example [1,2,3,4,5] and I would like to change
it in a random way
e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
ordered.
What is the best/easiest
 way how to do it?

Thank you for help
L.

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


Re: Sorted list - how to change it

2006-11-09 Thread Wolfram Kraus
On 09.11.2006 10:52, Lad wrote:
 I have a sorted list for example [1,2,3,4,5] and I would like to change
 it in a random way
 e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
 ordered.
 What is the best/easiest
  way how to do it?
 
 Thank you for help
 L.
 
use random.shuffel:

 import random
 x = [1,2,3,4,5]
 random.shuffle(x)
 x
[1, 4, 2, 3, 5]
 random.shuffle(x)
 x
[4, 2, 1, 3, 5]

see: http://docs.python.org/lib/module-random.html

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


Re: Sorted list - how to change it

2006-11-09 Thread Lad

Wolfram Kraus wrote:
 On 09.11.2006 10:52, Lad wrote:
  I have a sorted list for example [1,2,3,4,5] and I would like to change
  it in a random way
  e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
  ordered.
  What is the best/easiest
   way how to do it?
 
  Thank you for help
  L.
 
 use random.shuffel:

  import random
  x = [1,2,3,4,5]
  random.shuffle(x)
  x
 [1, 4, 2, 3, 5]
  random.shuffle(x)
  x
 [4, 2, 1, 3, 5]

 see: http://docs.python.org/lib/module-random.html
 Wolfram,
Thanks a lot for help
L.

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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Lich_Ray
jEdit
Vim, it can handle all the things.
http://www.vim.org/

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


Re: Is there a commas-in-between idiom?

2006-11-09 Thread Magnus Lycka
Ernesto García García wrote:
 list = [1,2,3,4,5,6]

Just a nit-pick: It's considered an anti-idiom
to hide builtins just as list by using it as a
name for a variable.

  list=[1,2,3,4,5]
  tuple = (1,2,3,4,5)
  if list == list(tuple): print equal
...
Traceback (most recent call last):
   File stdin, line 1, in ?
TypeError: 'list' object is not callable
  #ouch!
...
  l=list
  del list
  if l == list(tuple): print equal
...
equal
  if tuple(l)==tuple: print equal
...
Traceback (most recent call last):
   File stdin, line 1, in ?
TypeError: 'tuple' object is not callable
  t=tuple
  del tuple
  if tuple(l)==t: print equal
...
equal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorted list - how to change it

2006-11-09 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Lad wrote:

 I have a sorted list for example [1,2,3,4,5] and I would like to change
 it in a random way
 e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
 ordered.

lst = [1, 2, 3, 4, 5]
tmp = list(lst)
while lst == tmp:
random.shuffle(lst)

If you *really* want to be sure it's not sorted after shuffling.  :-)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help using smtplib to work ..

2006-11-09 Thread Tim Williams
On 8 Nov 2006 19:45:00 -0800, Jordan [EMAIL PROTECTED] wrote:

  For some reason,
 smtp for gmail seems to require that you call server.ehlo() a second
 time, after having called server.starttls(), otherwise, the server
 won't accept authorization.  Thanks.

Not just GMAIL,  all (RFC Compliant) SMTP servers require a 2nd EHLO
after a successful STARTTLS command.

The list of returned options / available commands will usually be
different for the 2nd EHLO.  Often this will just mean the removal of
the STARTTLS option, but sometimes there can be additional
functionality offered.

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


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Nick Craig-Wood
John Salerno [EMAIL PROTECTED] wrote:
  Dan Lenski wrote:
 
  So, is there another toolkit I should be looking at?
 
  I highly recommend wxPython.

I'd second that!

There is a book also

  WxPython in Action

  http://www.amazon.com/Wxpython-Action-Noel-Rappin/dp/1932394621

Which is certainly my preferred way of learning new stuff!

  It's very mature, full-featured, and portable, and fairly easy to
  learn as well.

...with native look and feel on each platform unlike GTK / TK

It has got a huge set of widgets and an excellent demo program in
which you can try them all out and steal their code.

There are some bits of it in which the C++ heritage sticks out, but
over the years the toolkit designers have been tucking those under the
carpet.  The MethodNaming is a bit odd too!

A minor annoyance is that there are a number of features which only
work on a subset of the platforms.  These are well documented though.

IMHO the best of the toolkits, but it is a personal choice and yours
may differ!

There is also PyQT which we wrote off as we wanted to write commercial
applications too.  As it happens we have a commercial QT licence, but
we decided we didn't want to have to incurr the additional expense of
renewing it.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Christophe
Nick Craig-Wood a écrit :
 There is also PyQT which we wrote off as we wanted to write commercial
 applications too.  As it happens we have a commercial QT licence, but
 we decided we didn't want to have to incurr the additional expense of
 renewing it.
Note: Nothing in the GPL prevents you from writting commecial software ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


cx_Oracle and NCLOBs

2006-11-09 Thread [12]Nitro
Greetings,

I'm currently working in a Python project to create a multi-platform
database replication tool, and cx_Oracle was the chosen provider to
handle the Oracle connections. So far the results have been very
interesting, but I've been experiencing some problems when inserting
CLOB objects through executemany (meaning, using a pre-prepared
statement and a dynamic list of parameters). Namely, somehow the
provider seems to be converting the data to LONG rather than to CLOB,
even though the statement explicitly calls out the TO_NCLOB function;
therefore, we get ORA-01461 errors.
Now, this may possibly not be an error, but instead a misusage (not
many examples available, anyways). Any help/suggestion you can provide?

Best regards,
Nitro

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


Re: assigning values in __init__

2006-11-09 Thread Antoon Pardon
On 2006-11-09, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:

 John Salerno [EMAIL PROTECTED] writes:
 
 Ben Finney wrote:
  If you pass a *mapping* of the
  I-might-want-to-add-more-in-the-future values, then you get both
  explicit *and* expandable, without an arbitrary unneeded sequence.

 Do you mean by using the **kwargs parameter?
 
 No. 

 Well, that'll teach me to put words in your mouth.

 [snip]
 If you have a group of named, semantically-related, unsequenced values,
 pass them into the function as a mapping object (a dict object).

 Still, if you are doing this:

 mapping_object = {strength: roll_dice(10),
 intelligence:roll_dice(10),
 dexterity:roll_dice(10)}
 my_character = Character(mapping_object)

 then there is little benefit to building the dict just for the purposes of
 passing it to Character(), never to use it again, not when you can do this:

 my_character = Character(strength: roll_dice(10), 
 intelligence:roll_dice(10), dexterity:roll_dice(10))

But you will have to adapt this if you want extra or different
characteristics.

Personnally I would prefer something like:

  chardict = {}
  for char in characteristics:
chardict[char] = roll_dice(10)

  my_character = Character(chardict)

This way you only have to keep your characteristics in one place.

 If you happen to already have collected your character attributes in a
 mapping object for some other reason, then well and good, pass it into the
 function. Otherwise, well, I believe the correct container for
 character attributes is a Character, not a dict.

What is wrong with keeping the character attributes in a dict in the
Character?

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


Re: substring search without using built in utils

2006-11-09 Thread Bruno Desthuilliers
Gabriel Genellina wrote:
 At Wednesday 8/11/2006 22:29, zeal elite wrote:
 
 I am looking for substring search python program without using the
 built in funtions like find, or 'in'.
 
 The only reasonable usage for such a constraint would be a school
 assignment so: don't cheat and do your homework!
 

OTHO, looking for existing solutions to a same or similar problem and
studying them is usually considerer good practice in real-life
programming jobs !-)

-- 
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: Sorted list - how to change it

2006-11-09 Thread Tim Chase
 I have a sorted list for example [1,2,3,4,5] and I would like to change
 it in a random way
 e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
 ordered.
 What is the best/easiest
  way how to do it?

 use random.shuffel:
 
 import random
 x = [1,2,3,4,5]
 random.shuffle(x)
 x
 [1, 4, 2, 3, 5]


Just a caveat from past experience...while the OP was talking 
about lists, for future reference random.shuffle() chokes on 
strings (and possibly tuples).  It requires the ability to edit 
the target/parameter in place...a functionality that strings 
don't provide.

Thus, for a word jumble program I was playing with, you can't 
just do

word = 'hello'
random.shuffle(word)

but rather you have to list'ify the word, shuffle it, then pack 
it back together:

word = 'hello'
a = list(word)
random.shuffle(a)
word = ''.join(a)

I remember seeing discussion on the list at one point of a 
MutableString class, which might be successfully passed to 
random.shuffle() without hiccuping.

-tkc



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


Re: Sorted list - how to change it

2006-11-09 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Marc 'BlackJack' Rintsch
wrote:

 lst = [1, 2, 3, 4, 5]
 tmp = list(lst)
 while lst == tmp:
 random.shuffle(lst)

Argh, that fails if the list is empty or contains just one item.

lst = [1, 2, 3, 4, 5]
if len(lst)  1:
tmp = list(lst)
while lst == tmp:
random.shuffle(lst)

Ciao,
Marc 'BlackJack' Rintsch

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


Re: substring search without using built in utils

2006-11-09 Thread John Machin

Bruno Desthuilliers wrote:
 Gabriel Genellina wrote:
  At Wednesday 8/11/2006 22:29, zeal elite wrote:
 
  I am looking for substring search python program without using the
  built in funtions like find, or 'in'.
 
  The only reasonable usage for such a constraint would be a school
  assignment so: don't cheat and do your homework!
 

 OTHO, looking for existing solutions to a same or similar problem and
 studying them is usually considerer good practice in real-life
 programming jobs !-)


Looking at an existing solution for substring search that was coded in
Python, instead of using the built-in functionality would IMHO be
considered extremely bad practice in a real-life programming job.

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


Re: Is there a commas-in-between idiom?

2006-11-09 Thread Peter van Kampen
On 2006-11-08, Georg Brandl [EMAIL PROTECTED] wrote:
 Peter van Kampen schrieb:
 On 2006-11-06, Fredrik Lundh [EMAIL PROTECTED] wrote:
 I've collected a bunch of list pydioms and other notes here:

 http://effbot.org/zone/python-list.htm
 
 
 A = B = [] # both names will point to the same list
 
 
 I've been bitten by this once or twice in the past, but I have always
 wondered what it was useful for? Can anybody enlighten me?

 Do you never have a situation where you want to assign the same value
 to two variables?

In the sense that I might want two empty lists or maybe 2 ints that
are initialised as 0 (zero). That's what I (incorrectly) thought A = B
= [] did.

 Or are you objecting to the fact that both names point to the same
 object?

I'm not objecting to anything, merely wondering when I could/should
use this idiom. There's a nice example in another response (self.items
= items = [])

 It couldn't be otherwise. Consider:

 X = []
 A = B = X

 What should this do? Copy X and assign one copy to A, one to B?

Ah yes, I see the error in my ways...I skipped the A = B part too
lightly.

Thanks,

PterK


-- 
Peter van Kampen
pterk -- at -- datatailors.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a commas-in-between idiom?

2006-11-09 Thread Peter van Kampen
On 2006-11-08, Gabriel Genellina [EMAIL PROTECTED] wrote:
 At Wednesday 8/11/2006 16:51, Peter van Kampen wrote:


A = B = [] # both names will point to the same list


I've been bitten by this once or twice in the past, but I have always
wondered what it was useful for? Can anybody enlighten me?

 As an optimization, inside a method, you can bind an instance 
 attribute and a local name to the same object:

  def some_action(self):
  self.items = items = []
  // following many references to self.items,
  // but using items instead.

 Names in the local namespace are resolved at compile time, so using 
 items is a lot faster than looking for items inside self's 
 namespace each time it's used.

Nice example.

Thanks,

PterK

-- 
Peter van Kampen
pterk -- at -- datatailors.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cx_Oracle and NCLOBs

2006-11-09 Thread Bernard Delmée
Sorry I have no direct answer for you, but suspect you should
post to the cx_Oracle group. Check the sourceforge project page.
It is also conveniently mirrored at news.gmane.org.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-09 Thread Paul Boddie
robert wrote:
 Shane Hathaway wrote:
  of multiple cores.  I think Python only needs a nice way to share a
  relatively small set of objects using shared memory.  POSH goes in that
  direction, but I don't think it's simple enough yet.
 
  http://poshmodule.sourceforge.net/

 interesting, a solution possibly a little faster than pickling - but maybe 
 only in selected
 situations. Made already experiments with pickling through shared memory.

What did you discover in your experiments? I'd certainly suspect that
pickling is going to add an unacceptable degree of overhead in the kind
of application you're attempting to write (using a shared data
structure with random access properties), and I'll admit that I haven't
really had to deal with that kind of situation when using my own
pickle-based parallelisation solutions (which involve communicating
processes).

 With x = posh.share(x) an object tree will be (deep-)copied to shared mem ( 
 as far as
 objects fullfil some conditions 
 http://poshmodule.sourceforge.net/posh/html/node6.html: is
 this true for numpy arrays?)

My impression is that POSH isn't maintained any more and that work was
needed to make it portable, as you have observed. Some discussions did
occur on one of the Python development mailing lists about the
possibility of using shared memory together with serialisation
representations faster than pickles (which also don't need to be
managed as live objects by Python), and I think that this could be an
acceptable alternative.

 Every object to be inserted in the hot tunnel object tree has to be copied 
 that same style.
 Thus ~pickling, but somewhat easier to use.

If my understanding of hot tunnel object tree is correct, you're
really wanting fast access involving mutual exclusion to some shared
data structure. At this point it becomes worth considering some kind of
distributed object technology (or even a database technology) where you
have to initialise the data structure and then communicate with an
object (or database) to perform operations on it, all for reasons I'll
explain shortly.

In your ideal situation, you say that you'd have the data structure in
the same address space as a number of threads, and each thread would be
able to perform some algorithm on the data structure, but the pattern
of accessing the structure isn't an insignificant concern even where
you can assume that the overheads are generally low: reading and
writing things might be fast in the same address space, but if the
nature of access involves lots of locking, you'll incur quite a penalty
anyway. In other words, if each read or write to the structure involves
acquiring a lock for that operation in isolation, this could
significantly diminish performance, whereas if you can guarantee that
the granularity of locking is more coarse than having to occur upon
each read or write access - that there exist some high-level operations
that require consistency within the data structure - then reasonable
performance might be maintained.

However, if the pattern of concurrent access is restricted to coarse
operations, where some entity has exclusive access to a potentially
large dataset, and where the overhead of the communication of inputs
and outputs to and from that entity is low in comparison to the cost of
performing such coarse operations, and where such operations are
themselves performed infrequently, then such a pattern coincides with
classic database or distributed object scenario. In other words, you
implement the operations acting on the data structure in a distributed
object (or as a database query or operation) and then invoke such
operations from separate processes.

I hope this makes some sense. Generally, demands for high concurrent
performance using threads often ignore other important properties such
as reliability and scalability. Certainly, threads have an important
place - classically, this involved maintaining responsiveness in
graphical user interfaces - but even then, the background threads were
often detached and not competing for the same resources as the
foreground threads servicing the event loop. The only kinds of
situation I can think of right now which might benefit from uninhibited
random access to shared data structures might be things like
simulations or large-scale multi-user games, where an appropriate data
architecture cannot be decided in advance, but even then there are
approaches which attempt to mitigate the seemingly unpredictable nature
of access to shared data.

Paul

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


Re: Sorted list - how to change it

2006-11-09 Thread Christophe
Lad a écrit :
 I have a sorted list for example [1,2,3,4,5] and I would like to change
 it in a random way
 e.g [2,5,3,1,4] or [3,4,1,5,2]  or in any other way except being
 ordered.
 What is the best/easiest
  way how to do it?
 
 Thank you for help
 L.
Not accepting that the shuffle outputs the same list as entered would 
make the random less random :)

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


Re: Exception Handling in TCPServer (was; Problem exiting application in Windows Console.)

2006-11-09 Thread Ant
Steve Holden wrote:
...
 First of all, five hour response time is a high expectation, you must be
 a Platinum customer :-)

I'm in the last week of my current job - start a new one on Monday, and
so I haven't got a great deal to do at the moment. Five hours is a
lifetime when you're staring at a newsgroup waiting for it to change
;-)

 Secondly, while a try/except catching all exceptions *is* unusual it's
 justifiable in a server context (though some logging and/or analysis
 certainly wouldn't go amiss).

True. And I'd expected that the exception ought to be passed to the
handle_error method so that something could be done with it there. This
morning however I discovered that Guido's been in his time machine
since yesterday and provided the very useful sys.exc_info() function
for this very purpose!

 Thirdly your ugly hack *could* be replaced by something cleaner with
 more analysis of the trace structure, but given how infrequently this
 code is going to run and the low probability that anything else will
 trigger the hook I'd be happy with it as it is. But that's just me ...

The sys.exc_info()  was what I was looking for it turns out, I can get
the exception type from that instead of trying to parse the stack
trace.

However:

Gabriel Genellina wrote:
...
 Replace serve_forever with your own loop checking an exit flag, and
 set the flag in your quit.html handler instead of sys.exit(0)

This is the approach I decided to go for. I found that RequestHandler
objects have a reference to its server that I can use to control the
server.

Thanks for the input chaps!

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


Post data using the libcurl

2006-11-09 Thread Raj
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont get any errors, i am
nt able to get the o/p Can anyone kindly help. i will attach the
program here
#include curl/curl.h
 #include curl/types.h
 #include curl/easy.h

 int main(int argc, char *argv[])
 {
   CURL *curl;
   CURLcode res;

   struct curl_httppost *formpost=NULL;
   struct curl_httppost *lastptr=NULL;
   struct curl_slist *headerlist=NULL;
   char buf[] = Expect:;

   curl_global_init(CURL_GLOBAL_ALL);

   /* Fill in the file upload field */
   curl_formadd(formpost,
  lastptr,
CURLFORM_COPYNAME, rajani.vemula,
CURLFORM_END);

   /* Fill in the filename field */
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, x,
CURLFORM_END);
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, null,
CURLFORM_COPYCONTENTS, Sign in,
CURLFORM_END);




   curl = curl_easy_init();
   /* initalize custom header list (stating that Expect: 100-continue
is
 not
  wanted */
   headerlist = curl_slist_append(headerlist, buf);
   if(curl) {
 /* what URL that receives this POST */
 curl_easy_setopt(curl, CURLOPT_URL,
http://mail.google.com/mail;);
 curl_easy_setopt(curl, CURLOPT_PROXY, proxyname);
   curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, User:Password);
   /* only disable 100-continue header if explicitly requested */
   curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
 curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
 res = curl_easy_perform(curl);

 /* always cleanup */
 curl_easy_cleanup(curl);

 /* then cleanup the formpost chain */
 curl_formfree(formpost);
  curl_slist_free_all(headerlist
  }
   return 0;
 }

Thanks

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


Post data using the libcurl

2006-11-09 Thread Raj
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont get any errors, i am
nt able to get the o/p Can anyone kindly help. i will attach the
program here
#include curl/curl.h
 #include curl/types.h
 #include curl/easy.h

 int main(int argc, char *argv[])
 {
   CURL *curl;
   CURLcode res;

   struct curl_httppost *formpost=NULL;
   struct curl_httppost *lastptr=NULL;
   struct curl_slist *headerlist=NULL;
   char buf[] = Expect:;

   curl_global_init(CURL_GLOBAL_ALL);

   /* Fill in the file upload field */
   curl_formadd(formpost,
  lastptr,
CURLFORM_COPYNAME, rajani.vemula,
CURLFORM_END);

   /* Fill in the filename field */
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, x,
CURLFORM_END);
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, null,
CURLFORM_COPYCONTENTS, Sign in,
CURLFORM_END);




   curl = curl_easy_init();
   /* initalize custom header list (stating that Expect: 100-continue
is
 not
  wanted */
   headerlist = curl_slist_append(headerlist, buf);
   if(curl) {
 /* what URL that receives this POST */
 curl_easy_setopt(curl, CURLOPT_URL,
http://mail.google.com/mail;);
 curl_easy_setopt(curl, CURLOPT_PROXY, proxyname);
   curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, User:Password);
   /* only disable 100-continue header if explicitly requested */
   curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
 curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
 res = curl_easy_perform(curl);

 /* always cleanup */
 curl_easy_cleanup(curl);

 /* then cleanup the formpost chain */
 curl_formfree(formpost);
  curl_slist_free_all(headerlist
  }
   return 0;
 }

Thanks

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


Post data to http server using libcurl

2006-11-09 Thread Raj
Hi,
I am newbie to programming with libcurl. the problem is i want to send
my gmail username and password outside the browser and get access to my
mail. this i am doing with LibCurl. Though i dont get any errors, i am
nt able to get the o/p Can anyone kindly help. i will attach the
program here
#include curl/curl.h
 #include curl/types.h
 #include curl/easy.h

 int main(int argc, char *argv[])
 {
   CURL *curl;
   CURLcode res;

   struct curl_httppost *formpost=NULL;
   struct curl_httppost *lastptr=NULL;
   struct curl_slist *headerlist=NULL;
   char buf[] = Expect:;

   curl_global_init(CURL_GLOBAL_ALL);

   /* Fill in the file upload field */
   curl_formadd(formpost,
  lastptr,
CURLFORM_COPYNAME, rajani.vemula,
CURLFORM_END);

   /* Fill in the filename field */
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, x,
CURLFORM_END);
   curl_formadd(formpost,
lastptr,
CURLFORM_COPYNAME, null,
CURLFORM_COPYCONTENTS, Sign in,
CURLFORM_END);




   curl = curl_easy_init();
   /* initalize custom header list (stating that Expect: 100-continue
is
 not
  wanted */
   headerlist = curl_slist_append(headerlist, buf);
   if(curl) {
 /* what URL that receives this POST */
 curl_easy_setopt(curl, CURLOPT_URL,
http://mail.google.com/mail;);
 curl_easy_setopt(curl, CURLOPT_PROXY, proxyname);
   curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, User:Password);
   /* only disable 100-continue header if explicitly requested */
   curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
 curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
 res = curl_easy_perform(curl);

 /* always cleanup */
 curl_easy_cleanup(curl);

 /* then cleanup the formpost chain */
 curl_formfree(formpost);
  curl_slist_free_all(headerlist
  }
   return 0;
 }

Thanks

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-09 Thread Paul Boddie
Cliff Wells wrote:

 But of course not everyone is a double-edged sword that can just as
 easily be turned against either party.  If we limit ourselves to saying
 what is going to be the most palatable for the widest audience we will
 most likely find ourselves confined to discussing the weather.

I recall at this point the advice once given to writers submitting
articles to Linux Journal:

Be careful with humor. Sarcasm and irony are misread easily and can be
offensive. Many readers have English as a second language and may not
be familiar with your culture's running jokes and topical matters.

http://www.linuxjournal.com/xstatic/author/authguide

 And of course, people who worry too much about impressing others rarely
 do.  Just ask DHH of Ruby on Rails fame:

 http://static.flickr.com/47/127984254_ddd4363d6a_m.jpg

Yes, but not everyone is happy about that:

DHH has just got to stop saying [word elided] at conferences.

https://www.lostlake.org/blog/index.php?/archives/11-The-Impending-Ruby-Fracture.html#c36

There's a clear difference between using profanity for dramatic effect
(acceptable in various contexts) and going round like a twelve year
old, mouthing off in an attempt to impress or shock people.

[...]

 I'll apply an old software maxim (from sendmail?) to the topic of public
 interaction: Be liberal in what you accept, conservative in what you
 send.  Applying this would suggest that both parties were equally at
 fault in this situation, so perhaps we can just leave it at that.

I think this is reasonable advice.

Paul

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


[Ann] ctypes wiki

2006-11-09 Thread Thomas Heller
I have installed a wiki which could / should be used to document the ctypes 
package and
ctypes related packages (like comtypes, for example).

ctypes is a foreign function library for Python:

http://starship.python.net/crew/theller/ctypes/

I hope the wiki will evolve over time into a useful resource.

Currently there is no actual contents - so please contribute by adding tips, 
tricks,
and whatever you have to share about ctypes.

The wiki URL is:

  http://starship.python.net/crew/theller/wiki

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


Antivirus Notification

2006-11-09 Thread virusalert
InterScan Messaging Security Suite notification---BeginMessage---
The original message was received at Thu, 9 Nov 2006 13:26:55 +0100 from 
python.org [175.113.10.251]

- The following addresses had permanent fatal errors -
[EMAIL PROTECTED]

- Transcript of the session follows -
... while talking to 132.36.179.145:
 DATA
 400

We have removed message.zip(message.scr) from this email because it is not part 
of our content security policy.---End Message---
-- 
http://mail.python.org/mailman/listinfo/python-list

newbie class-building question

2006-11-09 Thread jrpfinch
I am constructing a simple class to make sure I understand how classes
work in Python (see below this paragraph).

It works as expected, except the __add__ redefinition.  I get the
following in the Python interpreter:

 a=myListSub()
 a
[]
 a+[5]
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: 'str' object is not callable


Please could you let me know where I am going wrong.  I have hacked
around with the code and tried googling this error message but am
having difficulty finding the source of the problem.

Many thanks

Jon

class myList:
def __init__ (self,value=[]):
self.wrapped=[]
for x in value :
self.wrapped.append(x)
def __repr__ (self):
return `self.wrapped`
def __getattr__ (self,attrib):
return getattr(self.wrapped,attrib,'attribute not found')
def __len__ (self):
return len(self.wrapped)
def __getitem__ (self,k):
return self.wrapped[k]
def __add__(self,other):
return self.wrapped+other

class myListSub(myList):
classCounter=0
def __init__ (self,value=[]):
self.instanceCounter=0
myList.__init__(self,value)
def __add__(self,other):
myListSub.classCounter=myListSub.classCounter+1
self.instanceCounter=self.instanceCounter+1
myList.__add__(self,other)
def getCounters (self):
return classCounter=%s instanceCounter=%s %
(myListSub.classCounter,self.classCounter)

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


Re: substring search without using built in utils

2006-11-09 Thread Bernard
do your homework and use regexes! but the find() and in() function
works great for normal strings...why don't you want to use them?

zeal elite a écrit :

 Hi,

 I am looking for substring search python program without using the built in
 funtions like find, or 'in'.

 Appreciate it. Thanks in advance.
 zeal

 _
 Find a local pizza place, music store, museum and more...then map the best
 route!  http://local.live.com?FORM=MGA001

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


Multithreaded C API Python questions

2006-11-09 Thread Svein Seldal
Hi

A couple of mulithreaded C API python questions:

I) The PyGILState_Ensure() simply ensures python api call ability, it 
doesnt actually lock the GIL, right?

PyGILState_STATE gstate;
gstate = PyGILState_Ensure();

II) Am I required to lock the GIL prior to running any python functions 
(in a threaded app)?

PyThreadState *pts = PyGILState_GetThisThreadState();
PyEval_AcquireThread(pts);
PyObject_CallObject(...);

III) Shouldn't the GIL be released after 100 bytecodes or so to enable 
other waiting threads to get the GIL?

I'm unable to get access to python as long as another python call is 
executing. The PyEval_AcquireThread() call blocks until the first call 
returns. I was hoping that the python system itself would release the 
GIL after some execution, but it itsnt.

I am dependent upon the ability to have to threads executing in python 
land at the same time. How can this be done?


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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Ant


On Nov 9, 6:52 am, BillJosephson [EMAIL PROTECTED] wrote:
...
 If anyone knows why i can't connect, in info about it would be
 a big help.

Sounds like the default mirror is down. Go to Utilities - Global
Options - Plugin Manager and click on Update mirror list. Choose a
new mirror and try again. If that still fails, it may be that you need
to set up your proxy server properly.

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


Re: assigning values in __init__

2006-11-09 Thread Steven D'Aprano
On Thu, 09 Nov 2006 10:36:07 +, Antoon Pardon wrote:

 On 2006-11-09, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:

 John Salerno [EMAIL PROTECTED] writes:
 
 Ben Finney wrote:
  If you pass a *mapping* of the
  I-might-want-to-add-more-in-the-future values, then you get both
  explicit *and* expandable, without an arbitrary unneeded sequence.

 Do you mean by using the **kwargs parameter?
 
 No. 

 Well, that'll teach me to put words in your mouth.

 [snip]
 If you have a group of named, semantically-related, unsequenced values,
 pass them into the function as a mapping object (a dict object).

 Still, if you are doing this:

 mapping_object = {strength: roll_dice(10),
 intelligence:roll_dice(10),
 dexterity:roll_dice(10)}
 my_character = Character(mapping_object)

 then there is little benefit to building the dict just for the purposes of
 passing it to Character(), never to use it again, not when you can do this:

 my_character = Character(strength: roll_dice(10), 
 intelligence:roll_dice(10), dexterity:roll_dice(10))
 
 But you will have to adapt this if you want extra or different
 characteristics.

Sure, but only in one place:

# now have charisma
my_character = Character(strength=roll_dice(8), 
intelligence=roll_dice(12), dexterity=roll_dice(20),
charisma=roll_dice(6))

If all the char attributes are initialised with the same function, it
may make sense to set them in a loop, as you do below. But if they are all
calculated differently, as above, then you lose the benefit of a loop.

 Personnally I would prefer something like:
 
   chardict = {}
   for char in characteristics:
 chardict[char] = roll_dice(10)
 
   my_character = Character(chardict)
 
 This way you only have to keep your characteristics in one place.

As I do.

Remember, the prerequisite for my suggestion to make sense is that, once
you've created your initial character attributes and stuck them in a dict,
you never use the dict again. Also, I'm assuming the constraint that there
is a manageably small number of character attributes.


 If you happen to already have collected your character attributes in a
 mapping object for some other reason, then well and good, pass it into the
 function. Otherwise, well, I believe the correct container for
 character attributes is a Character, not a dict.
 
 What is wrong with keeping the character attributes in a dict in the
 Character?

For the same reason we typically say object.attribute rather than
object.__dict__[attribute]

Perhaps you missed the original post, where one of the constraints was
that character attributes in the game were also object attributes. E.g.

class Character(object):
def __init__(self, strength):
self.strength = strength

The question posed was, what is the best way of calling __init__ with
values for those character attributes?

If the character attributes vary at runtime, or there are many of them, or
if they are needed together (rather than individually) in multiple places
apart from Character.__init__, then it makes sense to bundle them up in a
dict and pass the dict around, like Ben and now you are suggesting.

But if the character attributes are not varying, and there are only a few,
and they only get used collectively for Character.__init__, then I don't
believe there is any advantage to putting them in a dict to be used once
and then tossed away.

To give an analogy, if you are writing a coordinate class, you would
likely do something like this:

class Coord(object):
def __init__(self, x, y):
self.x = x
self.y = y

If you had a lot of dimensions, you'd change your entire model:

class Coord(object):
def __init__(self, alist):
self.coordinates = alist

But it is unlikely that a tactic like this would be worth the extra work:


class Coord(object):
def __init__(self, mapping_object):
# check that mapping_object has the right keys
expected = ['x', 'y']
for key in expected:
if key not in mapping_object.keys(): raise KeyError
# do something with mapping_object
self.__dict__.update(mapping_object)

mapping = {'x': some_value, 'y': some_value}
point = Coord(mapping)
del mapping # never use it again after construction


-- 
Steven.

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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Ant
 Vim, it can handle all the things.http://www.vim.org/

I'm not convinced of that quite yet. jEdit's syntax highlighting seems
more robust (see SocketServer.py in the standard library for an example
- vim gets the highlighting of the first doc-comment wrong). I've also
not found anything like jEdit's Console plugin for vim. It's
interactive. You can run the current buffer in the console window. The
console interacts with an error reporting pane which allows you to
click on the error and it will take you to the appropriate line in the
code that the stack trace indicates.

The only thing I have found for vim (and it is specific to running
Python code) is the runscript.vim plugin, which merely allows you to
view the stdout from the script in a different buffer. It doesn't allow
you to interact (say you are writing a console based interactive
application for example)  nor does it have all of those other features
I mentioned.

I'm very interested in other people's vim setup for Python coding
however, as I do use vim more than Python these days, mainly because I
have to use it a great deal on headless servers (jEdit would be no good
here of course) and I got fed up with adding artefacts such as
extraneous i's, o's and :w's into my code when working with jEdit ;-)
And it starts faster of course.

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


Re: Multithreaded C API Python questions

2006-11-09 Thread robert
Svein Seldal wrote:
 Hi
 
 A couple of mulithreaded C API python questions:
 
 I) The PyGILState_Ensure() simply ensures python api call ability, it 
 doesnt actually lock the GIL, right?
 
  PyGILState_STATE gstate;
 gstate = PyGILState_Ensure();
 
 II) Am I required to lock the GIL prior to running any python functions 
 (in a threaded app)?
 
 PyThreadState *pts = PyGILState_GetThisThreadState();
 PyEval_AcquireThread(pts);
 PyObject_CallObject(...);
 
 III) Shouldn't the GIL be released after 100 bytecodes or so to enable 
 other waiting threads to get the GIL?
 
 I'm unable to get access to python as long as another python call is 
 executing. The PyEval_AcquireThread() call blocks until the first call 
 returns. I was hoping that the python system itself would release the 
 GIL after some execution, but it itsnt.
 
 I am dependent upon the ability to have to threads executing in python 
 land at the same time. How can this be done?


PyGILState_Ensure/Release guarantees to establish the GIL - even if it was 
already held (useful if you deal with complex call ordering/dependencies)


PyObject_CallObject(...) calls Python code. Thus the interpreter will 
switch and do as usuall during that.


In your/C/system... code  you are responsible to release the GIL or not to 
enable other Python threads (and prevent from deadlocks) 
Usually you'd do this 
* if you do time consuming C/system stuff
* or if the code can possibly renter Python through the system (e.g. when you 
call a Windows function which itself can create Windows messages to be routed 
back into Python message handlers)


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


Re: substring search without using built in utils

2006-11-09 Thread Steven D'Aprano
On Thu, 09 Nov 2006 03:31:02 -0800, John Machin wrote:

 
 Bruno Desthuilliers wrote:
 Gabriel Genellina wrote:
  At Wednesday 8/11/2006 22:29, zeal elite wrote:
 
  I am looking for substring search python program without using the
  built in funtions like find, or 'in'.
 
  The only reasonable usage for such a constraint would be a school
  assignment so: don't cheat and do your homework!
 

 OTHO, looking for existing solutions to a same or similar problem and
 studying them is usually considerer good practice in real-life
 programming jobs !-)

 
 Looking at an existing solution for substring search that was coded in
 Python, instead of using the built-in functionality would IMHO be
 considered extremely bad practice in a real-life programming job.

Sure. But what if the data type in question wasn't a string, but a list?


Given a source list, find the offset of a target sub-list within the
source list, in other words, find for lists.

i.e. search(source, target) returns n if source[n:n+len(target)] == target
for any sequence type.

Yes, I know I'm changing the constraints of the problem. Now for a real
challenge, change the search from a one-dimensional data structure to two.

(The solution is left as an exercise for the class.)

-- 
Steve.

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


Re: newbie class-building question

2006-11-09 Thread Peter Otten
jrpfinch wrote:

 I am constructing a simple class to make sure I understand how classes
 work in Python (see below this paragraph).
 
 It works as expected, except the __add__ redefinition.  I get the
 following in the Python interpreter:
 
 a=myListSub()
 a
 []
 a+[5]
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: 'str' object is not callable

 
 Please could you let me know where I am going wrong.  I have hacked
 around with the code and tried googling this error message but am
 having difficulty finding the source of the problem.


 class myList:
 def __init__ (self,value=[]):
 self.wrapped=[]
 for x in value :
 self.wrapped.append(x)
 def __repr__ (self):
 return `self.wrapped`
 def __getattr__ (self,attrib):
 return getattr(self.wrapped,attrib,'attribute not found')

When Python is looking for an attribute that neither exists in myList nor
the 'wrapped' list, you give back a string.
In your case this happens for the __coerce__() method, and the interpreter
ends up calling attribute not found which of course must fail. The
solution:

- Don't provide a bogus default for getattr(), and get a traceback that is
  easier to understand.
- Use new-style classes (i.e. class myList(object): ...) which look for
  special methods in the class, not the instance.


Peter

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


Re: newbie class-building question

2006-11-09 Thread Jon Clements

jrpfinch wrote:

 I am constructing a simple class to make sure I understand how classes
 work in Python (see below this paragraph).

 It works as expected, except the __add__ redefinition.  I get the
 following in the Python interpreter:

  a=myListSub()
  a
 []
  a+[5]
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: 'str' object is not callable
 

 Please could you let me know where I am going wrong.  I have hacked
 around with the code and tried googling this error message but am
 having difficulty finding the source of the problem.

 Many thanks

 Jon

 class myList:
 def __init__ (self,value=[]):
 self.wrapped=[]
 for x in value :
 self.wrapped.append(x)
 def __repr__ (self):
 return `self.wrapped`
 def __getattr__ (self,attrib):
 return getattr(self.wrapped,attrib,'attribute not found')
 def __len__ (self):
 return len(self.wrapped)
 def __getitem__ (self,k):
 return self.wrapped[k]
 def __add__(self,other):
 return self.wrapped+other

 class myListSub(myList):
 classCounter=0
 def __init__ (self,value=[]):
 self.instanceCounter=0
 myList.__init__(self,value)
 def __add__(self,other):
 myListSub.classCounter=myListSub.classCounter+1
 self.instanceCounter=self.instanceCounter+1
 myList.__add__(self,other)
 def getCounters (self):
 return classCounter=%s instanceCounter=%s %
 (myListSub.classCounter,self.classCounter)

I'm not sure what you're trying to achieve with the __getattr__ in
myList, but the reason your __add__ isn't working is that when a +
[5] is executed, Python tries to find a __coerce__ attribute (to prove
this just put a print attrib as the first line of your __getattr__).
Your customer __getattr__ returns a default string object of 'attribute
not found', when it fails to locate this. Python then attempts to call
this string, and as your exception states -- strings aren't callable.

That should give you enough information to be going onwith.

Also, if you're trying to get use to classes, I would suggest you start
off with the 'new-style' classes; those are the ones that derive from
object. A quick google for new-style classes will sort you.

hth a bit,

Jon.

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


Re: assigning values in __init__

2006-11-09 Thread Steve Holden
Steven D'Aprano wrote:
 On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:
 
 John Salerno [EMAIL PROTECTED] writes:

 Ben Finney wrote:
 If you pass a *mapping* of the
 I-might-want-to-add-more-in-the-future values, then you get both
 explicit *and* expandable, without an arbitrary unneeded sequence.
 Do you mean by using the **kwargs parameter?
 No. 
 
 Well, that'll teach me to put words in your mouth.
 
 [snip]
 If you have a group of named, semantically-related, unsequenced values,
 pass them into the function as a mapping object (a dict object).
 
 Still, if you are doing this:
 
 mapping_object = {strength: roll_dice(10),
 intelligence:roll_dice(10),
 dexterity:roll_dice(10)}
 my_character = Character(mapping_object)
 
 then there is little benefit to building the dict just for the purposes of
 passing it to Character(), never to use it again, not when you can do this:
 
 my_character = Character(strength: roll_dice(10), 
 intelligence:roll_dice(10), dexterity:roll_dice(10))
 
Except, of course, that you *can't* do that: I think you meant to use 
equals signs instead of colons?

 If you happen to already have collected your character attributes in a
 mapping object for some other reason, then well and good, pass it into the
 function. Otherwise, well, I believe the correct container for
 character attributes is a Character, not a dict.
 
regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Problem getting a file pathname with tkFileDialog

2006-11-09 Thread Neil Cerutti
On 2006-11-09, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 you could also use encode(iso-8859-1) to nterpret just the
 printed name such as: print myfilename.encode(iso-8859-1)

 and by the way if you wanted the file NAME you could have used
 openfilename() instead of openfile();-)

The encoding of the filenames in the file system is available
from sys.getfilesystemencoding(). That might turn out to be
useful when interpreting them.

-- 
Neil Cerutti
Strangely, in slow motion replay, the ball seemed to hang in the air
for even longer. --David Acfield
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IndentationError: expected an indented block

2006-11-09 Thread Steve Holden
Antonios Katsikadamos wrote:
 hi all. I am using python 2.4. I have to run an older python code and 
 when i run it i get the following message
 
 IndentationError: expected an indented block.
 
 1)what does this mean?
Just what it did the first time you asked. This is a troll to get your 
sponsored link published, isn't it?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Multithreaded C API Python questions

2006-11-09 Thread Svein Seldal
robert wrote:
 PyGILState_Ensure/Release guarantees to establish the GIL - even if it 
 was already held (useful if you deal with complex call 
 ordering/dependencies)

I understand this to mean that I dont need to explicitly lock the GIL 
(with PyEval_AcquireLock() or PyEval_AcquireThread()).

Well I cant figure out the PyGILState_Ensure() because if I only use 
this function to establish the GIL, when calling python, python will 
shortly after crash with Fatal Python error: ceval: tstate mix-up. 
This happens consistently when the main app and the extra thread has 
called python and both are busy executing python code.

 PyObject_CallObject(...) calls Python code. Thus the interpreter 
 will switch and do as usuall during that.

BTW What do you mean by switch?

 In your/C/system... code  you are responsible to release the GIL or not 
 to enable other Python threads (and prevent from deadlocks) Usually 
 you'd do this * if you do time consuming C/system stuff
 * or if the code can possibly renter Python through the system (e.g. 
 when you call a Windows function which itself can create Windows 
 messages to be routed back into Python message handlers)

The main problem is that not done this way, it's the other way around. 
My main C app will call a python function which will be a lengthy time 
consuming process.

The main C app will call python and it will never return from 
PyObject_CallObject(...), while the extra thread should call a py 
function to deliver occational messages into C.


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


Lists of lists and tuples, and finding things within them

2006-11-09 Thread Michael B. Trausch




I have a program that keeps some of its data in a list of tuples. Sometimes, I want to be able to find that data out of the list. Here is the list in question:

[('password01', 'unk'), ('host', 'dragonstone.org'), ('port', '1234'), ('character01', 'Thessalus')]

For a regular list, I could do something like x.index('host') and find the index of it, but I don't know how to do this for a tuple where the data item isn't known in advance. For example, I want to get the host entry from the list above; but I can only retrieve it if I know what it contains (e.g., x.index(('host', 'dragonstone.org'))).

Is there a better way to do this than a construct similar the following?

for key, value in x:
 if key == 'host':
 print value

Thanks in advance!

  Mike




--



Michael B. Trausch


[EMAIL PROTECTED]




Phone: (404) 592-5746


Jabber IM: [EMAIL PROTECTED]




Demand Freedom! Use open and free protocols, standards, and software!





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

Re: newbie class-building question

2006-11-09 Thread jrpfinch
Thank you this is very helpful.  The only thing I now don't understand
is why it is calling __coerce__.  self.wrapped and other are both
lists.

Thanks

Jon

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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Neil Cerutti
On 2006-11-09, Ant [EMAIL PROTECTED] wrote:
 Vim, it can handle all the things.http://www.vim.org/

 I'm not convinced of that quite yet. jEdit's syntax
 highlighting seems more robust (see SocketServer.py in the
 standard library for an example - vim gets the highlighting of
 the first doc-comment wrong).

Code inside strings, e.g., doctests, breaks the synchronization
code. I fixed this for myself by adopting the convention in my
code that all closing  are at the end of a line, while opening
 never are. Then I changed the synchronize declarations in
/syntax/python.vim to the following:

  syn sync match pythonSync grouphere NONE '$'
  syn sync maxlines=300

The above is no good for random Python code, though.

But in random Python code you can simply increase the number of
lines inspected as high as your machine can handle, as documented
in python.vim.

 I've also not found anything like jEdit's Console plugin for
 vim. It's interactive. You can run the current buffer in the
 console window. The console interacts with an error reporting
 pane which allows you to click on the error and it will take
 you to the appropriate line in the code that the stack trace
 indicates.

I haven't got that working in Vim, because I haven't been
irritated enough by its lack to try. Python's extremely verbose
error reports make designing errorformat a little tricky, but it
can be done, and the day may come soon.

The reason I haven't adapted quickfix mode to Python is that Vim
would hide most of the Traceback. I'd constantly be executing the
command to show the entire error message, so I've chosen to
eschew quickfix mode for Python code.

If there's some quickfix mode settings that solve these problems
I'd be happy to purloin it.

 I'm very interested in other people's vim setup for Python coding
 however, as I do use vim more than Python these days, mainly because I
 have to use it a great deal on headless servers (jEdit would be no good
 here of course) and I got fed up with adding artefacts such as
 extraneous i's, o's and :w's into my code when working with jEdit ;-)
 And it starts faster of course.

The default Python plugin provides the [[, ]] and [m, ]m commands
for jumping to the next function or method respectively. They are
a nice help once you're aware of them. There's a more powerful
plugin available on the internet, but it the code-jumps were the
main commands I wanted.

pytags should be in your Tools directory. I haven't found it
terribly useful, but in theory it's invaluable (my project is
piddly in size at the moment).

If you set shiftwidth to your preferred Python indent, then
indenting and unindenting code blocks is as easy as the  and 
commands.

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


Re: newbie class-building question

2006-11-09 Thread Jon Clements

jrpfinch wrote:

 Thank you this is very helpful.  The only thing I now don't understand
 is why it is calling __coerce__.  self.wrapped and other are both
 lists.

Yes, but in a + [5], *a* is a myListSub object -- it's not a list! So
__coerce__ is called to try and get a common type...

Try this in myList...

# We could  check the type of 'other' to determine what we return
here
# At the moment, we return a list, whose + operator, requires another
list so this works
# and gives an exception if it's not for us
def __coerce__(self,other):
return self.wrapped, other

# 
def __add__(self,other):
return self + other



hth

Jon.

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


Re: Sorted list - how to change it

2006-11-09 Thread Nick Craig-Wood
Tim Chase [EMAIL PROTECTED] wrote:
  Just a caveat from past experience...while the OP was talking 
  about lists, for future reference random.shuffle() chokes on 
  strings (and possibly tuples).  It requires the ability to edit 
  the target/parameter in place...a functionality that strings 
  don't provide.

You can always use array.array('c'), eg

import random
import array
L = array.array('c')
L.fromstring(hello)
L
   array('c', 'hello')
random.shuffle(L)
L
   array('c', 'elohl')
L.tostring()
   'elohl'

Which is some way towards a mutable string...

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Nick Craig-Wood
Christophe [EMAIL PROTECTED] wrote:
  Nick Craig-Wood a écrit :
  There is also PyQT which we wrote off as we wanted to write commercial
  applications too.  As it happens we have a commercial QT licence, but
  we decided we didn't want to have to incurr the additional expense of
  renewing it.
  Note: Nothing in the GPL prevents you from writting commecial
  software ;)

A completely valid point!

s/commercial applications/closed source applications/ would be more
accurate.

However, in this case, our customer didn't want the source code
released as it contained some of their confidential stuff.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-09 Thread Robin Becker
Paul Boddie wrote:

 My impression is that POSH isn't maintained any more and that work was
 needed to make it portable, as you have observed. Some discussions did
 occur on one of the Python development mailing lists about the
 possibility of using shared memory together with serialisation
 representations faster than pickles (which also don't need to be
 managed as live objects by Python), and I think that this could be an
 acceptable alternative.
 
...

your impression is correct, when I contacted the author some while ago he 
maintained that it was a proof of concept only. When I compiled this today with 
python-2.4.2 the example fails with this rather cryptic message

~/devel/posh/examples:
$ python Matrix.py
Traceback (most recent call last):
   File Matrix.py, line 6, in ?
 import posh
   File /usr/local/lib/python2.4/site-packages/posh/__init__.py, line 14, in ?
 import _core
RuntimeError: semaphore set creation failed

but that's most likely something to do with not allocating a semaphore of the 
right sort or something.

I think it uses sysv semaphores and although freeBSD 6 has them perhaps there's 
something I need to do to allow them to work.


 Paul
 


-- 
Robin Becker

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


UnboundLocalError

2006-11-09 Thread Camellia
hi all

why it generates an UnboundLocalError when I do the following:

code
...
def main():
number = number()
number_user = user_guess()
while number_user != number:
check_number(number = number, number_user = number_user)
number_user = user_guess()

UnboundLocalError: local variable 'number' referenced before assignment
/code

I found when I changed the number() to num() or whatever the issue
solved
but doesn't every function has its own namespace?
Can anyone please explain it to me?

Peace

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


Re: help using smtplib to work ..

2006-11-09 Thread Gabriel Genellina

At Thursday 9/11/2006 00:45, Jordan wrote:


Your post was definitely the most helpful for me.  For some reason,
smtp for gmail seems to require that you call server.ehlo() a second
time, after having called server.starttls(), otherwise, the server
won't accept authorization.  Thanks.


That's clearly stated on the docs for the starttls method: 
http://docs.python.org/lib/SMTP-objects.html



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Ant


On Nov 9, 2:11 pm, Neil Cerutti [EMAIL PROTECTED] wrote:
...
  never are. Then I changed the synchronize declarations in
 /syntax/python.vim to the following:

   syn sync match pythonSync grouphere NONE '$'
   syn sync maxlines=300

 The above is no good for random Python code, though.

 But in random Python code you can simply increase the number of
 lines inspected as high as your machine can handle, as documented
 in python.vim.

I commented out the maxlines line, and uncommented the syn sync
minlines=2000 line, and that seems to have worked.

 The reason I haven't adapted quickfix mode to Python is that Vim
 would hide most of the Traceback. I'd constantly be executing the
 command to show the entire error message, so I've chosen to
 eschew quickfix mode for Python code.

Sounds interesting - I may take a look at it.

 ... default Python plugin provides the [[, ]] and [m, ]m commands
 for jumping to the next function or method respectively. They are
 a nice help once you're aware of them. There's a more powerful
 plugin available on the internet, but it the code-jumps were the
 main commands I wanted.

They sound good. I've been using the taglist.vim plugin for code
browsing which is pretty good for that sort of thing.

 pytags should be in your Tools directory. I haven't found it
 terribly useful, but in theory it's invaluable (my project is
 piddly in size at the moment).

I'll take a look. A code navigation tool I presume?

 If you set shiftwidth to your preferred Python indent, then
 indenting and unindenting code blocks is as easy as the  and 
 commands

Yes - I have that set up. Thanks for the tips :-)

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


Re: pack a three byte int

2006-11-09 Thread Dave Opstad
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

 Can Python not express the idea of a three-byte int?
 
 For instance, in the working example below, can we somehow collapse the
 three calls of struct.pack into one?
 
  import struct
 
  skip = 0x123456 ; count = 0x80
 
  cdb = ''
  cdb += struct.pack('B', 0x08)
  cdb += struct.pack('I', skip)[-3:]
  cdb += struct.pack('BB', count, 0)

Why not something like this:

skip += struct.pack(L, skip)[1:]

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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread BillJosephson

Ant wrote:
  Vim, it can handle all the things.http://www.vim.org/

 I'm not convinced of that quite yet. jEdit's syntax highlighting seems
 more robust (see SocketServer.py in the standard library for an example
 - vim gets the highlighting of the first doc-comment wrong). I've also
 not found anything like jEdit's Console plugin for vim. It's
 interactive. You can run the current buffer in the console window. The
 console interacts with an error reporting pane which allows you to
 click on the error and it will take you to the appropriate line in the
 code that the stack trace indicates.

 The only thing I have found for vim (and it is specific to running
 Python code) is the runscript.vim plugin, which merely allows you to
 view the stdout from the script in a different buffer. It doesn't allow
 you to interact (say you are writing a console based interactive
 application for example)  nor does it have all of those other features
 I mentioned.

 I'm very interested in other people's vim setup for Python coding
 however, as I do use vim more than Python these days, mainly because I
 have to use it a great deal on headless servers (jEdit would be no good
 here of course) and I got fed up with adding artefacts such as
 extraneous i's, o's and :w's into my code when working with jEdit ;-)
 And it starts faster of course.


Ant: 


Great. Can you help me get it?

Thanks.

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


Re: Question regarding lists and regex

2006-11-09 Thread Ant


On Nov 9, 6:29 am, Prabhu Gurumurthy [EMAIL PROTECTED] wrote:
...
 regex: I presume this is rather a dumb question, anyways here it comes! as you
 can see from my program, pattIp = r\d{1,3}\ etc, is there any other easy 
 way
 to group the reptitions, instead of typing the same regex 4 times.
...
pattIp = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'

pattIp = r\d{1,3}(\.\d{1,3}){3}

Is the best you can get using pure regexes (rather than something like
Paul's solution).

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


Re: pack a three byte int

2006-11-09 Thread Dave Opstad
Sorry, that should have been:

cdb += struct.pack(L, skip)[1:]

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


Re: UnboundLocalError

2006-11-09 Thread Benjamin Niemann
Hello,

Camellia wrote:

 why it generates an UnboundLocalError when I do the following:
 
 code
 ...
 def main():
 number = number()
 number_user = user_guess()
 while number_user != number:
 check_number(number = number, number_user = number_user)
 number_user = user_guess()
 
 UnboundLocalError: local variable 'number' referenced before assignment
 /code
 
 I found when I changed the number() to num() or whatever the issue
 solved
 but doesn't every function has its own namespace?
 Can anyone please explain it to me?

When Python compiles your code, it sees that you are using a local
variable 'number' in this function ('number = ...') and probably allocates
some memory for it or whatever - ask the core Python hackers for details.
When this statement is executed, the right hand side is evaluated first and
Python finds a reference to 'number'. It knows that number is a local
variable in main(), but has not been assigned yet (which would happend
after the right hand side is evaluated) - thus the error.

Even if you could get this to work, you have two 'number's in the function
with different meaning, which just makes understanding the code too
difficult.

Is number() (the global one) a function or class. I guess it's a function,
so I would suggest to name it 'get_number' (and same
for 'get_user_guess') - this makes the code more descriptive. Should it
really be a class, a common convention is to capitalize it 'Number()'.


HTH

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread John Salerno
Ant wrote:

 I do use vim more than Python these days

What does that mean? Are you referring to all the setup involved with vim?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread John Salerno
Nick Craig-Wood wrote:

 So, is there another toolkit I should be looking at?
  I highly recommend wxPython.
 
 I'd second that!
 
 There is a book also
 
   WxPython in Action

Oh yeah, how could I forget The Book! :) It's great to read straight 
through, and also a fantastic reference, and covers just about all there 
is to know to get very far in wxPython.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is this the right way to do subclasses?

2006-11-09 Thread John Salerno
Bruno Desthuilliers wrote:
 John Salerno a écrit :
 Peter Otten wrote:

 You may need a no-op implementation of fix_attributes() in the Character
 class.


 What does that mean? Is that in case I use Character directly to 
 create an object?
 
 Most propbably it can be useful for other character classes that don't 
 need too fix attributes.

Ah, I get it!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread BillJosephson

Ant wrote:
 On Nov 9, 6:52 am, BillJosephson [EMAIL PROTECTED] wrote:
 ...
  If anyone knows why i can't connect, in info about it would be
  a big help.

 Sounds like the default mirror is down. Go to Utilities - Global
 Options - Plugin Manager and click on Update mirror list. Choose a
 new mirror and try again. If that still fails, it may be that you need
 to set up your proxy server properly.



Woo hoo!  It worked!  Now of course it was a dumb question to begin
with.

May I ask another quetion?  I don't want to mess with lots of plugins
at this point. What are the minimum plugins to get a typical looking
IDE with a code window and output window and that lets me set
breakpoints and step through code?

Thanks a lot Ant, I appreciate your help.

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


Re: is this the right way to do subclasses?

2006-11-09 Thread John Salerno
Steve Holden wrote:

 Wait, I just might be an idiot. Is it not even necessary for me to 
 call Character's __init__ method? Fighter will inherit it 
 automatically and call it when a Fighter object is created, right?

 By Jove, he's got it!

But I was thinking...even though there are better ways to do it than 
what I did, I wasn't too far off the mark since I really *was* 
overriding the __init__ and doing some extra initializing of my own in 
each subclass. It was just a terribly ugly way to do it. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyQt v4.1 Released

2006-11-09 Thread Tool69

David Boddie a écrit :


 Do you mean the example from the PyQt4 distribution?
Yes, that was it.

 That uses a port of an old syntax highlighting example from Qt 4.0. Someone 
 needs to
 port the C++ example from Qt 4.2 to PyQt4.

So, we've got no sample to use QScintilla2 ??

Thanks,
6TooL9

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

extract text from a string

2006-11-09 Thread boris . smirnov
Hallo all,

I have tried for a couple of hours to solve my problem with re but I
have no success.

I have a string containing: +abc_cde.fgh_jkl\n and what I need to
become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
code of how to extract this text from that string?

thank you very much in advance
regards,
boris

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


Re: extract text from a string

2006-11-09 Thread Jon Clements

[EMAIL PROTECTED] wrote:

 Hallo all,

 I have tried for a couple of hours to solve my problem with re but I
 have no success.

 I have a string containing: +abc_cde.fgh_jkl\n and what I need to
 become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
 code of how to extract this text from that string?

Perhaps if you described what the actual *criteria* is for the
translation; for instance, I need to keep only letters, numbers and
punctuation characters etc... Going by your example, it's tempting to
suggest the best method would be string_name[1:-1] and that you don't
need a regex.

Jon.

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


Re: extract text from a string

2006-11-09 Thread Tim Williams
On 9 Nov 2006 07:45:25 -0800, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:


 I have a string containing: +abc_cde.fgh_jkl\n and what I need to
 become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
 code of how to extract this text from that string?


for that particular string

 +abc_cde.fgh_jkl\n[1:-1]
'abc_cde.fgh_jkl'
 +abc_cde.fgh_jkl\n.strip()[1:]
'abc_cde.fgh_jkl'
 +abc_cde.fgh_jkl\n[1:].strip()
'abc_cde.fgh_jkl'
 +abc_cde.fgh_jkl\n[1:].strip().replace('+','')
'abc_cde.fgh_jkl'
 +abc_cde.fgh_jkl\n[1:].replace('\n','').replace('+','')
'abc_cde.fgh_jkl'

I'm sure there are other ways too !!

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


Re: extract text from a string

2006-11-09 Thread Roberto Bonvallet
Jon Clements wrote:
 I have a string containing: +abc_cde.fgh_jkl\n and what I need to
 become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
 code of how to extract this text from that string?
 
 [...] Going by your example, it's tempting to suggest the best method
 would be string_name[1:-1] and that you don't need a regex.

...or string_name.lstrip('+').rstrip('\n')

I bet he doesn't need a regexp!
Cheers,
-- 
Roberto Bonvallet
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: PyQt v4.1 Released

2006-11-09 Thread David Boddie
Tool69 wrote:

  That uses a port of an old syntax highlighting example from Qt 4.0. Someone
 needs to port the C++ example from Qt 4.2 to PyQt4.

 So, we've got no sample to use QScintilla2 ??

Well, this should get you started:

import sys
from PyQt4.QtGui import QApplication
from PyQt4.Qsci import QsciScintilla, QsciLexerPython

if __name__ == __main__:
app = QApplication(sys.argv)
editor = QsciScintilla()
lexer = QsciLexerPython()
editor.setLexer(lexer)
editor.show()
editor.setText(open(qscintilla2_example.py).read())
sys.exit(app.exec_())

QScintilla provides a selection of different lexers, so you might want
to experiment with those.

Good luck!

David

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


Re: extract text from a string

2006-11-09 Thread Grant Edwards
On 2006-11-09, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hallo all,

 I have tried for a couple of hours to solve my problem with re but I
 have no success.

 I have a string containing: +abc_cde.fgh_jkl\n and what I need to
 become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
 code of how to extract this text from that string?

 s = +abc_cde.fgh_jkl\n
 s[1:-1]
'abc_cde.fgh_jkl'

-- 
Grant Edwards   grante Yow!  ... I think I'm
  at   having an overnight
   visi.comsensation right now!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Py3K idea: why not drop the colon?

2006-11-09 Thread Michael Hobbs
Can anyone find a flaw with this change in syntax?

Instead of dividing a compound statement with a colon, why not divide it 
on a newline? For example, the colon could be dropped from this statement:
if self.hungry:
self.eat()
to
if self.hungry
self.eat()

Python is already sensitive to whitespace and the newline anyway, so why 
not put it to good use? For example, Python rejects this statement 
because of the newline present:
if self.hungry or
  self.depressed:
self.eat()
You need to use the backslash to continue the expression on the next line:
if self.hungry or \
  self.depressed:
self.eat()
The colon that divides the statement therefore seems redundant. The 
colon could continue to be used for single-line statements:
if self.hungry: self.eat()

I think the colon could be omitted from every type of compound 
statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?

Thanks,
- Mike

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


Re: More elegant way to obtain ACLs / permissions for windows directories than using cacls dos command?

2006-11-09 Thread dananrg
 There are some examples of using the security descriptor objects in
 \Lib\site-packages\win32\Demos\security.
 Also, searching the Python-win32 mailing list should turn up some
 more code.

Thanks again Roger.

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


Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Anders Arnholm
Ant [EMAIL PROTECTED] skriver:
 Vim, it can handle all the things.http://www.vim.org/

 I'm not convinced of that quite yet. jEdit's syntax highlighting seems
 more robust (see SocketServer.py in the standard library for an example
 - vim gets the highlighting of the first doc-comment wrong). I've also

I can't see that problem at all. Vim 7.0 standard win32 build and
6.4 on OpenBSD.

My vimrc hold and old rule that I'm not sure is needed or how it works
against the new standard python module:

:au BufEnter *.py :set smarttab smartindent \
cinwords=if,elif,else,for,while,def,try,rxcept,finally,class

I have not yet seen any problenm from it but maybe it's time to remote
it soon.


/ Balp
-- 
http://anders.arnholm.nu/Keep on Balping
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Paul Boddie
Michael Hobbs wrote:

 I think the colon could be omitted from every type of compound
 statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?

The FAQ answer. ;-)

http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements

Paul

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


Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Michael Hobbs
wrote:

 Python is already sensitive to whitespace and the newline anyway, so why 
 not put it to good use? For example, Python rejects this statement 
 because of the newline present:
 if self.hungry or
   self.depressed:
 self.eat()
 You need to use the backslash to continue the expression on the next line:
 if self.hungry or \
   self.depressed:
 self.eat()

You don't need the backslash if you use parenthesis:

  if (self.hungry
  or self.depressed):
  self.eat()

 I think the colon could be omitted from every type of compound 
 statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?

I would miss auto-indenting in my editor to which the colon at the line
end is an important clue.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Michael Hobbs
Paul Boddie wrote:
 Michael Hobbs wrote:
   
 I think the colon could be omitted from every type of compound
 statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?
 

 The FAQ answer. ;-)

 http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements

 Paul
   
I knew there was a document somewhere that I missed. ;-) I even scanned 
all the Py3K PEPs before posting. Anyway, the FAQ answer seems to be a 
weak argument to me. But if the BDFL insists that it remains, why not 
take the converse approach? That is, assume that the expression ends at 
the colon, not at the newline. That would make this type of statement 
possible:
if color == red or
  color == blue or
  color == green:
return 'primary'
Right now, such a statement would have to be spelled thus:
if color == red or \
  color == blue or \
  color == green:
return 'primary'
or
if (color == red or
  color == blue or
  color == green):
return 'primary'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning values in __init__

2006-11-09 Thread Antoon Pardon
On 2006-11-09, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Thu, 09 Nov 2006 10:36:07 +, Antoon Pardon wrote:

 On 2006-11-09, Steven D'Aprano [EMAIL PROTECTED] wrote:
 On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:

 John Salerno [EMAIL PROTECTED] writes:
 
 Ben Finney wrote:
  If you pass a *mapping* of the
  I-might-want-to-add-more-in-the-future values, then you get both
  explicit *and* expandable, without an arbitrary unneeded sequence.

 Do you mean by using the **kwargs parameter?
 
 No. 

 Well, that'll teach me to put words in your mouth.

 [snip]
 If you have a group of named, semantically-related, unsequenced values,
 pass them into the function as a mapping object (a dict object).

 Still, if you are doing this:

 mapping_object = {strength: roll_dice(10),
 intelligence:roll_dice(10),
 dexterity:roll_dice(10)}
 my_character = Character(mapping_object)

 then there is little benefit to building the dict just for the purposes of
 passing it to Character(), never to use it again, not when you can do this:

 my_character = Character(strength: roll_dice(10), 
 intelligence:roll_dice(10), dexterity:roll_dice(10))
 
 But you will have to adapt this if you want extra or different
 characteristics.

 Sure, but only in one place:

Are your sure? The OP had subclasses like Fighter, Mage etc.
So it seems that you have to do something like this for
every such subclass. Or am I missing something.

 # now have charisma
 my_character = Character(strength=roll_dice(8), 
 intelligence=roll_dice(12), dexterity=roll_dice(20),
 charisma=roll_dice(6))

 If all the char attributes are initialised with the same function, it
 may make sense to set them in a loop, as you do below. But if they are all
 calculated differently, as above, then you lose the benefit of a loop.

Not necesarily. You could have a table as follows:

  characteristics = [(strength, partial(roll_dice, 8)),
 (inteligence , partial(roll_dice, 12),
 ...

  chardict={}
  for char, roller in characteristics:
chardict[char] = roller()


 Personnally I would prefer something like:
 
   chardict = {}
   for char in characteristics:
 chardict[char] = roll_dice(10)
 
   my_character = Character(chardict)
 
 This way you only have to keep your characteristics in one place.

 As I do.

 Remember, the prerequisite for my suggestion to make sense is that, once
 you've created your initial character attributes and stuck them in a dict,
 you never use the dict again. Also, I'm assuming the constraint that there
 is a manageably small number of character attributes.

That depends on how the rest of the game is set up. Suppose the
character is wandering through a maze. Now in the maze are tests
which require the character to roll under a certain characteristic
with a certain bonus/malus. So such a test object value may be
equivallent to (strength , -2) I think such a setup will be
easier to implement if you keep the characteristics as a dictionary
within a character instance.

Now whether such a scheme would suit the OP is up to him to decide.

 If you happen to already have collected your character attributes in a
 mapping object for some other reason, then well and good, pass it into the
 function. Otherwise, well, I believe the correct container for
 character attributes is a Character, not a dict.
 
 What is wrong with keeping the character attributes in a dict in the
 Character?

 For the same reason we typically say object.attribute rather than
 object.__dict__[attribute]

But we also typically use:

  object.some_dict[some_characteristic]

rather than

  object.__dict__[some_characterictic]

where some_charaterictic contains the name of a characteristic.

 Perhaps you missed the original post, where one of the constraints was
 that character attributes in the game were also object attributes. E.g.

 class Character(object):
 def __init__(self, strength):
 self.strength = strength

 The question posed was, what is the best way of calling __init__ with
 values for those character attributes?

Well if that is what he wants.

 If the character attributes vary at runtime, or there are many of them, or
 if they are needed together (rather than individually) in multiple places
 apart from Character.__init__, then it makes sense to bundle them up in a
 dict and pass the dict around, like Ben and now you are suggesting.

It is not only that they can vary ay runtime. There is also the
possibility that you don't know in advance which one you will need
because that is decided by the environment. I think that would be
an argument in favor of a dict too.

 But if the character attributes are not varying, and there are only a few,
 and they only get used collectively for Character.__init__, then I don't
 believe there is any advantage to putting them in a dict to be used once
 and then tossed away.

I guess it depends on how he will need those characteristics later on.

 To give an 

Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Ant
 May I ask another quetion?  I don't want to mess with lots of plugins
 at this point. What are the minimum plugins to get a typical looking
 IDE with a code window and output window and that lets me set
 breakpoints and step through code?

The Console plugin is a must (I think it depends on the ErrorList
plugin which is also very useful as I noted above). JPyDebug is an
interactive debugger - I have never used it mind, I usually rely on
print statements to debug stuff.

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


Re: extract text from a string

2006-11-09 Thread boris . smirnov
Thank you very much.
I needed this kick. :)
Rg,
Boris


Grant Edwards napísal(a):
 On 2006-11-09, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Hallo all,
 
  I have tried for a couple of hours to solve my problem with re but I
  have no success.
 
  I have a string containing: +abc_cde.fgh_jkl\n and what I need to
  become is abc_cde.fgh_jkl.  Could anybody be so kind and write me a
  code of how to extract this text from that string?

  s = +abc_cde.fgh_jkl\n
  s[1:-1]
 'abc_cde.fgh_jkl'

 --
 Grant Edwards   grante Yow!  ... I think I'm
   at   having an overnight
visi.comsensation right now!!

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

Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Ant


On Nov 9, 3:27 pm, John Salerno [EMAIL PROTECTED] wrote:
 Ant wrote:
  I do use vim more than Python these daysWhat does that mean? Are you 
  referring to all the setup involved with vim?

Whoops! I mean I use vim more than jEdit these days!

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


Re: pack a three byte int

2006-11-09 Thread John Machin

Dave Opstad wrote:
 Sorry, that should have been:

 cdb += struct.pack(L, skip)[1:]


L and I produce exactly the same 4-byte result. The change from
[-3:] to [1:] is a minor cosmetic improvement, but obscures the
underlying ... a bit like putting mascara on a pig. I got the
impression that the OP was interested in more radical improvement.

Cheers,
John

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


Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Steve Holden
Paul Boddie wrote:
 Michael Hobbs wrote:
 I think the colon could be omitted from every type of compound
 statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?
 
 The FAQ answer. ;-)
 
 http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements
 
 Paul
 
I suppose it would be even better if that hyperlink actually took you to 
  section 1.4.27 rather than 1.4.14 ...

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
Nick Craig-Wood wrote:
 John Salerno [EMAIL PROTECTED] wrote:
   Dan Lenski wrote:
 
   So, is there another toolkit I should be looking at?
 
   I highly recommend wxPython.

 I'd second that!

 There is a book also

   WxPython in Action

Nick and John S., thank you for the tip on wxPython!  I'll look into it
for my next project.  I too would avoid Qt, not because of the GPL but
simply because I don't use KDE under Linux and because Qt is not well
supported under Cygwin or on native Windows.  I too like to learn from
actual printed books, so I'll check this one out.  O'Reilly should do a
book on Python GUI stuff!

John H.: thanks for pointing out pythoncard.  This looks like it might
be an excellent substitute for LabView-like GUIs, which all my
coworkers like.  I personally refuse to read or write LabView code, on
the grounds that its syntax causes severe brain damage and is
completely unportable.  But that's a flame for another thread, so to
speak...

Thanks,
Dan

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


Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Paul Boddie
Steve Holden wrote:
 Paul Boddie wrote:
  http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements
 
 I suppose it would be even better if that hyperlink actually took you to
   section 1.4.27 rather than 1.4.14 ...

I'd suggest a browser upgrade: even the old version of Konqueror I'm
using here manages to scroll to the right place. And it isn't a Web
site maintenance problem, either, although I did have my suspicions.

Paul

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


  1   2   3   >