Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44552
| References | <ad277b74-0fbd-456d-915e-e87743dc16df@googlegroups.com> <517FE68A.1000703@davea.name> <CAPTjJmp9_Mc+uhP3n1DsSLUpo4=81xo4Qv-5zLj3K_qD=AwfXA@mail.gmail.com> <517FEA29.1010006@davea.name> |
|---|---|
| Date | 2013-05-01 02:06 +1000 |
| Subject | Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1185.1367338005.3114.python-list@python.org> (permalink) |
On Wed, May 1, 2013 at 1:58 AM, Dave Angel <davea@davea.name> wrote:
> On 04/30/2013 11:49 AM, Chris Angelico wrote:
>>
>> On Wed, May 1, 2013 at 1:43 AM, Dave Angel <davea@davea.name> wrote:
>>>
>>> On 04/30/2013 11:27 AM, tromeo@mdlogix.com wrote:
>>>>
>>>>
>>>>
>>>> Please help me to debug
>>>>
>>>> -------
>>>> shmid = shmget(SHM_KEY, SHM_SIZE, 0o666)
>>>> ^
>>>> SyntaxError: invalid syntax
>>>>
>>>
>>> 0o666 is indeed a syntax error. What is that value supposed to be? If
>>> it's
>>> intended to be an int that's equal to octal 666, just use 438
>>
>>
>> Without checking docs, I would guess that to be Unix file permissions,
>> which make most sense in octal.
>>
>>
>
> So put the octal description in the comment. I think the Python 2.x syntax
> for octal is a travesty. And of course it's non-portable to Python 3. I
> would not intentionally leave 0666 in my source code, unless there was some
> other overriding reason for it. And then I'd surround it with snide
> remarks.
Here's a stupid way to convert octal to decimal in Python:
>>> ord("\666")
438
Because backslash escapes in strings are, per convention, done in
octal. :) And actually, on the extremely rare occasions when they're
NOT octal, it's highly confusing.
http://rosuav.blogspot.com.au/2012/12/i-want-my-octal.html
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. tromeo@mdlogix.com - 2013-04-30 08:27 -0700
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-30 11:36 -0400
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Chris Angelico <rosuav@gmail.com> - 2013-05-01 01:37 +1000
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Tony Romeo <tromeo@mdlogix.com> - 2013-04-30 08:52 -0700
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Chris Angelico <rosuav@gmail.com> - 2013-05-01 01:58 +1000
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Dave Angel <davea@davea.name> - 2013-04-30 11:43 -0400
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Chris Angelico <rosuav@gmail.com> - 2013-05-01 01:49 +1000
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Dave Angel <davea@davea.name> - 2013-04-30 11:58 -0400
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Chris Angelico <rosuav@gmail.com> - 2013-05-01 02:06 +1000
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Tony Romeo <tromeo@mdlogix.com> - 2013-04-30 11:10 -0700
Re: shmid = shmget(SHM_KEY, SHM_SIZE, 0o666) - syntax error. Chris Angelico <rosuav@gmail.com> - 2013-05-01 07:51 +1000
csiph-web