ANN: pyftpdlib 0.5.2 released

2009-09-14 Thread Giampaolo Rodola'
Hi,
I'm pleased to announce release 0.5.2 of Python FTP Server library
(pyftpdlib).
http://code.google.com/p/pyftpdlib

=== About ===

Python FTP server library provides a high-level portable interface to
easily write asynchronous FTP servers with Python.
pyftpdlib is currently the most complete RFC-959 FTP server
implementation available for Python programming language.
It is used in projects like Google Chromium and Bazaar and included in
Linux Fedora and FreeBSD package repositories.


=== Changes ===

This new version is mainly a bugfix release, including some important
security-related patches.
Aside from fixing those bugs, it includes the following enhancements:

* A new ThrottledDTPHandler class is available. With this you can
limit the speed for downloads and uploads affecting the data channel.
Take a look at the throttled_ftpd.py script which shows an example
usage:
http://code.google.com/p/pyftpdlib/source/browse/trunk/demo/throttled_ftpd.py

* A new unix_daemon.py script has been included in the demo directory
(contributed by Michele Petrazzo).

A complete list of changes including enhancements and bug fixes is
available here:
http://code.google.com/p/pyftpdlib/wiki/ReleaseNotes05


=== More links ===

* Source tarball: http://pyftpdlib.googlecode.com/files/pyftpdlib-0.5.2.tar.gz
* Online docs: http://code.google.com/p/pyftpdlib/wiki/Tutorial
* FAQs: http://code.google.com/p/pyftpdlib/wiki/FAQ
* RFCs compliance paper: http://code.google.com/p/pyftpdlib/wiki/RFCsCompliance
* Issue tracker: http://code.google.com/p/pyftpdlib/issues/list
* Mailing list: http://groups.google.com/group/pyftpdlib


Thanks,

--- Giampaolo Rodola'  g.rodola [at] gmail [dot] com 
http://code.google.com/p/pyftpdlib/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Accessing objects at runtime.

2009-09-14 Thread jacopo

    You might consider running a BaseHTTPServer in a separate thread
 which has references to your objects of interest and exporting the
 data through a web interface. Using a RESTful approach for mapping
 URLs to objects within your system, a basic export of the data can
 be as simple as printing out HTML strings with interpolated data.


Thank you Gary,

just to be sure I understood correctly:
with this solution, in order to inspect an object I would have to load
a web page at a specific URL. That URL,
through a separate thread, would access the object on the fly and
display the content in a web page?!
Is there a reason to link objects to different URLs or I could link
many of them to the same URL?

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


Re: Accessing objects at runtime.

2009-09-14 Thread Chris Colbert
why not just pawn your processing loop off onto a child thread and
give yourself a hook (function) that you can call that return whatver
info you what. Run the script in ipython, problem solved.


On Mon, Sep 14, 2009 at 7:57 AM, jacopo jacopo.pe...@gmail.com wrote:

    You might consider running a BaseHTTPServer in a separate thread
 which has references to your objects of interest and exporting the
 data through a web interface. Using a RESTful approach for mapping
 URLs to objects within your system, a basic export of the data can
 be as simple as printing out HTML strings with interpolated data.


 Thank you Gary,

 just to be sure I understood correctly:
 with this solution, in order to inspect an object I would have to load
 a web page at a specific URL. That URL,
 through a separate thread, would access the object on the fly and
 display the content in a web page?!
 Is there a reason to link objects to different URLs or I could link
 many of them to the same URL?

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

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


Re: yet another modifying locals() question

2009-09-14 Thread Ed Anuff
On Sep 13, 8:15 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
 Metaclasses are left as an exercise for the reader.

The parent class has a metaclass, which is why I was trying this
approach instead, since it let me get at the class attributes before
the metaclass did.  Overriding the metaclass looked to be a much more
messy proposition, but I think I've got that working now.  Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why use locals()

2009-09-14 Thread Chris Colbert
Given that python is devoid of types: Is the variable 'a' an int or a
float at runtime?, explicit can only be taken so far.

Personally, I use locals() when I work with Django.


On Mon, Sep 14, 2009 at 7:42 AM, Sean DiZazzo half.ital...@gmail.com wrote:
 If you are willing to open your mind to the possibility that some
 Pythonic things don't adhere to every Zen, then I would suggest that
 Gabrielle's examples are perfectly Pythonic shortcuts.  But if you
 don't want to use them, you don't have to, nobody is forcing you.

 It's a pretty small domain, but I see the use (and the Pythonicity).

 Thanks all for your advice.

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

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


Re: list as an instance attribute

2009-09-14 Thread Daniel Santos
Here goes,

I have a base class that is the following :

class primitive:


def __init__(self):
self.name = 
self.transforms = []

def copyInternalState(self, sourceObj, copyName):
return null

def copy(self, copyName):

# copy the source object internal state
primitiveCopy = self.copyInternalState(self, copyName)

# copy the transformations
primitiveCopy.transforms = []

if self.transforms != []:
for transf in self.transforms:
primitiveCopy.transforms.append(transf.copy())

return primitiveCopy

# more methods. the ones listed should be enough to get the picture

And a derived class,

class CircularCilinder(primitive):


def __init__(self, name):

self.name = name
self.baseCenterVertex = [0, 0, 0]
self.heightVertex = [0, 1, 0]
self.radius = 1

def copyInternalState(self, sourceObj, copyName):

copy = CircularCilinder(copyName)

copy.setHeight(self.heightVertex[1])
copy.setRadius(self.radius)

return copy


I then have a script that creates a CircularCilinder,

cilinder = CircularCilinder(cilinder)
cilinderCopy = cilinder.copy(cilinderCopy)


when I run this script I get the error,

Traceback (most recent call last):
  File ./testscript.py, line 26, in module
cilinderCopy = cilinder.copy(cilinderCopy)
  File /cygdrive/d/cg/brlcad_api/trunk/src/ds_brlcad_modeler/api/primitive.py,
 line 64, in copy
if self.transforms != []:
AttributeError: CircularCilinder instance has no attribute 'transforms'


the transforms instance attribute is not known in the derived class. But I
wanted to avoid adding a self.transforms = [] line to the derived class
__init__ method. That attribute is only to be known by the superclass.

Is there a way to do this ?


On Sat, 12 Sep 2009 20:28:12 -0700, Chris Rebert wrote:

 Cheers,
 Chris
 --
 http://blog.rebertia.com
 
 
 
 On Sat, Sep 12, 2009 at 8:22 PM, André andre.robe...@gmail.com wrote:
 On Sep 12, 11:48 pm, Daniel Luis dos Santos daniel.d...@gmail.com
 wrote:
 Hello,

 I have an object definition :

 class primitive:

         def __init__(self)
                 self.name = 
                 self.transforms = []

         def copy(self, copyName)

                 copy = self.copyInternalState(copyName)  # method defined 
 elsewhere
 in derived class

                 if self.transforms != []
                         for transf in self.transforms
                                 copy.transforms.append(transf.copy())

 In short, what I want to is to have the transforms list as an instance
 attribute of the class. I will add objects to it. When I call the copy
 method on the object the list is to be copied to the new object.

 Problem is that the python interpreter is complaining that it doesn't
 know any self.transforms in the if statement.

 Help

 1. Always post the actual code - the code you posted is not valid
 Python as many colons (:) are missing.
 2. You appear to be attempting to use the same name (copy) both as a
 method name AND as a local variable of that method.  This definitely
 look wrong.

 Perhaps if you could post the actual offending code (the smallest
 example showing the problem you observe) others might be able to help
 you.
 
 The full, exact error message and exception traceback would also be helpful.
 
 Cheers,
 Chris

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


VT100 in Python

2009-09-14 Thread Nadav Chernin
Hi, everybody

 

I'm writing program that read data from some instrument trough RS232.
This instrument send data in VT100 format. I need only to extract the
text without all other characters that describe how to represent data on
the screen. Is there some library in python for converting VT100
strings?

 

Thanks, Nadav

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


Re: list as an instance attribute

2009-09-14 Thread r
On Sep 13, 7:34 pm, Daniel Santos daniel.d...@gmail.com wrote:
 Here goes,

 I have a base class that is the following :

 class primitive:

         def __init__(self):
                 self.name = 
                 self.transforms = []

         def copyInternalState(self, sourceObj, copyName):
                 return null

         def copy(self, copyName):

                 # copy the source object internal state
                 primitiveCopy = self.copyInternalState(self, copyName)

                 # copy the transformations
                 primitiveCopy.transforms = []

                 if self.transforms != []:
                         for transf in self.transforms:
                                 primitiveCopy.transforms.append(transf.copy())

                 return primitiveCopy

         # more methods. the ones listed should be enough to get the picture

 And a derived class,

 class CircularCilinder(primitive):

         def __init__(self, name):

                 self.name = name
                 self.baseCenterVertex = [0, 0, 0]
                 self.heightVertex = [0, 1, 0]
                 self.radius = 1

         def copyInternalState(self, sourceObj, copyName):

                 copy = CircularCilinder(copyName)

                 copy.setHeight(self.heightVertex[1])
                 copy.setRadius(self.radius)

                 return copy



You never initialized Primitive in CCylinder! And always write class
names with an initial uppercase letter...
class Primitive():
   def...

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


Re: VT100 in Python

2009-09-14 Thread Wolfgang Rohdewald
On Sunday 13 September 2009, Nadav Chernin wrote:
 I'm writing program that read data from some instrument trough
  RS232. This instrument send data in VT100 format. I need only to
  extract the text without all other characters that describe how to
  represent data on the screen. Is there some library in python for
  converting VT100 strings?
 

that should be easy using regular expressions

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


Re: Why indentation is use to denote block of code?

2009-09-14 Thread Miles Kaufmann

On Sep 13, 2009, at 5:38 PM, AggieDan04 wrote:

On Sep 13, 6:27 pm, Steven D'Aprano wrote:

On Sun, 13 Sep 2009 15:15:40 -0700, Chris Rebert wrote:
In fact it's pretty much impossible to automatically indent Python  
code
that has had its indentation removed; it's impossible to know for  
sure

where the dedents should occur.


Just like most other syntactic elements -- if you remove all the  
return

statements from Python code, or dot operators, it's impossible to
automatically add them back in.

The only difference is that some (badly written?) applications mangle
leading whitespace, but very few feel free to remove other text on  
a whim.


I don't recall actually using a mail client or newsreader that  
removes
leading whitespace when posting, but I've occasionally seen posts  
from

others with all indentation removed, so presumably such badly-behaved
applications do exist.


I haven't seen it in a mail client, but it's very common in internet
forums.


If you regularly deal with some sort of transport that messes with  
your leading whitespace, you may find Tools/scripts/pindent.py in the  
Python source distribution useful; it adds comments that act as block  
closers to your code, and can then use those comments to restore the  
correct indentation to a mangled version.  (Most forums offer some  
sort of whitespace-preserving [code] tag, though; and pindent is  
relatively old, and apparently not well maintained (no support for  
with blocks)).


-Miles

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


Re: NameError: name '__main__' is not defined

2009-09-14 Thread Hendrik van Rooyen
On Monday 14 September 2009 03:43:19 Peng Yu wrote:
 Hi,

 I try the following code. I don't quite understand why __main__ is not
 defined. Could somebody let me know what I am wrong about it?

 Regards,
 Peng

 $ cat test.py
 #!/usr/bin/env python

 if __main__ == '__main__' :
   print Hello World!\n
 $ ./test.py
 Traceback (most recent call last):
   File ./test.py, line 3, in module
 if __main__ == '__main__' :
 NameError: name '__main__' is not defined

You are looking for __name__ , not __main__

if __name__ == '__main__':
We are at the top of the tree so run something
print Goodbye Cruel World

- Hendrik

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


Re: NameError: name '__main__' is not defined

2009-09-14 Thread Andre Engels
On Mon, Sep 14, 2009 at 4:29 AM, Sean DiZazzo half.ital...@gmail.com wrote:

 Is this a production program that you are using??

 Please show us the point you are trying to make in something more
 valuable.

I find this a very bad comment. Not only is it rude, it is condemning
a behaviour I would see as beneficial. I very much prefer someone
creating a toy program that is as short and simple as possible while
still showing their problem than being forced through hundreds of
lines of code which contain very useful code which however has nothing
to do with the problem at hand.


-- 
André Engels, andreeng...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Calling all C++ programmers for collaboration

2009-09-14 Thread r
Hello all,

Are you a C++ programmer who is currently learning Python? If so,
maybe you can help me, and i can help you. It does not matter how much
or how little experience you have! All help is greatly welcomed!

I am currently working on a project from an opensource app that is
written in C++ and Python. I feel quite comfortable with Python but
for the most part i am lost at C ;). All i need is to make a
few *very* small modifications to the C++ code so i can continue on
building this app. Anyone who is willing to give me pointers ;) or
help would be most welcome! In return i would be more than happy to
help you with learning the Python language.

Thanks

PS: you may want to reply off list.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python environment

2009-09-14 Thread Gabriel Genellina
En Sun, 13 Sep 2009 08:32:33 -0300, Ecir Hana ecir.h...@gmail.com  
escribió:



I have an app which I would like to extend with Python. I I saw how to
embed the interpreter into C. If I bundle my app with the Python lib
(say, python26.dll) I can PyRun_SimpleString() some code. My question
is, how do I bundle the rest of the libraries (site, os, elementtree,
random, ...)? Is it possible to make one huge (ok, not so huge) .zip
blob containing all of the libraries?


Yes. That's what py2exe, cx_freeze and others do.
If you put a .zip file name in sys.path, it is searched as it were a  
directory.



And what happens if some user
has Python already installed? Which libraries get loaded first? Is it
possible to alter this order? I mean, first check for local Python
install and if the user doesn't have Python installation use the
bundled one?


Nothing special. Python looks for modules along its search path  
(sys.path); whatever is found first, wins.


--
Gabriel Genellina

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


Re: including constants

2009-09-14 Thread Nick Craig-Wood
Nikola Skoric nick-n...@net4u.hr wrote:
  I have a simple problem and I know how to solve it :-D, but I suspect that
  there is a standard solution which is more elegant.
 
  So, here is my problem: I have django app versioned with svn and I
  test my trunk on two different machines (one with mysql, another with
  sqlite3). How do I remove database-definition constants from my
  settings.py and put them in a separate file which wouldn't be
  maintained by svn? (did I really hear somebody call that kind of file
  unversioned file or did I make that up?) I suppose I could make a
  trivial module with database info, import it and then assign my
  constants with data from that module, but that looks so unelegant to
  me. What's the standard way of doing this?

