On Fri, Feb 19, 2010 at 11:16 PM, Lie Ryan lie.1...@gmail.com wrote:
Now, why don't we start a PEP to make python a fully-functional language
then?
Because people don't think the same way that programs are written in
functional languages.
--
Jonathan Gardner
jgard...@jonathangardner.net
--
On 02/20/10 14:39, northof40 wrote:
On Feb 20, 4:13 pm, MRAB pyt...@mrabarnett.plus.com wrote:
northof40 wrote:
I'm using the subroutine module to run run python script A.py from
B.py (this is on windows fwiw).
A.py is not my script and it may raise arbitary errors before exiting.
How can I
On Feb 20, 2:02 am, Lie Ryan lie.1...@gmail.com wrote:
On 02/20/10 13:32, MattB wrote:
I'm using the network in my own apartment. Not the campus's.
Moreover, my mac's MAC address is different from the MAC address shown
by my router, but as I said I'm also blocked when using my friend's
On Fri, Feb 19, 2010 at 11:17 PM, sjdevn...@yahoo.com
sjdevn...@yahoo.com wrote:
On Feb 20, 1:30 am, Lawrence D'Oliveiro l...@geek-
central.gen.new_zealand wrote:
If Python doesn’t distinguish between procedures and functions, why should
it distinguish between statements and expressions?
throw up your 'ifconfig' and mozilla-proxy output here. It seems you don't
know whether you are using proxy.
For mozilla proxy :
open mozilla - cmd + , - Network - Settings - Paste everything that is
there/ may be take a snapshot and upload a link.
~l0nwlf
On Sat, Feb 20, 2010 at 2:06 PM, MattB
Hi,
I have a problem using os.pipe() together with os.fork(). Usually when
the writing end of the pipe is closed, the reading end gets EOF. So
subsequent attempts to read data will return an empty string. But when
you call os.fork() after you have created a pipe using os.pipe(), and
read data
On 20 Feb, 03:33, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
I have a convention when writing unit tests to put the target of the test
into a class attribute, as follows:
class MyTest(unittest.TestCase):
target = mymodule.someclass
def test_spam(self):
On 20 Feb, 06:36, krishna krishna.k.0...@gmail.com wrote:
I have to manage a couple of dicts with huge dataset (larger than
feasible with the memory on my system), it basically has a key which
is a string (actually a tuple converted to a string) and a two item
list as value, with one element
Hello everyone. I think it is related to the precision with double
arithmetic so i posted here.I am trying with this problem (https://
www.spoj.pl/problems/CALCULAT) and the problem say that Note : for
all test cases whose N=100, its K=15. I know precision of doubles
in c is 16 digits. Could some
Not specifically Python related but thought I'd ask.
If you have a low-bandwidth website running on a shared web hosting
service as a WSGI server (or FastCGI, or any other interface with its
own process), is it considered a responsible thing for the process to
exit on its own after a period of
I have figured out that, you have to close the writing end in the child
process, which is reading from the pipe. Otherwise the underlying pipe
is not going to be closed when the parent process is closing its
writing end. This has nothing to do with Python itself. I have tried
plain C and there it
On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com
wrote:
Hello everyone. I think it is related to the precision with double
arithmetic so i posted here.I am trying with this problem
(https://www.spoj.pl/problems/CALCULAT) and the problem say that Note : for
all test cases whose
On Feb 18, 4:15 pm, Steve Howell showel...@yahoo.com wrote:
...
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25 || cube == 64
}.map { |square, cube|
cube
A quick solution I came out with, no stirling numbers and had tried to avoid
large integer multiplication as much as possible.
import math
for i in range(int(raw_input())):
n, k, l = [int(i) for i in raw_input().split()]
e = sum(math.log10(i) for i in range(1, n+1))
frac_e = e -
Following is the code I use. I got it from web, but forgot the link.
def k_fold_cross_validation(X, K, randomise = False):
Generates K (training, validation) pairs from the items in X.
Each pair is a partition of X, where validation is an iterable
of length
On Feb 20, 5:44 pm, Mark Dickinson dicki...@gmail.com wrote:
On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com
wrote:
Hello everyone. I think it is related to the precision with double
arithmetic so i posted here.I am trying with this problem
Thanks every one for commenting. I guess I misspoke. I meant to say
that the group is not necessarily the best for parts of this question,
so Subhabrata might not get as enthusiastic responses as in some other
lists (which i don't recollect at the moment, sorry). I didn't want to
convey the sense
On Feb 20, 8:13 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com
wrote:
On Feb 20, 5:44 pm, Mark Dickinson dicki...@gmail.com wrote:
On Feb 20, 11:17 am, mukesh tiwari mukeshtiwari.ii...@gmail.com
wrote:
Hello everyone. I think it is related to the precision with double
arithmetic
I don't know if is possible to import this decimal module but kindly
tell me.Also a bit about log implementation
Why don't you read about decimal module (there is log too in it) and try
writing your approach here in case it does not work? Or you insist someone
to rewrite your code using decimal
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param param2: ...
raise NotImplementedError,
Hi
I am trying to search an element by tag and new in reading a xml file
(in python). I coded this , but it did not work
--
'''This is to detect the first element and print out all that element
by tag'''
from xml.dom.minidom import parse
from
On Feb 19, 4:32 pm, Ryan Kelly r...@rfk.id.au wrote:
On Fri, 2010-02-19 at 11:08 -0800, T wrote:
On Feb 18, 7:19 pm, Ryan Kelly r...@rfk.id.au wrote:
On Thu, 2010-02-18 at 07:46 -0800, T wrote:
I have a Python app which I converted to an EXE (all files separate;
single EXE didn't
On Feb 20, 6:13 am, Michael Sparks spark...@gmail.com wrote:
On Feb 18, 4:15 pm, Steve Howell showel...@yahoo.com wrote:
...
def print_numbers()
[1, 2, 3, 4, 5, 6].map { |n|
[n * n, n * n * n]
}.reject { |square, cube|
square == 25 || cube
lallous wrote:
Hello
How can I do something similar to pure virtual functions in C++ ?
See, for example
http://code.activestate.com/recipes/266468/
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
Am 20.02.10 17:12, schrieb lallous:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param param2: ...
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param param2: ...
raise NotImplementedError, Implement me
# Dispatcher function that calls 'cb' only if 'cb' is implemented
Sorry, I totally mis-read the OP, too tired. You are right of course.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
On Saturday 20 February 2010 11:46:42 Diez B. Roggisch wrote:
Am 20.02.10 17:12, schrieb lallous:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
On Feb 20, 3:37 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com
wrote:
I don't know if is possible to import this decimal module but kindly
tell me.Also a bit about log implementation
The decimal module is part of the standard library; I don't know what
the rules are for SPOJ, but you're
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
header.
For example:
d={ (u'a',u'x'):1.0, (u'a',u'y'): 7.0, (u'b',u'y'):8.0 }
As you
On 02/20/10 19:36, MattB wrote:
On Feb 20, 2:02 am, Lie Ryan lie.1...@gmail.com wrote:
On 02/20/10 13:32, MattB wrote:
I'm using the network in my own apartment. Not the campus's.
Moreover, my mac's MAC address is different from the MAC address shown
by my router, but as I said I'm also
Shashwat Anand wrote:
basically I infer that : dirname = path - basename, like for path =
'//x', basename = x, hence dirname = '//'
[snip]
Basically, os.path.dirname() should return the directory name, which
means dropping everything after the last slash, and also the last slash.
However,
On Sat, Feb 20, 2010 at 2:42 PM, Shashwat Anand
anand.shash...@gmail.com wrote:
A quick solution I came out with, no stirling numbers and had tried to avoid
large integer multiplication as much as possible.
import math
for i in range(int(raw_input())):
n, k, l = [int(i) for i in
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
header.
For example:
d={ (u'a',u'x'):1.0, (u'a',u'y'): 7.0,
On 02/20/10 00:20, MattB wrote:
cut
Also, based on Martin's comment, I just wanted to make you all aware
that I intend no misuse, but rather am just trying to learn, as I'm a
programming noob.
cut
It wasn't my intention to imply that, rather the opposite, that if some
BOFH would see your
got it. thanks. :)
On Sat, Feb 20, 2010 at 11:19 PM, MRAB pyt...@mrabarnett.plus.com wrote:
Shashwat Anand wrote:
basically I infer that : dirname = path - basename, like for path =
'//x', basename = x, hence dirname = '//'
[snip]
Basically, os.path.dirname() should return the
lallous wrote:
How can I do something similar to pure virtual functions in C++ ?
http://docs.python.org/library/abc.html#abc.abstractmethod
Peter
--
http://mail.python.org/mailman/listinfo/python-list
@Mark,
The str(...).split('.') here doesn't do a good job of extracting the
integer part when its argument is = 1e12, since Python produces a
result in scientific notation. I think you're going to get strange
results when k = 13.
Yeah, you were correct. I tested it for k = 13, and there
Hi,
Some server-side Python applications are limited by memory usage
(hint: Zope), because Python effective uses processes and not threads
for multiprocessing. This is especially true for 64-bit platforms,
since Python programs are all about references and objects and 64-bit
effectively doubles
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
Sebastian Noack wrote:
I have figured out that, you have to close the writing end in the child
process, which is reading from the pipe. Otherwise the underlying pipe
is not going to be closed when the parent process is closing its
writing end. This has nothing to do with Python itself. I have
How one could create 32-bit Python run-time enviroment, preferable
virtualenv, on 64-bit Linux (VPS), reducing memory usage?
I'd install a 32-bit Linux on the hardware, and install a bigmem kernel
if it has more than 3GB of main memory.
I assume this involves having lib32 libs and compiling
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from
everywhere, in a program spanning multiple files?
--
http://mail.python.org/mailman/listinfo/python-list
vsoler wrote:
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
egasimus wrote:
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from
everywhere, in a program spanning multiple files?
Python's 'global' keyword is global
egasimus wrote:
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from
everywhere, in a program spanning multiple files?
Define your global in a module (a
On Sat, Feb 20, 2010 at 8:25 PM, egasimus fallenbl...@gmail.com wrote:
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from
everywhere, in a program
On Sat, 20 Feb 2010 08:12:01 -0800, lallous wrote:
How can I do something similar to pure virtual functions in C++ ?
From what you want, it seems like you want cb() to not be called if it
isn't implemented in the derived class; this isn't really what pure
virtual functions in C++ do - pure
Given the following
#!/usr/bin/python
import subprocess as s
broadcast = s.Popen(echo test | wall, shell=True,stdout=s.PIPE)
out = broadcast.stdout
while 1:
out
broadcast.wait()
broadcast.stdout.close()
The code only executes once. What I want to do is be able to
continuously
On Feb 20, 8:54 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None,
On Feb 20, 11:27 am, sWrath swrath swr...@gmail.com wrote:
2 Questions
1. Why can't I use dom.getElementsByTagName('book') in #Error 1? How
do i print the elements ?
Error- AttributeError: ElementTree instance has no attribute
'getElementsByTagName'
I only see one question here.
I
On Sat, Feb 20, 2010 at 9:27 AM, sWrath swrath swr...@gmail.com wrote:
from xml.dom.minidom import parse
from xml.etree.ElementTree import*
file1=book.xml
tmptree=ElementTree()
tmptree.parse(file1)
items=root.getiterator()
dom = parse(file1)
#Find tag names
for node in items :
if
lallous elias.bachaal...@gmail.com writes:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param
Hello,
i am trying to read a large bz2 compressed textfile using the bz2 module.
The file is 1717362770 lines long and 8GB large.
Using this code
source_file = bz2.BZ2File(file, r)
for line in source_file:
print line.strip()
print Exiting
print I used file: + file
the loop
Been trying to fix this issue for over 6 hours now.
It's doin my head in, any one know whats going on here.
==START==
python setup.py build
running build
running build_py
copying MySQLdb/release.py - build/lib.linux-x86_64-2.4/MySQLdb
running build_ext
building '_mysql' extension
gcc -pthread
Arnaud Delobelle wrote:
Astan Chee astan.c...@al.com.au writes:
Hi,
I have some variables in my script that looks like this:
vars = {'var_a':'10','var_b':'4'}
eqat = (var_a/2.0) = var_b
result = (var_a+var_b)/7
What I'm trying to do is to plug in var_a and var_b's values from vars
into eqat
On Sat, Feb 20, 2010 at 3:07 PM, Astan Chee astan.c...@al.com.au wrote:
Arnaud Delobelle wrote:
Astan Chee astan.c...@al.com.au writes:
Hi,
I have some variables in my script that looks like this:
vars = {'var_a':'10','var_b':'4'}
eqat = (var_a/2.0) = var_b
result = (var_a+var_b)/7
What
hello,
I would like my program to continue on the next line after an uncaught
exception,
is that possible ?
thanks
Stef Mientki
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki stef.mien...@gmail.com wrote:
hello,
I would like my program to continue on the next line after an uncaught
exception,
is that possible ?
thanks
Stef Mientki
Yes, you catch the exception and do nothing.
--
DANNY danijel.gv...@gmail.com wrote:
If I want to have a MPEG-4/10 coded video and stream it through the
network and than have the same video on the client side, what should I
use and of course I don't want to have raw MPEG data, because than I
couldn't extract the frames to manipulate them.
If
On Sat, 20 Feb 2010 11:25:46 -0800, egasimus wrote:
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from everywhere,
in a program spanning multiple files?
On Sat, 20 Feb 2010 18:28:16 +, Martin P. Hellwig wrote:
On 02/20/10 00:20, MattB wrote:
cut
Also, based on Martin's comment, I just wanted to make you all aware
that I intend no misuse, but rather am just trying to learn, as I'm a
programming noob.
cut
It wasn't my intention to imply
Thanks for the help, this is considerably faster and easier to read (see
below). I changed it to avoid the break and I think it makes it easy to
understand. I am checking the conditions each time slows it but it is worth
it to me at this time.
Thanks again
Vincent
def read_data_file(filename):
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki stef.mien...@gmail.com wrote:
hello,
I would like my program to continue on the next line after an uncaught
exception,
is that possible ?
thanks
Stef Mientki
That reminds me of VB's On Error Resume Next
--
W. eWatson wolftra...@invalid.com wrote in
news:hlls5c$89...@news.eternal-september.org:
I've successfully compiled several small python programs on Win
XP into executables using py2exe. A program goes from a name like
snowball.py to snowball. A dir in the command prompt window finds
Chris Rebert c...@rebertia.com wrote:
On Thu, Feb 18, 2010 at 11:58 AM, John Nagle na...@animats.com wrote:
Python isn't ready for this. Not with the GIL.
Is any language, save perhaps Erlang, really ready for it?
F# is. I only wish the syntax was a little less Perl-like. Too many
rzed wrote:
W. eWatson wolftra...@invalid.com wrote in
news:hlls5c$89...@news.eternal-september.org:
I've successfully compiled several small python programs on Win
XP into executables using py2exe. A program goes from a name like
snowball.py to snowball. A dir in the command prompt window
Hello,
I recently read about augmented assignments and that (with l1, l2
being lists)
l1.extend(l2)
is more efficient than
l1 = l1 + l2
because unnecessary copy operations can be avoided. Now my question is
if there's a similar thing for breaking a list into two parts. Let's
say I
Code is below, The files are about 5mb and 230,000 rows. When I have 43
files of them and when I get to the 35th (reading it in) my system gets so
slow that it is nearly functionless. I am on a mac and activity monitor
shows that python is using 2.99GB of memory (of 4GB). (python 2.6 64bit).
The
On Sat, Feb 20, 2010 at 4:55 PM, marwie mar...@gmx.de wrote:
Hello,
I recently read about augmented assignments and that (with l1, l2
being lists)
l1.extend(l2)
is more efficient than
l1 = l1 + l2
because unnecessary copy operations can be avoided. Now my question is
if there's
On Sat, Feb 20, 2010 at 4:21 PM, Vincent Davis vinc...@vincentdavis.netwrote:
Thanks for the help, this is considerably faster and easier to read (see
below). I changed it to avoid the break and I think it makes it easy to
understand. I am checking the conditions each time slows it but it is
Thanks again for the comment, not sure I will implement all of it but I will
separate the if not row The files have some extraneous blank rows in the
middle that I need to be sure not to import as blank rows.
I am actually having trouble with this filling my sys memory, I posted a
separate
On Sat, Feb 20, 2010 at 11:25 AM, egasimus fallenbl...@gmail.com wrote:
Hi, newbie here. I've read on using the 'global' keyword being
discouraged; then what is the preferred way to have something, for
example a class containing program settings, accessible from
everywhere, in a program
On Sat, 20 Feb 2010 16:55:10 -0800, marwie wrote:
Hello,
I recently read about augmented assignments and that (with l1, l2 being
lists)
l1.extend(l2)
is more efficient than
l1 = l1 + l2
because unnecessary copy operations can be avoided. Now my question is
if there's a
On Sat, Feb 20, 2010 at 3:03 PM, V8 NUT olaye1...@googlemail.com wrote:
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for
-lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -
lz
/usr/bin/ld: cannot find -lz
This is your problem.
Am trying to
hello all,
since I posted this last time, I've added a new function dates_diff and
modified the dates_dict function to set timedelta values returned by
dates_diff in the returned dict
def dates_dict(self,*targs,**dargs):
dates_dict() - takes params same as prefs()
On Sat, Feb 20, 2010 at 5:07 PM, Vincent Davis vinc...@vincentdavis.net wrote:
Code is below, The files are about 5mb and 230,000 rows. When I have 43
files of them and when I get to the 35th (reading it in) my system gets so
slow that it is nearly functionless. I am on a mac and activity
On Sat, 20 Feb 2010 17:06:36 -0800, Jonathan Gardner wrote:
On Sat, Feb 20, 2010 at 4:55 PM, marwie mar...@gmx.de wrote:
[...]
l2 = l1[10:]
del l1[10:]
But since I'm assigning a slice the elements will be copied. Basically,
I'm looking for something like l1.pop(10,len(l1)) which
I'm trying to use the python module netcdf4-python to read a netcdf
file. So far I'm trying to do the basics and just open the script:
from netCDF4 import Dataset
rootgrp = Dataset('20060402-201025.netcdf', 'r',
format='NETCDF3_CLASSIC')
print rootgrp.file_format
rootgrp.close()
when I do this I
On Sat, 20 Feb 2010 17:34:15 -0800, Jonathan Gardner wrote:
In terms of global, you should only really use global when you are
need to assign to a lexically scoped variable that is shared among other
functions. For instance:
def foo():
i = 0
def inc(): global i; i+=1
def
On 21 Feb., 02:30, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
Python lists are arrays of pointers to objects, so copying a slice is
fast: it doesn't have to copy the objects, just pointers. Deleting from
the end of the list is also quick, because you don't have to move memory,
On Feb 18, 2:58 pm, John Nagle na...@animats.com wrote:
Multiple processes are not the answer. That means loading multiple
copies of the same code into different areas of memory. The cache
miss rate goes up accordingly.
A decent OS will use copy-on-write with forked processes, which
On 02/21/10 12:02, Stef Mientki wrote:
On 21-02-2010 01:21, Lie Ryan wrote:
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki
stef.mien...@gmail.com wrote:
hello,
I would like my program to continue on the next line after an uncaught
exception,
is that possible ?
thanks
Stef Mientki
On Feb 20, 2010, at 9:17 PM, Lie Ryan wrote:
On 02/21/10 12:02, Stef Mientki wrote:
On 21-02-2010 01:21, Lie Ryan wrote:
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki
stef.mien...@gmail.com wrote:
hello,
I would like my program to continue on the next line after an uncaught
sjdevn...@yahoo.com wrote:
On Feb 18, 2:58 pm, John Nagle na...@animats.com wrote:
Multiple processes are not the answer. That means loading multiple
copies of the same code into different areas of memory. The cache
miss rate goes up accordingly.
A decent OS will use copy-on-write with
On Sun, 2010-02-21 at 13:17 +1100, Lie Ryan wrote:
On 02/21/10 12:02, Stef Mientki wrote:
On 21-02-2010 01:21, Lie Ryan wrote:
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki
stef.mien...@gmail.com wrote:
hello,
I would like my program to continue on the next line after an uncaught
On 21 Feb., 02:41, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
What the OP is doing is quite different:
(1) copy l1[:10]
(2) assign the name l2 to it
(3) resize l1 in place to the first 10 items.
What the OP wants is:
(1) assign the name l2 to l1[:10] without copying
(2)
Here is a sample of the output, It almost instantly uses 2GB and then starts
using VMem. This is probably the right suggestion but it's another thing to
install
It's probably also worth being aware of guppy's heapy stuff:
On Feb 20, 7:47 pm, deadpickle deadpic...@gmail.com wrote:
I'm trying to use the python module netcdf4-python to read a netcdf
file. So far I'm trying to do the basics and just open the script:
from netCDF4 import Dataset
rootgrp = Dataset('20060402-201025.netcdf', 'r',
I'm relatively new to python and I was very surprised by the following behavior:
a=1
b=2
mylist=[a,b]
print mylist
[1, 2]
a=3
print mylist
[1, 2]
Whoah! Are python lists only for literals? Nope:
c={}
d={}
mydlist=[c,d]
print mydlist
[{}, {}]
c['x']=1
print mydlist
[{'x': 1}, {}]
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
python-l...@open-sense.com wrote:
I'm relatively new to python and I was very surprised by the following
behavior:
a=1
b=2
mylist=[a,b]
print mylist
[1, 2]
a=3
print mylist
[1, 2]
Whoah! Are python lists only for literals? Nope:
On Sat, 20 Feb 2010 17:55:18 -0800, marwie wrote:
On 21 Feb., 02:30, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
Python lists are arrays of pointers to objects, so copying a slice is
fast: it doesn't have to copy the objects, just pointers. Deleting from
the end of the list
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
python-l...@open-sense.comwrote:
But what would be the python way to accomplish list of variables
functionality?
The problem is... Python doesn't have variables. At least not in the way
that you may be used to from other languages. Yeah, it's
John Nagle na...@animats.com writes:
A decent OS will use copy-on-write with forked processes, which should
carry through to the cache for the code.
That doesn't help much if you're using the subprocess module. The
C code of the interpreter is shared, but all the code generated from
Michael Pardee python-l...@open-sense.com writes:
But what would be the python way to accomplish list of variables
functionality?
You'll need to explain what “list of variables” functionality is.
If you mean “collection of name-to-value mappings”, the native mapping
type in Python is ‘dict’.
On Sat, Feb 20, 2010 at 6:55 PM, marwie mar...@gmx.de wrote:
Now my question is
if there's a similar thing for breaking a list into two parts. Let's
say I want to remove from l1 everything from and including position 10
and store it in l2. Then I can write
l2 = l1[10:]
del l1[10:]
On Sat, 20 Feb 2010 21:25:19 -0600, Michael Pardee wrote:
I'm relatively new to python and I was very surprised by the following
behavior:
[snip]
I don't see why. It's fairly unusual behaviour to want, and it would be
surprising if you did this:
def test():
x = 1
mylist = [2, 4, x]
Steven D'Aprano wrote:
[snip]
I'm sympathetic to your concern: I've often felt offended that doing
something like this:
x = SomeReallyBigListOrString
for item in x[1:]:
process(item)
has to copy the entire list or string (less the first item). But
honestly, I've never found a situation
On Sat, Feb 20, 2010 at 5:41 PM, Steven D'Aprano
st...@remove-this-cybersource.com.au wrote:
What the OP wants is:
(1) assign the name l2 to l1[:10] without copying
(2) resize l1 in place to the first 10 items without affecting l2.
For ten items, though, is it really faster to muck around
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
python-l...@open-sense.com wrote:
But what would be the python way to accomplish list of variables
functionality?
You're looking for namespaces, AKA dicts.
vars = {}
vars['a'] = 1
vars['b'] = 2
mylist = ['a', 'b']
print [vars[i] for i in
1 - 100 of 136 matches
Mail list logo