On 01/01/2014 07:13 AM, eryksun wrote:
>I'm afraid I've lost the context, and don't understand why this is
>important. It's true that not all built-in objects are in builtins, and
>not all objects in builtins are built-in, but other than for pedantic
>correctness, why does this matter?
Denis sai
On Tue, Dec 31, 2013 at 11:01 PM, Keith Winston wrote:
> I'm working my way slowly through Programming Python by Mark Lutz, and as an
> example of data persistence, he uses this example:
Ooops; the email got cut off a bit early. Can you try again?
___
According to:
http://docs.python.org/2/library/shelve.html
The shelve can be opened in 'writeback' mode, which I think might be
relevant to your question.
"By default modified objects are written only when assigned to the
shelf (see Example). If the optional writebackparameter is set to
True,
So sorry, I hit return: here's the example:
import shelve
db = shelve.open('class-shelve')
sue = db['sue']
sue.giveRaise(.25)
db['sue'] = sue
tom = db['tom']
tom.giveRaise(.20)
db['tom'] = tom
db.close()
Is it possible to dispense with the assignment/reassignment and just use
(open shelve)
db[
I'm working my way slowly through Programming Python by Mark Lutz, and as
an example of data persistence, he uses this example:
--
Keith
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mail
On Tue, Dec 31, 2013 at 10:53 PM, Steven D'Aprano wrote:
>
> __builtins__ with-an-s is a crappy hack that has never worked correctly
> and has caused more confusion than help:
>
> https://mail.python.org/pipermail/python-3000/2007-March/006170.html
>
> "Restricted mode" in CPython has never worked
On Tue, Dec 31, 2013 at 10:00:32PM -0500, eryksun wrote:
> On Tue, Dec 31, 2013 at 4:27 AM, spir wrote:
> > In addition, "iter" is also the name of a builtin function, like "print".
>
> While iter is a built-in function, it would be clearer if you
> referenced the __builtins__ namespace.
Don't
On Tue, Dec 31, 2013 at 4:27 AM, spir wrote:
> In addition, "iter" is also the name of a builtin function, like "print".
While iter is a built-in function, it would be clearer if you
referenced the __builtins__ namespace. Built-in objects are linked
into the interpreter, either statically or from
On Tue, Dec 31, 2013 at 7:26 PM, Steven D'Aprano wrote:
>
> from collections import namedtuple
>
> class Source(namedtuple("Source", "string i n")):
> def __new__(cls, string, i=0, n=None):
> if n is None:
> n = len(string)
> return super(Source, cls).__new__(cls, s
On Tue, Dec 31, 2013 at 03:35:55PM +0100, spir wrote:
> Hello,
>
> I don't remember exactly how to do that. As an example:
>
> class Source (str):
> __slots__ = ['i', 'n']
> def __init__ (self, string):
> self.i = 0 # current matching index in source
> sel
On 12/31/2013 09:46 PM, Keith Winston wrote:
Thanks Denis, I found out about the iter builtin last night, a few hours
after I'd coded/posted that. Oops. Thanks for your other comments, I am
clearer now about the distinction of creating a new, empty list vs.
clearing the same list out, and the sub
On 31/12/2013 21:11, Mark Lawrence wrote:
On 31/12/2013 17:53, eryksun wrote:
Refer to the language reference:
http://docs.python.org/3/reference/datamodel.html#notes-on-using-slots
Not found on the windows CHM file. Looks like another bug report to
keep our lazy, bone idle core developers
Hi PierreD, I think if you iterate over your strings with something like
this, it will do what you want, if I understand correctly (snum is your
string number, like "123,321"):
fnum = float(snum.replace(",", ".")
keith: rank beginner, take everything with a grain of salt!
Playing with this, a list comprehension is perfect:
fnumlist = [float(num.replace(",", ".")) for num in snumlist]
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
On 31/12/2013 17:53, eryksun wrote:
On Tue, Dec 31, 2013 at 11:21 AM, Mark Lawrence wrote:
The glossary entry for __slots__ states "A declaration inside a class that
saves memory by pre-declaring space for instance attributes and eliminating
instance dictionaries. Though popular, the technique
On 31/12/2013 13:53, Pierre Dagenais wrote:
Hi,
I'm trying to convert a list of strings to float. Unfortunately the
numbers are written with a decimal comma instead of a decimal point.
What is the best way to replace these commas with decimal points? Do I
need to write a function that will itera
Thanks Denis, I found out about the iter builtin last night, a few hours
after I'd coded/posted that. Oops. Thanks for your other comments, I am
clearer now about the distinction of creating a new, empty list vs.
clearing the same list out, and the subsequent implications on other
symbols bound to
Hi,
I'm trying to convert a list of strings to float. Unfortunately the
numbers are written with a decimal comma instead of a decimal point.
What is the best way to replace these commas with decimal points? Do I
need to write a function that will iterate over every alphanumeric,
replace the comma
On 12/31/2013 06:53 PM, eryksun wrote:
On Tue, Dec 31, 2013 at 11:21 AM, Mark Lawrence wrote:
The glossary entry for __slots__ states "A declaration inside a class that
saves memory by pre-declaring space for instance attributes and eliminating
instance dictionaries. Though popular, the techniq
On Tue, Dec 31, 2013 at 11:53 AM, eryksun wrote:
> Minor correction:
>
> It says str requires empty __slots__, but that's a bug in the docs.
> It's referring to 2.x str. Else this thread wouldn't exist. In 3.x,
> str is basically the unicode type from 2.x. Its __itemsize__ is 0
> because the char
On Tue, Dec 31, 2013 at 11:21 AM, Mark Lawrence wrote:
> The glossary entry for __slots__ states "A declaration inside a class that
> saves memory by pre-declaring space for instance attributes and eliminating
> instance dictionaries. Though popular, the technique is somewhat tricky to
> get right
On Tue, Dec 31, 2013 at 10:21 AM, Mark Lawrence wrote:
> The glossary entry for __slots__ states "A declaration inside a class that
> saves memory by pre-declaring space for instance attributes and eliminating
> instance dictionaries. Though popular, the technique is somewhat tricky to
> get right
On 31/12/2013 15:54, Zachary Ware wrote:
On Tue, Dec 31, 2013 at 9:22 AM, spir wrote:
Thank you, Oscar & Zachary. I guess thus the way it is done is correct (for
my case), is it? Seems your last remark shows the source of my confusion:
probably, in past times, I subtyped builtin types and overr
On Tue, Dec 31, 2013 at 9:22 AM, spir wrote:
> Thank you, Oscar & Zachary. I guess thus the way it is done is correct (for
> my case), is it? Seems your last remark shows the source of my confusion:
> probably, in past times, I subtyped builtin types and overrided their
> __new__, thus had to call
On Tue, Dec 31, 2013 at 9:35 AM, spir wrote:
>
> I[n] particular, how does python know which param to take as
> source string? (There could be other params to __init__.)
You override __new__, and you might also have to override __init__,
but not in this case. object.__init__ ignores the extra arg
On 12/31/2013 04:03 PM, Zachary Ware wrote:
On Tue, Dec 31, 2013 at 8:35 AM, spir wrote:
Hello,
I don't remember exactly how to do that. As an example:
class Source (str):
__slots__ = ['i', 'n']
def __init__ (self, string):
self.i = 0 # current matching ind
On Tue, Dec 31, 2013 at 8:35 AM, spir wrote:
> Hello,
>
> I don't remember exactly how to do that. As an example:
>
> class Source (str):
> __slots__ = ['i', 'n']
> def __init__ (self, string):
> self.i = 0 # current matching index in source
> self.n = len(
On Dec 31, 2013 2:37 PM, "spir" wrote:
>
> Hello,
>
> I don't remember exactly how to do that. As an example:
>
> class Source (str):
> __slots__ = ['i', 'n']
> def __init__ (self, string):
> self.i = 0 # current matching index in source
> self.n = len(stri
Hello,
I don't remember exactly how to do that. As an example:
class Source (str):
__slots__ = ['i', 'n']
def __init__ (self, string):
self.i = 0 # current matching index in source
self.n = len(string)# number of ucodes (Unicode code points)
On Dec 31, 2013 12:43 PM, "Protas, Meredith"
wrote:
>
> Thanks for all of your comments! I am working with human genome
information which is in the form of many very short DNA sequence reads. I
am using a script that sorts through all of these sequences and picks out
ones that contain a particul
Thanks for all of your comments! I am working with human genome information
which is in the form of many very short DNA sequence reads. I am using a
script that sorts through all of these sequences and picks out ones that
contain a particular sequence I'm interested in. Because my data set is
On Sunday, December 29, 2013 9:11 PM, Tobias M. wrote:
/bin/pyvenv ~/my_venv
source ~/my_venv/bin/activate
wget python-distribute.org/distribute_setup.py
python distribute_setup.py
Hi, can i ask why the name ~/my_venv/ .. is that just to indicate ~ as the
home directory?
so pyvenv alre
On 12/31/2013 06:59 AM, Keith Winston wrote:
I resolved a problem I was having with lists, but I don't understand how! I
caught my code inadvertently resetting/zeroing two lists TWICE at the
invocation of the game method, and it was leading to all the (gamechutes &
gameladders) lists returned by
On 31/12/2013 07:30, Keith Winston wrote:
Never mind, I figured out that the slice assignment is emptying the
previous lists, before the .reset() statements are creating new lists
that I then populate and pass on. It makes sense.
On Tue, Dec 31, 2013 at 12:59 AM, Keith Winston mailto:keithw...@g
34 matches
Mail list logo