Well settings.py is a normal python program so you can put any
mechanisms you can think of in there.

For example (from simple to complex)

Make settings.py a symlink to the correct one for the machine.

Make a subsettings.py which is a symlink to the correct one for the
machine.

Pass in some of the settings in the environment and read them with
os.environ.

Look up the hostname of the machine and import a secondary file of
settings with that name.  This has the advantage that you can check
everything in.

-- 
Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list as an instance attribute

2009-09-14 Thread Bruno Desthuilliers

Daniel Santos a écrit :

Here goes,

I have a base class that is the following :

class primitive:


pep08 : class names should be Capitalized.

Also, if you're using Python 2.x, make it:

class Primitive(object):
   #...




def __init__(self):
self.name = 
self.transforms = []

def copyInternalState(self, sourceObj, copyName):


pep08 : methods, attributes and variables names should be all_lower


return null


s/null/None/g




def copy(self, copyName):

# copy the source object internal state
primitiveCopy = self.copyInternalState(self, copyName)

# copy the transformations
primitiveCopy.transforms = []


If copyInternalState is supposed to return an instance of a 
(well-behaved) subclass of 'primitive' - or any object conforming to the 
(implicit) 'primitive' interface, you shouldn't have to do this.



if self.transforms != []:


An empty list has a false value in a boolean test, so the above test 
would be better written as :


if self.transforms:

But anyway, the whole test is plain useless:

for item in []:
   print you won't see me



for transf in self.transforms:
primitiveCopy.transforms.append(transf.copy())

return primitiveCopy

# more methods. the ones listed should be enough to get the picture

And a derived class,

class CircularCilinder(primitive):


def __init__(self, name):

self.name = name
self.baseCenterVertex = [0, 0, 0]
self.heightVertex = [0, 1, 0]
self.radius = 1


You're not calling the __init__ method of primitive. Your code here 
should be:


def __init__(self, name):
super(CircularCilinder, self).__init__(name)
self.baseCenterVertex = [0, 0, 0]
self.heightVertex = [0, 1, 0]
self.radius = 1




def copyInternalState(self, sourceObj, copyName):

copy = CircularCilinder(copyName)

copy.setHeight(self.heightVertex[1])
copy.setRadius(self.radius)


Python is not Java. We have good support for computed properties, so you 
*don't* need explicit getters/setters - just start with a plain 
attribute access, you can always turn it into a computed one latter if 
and when the need arises.




return copy


I then have a script that creates a CircularCilinder,

cilinder = CircularCilinder(cilinder)
cilinderCopy = cilinder.copy(cilinderCopy)


when I run this script I get the error,

Traceback (most recent call last):
  File ./testscript.py, line 26, in module
cilinderCopy = cilinder.copy(cilinderCopy)
  File /cygdrive/d/cg/brlcad_api/trunk/src/ds_brlcad_modeler/api/primitive.py,
 line 64, in copy
if self.transforms != []:
AttributeError: CircularCilinder instance has no attribute 'transforms'


Indeed - you didn't call the superclass's __init__



the transforms instance attribute is not known in the derived class. But I
wanted to avoid adding a self.transforms = [] line to the derived class
__init__ method.


Should be the same wrt/ the 'name' attribute FWIW.

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


Re: numpy NaN, not surviving pickle/unpickle?

2009-09-14 Thread Gabriel Genellina
En Sun, 13 Sep 2009 20:53:26 -0300, Steven D'Aprano  
st...@remove-this-cybersource.com.au escribió:



There may be something to be said for caching common floats, like pi,
small integers (0.0, 1.0, 2.0, ...), 0.5, 0.25 and similar, but I doubt
the memory savings would be worth the extra complexity.


I've read some time ago, that simply caching 0.0 reduced appreciably the  
memory usage of a Zope application.
(Note that Zope relies on pickling and unpickling objects all the time, so  
even if two objects started as the same zero, they may become different  
at a later time.)


--
Gabriel Genellina

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


Re: Accessing objects at runtime.

2009-09-14 Thread jacopo
On Sep 14, 9:54 am, Chris Colbert sccolb...@gmail.com wrote:
 why not just pawn your processing loop off onto a child thread and
 give yourself a hook (function) that you can call that return whatver
 info you what. Run the script in ipython, problem solved.


thank you Chris, I have just implemented this in a mock example it
seems to work.  Clean and simple!

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


Re: list as an instance attribute

2009-09-14 Thread Robin Becker

Bruno Desthuilliers wrote:

Daniel Santos a écrit :

Here goes,

I have a base class that is the following :

class primitive:


pep08 : class names should be Capitalized.

Also, if you're using Python 2.x, make it:

class Primitive(object):
   #...


...

I find it remarkable that the most primitive classes appear to break the pep08 
convention eg object, str, list etc etc. In fact all such conventions appear to 
be broken more often than not. So the rule appears to be create a convention 
and then break it :)


Python is often put forward as a as a finger friendly language, but we have 
capitals encouraged for user class names and for some common values eg None, 
True, False these are required.

--
Robin Becker

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


Re: An assessment of the Unicode standard

2009-09-14 Thread Christopher Culver
Hyuga hyugaricd...@gmail.com writes:
 I just wanted to add, in defense of the Chinese written language
 ... that I think it would make a fairly good candidate for use at
 least as a universal *written* language.  Particularly simplified
 Chinese since, well, it's simpler.

 The advantages are that the grammar is relatively simple, and it can
 be used to illustrate concepts independently of the writer's spoken
 language.

Musings about the universality of the Chinese writing system, once so
common among Western thinkers, nevertheless do not square with
reality. The Chinese writing system is in fact deeply linked to the
Chinese language, even to the specific dialect being spoken. See
Defrancis' _The Chinese Language: Fact and Fantasy_ (Honolulu:
University of Hawaii Press, 1984):

http://preview.tinyurl.com/rbyuuk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: VT100 in Python

2009-09-14 Thread Nick Craig-Wood
Wolfgang Rohdewald wolfg...@rohdewald.de wrote:
  On Sunday 13 September 2009, Nadav Chernin wrote:
  I'm writing program that read data from some instrument trough
   RS232. This instrument send data in VT100 format. I need only to
   extract the text without all other characters that describe how to
   represent data on the screen. Is there some library in python for
   converting VT100 strings?
 
  that should be easy using regular expressions

At a basic level parsing VT100 is quite easy, so you can get rid of
the VT100 control.  They start with ESC, have other characters in the
middle then end with a letter (upper or lowercase), so a regexp will
make short work of them.  Something like r\x1B[^A-Za-z]*[A-Za-z]

You might need to parse the VT100 stream as VT100 builds up a screen
buffer though and the commands don't always come out in the order you
might expect.

I think twisted has VT100 emulator, but I couldn't find it in a brief
search just now.

You'll find various others (like this one) if you search some more

http://svn.python.org/projects/python/branches/string_methods/Demo/cwilib/vt100.py

-- 
Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list as an instance attribute

2009-09-14 Thread Miles Kaufmann

On Sep 14, 2009, at 1:55 AM, Robin Becker wrote:

Bruno Desthuilliers wrote:

pep08 : class names should be Capitalized.
Also, if you're using Python 2.x, make it:
class Primitive(object):
  #...

...

I find it remarkable that the most primitive classes appear to break  
the pep08 convention eg object, str, list etc etc. In fact all such  
conventions appear to be broken more often than not. So the rule  
appears to be create a convention and then break it :)


More like break a convention and then create it. :)  Before Python  
2.2, built-in types were not classes at all; they couldn't be  
instantiated directly (from Python code), so you had to call the str()  
function to create an object of type string.  I think there may have  
been some discussion of renaming the built-ins to match PEP 8 for  
Python 3, but if so I doubt it got very far.


-Miles

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


equation of a graph

2009-09-14 Thread ankita dutta
hii..

i am working with graphs,
my problem is to find the equation for any given graph.

i tried with  *polyfit function*.
but that only give me the slope and y-axis intercept. hence *best-fit
line *   ,
but i want to find *best-fit curve *

how can i find that ?



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


Re: An assessment of the Unicode standard

2009-09-14 Thread Robin Becker

r wrote:
...


What makes you think that diversity is lost with a single language? I
say more pollination will occur and the seed will be more potent since
all parties will contribute to the same pool. Sure there will be
idioms of different regions but that is to be expected. But at least
then i could make international crank calls without the language
barrier ;-)


well allegedly, the medium is the message so we also need to take account of 
language in addition to the meaning of communications. I don't believe all 
languages are equivalent in the meanings that they can encode or convey. Our 
mathematics is heavily biassed towards continuous differential systems and as a 
result we end up with many physical theories that have smooth equilibrium 
descriptions, we may literally be unable to get at other theories of the 
physical world because our languages fall short.

--
Robin Becker

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


Re: Programming ideas?

2009-09-14 Thread Vimal
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 09/12/2009 07:43 PM, Someone Something wrote:
 I know you've probably had this question a million and one times but here it
 is again. I'm intermediate at C, pretty good at Java (though I really don't
 want to program in this), okay at perl and I've just learned python. But, I
 have no more ideas to write programs/scripts for! Any ideas will be helpful?
 
 

Hi,

You can try out 'http://www.codechef.com/' and Google Code jam if you
are interested in solving problems and algorithms. The good thing is
that code-chef have good prizes for the winners every month.

Thanks
- -- 


Vimal Kumar A R



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkquJvUACgkQNAxkGPLbEen5YwCcDcStRgw0BiW1w9E4P9Vw7Wgo
LpEAniRxcAJl5TheSEj7QO1dCCn7cleO
=un49
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: equation of a graph

2009-09-14 Thread Tim Chase

but i want to find *best-fit curve *


What type of curve?  Polynomial (of which your rejected linear is 
a low-order variant)?  Exponential or logarithmic?  Bell curve? 
S-curve?  Circle?  Axis-aligned ellipse? non-axis-aligned 
ellipse?  There are lots of curvy possibilities here...


-tkc
(Blast...if this post showed up a couple days later, I could 
abuse Talk Like A Pirate day to say things like avast, ye 
s-curvy sea-dog or intone a pirate's parrot with Piecewise of 
eight, Piecewise of eight and Polynomial want a cracker)







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


Re: Problem with the inclusion of new files like lxml, django, numpy, etc.

2009-09-14 Thread Paul Boddie
On 14 Sep, 04:46, alex23 wuwe...@gmail.com wrote:
 joy99 subhakolkata1...@gmail.com wrote:
  What is the problem I am doing?

 Following the wrong installation instructions?

The wrong instructions appear to come from this page:

http://docs.djangoproject.com/en/dev/topics/install/

Those instructions are really for Django core developers. Anyone not
actually working on Django itself should be looking here instead:

 http://docs.djangoproject.com/en/dev/topics/install/#installing-offic...

 Unpacking a module somewhere _other_ than site-packages and running
 setup.py is a fairly common installation pattern with python.

Agreed. I don't understand why the download file would be a winrar
file, but I guess this is just Windows getting confused about the file
type.

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


Re: Python server locks up

2009-09-14 Thread M.-A. Lemburg
Zac Burns wrote:
 I have a server running Python 2.6x64 which after running for about a
 month decides to lock up and become unresponsive to all threads for
 several minutes at a time. While it is locked up Python proceeds to
 consume large amounts of continually increasing memory.
 
 The basic function of the server is to serve a large dictionary -
 somewhat like a database. I have a couple theories as to why it locks
 up, but I'm not sure how to test them.
 
 Theories:
Python is resizing the large dictionary
Python is garbage collecting
 
 How would you suggest to figure out what is the problem?

Enable process core dumps and then kill the process.

Using a debugger you should be able to find out what caused the hang.

If you're serving a dictionary, I'd suggest using a different
approach: keep the dictionary on disk instead of in memory.

mxBeeBase will let you do that quite easily and is fast at
it as well:

http://www.egenix.com/products/python/mxBase/mxBeeBase/

It includes a tunable caching mechanism to keep the most often
requested data in memory.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Sep 14 2009)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble quitting PyQt4 App

2009-09-14 Thread MRAB

Soumen banerjee wrote:

Hi,
Im new to PyQt4 and im having fun using it. but ive run into a bit of
a problem. I cant quit the application.
The application has 2 modules. The gui module(gui.py) and then the
main program(main.py)

[snip]

so heres the problem:- when i hit the quit button, quit is set to high
(in the Gui module) and then the while loop in the speak thread
quits(printing quitting loop) and it updates the log file as its
supposed to do. then after it prints calling exit, the app freezes.
Isnt sys.exit() supposed to kill the interpreter? So, what is going
on? why does the app not quit?


sys.exit() just raises a SystemExit exception, so only the thread is
terminated.
--
http://mail.python.org/mailman/listinfo/python-list


myparentclass.__subclasses__() not working for me

2009-09-14 Thread samwyse
### I've tried this under both Python 2.5.1 and 3.1.1, and it isn't
working with either one.  Here is my program:

class Plugin(object):
This is the base object for a plug-in.
pass

def load_plugins(plugin_subdir='plugins'):
import sys, pkgutil, imp, os.path

try:
# Use this path if we're running as a module.
homedir = __path__[0]
except NameError:
# Use this path if we're running stand-alone.
homedir = sys.path[0]
plugin_path = [ os.path.join(homedir, plugin_subdir) ]

modules = {}
for loader, name, is_pkg in pkgutil.iter_modules(plugin_path):
file, pathname, desc = imp.find_module(name, plugin_path)
modules[name] = imp.load_module(name, file, pathname, desc)
for pair in modules.items():
print('name = %r\nmodule = %r\n' % pair)

if __name__ == '__main__':
print('subclasses = %r\n' %(Plugin.__subclasses__()))
load_plugins()
print('subclasses = %r\n' %(Plugin.__subclasses__()))

### And here is my plugin, in plugins/myplugin.py:

from plugin import Plugin
class MyPlugin(Plugin):
pass

### When I run the main program, I get this:

subclasses = []

name = 'myplugin'
module = module 'myplugin' from 'C:\Documents and Settings\sam_denton
\Desktop\scripting\plugins\myplugin.py'

subclasses = []

###  Obviously, myplugin is being found found and loaded, but my base
class doesn't know about it.  Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread rurpy
On Sep 14, 6:06 am, Christopher Culver
crcul...@christopherculver.com wrote:
 Robin Becker ro...@reportlab.com writes:
  well allegedly, the medium is the message so we also need to take
  account of language in addition to the meaning of communications. I
  don't believe all languages are equivalent in the meanings that they
  can encode or convey. Our mathematics is heavily biassed towards
  continuous differential systems and as a result we end up with many
  physical theories that have smooth equilibrium descriptions, we may
  literally be unable to get at other theories of the physical world
  because our languages fall short.

 This is the old Sapir-Whorf hypothesis, which fell out of favour among
 linguists half a century ago already. 1) Language does not constrain
 human thought, and 2) any two human languages are both capable of
 expressing the same things, though one may already have a convenient
 lexeme for the topic at hand while the other uses circumlocution.

