Re: Newbie: use of built-in exceptions

2013-09-02 Thread Rui Maciel
Chris “Kwpolska” Warrick wrote:

 There are no rules.  You should use common sense instead: if the
 exception fits your needs (eg. ValueError when incorrect output
 occurs) then use it.

Ok, thanks for the tip.


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


Newbie: use of built-in exceptions

2013-09-01 Thread Rui Maciel
Are there any guidelines on the use (and abuse) of Python's built-in 
exceptions, telling where 
it's ok to raise them and where it's preferable to define custom exceptions 
instead?  


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Ben Finney wrote:

 Rui Maciel rui.mac...@gmail.com writes:
 
 Is there any pythonic way to perform static typing?
 
 I think no; static typing is inherently un-Pythonic.
 
 Python provides strong, dynamic typing. Enjoy it!

Bummer. 


 Does anyone care to enlighten a newbie?
 
 Is there some specific problem you think needs static typing? Perhaps
 you could start a new thread, giving an example where you are having
 trouble and you think static typing would help.

It would be nice if some functions threw an error if they were passed a type 
they don't support or weren't designed to handle.  That would avoid having 
to deal with some bugs which otherwise would never happen.  

To avoid this sort of error, I've been testing arguments passed to some 
functions based on their type, and raising TypeError when necessariy, but 
surely there must be a better, more pythonic way to handle this issue.


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


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Steven D'Aprano wrote:

 On Mon, 05 Aug 2013 21:46:57 +0100, Rui Maciel wrote:
 
 Is there any pythonic way to perform static typing?  After searching the
 web I've stumbled on a significant number of comments that appear to
 cover static typing as a proof of concept , but in the process I've
 found no tutorial on how to implement it.
 
 Try Cobra instead. It's Python-like syntax, but allows static typing.
 
 http://cobra-language.com/

Thanks for the suggestion, but switching Python for another programming 
language would defeat the purpose of learning Python.


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


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Gary Herron wrote:

 The Pythonic way is to *enjoy* the freedom and flexibility and power of
 dynamic typing.  If you are stepping out of a static typing language
 into Python, don't step just half way.  Embrace dynamic typing.  (Like
 any freedom, it can bite you at times, but that's no reason to hobble
 Python with static typing.)


What's the Python way of dealing with objects being passed to a function 
that aren't of a certain type, have specific attributes of a specific type, 
nor support a specific interface?


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


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Joshua Landau wrote:

 Unless you have a very good reason, don't do this. It's a damn pain
 when functions won't accept my custom types with equivalent
 functionality -- Python's a duck-typed language and it should behave
 like one.

In that case what's the pythonic way to deal with standard cases like this 
one?

code
class SomeModel(object):
def __init__(self):
self.label = this is a label attribute

def accept(self, visitor):
visitor.visit(self)
print(visited: , self.label)


class AbstractVisitor(object):
def visit(self, element):
pass


class ConcreteVisitorA(AbstractVisitor):
def visit(self, element):
element.label = ConcreteVisitorA operated on this model

class ConcreteVisitorB(AbstractVisitor):
def visit(self, element):
element.label = ConcreteVisitorB operated on this model


model = SomeModel()

operatorA = ConcreteVisitorA()

model.accept(operatorA)

operatorB = ConcreteVisitorB()

model.accept(operatorA)

not_a_valid_type = foo

model.accept(not_a_valid_type)
/python


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


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Joshua Landau wrote:

 What's the actual problem you're facing? Where do you feel that you
 need to verify types?

A standard case would be when there's a function which is designed expecting 
that all operands support a specific interface or contain specific 
attributes.

In other words, when passing an unsupported type causes problems.


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


Re: Newbie: static typing?

2013-08-06 Thread Rui Maciel
Chris Angelico wrote:

 On Tue, Aug 6, 2013 at 10:01 AM, Rui Maciel rui.mac...@gmail.com wrote:
 It would be nice if some functions threw an error if they were passed a
 type
 they don't support or weren't designed to handle.  That would avoid
 having to deal with some bugs which otherwise would never happen.

 To avoid this sort of error, I've been testing arguments passed to some
 functions based on their type, and raising TypeError when necessariy, but
 surely there must be a better, more pythonic way to handle this issue.
 
 def add_three_values(x,y,z):
 return x+y+z
 
 Do you want to test these values for compatibility? Remember, you
 could take a mixture of types, as most of the numeric types can safely
 be added. You can also add strings, or lists, but you can't mix them.
 And look! It already raises TypeError if it's given something
 unsuitable:

If the type problems aren't caught right away when the invalid types are 
passed to a function then the problem may only manifest itself in some far 
away point in the code, making this bug needlessly harder to spot and fix, 
and making the whole ordeal needlessly too time consuming.


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


Newbie: static typing?

2013-08-05 Thread Rui Maciel
Is there any pythonic way to perform static typing?  After searching the web 
I've stumbled on a significant number of comments that appear to cover 
static typing as a proof of concept , but in the process I've found no 
tutorial on how to implement it.

Does anyone care to enlighten a newbie?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie: Python 3 and web applications?

2013-07-26 Thread Rui Maciel
I'm currently learning Python, and I've been focusing on Python3.  To try to 
kill two birds with one stone, I would also like to learn the basics of 
writing small web applications.  

These web applications don't need to do much more than provide an interface 
to a small database, and they may not even be required to be accessible 
outside of a LAN.

Does anyone have any tips on what's the best way to start off this 
adventure?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Rick Johnson wrote:

 On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote:
 [...]

 code
 class Point:
 position = []
 def __init__(self, x, y, z = 0):
 self.position = [x, y, z]
 
 Firstly. Why would you define a Point object that holds it's x,y,z values
 in a list attribute? Why not store them as self.x, self.y and self.z? 
snip/

The position in space is represented as a vector, which is then used in a 
series of operations.  

Currently I'm using numpy arrays to represent vectors.


 Secondly, why would store the position of the Point as a class attribute?
snip/

I've answered this 3 days ago.  I'm still learning Python, and python.org's 
tutorial on classes didn't explicitly covered the differences between class 
and instance attributes.


 If you construct your code properly this can be achieved. If each point is
 an object, and lines are merely holding references to two point objects
 that define the start and end position of an imaginary line, then
 updates on the points will be reflected in the Line object.

This was already covered three days ago in another post in this thread.  
I'll quote the post below

quote
I've tested the following:

code
model = Model()
model.points.append(Point(1,2))
model.points.append(Point(1,4))

line = Line( model.points[0], model.points[1])

# Case A: this works
model.points[0].position = [2,3,4]
line.points

# Case B: this doesn't work
test.model.points[0] = test.Point(5,4,7)
line.points
/code


Is there a Python way of getting the same effect with Case B?
/quote

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


Re: Version Control Software

2013-06-13 Thread Rui Maciel
Roy Smith wrote:

 In article 98c13a55-dbf2-46a7-a2aa-8c5f052ff...@googlegroups.com,
  cutems93 ms2...@cornell.edu wrote:
 
 I am looking for an appropriate version control software for python
 development, and need professionals' help to make a good decision.
 Currently I am considering four software: git, SVN, CVS, and Mercurial.
 
 CVS is hopelessly obsolete.  SVN pretty much the same.

I would say that SVN does have its uses, but managing software repositories 
isn't one of them due to the wealth of available alternatives out there 
which are far better than it.


 Git and Mercurial are essentially identical in terms of features; which
 you like is as much a matter of personal preference as anything else.
 Pick one and learn it.

I agree, but there is a feature Git provides right out of the box which is 
extremelly useful but Mercurial supports only as a non-standard module: the 
git stash feature.


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


Newbie: standard way to add version, author and license to a source file?

