473,386 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

append

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, sequence. Is there a place where
us doofi ( who may not have our heads out in the sunlight) may find
all related syntax grouped together?

thanx,

jh

May 10 '07 #1
13 4736
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, append, sequence.
Have you tried Google? Searching for "python list append" brings up the
following useful looking link to the tutorial at the very top:

http://docs.python.org/tut/node7.html

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
May 10 '07 #3
On 10 May, 18:02, HMS Surprise <j...@datavoiceint.comwrote:
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, sequence. Is there a place where
us doofi ( who may not have our heads out in the sunlight) may find
all related syntax grouped together?
>>dir(list())
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__',
'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
'__setslice__', '__str__', 'append', 'count', 'extend', 'index',
'insert', 'pop', 'remove', 'reverse', 'sort']
This doesn't give syntax, but if you have any questions, try:
>>help(list().append)
May 10 '07 #4
On May 10, 1:11 pm, HMS Surprise <j...@datavoiceint.comwrote:
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

May 10 '07 #5
HMS Surprise <jo**@datavoiceint.comwrote:
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, sequence. Is there a place where
us doofi ( who may not have our heads out in the sunlight) may find
all related syntax grouped together?
Do you really mean syntax?

Anyway, try google: python list methods

The second result is: http://docs.python.org/lib/typesseq-mutable.html
May 10 '07 #6
On 2007-05-10, HMS Surprise <jo**@datavoiceint.comwrote:
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, sequence. Is there a place where us doofi ( who may not
have our heads out in the sunlight) may find all related syntax
grouped together?
You need the material in the Python Manual in the astonishingly
useful Library Reference section 1.2.3: Built-In Types. The only
thing you'll look at nearly as much is 1.2.1: Built-In Functions.

--
Neil Cerutti
May 10 '07 #7

>
Do you really mean syntax?
Thought so?

A few sources I bookmarked to avoid future google two-steps.

http://www.diveintopython.org/native...pes/lists.html
http://en.wikibooks.org/wiki/Python_Programming/Lists
http://infohost.nmt.edu/tcc/help/pubs/python22.pdf

Thank you all.

jh

May 10 '07 #8

"Neil Cerutti" <ho*****@yahoo.comwrote in message
news:sl********************@FIAD06.norwich.edu...
| On 2007-05-10, HMS Surprise <jo**@datavoiceint.comwrote:
| 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, sequence. Is there a place where us doofi ( who may not
| have our heads out in the sunlight) may find all related syntax
| grouped together?
|
| You need the material in the Python Manual in the astonishingly
| useful Library Reference section 1.2.3: Built-In Types. The only
| thing you'll look at nearly as much is 1.2.1: Built-In Functions.

In the current version of the library reference, these are chapter 3
http://docs.python.org/lib/types.html
and section 2.1
http://docs.python.org/lib/built-in-funcs.html

A substantial number of newbie questions are answered therein.

'append' has several entries in the substantial lib ref index.

tjr

May 10 '07 #9
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
strings are immutables. If you want to sequentially build a string, you
can either rebind the name to a new string :

s = ""
for c in "abcdef":
s += c

or collect substrings in a list and join it:

s = []
for c in "abcdef":
s.append(c)
s = "".join(s)
May 10 '07 #10
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 or function, the single most efficient source for me has been
the keyword search page for the Python Library Reference, Language
Reference, and Python/C API manuals that you can find from a link on
the official documentation page at http://www.python.org/doc/ or
directly at

http://starship.python.net/crew/theller/pyhelp.cgi

Full text searches (not limited to keywords like the resource above)
of the Python Library Reference can also be done at
http://www.zvon.org/other/python/PHP/search.php

Other handy references are:

Dive into Python at
http://diveintopython.org/toc/index.html

The Python 2.5 Quick Reference at
http://rgruet.free.fr/PQR25/PQR2.5.html

Last, but far from least, the one resource that I most wish I had
known about when I started with Python is the screencast tutorial site
at www.showmedo.com. There are two excellent free screencasts on
Python resources at http://tinyurl.com/2qkuht and lots of other Python
tutorials, most free and some for a modest fee. In particular, the 9th
installment of the paid series called Python Newbies on XP at
http://tinyurl.com/3ayhwt is about how to use the help functions built
into Python Idle.

May 11 '07 #11
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
[66.25, 333, -1, 333, 1, 1234.5, 333]
>>>a.index(333)
1
>>>a.remove(333)
a
[66.25, -1, 333, 1, 1234.5, 333]
>>>a.reverse()
a
[333, 1234.5, 1, 333, -1, 66.25]
>>>a.sort()
a
[-1, 1, 66.25, 333, 333, 1234.5]

"
On 10 May 2007 10:02:26 -0700, *HMS Surprise* <jo**@datavoiceint.com
<mailto:jo**@datavoiceint.com>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, sequence. Is there a place where
us doofi ( who may not have our heads out in the sunlight) may find
all related syntax grouped together?

thanx,

jh

--
http://mail.python.org/mailman/listinfo/python-list

Most of the syntax is set out in Sections 5, 6, 7 & 8 of the Language
Reference Manual, with a very small part in Section 2.

Colin W.

May 14 '07 #12
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
[66.25, 333, -1, 333, 1, 1234.5, 333]
>>>a.index(333)
1
>>>a.remove(333)
a
[66.25, -1, 333, 1, 1234.5, 333]
>>>a.reverse()
a
[333, 1234.5, 1, 333, -1, 66.25]
>>>a.sort()
a
[-1, 1, 66.25, 333, 333, 1234.5]

"
On 10 May 2007 10:02:26 -0700, *HMS Surprise* <jo**@datavoiceint.com
<mailto:jo**@datavoiceint.com>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, sequence. Is there a place where
us doofi ( who may not have our heads out in the sunlight) may find
all related syntax grouped together?

thanx,

jh

--
http://mail.python.org/mailman/listinfo/python-list

Most of the syntax is set out in Sections 5, 6, 7 & 8 of the Language
Reference Manual, with a very small part in Section 2.

Colin W.
May 14 '07 #13
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrote:
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
strings are immutables. If you want to sequentially build a string, you
can either rebind the name to a new string :
Huh? Where did strings come into this question?
s = ""
for c in "abcdef":
s += c
Huh? Why not just use: s = list(s)? For a more clear example:
>>list("foo")
['f', 'o', 'o']

See?
or collect substrings in a list and join it:
s = []
for c in "abcdef":
s.append(c)
s = "".join(s)
Yes, "".join(list("foo")) is a sort of "expensive" no-op.

As for the original post: dir() and help() from the interactive
prompt are good friends. An ipython prompt is an even better
friend to have while learning python. Consider this:

In[1]:list.app[[Tab]] ...
list.append

In[1]:list.append[[?]][[Enter]]

Type: method_descriptor
Base Class: <type 'method_descriptor'>
String Form: <method 'append' of 'list' objects>
Namespace: Python builtin
Docstring:
L.append(object) -- append object to end

In[2]:

... where I'm highlighting some keystrokes with [[]] marks.

The point is that ipython offers [Tab] completion(*) and
has a number other cool features. For example if you end a
function/method/class/member line with a ? key and hit enter,
then you get a help screen as shown in my mini-transcript above.

Python simply has the best interactive introspection features
around. (Also, if you use docstrings in your own code than
these features will work on your code, too).

For extra fun go into one of your directories which contains
some of your .py files, and/or add a few such directories to
your PYTHONPATH environment variable. Then start up a command
like:

pydoc -p 8080

... or pick some other TCP port.

Then point a web browser at localhost:8080 ...

... see? There's a mini-web service with clickable links
to read the docs for all the Python modules installed on
your system ... including your own code!

* ([Tab]-completion is also possible in the normal python >>>
interpreter using: import rlcompleter
... and then calling the relatively obscure incantation:

rlcompleter.readline.parse_and_bind("tab: complete")

If, like me you prefer vi-mode readline editing then you
add another incantation:

rlcompleter.readline.parse_and_bind("set editing-mode vi")

... or you can simply put the following in you ~/.inputrc:

$if python
set editing-mode vi
$endif

... and, in that case, you can bind other keystrokes into macro
strings like: C-o:"import sys,os" or whatever).
--
Jim Dennis,
Starshine: Signed, Sealed, Delivered

May 25 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: cody | last post by:
Why isn't there an StringBuilder.Append() overload with a StringBuilder as argument? Is there a reason that I missed?
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
9
by: JMCN | last post by:
hi- i have inherited an access 97 database that keeps track of the loans. i have been running into referential intergrity problems when i try to append new loans to table. first of all is a...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
5
by: Michael C via AccessMonster.com | last post by:
Hello, I have a table that I am appending 3 seperate tables into. My main problem is that each time I append the data, it simply adds to the data already there. That might sound ok, except that...
0
by: audleman | last post by:
I have an ASP form on my website where a visitor enters information. On submit, the form calls a stored procedure stores in a MS SQL 2000 database. The stored procedure works most of the time, but...
26
by: John Salerno | last post by:
If I want to create a list of the form (where each item is repeated twice after the first one), how might I do that most efficiently? Right now I have this: series = for x in range(10): ...
2
by: jeremito | last post by:
I have created a class that inherits from the list object. I want to override the append function to allow my class to append several copies at the same time with one function call. I want to do...
10
by: HYRY | last post by:
I have the following questions, I am using Python 2.4.2 19167152 #1 11306608 #1 1. the address of a.append and list.append is different, can I get the address of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.