Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12453
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'instance': 0.05; 'parameter': 0.05; 'python': 0.08; 'from:addr:python': 0.09; 'parameter.': 0.09; 'tuple': 0.09; 'argument': 0.15; '0).': 0.16; 'andreas': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'hint': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply- to:addr:python-list': 0.16; 'timestamp': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; 'arguments': 0.18; 'phrase': 0.18; 'header:In- Reply-To:1': 0.22; 'input': 0.24; 'says': 0.25; 'tried': 0.26; "i'm": 0.27; 'function': 0.27; 'somebody': 0.28; 'received:84': 0.28; '(even': 0.29; 'example': 0.30; 'hi,': 0.32; 'does': 0.32; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'follows:': 0.34; 'null': 0.34; 'reply-to:addr:python.org': 0.34; 'reference': 0.35; 'object': 0.35; 'url:python': 0.36; 'passed': 0.37; 'put': 0.37; 'but': 0.37; 'url:org': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'description': 0.39; 'kind': 0.61; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'datetime': 0.84 |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AuQFALRZXU7Unw4S/2dsb2JhbABCmRmPJ3eBQAEBBThAEQsIEAkWDwkDAgECAQ04EwgBAYdwArg4gkSECQSLaUmMAIMwiEg |
| Date | Tue, 30 Aug 2011 22:49:04 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Usage of PyDateTime_FromTimestamp |
| References | <j3jhvm$8o8$1@dough.gmane.org> |
| In-Reply-To | <j3jhvm$8o8$1@dough.gmane.org> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.586.1314740949.27778.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1314740949 news.xs4all.nl 2427 [2001:888:2000:d::a6]:47022 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12453 |
Show key headers only | View raw
On 30/08/2011 21:42, Andreas wrote:
> Hi,
>
> I'm working on a c-extension of python and want to create an instance of
> python datetime object with a unix timestamp in c.
>
> On the documentation site ( http://docs.python.org/c-api/datetime.html )
> I found the function PyDateTime_FromTimestamp() which returns a new
> reference based on an input parameter.
>
> The description is as follows: Create and return a new datetime.datetime
> object given an argument tuple suitable for passing to
> datetime.datetime.fromtimestamp().
>
> I tried out to call the function with a PyFloat_Object but the function
> always returns NULL (even if I simply put in 0).
>
> Does somebody have an example how I have to call the function or can
> give a hint what kind of parameter tuple is required to get it work?
>
The key phrase is "argument tuple". The arguments passed to a Python
call are always a tuple, not PyFloat_Object.
You can build a tuple from the PyFloat_Object using:
Py_BuildValue("(O)", float_object)
The "(O)" says to build a tuple ("(...)") containing a single object
("O").
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Usage of PyDateTime_FromTimestamp MRAB <python@mrabarnett.plus.com> - 2011-08-30 22:49 +0100
csiph-web