Re: Calling private base methods

2007-04-15 Thread Isaac Rodriguez

> The fact that I had
> to resort to this trick is a big indication of course that genuinely
> private members (as opposed to a 'keep off' naming convention) are a bad
> idea in general.


The fact that you had to resort to this trick is a big indication that
the library you were using is bad designed; it has nothing to do with
private members being a bad idea. You were using a library which
interface was in-complete (provided that you "genuinely" really needed
to access the private member to do what you wanted to do).

Private members is a great thing. They are the foundations of
encapsulation and object oriented design. The fact that Python allows
you to access "private" methods because the only "restriction" is the
name mangling does not mean you should access them and use them
directly.

I don't see the way private members are handled in Python a strenght
or a weakness of the language as compared to other languages. However,
I do see libraries that do not provide all the needed interface
methods as poor designed, or programmers that try to work around the
public interface of a class when it is not needed as poor programmers.

Thanks,

- Isaac.

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


Re: Calling private base methods

2007-04-18 Thread Isaac Rodriguez
>
> C++'s and Java's approaches are vitiated by an unspoken assumption that
> the library's designer is some kind of demigod, while the writer of code
> that uses the library is presumably still struggling with the challenge
> of opposable thumbs.  

That might be  your point of view. To me, the library designer is the
one that has done the homework and should know better how to simplify
things for others not a God. No one uses a high level library if
implementing the low-level your self is easier. Libraries provide
functionality that allow the application programmer to concentrate in
what he is being paid for, making the application. An application
programmer will have to define what the correct interface for the
application is (for example, what UI to provide). There will be users
that will say, I wish this application had a way of doing this, but
unless they were technically savy and wanted to spend the necessary
time to understand how the application works, they would not write the
feature themselves; they will request that feature to the programmer.



> In real life, the skills of the two people in
> question are likely to be much closer, and since designing libraries for
> use in all kinds of applications is a really hard task, it's likelier
> than the library designer will make an error in designing his or her
> library, rather than the application programmer in using that library.

Those are called defects or "bugs". When I find a bug in a library or
an application, I submit a bug report. I might have to work around it
for a little bit, but I don't just work around it and call it goods.
Library designers are normal programmers that work under a set of
requirements like any other programmer (application programmers
included), but when I find a bug in an application, I report it and
try to work around it until it gets fixed; I don't hack the
application or re-write my own just because a found a bug.

>
> Purely-advisory encapsulation approaches, like Python's, even the odds.
> Actually, I'd argue that even double-leading-underscores are overkill
> more often than not (and single-leading-underscores the compromise that
> is generally prefereable).

You see it as an intelligence challenge, where I see it as making
things easier for everybody.

Thanks,

- Isaac.


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


Re: What makes an iterator an iterator?

2007-04-18 Thread Isaac Rodriguez
>
> class Parrot(object):
> def __iter__(self):
> return self
> def __init__(self):


Typo right here

> self.next = self._next()

write:
self.next = self._next

no parenthesis.

> def _next(self):
> for word in "Norwegian Blue's have beautiful plumage!".split():
> yield word
>


See previous explanation.

thanks,

- Isaac.

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


Re: What makes an iterator an iterator?

2007-04-18 Thread Isaac Rodriguez

Sorry, my previous post was incomplete. I didn't realized that you
implemented _next() as a generator funcition. Besides changing
__init__() from

self.next = self._next()

to
self.next = self._next

you need to implement __iter__() as:

return self.next()


> class Parrot(object):
> def __iter__(self):
> return self
> def __init__(self):
> self.next = self._next()
> def _next(self):
> for word in "Norwegian Blue's have beautiful plumage!".split():
> yield word
>

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


Re: Calling private base methods

2007-04-18 Thread Isaac Rodriguez

> After all, that's what duck-typing is about. There is no official
> interface declaration, just an implicit protocol. And "private" methods
> or members are part of that protocol as well.


I don't think so. Duck-typing is about implementing the expected
public interface, and has nothing to do with accessing private members
of a class, nor overriding those members.

- Isaac.

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


Re: Calling private base methods

2007-04-19 Thread Isaac Rodriguez

> You appear to have led a very sheltered life if the only libraries you ever
> use are ones where you can always get a change to the library api in a
> timely manner.
>

The thing here is that we are not talking about my life. I may not
have expressed my self correctly, but you are not understanding the
point I am trying to make. You can say that you don't like C++ or Java
because they put too much restriction when members are declared
private. That you prefer Python's approach because in a time of need
it will make your life easier. All that is fine with me. It is just a
matter of taste.

But the truth is that C++ and Java made a decision to do that for a
reason, and the times when you have to work around those language
features come once in a blue moon; they are the exception, not the
rule, and you don't implement features in a language, or for that
matter in an application, to simplify the exceptions; you try to
implement the most common scenarios. Which features you add to your
programs? The features your customers' ask for because they need them
and they use them all the time or the ones that you like to implement
even if they are not ever used?

Thanks,

- Isaac


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


Re: My Python annoyances

2007-04-30 Thread Isaac Rodriguez
> Hmm, on my PyCon mug there are words "Python: so easy...even your BOSS
> can use it!"

Oh man! I would've killed for a mug like that a year ago. I was
working for this guy, who had the entire build process automated
in .BAT scripts. We spent more time fixing the build process than
devoloping our product.

Anyway, I started to move the entire thing to Python. Using a real
programming language, allows creating a more robust process. It also
allows separating data and code, which comes very handy when the data
changes to not have to touch the code.

So a year ago, I moved to another department. I would not get into the
details of why, but I am just going to say that I'm much happier now.
One day, I walking down the hall, and I see a book in my old boss'
desk: "Learning Perl." I thought to my self, "You gotta be kiddin". So
I saw him in the coffee area, and I asked him about it. His answer
was, "Yeah, I'm re-writing the build scripts in Perl because you are
the only one that knew Python, and we need to maintain them."

Well, there is no-one in that team that knows Perl either, and if they
haven't been able to learn Python in the couple of years I tried to
push it, I really doubt they are going to learn Perl. Or maybe, the
problem was that I was trying to push Python, so they are doing this
just to prove me wrong.

Like I said, I'm much happier now, and so much glad to be out of that
team.

Thanks,

- Isaac.

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


Re: How to find the present working directory using python.

2007-05-04 Thread Isaac Rodriguez

> how to find out the present working directory using python.
>

Try this:

import os
os.getcwd()

It returns the current working directory.

Thanks,

- Isaac.

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


Experiences with Py2Exe

2006-10-11 Thread Isaac Rodriguez
Hi,

I am looking for feedback from people that has used or still uses
Py2Exe. I love to program in python, and I would like to use it to
write support tools for our development team, but I cannot require
everyone to install python in their machines, so I was thinking that
Py2Exe would help on that.

The support tools I write are mostly command line driven (no GUI), but
in the future, I would like to write some expert applications that will
contain GUI. I was thinking on using wxPython for the GUI, so I was
wondering how well behaves Py2Exe with the wxPython module.

Other modules I use besides the standard modules are CTypes and the
Perforce python module p4.py. I try not to use any of the win32 stuff,
but I can see how I will have to for some utilitites, so if anyone has
experience with the win32 modules and Py2Exe, any feedback will be
highly appreciated.

Thanks,

Isaac.

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


Re: Experiences with Py2Exe

2006-10-11 Thread Isaac Rodriguez

>
> I did a project with wxPython and py2exe. Just great :-) I also used
> Inno Setup (http://www.jrsoftware.org/isinfo.php) to create an
> installer. You should be able to learn/use both in one day.
>

Do you have a specific reason for using Inno Setup and not a Windows
Installer based setup? Will Inno Setup play especially well with py3exe
or was it just the learning curve of using a Windows Installer setup?

I am asking this because I have a lot of experience using the Windows
Installer service, and I also have all the productivity tools available
to create an installer for my tools if I needed to, but now I am
curious about this Inno Setup.

Thanks,

Isaac.

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


Re: One module per class, bad idea?

2006-12-12 Thread Isaac Rodriguez

> Yes, it would be a bad idea. =)

Saying it is a bad idea and not explaining why will not help anyone. I
would like you to elaborate on why it is a bad idea to have one file
per class.

Thanks,

- Isaac.

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


Re: One module per class, bad idea?

2006-12-12 Thread Isaac Rodriguez



>   make the import statements look good.


You can still make your import statements look good and have one class
per file, that's one of the __init__.py wonderful features.

Also, C++ support stand alone functions and the rule is to organize
classes and their interface (functions that operate in objects of the
class are considered part of the interface) in their own module.

I will like to understand why this will not be a good idea for python,
other than to make beautiful import statements that is.

Thanks,

- Isaac.

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


Are all classes new-style classes in 2.4+?

2006-12-31 Thread Isaac Rodriguez
Hi,

This is probably a very basic question, but I've been playing with new
style classes, and I cannot see any difference in behavior when a
declare a class as:

class NewStyleClass(object):

or

class NewStyleClass:

I declare property members in both and it seems to work the exact same
way. I am using Python 2.4, and I was wondering if by default, all
classes are assumed to be derived from "object". If not, can someone
point me to some place where I can learn more about new-style classes
and their advantages? All the documentation I've found is very vague.

Thanks,

- Isaac.

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


CAB files manipulation API (again).

2005-06-28 Thread Isaac Rodriguez
Hi,

I am sorry to post this question again, but when I did it the other day, my 
news reader got stucked downloading new messages, and it has been that way 
for a few days. It still gets stucked if I try to download old messages.

Anyway, does anyone know of a Python module, API, etc. that allows to 
manipulate CAB files?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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


Coding Standards (and Best Practices)

2005-04-26 Thread Isaac Rodriguez
Hi,

I am fairily new to Python, but I am really liking what I am seeing. My team 
is going to re-design some automation projects, and we were going to use 
Python as our programming language. One of the things we would like to do, 
since we are all new to the language, is to define a set of guidelines and 
best practices as our coding standards.

Does anyone know where I can get some information about what the community 
is doing? Are there any well defined guidelines established?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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


Documenting Python code.

2005-05-03 Thread Isaac Rodriguez
Hi,

Are there any standarized ways of documenting Python code? When I check the 
__doc__ attribute of the standard modules, the results are kind of plain. Is 
everyone using this style?

Since Python is a very powerful language parsing strings, replacing 
expressions, and processing XML, I was wondering if people documents the 
code using constructs similar to JavaDoc and then use some functions to 
display the documentation with a little bit more of structure.

Python is a dynamically typed language, which makes me think of the 
importance of documenting not only the purpose of a particular function or 
class method, but also what requirements should be met by the objects passed 
as parameters, what will the function return, and what type of erros can 
happen. I don't see any of this information in the __doc__ attributes, so I 
was wondering if people is using some other way to document their code.

If there is no standard way to do this inside the Python community, does 
anyone feels there is a need for standarizing it?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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


Python API to manipulate CAB files.

2005-06-22 Thread Isaac Rodriguez
Does anyone know of a Python API to manipulate CAB files?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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