Fashion changes in science as well as clothes. :-)  I wouldn't count
Sapir-Whorf out yet...
http://edge.org/3rd_culture/boroditsky09/boroditsky09_index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread Processor-Dev1l
On Aug 30, 2:19 pm, r rt8...@gmail.com wrote:
 On Aug 29, 11:05 pm, Anny Mous b1540...@tyldd.com wrote:
 (snip)

  How do we distinguish resume from résumé without accents?

 This is another quirk of some languages that befuddles me. What is
 with the ongoing language pronunciation tutorial some languages have
 turned into -- French is a good example (*puke*). Do you *really* need
 those squiggly lines and cues above letters so you won't forget how to
 pronounce a word. Pure ridiculousness!

  Even when we succeed in banning all languages that can't be written using
  A-Z, what do we do about the vast number of legacy documents? How do we
  write about obsolete English letters like Ð and Þ without Unicode?

 Who gives a fig about obsolete languages, thank god they are dead and
 let's move on!!



   Some may say well how can we possibly force countries/people to speak/
   code in a uniform manner? Well that's simple, you just stop supporting
   their cryptic languages by dumping Unicode and returning to the
   beautiful ASCII and adopting English as the universal world language.
   Why English? Well because it is so widely spoken.

  World population: 6.7 billion

  Number of native Mandarin speakers: 873 million
  Number of native Hindi speakers: 370 million
  Number of native Spanish speakers: 350 million
  Number of native English speakers: 340 million

  Total number of Mandarin speakers: 1051 million
  Total number of English speakers: 510 million

 http://www.vistawide.com/languages/top_30_languages.htm

 I was actually referring to countries where the majority of people
 *actually* know what a computer is and how to use it... If there
 culture has not caught up with western technology yet they are doomed
 to the fate of native American Indians.

  Whichever way you look at it, we should all convert to Mandarin, not
  English. Looks like we still need Unicode.

 see my last comment

 (snip entertaining assumptions)

  Yes, because language differences have utterly destroyed us so many times in
  the past!

  Have you thought about the difference between China, with one culture and
  one spoken language for thousands of years, and Europe, with dozens of
  competing cultures, competing governments, and alternate languages for just
  as long? If multiple languages are so harmful, why was it the British,
  French, Japanese, Russians, Germans, Italians, Austrians, Hungarians and
  Americans who were occupying China during the Opium Wars and the Boxer
  Rebellion, instead of the other way around?

  Strength comes from diversity, not monoculture.

 No strength comes from superior firepower. The Chinese culture stop
 evolving thousands of years ago. Who invented gun powder? Yes the
 Chinese and all they could do with it was create fireworks. Europeans
 took gun powered and started a revolution that changes the world
 forever -- for better and for worse, but that is how advancements
 work. It wasn't until western influence came along and finally nudged
 china into the 21st century. Europeans seek out technology and aren't
 dragged down by an antiquated culture which is good for innovation. If
 China with it's huge population thought like a European, they would
 rule the earth for 10,000 years.

Well, I am from one of the non-English speaking countries (Czech
Republic). We were always messed up with windows-1250 or iso-8859-2.
Unicode is really great thing for us and for our developers.
About the western technology made in China and Taiwan... do you
really think US are so modern? I can only recommend you to visit
Japan :).
I also think 26 letters are really limited and English is one of the
most limited languages ever. It has too strict syntax. Yeah, it is
easy to learn, but not so cool to hear every day.
Btw how many foreign languages do you speak?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread Robin Becker

ru...@yahoo.com wrote:

On Sep 14, 6:06 am, Christopher Culver
crcul...@christopherculver.com wrote:

Robin Becker ro...@reportlab.com writes:

well allegedly, the medium is the message so we also need to take
account of language in addition to the meaning of communications. I
don't believe all languages are equivalent in the meanings that they
can encode or convey. Our mathematics is heavily biassed towards
continuous differential systems and as a result we end up with many
physical theories that have smooth equilibrium descriptions, we may
literally be unable to get at other theories of the physical world
because our languages fall short.

This is the old Sapir-Whorf hypothesis, which fell out of favour among
linguists half a century ago already. 1) Language does not constrain
human thought, and 2) any two human languages are both capable of
expressing the same things, though one may already have a convenient
lexeme for the topic at hand while the other uses circumlocution.


Fashion changes in science as well as clothes. :-)  I wouldn't count
Sapir-Whorf out yet...
http://edge.org/3rd_culture/boroditsky09/boroditsky09_index.html


very nice link, thanks.
--
Robin Becker

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


Re: An assessment of the Unicode standard

2009-09-14 Thread Christopher Culver
ru...@yahoo.com writes:
 Fashion changes in science as well as clothes. :-)

A favourite line of crackpots who think that their ridiculous position
is not held by others merely because of fashion.

  I wouldn't count
 Sapir-Whorf out yet...
 http://edge.org/3rd_culture/boroditsky09/boroditsky09_index.html

That researcher does not say that language *constrains* thought, which
was the assertion of the OP and of the strict form of the Sapir-Whorf
hypothesis. She merely says that it may influence thought.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with the inclusion of new files like lxml, django, numpy, etc.

2009-09-14 Thread Terry Reedy

Paul Boddie wrote:


Agreed. I don't understand why the download file would be a winrar
file, but I guess this is just Windows getting confused about the file
type.


Windows does not know much about files types other that .exe, .bat, 
except what programs you load tell it. I presume the file is .zip. 
Different unzip programs will give .zip files different names. Some 
names files after themselves. 7zip acts properly and calls .zip a 'zip 
archive'. I suspect you have WinRar loaded and that it 'brands' the 
files it decodes.


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


[ANN] Intro+Intermediate Python course, San Francisco, Nov 2009

2009-09-14 Thread wesley chun
(COMPREHENSIVE) INTRO+INTERMEDIATE PYTHON
Mon-Wed, 2009 Nov 9-11, 9AM - 5PM

If you have been in the Python community for some time, you may be
familiar with my introductory (and advanced) courses. Many new Python
intro courses have been added over the past few years, so aren't all
classes the same? Most introductory courses focus on teaching you the
syntax and giving you an idea of a language's flow control and data
types.

However, this can only get your so far. Although our course may appear
to be for those new to Python, it is also perfect for those who have
tinkered with it and want to fill in the gaps or desire more
in-depth formal training. It combines the best of both an introduction
to the language as well as covering intermediate language fundamentals
that can make you more effective, even as a beginner.

We will immerse you in the world of Python in only a few days, showing
you more than just its syntax (which you don't really need a book to
learn, right?). Knowing more about how Python works under the covers,
including the relationship between data objects and memory management,
will make you a much more effective Python programmer coming out of
the gate. Daily hands-on labs will help hammer the concepts home.

Come join me, Wesley Chun, author of Prentice-Hall's bestseller Core
Python Programming, for a comprehensive course coming up this Fall in
beautiful Northern California to get up-to-speed with Python as
quickly and as in-depth as possible!

WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA
INFO:  http://cyberwebconsulting.com (click Python Training)
FLYER: http://starship.python.net/crew/wesc/flyerPP1nov09.pdf

LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area

VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites

FREE PREVIEW: at the website below, you will find (and can download) a
video clip of a live lesson that was delivered recently to get an idea
of the lecture style and interactive classroom environment.

FREE PREVIEW 2: Partnering with O'Reilly and Pearson, I delivered a
one-hour introductory webcast at Safari Books Online earlier this year
called BIWhat is Python?/I/B. You will get both my lecture
style as well as an overview of the material covered in the course.

http://www.safaribooksonline.com/events/WhatIsPython.html (event announcement)
http://www.safaribooksonline.com/Corporate/DownloadAndResources/webcastInfo.php?page=WhatIsPython
(free download with registration)

See website for costs, venue info, and registration; various discounts
available.

Hope to see you there!
- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Core Python Programming, Prentice Hall, (c)2007, 2001
Python Fundamentals DVD, Prentice Hall, (c)2009
http://corepython.com

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


Re: AttributeError: 'NoneType' object has no attribute 'get_text'

2009-09-14 Thread Raji Seetharaman
 -- Forwarded message --
 From: MRAB pyt...@mrabarnett.plus.com
 To: python-list@python.org
 Date: Sun, 13 Sep 2009 19:44:30 +0100
 Subject: Re: AttributeError: 'NoneType' object has no attribute 'get_text'
 Raji Seetharaman wrote:

 Hi all,
 i did a small gui addressbook application using pygtk, python, mysql db.
 It was successful.
 I tried the same application with glade. But i ended up with errors.
 I desgined the code as follows.
 1.It has one main window and four child dialogs.
 2.In the main window, i have to fill in the text entry widget  if i press
 'add', the data will get inserted into the database.This works fine.
 3. If showdialog button is clicked, a child dialog appears, where i have
 to enter old entry to update.
 4. To update, i again use the main window, where i get the following error
  Traceback (most recent call last):
  File addressbookglade.py, line 63, in update
self.ssn = self.wTree.get_widget(ssn).
 get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

 Also i already set the name in properties window.  It works fine for add
 option. But not for update option.
 Im using the same window for both add and update.

 The code is available here http://pastebin.com/m28a4747e
 The glade xml file is here http://pastebin.com/m1af61a29
 The screenshot of my glade windows are here
 http://www.flickr.com/photos/raji_me/?saved=1
  It works fine for add option. But not for update option. Im using the
 same window for both add and update.

  You're using instance attributes a lot where I think local variables
 would be better, eg self.ssn instead of just ssn.

 In the '__init__' method you have:

self.wTree = gtk.glade.XML(self.gladefile,mainWindow)

 and then in the 'view' method you have:

self.wTree = gtk.glade.XML(self.gladefile,viewdialog)

 In both the 'add' and 'update' methods you have:

self.ssn = self.wTree.get_widget(ssn).get_text()

 so I suspect that the following is happening:

 1. __init__ makes self.wTree refer to 'mainWindow';

 2. You click on the Add button, the 'add' method is called, and the
 self.ssn =  line looks for the ssn widget in 'mainWindow';

 3. You click on the OK(?) button and view what's just been added;

 4. The 'view' method makes self.wTree refer to 'viewdialog';

 5. You click on the Update button, the 'update' method is called, and the
 self.ssn =  line looks for the ssn widget in 'viewdialog'.





 Yes, u r right, the self.ssn =  looks for widget in the child dialog, not
 the mainWindow. But how to set it to 'mainWindow' again.

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


ANN: Wing IDE 3.2.1 released

2009-09-14 Thread Stephan Deibel

Hi,

Wingware has released version 3.2.1 of Wing IDE, our integrated development
environment for the Python programming language.  This is a bug fix release
that includes the following changes:

* Improved support for Snow Leopard (OS X 10.6)
* Support for x86_64 Python 2.4+ on OS X
* Support for Stackless Python 3.0 and 3.1
* Fixed Stackless Python support on 64-bit Linux
* Several other bug fixes; See the change log for details:
  http://wingware.com/pub/wingide/3.2.1/CHANGELOG.txt

*Wing 3.2 Highlights*

Version 3.2 of Wing IDE includes the following new features not present
in Wing IDE 3.1:

* Support for Python 3.0 and 3.1
* Rewritten version control integration with support for Subversion, CVS,
  Bazaar, git, Mercurial, and Perforce (*)
* Added 64-bit Debian, RPM, and tar file installers for Linux
* File management in Project view (**)
* Auto-completion in the editor obtains completion data from live runtime
  when the debugger is active (**)
* Perspectives: Create and save named GUI layouts and optionally automatically
  transition when debugging is started (*)
* Improved support for Cython and Pyrex (*.pyx files)
* Added key binding documentation to the manual
* Added Restart Debugging item in Debug menu and tool bar (**)

(*)'d items are available in Wing IDE Professional only.
(**)'d items are available in Wing IDE Personal and Professional only.

The release also contains many other minor features and bug fixes; see the
change log for details:  http://wingware.com/pub/wingide/3.2.1/CHANGELOG.txt

*Downloads*

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial license can be obtained directly from
the product when launched.  Wing IDE 101 can be used free of charge.

Wing IDE Pro 3.2.1http://wingware.com/downloads/wingide/3.2

Wing IDE Personal 3.2.1   http://wingware.com/downloads/wingide-personal/3.2

Wing IDE 101 3.2.1http://wingware.com/downloads/wingide-101/3.2

*About Wing IDE*

Wing IDE is an integrated development environment for the Python programming
language.  It provides powerful debugging, editing, code intelligence,
testing, version control, and search capabilities that reduce development and
debugging time, cut down on coding errors, and make it easier to understand
and navigate Python code.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free simplified version designed
for teaching entry level programming courses with Python.

System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or
Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit).
Wing IDE 3.2 supports Python versions 2.0.x through 3.1.x.

*Purchasing and Upgrading*

Wing 3.2 is a free upgrade for all Wing IDE 3.0 and 3.1 users. Any 2.x license
sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price
to upgrade.

Upgrade a 2.x license: https://wingware.com/store/upgrade

Purchase a 3.x license:https://wingware.com/store/purchase

--

The Wingware Team
Wingware | Python IDE
Advancing Software Development

www.wingware.com

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


Re: An assessment of the Unicode standard

2009-09-14 Thread r
On Sep 14, 6:00 am, Robin Becker ro...@reportlab.com wrote:
(snip)
 well allegedly, the medium is the message so we also need to take account of
 language in addition to the meaning of communications. I don't believe all
 languages are equivalent in the meanings that they can encode or convey. Our
 mathematics is heavily biassed towards continuous differential systems and as 
 a
 result we end up with many physical theories that have smooth equilibrium
 descriptions, we may literally be unable to get at other theories of the
 physical world because our languages fall short.
 --
 Robin Becker

Intelligence does not depend on outside resources (languages),
intelligence begets new intelligent resources!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread r
On Sep 14, 9:05 am, Mel mwil...@the-wire.com wrote:
(snip)
 Worf was raised as a Klingon, so you can expect this.  If he'd been brought
 up speaking Minbari, points 1 and 2 would have been obvious to him.

         Mel.

Yes Klingon's are a product of their moronic society, not their
moronic language. The brainwashing starts at home!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy NaN, not surviving pickle/unpickle?

2009-09-14 Thread Scott David Daniels

Steven D'Aprano wrote:

On Sun, 13 Sep 2009 17:58:14 -0500, Robert Kern wrote:
Exactly -- there are 2**53 distinct floats on most IEEE systems, the vast 
majority of which might as well be random. What's the point of caching 
numbers like 2.5209481723210079? Chances are it will never come up again 
in a calculation.


You are missing a few orders of magnitude here; there are approx. 2 ** 64
distinct floats.  2 ** 53 is the mantissa of regular floats.  There are
2**52 floats X where 1.0 = X  2.0.
The number of normal floats is 2 ** 64 - 2 ** 52 + 1.
The number including denormals and -0.0 is 2 ** 64 - 2 ** 53.

There are approx. 2 ** 53 NaNs (half with the sign bit on).

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and 3d

2009-09-14 Thread Kevin MacPhail
On Sun, Sep 13, 2009 at 2:29 PM, Ryniek90 rynie...@gmail.com wrote:


 
  azrael wrote:
 
  Has anyone any exipience with python and 3d.
 
  I mean, is there a module to deal with popular 3d formats like 3ds, or
  vrml. is it possible to import into python opengl models and then use
  it in application for GUI purposes like through WX. I know that WX
  supports OpenGL but how to import models from file.
 
 
  http://www.vrplumber.com/py3d.py
 
  There's a few older projects to load 3DS files, but I don't think any of
  them is currently PyOpenGL 3.x compatible.  OpenGLContext loads VRML97
  files (with SimpleParse installed).  Pyglet, OpenGLContext and Ian
  Mallet's game engine all load .obj models (I believe Ian's engine is the
  most advanced there).  Pivy should load VRML files as well, and has a
  very powerful engine (COIN) under the covers (OpenGLContext is more of a
  demo/testing system).  The big engines (Ogre, Soya, OpenSceneGraph,
  Crystal Space, etc) should all have content loaders, though I haven't
  played with them enough to be able to say what formats they support.
 
  HTH,
  Mike
 
 

 Maybe check out:

 - Panda3D ( http://www.panda3d.org/ ),
 - PyGame ( http://www.pygame.org/news.html ),
 - PyKyra ( http://www.alobbs.com/pykyra ),
 - PyOpenGL ( http://pyopengl.sourceforge.net/ ),

 or

 Blender ( http://www.blender.org/ ).

 All above deserve attention.
 --
 http://mail.python.org/mailman/listinfo/python-list



Also worth mentioning:

- The Python Computer Graphics Kit ( http://cgkit.sourceforge.net )

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


Re: Why indentation is use to denote block of code?

2009-09-14 Thread Andreas Waldenburger
On Sun, 13 Sep 2009 21:43:49 -0700 (PDT) TerryP bigboss1...@gmail.com
wrote:

 Not to be omega-rude and disrespectful, but if you have to ask such a
 question -- you are either to stupid a programmer to warrant any
 intellectual response, or are just interested in wasting peoples
 bandwidth.
 
Wow, dude. Easy. There was absolutely no reason for this kind of
statement. The OP is probably just used to a certain way of programming
and has a hard time adjusting. Some people are that way, so why not cut
them some slack.

In general: How about we leave it at that? This is in the list of
Frequently Asked Questions, and the point of that is that it does not
become a frequently answered question. We can do better things than
start attacking or defending syntax, can we?

/W

-- 
INVALID? DE!

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


Re: Google Code Jam language usage

2009-09-14 Thread Andreas Waldenburger
On Mon, 14 Sep 2009 11:17:02 -0400 Terry Reedy tjre...@udel.edu wrote:

 At the recent Google Code Jam, Python was the 3rd most popular
 language after C/C++ and Java. 

Good for C/C++ and Java that they are not ranked by fun per line.

/W


-- 
INVALID? DE!

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


Re: Python and 3d

2009-09-14 Thread Olivier Renouard
Kevin MacPhail wrote:


 On Sun, Sep 13, 2009 at 2:29 PM, Ryniek90 rynie...@gmail.com
 mailto:rynie...@gmail.com wrote:


 
  azrael wrote:
 
  Has anyone any exipience with python and 3d.
 
  I mean, is there a module to deal with popular 3d formats like
 3ds, or
  vrml. is it possible to import into python opengl models and
 then use
  it in application for GUI purposes like through WX. I know that WX
  supports OpenGL but how to import models from file.
 
 
  http://www.vrplumber.com/py3d.py
 
  There's a few older projects to load 3DS files, but I don't
 think any of
  them is currently PyOpenGL 3.x compatible.  OpenGLContext loads
 VRML97
  files (with SimpleParse installed).  Pyglet, OpenGLContext and Ian
  Mallet's game engine all load .obj models (I believe Ian's
 engine is the
  most advanced there).  Pivy should load VRML files as well, and
 has a
  very powerful engine (COIN) under the covers (OpenGLContext is
 more of a
  demo/testing system).  The big engines (Ogre, Soya, OpenSceneGraph,
  Crystal Space, etc) should all have content loaders, though I
 haven't
  played with them enough to be able to say what formats they support.
 
  HTH,
  Mike
 
 

 Maybe check out:

 - Panda3D ( http://www.panda3d.org/ ),
 - PyGame ( http://www.pygame.org/news.html ),
 - PyKyra ( http://www.alobbs.com/pykyra ),
 - PyOpenGL ( http://pyopengl.sourceforge.net/ ),

 or

 Blender ( http://www.blender.org/ ).

 All above deserve attention.
 --
 http://mail.python.org/mailman/listinfo/python-list



 Also worth mentioning:

 - The Python Computer Graphics Kit ( http://cgkit.sourceforge.net )

 Cheers

And you could add Cortex, http://cortex.devjavu.com, various C++
libraries with Python binding to manipulate 3d content creation format
and either display them in OpenGL format or export them to RIB format
for rendering.




-- 
Olivier Renouard

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


Re: An assessment of the Unicode standard

2009-09-14 Thread r
On Sep 14, 9:11 am, Processor-Dev1l processor.de...@gmail.com wrote:
(snip)

 Well, I am from one of the non-English speaking countries (Czech
 Republic). We were always messed up with windows-1250 or iso-8859-2.
 Unicode is really great thing for us and for our developers.

Yes you need the crutch of Unicode because no all-encompassing-
language exists today. Because of this we need interpretors at
accident scenes, and subtitles on movies. Public Warning Systems must
be delayed due to repeating the same information in different
languages. And the worst part of all of this is the human instinct to
fear that which is different. Yes, multi-languages contribute to
racism and classism although are not the only cause. What moronicity
is this when a self-aware species has evolved for as long as we and
yet, has not perfected universal communication, sad, very sad! What
would an advanced civilization think if they dropped in for a spot of
tea?

 About the western technology made in China and Taiwan... do you
 really think US are so modern? I can only recommend you to visit
 Japan :).

The US is nearing the end of it's global reign and superpower status.
Is that a good or bad thing? Only time shall tell! Doesn't matter
really because some other power will step in and be the hated one,
it's very lonely at the top -- i myself know this fact all to well ;-)

 I also think 26 letters are really limited and English is one of the
 most limited languages ever. It has too strict syntax. Yeah, it is
 easy to learn, but not so cool to hear every day.

So how many letters do we need? 50, 100, 1000? Simplisticity is
elegance, that is why Python is so beautiful! Yes, English sucks eggs
and if we do adopt it as universal language, it should get an enema
for sure. But i am all for scraping the English language all together
and creating something completely new.

 Btw how many foreign languages do you speak?

I guess you judge intelligence from memorization of redundant facts?
Some people believe this, however i don't. I have gb's and gb's on my
hard drive for storing redundant facts. I use my mind for dreaming,
reasoning, contemplating, exploring, etc, not as a refuse bin! As i
said before language is nothing more than a utility, a way to
communicate with others. You can romanticize it all you want but at
the end of the day it is nothing more than what it is. People who
romanticize language typically like Shakespeare and such. I have no
interest in flower sniffing pansies from days gone by. My interest are
science, technology, and the advancement of human intelligence. I
leave Saturday morning cartoons for children.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread r
On Sep 14, 9:23 am, Christopher Culver
crcul...@christopherculver.com wrote:
(snip)
 That researcher does not say that language *constrains* thought, which
 was the assertion of the OP and of the strict form of the Sapir-Whorf
 hypothesis. She merely says that it may influence thought.

*I* am the OP! I never said language constrained thought or
intelligence, that's lunacy! That would be akin to saying class status
decides intelligence! You should reread this thread immediately! My
argument is multi-languages and the loss of communication, and
obviously we have before us an example of this miss-communication.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: myparentclass.__subclasses__() not working for me

2009-09-14 Thread Gabriel Genellina

En Mon, 14 Sep 2009 10:30:07 -0300, samwyse samw...@gmail.com escribió:


### I've tried this under both Python 2.5.1 and 3.1.1, and it isn't
working with either one.  Here is my program:

class Plugin(object):
This is the base object for a plug-in.
pass

def load_plugins(plugin_subdir='plugins'):
import sys, pkgutil, imp, os.path

try:
# Use this path if we're running as a module.
homedir = __path__[0]
except NameError:
# Use this path if we're running stand-alone.
homedir = sys.path[0]
plugin_path = [ os.path.join(homedir, plugin_subdir) ]

modules = {}
for loader, name, is_pkg in pkgutil.iter_modules(plugin_path):
file, pathname, desc = imp.find_module(name, plugin_path)
modules[name] = imp.load_module(name, file, pathname, desc)
for pair in modules.items():
print('name = %r\nmodule = %r\n' % pair)

if __name__ == '__main__':
print('subclasses = %r\n' %(Plugin.__subclasses__()))
load_plugins()
print('subclasses = %r\n' %(Plugin.__subclasses__()))

### And here is my plugin, in plugins/myplugin.py:

from plugin import Plugin
class MyPlugin(Plugin):
pass

### When I run the main program, I get this:

subclasses = []

name = 'myplugin'
module = module 'myplugin' from 'C:\Documents and Settings\sam_denton
\Desktop\scripting\plugins\myplugin.py'

subclasses = []

###  Obviously, myplugin is being found found and loaded, but my base
class doesn't know about it.  Any ideas?


Don't run the first module as a program itself. When it's run as a  
program, it's known as '__main__'; when someone executes 'import plugin'  
*another* copy is imported under the name 'plugin'.
So your plugin classes inherit from plugin.Plugin but you're printing  
__main__.Plugin subclasses.


--
Gabriel Genellina

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


Re: Message box always appears on 2nd monitor

2009-09-14 Thread ed

Sean DiZazzo wrote:

On Sep 11, 8:27 am, ed e...@nospam.net wrote:

No matter what I do, the MessageBox always appears on the 2nd monitor.
I've forced all the other widgets to monitor 1.
I thought that creating a class and forcing the position would help, but
it hasn't.

I'm using Ubuntu Jaunty, python 2.6.

Any ideas what I can do to force widgets to a specific monitor?

Thank you.

class ConnectErrorMsgBox( wx.Frame ):
 def __init__( self ):
 wx.Frame.__init__(self,None, -1, '', pos=(0,0) )
 self.SetPosition( (0, 0) )
 wx.MessageBox(message='Connect Error',
  caption='Status',
  style=wx.OK | wx.ICON_EXCLAMATION| wx.CENTER,
  x=0, y=0)


Did you try making the message box a child of whatever window called
it?  ie.  Pass in the parent= attribute.

~Sean


Now I have.  That did the trick.  Thank you.
--
http://mail.python.org/mailman/listinfo/python-list


Google Code Jam language usage

2009-09-14 Thread Terry Reedy
At the recent Google Code Jam, Python was the 3rd most popular language 
after C/C++ and Java. From qualification round

http://www.go-hero.net/jam/09/languages/0

Language #contests (rounded)
C/C++ 4200
Java  1900
Python 900
C#   600
Perl 300
Ruby 200
PHP  200

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


Check if button is pressed in QDialogButtonBox

2009-09-14 Thread Kashif Umer
Hello,
I am new to Python and I'm working with a UI that has a dialog button box
with 'OK' and 'Cancel' standard buttons. I want to check if the 'OK' button
has been pressed, but I can't use isDown or isChecked for example because it
throws an attribute error:

AttributeError: 'StandardButton' object has no attribute 'isDown'

Is this because the StandardButton type does not inherit from the
QPushButton and QAbstractButton classes? How would I perform the check with
the a StandardButton object?

Thanks,

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


Re: Why indentation is use to denote block of code?

2009-09-14 Thread rurpy
On 09/13/2009 10:43 PM, TerryP wrote:
 On Sep 13, 10:12 pm, Peng Yu pengyu...@gmail.com wrote:
 Hi,

 I want to understand why python use indentation to denote block of
 code. What are the advantages of it? Is there a style in python to
 denote a block of code the same as that of C++ (with '{}')?

 One disadvantage of using indentation to denote a block of code is
 that the runtime to automatically indent a python code would be about
 a few times more than the runtime to automatically indent a C++ code
 of the same length (both are in vim).

 Not to be omega-rude and disrespectful, but if you have to ask such a
 question -- you are either to stupid a programmer to warrant any
 intellectual response, or are just interested in wasting peoples
 bandwidth.

Not to be omega-rude and disrespectful either but if you think
tradeoffs made in designing a language, such as the choice of
indents or braces to denote blocks, are simple and obvious
ones, then you are either a very stupid person, or are trying
to vent your anger from the safety of a remote computer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why indentation is use to denote block of code?

2009-09-14 Thread TerryP

 Not to be omega-rude and disrespectful either but if you think
 tradeoffs made in designing a language, such as the choice of
 indents or braces to denote blocks, are simple and obvious
 ones, then you are either a very stupid person, or are trying
 to vent your anger from the safety of a remote computer.

I did not say the choice of, I said the advantage and disadvantage of;
there is _quite a bit of difference_ between such statements. If I had
said the former, I would agree with you, but as I said the latter,
I'll remark thus: in use they become very apparent, to anyone whose
used much of either style.

Designing and using a language are different things.


On Sep 14, 3:38 pm, Andreas Waldenburger use...@geekmail.invalid
wrote:
 Wow, dude. Easy. There was absolutely no reason for this kind of
 statement. The OP is probably just used to a certain way of programming
 and has a hard time adjusting. Some people are that way, so why not cut
 them some slack.



I'm not a person who believes in mincing words off the first date, so
I apologize (OP included) if my choice of words were too harsh.
There's no intention of attacking or defending anything, just of being
concise!


Two things I learned at an early age, a C programmer can write C in
any language - and making Adam into Eve is probably a bad idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy NaN, not surviving pickle/unpickle?

2009-09-14 Thread Terry Reedy

Gabriel Genellina wrote:
En Sun, 13 Sep 2009 20:53:26 -0300, Steven D'Aprano 
st...@remove-this-cybersource.com.au escribió:



There may be something to be said for caching common floats, like pi,
small integers (0.0, 1.0, 2.0, ...), 0.5, 0.25 and similar, but I doubt
the memory savings would be worth the extra complexity.


Pi is already cached -- in the math module.
Zero is not because one can easily write zero=0.0, etc.
The main memory saving comes on allocation of large arrays or of 
multiple medium arrays. For that, one can use one named object.


It is easy to cache and test for ints in a contiguous range.
Cached ints are heavily reused in the interpreter before it executes a 
line of code.


Built-in equality tests for several floats would slow down all float 
code. Interpreter does not use floats for its internal operations. So 
idea was considered and rejected by devs.


I've read some time ago, that simply caching 0.0 reduced appreciably the 
memory usage of a Zope application.
(Note that Zope relies on pickling and unpickling objects all the time, 
so even if two objects started as the same zero, they may become 
different at a later time.)





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


Re: Iterating Through Dictionary of Lists

2009-09-14 Thread JB
On Sep 11, 9:42 am, Stefan Behnel stefan...@behnel.de wrote:
 JBwrote:
  I have created a small program that generates a project tree from a
  dictionary. The dictionary is of key/value pairs where each key is a
  directory, and each value is a list. The list have unique values
  corresponding to the key, which is a directory where each value in the
  list becomes a subdirectory.

  The question that I have is how to do this process if one of the
  unique values in the list is itself a dict. For example, in the
  projdir dict below, suppose the Analysis value in the list
  corresponding to the Engineering key was itself a dict and was
  assigned {'Analysis' : 'Simulink'} for example.

 You might want to read up on recursion, i.e. a function calling itself.

 You can find out if something is a dict like this:

         isinstance(x, dict)

 or, if you know it really is a dict and not a subtype:

         type(x) is dict

 Stefan

Stefan;

Thanks for your valuable suggestion. I have employed your suggestion
with the code below.
I also converted this to object oriented design. With this type of
construction, the
program will easily handle the dictionary specified by the self.proj
variable. This
variable is a dictionary with some of the value variables also being
dictionaries.
I did not generalize the function call but have more of horizontal
code for this
area of the implementation. If this program were packaged with a GUI,
it would
make the beginning of a project management software platform.

-James



from time import strftime
import os

#-
# Print/Make Directories
#-
class Tree:
 def __init__(self,dir_main,dir_sub,sch_names,drawing_name):
self.proj = {'Project':  ['Schedule',
'Specifications'],

'Schematics_PCB' :  [{'SCH':sch_names},{'BOM':sch_names},
{'ASSY':sch_names},
 {'RELEASE':sch_names}],

'Drawings'   :  [{'System':drawing_name},
{'Board':sch_names},
 'Packaging_3D'],

'Engineering':  [{'Analysis':
['Simulink','Matlab','Excel',
  'MathCad','Python']},
 {'Eng Reports':sch_names}, {'Design
Reviews':sch_names},
 {'Procedures':['Board Test','System
Test']}]}
self.sch_names= sch_names
self.drawing_name = drawing_name
self.dir_main = dir_main
self.dir_sub  = dir_sub
self.root = self.dir_main + self.dir_sub
self.pathname = ''
self.suffix   = \\Previous \n
self.recursion= 0.0
self.zs   = ''

 def gen_dir(self):
if os.path.exists(self.pathname):
pass
else:
os.makedirs(self.pathname)
return

 def print_path(self):
print self.pathname
Tree.gen_dir(self)

self.zs = self.pathname + self.suffix

Tree.gen_dir(self)
print self.zs
#-
# Make a Directory Project Tree
#-
 def make_tree(self):
counter = 0
print This project tree for  + self.dir_sub[0:-1] +  was completed
by 
print Generated on  + strftime(%m/%d/%Y at %H.%M hours)
print The project tree / dictionary was found to have the following:
\n

#-
# Iterate over items in the dictionary, creating tuples of key/value
pairs

#-
for key, values in self.proj.iteritems():
counter = counter + 1
print Key # + str(counter) +  is   + ' + key + \\
print For this key, the values are  + str(values)
print Thus, the results of generating directories for this 
print  key/values combo are: \n
#-
# Iterate over the invidividual unique values in the list
# that is associated with each key in the dict, where
# an individual value may itself be a dict
#-
for unique in values:
prefix = self.root + key +  /
if isinstance(unique, dict) == True:
for kx,vx in unique.iteritems():
if isinstance(vx,list) == True:
for items in vx:
  self.pathname = prefix  + kx 
+  \\ + items
  Tree.print_path(self)
else:
   

Re: Why indentation is use to denote block of code?

2009-09-14 Thread Terry Reedy

Miles Kaufmann wrote:

whitespace-preserving [code] tag, though; and pindent is relatively old, 
and apparently not well maintained (no support for with blocks)).


http://bugs.python.org/issue6912
Add 'with' block support to Tools/Scripts/pindent.py

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


Re: Why indentation is use to denote block of code?

2009-09-14 Thread Robert Kern

On 2009-09-14 12:42 PM, TerryP wrote:


I'm not a person who believes in mincing words off the first date, so
I apologize (OP included) if my choice of words were too harsh.
There's no intention of attacking or defending anything, just of being
concise!


I would never have thought to describe your post as concise. In fact, you 
seemed to go out of your way to abuse the OP with rhetorical flourishes and 
avoid giving any actual information. There are times when concise but 
informative responses can appear to be rude, but you can't hide deliberate abuse 
behind that excuse.


 Two things I learned at an early age, a C programmer can write C in
 any language - and making Adam into Eve is probably a bad idea.

Adam can bloody well act like a decent human being without losing his manhood, I 
assure you.


--
Robert Kern

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

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


Re: An assessment of the Unicode standard

2009-09-14 Thread Terry Reedy

r wrote:



So how many letters do we need? 50, 100, 1000? 


From Wikipedia IPA article:
Occasionally symbols are added, removed, or modified by the 
International Phonetic Association. As of 2008, there are 107 distinct 
letters, 52 diacritics, and four prosody marks in the IPA proper.




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


Re: Writing a thread-safe class

2009-09-14 Thread News123
So what's recommended way for multicore machines?
Threads will probably only accelerate if the used C libraries are
releasing the GIL, right?

What's for example about PIL (Python Imaging library)?



Assuming, that the C library calls don't releas the GIL


Shoud I directly use use fork() and some kind of IPC? or are there some
special well established, recommendable commodity modules aiming for
rmultiprocessor job distribution?

So far I have just a single-core machine, but I'll be using a multicore
machine in the next weeks.

Then I'll probably find out

bye

N




sturlamolden wrote:
 On 12 Sep, 15:54, Timothy Madden terminato...@gmail.com wrote:
 
 I find that hard to believe, but I will look into it.
 
 Carl Banks is correct.
 
 There is a mutex called the global interpreter lock that takes care
 of this. You can have multiple threads running, but access to the
 Python interpreter is serialized.
 
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a thread-safe class

2009-09-14 Thread MRAB

News123 wrote:

So what's recommended way for multicore machines?
Threads will probably only accelerate if the used C libraries are
releasing the GIL, right?

What's for example about PIL (Python Imaging library)?



Assuming, that the C library calls don't releas the GIL


Shoud I directly use use fork() and some kind of IPC? or are there some
special well established, recommendable commodity modules aiming for
rmultiprocessor job distribution?

So far I have just a single-core machine, but I'll be using a multicore
machine in the next weeks.

Then I'll probably find out


Have a look at the multiprocessing module.


bye

N




sturlamolden wrote:

On 12 Sep, 15:54, Timothy Madden terminato...@gmail.com wrote:


I find that hard to believe, but I will look into it.

Carl Banks is correct.

There is a mutex called the global interpreter lock that takes care
of this. You can have multiple threads running, but access to the
Python interpreter is serialized.





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


Re: Google Code Jam language usage

2009-09-14 Thread Stefan Behnel
Andreas Waldenburger wrote:
 On Mon, 14 Sep 2009 11:17:02 -0400 Terry Reedy wrote:
 
 At the recent Google Code Jam, Python was the 3rd most popular
 language after C/C++ and Java. 
 
 Good for C/C++ and Java that they are not ranked by fun per line.

Oh, I actually tend to have a lot of fun per line with Java. But that's
usually not with code I have written myself.

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


Re: Odd/Weird errors with FTPLib

2009-09-14 Thread Bakes
On Sep 13, 11:47 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 Bakes wrote:
  On 13 Sep, 22:41, Chris Rebert c...@rebertia.com wrote:
  On Sun, Sep 13, 2009 at 2:34 PM, Bakes ba...@ymail.com wrote:
  I am using a simple python script to download my logfiles. This is on
  a while loop, the logfile grows rapidly, so it is necessary for python
  to start downloading the new script as soon as it has finished the
  old.
  It works fine (for about 20 minutes), then crashes. I have removed a
  couple of excepts, and have narrowed the error down to a 'error_perm:
  550 logfile.log: The data is invalid.' error.
  Does anyone know what the problem might be regarding this, and what I
  might do to fix it?
  Including an actual code snippet and the full error traceback would help a 
  lot.

  According tohttp://en.wikipedia.org/wiki/List_of_FTP_server_return_codes,
  error code 550 translates to:
  Requested action not taken. File unavailable (e.g., file not found,
  no access).

  Does the logfile get rotated or something, thus causing it to briefly not 
  exist?

  It might also help if you explain how your logfile system works.

  Cheers,
  Chris
  --http://blog.rebertia.com

  It's a cod4 gameserver logfile, being downloaded for a python bot to
  parse.

  The logfile is downloaded using this try/except while loop.

      while True:
          try:
              if ftp == False:
                  self.debug('FTP connection not active, attempting to 
  (re)connect')
                  ftp = self.ftpconnect()
              size=os.path.getsize('games_mp.log')
              ftp.retrbinary('RETR ' + os.path.basename(self.ftpconfig 
  ['path']), handleDownload, rest=size)
              if self.console._paused:
                  self.console.unpause()
          except:
              print error
              self.debug('Lost connection to server, pausing until updated 
  properly, Sleeping 10 seconds')
              self.console.pause()
              try:
                  ftp.close()
                  self.debug('FTP Connection Closed')
              except:
                  self.debug('FTP does not appear to be open, so not closed')
              ftp = False
              time.sleep(10)

  I can only assume that occasionally, the logfile is being written to
  by the gameserver at the same time that it's downloading.
  If this was the case, do you think a try: download except: sleep
  900msec then download loop would work?

 Bare excepts are almost always a bad idea because they'll catch _all_
 exceptions, both those you expect could happen and those you don't.
 Catch only those you expect.

 For example, if the file 'games_mp.log' doesn't exist then
 os.path.getsize('games_mp.log') will raise an exception, and if you
 forgot to import the os module then that will raise a NameError
 exception.

 Anyway, I can't see how you leave the loop; I'd expect something like a
 'break' statement.

 And as a matter of style, I'd prefer None to False to indicate when
 there's no FTP connection (and if not ftp instead of if ftp ==
 False).

I removed the try/except and saw when it failed.

I'll change those things, games_mp.log is guaranteed to be there (file
made in another script), os is imported correctly.

So, what do you think the error could be?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of the Unicode standard

2009-09-14 Thread Rhodri James

On Mon, 14 Sep 2009 19:24:44 +0100, Terry Reedy tjre...@udel.edu wrote:


r wrote:


 So how many letters do we need? 50, 100, 1000?


 From Wikipedia IPA article:
Occasionally symbols are added, removed, or modified by the  
International Phonetic Association. As of 2008, there are 107 distinct  
letters, 52 diacritics, and four prosody marks in the IPA proper.


The biggest problem for the IPA is that vowels are a two-dimensional
continuum, which is hard to map with discrete symbols.  Worse, differing
vowel sounds are the big variable in regional accents.  There's basically
too much variation within the dialectal family of English to make an
attempt to render it phonetically much use.

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why indentation is use to denote block of code?

2009-09-14 Thread Ben Finney
TerryP bigboss1...@gmail.com writes:

 Not to be omega-rude and disrespectful, but if you have to ask such a
 question -- you are either to stupid a programmer to warrant any
 intellectual response, or are just interested in wasting peoples
 bandwidth.

If you think this is “not to be rude and disrespectful”, you're not
reading what you write. Please refrain from personal insults like this.

-- 
 \ “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\Brain, but Zero Mostel times anything will still give you Zero |
_o__)  Mostel.” —_Pinky and The Brain_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Retracing your steps in an interactive python env

2009-09-14 Thread Jack Norton

Hello all,

I am playing around in a python shell (IPython on win32 right now 
actually).  I am writing some code on the fly to interface to a rotary 
encoder (not important in this scope).


Anyway, I have created a function using def, and well, I like the way it 
is working, however...  I have already filled the command line history 
buffer (the com.exe buffer?) so _what_ I actually filled this def with 
is lost.  Now, it isn't that complicated, and I can easily re-write the 
function off the top of my head, however it would be really nice to be 
able to _ask_ python what makes up a def.
Something like this (remember I am using IPython interactive interpreter 
session):

In [0]: def func(input):
.:print im in this function! + str(input)
.:print doing some stuff
.:sleep(10)

Then later on while still in this interactive shell session I could do 
something like:

In [1]: what_is_in(func)
The def for func(input) is:
print im in this function! + str(input)
print doing some stuff
sleep(10)

and therefore be able to recount what I just did.

Cheers,

Jack 


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


FW: Python / C++

2009-09-14 Thread Jeffrey Murphy
Hi Michael,

Thought this might be of interest to you... client is in Newport Beach...the 
job description is below...either ping me back with your resume and I will 
screen you for this role or give me a call for details...

We are seeking Python programmers with web-based development experience to 
assist with developing web based applications. The successful candidates should 
have excellent Python programming skills (with web development and dynamically 
generated charts/plots in particular) and working knowledge of Linux/UNIX Shell 
Scripts and SQL. Knowledge of Python integration with C/C++ - a definite plus.

Selected candidate will be working with our trade desk to develop and enhance 
applications used by Fixed Income Portfolio Management. You will assist in the 
design, construction and enhancement of applications used. Qualified candidates 
must possess a four-year college degree with a preferred major in Computer 
Science, Computer Engineering, or other technical/IT degree. A strong 
familiarity with Python on Linux; recent (2007) experience is required. 
Knowledge with web technologies including Apache, JavaScript/AJAX, CSS, HTML, 
designing, coding, and testing web based applications a plus. Programming 
experience in C++ is also a plus.

Our selected individual must be a team player, be self-motivated, and have 
excellent verbal communication skills. In addition, the ability to project 
manage and work within a team environment will be critical to being successful 
in this role.

Qualifications/Requirements
* 3+ years of Python programming on Linux/Unix platform; recent (2007) required
* Programming skills building forms, lay-outs, charts, and graphing required
* Designing, coding, and testing web based applications preferred.
* Strong organizational, oral and written communications skills
* High energy/self starter with the ability to work independently within the 
firm's demanding and highly focused environment


Jeffrey J Murphy
Managing Director
310.640.3050 or 510.269.4699

Surrex Consulting HQ
2151 East Grand Avenue
Suite 210
El Segundo, Ca  90245
Surrex Consulting NCal
1300 Clay Street, Suite 600
Oakland, Ca.  94612
www.surrex.comhttp://www.surrex.com

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


Re: Why indentation is use to denote block of code?

2009-09-14 Thread r
On Sep 14, 5:20 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
 TerryP bigboss1...@gmail.com writes:
  Not to be omega-rude and disrespectful, but if you have to ask such a
  question -- you are either to stupid a programmer to warrant any
  intellectual response, or are just interested in wasting peoples
  bandwidth.

 If you think this is “not to be rude and disrespectful”, you're not
 reading what you write. Please refrain from personal insults like this.

 Ben Finney

Respectfully Ben (or anyone regular for that matter), when have you
come to the aid of a noob when a regular on this group has shown
disrespect? I have seen lots of disrespect flung downwards and nobody
says a peep about it. Every time a small disagreement erupts the
*plonking* or trolling begins. I can't see why some get so emotional
and let disagreement turn to hate filled rage. Actually since i have
been *plonked* my experiences here have been much better. Maybe one
day the *plonkers* will return, but if not, oh well!

The OP obviously did not ponder the deeps of why Python uses indention
for blocks before posting. I will admit TerryP's language could offend
touchy people, but i have seen much worse on this list from some very
well known regulars!

This group is not the shining jewel of friendliness i wish it were. I
have been here for about 1.5 years and still feel i must watch my back
constantly. Too many people let little disagreement harbor
resentments. I have no time for hating this person or that person
because i do not agree with his or her politics or whatever. I may
exchange heated debate with them one minute and share a cold beer the
next. I think some of you need to follow this model.

A Usenet group is for learning and participating. No one should ever
feel intimidated to post comments because he or she may get bullied. I
find i learn much more about a subject when i get involved and share
my opinions. Sometimes i might be completely wrong, and get a wee bit
embarrassed, but what better way to learn than that!

I think Terrp's post is not a case of bulling, more a case of one or
two poor word choices. TerryP's post is actually completely factual,
albeit just a wee bit *too* colorful. ;-)

everybody just relax a bit!

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


Re: Retracing your steps in an interactive python env

2009-09-14 Thread r
On Sep 14, 2:52 pm, Jack Norton j...@0x6a.com wrote:
 Hello all,

 I am playing around in a python shell (IPython on win32 right now
 actually).  I am writing some code on the fly to interface to a rotary
 encoder (not important in this scope).

 Anyway, I have created a function using def, and well, I like the way it
 is working, however...  I have already filled the command line history
 buffer (the com.exe buffer?) so _what_ I actually filled this def with
 is lost.  Now, it isn't that complicated, and I can easily re-write the
 function off the top of my head, however it would be really nice to be
 able to _ask_ python what makes up a def.
 Something like this (remember I am using IPython interactive interpreter
 session):
 In [0]: def func(input):
 .:print im in this function! + str(input)
 .:print doing some stuff
 .:sleep(10)

 Then later on while still in this interactive shell session I could do
 something like:
 In [1]: what_is_in(func)
 The def for func(input) is:
 print im in this function! + str(input)
 print doing some stuff
 sleep(10)

 and therefore be able to recount what I just did.

 Cheers,

 Jack

You could put the entire def in a multi line doc string...?

 print func.__doc__

Considering you created a doc string.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Retracing your steps in an interactive python env

2009-09-14 Thread Mensanator
On Sep 14, 2:52 pm, Jack Norton j...@0x6a.com wrote:
 Hello all,

 I am playing around in a python shell (IPython on win32 right now
 actually).  I am writing some code on the fly to interface to a rotary
 encoder (not important in this scope).

 Anyway, I have created a function using def, and well, I like the way it
 is working, however...  I have already filled the command line history
 buffer (the com.exe buffer?)

I usually have my buffer default to 8000x132.

 so _what_ I actually filled this def with
 is lost.  Now, it isn't that complicated, and I can easily re-write the
 function off the top of my head, however it would be really nice to be
 able to _ask_ python what makes up a def.
 Something like this (remember I am using IPython interactive interpreter
 session):
 In [0]: def func(input):
 .:print im in this function! + str(input)
 .:print doing some stuff
 .:sleep(10)

 Then later on while still in this interactive shell session I could do
 something like:
 In [1]: what_is_in(func)
 The def for func(input) is:
 print im in this function! + str(input)
 print doing some stuff
 sleep(10)

 and therefore be able to recount what I just did.

 Cheers,

 Jack

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


Re: Distributing Python environment

2009-09-14 Thread Ecir Hana
I see, thanks a lot!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Retracing your steps in an interactive python env

2009-09-14 Thread TerryP
I'm not sure what the best way to do this is, other then that it would
mean asking the interp to explain it in a format we understand ;).


In the (c)python library reference, I see an inspect module that
sounds like it should be useful, but it doesn't work on my test case
here:

 def foo(x, y):
...  print(x+y)
...
 inspect.getsource(foo)
(throws IOError: could not get source code)

Perhaps someone else has more experience on the matter.

--

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


Re: platform-specific overrides of functions and class methods (expanding on imputils demo code)

2009-09-14 Thread lkcl
On Sep 6, 5:49 pm, Terry Reedy tjre...@udel.edu wrote:
 lkclwrote:
  On Aug 21, 12:58 am, a...@pythoncraft.com (Aahz) wrote:
  In article 
  77715735-2668-43e7-95da-c91d175b3...@z31g2000yqd.googlegroups.com,

 lkcl luke.leigh...@googlemail.com wrote:

  if somebody would like to add this to the python bugtracker, as a
  contribution, that would be great.  alternatively, you might like to
  have a word with the python developers to get them to remove the
  censorship on my contributions.
  Excuse me?  What censorship?

   i was ordered to cease contributing to python.

 As I remember from the public discussion, you were asked to cease using
 the bugtracker as a progress blog ...

 i used the bugtracker as a substitute for svn access, so that other
people who may be interested could follow, pick up and contribute.

 to describe valuable contributions as a prrrogress bloog
makes it sound like the work is at the same level as much of the
mindless drivel found on e.g. wordpress.

 if that's how it was being viewed, then it's no wonder there were
complaints.

 at the time that i was ordered to cease contributing, the work done
passed all but 8-12 of the standard python regression tests.  out of
several thousand.


  the cause was the
  provision of a port of python to run under mingw32, which passed all
  but eight of the regression tests.

 and wait until you had a complete patch to submit.

 1) i've stopped.  it's declared complete.  there.  it can now be
added.  does that help?

 2) you know as well as i do that there is never going to be a
complete patch.  no-one in the world is a perfect coder.  work is
_always_ ongoing.  there is _always_ going to be a better patch.

 3) wait until there is a complete patch flies in the face of the
basic tenets of both commercial _and_ free software development.  you
_never_ wait until the work is completed.  release early, release
often, remember?

 There is also a real
 question of whether such ports should be folded into the main CPython
 code base, as some have been, or maintained as separate projects, as
 other have been.

 the mingw32 port comprises two (necessary) features: 1) cross-
compiling support, which the mingw32 port uses to create python.exe
(from a posix system) 2) actual support for mingw32-compiled python,
including proper support on ILP32 systems, checking support for
features properly using autoconf tests not #ifdef WIN32 etc. etc.

 cross-compiling of cpython is tricky as hell, starting from pgen and
going from there, to create python.exe.  to be able to run that - in
order to compile the modules and run the regression tests is _even
more_ tricky. but - it's been done.

roumen and the other contributors to the cross-compile support have
consistently had their contributions considered to be worthless,
basically, for nearly five years, now. _despite_ clear evidence
indicating a need, and clear requests for cross-compiling to be
included in the standard python distribution.

 for example, from the gentoo team, who have a bitch of a job cross-
compiling python for embedded-mips systems.


 then there's the issue of continuing to rely on the proprietary
microsoft compiler toolchain.  you _know_ that's going to cause
problems, ultimately, with an important free software project such as
python.

so to throw mud in the face of people willing to think ahead and put
in the work to get you [PSF / python-devs] out of a potentially
difficult [political/strategic] situation is just ... i don't
understand it.  i even solved the issue of compiling python under
mingw32 using assemblies, so that it could be linked against MSVCRT80,
91 etc.

these kinds of multiple interdependent technical issues aren't the
sorts of things you put into a single patch and then stop - you keep
on at it, picking at one part of the pattern, moving to the next
issue, pick some more, solve that, and keep moving.

so - these are the kinds of things i received [not exact words]:
please stop submitting continual patches, we think it's about the
same level of value as some of the trash we see on wordpress.com.
please stop doing work because we think it's worthless.  we don't
really like and don't really want to maintain the win32 port of python
anyway, so why are you bothering to work on it?

do you notice a theme, here?  there isn't anything which is
particularly encouraging.  or places any value on the work being
done.  or indicates a willingness to extend free software.

this theme was so completely contrary to what i was expecting
[openness, trust and respect] that i just... went does not compute
and continued coding.  i don't mean that in a flippant way - i really
_mean_, my mind went this message [from e.g. martin] doesn't match my
expectations of a free software project developer/contributor.  what's
the next technical challenge i have to solve?  note the discontinuity
in the internal dialog between those two sentences.  there was no
_judging_ of the message received; no pffh. 

Re: Retracing your steps in an interactive python env

2009-09-14 Thread Steven D'Aprano
On Mon, 14 Sep 2009 14:52:34 -0500, Jack Norton wrote:

 it would be really nice to be
 able to _ask_ python what makes up a def. Something like this (remember
 I am using IPython interactive interpreter session):
 In [0]: def func(input):
 .:print im in this function! + str(input)
 .:print doing some stuff .:sleep(10)
 
 Then later on while still in this interactive shell session I could do
 something like:
 In [1]: what_is_in(func)
 The def for func(input) is:
 print im in this function! + str(input) print doing some stuff
 sleep(10)
 
 and therefore be able to recount what I just did.

Can't be done in the CPython interactive interpreter, because code is 
compiled before being executed. It doesn't save the source code when it 
compiles the function definition, so there's no way it can show you the 
source code. That's why interactive tracebacks don't show you the 
offending line that failed (with the exception of syntax errors) unless 
you have imported the function from a .py file.

You could probably mess about with the readline library to save a copy of 
everything to a history file.

Another alternative is to disassemble the compiled function, and try to 
determine what it does from that. See the dis module.

I wonder whether there's a third party module which will take the output 
of dis.dis and try to reverse engineer Python code from it?



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


Re: Programming ideas?

2009-09-14 Thread r
On Sep 12, 9:25 am, Mark Tolonen metolone+gm...@gmail.com wrote:
 Someone Something fordhai...@gmail.com wrote in message

 news:e196a4050909120713m76592252r9e89fb24fdaae...@mail.gmail.com...

 I know you've probably had this question a million and one times but here
 it
  is again. I'm intermediate at C, pretty good at Java (though I really
  don't
  want to program in this), okay at perl and I've just learned python. But,
  I
  have no more ideas to write programs/scripts for! Any ideas will be
  helpful?

Ugh... This is quite shameful really, but i could use the help of a C
programmer if you are interested? And this app would be unique in the
Python community. Actually most of the code already exist, just needs
a slight tweaking really. Would be a good way to strut your stuff ;).
and of course I would let you have all the glory, i just want to use
it *wink*

Contact me off list if you are interested.


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


Re: Odd/Weird errors with FTPLib

2009-09-14 Thread MRAB

Bakes wrote:

On Sep 13, 11:47 pm, MRAB pyt...@mrabarnett.plus.com wrote:

Bakes wrote:

On 13 Sep, 22:41, Chris Rebert c...@rebertia.com wrote:

On Sun, Sep 13, 2009 at 2:34 PM, Bakes ba...@ymail.com wrote:

I am using a simple python script to download my logfiles. This is on
a while loop, the logfile grows rapidly, so it is necessary for python
to start downloading the new script as soon as it has finished the
old.
It works fine (for about 20 minutes), then crashes. I have removed a
couple of excepts, and have narrowed the error down to a 'error_perm:
550 logfile.log: The data is invalid.' error.
Does anyone know what the problem might be regarding this, and what I
might do to fix it?

Including an actual code snippet and the full error traceback would help a lot.
According tohttp://en.wikipedia.org/wiki/List_of_FTP_server_return_codes,
error code 550 translates to:
Requested action not taken. File unavailable (e.g., file not found,
no access).
Does the logfile get rotated or something, thus causing it to briefly not exist?
It might also help if you explain how your logfile system works.
Cheers,
Chris
--http://blog.rebertia.com

It's a cod4 gameserver logfile, being downloaded for a python bot to
parse.
The logfile is downloaded using this try/except while loop.
while True:
try:
if ftp == False:
self.debug('FTP connection not active, attempting to 
(re)connect')
ftp = self.ftpconnect()
size=os.path.getsize('games_mp.log')
ftp.retrbinary('RETR ' + os.path.basename(self.ftpconfig ['path']), 
handleDownload, rest=size)
if self.console._paused:
self.console.unpause()
except:
print error
self.debug('Lost connection to server, pausing until updated 
properly, Sleeping 10 seconds')
self.console.pause()
try:
ftp.close()
self.debug('FTP Connection Closed')
except:
self.debug('FTP does not appear to be open, so not closed')
ftp = False
time.sleep(10)
I can only assume that occasionally, the logfile is being written to
by the gameserver at the same time that it's downloading.
If this was the case, do you think a try: download except: sleep
900msec then download loop would work?

Bare excepts are almost always a bad idea because they'll catch _all_
exceptions, both those you expect could happen and those you don't.
Catch only those you expect.

For example, if the file 'games_mp.log' doesn't exist then
os.path.getsize('games_mp.log') will raise an exception, and if you
forgot to import the os module then that will raise a NameError
exception.

Anyway, I can't see how you leave the loop; I'd expect something like a
'break' statement.

And as a matter of style, I'd prefer None to False to indicate when
there's no FTP connection (and if not ftp instead of if ftp ==
False).


I removed the try/except and saw when it failed.

I'll change those things, games_mp.log is guaranteed to be there (file
made in another script), os is imported correctly.

So, what do you think the error could be?


How does control leave the while loop?

If you're running on Windows and you're opening the file 'games_mp.log'
with mode 'w' then there'll be the issue of the line-endings. If the log
file on the server uses '\n' for the line endings and you're using
'\r\n' then os.path.getsize('games_mp.log') will return a larger size
then you expect. In that case, could ftp.retrbinary() be complaining
because it's given you the entire file and then you're trying to
download from an offset that's beyond the end?

For example, suppose the file on the server contains just foo\n (4
bytes):

1. You open a file locally in text mode ('w').

2. You download the entire file, foo\n.

3. You write out the data, but because you've opened in text mode it
writes foo\r\n to the file. The local file size is now 5 bytes.

4. The loop means that you then try to download from offset 5, which is
beyond the end of the file on the server.

5. Error?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Retracing your steps in an interactive python env

2009-09-14 Thread Robert Kern

Steven D'Aprano wrote:

I wonder whether there's a third party module which will take the output 
of dis.dis and try to reverse engineer Python code from it?


There used to be decompyle, but it hasn't been kept up-to-date, at least not 
publicly. There used to be a service that would use an updated decompyle on your 
uploaded bytecode through the web for a fee, but I don't know of anyone who used 
it. It always seemed a little shady to me.


--
Robert Kern

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

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


How to improve this code?

2009-09-14 Thread Oltmans
Hello,

Is there someway I can improve the following code(pythonically)?
(Copying from IDLE)
match=[1,2,3,4,5]

def elementsPresent(aList):
result=False
if not aList:
return False
for e in aList:
if e in match:
result=True
else:
result = False
return result
 elementsPresent([6,7,8,9,5]) # should return True because 5 is
present in list named match.

Is there somehow I can improve code in elementsPresent()? I'm not a
very good programmer but I sense that idea of using a variable named
'result' inside elementsPresent() doesn't sound very good. Any ideas
will be highly appreciated.

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


Re: How to improve this code?

2009-09-14 Thread Diez B. Roggisch

Oltmans schrieb:

Hello,

Is there someway I can improve the following code(pythonically)?
(Copying from IDLE)
match=[1,2,3,4,5]

def elementsPresent(aList):
result=False
if not aList:
return False
for e in aList:
if e in match:
result=True
else:
result = False
return result
 elementsPresent([6,7,8,9,5]) # should return True because 5 is
present in list named match.

Is there somehow I can improve code in elementsPresent()? I'm not a
very good programmer but I sense that idea of using a variable named
'result' inside elementsPresent() doesn't sound very good. Any ideas
will be highly appreciated.


1) don't use a global variable for your function. Pass both parameters
2) make the lookup O(1) instead O(n) for you match by using a set
3) stop when something is found
4) Unless you want the code to be working with things that are not a 
list, but False, the first if is superflous



