Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75868
| X-Received | by 10.66.150.201 with SMTP id uk9mr3255864pab.17.1407482246041; Fri, 08 Aug 2014 00:17:26 -0700 (PDT) |
|---|---|
| X-Received | by 10.50.61.145 with SMTP id p17mr50939igr.16.1407482245796; Fri, 08 Aug 2014 00:17:25 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h18no16004499igc.0!news-out.google.com!px9ni588igc.0!nntp.google.com!h18no16004496igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Fri, 8 Aug 2014 00:17:25 -0700 (PDT) |
| In-Reply-To | <53e464a3$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=59.95.47.175; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui |
| NNTP-Posting-Host | 59.95.47.175 |
| References | <7bd83ac7-17e6-49c2-b5c7-3236c900d005@googlegroups.com> <mailman.12720.1407394838.18130.python-list@python.org> <roy-496ACC.07490507082014@news.panix.com> <53e3afd9$0$29970$c3e8da3$5496439d@news.astraweb.com> <f865db66-8cb8-4796-a8f0-bedfb2ef5079@googlegroups.com> <53e464a3$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <ca10fd68-16c7-45dc-b281-8a84e83d0b23@googlegroups.com> (permalink) |
| Subject | Re: AttributeError: 'module' object has no attribute 'fork' |
| From | Rustom Mody <rustompmody@gmail.com> |
| Injection-Date | Fri, 08 Aug 2014 07:17:25 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:75868 |
Show key headers only | View raw
On Friday, August 8, 2014 11:18:17 AM UTC+5:30, Steven D'Aprano wrote:
> Rustom Mody wrote:
> > On Thursday, August 7, 2014 10:26:56 PM UTC+5:30, Steven D'Aprano wrote:
> >> Roy Smith wrote:
> >> > Peter Otten wrote:
> >> >> os.fork()
> >> >> Fork a child process.
> >> >> ...
> >> >> Availability: Unix.
> >> >> """
> >> >> You are using the wrong operating system ;)
> >> > To be honest, this could be considered a buglet in the os module. It
> >> > really should raise:
> >> > NotImplementedError("fork() is only available on unix")
> >> > or perhaps even, as Peter suggests:
> >> > NotImplementedError("You are using the wrong operating system")
> >> > either of those would be better than AttributeError.
> >> I disagree. How would you tell if fork is implemented? With the current
> >> behaviour, telling whether fork is implemented or not is simple:
> >> is_implemented = hasattr(os, "fork")
> [...]
> > Surely I am missing something but why not check os.fork before
> > checking os.fork() ?
> Yes, you're missing something. That's what hasattr does.
> But with Roy's suggestion, testing for the existence of os.fork is not
> sufficient, because it will exist even on platforms where fork doesn't
> exist. So testing that os.fork exists is not sufficient to tell whether or
> not you can actually fork.
Windows:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import os
>>> os.fork
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.fork
AttributeError: 'module' object has no attribute 'fork'
Linux:
$ python
Python 2.7.8 (default, Jul 4 2014, 13:08:34)
[GCC 4.9.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.fork
<built-in function fork>
>>>
So yes, I continue to miss something...
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
AttributeError: 'module' object has no attribute 'fork' Satish ML <satishmlwizpro@gmail.com> - 2014-08-06 23:44 -0700
Re: AttributeError: 'module' object has no attribute 'fork' Peter Otten <__peter__@web.de> - 2014-08-07 09:00 +0200
Re: AttributeError: 'module' object has no attribute 'fork' Roy Smith <roy@panix.com> - 2014-08-07 07:49 -0400
Re: AttributeError: 'module' object has no attribute 'fork' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-08 02:56 +1000
Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-07 22:19 -0700
Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-07 22:35 -0700
Re: AttributeError: 'module' object has no attribute 'fork' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-08 15:48 +1000
Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-08 00:17 -0700
Re: AttributeError: 'module' object has no attribute 'fork' Chris Angelico <rosuav@gmail.com> - 2014-08-08 17:32 +1000
csiph-web