Re: Questions about list-creation

2009-11-30 Thread Luis Zarrabeitia
"function" with a single argument, an iterable that contains all the elements of xrange(10). You could be calling foobar(j for j in xrange(10)) instead. And I think I lost my way... I'm sleepy. If I confused you, sorry... and if I'm helped you, thank you for letting me :D.

Re: semantics of [:]

2009-11-20 Thread Luis Zarrabeitia
need to discard de old list, and get a new one. (1) would be the way to go. Note that (2) and (1) are the same, in both you discard the old value, if it exists, but in (2) you are creating a new list only to discard it right away - you shouldn't do that. > Am I correct wi

Re: restriction on sum: intentional bug?

2009-10-27 Thread Luis Zarrabeitia
the argument is a string before, it should do the "".join instead of returning an error. Also, why is there a special case for the strings, but not for the tuples? Doesn't sum(((1,) for _ in xrange(100)),()) also have quadratic behaviour, creating and destroying intermediate tu

Re: The rap against "while True:" loops

2009-10-12 Thread Luis Zarrabeitia
On Monday 12 October 2009 09:47:23 am Xavier Ho wrote: > On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia wrote: > > Actually, in python, this works even better: > > > > for lin in iter(file_object.readline, ""): > >... do something with lin > > Wh

Re: The rap against "while True:" loops

2009-10-12 Thread Luis Zarrabeitia
ng with lin Actually, in python, this works even better: for lin in iter(file_object.readline, ""): ... do something with lin -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Q: sort's key and cmp parameters

2009-10-07 Thread Luis Zarrabeitia
justification", of course that argument (and the one about the "gaps" themselves) will of course seem singularly unpersuasive. But if you see them as a "feature" (that may sometimes, albeit rarely, missfire), then you would have no problem with /either/ argument. --

Re: Confessions of a Python fanboy

2009-08-26 Thread Luis Zarrabeitia
On Friday 31 July 2009 04:08:33 am Masklinn wrote: > On 30 Jul 2009, at 23:57 , Luis Zarrabeitia wrote: > > I'd like to ask, what "container.each" is, exactly? It looks like a > > function > > call (as I've learned a few posts ago), but, what are its

Re: Confessions of a Python fanboy

2009-07-30 Thread Luis Zarrabeitia
nction call (as I've learned a few posts ago), but, what are its arguments? How the looping "works"? Does it receive a "code" object that it has to execute? Is .each some kind of magic keyword? (This has little to do with python or the current thread, so feel free t

Re: Help understanding the decisions *behind* python?

2009-07-28 Thread Luis Zarrabeitia
id them, unless you have a /reason/ to do it. Btw, def get_color(point): return screen[point] is way more readable (and less obscure) than def get_color(point): return rows_of_pixels[point[0]][point[1]] Regards, -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computa

Re: len() should always return something

2009-07-28 Thread Luis Zarrabeitia
r any object, not only int and floats. === def size(x): try: return len(x) except TypeError: return 1,1 === -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-17 Thread Luis Zarrabeitia
t;, but with the programmer. The exact same behaviour could be obtained with if int(inputValue) == 0: inputValue = 25 and no "or" involved. However, using only inputValue = inputValue or 25 could have been an error if you only wanted 25 in case inputValue is None. (the "or tr

Re: 4 hundred quadrillonth?

2009-05-27 Thread Luis Zarrabeitia
On Wednesday 27 May 2009 04:26:57 pm Mark Dickinson wrote: > Luis Zarrabeitia wrote: > > On Thursday 21 May 2009 08:50:48 pm R. David Murray wrote: > >> In py3k Eric Smith and Mark Dickinson have implemented Gay's floating > >> point algorithm for Python so that t

Re: 4 hundred quadrillonth?

2009-05-27 Thread Luis Zarrabeitia
e.gmane.org/gmane.comp.python.devel/103191/ Thank you. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a list of functions depending on a parameter?

2009-05-27 Thread Luis Zarrabeitia
In [1]: def get_incrementor(n): ...: def inc(x): ...: return x+n ...: return inc ...: In [3]: fs = [get_incrementor(n) for n in xrange(10)] In [4]: fs[2](1) Out[4]: 3 -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~ky

Re: Python Socket Issues with VirtualBox

2009-05-27 Thread Luis Zarrabeitia
n a listening socket in the "router"'s IP. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: 4 hundred quadrillonth?

2009-05-27 Thread Luis Zarrabeitia
6 without showing them what 0.2 /really/ means. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

How do I install these C modules in python? The tale of the C programming snake.

2009-05-21 Thread Luis Zarrabeitia
y. If you need to correct yourself, reply to your own message instead of opening a new thread.] -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a Par construct to Python?

2009-05-20 Thread Luis Zarrabeitia
only reason for a GIL. After all, one could argue for that goal in almost all languages. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a Par construct to Python?

2009-05-20 Thread Luis Zarrabeitia
s an argument against removing the GIL.  I > want to remove the GIL.  I'm only pointing out that removing the GIL > is not easy, and once it's removed there is a cost. Ah, allright then. Thanks for the clarification. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computac

Re: Adding a Par construct to Python?

2009-05-20 Thread Luis Zarrabeitia
an't be different from what Java, C# or any other languages do, including C++. Why is that so expensive in python extensions, that it is used as an argument against removing the GIL? -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~

Re: How to replace constructor with factory method

2009-05-11 Thread Luis Zarrabeitia
without having to change the user's code. [1] http://trucosos.crv.matcom.uh.cu/snippets/95/ -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-05 Thread Luis Zarrabeitia
t allow that easier implementation to be efficient enough. Programming languages suck, but that shouldn't mean that we can't hope to improve them. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-05 Thread Luis Zarrabeitia
ucks. [I'm not a lisp user, but I tend to think recursively anyway...] -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Self function

2009-05-05 Thread Luis Zarrabeitia
advantage on having it as a keyword, though: it would make static analisis easier) -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing.Queue - I want to end.

2009-05-04 Thread Luis Zarrabeitia
ould be still cheaper to scp the files. Now, if I only had a third core available to consume a bit faster ... Regards, -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Multiprocessing.Queue - I want to end.

2009-04-30 Thread Luis Zarrabeitia
for this? (raise the exception when the queue is exhausted, not when it is closed by the producer). -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: unpythonic use of property()?

2009-04-22 Thread Luis Zarrabeitia
that's unfortunate. Btw, when I re-read my phrase by itself, it seemed hostile... My apologies. I'm still not very good at expressing my thoughts in english. Then, I guess, you have little choice. Mangle the name, hope that the server will get fixed. -- Luis Zarrabeitia (aka Kyrie) F

Re: unpythonic use of property()?

2009-04-22 Thread Luis Zarrabeitia
lain as loudly as possible if they want to break encapsulation. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: any(), all() and empty iterable

2009-04-16 Thread Luis Zarrabeitia
confusion. /me wonders how no one on this thread suggested that before. That seems like a pretty simple and clear fix to all this thread. +100^2 -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Preferred syntax for the docstrings

2009-03-19 Thread Luis Zarrabeitia
#x27;re used for the std lib's very > spiffy new docs. See the Sphinx homepage for how to learn the syntax. > > Cheers, > Chris That was quick! Thanks! Opening the page now. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie Participe

Preferred syntax for the docstrings

2009-03-19 Thread Luis Zarrabeitia
syntax? (the one that python documentation viewers understand better? the one used by the stdlib?) How should/in what order should I write the docs? (brief description, argument types, return type, followed perhaps by some doctests). -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Luis Zarrabeitia
Quoting Jim Garrison : > Jim Garrison wrote: > > Luis Zarrabeitia wrote: > >> On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: > >> with open(filename, "rb") as f: > >> for buf in iter(lambda: f.read(1000),''): > >

Re: How to do this in Python?

2009-03-17 Thread Luis Zarrabeitia
iter(lambda: f.read(1000),''): do_something(buff) but I don't really like a lambda in there. I guess one could use functools.partial instead, but it still looks ugly to me. Oh, well, I guess I also want to see the canonical way of doing it. -- Luis

Re: array next pointer

2009-03-17 Thread Luis Zarrabeitia
> > But it does have a 'default' argument, and you can pass that > a sentinel, so it amounts to the same thing ;) Yep, that's what I meant, I forgot the parameter name. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: array next pointer

2009-03-17 Thread Luis Zarrabeitia
cial_methods__ should be avoided. That one is a better idiom. Works for python2.4 and 2.5 also. In python3, this should be used instead: >>> b = iter(a) >>> c = next(b) (btw, I love the new sentinel argument for the next function in python3!) -- Luis Zarrabeitia Facult

Re: Invalid syntax with print "Hello World"

2009-03-12 Thread Luis Zarrabeitia
ial written for Python > 3 however there are enough to get going: most of the Python 2 > tutorials are redundant. Sticking to Python 3 tutorials will give him > a higher signal-to-noise ratio in the tutorials that he finds. That is true. We need python tutorials aimed at python2.6 :D --

Re: unziping a file in python..

2009-03-02 Thread Luis Zarrabeitia
u also need to create all the intermediate folders from "output_folder" to "output_folder/name" (assuming that 'name' has several path parts in it)? Is there any elegant way to do it? (is there any way to make os.mkdir behave like mkdir -p?) -- Luis Zarrabeitia Fa

Re: OT: handling multiple software repositories

2009-02-26 Thread Luis Zarrabeitia
nces are that you will love DrProject. It's quite good (and easy to install, unlike gforge), but the developers are moving on to a version 2.0 that you can find around here: http://basieproject.org/ (yeah, the website is ugly). If you like trac, take a look at DrProject and keep an e

Re: Getting screen dims platform specific? Say it ain't so!

2009-02-24 Thread Luis Zarrabeitia
y, then it would be kind of irrelevant if it is on the stdlib or not. Of course, this only applies if you want to paint and your api provides that info. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman

Re: Getting screen dims platform specific? Say it ain't so!

2009-02-24 Thread Luis Zarrabeitia
On Tuesday 24 February 2009 05:57:52 pm Lionel wrote: > from win32api import GetSystemMetrics I'd guess that win32api is patform specific, as in "api for win32". -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http

Re: Challenge: Please break this! [Python Security]

2009-02-23 Thread Luis Zarrabeitia
ists None --- Versus: --- >>> import django >>> print django >>> import i_hope_this_doesnt_exists Traceback (most recent call last): File "", line 1, in ImportError: No module named i_hope_this_doesnt_exists --- ipython also gets broken after the import (not

Importing a file (not a module).

2009-02-08 Thread Luis Zarrabeitia
but I don't want to keep that script on the global python path nor on any of the project folders (it is required by more than one). Currently I have a symlink from the original modify_pythonpath.py to each project directory, but that seems clumsy. -- Luis Zarrabeitia Facultad de Mat

Re: is python Object oriented??

2009-02-04 Thread Luis Zarrabeitia
On Wednesday 04 February 2009 10:53:54 am Russ P. wrote: > On Feb 4, 5:35 am, Luis Zarrabeitia wrote: > > Quoting "Russ P." : > > This analogy is nonsense. There is no way you will execute code on my > > system if I don't authorize it, regardless of how "

Re: is python Object oriented??

2009-02-04 Thread Luis Zarrabeitia
position: you can easily _check_ that everything is alright before executing, whereas in the office example, it cannot be done. Of course, if the analogy is flawed in such an essential aspect, I won't even humor it. I worry, though, that you obviously believe that it is not flawed. -- Luis

Re: is python Object oriented??

2009-02-04 Thread Luis Zarrabeitia
ain. > Please, point out where, because I don't recall you explaining why is not enough to use a "validation script" on the code if you wish to. I _do_ recall you saying that you didn't want the validation script unless it is integrated with python, but I'm yet to

Re: is python Object oriented??

2009-02-02 Thread Luis Zarrabeitia
the interpreter will simplify them more than having the checks on an external tool? -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: is python Object oriented??

2009-02-02 Thread Luis Zarrabeitia
complaint has nothing to do with enforced vs not-enforced data hiding, and everything to do with static typing. And mind you, must of us who use python, do so _because_ of the dynamism and not in spite of it. Funny thing is, you have the choice, _now, today_, of having your precious sta

Re: is python Object oriented??

2009-02-01 Thread Luis Zarrabeitia
ical* given the current design of Python. Well, then. Do you want dynamic checks? Go fix Bastion/rexec (that would be a _good_ thing, valuable for way more than data hiding). Or do you want static checks? In that case, you have it already. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemátic

Re: is python Object oriented??

2009-02-01 Thread Luis Zarrabeitia
the dot is "self". If you can't trust yourself to access only the well identified "public" attributes, how can you trust that you will just not make "public" a private attribute anyway? -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Luis Zarrabeitia
On Tuesday 27 January 2009 02:56:51 pm Russ P. wrote: > On Jan 27, 11:40 am, Luis Zarrabeitia wrote: > > I think you still fail to see that what we are objecting is not that the > > original writer can "optionally" use the enforced data hiding (which, as > > someon

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Luis Zarrabeitia
h, as someone pointed out before me, can be done with tools like pylint). The objection is about the _user_ of the library. If you don't force it into the _user_, how is it different from the current situation? And if you do force it, how can you say that it is optional? -- Luis Zarrab

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Luis Zarrabeitia
e person. I have serious problems with names. [My apologies to both of you, if I said something that made you notice my confusion]. P.S: Just to be clear, I'm neither Russ P. nor Paul Robin :D -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.c

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Luis Zarrabeitia
Quoting "Russ P." : > On Jan 24, 9:54 pm, Luis Zarrabeitia wrote: > > Quoting "Russ P." : > > > > It is. For starters, I'd lose the information of "this attribute was > intended to > > be internal and I'm accessing it anyway".

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
quot; every time an attribute is > accessed that it is not a private attribute. I think that was a reply to a message where I said that I used pylint run those checks on third party libraries. And I obviously can do the same with my own code. I don't have threading now, so I can't ch

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
Quoting Steven D'Aprano : > On Fri, 23 Jan 2009 21:36:59 -0500, Luis Zarrabeitia wrote: > > > Quoting Steven D'Aprano : > >> Makes *no* sense? There's *no* good reason *at all* for the original > >> author to hide or protect internals? > &g

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
Quoting "Russ P." : > On Jan 23, 6:36 pm, Luis Zarrabeitia wrote: > > > > Makes *no* sense? There's *no* good reason *at all* for the original > > > author to hide or protect internals? > > > > My bad, sorry. > > It makes sense... if

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Luis Zarrabeitia
Quoting Steven D'Aprano : > On Fri, 23 Jan 2009 13:07:55 -0500, Luis Zarrabeitia wrote: > > > It should be in _our_ power as the team of all participant coders on > > _our_ project to decide if we should mess with the internals or not. > > > > What makes n

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Luis Zarrabeitia
On Friday 23 January 2009 06:31:50 am Antoon Pardon wrote: > On 2009-01-16, Luis Zarrabeitia wrote: > > Quoting "Russ P." : > >> If you "*shouldn't* mess with the implementation", then what is wrong > >> with enforcing that "shouldn'

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-22 Thread Luis Zarrabeitia
; ...     __colour = 'blue' > ...     def __str__(self): > ...         return 'A %s parrot' % self.__colour > ...     __repr__ = __str__ > ... > > >>> class RedParrot(Parrot): # Just like Parrot, only red. > > ...     __colour = 'red' >

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Luis Zarrabeitia
On Wednesday 21 January 2009 04:16:38 pm Russ P. wrote: > On Jan 21, 9:34 am, Luis Zarrabeitia wrote: > > But you keep failing to explay why do you need it to be _part of the > > standard_ library (or whatever). > > Technically, it doesn't need to be. But if someone p

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Luis Zarrabeitia
On Wednesday 21 January 2009 02:03:07 pm Paul Rubin wrote: > Luis Zarrabeitia writes: > > But somehow the discussion shifted from an optional requirement (giving > > you the chance to explicitly use 'from lock import unlock; o = > > unlock(obj)') to "it

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Luis Zarrabeitia
On Tuesday 20 January 2009 09:52:01 pm Paul Rubin wrote: > Luis Zarrabeitia writes: > > > Whaat? Assuming a program is perfect unless a failure is proven > > > is not at all a sane approach to getting reliable software. It is > > > the person claiming perfection w

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Luis Zarrabeitia
to be _part of the standard_ library (or whatever). If you need it in your project, _use_ it. If you don't, then don't use it. If _you_ need that thing you call security, just use it already and quit complaining that we don't use it. Is there a policy in your project that you

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-20 Thread Luis Zarrabeitia
On Tuesday 20 January 2009 05:00:34 am Paul Rubin wrote: > Luis Zarrabeitia writes: > > No wonder you can't get Bruno's point. For the second, static checks > > to prevent accidents, you have pylint. For the first, not only you > > are using the wrong tool, but yo

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-20 Thread Luis Zarrabeitia
On Tuesday 20 January 2009 02:00:43 am Russ P. wrote: > On Jan 19, 10:33 pm, Luis Zarrabeitia wrote: > > (Why do you keep calling it 'encapsulation'?). > > I keep calling it encapsulation because that is a widely accepted, > albeit not universal,

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
tion'?). It was a counterexample for your trust on compiler checks. Btw, what do you have against using pylint for detecting those 'access violations'? > If that reasoning is sound, think about what else is useless. I _hope_ that wasn't Bruno's reasoning. I don't want to switch sides on this discussion :D. Cheers, -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
Quoting Paul Rubin <"http://phr.cx"@NOSPAM.invalid>: > Luis Zarrabeitia writes: > > > Luis Zarrabeitia writes: > > class ImmutableType(type): ... > > Thanks for posting this, I haven't replied because I bookmarked the > post for later study,

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
lic interface, you shouldn't change it... But, if you absolutely have to do it, complain loudly and as soon as possible. In python, I'd say that [a subclass of?] AttributeError would be the best solution for this ill-advised situation. -- Luis Zarrabeitia Faculta

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
Quoting "Russ P." : > On Jan 19, 5:09 pm, Luis Zarrabeitia wrote: > > > Russ, I think _you_ are missing the point. > > If the attribute is already public, why does it need properties? Why would > a > > programmer go to the trouble of adding them

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
one I'm using right now (Horde/Imp), your only option is to reply-to-all and then delete the original sender. I can't blame anyone for forgetting about the last part. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
Quoting Luis Zarrabeitia : > > Quoting "Russ P." : > > > On Jan 19, 6:24 pm, "James Mills" > > wrote: > > > > > Python programmers tend to not have a need for > > > properties. Quite honestly they are a waste of time.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
capsulate it later without > breaking the client's code. Python programmers don't _need_ to plan ahead and encapsulate the radius from the start. That's the whole point. No clairvoyance needed. I kind of like that. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
rty access in C# is exactly the same. (Could it be that even if the syntax is the same, the compiled code differs? Don't know enough about .NET to answer that). I think I'm getting offtopic now. I better leave :D [snip the rest of the email, as I agree with it] -- Luis Zarrabeitia F

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-19 Thread Luis Zarrabeitia
enforced data hiding. You want something actually designed to try to prevent abuses from hostile programmers - go use .Net or Java, who attempt to do that (I don't know with what level of success, but they at least provide you the 'locks' and 'police' that you need).

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-16 Thread Luis Zarrabeitia
you can usually access the privates anyway - it's just a bit harder to do, and a lot harder to discover. You pointed out previously that Python wasn't up to the task of running untrusted code on my own application, and I agreed. _That_ is what you seem need, and enforced data hiding

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-15 Thread Luis Zarrabeitia
Quoting Paul Rubin <"http://phr.cx"@NOSPAM.invalid>: > Luis Zarrabeitia writes: > > Wait, do you _really_ believe that _static_ checks could prevent problems > > arising from _unexpected_ conditions in the _data_? > > The data does not arrive from outer spa

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
at could have been prevented with more compile time checking > that made sure the structures understood by the one-off script matched > the ones in the program that generated the input data. Wait, do you _really_ believe that _static_ checks could prevent problems arising from _unexpected_ c

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
On Wednesday 14 January 2009 12:54:13 pm Paul Rubin wrote: > Bruno Desthuilliers writes: > > You'll find successful "monster" projects written in > > languages that are even more permissive than Python (C anyone ?), > > Could you name one written in C?

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
On Wednesday 14 January 2009 11:45:46 am Paul Rubin wrote: > Luis Zarrabeitia writes: > > Why don't you do it backwards? > > You *can* implement a metaclass that will remove the dynasmism from its > > instances. Do it - I can give you a starting point if you wish. >

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
On Wednesday 14 January 2009 11:18:51 am Paul Rubin wrote: > Luis Zarrabeitia writes: > > when you need to share some objects with potentially untrusted code > > (like, a plugin system). You can't, and you shouldn't, expect that the > > user will know what plugins h

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
and guess what, C# not only needs a word for the concept of "objects should behave as you expect them to behave - we want no barking cats, ever", but it is even not polymorphic by default (the cursed "virtual" keyword). -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
likely make irrelevant if the members are private or public. But, for trusted code? Or at least code known at compile time? It's just not worth it... pylint should take care of that - and if it doesn't, the OP should go fix it. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y C

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
should access it] private = two leading underscores (name munging) [only you should access - implementation detail.] -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Luis Zarrabeitia
e of python... I chose python _because_ of it. > and because it can also improve performance. Btw, for performance, there is __slots__, with the side-effect that it forbids attribute creation 'on the fly'. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread Luis Zarrabeitia
prefix - if that were the case, what magic would you propose for the compiler to guess when you are referring to locals, globals, class or instance variables?) -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia
e(a, numpy.array) or isisntance(b,numpy.array): res = compare_numpy(a,b) elif isinstance(a,some_otherclass) or isinstance(b,someotherclass): res = compare_someotherclass(a,b) ... else: res = (a == b) if res: # do whatever -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computaci

Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia
n the way to test for equality should be the equality test. > > I'm certain that something could be worked out. A quick paragraph that > > took me just a few minutes to type shouldn't be construed as a PEP that > > will solve all the problems :D. > > As always: t

Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia
On Wednesday 10 December 2008 10:50:57 am M.-A. Lemburg wrote: > On 2008-12-10 16:40, Luis Zarrabeitia wrote: > > Quoting Rasmus Fogh <[EMAIL PROTECTED]>: > >> Rhamphoryncus wrote: > > Rich comparisons were added to Python at the request of the > Numeric (now num

Re: Rich Comparisons Gotcha

2008-12-10 Thread Luis Zarrabeitia
l. Even the transition itself could be done without breaking much code... Make the == op return an object that wraps the array of bools (instead of the array itself), give it the any() and all() methods, and make __nonzero__/__bool__ equivalent to all(). -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2008-12-07 Thread Luis Zarrabeitia
Quoting James Stroud <[EMAIL PROTECTED]>: > First, here is why the ability to throw an error is a feature: > > class Apple(object): >def __init__(self, appleness): > self.appleness = appleness >def __cmp__(self, other): > assert isinstance(other, Apple), 'must compare apples t

Re: how to document a property

2008-11-27 Thread Luis Zarrabeitia
p(a.age) and always get "stores the age of the person", I don't think python has any syntactical way of doing that. You could simulate it using properties, though (do a 'help(property)' to see an example), but I'm not sure if that will be a good solution. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-14 Thread Luis Zarrabeitia
e, but I wanted to explore possible alternatives. Fair enough. > >> I understand very well when data should be stored as instance data, > >> and when it > >> should be instead tucked away as static data within a method. > > > > OT: Please enlighthen me. I

Re: using "private" parameters as static storage?

2008-11-13 Thread Luis Zarrabeitia
27; variables. > If you don't understand that, or are > happy without having the choice, and have no answer to the question I > was asking, then that's fine. I believe he had an answer... You didn't like it, though. I hope mine was more palatable to you. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Parsing a file with iterators

2008-10-17 Thread Luis Zarrabeitia
e to leak the internals of the parsers to the outside. What could I do? (to the curious: the format is a dialect of the E00 used in GIS) -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading from stdin

2008-10-08 Thread Luis Zarrabeitia
the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given. = But it doesn't say how to put the file object in non-blocking mode. (I was trying t

Re: Reading from stdin

2008-10-07 Thread Luis Zarrabeitia
On Tuesday 07 October 2008 05:12:28 pm Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Luis > > Zarrabeitia wrote: > > I have a problem with this piece of code: > > > > > > import sys > > for line in sys.stdin: > > p

Re: Reading from stdin

2008-10-07 Thread Luis Zarrabeitia
ill stands (how to turn off the buffering), but this is a nice workaround until it gets answered. -- Luis Zarrabeitia (aka Kyrie) Fac. de Matemática y Computación, UH. http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list

Reading from stdin

2008-10-07 Thread Luis Zarrabeitia
e behavior. The stdin.readline() function doesn't share that behaviour (it returns as soon as I hit 'enter'). ??Is there any way to tell stdin's iterator not to buffer the input? Is it part of the standard file protocol? -- Luis Zarrabeitia (aka Kyrie) Fac. de Mate

Re: Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Luis Zarrabeitia
On Wednesday 01 October 2008 01:14:14 pm Peter Otten wrote: > Luis Zarrabeitia wrote: > > a = iter([1,2,3,4,5]) # assume you got the iterator from a function and > > b = iter([1,2,3]) # these two are just examples. > > Can you provide a concrete use case? I'd like

Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Luis Zarrabeitia
2 = tee(iterator) if any(i1): # do something with i2 Question/Proposal: Has there been any PEP regarding the problem of 'peeking' inside an iterator? Knowing if the iteration will end or not, and/or accessing the next value, without consuming it? Is there any (simple, elegant)

  1   2   >