2013-06-13 Thread Rui Maciel
Is there any PEP that establishes a standard way to specify the version 
number of a source code file, as well as its authors and what license it's 
distributed under?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Chris Angelico wrote:

 Just FYI, Rick Johnson (aka Ranting Rick) is a known troll. Don't let
 him goad you :)
 
 Follow other people's advice, and take Rick's posts with a grain of
 salt. Sometimes he has a good point to make (more often when he's
 talking about tkinter, which is his area of expertise), but frequently
 he spouts rubbish.

I had no idea.  


Thanks for the headsup.
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Let:
- class Point be a data type which is used to define points in space
- class Line be a data type which possesses an aggregate relationship with 
objects of type Point
- class Model be a container class which stores collections of Point and 
Line objects


Essentially, a Model object stores lists of Point objects and Line objects, 
and Line objects include references to Point objects which represent the 
starting and ending point of a line.

To reflect this class relationship, I've defined the following classes:

code
class Point:
position = []

def __init__(self, x, y, z = 0):
self.position = [x, y, z]

class Line:
points = ()
def __init__(self, p_i, p_f):
self.points = (p_i, p_f)

class Model:
points = []
lines = []


/code

It would be nice if, whenever a Point object was updated, the Line objects 
which are associated with it could reflect those updates directly in 
Line.p_i and Line.p_f.

What's the Python way of achieving the same effect?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Roy Smith wrote:

 Have you tried running the code you wrote?  It does that already!  When
 you do something like:
 
 my_list = [obj1, obj2]
 
 in Python, the objects are stored by reference (not just lists, all
 assignments are by reference).

I've tested the following:

code
model = Model()
model.points.append(Point(1,2))
model.points.append(Point(1,4))

line = Line( model.points[0], model.points[1])

# Case A: this works
model.points[0].position = [2,3,4]
line.points

# Case B: this doesn't work
test.model.points[0] = test.Point(5,4,7)
line.points
/code


Is there a Python way of getting the same effect with Case B?


Thanks in advance,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote:

 Don't add
 
position = []
 
 to your code. That's not a declaration, but a class attribute and in the
 long run it will cause nothing but trouble.

Why's that?


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Rui Maciel wrote:

 # Case B: this doesn't work
 test.model.points[0] = test.Point(5,4,7)

Disregard the test. bit.  I was testing the code by importing the 
definitions as a module.


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote:

 Rui Maciel wrote:
 
 Peter Otten wrote:
 
 Don't add
 
position = []
 
 to your code. That's not a declaration, but a class attribute and in the
 long run it will cause nothing but trouble.
 
 Why's that?
 
 Especially with mutable attributes it's hard to keep track whether you are
 operating on the instance or the class:
 
 class Point:
 ... position = []
 ... def __init__(self, x, y, z):
 ... self.position = [x, y, z]
 ...
 a = Point(1, 2, 3)
 b = Point(10, 20, 30)
 a.position
 [1, 2, 3]
 del a.position
 a.position
 [] # did you expect that?
 del b.position
 b.position.extend([did you expect that?])
 a.position
 ['did you expect that?']
 del a.position
 Traceback (most recent call last):
   File stdin, line 1, in module
 AttributeError: position


How do you guarantee that any object of a class has a specific set of 
attributes?


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote:

 Rui Maciel wrote:
 
 How do you guarantee that any object of a class has a specific set of
 attributes?
 
 You don't.


What's your point regarding attribute assignments in class declarations, 
then?


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote:

 I don't understand the question. My original point was that you should
 omit class attributes that don't fulfill a technical purpose.
 

You've said the following:

quote
 class Point:

Don't add 

 position = []

to your code. That's not a declaration, but a class attribute and in the 
long run it will cause nothing but trouble.
/quote


We've established that you don't like attribute declarations, at least those 
you describe as not fulfill a technical purpose.  What I don't understand is 
why you claim that that would cause nothing but trouble.


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote:

 Have you read the code in the interpreter session I posted?
 
 If you do not agree that the demonstrated behaviour is puzzling I'll have
 to drop my claim...

I don't see how it should be puzzling.  You've deleted the attribute, so it 
ceassed to exist.


 Likewise if you can show a benefit of the
 
position = []
 
 line.

I wrote the code that way to declare intent and help document the code.  In 
this case that the class Point is expected to have an attribute named 
position which will point to a list.


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Terry Jan Reedy wrote:

 On 6/10/2013 9:18 AM, Rui Maciel wrote:
 
 class Model:
  points = []
  lines = []
 
 Unless you actually need keep the points and lines ordered by entry
 order, or expect to keep sorting them by whatever, sets may be better
 than lists. Testing that a point or line is in the model will be faster,
 as will deleting one by its identify.

Thanks for the tip, Terry.  Sounds great.  I'll update my code.


Once again, thanks for the help,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Terry Jan Reedy wrote:

 Three answers:
 Look how much trouble it has already caused ;-)
 Since you are a self-declared newbie, believe us!
 Since, be definition, useless code can do no good, it can only cause
 trouble. Think about it.

I don't doubt that there might good reasons for that, but it is always 
preferable to get the rationale behind a decision to be able to understand 
how things work and how to do things properly.


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


Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Dave Angel wrote:

 So why do you also have an instance attribute of the same name?

Thanks to this thread, and after a bit of reading, I've finally managed to 
discover that in Python there are class attributes and instance attributes, 
the former working similarly to C++'s static member variables and the latter 
being more like proper member variables.

And there was light.

Python.org's tutorial could cover this issue a bit better than it does.


Thanks for the help,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ubuntu package python3 does not include tkinter

2013-04-23 Thread Rui Maciel
Steven D'Aprano wrote:

 Nobody forces you to do anything. Python is open source, and the source
 code is freely available.

That goes both ways, with the added benefit that python-tkinter is already 
available in distro's official repositories.  If you want to install it, go 
for it.  Nothing stops you.  If you don't then you aren't forced to install 
half the packages in the repository just to have a python interpreter in 
your system.


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


Re: Ubuntu package python3 does not include tkinter

2013-04-23 Thread Rui Maciel
Chris Angelico wrote:

 30 years ago, people weren't using Tk. 

And after 30 years gone by, some people still don't use Tk, let alone 
Tkinter.  There is absolutely no reason to force them to install that if 
they don't need to.


 We've moved on beyond worrying about the odd kilobyte of space.

That must be reason why you are the only one complaining about that.


Rui Maciel

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


Re: Ubuntu package python3 does not include tkinter

2013-04-23 Thread Rui Maciel
Steven D'Aprano wrote:

 No, the job of the package system is to manage dependencies. It makes no
 guarantee about whether or not something will work.

The purpose of establishing dependencies is to guarantee that once a 
software package is installed, all the necessary components needed for it to 
run properly are already present in the system or can be installed 
automatically.

http://en.wikipedia.org/wiki/Dependency_hell


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


Re: Ubuntu package python3 does not include tkinter

2013-04-22 Thread Rui Maciel
lcrocker wrote:

 I understand that for something like a server distribution, but Ubuntu
 is a user-focused desktop distribution. It has a GUI, always. 

Irrelevant.  


 The
 purpose of a distro like that is to give users a good experience. If I
 install Python on Windows, I get to use Python. On Ubuntu, I don't,
 and I think that will confuse some users. 

Nonsense.  No one is keeping anyone off tkinter.  If you want it, install 
it.  There are official packages in the repositories such as python-tk and 
python3-tk.  If someone else doesn't want them then they aren't forced to 
pack their Ubuntu systems with more cruft.  There's nothing worse than being 
forced to install piles of irrelevant and useless stuff as a dependency to a 
fundamental package.


 I recently recommended
 Python to a friend who wants to start learning programming. Hurdles
 like this don't help someone like him.