def elementsPresent(aList, match):
match = set(match)
for item in aList:
if item in match:
return True
return False


It might actually be that turning both lists to sets  checking if these 
overlap is faster because it's in pure C.



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


python decimals

2009-09-14 Thread Andrew Svetlov
Is there some kind of python binding for decNumber library?
Standard decimal.Decimal is good enough, but very slow.
My current project toughly coupled with 'currency' operations and we
have performance problems related to decimal calculations.
From my perspective decNumber is fast and has well wide domain to
represent and process all required set of numbers - we don't need to
work with 'almost infinite numbers' as python decimal can.
I tried to google for desired binding - but found nothing.
gmpy is interesting project, but supported types is not exactly what
we need - rationals and big floats is not decimals in fixed point
notation.
My team discussed about making own python binding of decNumber - but
before we start this task I like to ask python community: is there
existing implementation? I don't want to invent the wheel again.

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


Re: How to improve this code?

2009-09-14 Thread André
On Sep 14, 10:16 pm, Diez B. Roggisch de...@nospam.web.de wrote:
 Oltmans schrieb:



  Hello,

  Is there someway I can improve the following code(pythonically)?
  (Copying from IDLE)
  match=[1,2,3,4,5]

  def elementsPresent(aList):
     result=False
     if not aList:
             return False
     for e in aList:
             if e in match:
                     result=True
             else:
                     result = False
     return result
   elementsPresent([6,7,8,9,5]) # should return True because 5 is
  present in list named match.

  Is there somehow I can improve code in elementsPresent()? I'm not a
  very good programmer but I sense that idea of using a variable named
  'result' inside elementsPresent() doesn't sound very good. Any ideas
  will be highly appreciated.

 1) don't use a global variable for your function. Pass both parameters
 2) make the lookup O(1) instead O(n) for you match by using a set
 3) stop when something is found
 4) Unless you want the code to be working with things that are not a
 list, but False, the first if is superflous

 def elementsPresent(aList, match):
      match = set(match)
      for item in aList:
          if item in match:
              return True
      return False

 It might actually be that turning both lists to sets  checking if these
 overlap is faster because it's in pure C.

 Diez

