Re: The future of "frozen" types as the number of CPU cores increases

2010-02-20 Thread sjdevn...@yahoo.com
On Feb 20, 9:58 pm, John Nagle wrote: > sjdevn...@yahoo.com wrote: > > On Feb 18, 2:58 pm, John Nagle 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. > >

Re: lists of variables

2010-02-20 Thread Carl Banks
On Feb 20, 10:50 pm, Steven D'Aprano wrote: > On Sat, 20 Feb 2010 22:31:44 -0800, Carl Banks wrote: > > The one place where Python does have references is when accessing > > variables in an enclosing scope (not counting module-level).   > > What makes you say that? > > > But these > > references a

Re: Shipping Executables

2010-02-20 Thread Gib Bogle
Steven D'Aprano wrote: On Wed, 17 Feb 2010 02:00:59 -0500, geremy condra quoted Banibrata Dutta : BTW for people who are non-believers in something being worth stealing needing protection, need to read about the Skype client. Pardon me for breaking threading, but the original post has not com

Re: lists of variables

2010-02-20 Thread Steven D'Aprano
On Sat, 20 Feb 2010 22:31:44 -0800, Carl Banks wrote: > The one place where Python does have references is when accessing > variables in an enclosing scope (not counting module-level). What makes you say that? > But these > references aren't objects, so you can't store them in a list, so it >

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Steven D'Aprano
On Sat, 20 Feb 2010 21:21:47 -0800, Jonathan Gardner wrote: > On Sat, Feb 20, 2010 at 5:41 PM, Steven D'Aprano > 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,

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Carl Banks
On Feb 20, 4:55 pm, 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 similar th

come and join www.pakdub.com a social network with full features like games, classifieds, forums, blogs and a lot more

2010-02-20 Thread babu lohar
come and join www.pakdub.com a social network with full features like games, classifieds, forums, blogs and a lot more -- http://mail.python.org/mailman/listinfo/python-list

Re: lists of variables

2010-02-20 Thread Carl Banks
On Feb 20, 7:25 pm, Michael Pardee 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: > > >>

Re: if not global -- then what?

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:53 PM, Steven D'Aprano wrote: > 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: >>

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:53 PM, Vincent Davis wrote: >> On Sat, Feb 20, 2010 at 6:44 PM, Jonathan >> Gardner  wrote: >> >> With this kind of data set, you should start looking at BDBs or >> PostgreSQL to hold your data. While processing files this large is >> possible, it isn't easy. Your time i

Re: lists of variables

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee 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 mylis

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:41 PM, Steven D'Aprano 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 with array lengths than just cop

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread MRAB
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 wh

Re: lists of variables

2010-02-20 Thread Steven D'Aprano
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]

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Daniel Stutzbach
On Sat, Feb 20, 2010 at 6:55 PM, marwie 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:] With Py

Re: lists of variables

2010-02-20 Thread Ben Finney
Michael Pardee 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’. If that doesn't meet

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-20 Thread Paul Rubin
John Nagle 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 > Python is not.

Re: lists of variables

2010-02-20 Thread Stephen Hansen
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee wrote: > 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 got data, and data obv

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Steven D'Aprano
On Sat, 20 Feb 2010 17:55:18 -0800, marwie wrote: > On 21 Feb., 02:30, Steven D'Aprano 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 quic

Re: lists of variables

2010-02-20 Thread Chris Rebert
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee 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: >

lists of variables

2010-02-20 Thread Michael Pardee
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

Re: netcdf4-python

2010-02-20 Thread Matt Newville
On Feb 20, 7:47 pm, deadpickle 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', > format='NETCDF3_CLASSIC') > print

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Vincent Davis
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: http://guppy-pe.sourceforge.net/heapy_tutorial

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread marwie
On 21 Feb., 02:41, Steven D'Aprano 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) resize l1 in place to the f

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Ryan Kelly
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 > wrote: > >>> > hello, > > I would like my program to continue on the next line after an uncaugh

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-20 Thread John Nagle
sjdevn...@yahoo.com wrote: On Feb 18, 2:58 pm, John Nagle 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,

Re: Is there a way to continue after an exception ?

2010-02-20 Thread sstein...@gmail.com
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 > wrote: > hello, > > I would like my program to continue on the next line after an uncaught >

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Lie Ryan
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 wrote: >>> hello, I would like my program to continue on the next line after an uncaught exception, is that possible ? thanks Ste

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-20 Thread sjdevn...@yahoo.com
On Feb 18, 2:58 pm, John Nagle 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 should carry throug

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread marwie
On 21 Feb., 02:30, Steven D'Aprano 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, > just clear some pointers and cha

Re: if not global -- then what?

2010-02-20 Thread Steven D'Aprano
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 >

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Vincent Davis
On Sat, Feb 20, 2010 at 6:44 PM, Jonathan Gardner < > jgard...@jonathangardner.net> wrote: With this kind of data set, you should start looking at BDBs or PostgreSQL to hold your data. While processing files this large is possible, it isn't easy. Your time is better spent letting the DB figure

netcdf4-python

2010-02-20 Thread deadpickle
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

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Steven D'Aprano
On Sat, 20 Feb 2010 17:06:36 -0800, Jonathan Gardner wrote: > On Sat, Feb 20, 2010 at 4:55 PM, marwie 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 returns

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:07 PM, Vincent Davis 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 monitor >> shows that py

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 5:32 PM, Vincent Davis wrote: > > 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

Re: datelib pythonification

2010-02-20 Thread alex goretoy
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()

Re: /usr/bin/ld: cannot find -lz on Cent OS - Python 2.4

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 3:03 PM, V8 NUT 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 get MySQL-python-1.

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Steven D'Aprano
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

Re: if not global -- then what?

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 11:25 AM, 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?

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Vincent Davis
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 questi

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 4:21 PM, Vincent Davis wrote: > 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 t

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Shashwat Anand
You can always implement your own data-structures or simply a function if you need so. A language consist of building blocks and not buildings. On Sun, Feb 21, 2010 at 6:36 AM, Jonathan Gardner < jgard...@jonathangardner.net> wrote: > On Sat, Feb 20, 2010 at 4:55 PM, marwie wrote: > > Hello, > >

Re: Not sure why this is filling my sys memory

2010-02-20 Thread Vincent Davis
> 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)

Re: Efficient way to break up a list into two pieces

2010-02-20 Thread Jonathan Gardner
On Sat, Feb 20, 2010 at 4:55 PM, 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

Not sure why this is filling my sys memory

2010-02-20 Thread Vincent Davis
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 ge

Efficient way to break up a list into two pieces

2010-02-20 Thread marwie
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 want

Re: The Disappearing Program?

2010-02-20 Thread MRAB
rzed wrote: "W. eWatson" 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 snowball.py but n

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-20 Thread Tim Roberts
Chris Rebert wrote: >On Thu, Feb 18, 2010 at 11:58 AM, John Nagle 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 special characters. -- Tim Robert

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Daniel Fetchinson
> I would like my program to continue on the next line after an uncaught > exception, > is that possible ? try: # here is your error except: pass # this will get executed no matter what See http://docs.python.org/tutorial/errors.html HTH, Daniel -- Psss, psss, put it down! - http://

Re: The Disappearing Program?

2010-02-20 Thread rzed
"W. eWatson" 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 > snowball.py but not snow

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Lie Ryan
> On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki 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" -- http://mail.python.org/mailman/list

Re: speed question, reading csv using takewhile() and dropwhile()

2010-02-20 Thread Vincent Davis
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):

Re: Can't Access ANY url from python (errno 61)

2010-02-20 Thread Steven D'Aprano
On Sat, 20 Feb 2010 18:28:16 +, Martin P. Hellwig wrote: > On 02/20/10 00:20, MattB wrote: > >> >> 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. > > It wasn't my intention to

Re: if not global -- then what?

2010-02-20 Thread Steven D'Aprano
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 file

Re: MODULE FOR I, P FRAME

2010-02-20 Thread Tim Roberts
DANNY 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 you want to manipul

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Krister Svanlund
On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki 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. -- http://mail.python.org/mailman/listinfo/python-l

Is there a way to continue after an exception ?

2010-02-20 Thread Stef Mientki
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

Re: calculating a string equation

2010-02-20 Thread Chris Rebert
On Sat, Feb 20, 2010 at 3:07 PM, Astan Chee wrote: > Arnaud Delobelle wrote: > Astan Chee 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

Re: calculating a string equation

2010-02-20 Thread Astan Chee
Arnaud Delobelle wrote: Astan Chee 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 and see if eqat

/usr/bin/ld: cannot find -lz on Cent OS - Python 2.4

2010-02-20 Thread V8 NUT
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 -sh

Reading a large bz2 textfile exits early

2010-02-20 Thread Norman Rieß
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 loo

Re: Pure virtual functions in Python?

2010-02-20 Thread Arnaud Delobelle
lallous 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 param2: ... >

Re: finding element by tag in xml

2010-02-20 Thread Dj Gilcrease
On Sat, Feb 20, 2010 at 9:27 AM, sWrath swrath 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

Re: finding element by tag in xml

2010-02-20 Thread Jim
On Feb 20, 11:27 am, sWrath swrath 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 think the err

Re: Building a dict from a tuple of tuples

2010-02-20 Thread vsoler
On Feb 20, 8:54 pm, MRAB wrote: > vsoler wrote: > > On Feb 20, 7:00 pm, MRAB 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

How would I do a continuous write over a pipe in the following code...

2010-02-20 Thread chad
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 w

Re: Pure virtual functions in Python?

2010-02-20 Thread I V
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 vi

Re: if not global -- then what?

2010-02-20 Thread Krister Svanlund
On Sat, Feb 20, 2010 at 8:25 PM, 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?

Re: if not global -- then what?

2010-02-20 Thread Gary Herron
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

Re: if not global -- then what?

2010-02-20 Thread MRAB
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 in

Re: Building a dict from a tuple of tuples

2010-02-20 Thread MRAB
vsoler wrote: On Feb 20, 7:00 pm, MRAB 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 header. For example: d={ (

if not global -- then what?

2010-02-20 Thread egasimus
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

Re: Compiling and running 32-bit Python on 64-bit server?

2010-02-20 Thread Martin v. Loewis
> 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

Re: os.pipe() + os.fork()

2010-02-20 Thread Gary Herron
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 tri

Re: Building a dict from a tuple of tuples

2010-02-20 Thread vsoler
On Feb 20, 7:00 pm, MRAB 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 > > header.

Compiling and running 32-bit Python on 64-bit server?

2010-02-20 Thread Mikko Ohtamaa
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 re

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
@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 the

Re: Pure virtual functions in Python?

2010-02-20 Thread Peter Otten
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

Re: the mystery of dirname()

2010-02-20 Thread Shashwat Anand
got it. thanks. :) On Sat, Feb 20, 2010 at 11:19 PM, MRAB 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 directory name, which >

Re: Can't Access ANY url from python (errno 61)

2010-02-20 Thread Martin P. Hellwig
On 02/20/10 00:20, MattB wrote: 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. It wasn't my intention to imply that, rather the opposite, that if some BOFH would see your action as m

Re: Building a dict from a tuple of tuples

2010-02-20 Thread MRAB
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, (u'b',u'y')

Re: Precision issue in python

2010-02-20 Thread Mark Dickinson
On Sat, Feb 20, 2010 at 2:42 PM, Shashwat Anand 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 raw_input().split()] >   

Re: the mystery of dirname()

2010-02-20 Thread MRAB
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, the

Re: Can't Access ANY url from python (errno 61)

2010-02-20 Thread Lie Ryan
On 02/20/10 19:36, MattB wrote: > On Feb 20, 2:02 am, Lie Ryan 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 blo

Building a dict from a tuple of tuples

2010-02-20 Thread vsoler
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 c

Re: Precision issue in python

2010-02-20 Thread Mark Dickinson
On Feb 20, 3:37 pm, mukesh tiwari 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 already importing the math module

Re: Pure virtual functions in Python?

2010-02-20 Thread Rami Chowdhury
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):

Re: Pure virtual functions in Python?

2010-02-20 Thread Diez B. Roggisch
Sorry, I totally mis-read the OP, too tired. You are right of course. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Pure virtual functions in Python?

2010-02-20 Thread Martin v. Loewis
>> 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 '

Re: Pure virtual functions in Python?

2010-02-20 Thread Diez B. Roggisch
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: ...

Re: Pure virtual functions in Python?

2010-02-20 Thread Martin v. Loewis
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

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Steve Howell
On Feb 20, 6:13 am, Michael Sparks wrote: > On Feb 18, 4:15 pm, Steve Howell 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 {

Re: Upgrading Py2exe App

2010-02-20 Thread T
On Feb 19, 4:32 pm, Ryan Kelly wrote: > On Fri, 2010-02-19 at 11:08 -0800, T wrote: > > On Feb 18, 7:19 pm, Ryan Kelly 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 work properly) via

finding element by tag in xml

2010-02-20 Thread sWrath swrath
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 xml.etre

Pure virtual functions in Python?

2010-02-20 Thread 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: ... """ raise NotImplementedErro

Re: Precision issue in python

2010-02-20 Thread Shashwat Anand
> 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 decim

Re: Precision issue in python

2010-02-20 Thread mukesh tiwari
On Feb 20, 8:13 pm, mukesh tiwari wrote: > On Feb 20, 5:44 pm, Mark Dickinson wrote: > > > > > > > On Feb 20, 11:17 am, mukesh tiwari > > wrote: > > > > Hello everyone. I think it is  related to the precision with double > > > arithmetic so i posted here.I am trying with this problem > > > (htt

Re: Few questions on SOAP

2010-02-20 Thread Muhammad Alkarouri
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 t

Re: Precision issue in python

2010-02-20 Thread mukesh tiwari
On Feb 20, 5:44 pm, Mark Dickinson wrote: > On Feb 20, 11:17 am, mukesh tiwari > 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 "No

  1   2   >