If your friend believes that having to do an extra pair of clicks or typing 
sudo apt-get install python-tk is an unbeatable hurdle then your friend's 
computer skills are awfully lacking and he won't have much success learning 
how to write programs.


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


Re: Ubuntu package python3 does not include tkinter

2013-04-22 Thread Rui Maciel
Steven D'Aprano wrote:

 It's only easy to install a package on Ubuntu if you know that you have
 to, and can somehow work out the name of the package.

No one actually has to install tkinter.  That's the whole point of providing 
it as a separate package: only those who want to use it have to install it. 
The rest of us don't.


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


Re: Ubuntu package python3 does not include tkinter

2013-04-22 Thread Rui Maciel
lcrocker wrote:

 I'm a programmer, I installed Tkinter, and use it. I'd like to deploy
 programs written with it to others.  **Those** people know nothing 
 about it, and **shouldn't have to**.

They don't need to.  The only person that needs to know what he is doing is 
you.  You want to distribute a software package?  Package it.  Learn the 
very basics and set python-tkinter as a dependency.

http://wiki.debian.org/Packaging


Rui Maciel

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


Re: Ubuntu package python3 does not include tkinter

2013-04-22 Thread Rui Maciel
Steven D'Aprano wrote:

 I think that if you are worrying about the overhead of the tkinter
 bindings for Python, you're guilty of premature optimization.

I'm not worried about that.  No one should be forced to install crap that 
they don't use or will ever need, no matter how great the average HD 
capacity is nowadays.


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


Re: Functional vs. Object oriented API

2013-04-13 Thread Rui Maciel
Max Bucknell wrote:

 Hi,
 I'm currently learning Python, and it's going great. I've dabbled before,
 but really getting into it is good fun.
 
 To test myself, and not detract too much from my actual studies
 (mathematics), I've been writing my own package to do linear algebra, and
 I am unsure about how best to structure my API.
 
 For example, I have a vector class, that works like so:
 
  a = Vector([2, 7, 4])
  b = Vector.j # unit vector in 3D y direction
 
 I also have a function to generate the dot product of these two vectors.
 In Java, such a function would be put as a method on the class and I would
 do something like:
 
  a.dot_product(b)
 7

Not necessarily.  That would only happen if that code was designed that way.  
It's quite possible, and desirable, that the dot product isn't implemented 
as a member function of the vector data type, and instead is implemented as 
an operator to be applied to two object.


 and that would be the end of it. But in Python, I can also have:
 
  dot_product(a, b)
 7
 
 Which of these two are preferred in Python? And are there any general
 guidelines for choosing between the two styles, or is it largely a matter
 of personal preference?

The separation of concerns principle is a good guideline.  This doesn't 
apply exclusively to Python; it essentiallyl applies to all programming 
languages.

http://en.wikipedia.org/wiki/Separation_of_concerns


There are significant advantages in separating the definition of a data type 
from the definition of the operations that are to be applied to it.  If 
operations are decoupled from the data type then it's possible to preserve 
the definition of that data type eternally, while the operators that are 
written to operate on it can be added, tweaked and removed independently and 
at anyone's whims.


Hope this helps,
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In defence of 80-char lines

2013-04-04 Thread Rui Maciel
Steven D'Aprano wrote:

 Although PEP 8 is only compulsory for the Python standard library, many
 users like to stick to PEP 8 for external projects.
 
 http://www.python.org/dev/peps/pep-0008/
 
 With perhaps one glaring exception: many people hate, or ignore, PEP 8's
 recommendation to limit lines to 80 characters. (Strictly speaking, 79
 characters.)
 
 
 Here is a good defence of 80 char lines:
 
 http://wrongsideofmemphis.com/2013/03/25/80-chars-per-line-is-great/


The now arbitrary 80-column limit is a remnant of the limitations built into 
ancient terminals.

Why not let the text editor auto-wrap the lines?  They can do that now.


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


Re: Why is Ruby on Rails more popular than Django?

2013-03-07 Thread Rui Maciel
rusi wrote:

 Anyone who's used emacs will know this as the bane of FLOSS software
 -- 100 ways of doing something and none perfect -- IOW too much
 spurious choice.


This is a fallacy.  Just because someone claims that there are 100 ways of 
doing something and none perfect, it doesn't mean that restricting choice 
leads to perfection.  It doesn't.  It only leads to getting stuck with a 
poor solution with no possibility of improving your life by switching to a 
better alternative.  

Worse, a complete lack of alternatives leads to a complete lack of 
competition, and therefore the absense of incentives to work on 
improvements.  You know, progress.

Choice is good.  Don't pretend it isn't.  It's one of the reasons we have 
stuff like Python or Ruby nowadays, for example.


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


Re: Python Newbie

2013-02-23 Thread Rui Maciel
piterrr.dolin...@gmail.com wrote:

snip/
 So far I am getting the impression that Python is a toy language of some
 kind (similar to Basic of the early 80's), not really suitable for serious
 work. The only difference between these languages (admittedly, a serious
 one) is the existence of extensive libraries. Otherwise there would be no
 good reason for Python to exist. Nevertheless, it does exist and I have to
 learn it. As long as someone is paying for my time, that's OK with me.

That's some military-grade trolling.


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


Re: Python Newbie

2013-02-22 Thread Rui Maciel
Mitya Sirenef wrote:

 Looks very unclear and confusing to me. Whether it's C# or ruby or
 anything else, most devs don't indent like that;

The Go programming language makes that style mandatory.


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


Re: Python Newbie

2013-02-22 Thread Rui Maciel
Chris Angelico wrote:

 On Fri, Feb 22, 2013 at 10:58 PM, Rui Maciel rui.mac...@gmail.com wrote:
 Mitya Sirenef wrote:

 Looks very unclear and confusing to me. Whether it's C# or ruby or
 anything else, most devs don't indent like that;

 The Go programming language makes that style mandatory.
 
 [citation needed]
 
 What do you mean by that style? The OP's style with the 'if'
 indented? I just checked out golang.org for examples, and they're
 written in OTBS.


Read Mitya Sirenef's post, specifically the bit I've replied to.


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


Re: Is Python venerable?

2013-02-20 Thread Rui Maciel
rusi wrote:

 Heh! I am reminded:
 Some years ago a new reprint of Knuth's Art of Programming had on the
 back cover something to the effect that this was 'classical CS.'
 
 So what then is pop-CS, folk-CS?


Knuth's work is undoubtedly classic.

Classic:

1.
of the first or highest quality, class, or rank: a classic piece of work.
2.
serving as a standard, model, or guide: the classic method of teaching 
arithmetic. 


http://dictionary.reference.com/browse/classic


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


Re: Guy Steele on Parallel Programing

2011-02-05 Thread Rui Maciel
Xah Lee wrote:

 might be interesting.
 
 〈Guy Steele on Parallel Programing〉
 http://xahlee.org/comp/Guy_Steele_parallel_computing.html

Very interesting.  Thanks for the link.


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


Re: Use the Source Luke

2011-01-28 Thread Rui Maciel
Raymond Hettinger wrote:

 Have any of you all seen other examples besides
 the Go language docs and the Python docs?

Wasn't doxygen developed with that in mind?


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


Re: [OT] Python like lanugages [was Re: After C++, what with Python?]

2011-01-18 Thread Rui Maciel
Tim Harig wrote:

 You still don't see many
 companies doing large scale internal development using Python and you
 definately don't see any doing external developement using a language
 that gives the customers full access to the source code.

What you refered as full access to the source code only goes as far as 
the license which was imposed by the copyright holders lets it to go.  If 
you distribute the source code along with the binaries but you only 
license your code if the licencees accept that they may look at the source 
code but they can't touch it then distributing the source code is 
essentially meaningless.  There is a good reason why open source 
software is not the same thing as free software.


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


Re: Strong typing vs. strong testing

2010-10-01 Thread Rui Maciel
namekuseijin wrote:

 in C I can have a function maximum(int a, int b) that will always
 work. Never blow up, and never give an invalid answer. If someone
 tries to call it incorrectly it is a compile error.
 In a dynamic typed language maximum(a, b) can be called with incorrect
 datatypes. Even if I make it so it can handle many types as you did
 above, it could still be inadvertantly called with a file handle for a
 parameter or some other type not provided for. So does Eckel and
 others, when they are writing their dynamically typed code advocate
 just letting the function blow up or give a bogus answer, or do they
 check for valid types passed? If they are checking for valid types it
 would seem that any benefits gained by not specifying type are lost by
 checking for type. And if they don't check for type it would seem that
 their code's error handling is poor.
 
 that is a lie.
 
 Compilation only makes sure that values provided at compilation-time
 are of the right datatype.
 
 What happens though is that in the real world, pretty much all
 computation depends on user provided values at runtime.  See where are
 we heading?

You are confusing two completely different and independent concepts, which is a 
language's typing 
sytem and input validation.  TheFlyingDutchman pointed out the typical problems 
associated with 
weakly typed languages while you tried to contradict him by complaining about 
input sanity issues.  
The thing is, input sanity issues are perfectly independent of a language's 
typing system.  
Therefore, arguing about the need to perform sanity checks on programs written 
on language X or Y 
does nothing to tackle the issues related to passing a variable/object of the 
wrong type as a 
parameter to some function.


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


Re: Strong typing vs. strong testing

2010-10-01 Thread Rui Maciel
George Neuner wrote:

 That's true.  But it is a situation where the conversion to SI units
 loses precision and therefore probably shouldn't be done.

snip/

 I don't care to check it ... the fact that the SI unit involves 12
 decimal places whereas the imperial unit involves 3 tells me the
 conversion probably shouldn't be done in a program that wants
 accuracy.


Your comment is absurd for multiple reasons.   As we are focusing on the 
computational aspect of 
this issue then I will only say this:  If we are dealing with a computer 
representation of numbers 
then, as long as the numeric data type provides enough precision, it is 
perfectly irrelevant if a 
decimal representation of a certain number involves 12 or 3 decimal places.  
The only precision 
issues which affect a calculation is the ones arising from a) the ability to 
exactly represent a 
certain number in a specific representation and b) the precision errors 
produced by arithmetic 
operations.


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


Re: Strong typing vs. strong testing

2010-10-01 Thread Rui Maciel
Pascal J. Bourguignon wrote:

 Nothing extraordinary here.  Common Lisp is more efficient than C.
 http://www.lrde.epita.fr/~didier/research/verna.06.ecoop.pdf
 http://portal.acm.org/citation.cfm?id=1144168

I don't know if you are intentionally trying to be deceitful or if you honestly 
didn't spent much 
time thinking about this issue.  To be brief I will only point out the 
following topics:


a) no language is inherently more or less efficient than any other language.  
The efficiency 
aspect is only related to how those languages are implemented (i.e., the 
investments made in 
optimizing the compilers/interpreters)
b) Just because someone invested enough effort to optimize a specific 
implementation of language X 
to run, under a specific scenario, a benchmark faster than some other 
implementation of language Y 
it doesn't mean that language X's implementation outperforms or even matches 
every implementation 
of language Y under every conceivable scenario.


Regarding the links that you've provided, again I don't know if you intended to 
be dishonest or if 
you simply didn't read them.  The first link, entitled Beating C in Scientific 
Computing 
Applications On the Behavior and Performance of LISP, Part 1, basically 
compares a highly 
optimized implementation of lisp (quite literally the current state of the art 
in COMMON -LISP 
compiler technology) with a standard, run of the mill C implementation by 
performing a very 
specific benchmark.  If that wasn't enough, the C implementation they adopted 
to represent C was 
none other than GCC 4.0.3.  As we all know, the 4.0 branch of GCC was still 
experimental an ran 
notoriously worse than the 3.4 branch[1].

But even though you've ignored this, the article's authors haven't.  They've 
stated the following 
on their article:

quote
We must admit however that this point of view is not totally unjustified. Recent 
studies (Neuss, 
2003; Quam, 2005) on various numerical computation algorithms find that LISP 
code compiled with C 
MU - CL can run at 60% of the speed of equivalent C code.
/quote

So, where exactly do you base your claims?


 
 Actually, it's hard to find a language that has no compiler generating
 faster code than C...

Once again, I don't know if you are intentionally trying to be deceitful.  If 
an undergraduate 
student happens to write a C compiler for a compiler class which employs no 
optimization 
whatsoevere then that will not mean that every single C compiler is incapable 
of generating 
efficient code. 


Rui Maciel


[1] http://coyotegulch.com/reviews/gcc4/index.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fascinating interview by Richard Stallman at KTH on emacs history and internals

2010-07-19 Thread Rui Maciel
Kenneth Tilton wrote:

 What we do not have is any interesting amount of free as in speech
 software, because no one uses the GPL.

You appear to be either confused or out of touch with reality.  If that wasn't 
enough, your comment 
becomes a bit more amusing once we check your post's user agent.


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


Re: Fascinating interview by Richard Stallman on Russia TV

2010-07-17 Thread Rui Maciel
Emmy Noether wrote:

snip nonsense/
 Mackenzie, bring a properly written documentation by FSF for example
 on emacs of gcc. I want to see where RMS got his ideas ? Did he
 invent
 all of them himself ? Is he giving proper references to the sources
 of
 the ideas ? Is that plagiarism ?
 
 I am sick of such jews/zionists like RMS, Roman Polansky, Bernard
 Madoff, Larry Ellison (he had to pay 100K in court to a chinese girl
 he screwed), Stephen Wolfram, Albert Einstein spreading anti-semitism
 by their flagrant unethical behaviour.
snip more nonsense/

You are a lousy troll.


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


Re: A Exhibition Of Tech Geekers Incompetence: Emacs whitespace-mode

2009-08-18 Thread Rui Maciel
Xah Lee wrote:

 This feature is important in practical ways. For example, when you
 work with “tab separated line” files (CSV) that's a common format for
 importing/exporting address books or spreadsheets.

CSV stands for comma separated values and the import facilities of any 
spreadsheet application lets the 
user define the field separator character.


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


Re: If Scheme is so good why MIT drops it?

2009-07-23 Thread Rui Maciel
fft1976 wrote:

 How do you explain that something as inferior as Python beat Lisp in
 the market place despite starting 40 years later.

Probably due to similar reasons that lead php to become remotely relevant.


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


Re: Is this a good time to start learning python?

2008-04-01 Thread Rui Maciel
After reading all replies I've decided to keep the subscription to this
group, crank up the tutorials and start getting my head around Python. 

Thanks for all the helpful replies. Kudos, everyone!


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


Is this a good time to start learning python?

2008-03-31 Thread Rui Maciel
Recently I woke up inclined to take up the task of learning another
programming language. I've already dipped my toes in Perl (I've read online
tutorials and wrote a couple of irrelevant pet projects) but, as the
computers at my workplace only sport the python interpreter, it probably
means that learning python will end up serving me better, at least in the
short run. Plus, you know how Perl goes.

So far the decision seems to be a no brainer. Yet, Python 3000 will arrive
in a few months. As it isn't backwards compatible with today's Python,
there is the risk that no matter what I learn until then, I will end up
having to re-learn at least a considerable part of the language. To put it
in other words, I fear that I will be wasting my time.

At least that is what a clueless newbie believes. As this group is
frequented by people who have more insight into all things pythonesque,
what are your thoughts on this?


Thanks for the help
Rui Maciel
-- 
http://mail.python.org/mailman/listinfo/python-list