Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-26 Thread Bartosz Golaszewski
On Sat, Jul 24, 2021 at 6:55 AM Dan Stromberg  wrote:
>
>
> On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski  wrote:
>>
>> Hi!
>>
>> I'm working on a Python C extension and I would like to expose a
>> custom enum (as in: a class inheriting from enum.Enum) that would be
>> entirely defined in C.
>
>
> I'm probably missing something obvious, but why would you write new code in C 
> when you can just use Cython?  Cython is a lot easier, and quite fast, and 
> should (eventually?) allow compiling to HPY instead of just "the" C extension 
> module interface.
>
> https://news.ycombinator.com/item?id=26627683
>

I'm the author and maintainer of libgpiod - the user-space library and
tools for using the linux GPIO character device.

The core library is written in C but we're also exposing C++ and
Python bindings (with more language bindings planned). The python
bindings are written as a C extension module and look like this:
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/bindings/python/gpiodmodule.c.

We're in the process of writing the (backward incompatible) version 2
of the library in order to support the new kernel features and the C
API has changed a lot so we're also rewriting the bindings. Among
others: all bitwise flags have now been converted to enums, hence my
question. In C++ we'll use scoped enum classes and I'd like to do a
similar thing in python.

What I'm doing is not aimed at using C for speed but for calling the C
APIs. I know I could use SWIG but in order to make the interface
elegant, it would have to be packaged in proper Python classes anyway,
creating another layer of code so I prefer to just use C.

Bart
-- 
https://mail.python.org/mailman/listinfo/python-list


a simple question

2021-07-26 Thread Glenn Wilson via Python-list
I recently downloaded the latest version of python, 3.9.6. Everything works 
except, the turtle module. I get an error message every time , I use basic 
commands like forward, backward, right and left. My syntax is correct: 
pat.forward(100) is an example. Can you tell me what is wrong.
     thanks, glenn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a simple question

2021-07-26 Thread Paul Bryan
It would help to know the error message you get every time.

On Mon, 2021-07-26 at 22:19 +, Glenn Wilson via Python-list wrote:
> I recently downloaded the latest version of python, 3.9.6. Everything
> works except, the turtle module. I get an error message every time ,
> I use basic commands like forward, backward, right and left. My
> syntax is correct: pat.forward(100) is an example. Can you tell me
> what is wrong.
>      thanks, glenn

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


Re: a simple question

2021-07-26 Thread dn via Python-list
On 27/07/2021 10.19, Glenn Wilson via Python-list wrote:
> I recently downloaded the latest version of python, 3.9.6. Everything works 
> except, the turtle module. I get an error message every time , I use basic 
> commands like forward, backward, right and left. My syntax is correct: 
> pat.forward(100) is an example. Can you tell me what is wrong.


Python comes with "batteries included". However, if 'everything' was
made immediately-available, each of your program[me]s would be very
long. Accordingly, the 'batteries' are kept in what is called "The
Python Standard Library". To use a library it must be import-ed into
your code.

Docs describing the library are available on-line, specifically the
turtle module (and some examples of its use) can be found at:
https://docs.python.org/3/library/turtle.html

Have fun!
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: a simple question

2021-07-26 Thread Avi Gross via Python-list
In addition to the other requests for more info on a very ambiguous
question, let me add one. Did the message suggest something worked on an
earlier version and broke with a new version, or did they mean they just
started USING the current version and hoped the version number was
meaningful for the way they probably did not write proper code in the first
place that loads the module(s) they need?

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Monday, July 26, 2021 9:46 PM
To: [email protected]
Subject: Re: a simple question

On Mon, 26 Jul 2021 22:19:58 + (UTC), Glenn Wilson via Python-list
 declaimed the following:

>I recently downloaded the latest version of python, 3.9.6. Everything works
except, the turtle module. I get an error message every time , I use basic
commands like forward, backward, right and left. My syntax is correct:
pat.forward(100) is an example. Can you tell me what is wrong.

No we can't. 

Please provide a cut&paste (NOT a screen-grab image) of the error
traceback, an indication of what OS/hardware you are running upon, etc.
Maybe even which installer you downloaded (python.org, or some third-party
repackager: ActiveState, Anaconda, M$ app store)



-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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

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