Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110936
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: problem using pickle |
| Date | 2016-07-02 14:29 +1000 |
| Message-ID | <mailman.9.1467433773.2295.python-list@python.org> (permalink) |
| References | <mailman.62.1457870512.12893.python-list@python.org> <nl7df9$lhe$2@dont-email.me> <85wpl4u0gt.fsf@benfinney.id.au> |
"Veek. M" <vek.m1234@gmail.com> writes:
> class Foo(object):
> pass
>
> object is a keyword and you're using it as an identifier
Python does not have ‘object’ as a keyword. ‘and’ is a keyword.
Here's the difference::
>>> object
<class 'object'>
>>> object = "Lorem ipsum"
>>> object
'Lorem ipsum'
>>> and
File "<stdin>", line 1
and
^
SyntaxError: invalid syntax
>>> and = "Lorem ipsum"
File "<stdin>", line 1
and = "Lorem ipsum"
^
SyntaxError: invalid syntax
Here is how you can test whether a word is a Python keyword::
>>> import keyword
>>> keyword.iskeyword('object')
False
>>> keyword.iskeyword('and')
True
The set of keywords in Python is quite small.
>>> len(keyword.kwlist)
33
--
\ “The best in us does not require the worst in us: Our love of |
`\ other human beings does not need to be nurtured by delusion.” |
_o__) —Sam Harris, at _Beyond Belief 2006_ |
Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: problem using pickle "Veek. M" <vek.m1234@gmail.com> - 2016-07-02 09:16 +0530
Re: problem using pickle Rustom Mody <rustompmody@gmail.com> - 2016-07-01 21:05 -0700
Re: problem using pickle Veek M <vek.m1234@gmail.com> - 2016-10-27 21:23 +0530
Re: problem using pickle Ben Finney <ben+python@benfinney.id.au> - 2016-07-02 14:29 +1000
Re: problem using pickle Veek M <vek.m1234@gmail.com> - 2016-10-27 21:22 +0530
csiph-web