Re: Append some stuff into a file with only the last appended line reserved.

2019-09-03 Thread Hongyi Zhao
On Tue, 03 Sep 2019 08:29:31 +1000, Cameron Simpson wrote: > Please describe this in more detail. Present a little pycurl output and > then explain what portion of it should land in the log file. See the following code from here: http://pycurl.io/docs/latest/callbacks.html#xferinfofunction

Re: Append some stuff into a file with only the last appended line reserved.

2019-09-02 Thread Cameron Simpson
On 01Sep2019 04:13, Hongyi Zhao wrote: I want to append some log of pycurl's downloading info to file, and I only want to reserve the last appended line when write. How to do this? Please describe this in more detail. Present a little pycurl output and then explain what portion of it should

Re: Append/Replace a row in a pandas DataFrame [SOLVED]

2016-04-14 Thread Peter Otten
Paulo da Silva wrote: > Às 21:10 de 13-04-2016, Paulo da Silva escreveu: >> Hi all. > ... > >> [6 rows x 4 columns] >> >>> dft=pd.DataFrame([[1,2,3,4]], >> index=[datetime.date(2016,1,12)],columns=df.columns) >> >>> dft >> A B C D >> 2016-01-12 1 2 3 4 >> >> [1 rows x 4 colu

Re: Append/Replace a row in a pandas DataFrame [SOLVED]

2016-04-13 Thread Paulo da Silva
Às 21:10 de 13-04-2016, Paulo da Silva escreveu: > Hi all. ... > [6 rows x 4 columns] > >> dft=pd.DataFrame([[1,2,3,4]], > index=[datetime.date(2016,1,12)],columns=df.columns) > >> dft > A B C D > 2016-01-12 1 2 3 4 > > [1 rows x 4 columns] > >> pd.concat([df,dft]) > Out[71]

Re: Append a file

2015-03-08 Thread Jason Venneri
Jason; Thank you for your response. I’m just starting out with Python and the tutorials I have done are on 2.7.9. I will looking on to python3. It is preloaded on Mac :-). Jason ___ [email protected] 619-227-0927 > On Mar 6, 2015, at 9:37 PM, Jason Friedman w

Re: Append a file

