codecs.register_error for strict, unicode.encode() and str.decode()

2012-07-26 Thread Alan Franzoni
Hello,
I think I'm missing some piece here.

I'm trying to register a default error handler for handling exceptions
for preventing encoding/decoding errors (I know how this works and that
making this global is probably not a good practice, but I found this
strange behaviour while writing a proof of concept of how to let Python
work in a more forgiving way).

What I discovered is that register_error() for strict seems to work in
the way I expect for string decoding, not for unicode encoding.

That's what happens on Mac, Python 2.7.1 from Apple:

melquiades:tmp alan$ cat minimal_test_encode.py
# -*- coding: utf-8 -*-

import codecs

def handle_encode(e):
return (ASD, e.end)

codecs.register_error(strict, handle_encode)

print uà.encode(ascii)

melquiades:tmp alan$ python minimal_test_encode.py
Traceback (most recent call last):
  File minimal_test_encode.py, line 10, in module
uà.encode(ascii)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in
position 0: ordinal not in range(128)


OTOH this works properly:

melquiades:tmp alan$ cat minimal_test_decode.py
# -*- coding: utf-8 -*-

import codecs

def handle_decode(e):
return (uASD, e.end)

codecs.register_error(strict, handle_decode)

print à.decode(ascii)

melquiades:tmp alan$ python minimal_test_decode.py
ASDASD


What piece am I missing? The doc at 
http://docs.python.org/library/codecs.html says  For
encoding /error_handler/ will be called with a UnicodeEncodeError
http://docs.python.org/library/exceptions.html#exceptions.UnicodeEncodeError 
instance,
which contains information about the location of the error., is there
any reason why the standard strict handler cannot be replaced?


Thanks for any clue.

File links:
https://dl.dropbox.com/u/249926/minimal_test_decode.py
https://dl.dropbox.com/u/249926/minimal_test_encode.py

-- 
Alan Franzoni
contact me at public@[mysurname].eu

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


Re: Behaviour-based interface/protocol implementation?

2011-01-28 Thread Alan Franzoni
On Thu, Jan 27, 2011 at 11:41 PM, Daniel Urban urban.d...@gmail.com wrote:

 Actually it can. You don't have to modify the object, just check for
 the desired methods/signature/whatever. See for example the
 implementation of collections.Hashable.__subclasshook__ in _abcoll.py
 and the abc.ABCMeta.__instancecheck__ method.

Mmh, I don't get your examples (subclasshook checks for *classes*, not
instances, and ABCMeta is a metaclass whose instance is an ABC), but
after properly looking at the PEP (__instancecheck__ seems to be
poorly documented in python standard docs) I've seen that yes,
__instancecheck__ on an ABC can actually be used in place of
maybe_implemented_by and hooking into isinstance().

Thanks!


-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-27 Thread Alan Franzoni
On Wed, Jan 26, 2011 at 7:23 PM, Daniel Urban urban.d...@gmail.com wrote:
 That's just what I'd like and I suppose can't be currently done with
 current ABC, PyProtocols or zope.interface implementations, right?

 It can. With __instancecheck__ you can override isinstance. It is
 possible (for example) to write a subclass of abc.ABCMeta, which
 extends __instancecheck__ to use an _instancehook classmethod
 similarly to __subclasshook__. Then in your MyInterface class you can
 implement _instancehook to check for methods/signatures/whatever you
 want.

Yes, __instancecheck__ could be used as an alternative hook with
respect to maybe_implemented_by(), but there's no such logic for
signature checking. That's a minor detail, I think.


-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-27 Thread Alan Franzoni
On Thu, Jan 27, 2011 at 8:03 PM, Alan Franzoni mail...@franzoni.eu wrote:
 Yes, __instancecheck__ could be used as an alternative hook with
 respect to maybe_implemented_by(), but there's no such logic for
 signature checking. That's a minor detail, I think.

On the contrary, now that I double checked, it can't be used that way;
I don't want to modify the object I'm testing (it could be a third
party object) nor I want to force it to be registered as a certain
ABC; so __instancecheck__() is just useless here.


-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-27 Thread Alan Franzoni
On Thu, Jan 27, 2011 at 8:58 PM, Ethan Furman et...@stoneleaf.us wrote:
 When you signature check, do you mean counting the number of arguments, or
 actually checking argument types?

In order to check for argument types I should either assume type
annotation (python 3 only, optional) or parse the docstring for the
method, which might not be available or be out of sync.

I just want to check for method name, number and/or names of the
arguments. It might not be trivial in python because the very same
argument can be passed either as a positional or a kw argument, so

def method1(self, a, b):
...

def method1(self, c, d):
 ...

could satisfy or not the very same interface, depending whether the
args are passed as postional or kw.


-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-27 Thread Alan Franzoni
On Thu, Jan 27, 2011 at 10:30 PM, Carl Banks pavlovevide...@gmail.com wrote:
 Write some kind of signature proxy to do it.

I don't have a specific implementation idea yet, I see how that grows.

 Based on this thread, you have quite specific requirements, so it's
 doubtful someone else has implemented exactly what you want.

Yes, but asking is better than blinding reimplementing :-)

 And because it hasn't been mentioned in this thread yet--surprisingly--
 many people in Python prefer the EAFP strategy, Easier to Ask
 Forgiveness than Permission, that is, to just do it and handle the
 resulting exception:

 try:
    myobj.somemethod(somevalue)
 except AttributeError:
    # doesn't fit signature, so do nothing
    pass

Sure. That's an approach. But this has drawbacks.

- it violates the CQS principle:
http://en.wikipedia.org/wiki/Command-query_separation

- Maybe my interface has not just a single method, and I might want to
call multiple methods on my object. I need to check for all signatures
before proceeding.

-  When calling the method, if an exception is raised - either
AttributeError or TypeError most of the times - it could not be
generated from my own call, but from a call deeper into the stack;
It's easy to just think that object doesn't support that interface I
could mistake an object for not supporting an interface, and I could
silently swallow a true runtime exception instead. Maybe some stack
analysis could be performed, but I'd prefer to check as much as I can
*before* calling.

- Sometimes I'd like to group objects depending on their *behaviour*
(not their type), and then feed them somewhere else without actually
calling their methods. If I can know their behaviour just after
they've been called, it might be just too late.


-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-26 Thread Alan Franzoni
On Tue, Jan 25, 2011 at 6:48 PM, Terry Reedy tjre...@udel.edu wrote:
 This is correct!

 print(len(mo))
 TypeError: object of type 'MyObj' has no len()

That's interesting. I must admit I was not thinking about special
methods in my original post, I used that example just because of Chris
response.

by the way, define 'correct' - if that means 'that's how this works in
python', it's a tautology, not correctness :-)  Instead I think this
highlights an asymmetry in how python handles special methods, and
makes it less ducktyped than I wanted. Consider this:


class MyObject(object):
@staticmethod
def __len__():
return 1

mo = MyObject()
print mo.__len__
print len(mo)


class LenObj(object):
def __len__(self):
return 3

lo = LenObj()
print lo.__len__
print len(lo)

import types

class OtherObj(object):
pass

oo = OtherObj()

def __len__(self):
return 2


oo.__len__ = types.MethodType(__len__, oo, OtherObj)

print oo.__len__
print len(oo)

Output:
function __len__ at 0x1004bb938
1
bound method LenObj.__len__ of __main__.LenObj object at 0x1004ce510
3
bound method OtherObj.__len__ of __main__.OtherObj object at 0x1004ce590
Traceback (most recent call last):
  File pymethods.py, line 34, in module
print len(oo)
TypeError: object of type 'OtherObj' has no len()


The problem is not function attributes - the problem is that the
__len__() method must be set on the class, not on the instance. I
think this is not completely clear here:

http://docs.python.org/reference/datamodel.html


By the way, my original post didn't take into account special methods
- let's suppose they don't exist for a moment.

I'd just like to check *at runtime* whether an object *any object!*
respects a certain signature.

*I don't want to care about the class of that object because I want
true duck typing*. I mean, I should be able to pass *anything* that
responds to a certain contract:




@DuckType
class MyInterface(object):
def someMethod(self):
pass

def otherMethod(self, a, b):
pass



class SomeObj(object):
@classmethod
def someMethod(cls):
pass

@classmethod
def otherMethod(cls, a, b):
pass


class OtherObj(object):
def someMethod(self):
pass

def otherMethod(cls, a, b):
pass


class ThirdObj(object):
pass


oo = OtherObj()
to = ThirdObj()
to.someMethod = lambda: None
to.otherMethod = lambda a,b: None

MyInterface.maybe_implemented_by(oo) # - True
MyInterface.maybe_implemented_by(to) # - True
MyInterface.maybe_implemented_by(SomeObj) # - True



That's just what I'd like and I suppose can't be currently done with
current ABC, PyProtocols or zope.interface implementations, right?