Here's an example using sets:

 def is_present(list_1, list_2):
...if set(list_1).intersection(set(list_2)):
...   return True
...return False
...
 is_present([1,2,3], [4,5,6])
False
 is_present([1,2,3], [0,2,4])
True


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


Re: VT100 in Python

2009-09-14 Thread exarkun

On 09:29 am, n...@craig-wood.com wrote:

Wolfgang Rohdewald wolfg...@rohdewald.de wrote:

 On Sunday 13 September 2009, Nadav Chernin wrote:
 I'm writing program that read data from some instrument trough
  RS232. This instrument send data in VT100 format. I need only to
  extract the text without all other characters that describe how to
  represent data on the screen. Is there some library in python for
  converting VT100 strings?

 that should be easy using regular expressions


At a basic level parsing VT100 is quite easy, so you can get rid of
the VT100 control.  They start with ESC, have other characters in the
middle then end with a letter (upper or lowercase), so a regexp will
make short work of them.  Something like r\x1B[^A-Za-z]*[A-Za-z]

You might need to parse the VT100 stream as VT100 builds up a screen
buffer though and the commands don't always come out in the order you
might expect.

I think twisted has VT100 emulator, but I couldn't find it in a brief
search just now.


Yep, though it's one of the parts of Twisted that only has API 
documentation and a few examples, no expository prose-style docs.  If 
you're feeling brave, though:


http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalTransport.html

http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalProtocol.html

 http://twistedmatrix.com/projects/conch/documentation/examples/ (the 
insults section)


It's not really all that complicated, but without adequate docs it can 
still be tricky to figure things out.  There's almost always someone on 
IRC (#twisted on freenode) to offer real-time help, though.


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


Remove empty strings from list

2009-09-14 Thread Helvin
Hi,

Sorry I did not want to bother the group, but I really do not
understand this seeming trivial problem.
I am reading from a textfile, where each line has 2 values, with
spaces before and between the values.
I would like to read in these values, but of course, I don't want the
whitespaces between them.
I have looked at documentation, and how strings and lists work, but I
cannot understand the behaviour of the following:
line = f.readline()
line = line.lstrip() # take away whitespace at the 
beginning of the
readline.
list = line.split(' ') # split the str line into a list

# the list has empty strings in it, so now,
remove these empty strings
for item in list:
if item is ' ':
print 'discard these: ',item
index = list.index(item)
del list[index] # remove this 
item from the list
else:
print 'keep this: ',item
The problem is, when my list is :  ['44', '', '', '', '', '',
'0.0\n']
The output is:
len of list:  7
keep this:  44
discard these:
discard these:
discard these:
So finally the list is:   ['44', '', '', '0.0\n']
The code above removes all the empty strings in the middle, all except
two. My code seems to miss two of the empty strings.

Would you know why this is occuring?

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


Re: Remove empty strings from list

2009-09-14 Thread Chris Rebert
On Mon, Sep 14, 2009 at 6:49 PM, Helvin helvin...@gmail.com wrote:
 Hi,

 Sorry I did not want to bother the group, but I really do not
 understand this seeming trivial problem.
 I am reading from a textfile, where each line has 2 values, with
 spaces before and between the values.
 I would like to read in these values, but of course, I don't want the
 whitespaces between them.
 I have looked at documentation, and how strings and lists work, but I
 cannot understand the behaviour of the following:
                        line = f.readline()
                        line = line.lstrip() # take away whitespace at the 
 beginning of the
 readline.
                        list = line.split(' ') # split the str line into a list

                        # the list has empty strings in it, so now,
 remove these empty strings
                        for item in list:
                                if item is ' ':
                                        print 'discard these: ',item
                                        index = list.index(item)
                                        del list[index]         # remove this 
 item from the list
                                else:
                                        print 'keep this: ',item
 The problem is, when my list is :  ['44', '', '', '', '', '',
 '0.0\n']
 The output is:
    len of list:  7
    keep this:  44
    discard these:
    discard these:
    discard these:
 So finally the list is:   ['44', '', '', '0.0\n']
 The code above removes all the empty strings in the middle, all except
 two. My code seems to miss two of the empty strings.

 Would you know why this is occuring?

Block quoting from http://effbot.org/zone/python-list.htm

Note that the for-in statement maintains an internal index, which is
incremented for each loop iteration. This means that if you modify the
list you’re looping over, the indexes will get out of sync, and you
may end up skipping over items, or process the same item multiple
times.


Thus why your code is skipping over some elements and not removing them.
Moral: Don't modify a list while iterating over it. Use the loop to
create a separate, new list from the old one instead.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to improve this code?

2009-09-14 Thread Tim Chase

def elementsPresent(aList, match):
 match = set(match)
 for item in aList:
 if item in match:
 return True
 return False


This could be rewritten in Python2.5+ as

  def elementsPresent(aList, match):
match = set(match)
return any(elem in match for elem in aList)

though as suggested both places, the set intersection may be fastest.

-tkc



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


Re: Remove empty strings from list

2009-09-14 Thread tec

Chris Rebert 写道:

On Mon, Sep 14, 2009 at 6:49 PM, Helvin helvin...@gmail.com wrote:

Hi,

Sorry I did not want to bother the group, but I really do not
understand this seeming trivial problem.
I am reading from a textfile, where each line has 2 values, with
spaces before and between the values.
I would like to read in these values, but of course, I don't want the
whitespaces between them.
I have looked at documentation, and how strings and lists work, but I
cannot understand the behaviour of the following:
   line = f.readline()
   line = line.lstrip() # take away whitespace at the 
beginning of the
readline.
   list = line.split(' ') # split the str line into a list

   # the list has empty strings in it, so now,
remove these empty strings
   for item in list:
   if item is ' ':
   print 'discard these: ',item
   index = list.index(item)
   del list[index] # remove this 
item from the list
   else:
   print 'keep this: ',item
The problem is, when my list is :  ['44', '', '', '', '', '',
'0.0\n']
The output is:
   len of list:  7
   keep this:  44
   discard these:
   discard these:
   discard these:
So finally the list is:   ['44', '', '', '0.0\n']
The code above removes all the empty strings in the middle, all except
two. My code seems to miss two of the empty strings.

Would you know why this is occuring?


Block quoting from http://effbot.org/zone/python-list.htm

Note that the for-in statement maintains an internal index, which is
incremented for each loop iteration. This means that if you modify the
list you’re looping over, the indexes will get out of sync, and you
may end up skipping over items, or process the same item multiple
times.


Thus why your code is skipping over some elements and not removing them.
Moral: Don't modify a list while iterating over it. Use the loop to
create a separate, new list from the old one instead.


or use filter
list=filter(lambda x: len(x)0, list)



Cheers,
Chris
--
http://blog.rebertia.com

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


Re: Remove empty strings from list

2009-09-14 Thread tec

Helvin 写道:

Hi,

Sorry I did not want to bother the group, but I really do not
understand this seeming trivial problem.
I am reading from a textfile, where each line has 2 values, with
spaces before and between the values.
I would like to read in these values, but of course, I don't want the
whitespaces between them.
I have looked at documentation, and how strings and lists work, but I
cannot understand the behaviour of the following:
line = f.readline()
line = line.lstrip() # take away whitespace at the 
beginning of the
readline.
list = line.split(' ') # split the str line into a list

# the list has empty strings in it, so now,
remove these empty strings
for item in list:
if item is ' ':
print 'discard these: ',item
index = list.index(item)
del list[index] # remove this 
item from the list
else:
print 'keep this: ',item
The problem is, when my list is :  ['44', '', '', '', '', '',
'0.0\n']
The output is:
len of list:  7
keep this:  44
discard these:
discard these:
discard these:
So finally the list is:   ['44', '', '', '0.0\n']
The code above removes all the empty strings in the middle, all except
two. My code seems to miss two of the empty strings.

Would you know why this is occuring?

Regards,
Helvin


You can use the default argument of split:
list = line.split()

From the python documentation,

If the optional second argument sep is absent or None, the words are 
separated by arbitrary strings of whitespace characters (space, tab, 
newline, return, formfeed).


So it is suitable for most cases without introduce empty strings.
--
http://mail.python.org/mailman/listinfo/python-list


Incremental project based programming guide

2009-09-14 Thread bouncy...@gmail.com
I was wondering if anyone had actually designed their programming text around 
incremental parts of a project and then taken the results of the project at 
each chapter and created something of value. specifically in referwnce to 
python however other examples. ALl of education was around pointless and 
unapplicable theory texts for which I am reaping nothing. Surely someone has 
seen this in actiom to whit: ch1 design of problem ch2 design taken out of ch1 
then done in ch2 to take input/ output for a smaller part ch3 take info from 
chs 1...@2 to craft an answer that is from the same problemto a theoretical 
chapter say 30 with a gui or some such. deitel and associates were 
unfortunately part of some of my worst exampes--drills applenty with little to 
no application. much appreciated towards python application and thanks in 
advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove empty strings from list

2009-09-14 Thread Helvin Lui
Thanks Chris! Thanks for the quick reply. Indeed this is the case! I have
now written out a new list, instead of modifying the list I am iterating
over.
Logged at my blog:
http://learnwithhelvin.blogspot.com/2009/09/python-loop-and-modify-list.html

Regards,
Helvin  =)

On Tue, Sep 15, 2009 at 1:55 PM, Chris Rebert c...@rebertia.com wrote:

 On Mon, Sep 14, 2009 at 6:49 PM, Helvin helvin...@gmail.com wrote:
  Hi,
 
  Sorry I did not want to bother the group, but I really do not
  understand this seeming trivial problem.
  I am reading from a textfile, where each line has 2 values, with
  spaces before and between the values.
  I would like to read in these values, but of course, I don't want the
  whitespaces between them.
  I have looked at documentation, and how strings and lists work, but I
  cannot understand the behaviour of the following:
 line = f.readline()
 line = line.lstrip() # take away whitespace at the
 beginning of the
  readline.
 list = line.split(' ') # split the str line into a
 list
 
 # the list has empty strings in it, so now,
  remove these empty strings
 for item in list:
 if item is ' ':
 print 'discard these: ',item
 index = list.index(item)
 del list[index] # remove
 this item from the list
 else:
 print 'keep this: ',item
  The problem is, when my list is :  ['44', '', '', '', '', '',
  '0.0\n']
  The output is:
 len of list:  7
 keep this:  44
 discard these:
 discard these:
 discard these:
  So finally the list is:   ['44', '', '', '0.0\n']
  The code above removes all the empty strings in the middle, all except
  two. My code seems to miss two of the empty strings.
 
  Would you know why this is occuring?

 Block quoting from http://effbot.org/zone/python-list.htm
 
 Note that the for-in statement maintains an internal index, which is
 incremented for each loop iteration. This means that if you modify the
 list you’re looping over, the indexes will get out of sync, and you
 may end up skipping over items, or process the same item multiple
 times.
 

 Thus why your code is skipping over some elements and not removing them.
 Moral: Don't modify a list while iterating over it. Use the loop to
 create a separate, new list from the old one instead.

 Cheers,
 Chris
 --
 http://blog.rebertia.com




-- 
Helvin

Though the world may promise me more, I'm just made to be filled with the
Lord.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: VT100 in Python

2009-09-14 Thread bouncy...@gmail.com


I hate to ask but what kind of device.and what`s with all the `insult` 
strings? - gimmick?

--Original Message--
From: exar...@twistedmatrix.com
To: python-list@python.org
Date: Mon, 14 Sep 2009 01:43:11 PM +
Subject: Re: VT100 in Python

On 09:29 am, n...@craig-wood.com wrote:
Wolfgang Rohdewald wolfg...@rohdewald.de wrote:
  On Sunday 13 September 2009, Nadav Chernin wrote:
  I'm writing program that read data from some instrument trough
   RS232. This instrument send data in VT100 format. I need only to
   extract the text without all other characters that describe how to
   represent data on the screen. Is there some library in python for
   converting VT100 strings?

  that should be easy using regular expressions

At a basic level parsing VT100 is quite easy, so you can get rid of
the VT100 control.  They start with ESC, have other characters in the
middle then end with a letter (upper or lowercase), so a regexp will
make short work of them.  Something like r\x1B[^A-Za-z]*[A-Za-z]

You might need to parse the VT100 stream as VT100 builds up a screen
buffer though and the commands don't always come out in the order you
might expect.

I think twisted has VT100 emulator, but I couldn't find it in a brief
search just now.

Yep, though it's one of the parts of Twisted that only has API 
documentation and a few examples, no expository prose-style docs.  If 
you're feeling brave, though:

http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalTransport.html

http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalProtocol.html

  http://twistedmatrix.com/projects/conch/documentation/examples/ (the 
insults section)

It's not really all that complicated, but without adequate docs it can 
still be tricky to figure things out.  There's almost always someone on 
IRC (#twisted on freenode) to offer real-time help, though.

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

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


Re: Remove empty strings from list

2009-09-14 Thread Dave Angel

Helvin wrote:

Hi,

Sorry I did not want to bother the group, but I really do not
understand this seeming trivial problem.
I am reading from a textfile, where each line has 2 values, with
spaces before and between the values.
I would like to read in these values, but of course, I don't want the
whitespaces between them.
I have looked at documentation, and how strings and lists work, but I
cannot understand the behaviour of the following:
line = f.readline()
line = line.lstrip() # take away whitespace at the 
beginning of the
readline.
list = line.split(' ') # split the str line into a list

# the list has empty strings in it, so now,
remove these empty strings
for item in list:
if item is ' ':
print 'discard these: ',item
index = list.index(item)
del list[index] # remove this 
item from the list
else:
print 'keep this: ',item
The problem is, when my list is :  ['44', '', '', '', '', '',
'0.0\n']
The output is:
len of list:  7
keep this:  44
discard these:
discard these:
discard these:
So finally the list is:   ['44', '', '', '0.0\n']
The code above removes all the empty strings in the middle, all except
two. My code seems to miss two of the empty strings.

Would you know why this is occuring?

Regards,
Helvin

  
(list already is a defined name, so you really should call it something 
else.



As Chris says, you're modifying the list while you're iterating through 
it, and that's undefined behavior.  Why not do the following?


mylist = line.strip().split(' ')
mylist = [item for item in mylist if item]

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


Re: VT100 in Python

2009-09-14 Thread Jerry Hill
On Mon, Sep 14, 2009 at 10:58 PM, bouncy...@gmail.com
bouncy...@gmail.com wrote:
 From: exar...@twistedmatrix.com
 http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalTransport.html
 http://twistedmatrix.com/documents/current/api/twisted.conch.insults.insults.ITerminalProtocol.html

  http://twistedmatrix.com/projects/conch/documentation/examples/ (the
 insults section)

  what`s with all the `insult` strings? - gimmick?

I think that 'insults' is twisted's replacement for curses.

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


Re: New Tkinter windows don't get focus on OS X

2009-09-14 Thread Joshua Bronson
On Sep 11, 3:53 am, eb303 eric.bru...@pragmadev.com wrote:
 For the OP: the problem comes from the tcl/tk level. Running a tcl
 script just opening a window from the terminal shows the same
 behaviour. You might want to forward the question to the tcl guys.

Done:
https://sourceforge.net/mailarchive/forum.php?thread_name=299cc2dd0909141604t5013feddkd6e82c0120d38c6a%40mail.gmail.comforum_name=tcl-mac
-- 
http://mail.python.org/mailman/listinfo/python-list


AttributeError: 'NoneType' object has no attribute 'get_text'

2009-09-14 Thread Raji Seetharaman
-- Forwarded message --
 From: MRAB pyt...@mrabarnett.plus.com
 To: python-list@python.org
 Date: Sun, 13 Sep 2009 19:44:30 +0100
 Subject: Re: AttributeError: 'NoneType' object has no attribute 'get_text'
 Raji Seetharaman wrote:

 Hi all,
 i did a small gui addressbook application using pygtk, python, mysql db.
 It was successful.
 I tried the same application with glade. But i ended up with errors.
 I desgined the code as follows.
 1.It has one main window and four child dialogs.
 2.In the main window, i have to fill in the text entry widget  if i press
 'add', the data will get inserted into the database.This works fine.
 3. If showdialog button is clicked, a child dialog appears, where i have
 to enter old entry to update.
 4. To update, i again use the main window, where i get the following error
  Traceback (most recent call last):
  File addressbookglade.py, line 63, in update
self.ssn = self.wTree.get_widget(ssn).
 get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

 Also i already set the name in properties window.  It works fine for add
 option. But not for update option.
 Im using the same window for both add and update.

 The code is available here http://pastebin.com/m28a4747e
 The glade xml file is here http://pastebin.com/m1af61a29
 The screenshot of my glade windows are here
 http://www.flickr.com/photos/raji_me/?saved=1
  It works fine for add option. But not for update option. Im using the
 same window for both add and update.

  You're using instance attributes a lot where I think local variables
 would be better, eg self.ssn instead of just ssn.

 In the '__init__' method you have:

self.wTree = gtk.glade.XML(self.gladefile,mainWindow)

 and then in the 'view' method you have:

self.wTree = gtk.glade.XML(self.gladefile,viewdialog)

 In both the 'add' and 'update' methods you have:

self.ssn = self.wTree.get_widget(ssn).get_text()

 so I suspect that the following is happening:

 1. __init__ makes self.wTree refer to 'mainWindow';

 2. You click on the Add button, the 'add' method is called, and the
 self.ssn =  line looks for the ssn widget in 'mainWindow';

 3. You click on the OK(?) button and view what's just been added;

 4. The 'view' method makes self.wTree refer to 'viewdialog';

 5. You click on the Update button, the 'update' method is called, and the
 self.ssn =  line looks for the ssn widget in 'viewdialog'.


 I'll use local variables. Yes the self.ssn =  line looks for the 'ssn'
 widget in 'viewdialog'

How to set the self.ssn =  in update method to the mainWindow ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove empty strings from list

2009-09-14 Thread Gabriel Genellina

En Mon, 14 Sep 2009 23:33:05 -0300, tec technic@gmail.com escribió:


or use filter
list=filter(lambda x: len(x)0, list)


For strings, len(x)0 = len(x) = x, so the above statement is  
equivalent to:


list=filter(lambda x: x, list)

which according to the documentation is the same as:

list=filter(None, list)

which is the fastest variant AFAIK.

(Of course, it's even better to use the right split() call so there is no  
empty strings to filter out in the first place)


--
Gabriel Genellina

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


Re: Retracing your steps in an interactive python env

2009-09-14 Thread TerryP
Under unix and cygwin, it's also possible to use GNU Screen, along
with a much larger then default defscrollback value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove empty strings from list

2009-09-14 Thread Steven D'Aprano
On Mon, 14 Sep 2009 18:55:13 -0700, Chris Rebert wrote:

 On Mon, Sep 14, 2009 at 6:49 PM, Helvin helvin...@gmail.com wrote:
...
  I have looked at documentation, and how strings and lists work, but I
  cannot understand the behaviour of the following:
...
                         for item in list:
                                 if item is ' ':
                                         print 'discard these: ',item
                                         index = list.index(item)
                                         del list[index]

...

 Moral: Don't modify a list while iterating over it. Use the loop to
 create a separate, new list from the old one instead.


This doesn't just apply to Python, it is good advice in every language 
I'm familiar with. At the very least, if you have to modify over a list 
in place and you are deleting or inserting items, work *backwards*:

for i in xrange(len(alist), -1, -1):
item = alist[i]
if item == 'delete me':
del alist[i]


This is almost never the right solution in Python, but as a general 
technique, it works in all sorts of situations. (E.g. when varnishing a 
floor, don't start at the doorway and varnish towards the end of the 
room, because you'll be walking all over the fresh varnish. Do it the 
other way, starting at the end of the room, and work backwards towards 
the door.)

In Python, the right solution is almost always to make a new copy of the 
list. Here are three ways to do that:


newlist = []
for item in alist:
if item != 'delete me':
 newlist.append(item)


newlist = [item for item in alist if item != 'delete me']

newlist = filter(lambda item: item != 'delete me', alist)



Once you have newlist, you can then rebind it to alist:

alist = newlist

or you can replace the contents of alist with the contents of newlist:

alist[:] = newlist


The two have a subtle difference in behavior that may not be apparent 
unless you have multiple names bound to alist.



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


MayaVi install

2009-09-14 Thread Gib
I am trying to follow the instructions for installing MayaVi  given on
the Enthought site:
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/installation.html
I'm following the step-by-step instructions to install with eggs under
Windows.  When I get to this point:
easy_install Sphinx EnvisageCore EnvisagePlugins configobj
Sphinx 0.6.3 is installed OK, but when envisagecore 3.1.1 is being
installed, after doing a few steps it fails with the message:
error: Setup script exited with error: Unable to find vcvarsall.bat

A search showed that vcvarsall.bat is where you might expect to find
it, in
C:\Program Files\Microsoft Visual Studio 8\VC
I'm not sure what to do now.
-- 
http://mail.python.org/mailman/listinfo/python-list


VTK install

2009-09-14 Thread Gib
As part of the MayaVi install, I need to install VTK.  Follwoing the
Enthought instructions, I went here:
http://cpbotha.net/2009/08/13/python-2-6-enabled-vtk-5-4-windows-binaries/
and installed vtk-5.4.  I modified the PATH and also created an
environment variable PYTHONPATH as directed, setting it to be C:
\Program Files\VTK\bin; C:\Program Files\VTK\lib\site-packages;
According to Botha's instructions, I should now be able to do 'import
vtk', but this doesn't work: no module named vtk.

Since VTK appears to be installed, I'm guessing that either the path
setting is wrong, or python is not using PYTHONPATH.  How can I check
that PYTHONPATH is being used?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Remove empty strings from list

2009-09-14 Thread Join hack
good solution ,thanks~!

2009/9/15 Steven D'Aprano ste...@remove.this.cybersource.com.au

 On Mon, 14 Sep 2009 18:55:13 -0700, Chris Rebert wrote:

  On Mon, Sep 14, 2009 at 6:49 PM, Helvin helvin...@gmail.com wrote:
 ...
   I have looked at documentation, and how strings and lists work, but I
   cannot understand the behaviour of the following:
 ...
  for item in list:
  if item is ' ':
  print 'discard these: ',item
  index = list.index(item)
  del list[index]

 ...

  Moral: Don't modify a list while iterating over it. Use the loop to
  create a separate, new list from the old one instead.


 This doesn't just apply to Python, it is good advice in every language
 I'm familiar with. At the very least, if you have to modify over a list
 in place and you are deleting or inserting items, work *backwards*:

 for i in xrange(len(alist), -1, -1):
item = alist[i]
if item == 'delete me':
del alist[i]


 This is almost never the right solution in Python, but as a general
 technique, it works in all sorts of situations. (E.g. when varnishing a
 floor, don't start at the doorway and varnish towards the end of the
 room, because you'll be walking all over the fresh varnish. Do it the
 other way, starting at the end of the room, and work backwards towards
 the door.)

 In Python, the right solution is almost always to make a new copy of the
 list. Here are three ways to do that:


 newlist = []
 for item in alist:
if item != 'delete me':
 newlist.append(item)


 newlist = [item for item in alist if item != 'delete me']

 newlist = filter(lambda item: item != 'delete me', alist)



 Once you have newlist, you can then rebind it to alist:

 alist = newlist

 or you can replace the contents of alist with the contents of newlist:

 alist[:] = newlist


 The two have a subtle difference in behavior that may not be apparent
 unless you have multiple names bound to alist.



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

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


overrideredirect vs. text entry etc. widget

2009-09-14 Thread kernus
I just googled this post:

http://mail.python.org/pipermail/python-list/2006-September/575832.html

something like:

from Tkinter import *

root = Tk()
Entry(root).pack()
Button(root, text='Quit', command=sys.exit).pack()
root.overrideredirect(1)
root.mainloop()

the button works boths under linux(debian) and windows, but the entry
widget only works on windows, any idea?

I am making a skinnalbe music player, so the issue must be solved.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >