"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.
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
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
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
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
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.
--
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
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
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
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
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
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
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
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
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
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
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
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
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
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/~
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
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
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
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
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
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
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
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
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
#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
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
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),''):
> >
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
>
> 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
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
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
--
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
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
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
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
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
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
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 "
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
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
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
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
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
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
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
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
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
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".
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
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
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
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
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'
; ... __colour = 'blue'
> ... def __str__(self):
> ... return 'A %s parrot' % self.__colour
> ... __repr__ = __str__
> ...
>
> >>> class RedParrot(Parrot): # Just like Parrot, only red.
>
> ... __colour = 'red'
>
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
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
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
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
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
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,
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
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,
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
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
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
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.
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
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
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).
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
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
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
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?
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.
>
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 - 100 of 125 matches
Mail list logo