2015-03-06 Thread Jason Friedman
On Fri, Mar 6, 2015 at 2:55 PM, Jason Venneri wrote: > Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines > of data. I want to combine the two results into one file not two. > > Any suggestions? > > Sample > urllib.urlretrieve('http://www.airplanes.com/data/boeing1.htm

Re: Append a file

2015-03-06 Thread sohcahtoa82
On Friday, March 6, 2015 at 1:55:31 PM UTC-8, Jason Venneri wrote: > Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines > of data. I want to combine the two results into one file not two. > > Any suggestions? > > Sample > urllib.urlretrieve('http://www.airplanes.com

Re: Append to python List

2013-05-11 Thread Jussi Piitulainen
Chris Angelico writes: > On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen wrote: > > 8 Dihedral writes: > > > >> This is just the handy style for a non-critical loop. > >> In a critical loop, the number of the total operation counts > >> does matter in the execution speed. > > > > Do you use

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 12:29 PM, 8 Dihedral wrote: > Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道: >> Most humans would get defensive, or at >> least protest, if treated as bots; Dihedral never has, despite being >> referred to in this way a number of times. >> >> ChrisA > > Don't you get

Re: Append to python List

2013-05-11 Thread 88888 Dihedral
Chris Angelico於 2013年5月12日星期日UTC+8上午12時00分44秒寫道: > On Sun, May 12, 2013 at 1:47 AM, Anssi Saari wrote: > > > Chris Angelico writes: > > > > > >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen > > >> wrote: > > >>> 8 Dihedral writes: > > >>> > > This is just the handy style for

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Sun, May 12, 2013 at 1:47 AM, Anssi Saari wrote: > Chris Angelico writes: > >> On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen >> wrote: >>> 8 Dihedral writes: >>> This is just the handy style for a non-critical loop. In a critical loop, the number of the total operation coun

Re: Append to python List

2013-05-11 Thread Anssi Saari
Chris Angelico writes: > On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen > wrote: >> 8 Dihedral writes: >> >>> This is just the handy style for a non-critical loop. >>> In a critical loop, the number of the total operation counts >>> does matter in the execution speed. >> >> Do you use sp

Re: Append to python List

2013-05-11 Thread Chris Angelico
On Thu, May 9, 2013 at 9:30 PM, Jussi Piitulainen wrote: > 8 Dihedral writes: > >> This is just the handy style for a non-critical loop. >> In a critical loop, the number of the total operation counts >> does matter in the execution speed. > > Do you use speed often? Dihedral is a bot. Quite

Re: Append to python List

2013-05-10 Thread 88888 Dihedral
Jussi Piitulainen於 2013年5月9日星期四UTC+8下午7時30分05秒寫道: > 8 Dihedral writes: > > > > > This is just the handy style for a non-critical loop. > > > In a critical loop, the number of the total operation counts > > > does matter in the execution speed. > > > > Do you use speed often? There i

Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
8 Dihedral writes: > This is just the handy style for a non-critical loop. > In a critical loop, the number of the total operation counts > does matter in the execution speed. Do you use speed often? -- http://mail.python.org/mailman/listinfo/python-list

Re: Append to python List

2013-05-09 Thread 88888 Dihedral
Jussi Piitulainen於 2013年5月9日星期四UTC+8下午2時55分20秒寫道: > RAHUL RAJ writes: > > > > > Checkout the following code: > > > > > > sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] > > > output=[] > > > output=[x for x in sample2 if x not in output] > > > > > > the output I get

Re: Append to python List

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 01:18:51 -0700, RAHUL RAJ wrote: > Then what about this code part? What about it? > [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] > > and the following code part: > > for x in [1,2,3]: > for y in [3,1,4]: > if x != y: > combs.append((x, y)) Apart from

Re: Append to python List

2013-05-09 Thread RAHUL RAJ
I'm getting same output for both code parts, why not for th code parts in question? On Thursday, May 9, 2013 1:48:51 PM UTC+5:30, RAHUL RAJ wrote: > Then what about this code part? > > > > [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] > > > > and the following code part: > > > > f

Re: Append to python List

2013-05-09 Thread RAHUL RAJ
Then what about this code part? [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] and the following code part: for x in [1,2,3]: for y in [3,1,4]: if x != y: combs.append((x, y)) On Thursday, May 9, 2013 12:24:24 PM UTC+5:30, Gary Herron wrote: > On 05/08/2013 11:36 PM, RAHUL RA

Re: Append to python List

2013-05-09 Thread Chris Angelico
On Thu, May 9, 2013 at 4:36 PM, RAHUL RAJ wrote: > output=[x for x in sample2 if x not in output] > > output=[] > for x in sample2: > if x not in output: > output.append(x) The first one constructs a list, then points the name 'output' at it. The second one builds up a list, with 'output'

Re: Append to python List

2013-05-09 Thread Gary Herron
On 05/08/2013 11:36 PM, RAHUL RAJ wrote: Checkout the following code: sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] output=[] output=[x for x in sample2 if x not in output] This statement is not doing what you expect. It is not building a list in the variable named outpu

Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
RAHUL RAJ writes: > Checkout the following code: > > sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] > output=[] > output=[x for x in sample2 if x not in output] > > the output I get is > 3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 > 12 13 6 7 8 9 11

Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Terry Reedy
On 7/26/2012 7:55 AM, Simon Pirschel wrote: On 07/26/2012 11:25 AM, Simon Pirschel wrote: Ok, forget about the EXISTS and RECENT response. The server will response this way if you selected a mailbox, which I did in the Python code but not in the Perl code. I disabled selecting the mailbox in Pyt

Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel
On 07/26/2012 11:25 AM, Simon Pirschel wrote: Ok, forget about the EXISTS and RECENT response. The server will response this way if you selected a mailbox, which I did in the Python code but not in the Perl code. I disabled selecting the mailbox in Python and there is no difference in the runti

Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel
On 07/26/2012 09:49 AM, Simon Pirschel wrote: On 07/26/2012 05:21 AM, Tim Chase wrote: On 07/25/12 12:47, Simon Pirschel wrote: I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 from imaplib. I noticed the performance to be very bad. I read 5000 files from a directory and appen

Re: append in IMAP4 from imaplib very slow

2012-07-26 Thread Simon Pirschel
On 07/26/2012 05:21 AM, Tim Chase wrote: On 07/25/12 12:47, Simon Pirschel wrote: I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 from imaplib. I noticed the performance to be very bad. I read 5000 files from a directory and append them to an IMAP INBOX. The hole procedure of

Re: append in IMAP4 from imaplib very slow

2012-07-25 Thread Tim Chase
On 07/25/12 12:47, Simon Pirschel wrote: > I'm currently experimenting with IMAP using Python 2.7.3 and > IMAP4 from imaplib. I noticed the performance to be very bad. I > read 5000 files from a directory and append them to an IMAP > INBOX. The hole procedure of reading and appending is taking > ab

Re: append in IMAP4 from imaplib very slow

2012-07-25 Thread Antoine Pitrou
Simon Pirschel abusix.org> writes: > > Hi, > I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 > from imaplib. I noticed the performance to be very bad. I read 5000 > files from a directory and append them to an IMAP INBOX. The hole > procedure of reading and

Re: append method

2012-05-23 Thread Chris Kaynor
On Wed, May 23, 2012 at 12:42 PM, Dave Angel wrote: > On 05/23/2012 03:13 PM, Emile van Sebille wrote: >> A design decision -- there's currently a mix of methods that return >> themselves and not.  Mostly is appears to me that mutables modify in >> place without returning self and immutables retur

Re: append method

2012-05-23 Thread Dave Angel
On 05/23/2012 03:13 PM, Emile van Sebille wrote: > On 5/23/2012 5:23 AM 水静流深 said... >> >>> s=[1,2,3] >> >>> s.append(5) >> >>> s >> [1, 2, 3, 5] >> >>> s=s.append(5) >> >>> s >> >>> print s >> None >> >> why can't s=s.append(5) > > It could, but it doesn't. > > >> ,what is the reason? > > >

Re: append method

2012-05-23 Thread Emile van Sebille
On 5/23/2012 5:23 AM 水静流深 said... >>> s=[1,2,3] >>> s.append(5) >>> s [1, 2, 3, 5] >>> s=s.append(5) >>> s >>> print s None why can't s=s.append(5) It could, but it doesn't. ,what is the reason? A design decision -- there's currently a mix of methods that return themselves and not

Re: append method

2012-05-23 Thread Karl Knechtel
On Wed, May 23, 2012 at 8:23 AM, 水静流深 <[email protected]> wrote: s=[1,2,3] s.append(5) s > [1, 2, 3, 5] s=s.append(5) s print s > None > > why can't  s=s.append(5)  ,what is the reason? For the same reason that you don't see `[1, 2, 3, 5]` immediately after doing `s.a

Re: append method

2012-05-23 Thread Jean-Michel Pichavant
wrote: >>> s=[1,2,3] >>> s.append(5) >>> s [1, 2, 3, 5] >>> s=s.append(5) >>> s >>> print s None why can't s=s.append(5) ,what is the reason? Because the append method returns None, not the object. It modifies the object in place, and does not create any copy. You can still write s

Re: Append to an Excel file

2010-01-12 Thread Chris Withers
Niels L. Ellegaard wrote: pp writes: On Jan 9, 1:47 am, Jason Scheirer wrote: On Jan 9, 12:30 am, pp wrote: Hi All, How do I add a line to an existing file. This should append to the existing data in the excel file, which was saved previously. Thanks, PP http://pypi.python.org/pypi/xlwt

Re: Append to an Excel file

2010-01-09 Thread Niels L. Ellegaard
pp writes: > On Jan 9, 1:47 am, Jason Scheirer wrote: >> On Jan 9, 12:30 am, pp wrote: >> >> > Hi All, >> >> > How do I add a line to an existing file. This should append to the >> > existing data in the excel file, which was saved previously. >> >> > Thanks, >> > PP >> >> http://pypi.python.or

Re: Append to an Excel file

2010-01-09 Thread Steve Holden
pp wrote: > On Jan 9, 1:47 am, Jason Scheirer wrote: >> On Jan 9, 12:30 am, pp wrote: >> >>> Hi All, >>> How do I add a line to an existing file. This should append to the >>> existing data in the excel file, which was saved previously. >>> Thanks, >>> PP >> http://pypi.python.org/pypi/xlwt > >

Re: Append to an Excel file

2010-01-09 Thread pp
On Jan 9, 1:47 am, Jason Scheirer wrote: > On Jan 9, 12:30 am, pp wrote: > > > Hi All, > > > How do I add a line to an existing file. This should append to the > > existing data in the excel file, which was saved previously. > > > Thanks, > > PP > > http://pypi.python.org/pypi/xlwt Hi Jason and

Re: Append to an Excel file

2010-01-09 Thread Jason Scheirer
On Jan 9, 12:30 am, pp wrote: > Hi All, > > How do I add a line to an existing file. This should append to the > existing data in the excel file, which was saved previously. > > Thanks, > PP http://pypi.python.org/pypi/xlwt -- http://mail.python.org/mailman/listinfo/python-list

Re: Append Problem

2010-01-02 Thread Victor Subervi
On Sat, Jan 2, 2010 at 10:46 AM, Steve Holden wrote: > > See the .sig. Of course I'm a businessman. > Nice site! In that case, respectfully I disagree! beno -- http://mail.python.org/mailman/listinfo/python-list

Re: Append Problem

2010-01-02 Thread Steve Holden
Victor Subervi wrote: [...] > While the learning you have performed in getting this system to work > (for some rather questionable value of "work", I can't help feeling, but > we'll overlook the horrors induced by your lack of programming > experience) is a testament to your persist

Re: Append Problem

2010-01-02 Thread Victor Subervi
There isn't a tuple is sight there - you are dealing with lists, and you > are modifying the very list you are iterating over. > > Try rewriting the code to create a new list from the old one (i.e. > iterate over catChains and have your code append to an initially empty > list called, for example,

Re: Append Problem

2010-01-02 Thread Steve Holden
Victor Subervi wrote: > Hi; > I have the following code snippet: > > print 'Original: ', catChains, '' > while i < MAXLEVEL: > flag = 0 > j = 0 > while j < len(parents): > for chain in catChains: > if parents[j] == chain[len(chain)-1]: > chain.append(childre

Re: Append a new value to dict

2008-10-23 Thread bearophileHUGS
slais-www: > Slower than > ... Okay, I seen there's a little confusion, I try to say it more clearly. Generally this is the faster version (faster than the version with get), especially if you use Psyco: version 1) if 'B' in counter: counter['B'] += 1 else: counter['B'] = 1

Re: Append a new value to dict

2008-10-23 Thread slais-www
[EMAIL PROTECTED] wrote: Marc 'BlackJack' Rintsch: counter['B'] = counter.get('B', 0) + 1 If you benchmark it, you will find that using the get() method it's quite slower. Slower than if 'B' in counter: > counter['B'] += 1 > else: > counter['B'] = 1 ? It is not slower than default

Re: Append a new value to dict

2008-10-23 Thread [EMAIL PROTECTED]
Frank Niemeyer wrote: > >> However incrementing a non-existing key throws an exception. > > Right. And that's exactly what I would expect, according to the > "principle of least surprise" Python tries to obey. There's simply no > way to increment a non-existent value - not without performing s

Re: Append a new value to dict

2008-10-23 Thread bearophileHUGS
Marc 'BlackJack' Rintsch: > counter['B'] = counter.get('B', 0) + 1 If you benchmark it, you will find that using the get() method it's quite slower. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Append a new value to dict

2008-10-23 Thread Frank Niemeyer
[EMAIL PROTECTED] schrieb: > Frank Niemeyer: >> There's simply no >> way to increment a non-existent value - not without performing some >> obscure implict behind-the-scenes stuff. > > Like importing and using a defaultdict(int). There's nothing implicit in explicitly defining some default behavi

Re: Append a new value to dict

2008-10-22 Thread Marc 'BlackJack' Rintsch
On Wed, 22 Oct 2008 10:12:56 -0700, bearophileHUGS wrote: > Frank Niemeyer: >> There's simply no >> way to increment a non-existent value - not without performing some >> obscure implict behind-the-scenes stuff. > > Like importing and using a defaultdict(int). > > >> > So you >> > either have t

Re: Append a new value to dict

2008-10-22 Thread bearophileHUGS
Frank Niemeyer: > There's simply no > way to increment a non-existent value - not without performing some > obscure implict behind-the-scenes stuff. Like importing and using a defaultdict(int). > > So you > > either have to use a workaround: > > >  >>> try: > > ...   counter['B'] += 1 > > ... ex

Re: Append a new value to dict

2008-10-22 Thread Frank Niemeyer
> However incrementing a non-existing key throws an exception. Right. And that's exactly what I would expect, according to the "principle of least surprise" Python tries to obey. There's simply no way to increment a non-existent value - not without performing some obscure implict behind-the-scenes

Re: Append a new value to dict

2008-10-16 Thread Pat
paul wrote: Pat schrieb: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.s

Re: Append a new value to dict

2008-10-16 Thread Boris Borcic
Kirk Strauser wrote: While we're on the subject, use keyword arguments to dict like: foo.update(dict(quux='blah', baz='bearophile', jdd='dict')) was *much* slower, at 11.8s. Presumably you would save half of that time by writing simply foo.update(quux='blah', baz='bearophile', jdd

Re: Append a new value to dict

2008-10-13 Thread pruebauno
On Oct 13, 9:41 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 13 Oct 2008 14:10:43 +0200, Mathias Frey wrote: > > However incrementing a non-existing key throws an exception. So you > > either have to use a workaround: > > > >>> try: > > ... counter['B'] += 1 > > ... except K

Re: Append a new value to dict

2008-10-13 Thread Kirk Strauser
At 2008-10-13T13:14:15Z, [EMAIL PROTECTED] writes: > jdd: >> foo = {'bar': 'baz'} >> foo.update({'quux': 'blah'}) > > That creates a new dict, to throw it away. Don't do that. I use that if I'm changing many values at once, eg: foo.update({ 'quux': 'blah', 'baz' : 'bearophile

Re: Append a new value to dict

2008-10-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : jdd: foo = {'bar': 'baz'} foo.update({'quux': 'blah'}) That creates a new dict, to throw it away. Just to make it clear for the easily confused ones (like me...): bearophile is talking about the dict passed as an argument to foo.update - not about the behaviour

Re: Append a new value to dict

2008-10-13 Thread Marc 'BlackJack' Rintsch
On Mon, 13 Oct 2008 14:10:43 +0200, Mathias Frey wrote: > However incrementing a non-existing key throws an exception. So you > either have to use a workaround: > > >>> try: > ... counter['B'] += 1 > ... except KeyError: > ... counter['B'] = 1 > > Since this looks ugly somebody invented the

Re: Append a new value to dict

2008-10-13 Thread bearophileHUGS
jdd: > foo = {'bar': 'baz'} > foo.update({'quux': 'blah'}) That creates a new dict, to throw it away. Don't do that. Use the standard and more readable syntax: > foo = {...} > foo['quux'] = 'blah' Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Append a new value to dict

2008-10-13 Thread Tim Chase
In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [] ).append( v ) Naturally, right after writing my post I found that there is an easier way: table[ k ] = v Just to be clear...these do two VERY different things: >>> v1=42

Re: Append a new value to dict

2008-10-13 Thread Mathias Frey
Pat wrote: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [

Re: Append a new value to dict

2008-10-13 Thread paul
Pat schrieb: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k,

Re: Append a new value to dict

2008-10-13 Thread jdd
On Oct 13, 7:21 am, Pat <[EMAIL PROTECTED]> wrote: > Is there a better/easier way to code this in Python than the > obtuse/arcane setdefault code? foo = {'bar': 'baz'} foo.update({'quux': 'blah'}) -- http://mail.python.org/mailman/listinfo/python-list

Re: Append a new value to dict

2008-10-13 Thread Pat
Pat wrote: I know it's not "fair" to compare language features, but it seems to me (a Python newbie) that appending a new key/value to a dict in Python is awfully cumbersome. In Python, this is the best code I could come up with for adding a new key, value to a dict mytable.setdefault( k, [

Re: append on lists

2008-09-18 Thread Steve Holden
Armin wrote: > Duncan Booth wrote: >> "Chris Rebert" <[EMAIL PROTECTED]> wrote: >>> On Tue, Sep 16, 2008 at 1:20 AM, Armin <[EMAIL PROTECTED]> wrote: [1,2,3,4,7].append(c) -> Is this a valid expression? >>> Literally, no, because you can't call methods on literals. >> >> Rubbish. There is no

Re: append on lists

2008-09-18 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Sep 16, 6:03 am, Peter Anderson <[EMAIL PROTECTED]> > wrote: >> "/... I don't think you've thought this one through, really./" >> snip >> >> We ought to try and be a little kinder to others on the list, don't you >> think? :-) >> >> snip > > Well said! >From personal

Re: append on lists

2008-09-17 Thread Lie
On Sep 16, 3:20 pm, Armin <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > On Sep 16, 6:45 am, Armin <[EMAIL PROTECTED]> wrote: > > >> Yes, but this is very unconvenient. > >> If d should reference the list a extended with a single list element > >> you need at least two lines > > >> a.append(7)

Re: append on lists

2008-09-16 Thread J. Cliff Dyer
On Tue, 2008-09-16 at 08:49 -0500, Grant Edwards wrote: > On 2008-09-16, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > Duncan Booth <[EMAIL PROTECTED]> writes: > > > >> The only relatively common use I can think of where you might want to call > >> a method directly on a literal is to produce a li

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez ?crit?: >> I was asking where in the specification >> it says that all >> expressions that return something, return a new object. ? > > I n

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : Where is that in the specification? Each literal creates a new instance, This does not answer 'where' but just adds another false claim. I just reread the Reference Manual, Lexical Analysis chapt

Re: append on lists

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: all expressions that return something, return a new object, That's not _quite_ true: a=1 b=a.__add__(0) a is b True ;) This is implementation

Re: append on lists

2008-09-16 Thread Terry Reedy
Maric Michaud wrote: It is, please try to understand it, in python all expressions that mutate an object should return None, You are over-generalizing. For builtin classes, mutation methods return none. Guido recommends this as a general practice, but users may do whatever they like in the

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez écrit : >> I was asking where in the specification >> it says that all expressions that >> return something, return a >> new object.   > > I

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 18:26:38 Grant Edwards, vous avez écrit : > I was asking where in the specification > it says that all expressions that > return something, return a > new object.   I never said this, I said it's the spirit of python APIs, with som

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: >> > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : >> >> On 2008-09-16, Maric Michaud

Re: literals optimization (was Re: append on lists)

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 16:57:26 Grant Edwards, vous avez écrit : > On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : > >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > >> > all expressions that return

Re: append on lists

2008-09-16 Thread Grant Edwards
On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : >> On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: >> > all expressions that return something, return a new object, >> >> That's not _quite_ true: >> >>> a=1 >> >

Re: append on lists

2008-09-16 Thread Maric Michaud
Le Tuesday 16 September 2008 15:57:53 Grant Edwards, vous avez écrit : > On 2008-09-16, Maric Michaud <[EMAIL PROTECTED]> wrote: > > all expressions that return something, return a new object, > > That's not _quite_ true: > >>> a=1 > >>> b=a.__add__(0) > >>> a is b > > True > > ;) This is implemen

Re: append to a sublist - please help

2008-04-06 Thread Lie
On Apr 6, 11:16 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Hi, > > I must be blind but I don't see what's going wrong > with The reason is: > G=[[]]*2 is doing a "shallow copy" of the blank list. The corrected code is either: G = [[] for _ in xrange(2)] or G = [[], []] btw, this is a

Re: append to a sublist - please help

2008-04-06 Thread Arnaud Delobelle
On Apr 6, 5:16 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Hi, > > I must be blind but I don't see what's going wrong > with > > G=[[]]*2 > > G[0].append('A') > G[1].append('B') > print G[0] > > gives > > ['A', 'B'] > > as well as > print G[1] > > I was expecting > ['A'] > and > ['B'] > respec

Re: Append zip files together, just get the binary data (in memory)

2008-01-15 Thread Neil Cerutti
On Jan 15, 2008 4:28 AM, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 15, 9:58 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > > Module StringIO is your friend. > > and cStringIO is your ? ... friend +1? -- Neil Cerutti <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/

Re: Append zip files together, just get the binary data (in memory)

2008-01-15 Thread John Machin
On Jan 15, 9:58 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Module StringIO is your friend. and cStringIO is your ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Append zip files together, just get the binary data (in memory)

2008-01-14 Thread BerlinBrown
On Jan 14, 5:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > BerlinBrown schrieb: > > > Is it possible to just build the binary content of a zip file. I want > > to create the content in memory (e.g. return binary data) and then get > > those byte strings representing the zip file? Is that

Re: Append zip files together, just get the binary data (in memory)

2008-01-14 Thread Diez B. Roggisch
BerlinBrown schrieb: > Is it possible to just build the binary content of a zip file. I want > to create the content in memory (e.g. return binary data) and then get > those byte strings representing the zip file? Is that possible? > > Or could I possibly override functions in the zip class. >

Re: append

2007-05-25 Thread James T. Dennis
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > HMS Surprise a ?crit : >> Trying not to be a whiner but I sure have trouble finding syntax in >> the reference material. I want to know about list operations such as >> append. > The only thing you have to know is that it doesn't exists. Python >

Re: append

2007-05-13 Thread Colin J. Williams
Sick Monkey wrote: > http://docs.python.org/tut/node7.html > > Yes there is a pop function. > > "An example that uses most of the list methods: > a = [66.25, 333, 333, 1, 1234.5] print a.count(333), a.count(66.25), a.count('x') > 2 1 0 a.insert(2, -1) a.append(333) a >

Re: append

2007-05-11 Thread vdicarlo
> > the reference material. I want to know about list >> operations such as > > append. I've been struggling myself to assemble and learn just the right combination of quick references. Here is some of what I've found. For a quick search for the syntax and a simple example of a particular method

Re: append

2007-05-10 Thread Terry Reedy
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On 2007-05-10, HMS Surprise <[EMAIL PROTECTED]> wrote: | > Trying not to be a whiner but I sure have trouble finding | > syntax in the reference material. I want to know about list | > operations such as append. Is there

Re: append

2007-05-10 Thread HMS Surprise
> > Do you really mean syntax? > Thought so? A few sources I bookmarked to avoid future google two-steps. http://www.diveintopython.org/native_data_types/lists.html http://en.wikibooks.org/wiki/Python_Programming/Lists http://infohost.nmt.edu/tcc/help/pubs/python22.pdf Thank you all. jh --

Re: append

2007-05-10 Thread Neil Cerutti
On 2007-05-10, HMS Surprise <[EMAIL PROTECTED]> wrote: > Trying not to be a whiner but I sure have trouble finding > syntax in the reference material. I want to know about list > operations such as append. Is there a pop type function? I > looked in tutorial, language reference, and lib for list, >

Re: append

2007-05-10 Thread Duncan Booth
HMS Surprise <[EMAIL PROTECTED]> wrote: > Trying not to be a whiner but I sure have trouble finding syntax in > the reference material. I want to know about list operations such as > append. Is there a pop type function? I looked in tutorial, language > reference, and lib for list, append, sequenc

Re: append

2007-05-10 Thread jmg3000
On May 10, 1:11 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > Found list popping at > > http://en.wikibooks.org/wiki/Python_Programming/Lists:) You can find terse info on the list methods by doing: >>> help(list) ---John -- http://mail.python.org/mailman/listinfo/python-list

Re: append

2007-05-10 Thread Bill Pursell
On 10 May, 18:02, HMS Surprise <[EMAIL PROTECTED]> wrote: > Trying not to be a whiner but I sure have trouble finding syntax in > the reference material. I want to know about list operations such as > append. Is there a pop type function? I looked in tutorial, language > reference, and lib for list

Re: append

2007-05-10 Thread HMS Surprise
Found list popping at http://en.wikibooks.org/wiki/Python_Programming/Lists :) -- http://mail.python.org/mailman/listinfo/python-list

Re: append

2007-05-10 Thread Carsten Haese
On Thu, 2007-05-10 at 10:02 -0700, HMS Surprise wrote: > Trying not to be a whiner but I sure have trouble finding syntax in > the reference material. I want to know about list operations such as > append. Is there a pop type function? I looked in tutorial, language > reference, and lib for list, a

Re: append

2007-05-10 Thread Sick Monkey
http://docs.python.org/tut/node7.html Yes there is a pop function. "An example that uses most of the list methods: a = [66.25, 333, 333, 1, 1234.5] print a.count(333), a.count(66.25), a.count('x') 2 1 0 a.insert(2, -1) a.append(333) a [66.25, 333, -1, 333, 1, 1234.5, 333] a.index(333) 1

Re: Append data to a list within a dict

2007-04-15 Thread Tina I
Alex Martelli wrote: > Tina I <[EMAIL PROTECTED]> wrote: >... >> He he... at the age of 40 I'm well beyond school work ;) > > Why would that be? My wife's over 40, yet she's a student (currently at > Stanford -- they were overjoyed to admit her, with lot of life > experience as well as previo

Re: Append data to a list within a dict

2007-04-14 Thread Alex Martelli
Tina I <[EMAIL PROTECTED]> wrote: ... > He he... at the age of 40 I'm well beyond school work ;) Why would that be? My wife's over 40, yet she's a student (currently at Stanford -- they were overjoyed to admit her, with lot of life experience as well as previous studies, apparently). She's no

Re: Append data to a list within a dict

2007-04-14 Thread Hendrik van Rooyen
"Tina I" wrote: > Hello group, > > Say I have the following dictionary: > > ListDict = { > 'one' : ['oneone' , 'onetwo' , 'onethree'], > 'two' : ['twoone' , 'twotwo', 'twothree'], > 'three' : ['threeone' , 'threetwo', threethree']} > > Now I want to append 'twofour' to the list of the 'two'

Re: Append data to a list within a dict

2007-04-13 Thread Tina I
Michael Bentley wrote: > > On Apr 14, 2007, at 12:39 AM, Tina I wrote: > >> Say I have the following dictionary: >> >> ListDict = { >> 'one' : ['oneone' , 'onetwo' , 'onethree'], >> 'two' : ['twoone' , 'twotwo', 'twothree'], >> 'three' : ['threeone' , 'threetwo', threethree']} >> >> Now I want to

Re: Append data to a list within a dict

2007-04-13 Thread Tina I
Paul Rubin wrote: > Tina I <[EMAIL PROTECTED]> writes: >> ListDict = { >> 'one' : ['oneone' , 'onetwo' , 'onethree'], >> 'two' : ['twoone' , 'twotwo', 'twothree'], >> 'three' : ['threeone' , 'threetwo', threethree']} >> >> Now I want to append 'twofour' to the list of the 'two' key but I >> can't f

Re: Append data to a list within a dict

2007-04-13 Thread Michael Bentley
On Apr 14, 2007, at 12:51 AM, Paul Rubin wrote: > Is this a class exercise? Hint: > 1) figure out how to access the list of the 'two' key > 2) append 'twofour' to it. damn. -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >