Re: compute the double square...... :(

2011-01-08 Thread Gary Herron

On 01/08/2011 10:10 PM, aregee wrote:

Double Squares
A double-square number is an integer X which can be expressed as the
sum of two perfect squares. For example, 10 is a double-square because
10 = 32 + 12. Your task in this problem is, given X, determine the
number of ways in which it can be written as the sum of two squares.
For example, 10 can only be written as 32 + 12 (we don't count 12 + 32
as being different). On the other hand, 25 can be written as 52 + 02
or as 42 + 32.


Huh?  In what number system does  10 = 32 + 12?
And how do either 32 or 12 qualify as perfect squares?

Gary Herron




Input
You should first read an integer N, the number of test cases. The next
N lines will contain N values of X.
Constraints
0 ≤ X ≤ 2147483647
1 ≤ N ≤ 100
Output
For each value of X, you should output the number of ways to write X
as the sum of two square

Is the code mention below solution to this question  what is the
fault...
Error :
are...@aregee-laptop:~/Desktop$ python pie.py
enter a number::10
pie.py:3: Deprecation Warning: integer argument expected, got float
   for b in range(0,(x**0.5)/2):

#Double square

x = input("enter a number::")
for b in range(0,(x**0.5)/2):
   a = (x-(b**2))**0.5
try:
   a = int(a)
except:
   print("not an integer")
   exit(1)

   count = 0;
   count = count + 1;
if (x == a**2 + b**2):

   print "double square"



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


Re: compute the double square...... :(

2011-01-08 Thread Corey Richardson
On 01/09/2011 01:10 AM, aregee wrote:
> 
> Double Squares
> A double-square number is an integer X which can be expressed as the
> sum of two perfect squares. For example, 10 is a double-square because
> 10 = 32 + 12. Your task in this problem is, given X, determine the
> number of ways in which it can be written as the sum of two squares.
> For example, 10 can only be written as 32 + 12 (we don't count 12 + 32
> as being different). On the other hand, 25 can be written as 52 + 02
> or as 42 + 32.
> 
> Input
> You should first read an integer N, the number of test cases. The next
> N lines will contain N values of X.
> Constraints
> 0 ≤ X ≤ 2147483647
> 1 ≤ N ≤ 100
> Output
> For each value of X, you should output the number of ways to write X
> as the sum of two square
> 
> Is the code mention below solution to this question  what is the
> fault...
> Error :
> are...@aregee-laptop:~/Desktop$ python pie.py
> enter a number::10
> pie.py:3: Deprecation Warning: integer argument expected, got float
>   for b in range(0,(x**0.5)/2):
That says it all. You can't use a float in range(), use int(x ** 0.5) if
that's what you need, but the behavior won't be the same. My suggestion
would be to try to find a different way to do it.
> 
> #Double square
> 
> x = input("enter a number::")
> for b in range(0,(x**0.5)/2):
>   a = (x-(b**2))**0.5
> try:
>   a = int(a)
> except:
>   print("not an integer")
>   exit(1)
> 
Here it would be better to use:
if type(a) != int
print("Not an integer")
exit(1)
>   count = 0;
>   count = count + 1;
> if (x == a**2 + b**2):
> 
>   print "double square"

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


compute the double square...... :(

2011-01-08 Thread aregee

Double Squares
A double-square number is an integer X which can be expressed as the
sum of two perfect squares. For example, 10 is a double-square because
10 = 32 + 12. Your task in this problem is, given X, determine the
number of ways in which it can be written as the sum of two squares.
For example, 10 can only be written as 32 + 12 (we don't count 12 + 32
as being different). On the other hand, 25 can be written as 52 + 02
or as 42 + 32.

Input
You should first read an integer N, the number of test cases. The next
N lines will contain N values of X.
Constraints
0 ≤ X ≤ 2147483647
1 ≤ N ≤ 100
Output
For each value of X, you should output the number of ways to write X
as the sum of two square

Is the code mention below solution to this question  what is the
fault...
Error :
are...@aregee-laptop:~/Desktop$ python pie.py
enter a number::10
pie.py:3: Deprecation Warning: integer argument expected, got float
  for b in range(0,(x**0.5)/2):

#Double square

x = input("enter a number::")
for b in range(0,(x**0.5)/2):
  a = (x-(b**2))**0.5
try:
  a = int(a)
except:
  print("not an integer")
  exit(1)

  count = 0;
  count = count + 1;
if (x == a**2 + b**2):

  print "double square"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to read ansic file into a pre-defined class?

2011-01-08 Thread Tim Roberts
Ying Zu  wrote:
>
>How to read ansic file into a pre-defined class?

This is not an "ansic" file.  It's just a plain old data file.

>I have a series of files written in the following format,
>
>2 # number of classes
>100   # number of items for the first class object 
>0   foo
>1   foo
>...
>99  foo
>150   # number of items for the second class object 
>0   bar
>1   bar
>...
>149 bar
>
>ultimately I want to read the file to two *structs* (sorry for my C
>jargon, just started playing with Python), with attributes
>number_of_items and data_array.
>
>I wrote a simply code to read and split each line into a list, then
>try to tell the meaning of each line by the number of elements of
>each line list and the its position in the file. But it is
>definitely not the way Python should be used.

You don't really need to count the number of elements.  The file tells you
how many of each to expect.  This works:

   numclasses = int(f.next().strip())
   classlist = []
   for i in range(numclasses):
  numitems = int(f.next().strip())
  classlist.append(
  [f.next().strip().split() for j in range(numitems)]
  )

Then len(classlist) tells you how many classes.  len(classlist[0]) tells
you how many items in the first class.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: surprised by import in python 2.6

2011-01-08 Thread Aahz
In article ,
Stefaan Himpe   wrote:
>
>Recently someone asked me this question, to which I could not give an 
>answer. I'm hoping for some insight, or a manual page. What follows is 
>python 2.6.
>
>The problem is with the difference between
>
>from test import *
>
>and
>
>import test

Just adding to this thread for Gooja:

Don't use "import *" -- it makes debugging difficult because you can't
tell where a name comes from.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Think of it as evolution in action."  --Tony Rand
-- 
http://mail.python.org/mailman/listinfo/python-list


Create a class to position a window on the screen.

2011-01-08 Thread Rohit Coder

Hi,elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility
I am new to Python and this is my fist Python class. I am using PyQt4 framework 
on Windows 7.
I don't know whether the code below is correctly written or not. I want to 
modify it further as:
 1. In the arguments, I want to pass the name of another opened Window (.py) on 
the screen. 2. I want to pass the x-coord., y-coord. and the name of the window 
to position on the screen.
How to modify the code to fulfill these requirements?
**Attempted Code**
class PositionWindow:def __init__(self, xCoord, yCoord, windowName, 
parent = None):  self.x = xCoord  self.y = yCoord  
self.wName = windowName;def center(self):screen 
= QtGui.QDesktopWidget().screenGeometry()size = self.geometry() 
   self.move((screen.width()-size.width())/2, 
(screen.height()-size.height())/2)
...Rohit.
  -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-08 Thread Terry Reedy

On 1/8/2011 5:48 PM, Roy Smith wrote:

In article,
  Terry Reedy  wrote:



Import from another file in /home/roy. (since '.' is part of sys.path).
Or put module or package of modules in Lib/site-packages.
But why the horror of modifying sys.path? It is normal proceedure.


Not quite horror, but since I already know the absolute path to the
file, it seems silly to change the search path just so import can use it
to search.  Also, if I change the search path, I risk other things
finding my module by mistake (if there's a module name collision).


Ben Finney asked you the right question. If config.py is the only .py 
file in .../autogen/, which I infer from your responses, you could 
.pop() .../autogen after the append and import. Or open config.py and 
use imp.load_module, being careful to get all the args correct. In 
either case, if I had a startup module or utility module that is 
imported right away, I would do the import with extra code there, just 
once. Then, either refer to util.config after importing util in other 
modules, or just do 'import config'. The latter should work because 
import first looks for already imported modules (in sys.modules). When 
the module is already there, 'import x' reduces to "x = sys.modules['x']".


--
Terry Jan Reedy

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


PyCon 2011 - Full talk and tutorial list now available, registration open!

2011-01-08 Thread Jesse Noller
I'm very pleased to announce, on behalf of the PyCon 2011 Program
committee, and entire PyCon 2011 volunteer staff, that the full list
of PyCon 2011 talks is now public, and available!

This was an especially hard year for the PyCon program committee: we
had over 200 proposals for only 95 total slots, so we ended up having
to reject a lot of excellent proposals. We've spent the better part of
the last few months in reviews, meetings and debates selecting which
talks would be in the final PyCon program. It was not and easy task -
all of the proposal authors really came through in their proposals -
the number of high quality proposals we had to chose from was simply
staggering.

That said - the program committee completed it's work yesterday
morning. Acceptance and rejection letters have been sent, and you can
now view the full program on the site:

http://us.pycon.org/2011/schedule/lists/talks/

This obviously complements the list of tutorials also available:

http://us.pycon.org/2011/schedule/lists/tutorials/

Personally, this is my second year acting as the Program Committee
chair (and hence, my last) - and between the talk list, and the list
of tutorials, our current keynote speaker
(http://us.pycon.org/2011/home/keynotes/) and the emerging line of up
poster sessions - I'm extremely proud to have been part of the
process, and extremely excited about the upcoming conference. It is
going to be amazing

One behalf of the entire PyCon 2011 staff, I want to again thank every
single talk author for their submission(s), and I look forward to
seeing all of you, and them at the conference. PyCon is an amazing
conference only because of the quality talks, tutorials and community
we have. I'm confident this one will knock it out of the park.

As a reminder: Early Bird registration
(http://us.pycon.org/2011/tickets/) closes January 17th - and we have
an attendance cap of 1500 total attendees (speakers are counted
against this number, and guaranteed a slot) so be sure to register
today!

Jesse Noller
PyCon 2011
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-08 Thread Roy Smith
In article ,
 Terry Reedy  wrote:

> 
> Import from another file in /home/roy. (since '.' is part of sys.path).
> Or put module or package of modules in Lib/site-packages.
> But why the horror of modifying sys.path? It is normal proceedure.

Not quite horror, but since I already know the absolute path to the 
file, it seems silly to change the search path just so import can use it 
to search.  Also, if I change the search path, I risk other things 
finding my module by mistake (if there's a module name collision).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-08 Thread Roy Smith
In article <877heff4fl@benfinney.id.au>,
 Ben Finney  wrote:

> Roy Smith  writes:
> 
> > If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is
> > there a way to import that as a module WITHOUT modifying sys.path? I'm
> > using Python 2.6.
> 
> Importing a module with ‘import’ is done by using the module's name,
> which is only *incidentally* related to its filesystem path.
> 
> What is the problem you're trying to solve? It is likely we can suggest
> a better solution.

Well, the problem I'm trying to solve is that I have an absolute 
pathname to a python source file that I want to import as a module :-)

I'm working on a project where developers will typically have several 
sandboxes, with different versions of the code.  There's a config file 
(which I have no control over) which defines a big multi-level dict 
containing configuration options:

config = {
'memcache_servers' : ['localhost'],
'build_type' : 'development',
 'thrift_configs' : {
   'SearchService' : {'hosts' : ['localhost'],
  'sendTimeout' : 300,
  'port' : 9192,
  'recvTimeout' : 3000
  },
 }
 }

and so on.  The file is auto-generated by some huge pile of perl scripts 
which also generates the same information in a forms ingestible by perl, 
PHP, Java, shell scripts, etc.  Not how I would have designed it, but it 
is what it is.

The best I can describe how to find the location of the config file is, 
"Work your way up the directory tree from where you are now, (i.e. 
following '..' links) until you get to the top level of the project, 
then from there, it's ./code/configs/autogen/config.py."

It's reasonably straight-forward to figure out that absolute path, 
starting from sys.argv[0] and using the tools in os.path.  Now I need to 
import the file, given that I know its absolute pathname.  It looks like 
imp.load_source() does what I want, I'm just wondering if there's a 
cleaner way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list displays

2011-01-08 Thread Steven D'Aprano
On Sat, 08 Jan 2011 22:57:45 +0100, Olive wrote:

> I am a newbie to python. Python supports what I thinks it is called list
> display, for example:
> 
> [i for i in range(10)]
> [i for i in range(10) if i<6]

This is called a list comprehension, not list display.


> Does anyone know a good documentation for this. I have read the language
> reference but it is confusing.

A list comprehension is syntactic sugar for a for loop. If you start with 
code looking like this:

storage = []
for i in range(10):
if i < 6:
storage.append(i)


you can re-write this as a list comprehension:

storage = [i for i in range(10) if i < 6]

The source doesn't have to be range, it can be any sequence or iterator:

lengths = [len(obj) for obj in my_list_of_objects]
# like map(len, my_list_of_objects)


If you are mathematically inclined, you might also like this analogy: the 
syntax for a list comprehension is similar to that of sets in mathematics.

[f(x) for x in D]

is similar to: 

{ f(x) ∀ x ∈ D }
("the set of f(x) for all x element of D")


Don't waste your time with list comprehensions that just walk over the 
source, doing nothing. For example:

[i for i in range(10)]

Just use list(range(10)) instead.


Where list comps get complicated is when you combine them. Nested list 
comps are not too bad, although they can get messy:


[len(s) for s in [str(x) for x in [2**n for n in range(10)]]]


That's the same as:

powers_of_two = [2**n for n in range(10)]
strings = [str(x) for x in powers_of_two]
lengths = [len(s) for s in strings]


But what do you make of this?


[a*b for a in range(3) for b in range(4)]

This is like a nested for-loop:

results = []
for a in range(3):
for b in range(4):
results.append(a*b)


Hope this helps.


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


Re: list displays

2011-01-08 Thread Chris Rebert
On Sat, Jan 8, 2011 at 1:57 PM, Olive  wrote:
> I am a newbie to python. Python supports what I thinks it is called
> list display, for example:
>
> [i for i in range(10)]
> [i for i in range(10) if i<6]
>
> Does anyone know a good documentation for this. I have read the
> language reference but it is confusing.

You may find the translation to equivalent list-comprehension-free
code in 
http://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions
helpful.

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


Re: list displays

2011-01-08 Thread Daniel da Silva
They're called "List Comprehensions"
http://docs.python.org/tutorial/datastructures.html#list-comprehensions



On Sat, Jan 8, 2011 at 4:57 PM, Olive  wrote:

> I am a newbie to python. Python supports what I thinks it is called
> list display, for example:
>
> [i for i in range(10)]
> [i for i in range(10) if i<6]
>
> Does anyone know a good documentation for this. I have read the
> language reference but it is confusing.
>
> Olive
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


list displays

2011-01-08 Thread Olive
I am a newbie to python. Python supports what I thinks it is called
list display, for example:

[i for i in range(10)]
[i for i in range(10) if i<6]

Does anyone know a good documentation for this. I have read the
language reference but it is confusing.

Olive  

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


Re: Absolute imports?

2011-01-08 Thread Ben Finney
Roy Smith  writes:

> If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is
> there a way to import that as a module WITHOUT modifying sys.path? I'm
> using Python 2.6.

Importing a module with ‘import’ is done by using the module's name,
which is only *incidentally* related to its filesystem path.

What is the problem you're trying to solve? It is likely we can suggest
a better solution.

> I've read PEP 328, and don't really understand how the absolute
> imports it's talking about are supposed to work. Should I be using
> imp.load_source()?

PEP 328 introduces a distinction between absolute imports and relative
imports. Before the implementation of PEP 328, it was impossible to
distinguish in the ‘import’ statement whether the import would be
absolute (i.e., from the directories listed in ‘sys.path’) or relative
(i.e., from the directory housing the current module).

I hope that clarifies. If you describe what you're trying to do and why
you want a different import behaviour, the answers might be more
directed to your actual situation.

-- 
 \“Spam will be a thing of the past in two years' time.” —Bill |
  `\ Gates, 2004-01-24 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-08 Thread Terry Reedy

On 1/8/2011 3:03 PM, Roy Smith wrote:

If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there
a way to import that as a module WITHOUT modifying sys.path?  I'm using
Python 2.6.


Import from another file in /home/roy. (since '.' is part of sys.path).
Or put module or package of modules in Lib/site-packages.
But why the horror of modifying sys.path? It is normal proceedure.


I've read PEP 328, and don't really understand how the absolute imports
it's talking about are supposed to work.


Those are the normal imports that start from a directory in sys.path. 
Relative imports (now) are ones that use '.'s to locate relative to the 
importing module. I have never done that. Purpose is to make a 
subpackage relocatable to another package without modification.



Should I be using imp.load_source()?


No idea, never done that. Try it if you want.

--
Terry Jan Reedy

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


Absolute imports?

2011-01-08 Thread Roy Smith
If I have an absolute path to a file (i.e. '/home/roy/foo.py'), is there 
a way to import that as a module WITHOUT modifying sys.path?  I'm using 
Python 2.6.

I've read PEP 328, and don't really understand how the absolute imports 
it's talking about are supposed to work.  Should I be using 
imp.load_source()?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: student question

2011-01-08 Thread Peter Pearson
On Fri, 7 Jan 2011 18:42:45 -0800 (PST), John  wrote:
 q_file = open(questions_location) #opens the document successfully
 for line in q_file:
>   print line
>
> # prints document successfully
 line
> # prints last line of document
 for line in q_file:
>   print line # prints nothing
>
> ...why does it print nothing?

open(filename) returns an iterator, not a list.  Once you
have exhausted the iterator, it stays exhausted.


-- 
To email me, substitute nowhere->spamcop, invalid->net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python app dev tools for Gnome?

2011-01-08 Thread Dan Stromberg
On Sat, Jan 8, 2011 at 8:07 AM, kj  wrote:
> There's a zillion utility apps that I've had kicking around in my
> head for years, but I've never implemented because I absolutely
> hate GUI programming.
>
> But I'm increasingly impressed by the quality, stability, and sheer
> number, of Gnome apps that I keep coming across that use Python
> under the hood.
>
> This gives me hope that maybe programming GUI Python apps for Gnome
> these days is no longer the traumatizing experience it used to be
> when I last tried it.
>
> Can someone recommend some good tools to speed up the development
> of Python apps[1] for Gnome?  E.g. is there anything like Xcode
> for Gnome+Python?
>
> TIA!
>
> ~kj
>
> [1] Needless to say, when I write "apps" I mean full-blown GUI
> apps: windows, menus, events, threads, clickable icon, the whole
> ball of wax.  As opposed to cli apps, panel widgets, etc.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Check out Glade (the standard answer), Illumination (a new tool that
has a very interesting design and goals), wxWindows (can run overtop
of GTK+, but is pretty different from PyGTK to program, and like
PyGTK, enables running on multiple desktop platforms), and pyjamas
(produces GTK GUI's using its own widget set overtop of GTK, and web
2.0 apps, from the same code).

Personally, I prefer to just code PyGTK GUI's manually, but I can't
help but be curious about Ilumination and pyjamas.

Illumination is at:
http://radicalbreeze.com/

...and it purportedly allows you to graphically build apps that run on
PyGTK, Android, iPhone (not mature last I heard), Windows, Haiku - all
automatically generated _from_a_single_description_, and I wouldn't be
surprised if it does more platforms than that by now.  It's been
getting a lot of buzz in the Android community, but if it lives up to
its design goals, it probably deserves buzz all over the place.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python app dev tools for Gnome?

2011-01-08 Thread Adam Tauno Williams
On Sat, 2011-01-08 at 16:07 +, kj wrote: 
> There's a zillion utility apps that I've had kicking around in my
> head for years, but I've never implemented because I absolutely
> hate GUI programming.
> But I'm increasingly impressed by the quality, stability, and sheer
> number, of Gnome apps that I keep coming across that use Python
> under the hood.
> This gives me hope that maybe programming GUI Python apps for Gnome
> these days is no longer the traumatizing experience it used to be
> when I last tried it.
> Can someone recommend some good tools to speed up the development
> of Python apps[1] for Gnome?  E.g. is there anything like Xcode
> for Gnome+Python?

I use Monodevelop for coding in Python, but I'm only writing server-side
Python.  While Monodevelop provides an excellent [possibly the best] Gtk
UI designer I believe that component only works for C#.


There are a variety of articles on the PyGTK
 site;  Glade is the UI designer you
probably want.





I've also found
 
which covers TreeViews which are the most tedious part of Gtk application 
development.

Note that, technically, Glade is deprecated and replaced with
GtkBuilder.  But I believe the application is still called Glade.

> [1] Needless to say, when I write "apps" I mean full-blown GUI
> apps: windows, menus, events, threads, clickable icon, the whole
> ball of wax.  As opposed to cli apps, panel widgets, etc.

Awesome;  although I've avoided [to do Python's myriad deployment
issues] Python for fat-client apps I'm becoming more and more tempted.

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


Re: filecmp.dircmp performance

2011-01-08 Thread Peter Otten
dads wrote:

> I'm creating a one way sync program, it's to automate backing up data
> over the wan from our shops to a server at head office. It uses
> filecmp.dircmp() but the performance seems poor to me.
> 
> for x in dc.diff_files:
> srcfp = os.path.join(src, x)
> self.fn777(srcfp)
> if os.path.isfile(srcfp):
> try:
> shutil.copy2(srcfp, dst)
> self.lg.add_diffiles(src, x)
> except Exception, e:
> self.lg.add_errors(e)
> 
> I tested it at a store which is only around 50 miles away on a 10Mbps
> line, the directory has 59 files that are under 100KB. When it gets to
> dc.diff_files it takes 15mins to complete. Looking at the filecmp.py
> it's only using os.stat, it seems excessively long.

As a baseline it would be interesting to see how long it takes to copy those 
59 files using system tools. 

However, there are efficient tools out there that work hard to reduce the 
traffic over the net which is likely to be the bottleneck. I suggest that 
you have have a look at

http://en.wikipedia.org/wiki/Rsync
-- 
http://mail.python.org/mailman/listinfo/python-list


Python app dev tools for Gnome?

2011-01-08 Thread kj



There's a zillion utility apps that I've had kicking around in my
head for years, but I've never implemented because I absolutely
hate GUI programming.

But I'm increasingly impressed by the quality, stability, and sheer
number, of Gnome apps that I keep coming across that use Python
under the hood.

This gives me hope that maybe programming GUI Python apps for Gnome
these days is no longer the traumatizing experience it used to be
when I last tried it.

Can someone recommend some good tools to speed up the development
of Python apps[1] for Gnome?  E.g. is there anything like Xcode
for Gnome+Python?

TIA!

~kj

[1] Needless to say, when I write "apps" I mean full-blown GUI
apps: windows, menus, events, threads, clickable icon, the whole
ball of wax.  As opposed to cli apps, panel widgets, etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


filecmp.dircmp performance

2011-01-08 Thread dads
I'm creating a one way sync program, it's to automate backing up data
over the wan from our shops to a server at head office. It uses
filecmp.dircmp() but the performance seems poor to me.

for x in dc.diff_files:
srcfp = os.path.join(src, x)
self.fn777(srcfp)
if os.path.isfile(srcfp):
try:
shutil.copy2(srcfp, dst)
self.lg.add_diffiles(src, x)
except Exception, e:
self.lg.add_errors(e)

I tested it at a store which is only around 50 miles away on a 10Mbps
line, the directory has 59 files that are under 100KB. When it gets to
dc.diff_files it takes 15mins to complete. Looking at the filecmp.py
it's only using os.stat, it seems excessively long.

code:
http://pastebin.com/QskXGDQT
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] pyxser-1.5.2r --- Python Object to XML serializer/deserializer

2011-01-08 Thread Daniel Molina Wegener
Hello Python Community.

I'm pleased to announce pyxser-1.5.2r, a python extension which
contains functions to serialize and deserialize Python Objects
into XML. This is a model based serializer. This release is
supports Python 2.4 to Python 2.5.

What can do this serializer?

* Serialization of cross references.
* Serialization of circular references.
* Preserves object references on deserialization.
* Custom serializations.
* Custom deserializations.
* Object attribute selection call-back.
* Serialization depth limit.
* Standards based serialization.
* Standards based XML validation using pyxser XML Schema.
* C14N based serialization, as optional kind of output.
* Model based XML serialization, represented on XML Schema
  and XML DTD.

The ChangeLog for this release is as follows:
-8<--8<--8<--8<-
1.5.2r (2011.01.08):

Daniel Molina Wegener 

* Added support for Python 2.4
* Replaced the use of the commands package by the
subprocess package on the setup script.
* On the next release will be added support
for Python 3.X ;)

Thanks to pyxser users for their feedback.
-8<--8<--8<--8<-


The project is hosted at:
http://sourceforge.net/projects/pyxser/

Where you can report bugs and have other options, like forums
mailing lists and access to the repository if you want to
contribute.

The web page for the project is located at:
http://coder.cl/products/pyxser/

PyPi entry is:
http://pypi.python.org/pypi/pyxser/1.5.2r

Best regards,
-- 
Daniel Molina Wegener 
System Programmer & Web Developer
Phone: +56 (2) 979-0277 | Blog: http://coder.cl/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: More Help with python .find fucntion

2011-01-08 Thread Keith Anthony
THanks ... I am new to Python ...

Comparing the result of find with -1 fixes the bug ... some
of the endobj start in the firt position ...

You're right about the lines ending in \n by accident,
EXCEPT in PDF files items are separated by obj <<\n
and endobj\n


-- 
- --- -- -
Posted with NewsLeecher v4.0 Final
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


Re: Error invalid syntax while statement

2011-01-08 Thread Terry Reedy



  15 print("counter: ", counter
  16
  17   while (end == 0):  #
<---returns syntax error on this while statement


Among other responses, there is no indent after print.
should be
print()
while x:
#now indent
--
Terry Jan Reedy

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