-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Behaviour-based interface/protocol implementation?

2011-01-25 Thread Alan Franzoni
On Tue, Jan 25, 2011 at 7:55 AM, Chris Rebert c...@rebertia.com wrote:
 Not true actually:

 Python 2.7.1 (r271:86832, Dec  5 2010, 00:12:20)
 [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
 Type help, copyright, credits or license for more information.
 class MyContainer(object):# no special inheritance
 ...     def __len__(self):
 ...         return 42
 ...
 # didn't do any registration.
 from collections import Sized
 issubclass(MyContainer, Sized)
 True
 isinstance(MyContainer(), Sized)
 True

You're right, I forgot about subclass check. But that's really a
placebo, because it statically checks the object's *class* for such
method, not the actual instance:

from collections import Sized

class MyObj(object):
pass

mo = MyObj()
mo.__len__ = lambda: 1


print isinstance(mo, Sized)
False

 Not precisely that I know of, no. The `abc`/`collections` system comes
 closest, but it does not check method signatures; it merely verifies
 methods' existence.

It only verifies the method's existence on the class. It does nothing
of what I'd like at runtime.


 You could *definitely* write something like that by combining the
 `abc` and `inspect` modules though:
 http://docs.python.org/library/inspect.html#inspect.getargspec
 http://docs.python.org/library/abc.html#abc.ABCMeta.__subclasshook__

Yes, I'm experimenting with inspect for signature matching.

 Duck typing partisans would question what the point of such an
 elaborate mechanism would be when it won't change the fact that your
 type errors will still occur at run-time and be of essentially the
 same character as if you didn't use such a mechanism in the first
 place.

The point is that this way I might identify ducktypes - at runtime -
in a way that doesn't clutter code. getattr() blocks are simply
boring.

Of course the runtime exception-check approach might work as well
(call the method and see whether it crashes) and I may finally pick
that approach, but I'd like not to clutter my code with explicit
try...except blocks. The very same approach might help.

 The chance for signature mismatch is of course high when using
extreme runtime dynamic proxies (methods with *args, **kwargs
signature), but at least I won't try faking static typing. Anything I
fetch would just be runtime information.

-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Behaviour-based interface/protocol implementation?

2011-01-24 Thread Alan Franzoni
Hello,
I'd like to have a system which lets me do certain actions if the
duck-type of a certain objects matches what I expect, i.e. I'd like to
have a formalization of what it's sometimes done through getattr()
calls:

if getattr(myobj, somemethod, None) is not None:
myobj.somemethod(somevalue)


The above approach is sometimes too naive, because a) clutters code
with many getattr calls and ifs b) I might want to check for multiple
attributes and c) only checks for the method name and not for the
method's signature.

After looking at PyProtocols, zope.interface and python's own abc
module, I'm left with a doubt: does any behaviour-based interface
testing system exist for Python?


I mean:
all these three libraries use a register-based or inheritance-based
approach; in abc, if I want instances of a class of mine FooClass to
be BarInterface instances, I can either a) inherit from BarInterface
or b) run BarInterface.register(FooClass).

This poses some issues in a purely duck-typed context, IMHO. If an
object perfectly satisfies the  BarInterface signature, but it
doesn't inherit from MyInterface and its class wasn't registered as a
BarInterface implementor, the check isinstance(myobj, BarInterface)
will yield a False result.

This might not be a big deal if a) python = 2.6 is used b) just
checking for builtin interfaces - e.g. those defined in the
collections module is required and c) you just require checking on
basic types or on python builtin types (which correctly register
builtin ABCs).

What happens if I define my own ABC for my own purpose? There might be
builtin objects, or third party libraries, which already offer objects
that satisfy such interface, but I'd need to import such modules and
register such classes as implementing my ABC, which is suboptimal.

What I'd like to do is:

class MyType(object):
def someMethod(self, a, b):
pass

def otherMethod(self):
pass

class OtherType(object):
def someMethod(self):
pass

def otherMethod(self):
pass


@DuckType
class MyDuckType(object):
def someMethod(self, a, b):
pass

def otherMethod(self):
pass

class TestDuckTypes(TestCase):
def test_mytype_is_compatible_with_ducktype(self):
myobj = MyType()
self.assertEquals(True, MyDuckType.maybe_implemented_by(myobj))

def test_othertype_is_not_compatible_with_ducktype(self):
myobj = OtherType()
self.assertEquals(False, MyDuckType.maybe_implemented_by(myobj))




I'd like to do a kind of runtime-check for signatures. Of course there
couldn't be an absolute certainty of interface implementation, because
a runtime dynamic proxy method (accepting *args and **kwargs in its
signature, as an example)  might  just fool my signature check.

So, my questions are:

a) does anything like that already exist in the python ecosystem?
b) can anybody see any flaw either in what I'd like to do (you
shouldn't do that because...) or in the way I want to do it (It
won't work because...)



-- 
Alan Franzoni
--
contact me at public@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


abc for generators?

2010-05-19 Thread Alan Franzoni
Hello,
I was looking for an ABC for generators in python. While there's a
types.GeneratorType type object - which can't be used directly  and it's
not an abc - and many collections-related ABCs in the collections
module, there's no way to say a user-defined class as a generator, even
though it could expose the very same interface as a builtin, yield-based
generator.

I think it would be pretty useful.

comments?


-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: abc for generators?

2010-05-19 Thread Alan Franzoni
On 5/19/10 7:24 PM, Carl Banks wrote:
 collections.Iterator

That would just support the next() method. But enhanced generators
interface - supporting coroutines as well - include send(), throw() and
close().


-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugger on system with Python 2 and 3

2009-11-27 Thread Alan Franzoni
On 11/27/09 6:17 PM, Yo Sato wrote:
 Hi,
 
 I am a relative newcomer to the Python language, and only write Python
 3. Now I would very much like to a more-than-basic debugger. However
 it seems as if the fact that I have both Python 2 and 3 on the system
 complicates the matter...

You haven't told OS which OS you're using, and what are your exact
problems, BTW I think two good debuggers for Python are winpdb/rpdb2
(work on any platform, despite the name) and the one you get in
Eclipse+Pydev.

You should be able to pick your platform, even though I've never tested
them in Python 3.


-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using setup.py for an application, not a library module.

2009-11-18 Thread Alan Franzoni
On 11/18/09 9:53 PM, John Nagle wrote:
 Most of the documentation for setup.py assumes you're packaging a
 library module. (Ref: http://docs.python.org/distutils/setupscript.html;)
 How do you properly package an application?  What happens
 on setup.py install?  Where does the application get installed?  Where
 does
 the main program go?

Usually, just package the lib and from your main program (e.g. the
script that goes in /usr/bin, for instance), do just something like that:

#!/usr/bin/python
from mylib import main
import sys

sys.exit(main())


-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pyfora, a place for python

2009-11-04 Thread Alan Franzoni
On 11/2/09 3:44 PM, Diez B. Roggisch wrote:
 Being from germany, I can say that we *have* this fragmentation, and
 frankly: I don't like it. I prefer my communication via NNTP/ML, and not
 with those visually rather noisy and IMHO suboptimal forums. E.g. it

That's right... forums, although more accessible to all the people who
can't/doesn't want to use specific email or nntp clients, are quite slow
to use.

But I think Ubuntu forums support threads and are kind of channeled
between ML and webinterface... something like Google Groups; I think
THAT would be a good idea. What about trying to channel
comp.lang.python and a forum?

-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Aaaargh! global name 'eggz' is not defined

2009-10-31 Thread Alan Franzoni
On 10/29/09 9:48 PM, kj wrote:
 How can one check that a Python script is lexically correct?

You can use a pseudo-static analyzer like pyflakes, pylint or pydoctor.

Or, better, you can avoid wild imports, excessive local or global
namespace manipulation, and break you program in smaller parts and write
unit tests for them.

Typos are very common but should very easy to catch. If you're not
catching them until a very long run of your program, then your code
coverage is probably too low.

-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Socket Issues with VirtualBox

2009-05-22 Thread Alan Franzoni
TechieInsights was kind enough to say:

[cut]

You're giving very few details on your issue, which is most probably not
related to python itself. Which operating system? Which virtualbox version?
Which kind of connection? Is the port open for listen? Does the code fail
at listening or at connecting (e.g. is either the client or the server
failing) ?

My first guess would be that you didn't specify the interface to bind to,
and the interface order changes once you install virtualbox since it
possibly adds a virtual interface of its own, but I can't tell unless you
tell something more.

-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Italy 2009: Late Bird Deadline

2009-04-25 Thread Alan Franzoni
The late-bird registration deadline for PyCon Tre (PyCon Italy 2009) is 
May 4th.

The conference will take place in Florence from May 8th till May 10th 2009, 
and features guests like Guido Van Rossum, Alex Martelli, Raymond 
Hettinger, Fredrik Lundh and Antonio Cangiano.

Feel free to take a look at the schedule:
http://www.pycon.it/pycon3/schedule/

A simultaneous interpretation service is available for the main track:

http://www.pycon.it/pycon3/non-italians

See you in Florence!


-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


PyCon Italy 2009: Late Bird Deadline

2009-04-25 Thread Alan Franzoni
The late-bird registration deadline for PyCon Tre (PyCon Italy 2009) is 
May 4th.

The conference will take place in Florence from May 8th till May 10th 2009, 
and features guests like Guido Van Rossum, Alex Martelli, Raymond 
Hettinger, Fredrik Lundh and Antonio Cangiano.

Feel free to take a look at the schedule:
http://www.pycon.it/pycon3/schedule/

A simultaneous interpretation service is available for the main track:

http://www.pycon.it/pycon3/non-italians

See you in Florence!


-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-23 Thread Alan Franzoni
Jeremy Banks was kind enough to say:

 Hi. I'm sure there've been debates about this before, but I can't seem
 to figure out what to search for to pull them up, so I'm asking here.

I'm not exactly sure what you mean... if you want to add functions to
another fuction, just do it this way:

def foo():
return i'm the main function.

foo.bar = lambda: i'm the bar attr

print foo()
print foo.bar()

 def foo.bar():
 return(I'm a method!)

So you'd just like some syntactic sugar to let function declarations to
be shorter?

I think this wouldn't make the language that clear. In order to accomplish
what you want, you could just use a class and the __call__ method for the
main function.

I think that what you really mean is that you would like an improved
lambda or different def. E.g., that could you write anonymous functions
( or ruby-like code blocks ) in a different way. Something like this:

d[func] = def pippo(a, b, c):
...
...
...

I suppose the reason behind this is that it's not really needed. There're
plenty of ways to do this  sort of things in python; if you just declare
methods in a class you can just use the plain def in order to achieve this,
and you can inherit from your container and specialize some methods in
order to achieve results which are similar to those you want.



-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


PyCon Italy 2009: Early Bird Deadline

2009-04-07 Thread Alan Franzoni
The early-bird registration deadline for PyCon Tre (PyCon Italy 2009) is 
April 13th, just a few days from now.

The conference will take place in Florence from May 8th till May 10th 2009, 
and features guests like Guido Van Rossum, Alex Martelli, Raymond 
Hettinger, Fredrik Lundh and Antonio Cangiano.

Feel free to take a look at the schedule:
http://www.pycon.it/pycon3/schedule/

A simultaneous interpretation service is available for the main track:

http://www.pycon.it/pycon3/non-italians

See you in Florence!


-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


PyCon Italy 2009: Early Bird Deadline

2009-04-07 Thread Alan Franzoni
The early-bird registration deadline for PyCon Tre (PyCon Italy 2009) is
April 13th, just a few days from now.

The conference will take place in Florence from May 8th till May 10th 2009,
and features guests like Guido Van Rossum, Alex Martelli, Raymond
Hettinger, Fredrik Lundh and Antonio Cangiano.

Feel free to take a look at the schedule:
http://www.pycon.it/pycon3/schedule/

A simultaneous interpretation service is available for the main track:

http://www.pycon.it/pycon3/non-italians

See you in Florence!


-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


PyCon Italy 2009: Early Bird Deadline

2009-04-07 Thread Alan Franzoni
The early-bird registration deadline for PyCon Tre (PyCon Italy 2009) is 
April 13th, just a few days from now.

The conference will take place in Florence from May 8th till May 10th 2009, 
and features guests like Guido Van Rossum, Alex Martelli, Raymond 
Hettinger, Fredrik Lundh and Antonio Cangiano.

Feel free to take a look at the schedule:
http://www.pycon.it/pycon3/schedule/

A simultaneous interpretation service is available for the main track:

http://www.pycon.it/pycon3/non-italians

See you in Florence!


-- 
Alan Franzoni alan.franzoni.x...@gmail.com
-
Remove .xyzz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


PyCon Italy 2009 - Florence, May 8th-10th

2009-01-27 Thread Alan Franzoni

PyCon Tre (http://www.pycon.it), the third edition of PyCon Italy,
will take place in Florence from the 8th May to 10th May 2009.
Confirmed keynote speakers so far include Guido Van Rossum, more to
come. The Call for papers (http://www.pycon.it/pycon3/call-for-paper/)
will be open from February, 9th, till March, 8th.

Most website pages are currently available in italian only, but
translations are in the way.

-- 
Alan Franzoni alan.franzoni@gmail.com
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: time

2008-10-07 Thread Alan Franzoni
Gabriel Rossetti was kind enough to say:

 I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours 
 earlier than the current time (14:59). I tried various other methods, I 
 still get the wrong time. Does anyone have an idea with what is wrong?

I don't see your IP since I'm reading this through gmane and you appear to
have posted via the python ml, but if your utc+1 means Central Europe ,
you're proably missing the daylight saving. 17.00 CEST is 15.00 UTC during
summer, when daylight saving is employed.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: starting gazpacho on windows

2008-08-30 Thread Alan Franzoni
nntpman68 was kind enough to say:

[cut]

I didn't check, but if c:\python25 is your python install dir, you'll very
likely find it in c:\python2.5\bin or c:\python25\scripts.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: email parsing

2008-08-27 Thread Alan Franzoni
ra9ftm was kind enough to say:

 It is my first script on python. Don't know is it correctly uses
 modules, but it is working fine with specially with russian code pages
 and mime formated messages. Also quoted-printable and base64
 encoded

Some hints:


1) don't write
x,

use

x * 10 

instead; it's more readable and editable.

 def obrez(strMsg):
 for s in subStrObrez:
 n = string.rfind(strMsg,s)
 if n != -1:
 return strMsg[0:n]
 return strMsg

In Python = 2.5 you can probably use the partition() method to make the
former function much shorter.

 # Convert message header
 def my_get_header(str):
 str2=
 for val,encoding in decode_header(str):
 if encoding:
 str2 = str2+ val.decode(encoding)+ 
 else:
 str2 = str2+ val+ 
 return str2

I'm not 100% sure what you're doing there, BTW I'd suggest you to use as
many Unicode objects as you can while working in Python, and encoding them
just when you're outputting them. It'll save you many headaches.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: GUI programming with python

2008-08-26 Thread Alan Franzoni
zamil was kind enough to say:

[cut]

If your needs are very basic, you can stick with the tk module that comes
with python. It's not really feature-packed, but it's maintained and pretty
cross-platform.

Otherwise, you can pick any supported widget set you like and use the
proper python bindings. You didn't tell us which OS you'd work with, hence
we can't tell you what's the best choice (if there's any).

BTW you should be able to enjoy GTK+, QT or Swing (if using Jython on Java)
or anything found in MS.NET (if using IronPython) - or you can go for
wxPython as well.

GUI Designers are widget-set related - I can suggest gazpacho for GTK+.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH utility

2008-08-11 Thread Alan Franzoni
James Brady was kind enough to say:

 Hi all,
 I'm looking for a python library that lets me execute shell commands
 on remote machines.
 
 I've tried a few SSH utilities so far: paramiko, PySSH and pssh;
 unfortunately all been unreliable, and repeated questions on their
 respective mailing lists haven't been answered...

Twisted conch seems to be your last chance :-) 

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't import work?

2008-08-05 Thread Alan Franzoni
ssecorp was kind enough to say:

 I have in Lib/site-packages a module named pdfminer. when I do import
 pdfminer it complains:
 
 import pdfminer

If you've got a directory, that's not a module - it's a package.

In order to import a directory as a package, you must create a (possibly
empty) __init__.py file in that dir.

then you can do something like

from pdfminer import pythonfile1

or you can follow Sean's advice and export the __all__ name in order to
directly access any module you like.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: sip.so: undefined symbol: PyUnicodeUCS4_AsWideChar

2008-08-04 Thread Alan Franzoni
Andreas Hinzmann was kind enough to say:

 I have also tried to configure python with --enable-unicode=ucs4, but it 
 didn't help.

But it should. try printing sys.maxunicode from your interpreter; if it's
2^16, then the interpreter is ucs2. If it's something more than 10 ^ 6,
it's ucs4.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Strong/weak typing

2008-08-01 Thread Alan Franzoni
[EMAIL PROTECTED] was kind enough to say:

 I'm writing Python as if it were strongly typed, never recycling a
 name to hold a type other than the original type.
 
 Is this good software engineering practice, or am I missing something
 Pythonic?

Python *is* strongly typed.

You're talking about dynamic typing, but that's not about name reuse.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Possible to have multiple loop variables?

2008-07-31 Thread Alan Franzoni
laredotornado was kind enough to say:

 How would I set up the ms1 array such that I can use three items per
 object?

Use tuples. But that should depend on which values make up the key for your
mapping.

E.g.
ms1 = {('managed1':7019):8020, ('managed2':7020):8021}
ms2 = {'managed1':(7019:8020), 'managed2':(7020:8021)}

depending on what you want, and then iterate over such structure just like
Marc suggested.

Otherwise, you can create a custom class which returns three-tuples when
iterated, in such case you can just extract m, lp, ssl_lp in the for cycle
just like your example.



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: static variables in Python?

2008-07-30 Thread Alan Franzoni
kj was kind enough to say:

 In this case, foo is defined by assigning to it a closure that has
 an associated variable, $x, in its scope.
 
 Is there an equivalent in Python?

There've been plenty of answers, and I'm not absolutely sure about what you
want... but closures are available in Python as well and you can use them,
and by combining them through the partial module you can get a sort of
closure factory:

from functools import partial

def getfunc(expensive_call, myfunc):
val = expensive_call()

f = partial(myfunc, val)

return f



you can then do something like that:

 f = getfunc(lambda: 1, lambda x,y:x*y)
 f(2)
6





-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Continuous integration for Python projects

2008-07-30 Thread Alan Franzoni
Hussein B was kind enough to say:

 Hi.
 Please correct my if I'm wrong but it seems to me that the major
 continuous integration servers (Hudson, CruiseControl, TeamCity ..)
 don't support Python based application.

If you want, you can use ant as a build script, and then define the usual
targets (build, dist, test), ecc. and then use xmlrunner to publish them in
a junit-like format which can be read through cruisecontrol or other CI
tools.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax error in my script

2008-07-30 Thread Alan Franzoni
laredotornado was kind enough to say:

[cut]

Indentation counts in Python. You're probably doing something wrong with
whitespace/tab/carriage return.



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: undo a dictionary

2008-07-30 Thread Alan Franzoni
mmm was kind enough to say:

 My desire is to take a set of data items in an alpha-numeric range and
 oput them into a dictionary
 
 i.e.,
 x1=1
 x2=20
 x3=33
 
 to yield  the dictionary
 
 { 'x1':1, 'x2':20, 'x3':33 }
 
 without having to type in as above but instead invoke a function
 
 maybe with syntax of
 
 dd=make_dict('x1--x99')

you'll need to pass the locals() or globals() manually. Can't be done
(cleanly) otherwise. Check the following code:

import re

x1=1
x2=20
x3=30
q6=40

def make_dict(regex, nsmapping):
output_dict = {}
compiled_regex = re.compile(regex)
for key, value in nsmapping.items():
if compiled_regex.match(key):
output_dict[key] = value

return output_dict




d = make_dict(x[123], locals())

print d





-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: write unsigned integer 32 bits to socket

2008-07-28 Thread Alan Franzoni
Michael Torrie was kind enough to say:

 Of course any time you send coherent numbers over the network, I highly
 recommend you use what's called network byte order.  In C, you'd use the
  htonl() call, and then when pulling it off the wire on the other end
 you'd use ntohl().  If you don't then you will have problems when the
 endianness is different between the hosts.  Standard convention (even in
 the MS word) is to use big-ending across the network.  I'm sure python
 has some convention in the struct module for dealing with this.

Not in the struct module; such functions are available in the socket
module, and should be employed indeed.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: write unsigned integer 32 bits to socket

2008-07-28 Thread Alan Franzoni
Scott David Daniels was kind enough to say:

 Alan Franzoni wrote:

 Please don't pass this misinformation along.
 
 In the struct module document, see the section on the initial character:
  Character Byte order Size and alignment
@  nativenative
=  native   standard
   little-endian   standard
big-endian standard
!network (= big-endian) standard

Sure, that's is one way to do it... but I was answering Micheal Torrie, who
said:

 htonl() call, and then when pulling it off the wire on the other end
you'd use ntohl().  If you don't then you will have problems when the

htonl() and ntohl() are available in Python in the socket module, so:
1) i was just pointing the OP to the right place where to find such
functions
2) they work just the same way, hence I can't see why the struct way
should be the preferred one while the socket way should be misinformation
:P

Bye!

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Remove .xyz from my email in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python iPod challenge

2007-11-11 Thread Alan Franzoni
Il Thu, 08 Nov 2007 08:11:27 -0600, Tim Chase ha scritto:


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

That's true, but you should remember it's a linguistic experiment, not a 
Python programming contest. The task is not to do that thing in the best 
possible way, but to fill in the gaps. You should just try to understand 
what the original programmer did and to complete the program in such way. 

Real problems here lie in the webapp implementation: it should check for 
javascript *before* beginning the test (I have noscript enabled, and had to 
give permission to the site, hence it took me far more time to complete the 
test since I was just clicking but obtaining nothing) and should state more 
clearly that it just needs the number of letters as the output (this should 
be related to scripteaze problem) without any other character. Error 
messages are pretty counter-intuitive.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: interesting threading result..

2007-10-29 Thread Alan Franzoni
Il Mon, 29 Oct 2007 09:08:01 -0700, Abandoned ha scritto:

 I'm sorry my bad english.
 King regards..

You must have messed up with something. You didn't post a working snippet
in first place, so you should do it now. I suppose you're working with some
editor or IDE which mantains the very same instance of a python interpreter
in memory; you probably have done something like 

end.append(current)

at a certain point in your tests.

I converted your pseudocode to python like that:

import threading

class GetData(threading.Thread):
   def __init__(self, name):
  threading.Thread.__init__(self)
  self.name = name

   def run(self):
self.data={2:3, 3:4}

nlist = []
current = GetData(a)
nlist.append(current)
current.start()
end=[]
dd=nlist[0]
dd.join()
result=dd.data
print result
end.append(result)
print end

and I just get the result I would expect:

{2: 3, 3: 4}
[{2: 3, 3: 4}]


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Memory leak issue with complex data structure

2007-07-04 Thread Alan Franzoni
Hello,
I've got a complex data structure (graph-like). Each of my nodes may
reference zero or more other nodes, internally managed by a set() object.

I have a root node which is not referenced by any other node. So, I
created a clear() method which is called on all children (by calling
their clear() method and then clears the set with the references of the
node itself.

I have a serious leak issue; even though I clear all those sets and I
delete all the references I can have to the current namespace, memory is
not freed.

I have tried the gc module and it couldn't help (I can't determine where
the references are) and I tried using weakref.ref as well to connect
object, but then I have problems (objects have no more references to
them beside their parents, hence they get deleted).

I understand it's impossibile to tell what's my problem without seeing
the actual code (which I can't post) but I'm asking if there's any
tool/debugger I could employ in order to track what's happening.

Thanks!

--
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c[:]()

2007-05-31 Thread Alan Franzoni
Il Wed, 30 May 2007 11:48:47 -0700, Warren Stringer ha scritto:

[cut]

 c[:] is c
True

BTW, I couldn't understand your concern. Are you sure you really need many
functions, and not just one function with different parametrs? In such a
case you could just use the builtin func map() to achieve the very same
result.

Or you could define a function of your own like:

def call_elems(iterable):
for elem in iterable:
elem()

and just do call_elems(c) when needed.




-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic Class/Instance Question

2007-05-23 Thread Alan Franzoni
Il 23 May 2007 04:07:19 -0700, Siah ha scritto:

 Ready to go insane here. Class A, taking on a default value for a

__init__ is a function, taking a default value of [], which is a list,
which is a mutable object. That said, you should remember that this means
that such default value is 'shared' between all instances. If you don't
want that, do something like:

def __init__(self, defaultvalue=None):
if defaultvalue is None:
defaultvalue=[]

http://docs.python.org/tut/node6.html#SECTION00671


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic Class/Instance Question

2007-05-23 Thread Alan Franzoni
Il 23 May 2007 04:53:55 -0700, Siah ha scritto:

[cut]

No.

It's because the *body* of the function gets evaluated every time the
function is called, while the *definition* of the function gets evaluated
just once, when the function is 'declared'.

Your issue arises when the default value of the function (which is part of
the definition, not of the body) is a mutable object, because it's the very
same default value that gets modified at each time.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Alan Franzoni
Il Sun, 13 May 2007 17:44:39 +0200, Martin v. Löwis ha scritto:

[cut]

I'm from Italy, and I can say that some thoughts by Martin v. Löwis are
quite right. It's pretty easy to see code that uses English identifiers
and comments, but they're not really english - many times, they're just
englishized versions of the italian word. They might lure a real english
reader into an error rather than help him understand what the name really
stands for. It would be better to let the programmer pick the language he
or she prefers, without restrictions.

The patch problem doesn't seem a real issue to me, because it's the project
admin the one who can pick the encoding, and he could easily refuse any
patch that doesn't conform to the standards he wants.

BTW, there're a couple of issues that should be solved; even though I could
do with iso-8859-1, I usually pick utf-8 as the preferred encoding for my
files, because I found it more portable and more compatible with different
editors and IDE (I don't know if I just found some bugs in some specific
software, but I had problems with accented characters when switching
environment from Win to Linux, especially when reading/writing to and from
non-native FS, e.g. reading files from a ntfs disk from linux, or reading
an ext2 volume from Windows) on various platforms.

By the way, I would highly dislike anybody submitting a patch that contains
identifiers other than ASCII or iso-8859-1. Hence, I think there should be
a way, a kind of directive or sth. like that, to constrain the identifiers
charset to a 'subset' of the 'global' one.

Also, there should be a way to convert source files in any 'exotic'
encoding to a pseudo-intellegibile encoding for any reader, a kind of
translittering (is that a proper english word) system out-of-the-box, not
requiring any other tool that's not included in the Python distro. This
will let people to retain their usual working environments even though
they're dealing with source code with identifiers in a really different
charset.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


vim e autoindentazione commenti

2007-05-11 Thread Alan Franzoni
Ciao a tutti,
alla fine dopo le mille dispute emacs vs vim mi sono messo a provarli
entrambi... e mi pare ora di essere diventato un vimmaro (pur se molto
'custom' in quanto lo sto rendendo un bel po' + simile a cream).

Una domanda stupida. Forse è più da comp.editors.
Come faccio a far sì che vim prosegua automaticamente i commenti su più
righe? Ho settato la lunghezza massima della riga a 79 caratteri, fin qui
tutto ok, ma quando vado a capo, anche se la riga inizia con #, vim non lo
aggiunge in automatico all'inizio.


Al contrario con altri tipi di file (es. Java) questa aggiunta è automatica
e la trovo molto, molto comoda.

Dovrei andae a intaccare il file di indentazione? o quello di sintassi?


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: vim e autoindentazione commenti

2007-05-11 Thread Alan Franzoni
Il Fri, 11 May 2007 13:15:01 GMT, Neil Cerutti ha scritto:

:help format-comments
 
 (Spiacente per la mia scrittura difettosa. Sto utilizzando il
 traduttore di altavista.)

Really sorry ^_^ I thought I was posting in it.comp.lang.python 

Thank you BTW!


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I use Python instead of Joomla?

2007-05-02 Thread Alan Franzoni
Il 2 May 2007 13:48:45 -0700, walterbyrd ha scritto:

 If I wanted to build a website with forums, news feeds, galleries,
 event calander, document managment, etc. I do so in Joomla easily.

You're using Joomla, which is a CMS written in PHP.

Python is a language, you should ask 'can I use Python instead of PHP'.

There are various Python CMSes lying around, you already got the link from
the Python wiki. Now, you should check if they offer the same level of
functionality and support that Joomla offers - and it may or may not be the
case; consider that Joomla and Mambo have been around since years, while
Python cmses and web frameworks are relatively young.

Finally, Django is a framework, not a CMS. It is used to create websites
and may be used to actually create CMSes.

Now the important part: if you're not a PHP programmer, you can still use
Joomla. You just download it, follow the instructions, plug in any
pre-packed addon, and use it. You could probably do the very same with some
of the Python CMSes around.

Django is different: you must be able to program Python in order to use it.
Nothing works from the beginning, since it's not a CMS: you must code it.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python QT or python-GTK

2007-03-18 Thread Alan Franzoni
Il Sun, 18 Mar 2007 11:55:47 -1000, Jon Van DeVries ha scritto:

 Please correct me if I'm wrong, I'm a newbie.

Please understand then, that both QT and GTK+ are graphic toolkits. An IDE
is a totally different thing.

Also, please understand that Qt3 and Qt4 exist, and they're quite different
beasts. Qt4 is fairly new.

Qt is GPL or commercial, while GTK+ is LGPL. That means: if you want to use
QT, you must either distribute your app under the GPL, or buy the
commercial license, while you don't have this limit in GTK+.

Both are cross-platform, but you should check for their actual visual
performance wherever they should be employed. Also, GTK+ seems to still
need an X server on macosx (don't know about QT)

Both have IDEs to create GUIs; take a look at Glade or Gazpacho for GTK+.

Also, remember GTK+ is a community project while QT is a fully commercial
project.



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-03-08 Thread Alan Franzoni
Il Wed, 07 Mar 2007 14:13:28 -0300, Gabriel Genellina ha scritto:

 __iadd__, in general, is not *required* to modify the instance in place  
 (but should try to do that, if possible). After this code:
   b = a
   a += c
 you can't assert than a and b both refer to the *same* object, as before.  
 If you need that, don't use += at all. (For a generic object, I mean. The  
 built-in list does the right thing, of course)

Surely _I_ can't, and _I_ won't. But take the opposite example.

Let's say I'm using an external library, and that library's author provides
any kind of 'convenience' container type he feels useful for the library's
purposes, but without forcing a type constraint to the parameters passed to
a certain function - as should be done in a language like python, and this
container does create a copy of the object even employing incremental
operators.

Now, let's suppose I find that container type not useful for my purposes,
*or* I have already written a different container type which mimicks a
list's behaviour (adding some kind of functionality, of course).

Now, let's suppose a certain function in that library should give a certain
result based on the contents of that container, but without modifying the
original object, but it needs to modify it in order to do some operations. 

if the function looks like this:

def foo(container):
container += [1, 2, 3]
... 

it might happen that the original object gets modified even when it
shouldn't, depending on the actual object passed to the library.

What I just mean... I don't see calling extend() to be that painful in
respect to += . If there were no other way to do it, I would agree it would
be useful. But if there're such methods, do we really need this syntactic
sugar to introduce confusion?

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-03-07 Thread Alan Franzoni
Il Tue, 06 Mar 2007 01:55:54 -0300, Gabriel Genellina ha scritto:


 The problem is that other people -not necesarily smarter and more  
 experienced than you- may use those features, and perhaps you have to  
 read, understand and modify some code written by someone else.
 So, you should at least know what a += b means, even if you are not  
 going to use it.

That's sure, and I'm in fact glad to know that by now. I still think it's
risky, BTW. Python is dynamically typed, after all, and there's no 'a
priori' way to know if 'a' is a list or another type, especially another
container type.

If we rely on duck typing, by the way, we may encounter two types quacking
like ducks, flying like ducks, but in fact acting as slightly different
ducks. I should remember as well, when designing a container type that I
want to use in place of a list, to carefully craft an __iadd__ method which
works just like the a list's own __iadd__ method; if I forget, I may
introduce a subtle error. 


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-03-05 Thread Alan Franzoni
Il Sat, 03 Mar 2007 17:34:35 +1300, greg ha scritto:

 This was all discussed at *very* great length many
 years ago, and the addition of in-place operators
 to the language was held up for a long time until
 the present compromise was devised. You might not
 like it, but it's here to stay.

Sure. I'm not a great programmer and I never thought about asking for such
a removal. I'm sure that there're people smarter and more experienced than
me out there designing Python, I'm glad I got it and I won't use such
shortcuts on mutable objects in my own programs.

At least, this is I what I think today; tomorrow, when I'm more
experienced, I could think about them and say 'Hey! They're really cute,
why haven't I used them before?'

Bye!

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-03-02 Thread Alan Franzoni
Il 28 Feb 2007 14:09:09 -0800, [EMAIL PROTECTED] ha scritto:


 Seems obvious and desirable to me.  Bare = is the way you assign a
 name to an object; saying NAME = will rebind the name, breaking the
 connection between a and b.  Without it, they continue to refer to the
 same object; extending the list (via += or .extend) mutates the
 object, but doesn't change which objects a and b are referencing.

Well... the main problem is not with the '+=' operators themselves, it's
with the 'global coherence'. I would assume then, that if the '+=' operator
is assumed to modify objects in-place, it would just fail on immutable
objects, wouldn't I?

I mean... I don't like that. I'm not really a Python expert, I found this
behaviour is documented in the language reference itself:

http://docs.python.org/ref/augassign.html

But... I don't know, still think it's confusing and not going to use it.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-02-28 Thread Alan Franzoni
Il Wed, 28 Feb 2007 07:53:47 +1100, Delaney, Timothy (Tim) ha scritto:

 Alan Franzoni wrote:
 the += operator is syntactic sugar just to save time... if one
 doesn't use it I don't think it's a matter of beauty.
 
 This change can have semantic differences, and so should not be done for
 anything except basic, immutable objects (such as integers). As such, it
 can't be done automatically.

Yeah, that's right, it could have semantic differences, but that shouldn't
be the case anyway. I mean, if I don't define an __iadd__ method, writing

a += n

or

a = a + n

is just the same, right?


So, if I bother to define an __iadd__ method, I should make sure it works
just the same, or I would introduce a very strange and hard-to-understand
behaviour.



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-02-28 Thread Alan Franzoni
Il 27 Feb 2007 16:14:20 -0800, [EMAIL PROTECTED] ha scritto:

 Those mean different things:
 
 a=[1]
 b=a
 a += [2]
 a
 [1, 2]
 b
 [1, 2]
 a=[1]
 b=a
 a = a + [2]
 a
 [1, 2]
 b
 [1]

This is a really nasty one! I just answered to Tim above here, and then I
saw your example... I had never realized that kind of list behaviour.
That's probably because i never use + and += on lists (i prefer the more
explicit append() or extend() and i do copy list explictly when I want to)
, BTW I think this behaviour is tricky!


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Eric on XP for Newbie

2007-02-28 Thread Alan Franzoni
Il 28 Feb 2007 08:13:42 -0800, [EMAIL PROTECTED] ha scritto:

[cut]

Forget the tars.

http://www.quadgames.com/download/pythonqt/

Get the two EXEs here. BTW, I don't think Eric3 is a really good IDE on
Windows (yet). Try something like SPE, or Scite, or any other editor like
UltraEdit32.

N.B: you need first to install python, then pyqtgpl, then eric.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: gtk.mainquit is deprecated

2007-02-27 Thread Alan Franzoni
Il 27 Feb 2007 01:56:33 -0800, awalter1 ha scritto:

 But I don't want to quit the application, I need only to close the
 window.
 My application includes others places where self.window.destroy()
 instruction is used and the execution is done without warning.
 Very strange.

But does then the application end, as if gtk.main_quit() were called? If
it's the case, it's very likely you connected the 'destroy' signal on that
very window and you set gtk.mainquit() as the callback.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-02-27 Thread Alan Franzoni
Il Tue, 27 Feb 2007 09:45:42 +0100, Franz Steinhaeusler ha scritto:

 Hello, I did not find any reasonable pyhton source code beautifier
 program (preferable gui).

Well, most of the things you ask should be written as such, not written and
then beautified!

 Use Spaces, size: 4

Your editor should support this.

 convert structs like: if (a  b):   to   if a  b:

Well... that's a matter of fact, not just style. Sometimes parentheses help
the reading; if a,b are not just plain names but somewhat complex
instructions, parentheses should stay.

 fill in spaces, but not in functions between operators:
 
 a+=1 = a += 1
 p(t + 1) = p(t+1)

Code should be written this way.

 self.scriptcount = self.scriptcount + 1 = self.scriptcount += 1

the += operator is syntactic sugar just to save time... if one doesn't use
it I don't think it's a matter of beauty.
 
 from is to == and is not to != (ok a find replace could do that
 easily also), but in a program that would be more comfortable.

what? No, I think you're missing the difference between 'is' and '=='. You
could say it the other way for None, True, False, e.g. if there's a 'a ==
None' it could be safely converted to 'a is None', but again: this should
be done while writing the code.

 break long lines (in a reasonable way)

well... this could be useful sometimes, but again... 'reason' is usually
something human beings should employ, and shouldn't be 'outsourced' to
computer programs.

 make from:
 if len(string)  0: = if string:
 and 
 if if len(string)  1 orr if string ==   = if not string

That's impossibile! Python is dynamically typed! How could the 'beautifier'
understand what the 'string' name is bound to? It could be whatever object!

 detect mixed line ending
 detect tabs mixed with space
 trim trailing whitespaces.

Those are editor tasks.

Get a good Editor or IDE. You haven't told us what OS are you on. If you're
on Windows, UltraEdit can do most of the things you'd like. And don't rely
on a software to correct human behaviours ^_^.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Python interactive interpreter has no command history

2007-02-16 Thread Alan Franzoni
Il Thu, 15 Feb 2007 15:14:00 -0200, Eduardo EdCrypt O. Padoan ha scritto:

 Are you using Ubuntu? The last comes with 2.4.x and 2.5. This only
 occurs on 2.5. This happens when you compile Python with libreadline
 installed, AFAIK.

I'm on Edgy and command history works well both with 2.4 and 2.5 with my
config. If it's really an Edgy glitch, it must be configuration-related!

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubunu - Linux - Unicode - encoding

2007-02-01 Thread Alan Franzoni
Il Thu, 01 Feb 2007 16:02:52 +0100, Franz Steinhaeusler ha scritto:

 The case:
 I have a file on a WindowsXP partition which has as contents german
 umlauts and the filename itself has umlauts like iÜüäßk.txt

Could you please tell us a) which filesystem is that partition using (winxp
may be installed on fat32 or ntfs partitions) and b) which driver are you
using to read that partition (may be vfat, ntfs or fuse/ntfs-3g) and, last
but not least, c) which options are passed to that driver?

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubunu - Linux - Unicode - encoding

2007-02-01 Thread Alan Franzoni
Il Thu, 01 Feb 2007 20:57:53 +0100, Franz Steinhäusler ha scritto:

 If I copy files with german umlauts (äöü and strong 's' ß), these
 filenames are not copied properly, and that characters are replaces
 by little square symbols.

Yes... I, myself, am italian, and I found no problem in using accented
letter (òèàìù). Since you say there's a problem as well in Nautilus and
other Ubuntu software, I suppose there's something wrong with your linux
setup, not with Python.

Or, at least: you should try solving that problem first, then check what
happens with python.

Try appending this options in your fstab as hda1 mount options:

iocharset=iso8859-15

unmount  remount and check what does happen.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to use MySQL without MySQLdb module

2006-12-06 Thread Alan Franzoni
Jia Lu  si è divertito a scrivere:

 Hi all.
  I am using a hosting space with python cgi.
  But this host haven't got MySQLdb installed.

Are you sure there's no other mysql db interface installed? If the DB is on
the very same server, it should be. If it isn't, and you'd like to access
an external firewall, you should check whether the firewall of your host
really allows outbound connections.

If it does, you should look for (or write by yourself) a pure-python db-api
implementation of mysqldb.

Otherwise, you could connect directly to the port of your mysql database
and just write raw sql and pull raw data from it, but this will prevent you
from the chance of using more enhanced db tools like sqlalchemy, and it's
highly discouraged as well as it's really prone to errors.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A python IDE for teaching that supports cyrillic i/o

2006-11-19 Thread Alan Franzoni
Kirill Simonov  si è divertito a scrivere:

 Unfortunately, most IDEs I tried failed miserably in this respect.  My
 test was simple: I've run the code
 name = raw_input(What's your name? )  # written in Russian
 print Hello, %s! % name   # in Russian as well
 both from the shell and as a standalone script. This either caused a
 UnicodeError or just printed invalid characters.

I highly dislike asking stupid questions, and this might be stupid
indeed... but did you write

# -*- coding: iso-8859-5 -*-

or

# -*- coding: koi8_r -*-

(they both seem suited to the Russian language, but I don't know the
difference)

as the first line in your .py file?

Personally, I use Eclipse+Pydev (a bit steep to learn at the beginning, and
quite memory and cpu hogging since it's a java-based ide; don't use it on
old/slow computers with less than 512MB RAM, and don't use version  3.2
either) and it uses that very line to recognize the actual character set
employed. You may check with other encodings as well.

http://docs.python.org/lib/standard-encodings.html

It does work on Windows indeed.

UPDATE:
I tried with Eclipse+Pydev, and using koi8_r I seems to be able to simply
copypaste a piece of the ixbt.com homepage in the editor I can save and
use it correctly.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A python IDE for teaching that supports cyrillic i/o

2006-11-19 Thread Alan Franzoni
Kirill Simonov  si è divertito a scrivere:

 On Sun, Nov 19, 2006 at 12:33:39PM +0100, Alan Franzoni wrote:
 
 No, I would prefer the editor to save the .py files with non-ASCII
 characters in UTF-8 encoding adding the BOM at the beginning of the
 file. This will allow the interpreted to detect the file encoding
 correctly and would save a teacher from explaining what an encoding is
 and why it is needed.

You'll run into encoding problems anyway in your programmer's life. I don't
think it's a workaround, try this article:

http://www.joelonsoftware.com/articles/Unicode.html

I think it's highly useful, you could tell that to your students.

BTW, not every editor supports the BOM. Have you tried with the explicit
encoding line:

# -*- coding: utf-8 -*-

Eclipse+Pydev seems to work with that. I'm not able to check with other
editors right now, but it seems you're experiencing a simple encoding
problem; your editor doesn't know which encoding you'd like to use, so it
defaults to ascii or iso-8859-1 leading to such problems.



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Change on file

2006-10-24 Thread Alan Franzoni
Il Tue, 24 Oct 2006 19:47:43 +0800, Fulvio ha scritto:

 Hello,
 
 I was thinking about use md5 check to se if a file had changes since last 
 check. Am I correct?
 Is there any other light method?

It's OK, but if you have a lot of files to check and they're large, and
changes frequent, it could put the system under severe workload.

If you just need to know if a file has changed, you can check via
date/time, or if you don't trust somebody who's got access to it (because
he could have manually altered the datetime) you could go for a simpler
algorithm, like sfv.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compile python on Solaris 64bit

2006-10-12 Thread Alan Franzoni
Il Thu, 12 Oct 2006 16:46:19 +0200 (CEST), Martijn de Munnik ha scritto:

 Hi,
 
 I want to compile python on my solaris 10 system (amd 64 bit).

Just a question... AFAIK, Solaris 10 64 bit includes binaries  kernels for
both 64 bit and 32 bit machines. Which binaries are you actually using? I
think there could be some configuration mismatch between running binaries
and environment variables that could confuse the compiler.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting MSWord Docs to PDF

2006-10-10 Thread Alan Franzoni
Il Tue, 10 Oct 2006 01:27:35 -0700, [EMAIL PROTECTED] ha scritto:

 is it possible to convert MSword docs into PDF format?
 i told my future employer that i could, because i knew
 of the COM scripting abilites that activePython had.
 and i knew there was modules for PDF creation such as
 reportlabs.

a lot depends on the availability of ms word itself on the platform you're
planning to do the work, if you want the result to be perfect. There're
several tools on Windows (some cheap, some freeware) like FreePDF o
pdffactory, which act like 'Virtual Printers' producing a PDF file instead;
you could try using Python to automate the printing process and getting the
PDF output instead. Or if you've got access to Adobe Acrobat as well, you
could automate the whole process via Acrobat (but it's untested, don't take
it as granted).

If you're doing this in Linux, you should consider something like Crossover
Office in order to run ms word and convert its output.

The openoffice.org based solution will surely work, but you'll heavily rely
on the conversion quality of that suite.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dive Into Python -- Still Being Updated?

2006-07-24 Thread Alan Franzoni
Il 22 Jul 2006 15:48:36 -0700, [EMAIL PROTECTED] ha scritto:

 http://diveintopython.org/getting_to_know_python/indenting_code.html
 
 The function called fib (presumably short for Fibonacci) appears to
 produce factorials. Anyway, 'fib' should really be called 'hem'. :)

I think this is just a bad name for the function... it's not stated
anywhere that it should return a Fibonacci sequence.


 
 http://diveintopython.org/native_data_types/tuples.html#odbchelper.tuplemethods
 
 I think tuples have methods, na?

Well... of course they have some *special* methods, (any python object has)
but they have no method of their own. I think this is pretty clear, it's
employed to emphasize the contrast with the list object.

BTW, you can see last update is 20 May 2004; it's right on the homepage.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance error: class Foo has no attribute bar

2006-07-09 Thread Alan Franzoni
Il Sun, 09 Jul 2006 04:24:01 GMT, crystalattice ha scritto:

 I can't see why it's saying this because Character.__init__(self) not only  
 has self.attrib_dict = {} but it also calls the setAttribute method  
 explicitly for each attribute name. If I do a print out of the dictionary  
 just for Character, the attributes are listed.

Are you sure attrib_dict is a class attribute? Aren't you defining it in
charachter's __init__ method, thus making it an instance attribute?


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compiling python (or ironpython) to .exe or .dll for or not for .NET

2006-06-28 Thread Alan Franzoni
Il 28 Jun 2006 06:29:58 -0700, per9000 ha scritto:

 Is the newest Ironpython really as old as from 2004 July 28 (as stated
 on http://www.ironpython.com/)?

Ironpython homepage seems long to have been abandoned.

Try this:

http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compiling python (or ironpython) to .exe or .dll for or not for .NET

2006-06-28 Thread Alan Franzoni
Il 28 Jun 2006 06:29:58 -0700, per9000 ha scritto:

 Is the newest Ironpython really as old as from 2004 July 28 (as stated
 on http://www.ironpython.com/)?

Sorry again, the up to date page is the following one:
http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-
Blog: http://laterradeglieroi.verdiperronchi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: performance degradation when looping through lists

2006-04-07 Thread Alan Franzoni
Joachim Worringen on comp.lang.python said: 

 I use Python 2.3.4 (#1, Sep  3 2004, 12:08:45)
 [GCC 2.96 2731 (Red Hat Linux 7.3 2.96-110)] on linux2

Check Peter Otten's answer, and remember as well that GCC 2.96 can lead to
highly strange issues whenever used.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pondering about the essence of types in python

2006-03-26 Thread Alan Franzoni
gangesmaster on comp.lang.python said: 

 TypeError: unbound method __init__() must be called with z instance as
 first argument (got x instance instead)
 ==
 
 and the question is -- WHY?

I think the answer would be: because it's an instance method. Its
'contract' it's to be bound to an object of a certain class. Would you like
a different behaviour, you could decorate whatever method you need. I.e.,
turn your example into:

class z(object):
@staticmethod
def __init__(self):
self.blah=5

class x(object):
def __init__(self):
z.__init__(self)


y = x()


And this will work as you wish. You could have used classmethod as well
with a properly tuned init, of course.
 
 but __mro__ is a readonly attribute, and deriving from instances is
 impossible (conn.modules.wx.Frame is a PROXY to the class)...
 
 and again -- WHY? these all look like INTENTIONAL limitations. someone
 went around and added type checks (which are NOT pythonic) into the
 cPython implementation. argh. why do that?

I really think this happens because Python was designed to be
casualerror-safe. This approach would probably lead to many programming
errors. 

By the way, Python was designed to *discourage* such behaviours, not to
prevent them. By the way, I didn't grasp what you would really like to do.
You're saying you want to derive from instances, but then I see in your
sample code you're creating a *class* derived from an object (I would
expect you would like to derive an instance from an instance, and to
'twist' such new instance methods to your needs, which I think can be done
as well). What's the difference between that and the use of __class__ ?

class z(object):
@staticmethod
def __init__(self):
self.blah=5

@staticmethod
def met_stat(self):
pass

@classmethod
def met_cls(self):
pass

def met_inst(self):
pass



class x(object):
def __init__(self):
z.__init__(self)


y = x()


class q(y.__class__):
pass


r = q()


This work OK to me. Unless you want to do something like making y instance
attributes become q class attributes, or you would like to set y instance
attributes on all q instances, which could require a bit more of code but
surely can be done. This would mix up a bit the class vs instance
behaviour, though, e.g. changing a derived class instance attribute which
is inherited from a parent instance would lead to a global attribute
change, or would 'spawn' a new instance attribute for that particular
instance?

 def derive_from(obj):
 class cls(object):
 def __getattr(self, name):
 return getattr(obj, name)
 return cls

This seems to work for deriving read-only data from instances (no way to
write back data).
 
 check types. DONT. the whole point of duck-typing is you DONT CHECK THE
 TYPES. you just work with objects, and instead of TypeError you'd get
 AttribiuteError, which is much better.  AAARRGGGHH.

You don't HAVE TO check types if you don't want. Just use @staticmethod
everywhere in your classes. I mean, a METHOD is supposed to be
class-related, and it's often useful to have it as such, (unexpected errors
and behaviours might rise everywhere if not so), but you're never forced to
use that.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __dict__ strangeness

2006-03-20 Thread Alan Franzoni
Georg Brandl on comp.lang.python said: 

 It's 2.4.2, on Linux. The 2.5 SVN trunk has the same symptom.

Yes, I confirm this. I think I had done something strange on my system
(probably misspelled something).

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __dict__ strangeness

2006-03-18 Thread Alan Franzoni
Georg Brandl on comp.lang.python said: 

 d.__dict__
 {}

Which Python version, on which system? I can see the properly inserted
attribute in __dict__, both with old style and new style classes.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which GUI toolkit is THE best?

2006-03-14 Thread Alan Franzoni
Paul Boddie on comp.lang.python said: 

 Now, since the commercial licence is per developer, some cunning
 outfit could claim that only one developer wrote their product (rather
 than one hundred developers, say), but this would be a fairly big
 breach of trust (although nothing unusual in the world of commerce, I'm
 sure). Would a business making software for other such businesses care
 about such things? What kind of recourse would they have?

Just one thing I don't understand: if you're developing all your software
inside your company, how would they know if you already coded it or you
still have to?

Also, couldn't a big company buy a *single* commercial license from the
beginning, build a software employing hundreds of developers using the GPL
license, and then distribute the software pretending that the single
developer had done everything? This would hit Trolltech anyway.

I think the problem has to do with the QT license system. It's their
problem, not a developer's one. Also, I suppose one of their commercial
licenses provides with far lot more than a license - e.g. I think they'll
offer support, design tools, additional docs and libraries.

And what would then be their income if they refused to sell you a
commercial license because they *know* you've already coded your app using
the GPL license of Qt? You could simply throw away your app and never
distribute it, and they would'nt see a cent anyway.

Personally, I don't like Qt licensing, since I think there're good widget
sets around that don't have such limitations, but I don't think that people
at Trolltech are really trolls :-=

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which GUI toolkit is THE best?

2006-03-10 Thread Alan Franzoni
invitro81 on comp.lang.python said: 

 again to make a choice is difficult; is there also some guy liking pyqt 
 is it worse or should it be avoided because of the licencing policy for 
 qt (which I also like..)?
 
   * Which one is the most fun to program with?
   * Which one is the most easy to learn?
   * Which one looks best?
   * Which one is the most productive to program with?

Those are all hard questions. You might as well have asked 'which is the
best web framework'. It's not easy to tell ^_^ It highly depends on which
tasks you're aiming at.

wxPython is a pretty good 'all-round' and cross-platform library, and
includes some non-graphical features. It's got a drawback: it's a wrapper
for the wxwidgets library, and hence it's not very pythonic; you can solve
part of its unpythonicness using wax, which is not very well documented at
the time. wxGlade can be used to design GUI apps with little effort.

pyGTK works well, too. Recent versions perform well and are good looking on
Windows systems as well as Linux and Macs (if you provide an X server).
It's very well documented (better than wxPython, in my opinion) and its
license is quite permissive. It's unpythonic just like wxPython. Glade and
Gazpacho can be used to design GUI apps in a visual way.

pyGUI is a pyGTK-based graphic library which is designed from scratch to be
pythonic. It seems very, very promising but I can't tell you if it's
production-stable since I've tested it just a couple of times. It may be
the funniest and more productive toolkit ever.

FLTK was interesting but seems to lack maintenance and support, pyQT is a
bit 'unfree' for most uses. Tkinter is quite old stuff.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Psychic bug

2006-02-22 Thread Alan Franzoni
Il Wed, 22 Feb 2006 19:04:48 +, Jennifer Hallinan ha scritto:

 Genome is a string of integers in the range 0- 3, hence the
 conversion.

Genome is a *class*, i suppose from this code, and Mutate is... an instance
method, I think. And self.genome is a string like composed of integers in
the 0-3 range.

I would advise you to use a list in first place, and define a method (maybe
__str__ or __repr__ ) in your class in order to output it as a string - I
think it may make your work easier.

Your code is a little unpythonic-inside. I think you're coding from a very
programmer-unfriendly language :-)

I don't understand your specific problem (it may be class-related but we
can't know if you don't post your full code) because the code looks fine to
me, e.g. it works as it should, with that line commented out.

For printing, try this:

print pos:%s , old value: %s, new value: %s  % (
 letter, gen[letter], base)

in place of your two prints in the if block, it should help you.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: yet another list compr. suggestion

2006-01-22 Thread Alan Franzoni
palo on comp.lang.python said: 

 The suggestion is that the same result could be achieved by
 [x in y if z(x)]

It's just a special case... and it saves very few carachters... I don't
think it would justify an update to the parser. What if you want to do
something like:

[str(x) for x in y if z(x)]

You've got to stick to the present syntax.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb - Query/fetch don't return result when it *theorically* should

2006-01-19 Thread Alan Franzoni
Bernard Lebel on comp.lang.python said: 

 I'm absolutely flabbergasted.

As I told you, i think this is related to the isolation level - I really
think it's a feature of the DB you're using - this way, until you commit,
your database lies in in the very same state on the same connection.
Suppose you make one query, and then you make another one, and you then
decide, on these result, to take a certain action on your DB; in the
meantime (between Q1 and Q2) another user/program/thread/connection might
have done a different operation on the very same db, and so you would be
getting a Q1 results from a certain state in the DB, while Q2 from a
different state, thus misleading you to take an inopportune action.

committing the connection syncs the state you're looking at with the actual
DB state.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb - Query/fetch don't return result when it *theorically* should

2006-01-18 Thread Alan Franzoni
Il Wed, 18 Jan 2006 14:39:09 -0500, Bernard Lebel ha scritto:

[cut]

1) It would be great if you didn't post four messages in less than an hour
^_^
2) Your code is very long! You can't expect many people to run and read it
all! You should post a very small demo program with the very same problem
as your main software. It'll help us a lot.
3) IMHO your problem looks like something related to isolation levels. You
should check with your DB-adapter docs about the issue. You may need to
manually sync/commit the connection or the cursor. Instead of re-creating
the connection, have you tried just creating a new cursor object at every
query? 

If you want to do a quick-test, try any ORM, like sqlalchemy or sqlobject,
and check the results.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive tree list from dictionary

2006-01-14 Thread Alan Franzoni
Il Sat, 14 Jan 2006 13:52:43 -0400, David Pratt ha scritto:

 source_list =[

I don't understand what you mean by saying that 'levels of categorization
is not fixed', are there more than two keys in any dictionary?

Basically, thus, you have a list of dictionaries and you want to get a list
of lists, right? You haven't specified what order would you like the list
to be sorted, though.  Maybe you would benefit from use and ordered
dictionary implementation like orderedDict, but such behaviour can be
created anyway. I would use a kind of 'helper dictionary' to map the list
position to the root element:

def convertList(dictlist):
helpdict={}
for elem in dictlist:
helpdict.setdefault(elem['parent'],[])
helpdict[elem['parent']].append(elem['title'])
  
return [k,v for k,v in helpdict.items() if k!='root']



-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross Compile Mips / Linux

2006-01-10 Thread Alan Franzoni
Il 10 Jan 2006 15:31:34 -0800, [EMAIL PROTECTED] ha scritto:

 Hi Everyone,
 
 I trying to get a build of Python together to run on an Embedded Linux
 / Mips machine.

You can't do that out of the box. The main reason is that the Python
interpreter is run during the compilation process, and if you compile it
for mips it won't, of course, run on your pc.

I had found a page explaining a way of cross-compiling python, but it's
old, you'll need some kind of manual work to adapt it to 2.4 (unless you're
satisfied with 2.2, of course):

http://www.ailis.de/~k/docs/crosscompiling/python.php

Or you could try surfing debian-mips package to see if you're lucky and
find a compatible package.

Best of all would be to host-compile python natively on the machine. Or you
could first compile a version on your PC, and then rename the executables
and edit the scripts...

If you're trying to compile it for an highly-embedded machine (something
like Linksys WRT series or any of the AR7-based routers around) I must tell
you I've tried something like that before, and I just partly succeeded: I
got what I think was a working python interpreter, but those machines are
so memory-limited (mine had 8MB I think) I couldn't have it work.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for with double test

2005-12-30 Thread Alan Franzoni
Il 30 Dec 2005 09:02:30 -0800, [EMAIL PROTECTED] ha scritto:

 hi all
 the is a way for doing  a for with double test:

what's a 'double test' exactly? :-)

'for' does no test, it just iterates over a list. If you want to execute
the iteration only if f is 1, do this:

if f==1:
for i in range(0,10):
...

if you want to use only certain values in the range, when the value of f[i]
(f may be a list, a dictionary, or whatever) is 1, you can use a list
comprehension:

for i in [x for x in range(0,10) if f[x]==1]:


of course, if you want to make it shorter, you can define a function
instead of the 'for' code block and use the list comprehension directly:

def myfunction(x):
...


[myfunction(x) for x in range(0,10) if f[x]==1]


and you'll end up with a list of the return values of myfunction.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between ActivePython and Python.org

2005-12-14 Thread Alan Franzoni
S.Chang on comp.lang.python said: 

 Hi,
 Anyone knows the difference(s) between the Python binaries from 
 ActiveState and Python.org?

ActivePython is a 'batteries included' distro. I think it's great for
Windows - it includes a lot of manuals in CHM format and the Win32
extensions.

The interpreter is a compile of their own, but I don't think it to be that
different from the 'official' binary. 

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Amara (XML) problem on Solaris

2005-12-13 Thread Alan Franzoni
Doru-Catalin Togea wrote:
 AttributeError: 'module' object has no attribute 'create_document'
 bash-2.03$
 
 Any ideas what is going on?

I would say it's a problem with the Amara installation on Solaris. I've
never used it, but maybe it's a package from another source which acts a
bit differently.

Also, are you sure the code is correct? I've taken a peek at the Amara's
website, and the create_document() function seems to lie within the
binderytools module. I think the line should look like:

doc = amara.binderytools.create_document()

or

doc = binderytools.create_document()

or simply

create_document()

depending on the way you imported the module, but your previous code, if
really working on Windows, makes me think you did something like:

import amara.binderytools as amara

or something like that?
Please post some more code, if you can.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
To contact me, remove .xyz from my email address.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NoneType to unicode

2005-12-12 Thread Alan Franzoni
John Morey on comp.lang.python said: 

 I have tried using the encode() function to change the values to unicode
 however I cannot do this because they are returned from the id3 
 library as NoneType instances. which means I need to convert
 to a string first (which i can't do because it crashes the application)

NoneType is just the type of None. It should mean that your ID3 library
returns 'None' when trying to read non-ascii ID3s. I think you should check
your ID3 library, not your main program.

-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Rremove .xyz from my address in order to contact me.
-
GPG Key Fingerprint:
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E
-- 
http://mail.python.org/mailman/listinfo/python-list