Python iPod challenge

2007-11-08 Thread josetokyo
Hi!
   a friend and me are investigating how mother-tongue influences
programming productivity.
   We need volunteers to take on  a 3 minutes python language
programming test.
   if you are interested please be so kind to visit:

  http://test-iq.web.cern.ch/test-iq/step1.php?lang=en

   if your native language is Spanish please do it in Spanish
language. Beginners particularly welcome

Thanks!

jose berengueres

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


Re: easy 3D graphics for rendering geometry?

2007-11-08 Thread Kjell Magne Fauske
On Nov 8, 6:53 am, gsal <[EMAIL PROTECTED]> wrote:
> What would be the easiest way to go about offering 3D graphics for the
> purpose of rendering geometry?
>
> Suppose engineers (my co-workes) have to design some enclosure,
> nozzle, bracket, or whatever physical part/component, I would like to
> write a program where they can at least see the resulting geometry and
> navigate it, i.e., zoon-in/out, rotate, pan.  On the side, I could
> have data entry fields with the input parameters and when something is
> changed, the graphics can be updated "immediately" (after the
> necessary calculations have been done).
>
> I know I need to learn something, and I am willing, I just need help
> choosing what to learn.
>
> I don't have any experience on this matter, don't know OpenGL, Mesa,
> VTK, VRS, Maya...and all seem to have a steep learning curve. I don't
> know any of the "other" graphics packages more oriented for game/
> scenery/movie development (Panda, etc.), either.
>
> I do know my trig and build my FEA parts parametrically from points,
> to line, to surfaces, to volumes or from volume boolean algebra.
>
> I would like the choice to be some kind of module/API that works
> equally well on Linux as in Windows.
>
> So:
> What would be the easiest way?
> and would it be worth learning?
> or
> is it better to shoot for something not so easy but worth learning?
>
> thanks in advance for any pointers.
>
> gsal

I recommend taking a look at Blender 3D: http://www.blender.org/
It is primarily a modeling, animation and rendering tool. However, my
favorite feature is the Python API which allows you to access most of
the functionality using Python. You can create simple GUIs and create
3d-objects programatically.

- Kjell Magne Fauske

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


Re: >>>> 911 operation by evil JEWS and Mossad <<<

2007-11-08 Thread James Matthews
Thank You!

Maybe we can get rid of this guy now... This is a python group...
On Nov 8, 2007 12:28 PM, philipp neulist <[EMAIL PROTECTED]>
wrote:

> On Nov 7, 4:08 pm, [EMAIL PROTECTED] wrote:
> > 911 carried out by evil jews and
> mossadhttp://www.guba.com/watch/2000991770
> >
> > 911 truckload of Explosives on the George Washington
> Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0
> >
> [...]
>
> I reported the first post in this thread (on Google groups) as abuse
> as its content is "false and defamatory". In addition to that, it has
> nothing to do with TeX.
>
> => Double reason to blaim the author!
>
> Please ignore threads like those in future and just report it!
>
> PN
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

wxPython ListCtrl image configuring

2007-11-08 Thread vedrandekovic
Hello,

Here is example of my ListCtrl items with image:

( filebox1 is ListCtrl )

il = wx.ImageList(16,16)
images=["file1.png","folder.png"]
for i in images:
il.Add(wx.Bitmap(i))
img_list=filebox1.SetImageList(il, wx.IMAGE_LIST_SMALL)
j=1
unos1p=unos1.GetValue()
unos2p=unos2.GetValue()
unos3p=unos3.GetValue()
newftp=FTPHost(unos1p,unos2p,unos3p)
for item in newftp._dir('/'):
if item.split()[2]=="":
index=filebox1.InsertStringItem(j,item)
filebox1.SetItemImage(index,2)

else:
index=filebox1.InsertStringItem(j,item)
filebox1.SetItemImage(index,1)


..Then my program show all items and images with them, but the
problem is when I click on item
image of item disappere .Any idea?


Regards,
Vedran

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


pyparsing and svg

2007-11-08 Thread Donn Ingle
Hi - I have been trying, but I need some help:
Here's my test code to parse an SVG path element, can anyone steer me right?

d1="""
M 209.12237 , 172.2415
 L 286.76739 , 153.51369
 L 286.76739 , 275.88534
 L 209.12237 , 294.45058
 L 209.12237 , 172.2415
 z """

#Try it with no enters
d1="""M 209.12237,172.2415 L 286.76739,153.51369 L 286.76739,275.88534 L
209.12237,294.45058 L 209.12237,172.2415 z """

#Try it with no spaces
d1="""M209.12237,172.2415L286.76739,153.51369L286.76739,275.88534L209.12237,294.45058L209.12237,172.2415z"""

#For later, has more commands 
d2="""
M 269.78326 , 381.27104
C 368.52151 , 424.27023 
 90.593578 , -18.581883
 90.027729 , 129.28708
C 89.461878 , 277.15604
 171.04501 , 338.27184
 269.78326 , 381.27104
 z """
 
## word   :: M, L, C, Z
## number :: group of numbers
## dot :: "."
## comma   :: ","
## couple :: number dot number comma number dot number
## command :: word
## 
## phrase :: command couple

from pyparsing import Word, Literal, alphas, nums, Optional, OneOrMore

command = Word("MLCZ")
comma = Literal(",")
dot = Literal(".")
float = nums + dot + nums
couple = float + comma + float

phrase = OneOrMore(command + OneOrMore(couple |  ( couple + couple ) ) )

print phrase

print phrase.parseString(d1.upper())

Thanks
\d

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


Re: help parsing ipv6 addresses and subnets

2007-11-08 Thread Thorsten Kampe
* Prabhu Gurumurthy (Wed, 07 Nov 2007 22:34:14 -0800)
> I would like to parse IPv6 addresses and subnet using re module in
> python.

Just don't: http://pypi.python.org/pypi?%3Aaction=search&term=ipv6
&submit=search
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: manually cutting a picture

2007-11-08 Thread Amit Khemka
On 11/7/07, Cameron Walsh <[EMAIL PROTECTED]> wrote:
> Amit Khemka wrote:
>
> > Cut image by "m X m" grid (bigger the m, the more varied shapes you
> > would be able to generate), this will give you m*m square pieces. With
> > each piece store a vector which represents the polygon (say by storing
> > co-ordinates of the corners).
> > Now visualize this set of pieces as a graph with an edge between
> > adjacent pieces. Now depending on the final number of pieces that you
> > want to generate (N), you traverse the graph and for each node:
> >
> > 1. "Merge" a node with a randomly selected neighbor
> >
> > Repeat step 1 until you have N pieces left
> >
> Doesn't that have the fairly likely possibility of ending up with 1 very
> large piece and n-1 very small pieces?  If you iterate over the graph
> merging with a neighbour at random, then each node has a 50% chance of
> being merged with a node that has already been merged.
>
> *-*-* *-*
> |   | |
> * *-*-* *
>
> * * * * * etc. could be the result of the first 8 steps.  Already every
> node touched is part of the same group.  Or have I misunderstood your
> algorithm?

Yes, It potentially can result into that. That is the reason I
suggested to calculate (m*m/N) and while merging nodes keep track of
the "size" (number of nodes are merged in a node), so that while
growing/merging the node does not grow 'much large' than (m*m/M)

>
> A random region growing approach might work, with seeds scattered evenly
> throughout the image.  That would be prone to orphaning squares inside
> larger objects, but that may be what you want.  It would not be easy to
> program.
>
> What I would do is break the graph in to m*m squares, then for each
> edge, randomly select a means of joining them - blob sticking out of
> piece A, or hole for blob in piece A; move hole/blob along the edge by a
> random amount, move edge in or out to get different sized pieces.  For
> each square this was applied to, it would apply the reverse sizing to
> the square touching on that edge.
>
> I'd restrict in/out movement of edges and movement of blob/hole along
> the edge to a specific range, to avoid problems where the blob of one
> square is stuck on the furthest corner, but the piece touching that
> corner has had its edge moved in too far so the blob would overlap two
> squares.

Interesting idea, though the implementation may become a bit complex !


To OP :
1. Have you checked out research papers on Digital Image Processing
and Graphics ?  I would guess that there should exist some good
solutions. I hadn't had much time but a quick search showed quite a
few "free softwares" to create Jigsaw puzzles and Algorithms to solve
one.

2. Can you please post anything relevant to this topic on this thread
only instead of doing a new post. Helps to track the postings easily.

Cheeers,

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


Re: >>>> 911 operation by evil JEWS and Mossad <<<

2007-11-08 Thread philipp neulist
On Nov 7, 4:08 pm, [EMAIL PROTECTED] wrote:
> 911 carried out by evil jews and mossadhttp://www.guba.com/watch/2000991770
>
> 911 truckload of Explosives on the George Washington 
> Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0
>
[...]

I reported the first post in this thread (on Google groups) as abuse
as its content is "false and defamatory". In addition to that, it has
nothing to do with TeX.

=> Double reason to blaim the author!

Please ignore threads like those in future and just report it!

PN

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


Linking debug C++ DLL with python dlls

2007-11-08 Thread moshehaim1
Hi,

I am working with C++ code that needs to be maintained both in debug
and release versions. The environment is Windows 32 bit with MSVC8.

I downloaded the python installation for Win32 and installed it.
When, however, I tried to compile my DLLs in debug mode i got link
errors specifying that I need the python25_d.lib.

this is the code that generates the dependency on the python25_d.lib
in the 
#ifdef MS_COREDLL
#   ifndef Py_BUILD_CORE /* not building the core - must be an ext */
#   if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
#   ifdef _DEBUG
#   pragma comment(lib,"python25_d.lib")
#   else
#   pragma comment(lib,"python25.lib")
#   endif /* _DEBUG */
#   endif /* _MSC_VER */
#   endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

So I decided to download and build the debug version of python2.5.1/
As it seems I also need to compile all relevant extension modules
(*.pyd) in debug as well - is this correct?

I tried to change the code above (just for fun) so in both cases i'll
use python25.lib and in debug compilation I got linker errors on
unresolved externals. seems like the debug version exports more
methods than the release version.

Is there a way to have my C++ code compile in debug mode (with _DEBUG)
but use the python25 release lib/dll? This way I don't need to have
additional set of debug extension modules.

Thanks,
Moshe.

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


Showing native 8-bit strings in Python interpreter

2007-11-08 Thread braver
I'm storing 8-bit characters from the 128-256 range in Python
strings.  They are Windows CP1251 Russian characters.  When looking at
those strings in the Python interpreter, they come up as codes inside
the string.  How can I teach Python to show those 8-bit characters in
the native encoding of the terminal -- in the current locale -- where
the interpreter was started?

Cheers,
Alexy

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


Re: Showing native 8-bit strings in Python interpreter

2007-11-08 Thread Diez B. Roggisch
braver wrote:

> I'm storing 8-bit characters from the 128-256 range in Python
> strings.  They are Windows CP1251 Russian characters.  When looking at
> those strings in the Python interpreter, they come up as codes inside
> the string.  How can I teach Python to show those 8-bit characters in
> the native encoding of the terminal -- in the current locale -- where
> the interpreter was started?

The python-interpreter will print them out using hex because it calls
repr(string) - to prevent any encoding-related troubles.

But printing them will meet your expectations. See below:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
>>> s = 'äöüßÄÜ'
>>> s
'\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f\xc3\x84\xc3\x9c'
>>> print s
äöüßÄÜ
>>>  


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

Re: python in academics?

2007-11-08 Thread Nicolas DERAM
2007/11/6, Nicolas.Chauvat <[EMAIL PROTECTED]>:
>
> Le Mon, 29 Oct 2007 20:39:29 -0700, sandipm a écrit:
>
> > seeing posts from students on group. I am curious to know, Do they teach
> > python in academic courses in universities?
>
> I am teaching assistant for the course
>
> http://www.etudes.ecp.fr/cours/claroline/course/index.php?cid=TI1210
>
> held at http://www.ecp.fr/index_html_en
>
> They are also making an increasing use of python over there.


Python is also taught at the university of Calais (France).
A master about free software opened last year.

http://dpt-info.univ-littoral.fr/mediawiki/index.php/I2L:Accueil

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

Re: >>>> 911 operation by evil JEWS and Mossad <<<

2007-11-08 Thread Simon Spiegel
On 2007-11-08 04:21:48 +0100, [EMAIL PROTECTED] said:

> 911 carried out by evil jews and mossad
> http://www.guba.com/watch/2000991770

I'm glad it was carried out by evil jews and not by nice ones. That 
rules me out.

simon

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


Re: easy 3D graphics for rendering geometry?

2007-11-08 Thread Marco Nawijn
On Nov 8, 6:53 am, gsal <[EMAIL PROTECTED]> wrote:
> What would be the easiest way to go about offering 3D graphics for the
> purpose of rendering geometry?
>
> Suppose engineers (my co-workes) have to design some enclosure,
> nozzle, bracket, or whatever physical part/component, I would like to
> write a program where they can at least see the resulting geometry and
> navigate it, i.e., zoon-in/out, rotate, pan.  On the side, I could
> have data entry fields with the input parameters and when something is
> changed, the graphics can be updated "immediately" (after the
> necessary calculations have been done).
>
> I know I need to learn something, and I am willing, I just need help
> choosing what to learn.
>
> I don't have any experience on this matter, don't know OpenGL, Mesa,
> VTK, VRS, Maya...and all seem to have a steep learning curve. I don't
> know any of the "other" graphics packages more oriented for game/
> scenery/movie development (Panda, etc.), either.
>
> I do know my trig and build my FEA parts parametrically from points,
> to line, to surfaces, to volumes or from volume boolean algebra.
>
> I would like the choice to be some kind of module/API that works
> equally well on Linux as in Windows.
>
> So:
> What would be the easiest way?
> and would it be worth learning?
> or
> is it better to shoot for something not so easy but worth learning?
>
> thanks in advance for any pointers.
>
> gsal

Hello,

Take a look at www.opencascade.org. This is a powerfull C++ library
for building CAE
(Computer Aided Engineering) applications. It also has a rather steep
learning curve,
but the resulting geometry could be easily exported to FEA packages.

Another possibility is www.salome-platform.org which is build on top
of OpenCascade. It has
a nice Python interface which makes the learning curve probably a
little more acceptable. A
downside is that, I think there are no Windows binaries yet.

Regards,

Marco Nawijn

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


pyserial: loose connection after inactivity

2007-11-08 Thread Frank Aune
Hello,

I configure the serial connection using:

self.port = serial.Serial(baudrate=57600,
 timeout=0.06,
 parity=serial.PARITY_EVEN,
 stopbits=serial.STOPBITS_TWO,
 bytesize = serial.EIGHTBITS)

After X hours of inactivity I loose connection to my serial device, with error 
message "Input/Output error" printed to stdout. The error happens both on 
Linux and Windows (although the error message is probably different on 
Windows, I've only been told the behaviour is the same).

I cannot find an obvious reason for why this is happening, and since it 
happens after a long time of inactivite, debugging is awkward. So I though 
I'd run the question through the expert panel for ideas, before venturing 
down the path of pain and suffering myself :)

Best regards,
Frank
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy 3D graphics for rendering geometry?

2007-11-08 Thread Donn Ingle
> I recommend taking a look at Blender 3D: http://www.blender.org/

Oh yeah, Blender is THE way to go. It's fantastic.

\d

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


Re: pyparsing and svg

2007-11-08 Thread Paul McGuire
On Nov 8, 3:14 am, Donn Ingle <[EMAIL PROTECTED]> wrote:

> float = nums + dot + nums

Should be:

float = Combine(Word(nums) + dot + Word(nums))

nums is a string that defines the set of numeric digits for composing
Word instances.  nums is not an expression by itself.

For that matter, I see in your later tests that some values have a
leading minus sign, so you should really go with:

float = Combine(Optional("-") + Word(nums) + dot + Word(nums))



Some other comments:

1. Read up on the Word class, you are not using it quite right.

command = Word("MLCZ")

will work with your test set, but it is not the form I would choose.
Word(characterstring) will match any "word" made up of the characters
in the input string.  So Word("MLCZ") will match
M
L
C
Z
MM
LC
MCZL
MMLCLLZCZLLM

I would suggest instead using:

command = Literal("M") | "L" | "C" | "Z"

or

command = oneOf("M L C Z")

2. Change comma to

comma = Literal(",").suppress()

The comma is important to the parsing process, but the ',' token is
not much use in the returned set of matched tokens, get rid of it (by
using suppress).

3. Group your expressions, such as

couple = Group(float + comma + float)

It will really simplify getting at the resulting parsed tokens.


4. What is the purpose of (couple + couple)?  This is sufficient:

phrase = OneOrMore(command + Group(OneOrMore(couple)) )

(Note use of Group to return the coord pairs as a sublist.)


5. Results names!

phrase = OneOrMore(command("command") + Group(OneOrMore(couple))
("coords") )

will allow you to access these fields by name instead of by index.
This will make your parser code *way* more readable.


-- Paul

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


Re: permuting over nested dicts?

2007-11-08 Thread Boris Borcic
Boris Borcic wrote:
> Christian Meesters wrote:
>> Hoi,
>>
>> I have the following data structure (of variable size actually, to make
>> things simple, just that one):
>> d = {'a': {'x':[1,2,3], 'y':[4,5,6]},
>>  'b': {'x':[7,8,9], 'y':[10,11,12]}}
>> This can be read as a dict of possibilities: The entities 'a' and 'b' 
>> have
>> the parameters 'x' and 'y', each. And d['a']['x'] can be either 1 or 2 or
>> 3. Does anybody know a convenient (and fast) way to permute over all
>> possible nested dicts like
>> {'a': {'x':1, 'y':4},
>>  'b': {'x':7, 'y':10}}
>> and
>> {'a': {'x':2, 'y':4},
>>  'b': {'x':7, 'y':10}}
>> and so forth?
>>
>> Any link or snippet is appreciated.
>>
>> TIA
>> Christian
> 
> def cases(d) :
> import re
> bits = re.split('(\[.*?\])',repr(d))
> vv = [('_%s' % k, ' for _%s in %s' % (k,v))
> for k,v in enumerate(bits[1::2])]
> expr = [p+v for p,(v,_) in zip(bits[::2],vv)]+bits[-1:]+[v for _,v 
> in vv]
> return eval('(%s)' % ''.join(expr))

That's too ugly; here is a simpler version, same behav and caveats.

def cases(d) :
 import re
 d = repr(d)
 k,n = 1,1
 while n :
 d,n = re.subn('\\[(.*?)\\](.*)',
   '_%s \\2 for _%s in (\\1,)' % (k,k),
   d,1)
 k+=1
 return eval('('+d+')')

> 
> for t in cases({'a': {'x':[1,2,3], 'y':[4,5,6]},
>'b': {'x':[7,8,9], 'y':[10,11,12]}}) :
> print t
> 
> 
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 10, 'x': 7}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 10, 'x': 8}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 10, 'x': 9}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 11, 'x': 7}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 11, 'x': 8}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 11, 'x': 9}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 12, 'x': 7}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 12, 'x': 8}}
> {'a': {'y': 4, 'x': 1}, 'b': {'y': 12, 'x': 9}}
> {'a': {'y': 4, 'x': 2}, 'b': {'y': 10, 'x': 7}}
> 
> 
> Caveats : (1) assert eval(repr(d))==d
>   (2) no square bracket in either keys or values
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-08 Thread Jens
On 8 Nov., 08:52, Michel Albert <[EMAIL PROTECTED]> wrote:
> In our company we are looking for one language to be used as default
> language. So far Python looks like a good choice (slacking behind
> Java). A few requirements that the language should be able cope with
> are:
>
> * Database access to Sybase.
>   This seems to be available for python, but the windows-binaries for
> the library
>   are not available. Self-Compiling them proved to be non-trivial (As
> always
>   on windows).
> * Easy GUI creation.
>   Solved using PyQt.
> * Cross Platform (Linux + Windows).
>   Again, PyQt, solves this
> * Easy deployment.
>   Solved using py2exe + innosetup
> * Charting (Histograms, Line charts, bar charts, pie charts, ...)
>   I am currently looking into PyQwt, which looks promising.
> * Report generation with GUI support
>   reportlab + rml?
>
> So far, nearly all point seems to be manageable. But I was not yet
> able to find a solution for the report generation. What we would like
> to have is a sort of GUI interface to prepare the reports without
> having to "code" the positioning. I found reportlab, and it looks like
> it can do all that is needed in terms of output. But you still have to
> code the report. And this is a no go. In context, I found RML and saw
> links to graphical RML editors. But I have not yet found a concrete
> example code, or documentation. What am I missing? Is RML a reportlab
> creation or is it a recognised open standard? If not, is there an open
> standard, that is easily to process with python?
>
> Any pointers? I would prefer coding Python to coding Java or
> worse. VB ;) which is another contender in our roundup.

I've been using Java since 1998, and Python for just about a year.
I've tried to do an objective analysis of the two languages. Both
languages have good and weak points, but personally I'd choose Python.
In the end, its a matter of personal taste and preferences. They're
both good languages. Try them both and see which one you like. Also,
try to write a wishlist for what you'd like in a language, and then
compare the wishlist to Java and Python.

About graphing - you should really try the NumPy/Matplotlib
combination. Works similar to MatLab.

About VB - I've coded a lot of VB. It is a very easy language to start
out with and it's based on .NET. Again, it depends on your needs, but
make that wishlist and compare with Java and Python.

Good luck!

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


Re: pyparsing and svg

2007-11-08 Thread Arkanes
Paul McGuire wrote:
> On Nov 8, 3:14 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
>
>   
>> float = nums + dot + nums
>> 
>
> Should be:
>
> float = Combine(Word(nums) + dot + Word(nums))
>
> nums is a string that defines the set of numeric digits for composing
> Word instances.  nums is not an expression by itself.
>
> For that matter, I see in your later tests that some values have a
> leading minus sign, so you should really go with:
>
> float = Combine(Optional("-") + Word(nums) + dot + Word(nums))
>
>
>   

I have a working path data parser (in pyparsing) at 
http://code.google.com/p/wxpsvg.

Parsing the numeric values initially gave me a lot of trouble - I 
translated the BNF in the spec literally and there was a *ton* of 
backtracking going on with every numeric value. I ended up using a more 
generous grammar, and letting pythons float() reject invalid values.

I couldn't get repeating path elements (like M 100 100 200 200, which is 
the same as M 100 100 M 200 200) working right in the grammar, so I 
expand those with post-processing.

The parser itself can be seen at 
http://wxpsvg.googlecode.com/svn/trunk/svg/pathdata.py

> Some other comments:
>
> 1. Read up on the Word class, you are not using it quite right.
>
> command = Word("MLCZ")
>
> will work with your test set, but it is not the form I would choose.
> Word(characterstring) will match any "word" made up of the characters
> in the input string.  So Word("MLCZ") will match
> M
> L
> C
> Z
> MM
> LC
> MCZL
> MMLCLLZCZLLM
>
> I would suggest instead using:
>
> command = Literal("M") | "L" | "C" | "Z"
>
> or
>
> command = oneOf("M L C Z")
>
> 2. Change comma to
>
> comma = Literal(",").suppress()
>
> The comma is important to the parsing process, but the ',' token is
> not much use in the returned set of matched tokens, get rid of it (by
> using suppress).
>
> 3. Group your expressions, such as
>
> couple = Group(float + comma + float)
>
> It will really simplify getting at the resulting parsed tokens.
>
>
> 4. What is the purpose of (couple + couple)?  This is sufficient:
>
> phrase = OneOrMore(command + Group(OneOrMore(couple)) )
>
> (Note use of Group to return the coord pairs as a sublist.)
>
>
> 5. Results names!
>
> phrase = OneOrMore(command("command") + Group(OneOrMore(couple))
> ("coords") )
>
> will allow you to access these fields by name instead of by index.
> This will make your parser code *way* more readable.
>
>
> -- Paul
>
>   

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


Re: wxPython ListCtrl image configuring

2007-11-08 Thread kyosohma
On Nov 8, 5:45 am, [EMAIL PROTECTED] wrote:
> Hello,
>
> Here is example of my ListCtrl items with image:
>
> ( filebox1 is ListCtrl )
>
> il = wx.ImageList(16,16)
> images=["file1.png","folder.png"]
> for i in images:
> il.Add(wx.Bitmap(i))
> img_list=filebox1.SetImageList(il, wx.IMAGE_LIST_SMALL)
> j=1
> unos1p=unos1.GetValue()
> unos2p=unos2.GetValue()
> unos3p=unos3.GetValue()
> newftp=FTPHost(unos1p,unos2p,unos3p)
> for item in newftp._dir('/'):
> if item.split()[2]=="":
> index=filebox1.InsertStringItem(j,item)
> filebox1.SetItemImage(index,2)
>
> else:
> index=filebox1.InsertStringItem(j,item)
> filebox1.SetItemImage(index,1)
>
> ..Then my program show all items and images with them, but the
> problem is when I click on item
> image of item disappere .Any idea?
>
> Regards,
> Vedran

I'm not seeing anything, but then again I don't use images in my
listctrls. I would recommend posting your on-click event handler. You
may find the wxPython demo's code helpful. You can also see more
examples on the wxPython wiki:

http://wiki.wxpython.org/ListControls
http://wiki.wxpython.org/Refillable_List_Control

You should also post to the wxPython user's group: 
http://www.wxpython.org/maillist.php

Mike

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


System exit hanging in Leopard

2007-11-08 Thread Tony Mullen
Hello,

I'm using Tkinter to create widgets in Python 2.5 on OS X 10.5.  When
I call root.quit or sys.exit in any way, the following traceback
appears, after which the application stops responding and just gives
the spinning rainbow cursor.  The IDLE editor and the Python shell
remain responsive, and I can kill the application from the command
line, but not any other way.  I don't see anything problematic in the
traceback, but I don't think that the application should be hanging
like this.

Is this likely a Leopard-related issue?

Thanks for any responses,

Tony

Traceback (most recent call last):
  File "/Users/tonymullen/Documents/ui", line 11, in 
widget.mainloop()
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py",
line 1023, in mainloop
self.tk.mainloop(n)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py",
line 1405, in __call__
raise SystemExit, msg
SystemExit
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: >>>> 911 operation by evil JEWS and Mossad <<<

2007-11-08 Thread thermate
On Nov 8, 3:28 am, philipp neulist <[EMAIL PROTECTED]>
wrote:
> On Nov 7, 4:08 pm, [EMAIL PROTECTED] wrote:> 911 carried out by evil jews and 
> mossadhttp://www.guba.com/watch/2000991770
>
> > 911 truckload of Explosives on the George Washington 
> > Bridgehttp://www.youtube.com/watch?v=J520P-MD9a0
>
> [...]
>
> I reported the first post in this thread (on Google groups) as abuse
> as its content is "false and defamatory". In addition to that, it has
> nothing to do with TeX.

In a typical manner you lied. You did not point out what was false in
them.
The short video by Dan Rather is factual and by a jew like you. I am
reporting
you here to the whole internet as a LIAR like ALAN DERSHOWITZ who
saved the MURDERER by legal jugglery. Also He ran a smear campaign
against The Honorable Norman Finkelstein.

The post is very relevant to our liberal education. Most scientists
and
thesis writers come out as one dimensional specialists without any big
picture of the world.

Second, the book by Honorable Christofer Bjerknes is very well typeset
and humanities thesards will learn a lot from its example.

I am telling the ISP that this is a very good post.

You must specify what exactly is false and defamatory.

> => Double reason to blaim the author!
>
> Please ignore threads like those in future and just report it!
>

Come to think of it, your jews, Charles Krauthmer, Thomas Friedman and
countless others spew falsehoods and lies from their jew media for a
century.

You have an army of liars, here and in the Soviet Union.


Sheeple should use their analytical faculties.

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


Re: Python iPod challenge

2007-11-08 Thread scripteaze
On Nov 8, 2:21 am, [EMAIL PROTECTED] wrote:
> Hi!
>a friend and me are investigating how mother-tongue influences
> programming productivity.
>We need volunteers to take on  a 3 minutes python language
> programming test.
>if you are interested please be so kind to visit:
>
>  http://test-iq.web.cern.ch/test-iq/step1.php?lang=en
>
>if your native language is Spanish please do it in Spanish
> language. Beginners particularly welcome
>
> Thanks!
>
> jose berengueres

Well, just out of curosity, i started the test, however, it seems a
little bugy. My answer to the first question one was:


text = 'In principio creavit Deus caelum et terram. Terra autem erat'
count = 0
for char in text:
  if char == 'a':
count = count + 1
print 'the letter a appears',count ,'times.'


getting the following error:

SYNTAX ERROR Check line 3 text = 'In principio creavit Deus caelum et
terram. Terra autem erat' ^

Im not sure but i think you are looking for only one method of getting
the answer, however, there are several ways to achieve it, so, im
done..lol, no offense, but if im going to fail the test, i want to
fail because i  did it wrong and not because i did it different..




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


Re: Python iPod challenge

2007-11-08 Thread Tim Chase
>>if you are interested please be so kind to visit:
>>
>>  http://test-iq.web.cern.ch/test-iq/step1.php?lang=en
> 
> Well, just out of curosity, i started the test, however, it seems a
> little bugy. My answer to the first question one was:
[snipped]
> getting the following error:
> 
> SYNTAX ERROR Check line 3 text = 'In principio creavit Deus caelum et
> terram. Terra autem erat' ^
> 
> Im not sure but i think you are looking for only one method of getting
> the answer, however, there are several ways to achieve it, so, im
> done..lol, no offense, but if im going to fail the test, i want to
> fail because i  did it wrong and not because i did it different..

I had similar problems.  Additionally, that's pretty unpythonic 
code, as the "correct" answer would be something like

  print text.count("a")

which obviates the whole looping/testing/counting aspect, letting 
Python just do its thing instead.

The whole thing also seemed to fail if JavaScript/Cookies were 
turned off (I don't know which was the culprit...two strikes was 
enough to ).

-tkc



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


[win32] spawn background process and detach it w/o problems

2007-11-08 Thread Dmitry Teslenko
Hello!
How to write portable (win32, unix) script that launches another
program and continues its execution?

I've looked at spawn*() but it doesn't look in PATH dirs on windows so
it's totally unusable when you don't know where exactly program is.

I've looked at fork() way but there's no fork for windows.

My current solution is
thread.start_new(os.system, (,))

It's ugly and there's one big unpleasant pecularity:
in case there were any os.chdir()-s between beginning of script
execution and that thread.start_new() then new thread starts in
original directory. Not in current directory at moment of
thread.start_new()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can local function access local variables in main program?

2007-11-08 Thread Antoon Pardon
On 2007-11-03, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sat, 03 Nov 2007 17:30:45 -, Sullivan WxPyQtKinter
><[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>> Actually I am quite satisfied with and error, which is my expectation.
>> But the implicit global variable access seems quite uncomfortable to
>> me. Why is that necessary?
>
>   Would you want to have to write things like:

Well it would be explicit and explicit is better than implicit.

> import os
> import os.path
> import sys
>
> def dFunc(more): 
>   return "The full path of the item is: %s" % more
>
> def aFunc(something):
>   global os.path
>   global sys
>   global dFunc
>   sys.stdout.write(dFunc(os.path.join("nonsense", something)))
>
>   Your "variable" follows the same logic used for name look ups of all
> items -- "read" access will, after exhausting the local scope, search
> the module level names (note that you don't need "global" to modify a
> mutable object in module level -- it is only the rebinding of the name
> itself that needs "global")

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


Re: why did these companies choose Tcl over Python

2007-11-08 Thread Kryvor
> As an electronics engineer I use some very expensive EDA CAD tool
> programs that are scriptable using Tcl.  I was wondering why these
> companies have choose to use Tcl instead of Python.   Some of these
> are:
>
>Mentor Graphics ModelTech VHDL and Verilog simulator
>Synopsys  Design Compiler and Primetime Static Timing Analyzer
>ActelFPGA tools.


I suspect that it's due to historical reasons.

TCL first appeared in 1988, whereas Python appeared in 1991.  Some of
these tools have been around for a very long time, and I suspect that,
at first, it was mostly a question of picking the most popular
scripting language; decisions made in recent years are probably more
for convenience & backward-compatibility reasons than anything else.

(That said, I'm not a huge fan of Python's lack of braces ... :)

K.

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


optional arguments with compact reporting in optparse

2007-11-08 Thread braver
Posted to the Optik list, but it seems defunct.  Optik is now Python's
optparse.

I wonder how do you implement optional arguments to Optik.  I.e., you
can have an option

-P [file]

-- the filename is optional, with a default "data,pikl".  It works as
follows:

-- if no -P is given, no pickle is written
-- if -P is given without the filename following, a pickle file is
written with the default name data.pikl
-- if -P filename is given, the pickle is written to filename

How do we do optional values in Optik, with nargs <= 1?

Another question I have it how can I output a docstring right from the
parser.add_option() block?  I prefer to define all option-related
things in the same block once.  I'd like to output the help value from
the block, or append it to a report.

Here's example from my Ruby wrapper for Ruby's optparse:

name = :divisor
help = "show divisor"
short = "-m"
opt.on(short, "--#{name} [STR]", help) do |val|
hash[:show_divisor] = true
hash[:divisor] = val if val
end
report << [name,short,help]

-- notice that my report list is built with the exact values of all
options, regardless of whether they're encountered or not.  The I
simply walk through the report list to print a report for this run:

  report.each do |name,short,help|
val = opts.name || ""
STDERR.printf "--%s (%s)\t\%s\t%s\n", o, short, val, help
  end if verbose

How can I group such reporting together with add_option in Optik?

Cheers,
Alexy

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


http question

2007-11-08 Thread steven depret

hello there,

a question that keeps me puzzled for some time now:



basically i want to fetch the output from an http page. The page exists out of 
an input field and a button to calculate my data.

The problem is that I simply cannot get my hands on the output, but only on the 
page itself.



Image that the following URL ( 
http://10.10.10.10:8765/?command=foo&inputfield=bar ) gives as result :

a = xx

b = yy



My intention is to fetch the output so that I can play with it.



this is what I do :



import httplib

connection = httplib.HTTPConnection('10.10.10.10:8765')

connection.request('POST', 'command=foo', 'inputfield=bar')

response = connection.getresponse()

output = response.read()

print output



I get a lot of stuff in my output, but simply NOT the a=xx and the b = yy.

What the heck am I doing wrong ?







_
Deel je gedachten direct met je vrienden
http://messenger.live.com-- 
http://mail.python.org/mailman/listinfo/python-list

How to output newline or carriage return with optparse

2007-11-08 Thread john . m . roach
I'm trying to implement some simple command line options.  Some of the
'help' sections are long and I would like to control line breaks.  How
do you do this?

Thanks!

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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread Tim Chase
>> ASIDE:  I've started refactoring this bit out in my local
>> source...how would I go about contributing it back to the
>> Python code-base?  I didn't get any feedback from posting to
>> the Optik site.
> 
> You can post a patch to bugs.python.org, but it will probably
> just get forwarded to the optik site because the optparse
> module is supposed to be automatically generated from the
> current optik release. My impression is that optik is mostly
> unmaintained, which makes getting patches applied to optik
> difficult...

What sorts of things are required?  Just a patch?  Or do I also
need to include some sort of collection of doctest/unittests or
documentation patches (and if so, against which documentation
source)?

-tkc



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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread Steven Bethard
Tim Chase wrote:
>>> ASIDE:  I've started refactoring this bit out in my local
>>> source...how would I go about contributing it back to the
>>> Python code-base?  I didn't get any feedback from posting to
>>> the Optik site.
>>
>> You can post a patch to bugs.python.org, but it will probably
>> just get forwarded to the optik site because the optparse
>> module is supposed to be automatically generated from the
>> current optik release. My impression is that optik is mostly
>> unmaintained, which makes getting patches applied to optik
>> difficult...
> 
> What sorts of things are required?  Just a patch?  Or do I also
> need to include some sort of collection of doctest/unittests or
> documentation patches (and if so, against which documentation
> source)?

Yes, your patch will need to include tests and docs as well.  I would 
make the patch against the sources from the optik site (though I didn't 
see a CVS or SVN repository so you may just have to do it against the 
source release files).  Add your tests to test/test_optik.py and your 
doc fixes to doc/reference.txt (or whichever doc/ file seems most 
appropriate).

Thanks for taking this on, BTW.

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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread john . m . roach
On Nov 8, 11:46 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I'm trying to implement some simple command line options.
> > Some of the 'help' sections are long and I would like to
> > control line breaks.  How do you do this?
>
> I had this problem earlier and solved it here:
>
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/6df...
>
> thanks to a little guidance from Ben Finney on where to look.
>
> It came up again last month here:
>
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/e72...
>
> which should solve the problem for you.
>
> ASIDE:  I've started refactoring this bit out in my local
> source...how would I go about contributing it back to the Python
> code-base?  I didn't get any feedback from posting to the Optik
> site.  My refactor basically takes an optional pre-processing
> function to parse your string into the output that gets passed to
> textwrap.wrap() and textwrap.fill(), defaulting to the old
> behavior, but offering a function for splitting it into
> paragraphs based on newlines.
>
> -tkc


Thanks for the help Tim.  I just copied and pasted your code into a
file in my $PYTHONPATH (IndentedHelpFormatterWithNL.py), but I'm
getting the following error:

class IndentedHelpFormatterWithNL(IndentedHelpFormatter):
NameError: name 'IndentedHelpFormatter' is not defined


I tried adding: from optparse imoport IndentedHelpFormatter into the
aforementioned file, but no luck again.  What am I missing???

Thanks.

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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread Steven Bethard
Tim Chase wrote:
> ASIDE:  I've started refactoring this bit out in my local source...how 
> would I go about contributing it back to the Python code-base?  I didn't 
> get any feedback from posting to the Optik site.

You can post a patch to bugs.python.org, but it will probably just get 
forwarded to the optik site because the optparse module is supposed to 
be automatically generated from the current optik release. My impression 
is that optik is mostly unmaintained, which makes getting patches 
applied to optik difficult...

STeVe

P.S. FWIW, I think it would be great to get your patch in -- this 
feature is requested all the time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pyparsing really a recursive descent parser?

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 3, 10:49 am, Paul McGuire <[EMAIL PROTECTED]> wrote:

> grammar << ((word + grammar) | (word + Literal(end)))

> which works.  

[Clarifies that the common (and similar) solution doesn't work -- this
works only because the literal binds tightly to the word, so you can't
get a word that matches on its own.]


> Unfortunately, when the OneOrMore gets constructed, it does not have
> any visibility beyond knowing what is to be repeated.  Again, here is
> the data structure that is being built:
>
> - And
>   - OneOrMore
> - Word(alphas)
>   - Literal('end')
>
> Only at the level of the And is there any awareness that the OneOrMore
> is followed by anything, let alone by something which could be
> misinterpreted as something matching the OneOrMore's repetition
> expression.

> Can you suggest a way I could generalize this, so that OneOrMore stops
> matching before it gets to 'end'?

Not efficiently.

I think JAVotAM's point was that you could make it at least an option
if OneOrMore (and ZeroOrMore ...) could return fallback results as
well.

Then, when the And failed, it could retry with the next fallback
result from OneOrMore before it gives up completely.

-jJ

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


Catching and automating a win32 MessageBox

2007-11-08 Thread Xavier Homs
Hi,

I'm using an application that shows a standard (YES/NO) reconnect
MessageBox each time if loses conection with its server. It defaults to YES.

Is there any way to hook such a MessageBox a send a default action (yes)
from a Python Script?

All I've been able to do is to get a HWND with win32gui.FindWindow(none,
"Title Name") pointing to the parent window (the one that uses the
MessageBox() function)


Thanks in advance

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


Re: optional arguments with compact reporting in optparse

2007-11-08 Thread Steven Bethard
braver wrote:
> Posted to the Optik list, but it seems defunct.  Optik is now Python's
> optparse.
> 
> I wonder how do you implement optional arguments to Optik.

You may want to check out argparse:

 http://argparse.python-hosting.com/

It supports optional arguments like this::

 parser = argparse.ArgumentParser()
 parser.add_argument('-P', metavar='file', nargs='?', const='data')
 args = parser.parse_args()
 if args.file is not None:
 # -P was supplied, so do something with the file
 # if no argument to -P was given, it will be 'data'


> Another question I have it how can I output a docstring right from the
> parser.add_option() block?  I prefer to define all option-related
> things in the same block once.  I'd like to output the help value from
> the block, or append it to a report.
> 
> Here's example from my Ruby wrapper for Ruby's optparse:

I don't understand what you want here (and I don't understand the Ruby 
code).  Can you try explaining what you're trying to do here a different 
way?

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


Re: Linking debug C++ DLL with python dlls

2007-11-08 Thread brzrkr0
On Nov 8, 4:07 am, [EMAIL PROTECTED] wrote:
> I tried to change the code above (just for fun) so in both cases i'll
> use python25.lib and in debug compilation I got linker errors on
> unresolved externals. seems like the debug version exports more
> methods than the release version.

I usually just build my extensions in release mode and avoid using the
debugger.  Getting a copy of python24_d.lib (in my case) and building
a debug version of my extension isn't a big deal, but afaik all my
other extensions (wxPython, numpy, etc) have to be built in debug mode
as well in order for things to work.

If you find a good solution, please post it to the group because I'd
like to know how to do this as well.

-Casey

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


Re: How to output newline or carriage return with optparse

2007-11-08 Thread Tim Chase
> I'm trying to implement some simple command line options.
> Some of the 'help' sections are long and I would like to
> control line breaks.  How do you do this?

I had this problem earlier and solved it here:

http://groups.google.com/group/comp.lang.python/browse_frm/thread/6df6e6b541a15bc2/09f28e26af0699b1

thanks to a little guidance from Ben Finney on where to look.

It came up again last month here:

http://groups.google.com/group/comp.lang.python/browse_frm/thread/e72deee779d9989b/

which should solve the problem for you.

ASIDE:  I've started refactoring this bit out in my local 
source...how would I go about contributing it back to the Python 
code-base?  I didn't get any feedback from posting to the Optik 
site.  My refactor basically takes an optional pre-processing 
function to parse your string into the output that gets passed to 
textwrap.wrap() and textwrap.fill(), defaulting to the old 
behavior, but offering a function for splitting it into 
paragraphs based on newlines.

-tkc




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


Re: finding bluetooth serial port

2007-11-08 Thread Paul Sijben
thanks very much!


Grant Edwards wrote:
> On 2007-11-07, Paul Sijben <[EMAIL PROTECTED]> wrote:
> 
>> To automate/ease configuration in my app I am trying to find
>> out to which serial port a certain bluetooth device is
>> connected. With pybluez I can find out which bluetooth devices
>> I have, but it will not tell me the serial port they are
>> mapped to.
>>
>> Is there a way to figure this out from python? (I am
>> insterested in the platforms WinXP and linux primarily)
> 
> Under linux, the "right" thing to do is to write a udev rule so
> that the device has a predictiable name (or symlink).
> 
> http://reactivated.net/writing_udev_rules.html
> 
> If you don't want to write a udev rule, you'll need to bascally
> re-implement udev by parsing the sysfs directory tree until you
> find the device you're looking for. Here's how to do it for USB
> (I assume BT works in a similar fashion).  
> 
> Let's say I know the device has vendor ID 0403, product ID
> 6001, and serial number 123456.
> 
> I search through the directories under /sys/devices until I
> find a directory containing three files named
> 
>   idProduct
>   idVendor
>   serial  
> 
> Which contain the three strings I'm looking for.
> 
> In this case:
> 
> # cat /sys/devices/pci:00/:00:10.3/usb5/5-1/idVendor 
> 0403
> # cat /sys/devices/pci:00/:00:10.3/usb5/5-1/idProduct
> 6001
> # cat /sys/devices/pci:00/:00:10.3/usb5/5-1/serial   
> 12345678
> 
> Once you've found that directory, you can look at the other
> entries to find out whatever you want to know about the device:
> 
> /sys/devices/pci:00/:00:10.3/usb5/5-1/
> |-- 5-1:1.0
> |   |-- bAlternateSetting
> |   |-- bInterfaceClass
> |   |-- bInterfaceNumber
> |   |-- bInterfaceProtocol
> |   |-- bInterfaceSubClass
> |   |-- bNumEndpoints
> |   |-- bus -> ../../../../../../bus/usb
> |   |-- driver -> ../../../../../../bus/usb/drivers/ftdi_sio
> |   |-- ep_02 -> 
> ../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep02
> |   |-- ep_81 -> 
> ../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep81
> |   |-- interface
> |   |-- modalias
> |   |-- power
> |   |   |-- state
> |   |   `-- wakeup
> |   |-- subsystem -> ../../../../../../bus/usb
> |   |-- ttyUSB0
> |   |   |-- bus -> ../../../../../../../bus/usb-serial
> |   |   |-- driver -> ../../../../../../../bus/usb-serial/drivers/ftdi_sio
> |   |   |-- power
> |   |   |   |-- state
> |   |   |   `-- wakeup
> |   |   |-- subsystem -> ../../../../../../../bus/usb-serial
> |   |   |-- tty:ttyUSB0 -> ../../../../../../../class/tty/ttyUSB0
> |   |   `-- uevent
> |   |-- uevent
> |   |-- usb_endpoint:usbdev5.42_ep02 -> 
> ../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep02
> |   |-- usb_endpoint:usbdev5.42_ep81 -> 
> ../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0/usbdev5.42_ep81
> |   |-- usbdev5.42_ep02
> |   |   |-- bEndpointAddress
> |   |   |-- bInterval
> |   |   |-- bLength
> |   |   |-- bmAttributes
> |   |   |-- dev
> |   |   |-- device -> 
> ../../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0
> |   |   |-- direction
> |   |   |-- interval
> |   |   |-- power
> |   |   |   |-- state
> |   |   |   `-- wakeup
> |   |   |-- subsystem -> ../../../../../../../class/usb_endpoint
> |   |   |-- type
> |   |   |-- uevent
> |   |   `-- wMaxPacketSize
> |   `-- usbdev5.42_ep81
> |   |-- bEndpointAddress
> |   |-- bInterval
> |   |-- bLength
> |   |-- bmAttributes
> |   |-- dev
> |   |-- device -> 
> ../../../../../../../devices/pci:00/:00:10.3/usb5/5-1/5-1:1.0
> |   |-- direction
> |   |-- interval
> |   |-- power
> |   |   |-- state
> |   |   `-- wakeup
> |   |-- subsystem -> ../../../../../../../class/usb_endpoint
> |   |-- type
> |   |-- uevent
> |   `-- wMaxPacketSize
> |-- bConfigurationValue
> |-- bDeviceClass
> |-- bDeviceProtocol
> |-- bDeviceSubClass
> |-- bMaxPacketSize0
> |-- bMaxPower
> |-- bNumConfigurations
> |-- bNumInterfaces
> |-- bcdDevice
> |-- bmAttributes
> |-- bus -> ../../../../../bus/usb
> |-- configuration
> |-- devnum
> |-- driver -> ../../../../../bus/usb/drivers/usb
> |-- ep_00 -> 
> ../../../../../devices/pci:00/:00:10.3/usb5/5-1/usbdev5.42_ep00
> |-- event_char
> |-- idProduct
> |-- idVendor
> |-- manufacturer
> |-- maxchild
> |-- power
> |   |-- state
> |   `-- wakeup
> |-- product
> |-- serial
> |-- speed
> |-- subsystem -> ../../../../../bus/usb
> |-- uevent
> |-- usb_device:usbdev5.42 -> ../../../../../class/usb_device/usbdev5.42
> |-- usb_endpoint:usbdev5.42_ep00 -> 
> ../../../../../devices/pci:00/:00:10.3/usb5/5-1/usbdev5.42_ep00
> |-- usbdev5.42_ep00
> |   |-- bEndpointAddress
> |   |-- bInterval
> |   |-- bLength
> |   |-- bmAttributes
> |   |-- dev
> |   |-- device -> ../../../../../../devices/pci:00/:00:10.3/usb5/5-1
> |   |-- direction
> |   |-- interval
> |   |-- power
> |

Re: http question

2007-11-08 Thread Joe Riopel
On Nov 8, 2007 11:02 AM, steven depret <[EMAIL PROTECTED]> wrote:
>  I get a lot of stuff in my output, but simply NOT the a=xx and the b = yy.
>  What the heck am I doing wrong ?

What kind of stuff are you getting? Are you getting all the contents
of the HTTP response and/or HTML?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to output newline or carriage return with optparse

2007-11-08 Thread Tim Chase
> Thanks for the help Tim.  I just copied and pasted your code into a
> file in my $PYTHONPATH (IndentedHelpFormatterWithNL.py), but I'm
> getting the following error:
> 
> class IndentedHelpFormatterWithNL(IndentedHelpFormatter):
> NameError: name 'IndentedHelpFormatter' is not defined
> 
> 
> I tried adding: from optparse imoport IndentedHelpFormatter into the
> aforementioned file, but no luck again.  What am I missing???

spelling "import" correctly? :)  Also, make sure that, if you've 
named your module "IndentedHelpFormatterWithNL.py" that created 
your parser with

   parser = OptionParser(...
 formatter=
 IndentedHelpFormatterWithNL.IndentedHelpFormatterWithNL
 )

You'll also want to make sure that these two lines:

   from optparse import IndentedHelpFormatter
   import textwrap

are at the top of the IndentedHelpFormatterWithNL.py file, not at 
the top of the file importing the IndentedHelpFormatter.

-tkc


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


Old version of sqlite3

2007-11-08 Thread Colin J. Williams
sqlalchemy gives the following error 
message for sqlite:

C:\Python25\lib\site-packages\sqlalchemy\databases\sqlite.py:167: 
RuntimeWarning: The installed version of 
sqlite (3.3.4) is out-dated, and will 
cause errors in some cases.  Version 
3.3.13 or greater is recommended.
   warnings.warn(RuntimeWarning("The 
installed version of sqlite (%s) is 
out-dated, and will cause errors in some 
cases.  Version 3.3.13 or greater is 
recommended." % self.dbapi.sqlite_version))

The installed version is in 
C:\Python25\DLLs\sqlite3dll dated 
18-Apr-07.

sqlite3 has been updated since then.

I am using Python 2.5.1 with Windows XP.

Any suggestions for a workaround?

Colin W.

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


Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread [EMAIL PROTECTED]
I'm trying to get a list of messages from GMAIL using it's new IMAP
access.

So far I've tried running this command but it just hangs.  Any ideas?

>>> import imaplib
>>> M=imaplib.IMAP4('imap.gmail.com',993)

I figured that's the first line to run from this example:
http://docs.python.org/lib/imap4-example.html

Here are the configuration settings GMAIL says to use:
https://mail.google.com/support/bin/answer.py?answer=78799

Thanks for any help.

-Greg

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


Re: Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread Jason
On Nov 8, 11:41 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I'm trying to get a list of messages from GMAIL using it's new IMAP
> access.
>
> So far I've tried running this command but it just hangs.  Any ideas?
>
> >>> import imaplib
> >>> M=imaplib.IMAP4('imap.gmail.com',993)
>
> I figured that's the first line to run from this 
> example:http://docs.python.org/lib/imap4-example.html
>
> Here are the configuration settings GMAIL says to 
> use:https://mail.google.com/support/bin/answer.py?answer=78799
>
> Thanks for any help.
>
> -Greg

Well, Google states that it's using SSL.  You're not using the SSL
with your example code.  Take a look in the imaplib module.  At least
under Python 2.5, there's also an IMAP4_SSL class:

>>> import imaplib
>>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)

That worked for me.  I could then use the login method to log into the
mail server.

  --Jason

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


Creating a cell 'by hand'

2007-11-08 Thread Prepscius, Colin (IT)
The last argument to new.function takes a closure, which is a tuple of
cell objects.  Does anybody know how to create those cell objects 'by
hand'?

Thanks!
Colin


NOTICE: If received in error, please destroy and notify sender. Sender does not 
intend to waive confidentiality or privilege. Use of this email is prohibited 
when received in error.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Using python as primary language

2007-11-08 Thread Michael Bacarella

> > How do you feel about multithreading support?
> >
> > A multithreaded application in Python will only use a single CPU on
> > multi-CPU machines due to big interpreter lock, whereas the "right
> thing"
> > happens in Java.
> 
> Note that this is untrue for many common uses of threading (e.g. using
> threads to wait on network connections, or calling out to most common
> compute-intensive C extensions), where the GIL is released and
> multiple CPUs are used just fine.

It's true in exactly the case where you would gain the most benefit
from multiple CPUs.  So I'm not sure how uncommon that is.


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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Bruno Desthuilliers
Frank Samuelson a écrit :
> I love Python, and it is one of my 2 favorite
> languages.  I would suggest that Python steal some
> aspects of the S language.
> 
> ---
> 1. Currently in Python
> def  foo(x,y): ...
> assigns the name foo to a function object.  Is this pythonic?

Yes. Python deliberately choosed to be a statement-based language.

> Why not use the = operator like most other assignments?

This dead horse has been beaten to hell and back.

Note that as far as I'm concerned, I may like an expression-based 
Python-inspired language. But this is another story.

> 
> ---
> 2. Allow sequences to be indices:
>  >>> s=["hello", 6, 33, "none"]
>  >>> x= [1,3]
>  >>> [ s[y] for y in x] # Current verbose version

Verbose ???

> [6, 'none']
>  >>> s[x]   # Simpler, clearer, more productive
> 
> To quote a poster at http://www.thescripts.com/forum/thread22741.html,
> "While we are at it, I also don't understand why sequences can't be
> used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special
> slice concept? 

slices are very powerful.

>"  Isn't that unpythonic?

Not IMHO. But extending slices to support might not be totally stupid. 
Do you volunteer to write the PEP and the patch ?

> 
> 3. When I first started using python, I frequently used
> map, because I didn't want to have to learn the
> additional syntax of list comprehensions, which
> appeared very nonstructured.
> 
> # Is this readable?
> b= [x+y for x in vec1 if x>0 for y in vec2 if y>x ]

Yes.

> Perhaps a list comprehension syntax more like the rest
> of python. "for" could return a list given by continue
> arguments:
> 
> b= for x in vec1 :
>   if (x>0):  continue # "returns" nothing
>   continue for y in vec2:
>  if (x>y): continue(x+y)

Now *this* is a mess. And FWIW, you inverted the second test...

> Note that my code would actually return a list of lists
> rather than a single list like the list comprehension.
> More structured syntax opens the door to having much
> more complicated, yet still comprehensible (thus more
> pythonic), list comprehensions.

The Pythonic way to write "more complicated yet still comprehensible 
list comprehensions" is to not use list comprehensions.

b = []
for x in vec1:
   if x > 0:
 for y in vec2:
   if y > x:
 b.append(x + y)

Or if you really want a more functional approach:

def do_stuff(vec1, vec2):
   for x in vec1:
 if x > 0:
   for y in vec2:
 if y > x:
   yield x + y

b = list(do_stuff(vec1, vec2))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using python as primary language

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 8, 2:09 pm, "Michael Bacarella" <[EMAIL PROTECTED]> wrote:
> > In our company we are looking for one language to be used as default
> > language. So far Python looks like a good choice (slacking behind
> > Java). A few requirements that the language should be able cope with
> > are:
>
> How do you feel about multithreading support?
>
> A multithreaded application in Python will only use a single CPU on
> multi-CPU machines due to big interpreter lock, whereas the "right thing"
> happens in Java.

Note that this is untrue for many common uses of threading (e.g. using
threads to wait on network connections, or calling out to most common
compute-intensive C extensions), where the GIL is released and
multiple CPUs are used just fine.

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


Re: Creating a cell 'by hand'

2007-11-08 Thread Chris Mellon
On Nov 8, 2007 5:30 PM, Prepscius, Colin (IT)
<[EMAIL PROTECTED]> wrote:
> The last argument to new.function takes a closure, which is a tuple of
> cell objects.  Does anybody know how to create those cell objects 'by
> hand'?
>

Beyond copying them from an existing closure, you'll have to use the C
API to create the new cell objects:

>>> pc = ctypes.pythonapi.PyCell_New
>>> pc.restype = ctypes.py_object
>>> pc.argtypes = [ctypes.py_object]
>>> pc(100)

>>> import new
>>> def f():
... x = 10
... def g():
... return x
... return g
...
>>> f()

>>> g = _
>>> new.function(g.func_code, {}, "free as a bird", None, (pc(100),))

>>> _()
100
>>> g()
10


I don't really know how safe this is or what sort of refcount or GC
implications creating cell objects on the fly like this might have.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a cell 'by hand'

2007-11-08 Thread Jean-Paul Calderone
On Thu, 8 Nov 2007 18:30:15 -0500, "Prepscius, Colin \(IT\)" <[EMAIL 
PROTECTED]> wrote:
>The last argument to new.function takes a closure, which is a tuple of
>cell objects.  Does anybody know how to create those cell objects 'by
>hand'?

Here's one approach:

>>> def f():
... x = 10
... def g():
... a = x
... return g
...
>>> f().func_closure
(,)
>>>

I don't know what your use-case is, so I have no idea if this is the
kind of solution you're looking for.

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


Re: Using python as primary language

2007-11-08 Thread Chris Mellon
On Nov 8, 2007 5:22 PM, Michael Bacarella <[EMAIL PROTECTED]> wrote:
>
> > > How do you feel about multithreading support?
> > >
> > > A multithreaded application in Python will only use a single CPU on
> > > multi-CPU machines due to big interpreter lock, whereas the "right
> > thing"
> > > happens in Java.
> >
> > Note that this is untrue for many common uses of threading (e.g. using
> > threads to wait on network connections, or calling out to most common
> > compute-intensive C extensions), where the GIL is released and
> > multiple CPUs are used just fine.
>
> It's true in exactly the case where you would gain the most benefit
> from multiple CPUs.  So I'm not sure how uncommon that is.
>

It's pretty uncommon. There are relatively few CPU bound tasks that
are a) highly parallel and b) can't be easily scaled between
processes. Python is not (by itself) an especially good tool for those
tasks.

I find that, by far, the most common use of threads (especially in
Java applications) has more to do with the designers lack of knowledge
of other concurrency models than any particular benefit of the
threading model.

Python is excellently suited to be the "primary language" for pretty
much any company because of its flexibility and (especially) it's
willingness to play nicely with other languages and environments. It
isn't well suited to being the *only* language used, and I would argue
that no language is - lots of companies to try to treat C#/.NET or
Java as the One True Language and suffer for it in stagnant, expensive
development, cumbersome library use, and lack of flexibility.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pyparsing really a recursive descent parser?

2007-11-08 Thread [david]
Kay Schluehr wrote:
> 
> Could you please learn some parser theory 101 and then come back when
> you have complaints about one or the other implemententation of a
> particular Python parser? When some guy enters a forum with a "newbie
> question" most of the time people are willing to give a fair and
> comprehensive answer but they don't want to mess around with him
> endlessly when he is not willing to learn and to listen.
> 
> 
Immaturity is a mark of this group, isn't it?  When all else fails, 
resort to insults.

My suggestion is, if you can't be polite, just go back to your own room.

(david)

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


Please post Python jobs to the Python Job Board (was: Python Developers needed for...)

2007-11-08 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> Hello! Please feel free to forward this on to your network. All those
> interested in this position, please email me at [...]

This forum is not an appropriate place to post job
advertisements. Instead, please use the Python Job Board
http://www.python.org/community/jobs/>.

-- 
 \"A hundred times every day I remind myself that [...] I must |
  `\   exert myself in order to give in the same measure as I have |
_o__)received and am still receiving" —Albert Einstein |
Ben Finney <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python on Leopard issues

2007-11-08 Thread Nicholas Bastin
On Nov 8, 2007 4:59 PM, Nicholas Bastin <[EMAIL PROTECTED]> wrote:
>  Also, Apple distributes the standard library in a zip file, so you
> won't find all the packages just lying around.  They should all be
> stored in /Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip.

I'll eat my words on this one.  In Leopard the standard library is all
.py files in /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/

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


Re: Python on Leopard issues

2007-11-08 Thread Nicholas Bastin
On Nov 8, 2007 4:13 PM, Chris <[EMAIL PROTECTED]> wrote:
> Are others having fundamental issues on OSX 10.5 with python 2.5.1? I was
> excited that Python 2.5 was included, but this excitement was very short
> lived. Almost nothing works. Upon startup I get this message:
>
> 'import site' failed; use -v for traceback
>
> and sure enough, all of the built-in packages are non-existent. I'm not sure
> why Apple bothered including an improperly-configured version. Does
>  anyone have an easy fix for this, or should I go to ActiveState and install a
> version that works?

A fresh full install of leopard does not have this problem, nor does
my machine with a simple upgrade.  Typically when import site fails,
your environment is screwed up.  Does 'which python' give you:
/Library/Frameworks/Python.framework/Versions/Current/bin/python?

Also, Apple distributes the standard library in a zip file, so you
won't find all the packages just lying around.  They should all be
stored in /Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip.

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


Re: Anyone had success using NetUseAdd() on shares accessed through a Windows 2003 DFS root?

2007-11-08 Thread kyosohma
On Nov 8, 2:23 pm, Sean Peterson <[EMAIL PROTECTED]> wrote:
> Has anyone had success using NetUseAdd() on shares that were replica links on 
> a Windows 2003 DFS root? In my code, I'm getting error:
>
> pywintypes.error: (67, 'NetUseAdd', 'The network name cannot be found.')
>
> This is my scenario:
>
> Win2003 Server hosting DFS root #NTS-03
> \\NTS-03.central.purdue.lcl\MI
>
> Win2003 Server hosting file share
> \\itifs03.itap.purdue.edu\itea_zonedirs\MI
>
> 
>
> import win32net
>
> # this works --
> win32net.NetUseAdd(None,1,{'remote':r'//itifs03.itap.purdue.edu/itea_zonedirs/MI/TEAMDIRS/DCS
> Zone','local':'W:'})
>
> # this doesn't work --
> win32net.NetUseAdd(None,1,{'remote':r'//NTS-03.central.purdue.lcl/MI/TEAMDIRS/DCS
> Zone','local':'W:'})
>
> 
>
> Any help greatly appreciated.
>
> -Sean.

We actually use win32wnet.WNetAddConnection2 to map a drive. The
following recipe lists a slightly different way of doing it as well:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/426742

I don't think you need to make those path strings into raw text if
you're using forward slashes, by the way.

Mike

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Raymond Hettinger
On Nov 8, 12:00 pm, Frank Samuelson
<[EMAIL PROTECTED]> wrote:
> def  foo(x,y): ...
> assigns the name foo to a function object.
>
> Why not use the = operator like most other assignments?

FWIW, the also binds the __name__ attribute:

   foo = lambda(x,y): ...
   foo.__name__ = 'foo'


Raymond

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


Re: Old version of sqlite3

2007-11-08 Thread Martin v. Löwis
> Any suggestions for a workaround?

You could silence the warning, using the warnings module.
Alternatively, I think you should be able to replace sqlite3.dll
with a newer version.

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


Anyone had success using NetUseAdd() on shares accessed through a Windows 2003 DFS root?

2007-11-08 Thread Sean Peterson
Has anyone had success using NetUseAdd() on shares that were replica links on a 
Windows 2003 DFS root? In my code, I'm getting error:

pywintypes.error: (67, 'NetUseAdd', 'The network name cannot be found.')

This is my scenario:


Win2003 Server hosting DFS root #NTS-03
\\NTS-03.central.purdue.lcl\MI


Win2003 Server hosting file share
\\itifs03.itap.purdue.edu\itea_zonedirs\MI



import win32net

# this works -- 
win32net.NetUseAdd(None,1,{'remote':r'//itifs03.itap.purdue.edu/itea_zonedirs/MI/TEAMDIRS/DCS
 
Zone','local':'W:'})

# this doesn't work --
win32net.NetUseAdd(None,1,{'remote':r'//NTS-03.central.purdue.lcl/MI/TEAMDIRS/DCS
 
Zone','local':'W:'})



Any help greatly appreciated.

-Sean.

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


Re: Linking debug C++ DLL with python dlls

2007-11-08 Thread Mathieu Gontier
Hello,

I often build Python on Windows.

What I can say is it not so trivial to build debug libraries for Python: 
each debug library must have the postfix *_d.dll/.pyd.

Another useful information. On Windows, a shared library is linked to 
our application though a associated file with the .lib extension. This 
"static library" contains all the information relating to de 
__declspec(import) / __declspec(export) instructions you should add in 
the code. The most important in Python is that the shared libraries 
(usually with the extension .dll) have as extension .pyd.
So, you can change it in Visual Studio.


Mathieu Gontier
Core Development Engineer

Read the attached v-card for telephone, fax, adress
Look at our web-site http://www.fft.be
 



[EMAIL PROTECTED] wrote:
> On Nov 8, 4:07 am, [EMAIL PROTECTED] wrote:
>   
>> I tried to change the code above (just for fun) so in both cases i'll
>> use python25.lib and in debug compilation I got linker errors on
>> unresolved externals. seems like the debug version exports more
>> methods than the release version.
>> 
>
> I usually just build my extensions in release mode and avoid using the
> debugger.  Getting a copy of python24_d.lib (in my case) and building
> a debug version of my extension isn't a big deal, but afaik all my
> other extensions (wxPython, numpy, etc) have to be built in debug mode
> as well in order for things to work.
>
> If you find a good solution, please post it to the group because I'd
> like to know how to do this as well.
>
> -Casey
>
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to output newline or carriage return with optparse

2007-11-08 Thread John
On Nov 8, 12:40 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > Thanks for the help Tim.  I just copied and pasted your code into a
> > file in my $PYTHONPATH (IndentedHelpFormatterWithNL.py), but I'm
> > getting the following error:
>
> > class IndentedHelpFormatterWithNL(IndentedHelpFormatter):
> > NameError: name 'IndentedHelpFormatter' is not defined
>
> > I tried adding: from optparse imoport IndentedHelpFormatter into the
> > aforementioned file, but no luck again.  What am I missing???
>
> spelling "import" correctly? :)  Also, make sure that, if you've
> named your module "IndentedHelpFormatterWithNL.py" that created
> your parser with
>
>parser = OptionParser(...
>  formatter=
>  IndentedHelpFormatterWithNL.IndentedHelpFormatterWithNL
>  )
>
> You'll also want to make sure that these two lines:
>
>from optparse import IndentedHelpFormatter
>import textwrap
>
> are at the top of the IndentedHelpFormatterWithNL.py file, not at
> the top of the file importing the IndentedHelpFormatter.
>
> -tkc

That seems to do the trick.  I'm sure there are quite a few people out
there who have run into this same problem-- I'm glad you're adding it
to the patches!

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


Re: Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 8, 2:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Nov 8, 1:52 pm, Jason <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Nov 8, 11:41 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > I'm trying to get a list of messages from GMAIL using it's new IMAP
> > > access.
>
> > > So far I've tried running this command but it just hangs.  Any ideas?
>
> > > >>> import imaplib
> > > >>> M=imaplib.IMAP4('imap.gmail.com',993)
>
> > > I figured that's the first line to run from this 
> > > example:http://docs.python.org/lib/imap4-example.html
>
> > > Here are the configuration settings GMAIL says to 
> > > use:https://mail.google.com/support/bin/answer.py?answer=78799
>
> > > Thanks for any help.
>
> > > -Greg
>
> > Well, Google states that it's using SSL.  You're not using the SSL
> > with your example code.  Take a look in the imaplib module.  At least
> > under Python 2.5, there's also an IMAP4_SSL class:
>
> > >>> import imaplib
> > >>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>
> > That worked for me.  I could then use the login method to log into the
> > mail server.
>
> >   --Jason
>
> Followup question.  My ultimate goal is to get all messages with a
> certain GMAIL label.  I'm going under the assumption labels will
> appear as folders over IMAP.  Any idea how to access folders with
> IMAP?
>
> -Greg


Figured it out.  Just do mail.select('label')

GMAIL does treat labels as folders.

-Greg

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


Re: help parsing ipv6 addresses and subnets

2007-11-08 Thread Hyuga
On Nov 8, 3:11 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote:
> * Prabhu Gurumurthy (Wed, 07 Nov 2007 22:34:14 -0800)
>
> > I would like to parse IPv6 addresses and subnet using re module in
> > python.
>
> Just don't:http://pypi.python.org/pypi?%3Aaction=search&term=ipv6
> &submit=search

And even if you do end up doing the IPv6 parsing yourself (which you
shouldn't), regular expressions would be the wrong approach--there's
no way an RE can deal with replacing a :: with the correct number of
zeroes, among other complications.

Hyuga

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


RE: Using python as primary language

2007-11-08 Thread Michael Bacarella
> In our company we are looking for one language to be used as default
> language. So far Python looks like a good choice (slacking behind
> Java). A few requirements that the language should be able cope with
> are:

How do you feel about multithreading support?

A multithreaded application in Python will only use a single CPU on
multi-CPU machines due to big interpreter lock, whereas the "right thing"
happens in Java.

This can be worked around with fork() and shared memory but it certainly
surprised us to learn this.

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Carl Banks
On Nov 8, 3:00 pm, Frank Samuelson
<[EMAIL PROTECTED]> wrote:
> I know these ideas are not perfect, but I think they
> may be better... Fire away.


Python isn't Lisp.


Carl Banks

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


*** Revealing New Video on VP Dick Cheney's ILLUSTRIOUS Career ***

2007-11-08 Thread thermate
Take a break from a stressful day, and educate yourself !!!

Below is the optimum browsing order.

http://novakeo.com/?p=151
http://www.youtube.com/watch?v=oEenyyiQGGQ
http://www.youtube.com/watch?v=tRfhUezbKLw
http://www.youtube.com/watch?v=PtpvLIpdXPQ

http://www.republicbroadcasting.org/index.php?cmd=nwo911

http://www.republicbroadcasting.org/index.php?cmd=archives

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


Re: Using python as primary language

2007-11-08 Thread kyosohma
On Nov 8, 1:09 pm, "Michael Bacarella" <[EMAIL PROTECTED]> wrote:
> > In our company we are looking for one language to be used as default
> > language. So far Python looks like a good choice (slacking behind
> > Java). A few requirements that the language should be able cope with
> > are:
>
> How do you feel about multithreading support?
>
> A multithreaded application in Python will only use a single CPU on
> multi-CPU machines due to big interpreter lock, whereas the "right thing"
> happens in Java.
>
> This can be worked around with fork() and shared memory but it certainly
> surprised us to learn this.

For multithreaded apps, the usual recommendation is Parallel Python

http://www.parallelpython.com/

Mike

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


Re: Looking for a good Python environment

2007-11-08 Thread PyScripter
On Nov 7, 6:50 pm, Paul Rubin  wrote:
> "Colin J. Williams" <[EMAIL PROTECTED]> writes:
>
> > Could you elaborate on "lightweight" please? I findPyScripterto be a
> > powerful editor/debugger combination.
>
> > What functionality does Eclipse have thatPyScripterdoes not?
>
> While we're at it, do any of these debuggers implement a good way to
> debug multi-threaded Python programs?

PyScripter (http://pyscripter.googlepages.com) debugging is based on
the standard Python debugger bdb.py which does not currently support
multi-threaded debugging (only the main thread can be debugged).  One
debugger with such support is Winpdb.  PyScripter may integrate Winpdb
in the future.  However PyScripter does support debugging of GUI (e.g.
Tkinter, WxPython) applications with remote debugging.

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


Re: Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 8, 1:52 pm, Jason <[EMAIL PROTECTED]> wrote:
> On Nov 8, 11:41 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I'm trying to get a list of messages from GMAIL using it's new IMAP
> > access.
>
> > So far I've tried running this command but it just hangs.  Any ideas?
>
> > >>> import imaplib
> > >>> M=imaplib.IMAP4('imap.gmail.com',993)
>
> > I figured that's the first line to run from this 
> > example:http://docs.python.org/lib/imap4-example.html
>
> > Here are the configuration settings GMAIL says to 
> > use:https://mail.google.com/support/bin/answer.py?answer=78799
>
> > Thanks for any help.
>
> > -Greg
>
> Well, Google states that it's using SSL.  You're not using the SSL
> with your example code.  Take a look in the imaplib module.  At least
> under Python 2.5, there's also an IMAP4_SSL class:
>
> >>> import imaplib
> >>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>
> That worked for me.  I could then use the login method to log into the
> mail server.
>
>   --Jason


Thanks! That worked.  You're a gem.

-Greg

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


Re: spawn background process and detach it w/o problems

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 8, 8:09 am, "Dmitry Teslenko" <[EMAIL PROTECTED]> wrote:
> Hello!
> How to write portable (win32, unix) script that launches another
> program and continues its execution?
>
> I've looked at spawn*() but it doesn't look in PATH dirs on windows so
> it's totally unusable when you don't know where exactly program is.
>
> I've looked at fork() way but there's no fork for windows.
>
> My current solution is
> thread.start_new(os.system, (,))
>
> It's ugly and there's one big unpleasant pecularity:
> in case there were any os.chdir()-s between beginning of script
> execution and that thread.start_new() then new thread starts in
> original directory. Not in current directory at moment of
> thread.start_new()

Take a look at the subprocess module.

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


Re: Using imaplib module with GMAIL's IMAP - hangs

2007-11-08 Thread [EMAIL PROTECTED]
On Nov 8, 1:52 pm, Jason <[EMAIL PROTECTED]> wrote:
> On Nov 8, 11:41 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I'm trying to get a list of messages from GMAIL using it's new IMAP
> > access.
>
> > So far I've tried running this command but it just hangs.  Any ideas?
>
> > >>> import imaplib
> > >>> M=imaplib.IMAP4('imap.gmail.com',993)
>
> > I figured that's the first line to run from this 
> > example:http://docs.python.org/lib/imap4-example.html
>
> > Here are the configuration settings GMAIL says to 
> > use:https://mail.google.com/support/bin/answer.py?answer=78799
>
> > Thanks for any help.
>
> > -Greg
>
> Well, Google states that it's using SSL.  You're not using the SSL
> with your example code.  Take a look in the imaplib module.  At least
> under Python 2.5, there's also an IMAP4_SSL class:
>
> >>> import imaplib
> >>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>
> That worked for me.  I could then use the login method to log into the
> mail server.
>
>   --Jason


Followup question.  My ultimate goal is to get all messages with a
certain GMAIL label.  I'm going under the assumption labels will
appear as folders over IMAP.  Any idea how to access folders with
IMAP?

-Greg

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


Re: Using python as primary language

2007-11-08 Thread kyosohma
On Nov 8, 1:52 am, Michel Albert <[EMAIL PROTECTED]> wrote:
> In our company we are looking for one language to be used as default
> language. So far Python looks like a good choice (slacking behind
> Java). A few requirements that the language should be able cope with
> are:
>
> * Database access to Sybase.
>   This seems to be available for python, but the windows-binaries for
> the library
>   are not available. Self-Compiling them proved to be non-trivial (As
> always
>   on windows).
> * Easy GUI creation.
>   Solved using PyQt.
> * Cross Platform (Linux + Windows).
>   Again, PyQt, solves this
> * Easy deployment.
>   Solved using py2exe + innosetup
> * Charting (Histograms, Line charts, bar charts, pie charts, ...)
>   I am currently looking into PyQwt, which looks promising.
> * Report generation with GUI support
>   reportlab + rml?
>
> So far, nearly all point seems to be manageable. But I was not yet
> able to find a solution for the report generation. What we would like
> to have is a sort of GUI interface to prepare the reports without
> having to "code" the positioning. I found reportlab, and it looks like
> it can do all that is needed in terms of output. But you still have to
> code the report. And this is a no go. In context, I found RML and saw
> links to graphical RML editors. But I have not yet found a concrete
> example code, or documentation. What am I missing? Is RML a reportlab
> creation or is it a recognised open standard? If not, is there an open
> standard, that is easily to process with python?
>
> Any pointers? I would prefer coding Python to coding Java or
> worse. VB ;) which is another contender in our roundup.

It looks like RML (Reportlab Markup Language) is a type of XML to me.
It also appears to be a ReportLab invention. Lots of code examples can
be found here:

http://developer.reportlab.com/examples.html

See also: http://www.reportlab.com/rml_index.html

I'm not sure what you mean by "editing" a report. I have an
application that allows users to enter data into a GUI and then it
takes their data and inputs it into a ReportLab generated PDF.

Mike

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


Some "pythonic" suggestions for Python

2007-11-08 Thread Frank Samuelson
I love Python, and it is one of my 2 favorite
languages.  I would suggest that Python steal some
aspects of the S language.

---
1. Currently in Python
def  foo(x,y): ...
assigns the name foo to a function object.  Is this pythonic?

Why not use the = operator like most other assignments?
Define function objects as "function"s, let users put them where
they want to.  Get rid of lambda, get rid of def, only use =
for assignments.

foo = function(x,y) x+y*2   # Example S language code
bar = foo
bar(3,4)
m = lapply( s, foo )
bb = lapply(s, function(t) t[3]*4 )

foo = func(x,y): x+y*2   # Possible python code
bar = foo
bar(3,4)
m = barf( s, foo )
bb = barf(s, func(t): t[3]*4 )

---
2. Allow sequences to be indices:
 >>> s=["hello", 6, 33, "none"]
 >>> x= [1,3]
 >>> [ s[y] for y in x] # Current verbose version
[6, 'none']
 >>> s[x]   # Simpler, clearer, more productive

To quote a poster at http://www.thescripts.com/forum/thread22741.html,
"While we are at it, I also don't understand why sequences can't be
used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special
slice concept? "  Isn't that unpythonic?


3. When I first started using python, I frequently used
map, because I didn't want to have to learn the
additional syntax of list comprehensions, which
appeared very nonstructured.

# Is this readable?
b= [x+y for x in vec1 if x>0 for y in vec2 if y>x ]

Perhaps a list comprehension syntax more like the rest
of python. "for" could return a list given by continue
arguments:

b= for x in vec1 :
   if (x>0):  continue # "returns" nothing
   continue for y in vec2:
  if (x>y): continue(x+y)

Note that my code would actually return a list of lists
rather than a single list like the list comprehension.
More structured syntax opens the door to having much
more complicated, yet still comprehensible (thus more
pythonic), list comprehensions.



I know these ideas are not perfect, but I think they
may be better... Fire away.

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


Re: Linking debug C++ DLL with python dlls

2007-11-08 Thread Martin v. Lo
> So I decided to download and build the debug version of python2.5.1/
> As it seems I also need to compile all relevant extension modules
> (*.pyd) in debug as well - is this correct?

That's correct.

> I tried to change the code above (just for fun) so in both cases i'll
> use python25.lib and in debug compilation I got linker errors on
> unresolved externals. seems like the debug version exports more
> methods than the release version.

Correct.

> Is there a way to have my C++ code compile in debug mode (with _DEBUG)
> but use the python25 release lib/dll? This way I don't need to have
> additional set of debug extension modules.

Try removing the definition of Py_DEBUG that is implied by _DEBUG.

Notice, however, that it is risky to mix different CRT versions
(debug and nodebug) in a single application; this could cause memory
leaks and crashes. In particular, it *will* cause crashes if you
pass FILE* opened by the debug CRT to PyRun_File and friends. That's
an inherent limitation of Windows DLLs, and the way Microsoft set
up global variables in the VC CRT.

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


Re: Anyone had success using NetUseAdd() on shares accessed through a Windows 2003 DFS root?

2007-11-08 Thread kyosohma
On Nov 8, 2:23 pm, Sean Peterson <[EMAIL PROTECTED]> wrote:
> Has anyone had success using NetUseAdd() on shares that were replica links on 
> a Windows 2003 DFS root? In my code, I'm getting error:
>
> pywintypes.error: (67, 'NetUseAdd', 'The network name cannot be found.')
>
> This is my scenario:
>
> Win2003 Server hosting DFS root #NTS-03
> \\NTS-03.central.purdue.lcl\MI
>
> Win2003 Server hosting file share
> \\itifs03.itap.purdue.edu\itea_zonedirs\MI
>
> 
>
> import win32net
>
> # this works --
> win32net.NetUseAdd(None,1,{'remote':r'//itifs03.itap.purdue.edu/itea_zonedirs/MI/TEAMDIRS/DCS
> Zone','local':'W:'})
>
> # this doesn't work --
> win32net.NetUseAdd(None,1,{'remote':r'//NTS-03.central.purdue.lcl/MI/TEAMDIRS/DCS
> Zone','local':'W:'})
>
> 
>
> Any help greatly appreciated.
>
> -Sean.

I'm not seeing any typos in your code...but it looks like you're
trying to map two different locations to the same drive letter. Maybe
that's throwing an error in and of itself?

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Jarek Zgoda
Frank Samuelson pisze:

> foo = function(x,y) x+y*2   # Example S language code

Ugly.

-- 
Jarek Zgoda
http://zgodowie.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Python on Leopard issues

2007-11-08 Thread Chris
Are others having fundamental issues on OSX 10.5 with python 2.5.1? I was 
excited that Python 2.5 was included, but this excitement was very short 
lived. Almost nothing works. Upon startup I get this message:

'import site' failed; use -v for traceback

and sure enough, all of the built-in packages are non-existent. I'm not sure 
why Apple bothered including an improperly-configured version. Does
 anyone have an easy fix for this, or should I go to ActiveState and install a 
version that works?

Thanks.

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Diez B. Roggisch
Frank Samuelson schrieb:
> I love Python, and it is one of my 2 favorite
> languages.  I would suggest that Python steal some
> aspects of the S language.
> 
> ---
> 1. Currently in Python
> def  foo(x,y): ...
> assigns the name foo to a function object.  Is this pythonic?
> 
> Why not use the = operator like most other assignments?
> Define function objects as "function"s, let users put them where
> they want to.  Get rid of lambda, get rid of def, only use =
> for assignments.
> 
> foo = function(x,y) x+y*2   # Example S language code
> bar = foo
> bar(3,4)
> m = lapply( s, foo )
> bb = lapply(s, function(t) t[3]*4 )
> 
> foo = func(x,y): x+y*2   # Possible python code
> bar = foo
> bar(3,4)
> m = barf( s, foo )
> bb = barf(s, func(t): t[3]*4 )

The whole purpose being that you have statements in lambdas - something 
that has been proposed and rejected about a bazillion times. Read the 
archives.


> ---
> 2. Allow sequences to be indices:
>  >>> s=["hello", 6, 33, "none"]
>  >>> x= [1,3]
>  >>> [ s[y] for y in x] # Current verbose version
> [6, 'none']
>  >>> s[x]   # Simpler, clearer, more productive
> 
> To quote a poster at http://www.thescripts.com/forum/thread22741.html,
> "While we are at it, I also don't understand why sequences can't be
> used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special
> slice concept? "  Isn't that unpythonic?


What has the one to do with the other? Slices are use- and powerful.

I'm not against this, but then what you call "verbose" is very concise 
in my book - and concise enough to be used when the need arises, which 
is seldom enough.

> 
> 3. When I first started using python, I frequently used
> map, because I didn't want to have to learn the
> additional syntax of list comprehensions, which
> appeared very nonstructured.
> 
> # Is this readable?
> b= [x+y for x in vec1 if x>0 for y in vec2 if y>x ]


Yes, I think it is readable. You could ask the same for the 
parenthesis-overload in lisp - after all, it's just what you are 
accustomed to.


> Perhaps a list comprehension syntax more like the rest
> of python. "for" could return a list given by continue
> arguments:
> 
> b= for x in vec1 :
>   if (x>0):  continue # "returns" nothing
>   continue for y in vec2:
>  if (x>y): continue(x+y)
> 
> Note that my code would actually return a list of lists
> rather than a single list like the list comprehension.
> More structured syntax opens the door to having much
> more complicated, yet still comprehensible (thus more
> pythonic), list comprehensions.

So it is _not_ a list comprehension, but all it does is to create 
implicit lists?

I prefer list-comps. They allow for nested as well as flattened structures:

b= [x+y for x in vec1 if x>0 for y in vec2 if y>x ]
b= [[x+y  for y in vec2 if y>x  ] for x in vec1 if x>0]

Overall, I'd say you don't stand a chance that your proposals will be 
adopted. They are minor variations of things that have been proposed & 
rejected too often to count - and to be honest: it get's tiresome 
beating the same old horses again and again...

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Ben Finney
Frank Samuelson <[EMAIL PROTECTED]> writes:

> I love Python, and it is one of my 2 favorite
> languages.  I would suggest that Python steal some
> aspects of the S language.

I would suggest each of these be discussed in a separate thread, each
with a specific Subject field, rather than three loosely-related
questions in a single thread.

-- 
 \   "People are very open-minded about new things, as long as |
  `\  they're exactly like the old ones."  -- Charles F. Kettering |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python on Leopard issues

2007-11-08 Thread Diez B. Roggisch
Chris schrieb:
> Are others having fundamental issues on OSX 10.5 with python 2.5.1? I was 
> excited that Python 2.5 was included, but this excitement was very short 
> lived. Almost nothing works. Upon startup I get this message:
> 
> 'import site' failed; use -v for traceback
> 
> and sure enough, all of the built-in packages are non-existent. I'm not sure 
> why Apple bothered including an improperly-configured version. Does
>  anyone have an easy fix for this, or should I go to ActiveState and install 
> a 
> version that works?

While Apple is far from being perfect, I strongly doubt that they ship a 
python as damaged as this - after all, they rely for some system stuff 
on the shipped interpreter.

But I bet you didn't install leopard fresh, but upgraded? And did you by 
any chance have a python 2.5 installed before?

Anyway, without much more information (where is the python framework 
located and so forth) there is no chance of being more helpful.

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


Python Developers needed for Rackspace Managed Hosting-full time employment opportunities

2007-11-08 Thread [EMAIL PROTECTED]
Hello! Please feel free to forward this on to your network. All those
interested in this position, please email me at
[EMAIL PROTECTED] Thanks!-Amanda Papp

Python Developer
Job Description: Rackspace is a highly awarded and respected managed
web hosting company. We earned our place by approaching what we do
from our customer’s point-of-view. We do more than just expertly
support the technologies we provide (the servers, the devices, the
data centers and the network); we also expertly support our customers.
We call it Fanatical Support™. It’s a novel idea and it seems to work
really well for all involved – our customers, our company and our
employees.

Home to more than 1,800 Rackers (known to the outside world as
Rackspace employees), we’ve nearly doubled in size during the past
year – that’s how rapidly we’re expanding. And the growth has happened
without us acquiring other companies or being acquired by another
company. If you’re paying attention, this kind of growth means that
we’re hiring all the time.

But just because we need to hire people, doesn’t mean we’ll let anyone
in the place. There are a few prerequisites. You have to be pretty
darn sharp. You need to like working hard. You should believe in
Rackspace and Fanatical Support and in yourself. And you better love
what you do, because we do.

Our Core Values are:

FANATICAL SUPPORT™ in all we do
RESULTS first: substance over flash
Embrace CHANGE for excellence
PASSION for our work
Keep our PROMISES
We treat each other like FRIENDS and FAMILY
Rackspace Managed Hosting is seeking a Python Developer to join our
Open Source Environment. You would be part of a fast paced, cutting
edge development team responsible for the future of our world class
mission critical systems. Are you up for the challenge?

Do you believe there is always a better way to solve a problem? Do you
enjoy creating new innovative solutions to interesting problems? Do
you like working with others in an agile environment creating
solutions for the next generation? If so then you may be a Racker and
you just don’t know it yet!

Stuff you’ll need to be a star:

Good enterprise web application development experience
Sufficient object oriented programming experience
Strong Python development experience or other dynamic language web
development such as PHP or Javascript
Enough Quality Assurance experience
Know your way around a database – extra cool if you know SQL
Driven to be part of the team creating the next great software
solution
Rackspace Managed Hosting is an Equal Opportunity Employer

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

RE: Catching and automating a win32 MessageBox

2007-11-08 Thread Ryan Ginstrom
> On Behalf Of Xavier Homs
> Is there any way to hook such a MessageBox a send a default 
> action (yes) from a Python Script?

A pure Python solution is pywinauto:
http://www.openqa.org/pywinauto/

Another solution is AutoIt
http://www.autoitscript.com/autoit3/
It has a COM server, which you can automate from Python.

Regards,
Ryan Ginstrom

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


Version 0.6.0 of CodeInvestigator

2007-11-08 Thread Hans Moleman
CodeInvestigator version 0.6.0 was released on November 8.



This version adds support for input() and raw_input() functions.



The main changes:



  * The 'Details' button on the file selection screen gives access 

to statistics, stdin and stdout for the running program. 

Control Z and control D keys in stdin are honored.

  * Keyword values are now recorded just like variable values.

  * Bug fixes. An expression that evaluates to a function call was 

not handled correctly.





CodeInvestigator is a tracing tool for Python programs.



Running a program trough CodeInvestigator creates a recording. Program 
flow, function calls, variable values and conditions are all stored for 
every line the program executes. 



The recording is then viewed with an interface consisting of the code. 
The code can be clicked: A clicked variable displays its value, a clicked 
loop displays its iterations.



You read code, and have at your disposal all the run time details of that 
code.

A computerized desk check tool and another way to learn about your 
program.



http://sourceforge.net/project/showfiles.php?group_id=183942

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Steven D'Aprano
On Thu, 08 Nov 2007 15:00:03 -0500, Frank Samuelson wrote:

> 1. Currently in Python
> def  foo(x,y): ...
> assigns the name foo to a function object.  Is this pythonic?
> 
> Why not use the = operator like most other assignments? 

Why? What benefit do you gain?

> Define function objects as "function"s, let users put them where they 
> want to.  Get rid of lambda, get rid of def, only use = for assignments.

So you remove two keywords. That's a plus. But then you have to create a 
WHOLE lot more syntax to support it, and that's about a thousand minuses. 
Python has very little syntax, and the designers are (rightly) very 
resistant to adding more.


> foo = function(x,y) x+y*2   # Example S language code 

This would currently be a syntax error, hence the need for new syntax.

Also, function() couldn't be a normal type, or even a built-in function, 
because it has to have special syntax:

name = function(*argument_list) expression

It's also not clear how you expect this to work with anything more 
complex than a single expression. How do you handle statements and 
multiple returns?

def foo(x, y):
L = []
try:
if x[y] % 2:
print x, y
return y
return x[y]
except:
return None





> bar = foo

But you can still do this with Python:

def foo(x, y):
return x+y*2
bar = foo





> 2. Allow sequences to be indices:
>  >>> s=["hello", 6, 33, "none"]
>  >>> x= [1,3]
>  >>> [ s[y] for y in x] # Current verbose version
> [6, 'none']

I don't especially call it verbose.


>  >>> s[x]   # Simpler, clearer, more productive

It's certainly smaller.

But the fatal objection to this is that it is a special case for a very 
limited benefit: saving half a dozen characters. List comprehensions are 
very flexible:

[float(s[3*i % 2]) for i in x if 3 <= i < 12] # for example...

Your proposal doesn't have anywhere near that flexibility. It simply 
duplicates perhaps the most trivial list comp [s[y] for y in x], just to 
save a dozen or so characters. Python doesn't treat terseness as that big 
a virtue.

Besides, if you want this behaviour, you can add it yourself:

class mylist(list):
# Untested!
def __getitem__(self, index):
if type(index) is list:
 return [self[i] for i in index]
return super(mylist, self).__getitem__(index)

list = mylist


The only difference is you have to write:

s = list([1,2,3])

instead of s = [1,2,3].


 
> To quote a poster at http://www.thescripts.com/forum/thread22741.html,
> "While we are at it, I also don't understand why sequences can't be used
> as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special slice
> concept? "  Isn't that unpythonic?


But can't you see that the suggestion to use sequences as replacements 
for slices is completely incompatible with your suggestion above?

seq = range(10)

Would you expect seq[[2,6]] to do an index lookup, as you suggested 
originally, or a slice? In the first case, it would return [2, 6], but in 
the second, it would return [2, 3, 4, 5].

If sequence indices are slices, what does an index of [1, 2, 3, 4] mean?



> 3. When I first
> started using python, I frequently used map, because I didn't want to
> have to learn the additional syntax of list comprehensions, which
> appeared very nonstructured.

It is a slightly more verbose form of standard mathematical set notation.

In case it comes out wrong, the symbol ϵ is supposed to be the symbol for 
"element".

"the set of 3x+1 such that x is in (1, 2, 3) if x is odd"

{ 3x+1 : x ϵ (1, 2, 3) if x%2 }

becomes the list comprehension:

[ 3*x+1 for x in (1, 2, 3) if x%2 ]


> # Is this readable?
> b= [x+y for x in vec1 if x>0 for y in vec2 if y>x ]

It is probably pushing the boundaries of how readable a list comp can get 
before it should be refactored, but it hasn't crossed over into 
unreadability.

 
> Perhaps a list comprehension syntax more like the rest of python.

I think the great majority Python folks find the list comprehension 
syntax to be one of the MOST Pythonic features, not the least.



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

RE: Using python as primary language

2007-11-08 Thread Michael Bacarella
> > > > A multithreaded application in Python will only use a single CPU
> on
> > > > multi-CPU machines due to big interpreter lock, whereas the
> "right
> > > thing"
> > > > happens in Java.
> > >
> > > Note that this is untrue for many common uses of threading (e.g.
> using
> > > threads to wait on network connections, or calling out to most
> common
> > > compute-intensive C extensions), where the GIL is released and
> > > multiple CPUs are used just fine.
> >
> > It's true in exactly the case where you would gain the most benefit
> > from multiple CPUs.  So I'm not sure how uncommon that is.
> 
> It's pretty uncommon. There are relatively few CPU bound tasks that
> are a) highly parallel and b) can't be easily scaled between
> processes. Python is not (by itself) an especially good tool for those
> tasks.

Is there any reason for this besides economics?

I only assumed this because Perl threads can tax multiple CPUs. 

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


[OT] Stupid email disclaimers (was: Creating a cell 'by hand')

2007-11-08 Thread Ben Finney
"Prepscius, Colin (IT)" <[EMAIL PROTECTED]> writes:

> NOTICE: If received in error,

If I've received it, it's not "received in error", it's received
successfully.

If, instead, you're referring to the actual recipient being different
from the intended recipient, why are you putting this judgement onto
the actual recipient? Surely they're in no position to judge the
intentions of the sender.

> please destroy and notify sender.

(Insert humour regarding different parsings of the grammar in the
above.)

In that order? If I'm supposed to notify the sender, I have to
re-transmit the message or at least part of it. That seems quite the
opposite of destroying it.

> Sender does not intend to waive confidentiality or privilege.

Then perhaps sender should not be posting to a public forum. There is
*no* confidentiality or privilege in postings to this forum, so this
disclaimer is null and void.

> Use of this email is prohibited when received in error.

There's no way for a recipient to know whether they're in such a
"prohibited" zone. Don't make such threatening statements to an entire
community, please.


In general:

Please, don't attach these disclaimers and threats to messages —
*especially* on a public forum. If you're choosing to apply them to
your messages, please stop.

If, on the other hand, your organisation is applying them
indiscriminately to every outgoing message, even in cases where
there's no such thing as "confidentiality" or "privilege", then
they're mindlessly undermining the meaning of those terms. Please get
your organisation to *only* apply these threats and disclaimers where
they have meaning.

http://www.goldmark.org/jeff/stupid-disclaimers/>

-- 
 \   "Earth gets its price for what Earth gives us."  -- James |
  `\Russell Lowell |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

recording sound with python

2007-11-08 Thread jesse j
Hello Everyone,

I'm new to python.  I have worked through some tutorials and played around
with the language a little bit but I'm stuck.

I want to know how I can make python run a program.  More specifically, I
want to get python to work with SOX to record a sound through the
microphone, save the sound and then play the sound by typing one command
into a linux terminal (UBUNTU).

Can someone give me some hints on how this can be done?

Thank You.

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

Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-08 Thread Scott David Daniels
Wayne Brehaut wrote:
...
> For learning DSA it's more important to have a clear, well-written and
> well-documented implementation in a language of interest (again,
> especially, the core language in one's programs) than just "using" or
> even inspecting and trying to learn subtle details of some particular
> implementation of a related DS or A in some "other" language.
> 
> How many of those who devleoped and improved  the very efficient data
> structures in Python learned and honed their skills in Python (vs. C
> or Pascal, for example)?

True, but these days I build my data structures first in Python to
measure their effectiveness, and (sometimes) cast them into C concrete
once I know the winner.

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


Re: easy 3D graphics for rendering geometry?

2007-11-08 Thread Scott David Daniels
gsal wrote:
> What would be the easiest way to go about offering 3D graphics for the
> purpose of rendering geometry?

Take a look at VPython.  If you are pretty bright, give up a weekend
and do all you can in that one weekend.  I think you will be amazed.
You will one day get to a point where it is not good enough for you,
but nowhere will you find so shallow a ramp to getting to competent,
relatively fully-featured, 3-D visualizations in simple, direct code.

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


Re: Some "pythonic" suggestions for Python

2007-11-08 Thread Scott David Daniels
Frank Samuelson wrote:
> I love Python, and it is one of my 2 favorite
> languages.  I would suggest that Python steal some
> aspects of the S language.

I generally agree with the various naye-sayers, but find one
argument missing:

> ---
> 2. Allow sequences to be indices:
>  >>> s=["hello", 6, 33, "none"]
>  >>> x= [1,3]
>  >>> [ s[y] for y in x] # Current verbose version
> [6, 'none']
>  >>> s[x]   # Simpler, clearer, more productive
> 
> To quote a poster at http://www.thescripts.com/forum/thread22741.html,
> "While we are at it, I also don't understand why sequences can't be
> used as indices. Why not, say, l[[2,3]] or l[(2, 3)]? Why a special
> slice concept? "  Isn't that unpythonic?

Right now, after:

 which_corner = {}
 corner = {}
 for n, position in enumerate([(1,1), (1,5), (3,5), (3,1)]):
 corner[n] = position
 which_corner[position] = n

 which_corner[1,5] returns 1

I would hate to have to know whether which_corner is a dictionary
or a list before I can decide whether this is iteration.

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


Re: Is pyparsing really a recursive descent parser?

2007-11-08 Thread Kay Schluehr
On Nov 9, 12:28 am, "[david]" <[EMAIL PROTECTED]> wrote:
> Kay Schluehr wrote:
>
> > Could you please learn some parser theory 101 and then come back when
> > you have complaints about one or the other implemententation of a
> > particular Python parser? When some guy enters a forum with a "newbie
> > question" most of the time people are willing to give a fair and
> > comprehensive answer but they don't want to mess around with him
> > endlessly when he is not willing to learn and to listen.
>
> Immaturity is a mark of this group, isn't it?  When all else fails,
> resort to insults.

Dear [david], when all else fails, be rigorous. Tell someone that it
is not o.k. to keep people busy with his complaints when he doesn't
know what he is talking about. This is *my* rejection of inpoliteness
and has nothing to do with "this group" in the first place. But I'm
not entirely sure I want to discuss about polite behaviour with
someone not using his full name.

Kay

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


Re: Using python as primary language

2007-11-08 Thread Terry Reedy

"Michael Bacarella" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| > It's pretty uncommon. There are relatively few CPU bound tasks that
| > are a) highly parallel and b) can't be easily scaled between
| > processes. Python is not (by itself) an especially good tool for those
| > tasks.
|
| Is there any reason for this besides economics?

If by 'this' you mean the global interpreter lock, yes, there are good 
technical reasons.  All attempts so far to remove it have resulted in an 
interpeter that is substantially slower on a single processor. 



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


Expanding the size of wx Frame

2007-11-08 Thread sundarvenkata
hello all, is there a way to make wxpython frame to expand itself
   as we add controls to it

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


Re: pyserial: loose connection after inactivity

2007-11-08 Thread Hendrik van Rooyen
"Frank Aune"  wrote:

> Hello,
>
> I configure the serial connection using:
>
> self.port = serial.Serial(baudrate=57600,
>  timeout=0.06,
>  parity=serial.PARITY_EVEN,
>  stopbits=serial.STOPBITS_TWO,
>  bytesize = serial.EIGHTBITS)
>
> After X hours of inactivity I loose connection to my serial device, with error
> message "Input/Output error" printed to stdout. The error happens both on
> Linux and Windows (although the error message is probably different on
> Windows, I've only been told the behaviour is the same).
>
> I cannot find an obvious reason for why this is happening, and since it
> happens after a long time of inactivite, debugging is awkward. So I though
> I'd run the question through the expert panel for ideas, before venturing
> down the path of pain and suffering myself :)

I have heard rumours that on windoze, the serial drivers for USB attached
serial ports are not stable.
Never seen it myself, though.
And if its good old COM1 its not applicable.
Have not heard similar rumours about Linux.

Cold comfort, I know.

- Hendrik

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


operator overloading on built-ins

2007-11-08 Thread r . grimm
Hallo,
could you explaint me the difference between the two following
statements.


Python 2.5 (r25:51908, Oct  7 2006, 23:45:05)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (1).__cmp__(10)
-1
>>> 1.__cmp__(10)
  File "", line 1
1.__cmp__(10)
^
SyntaxError: invalid syntax

The first works as expect, but the second.

Regards Rainer

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


Re: operator overloading on built-ins

2007-11-08 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
 (1).__cmp__(10)
> -1

Integer object "(1)" followed by method call ".__cmp__(10)"

 1.__cmp__(10)
>   File "", line 1
> 1.__cmp__(10)
> ^
> SyntaxError: invalid syntax

Floating point number "1." followed by "__cmp__(10)".

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


Re: operator overloading on built-ins

2007-11-08 Thread Marc 'BlackJack' Rintsch
On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote:

 (1).__cmp__(10)
> -1

As the dot is an operator like ``+`` or ``/`` you can also add spaces to
avoid the ambiguity:

In [493]: 1 . __cmp__(10)
Out[493]: -1

In [494]: 1 .__cmp__(10)
Out[494]: -1

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