Re: How to delay until a next increment of time occurs ?

2019-11-19 Thread R.Wieser
Peter,

First things first: For some reason I see your message coming in empty, but 
with two attachments.   An "att*.txt" one with the actual message contents, 
and a "signature.asc".  Makes it kind of hard to read ...

> No. There are many reasons why sleep() might return after t

Not /that/ many, but true.  But do you think that adding all of those 
if-when-but reasons to the issue I tried to explain would be a good idea ? 
I don't.   I would just drown the actual issue with it. :-\

> No, because you get the actual time at some time between the the
> previous and the next sleep

No, you don't. Thats the whole trick.  The only place where you ask for the 
time (and subtract it from the desired one) is directly infront of actually 
doing the sleep.  (dotting i's works two ways I'm afraid :-) ).   And the 
/asked for/ time (before subtraction of the current time I mean - ghah!  I 
hate needing to specify every fricking detail) will be exactly the specified 
increment away from the (calculated!) last one.   And yes, that thus also 
tries to negate a previous sleep having ended late.

In short: The calculated(!) next sleeps termination time is not dependant on 
how well the previous sleeps and code between them behaved.

> the time used to compute the sleep time would be a little later.

That doesn't matter, as that "a little later" time would be the same for all 
the sleeps.  In short, the /whole/ output would be delayed a bit.Which, 
in this case, is of no consequence.

Regards,
Rudy Wieser


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


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
Michael

> Does this have to be done in the C API?

As far as I can tell, yes.  What I need to do is not exposed by the 
extension itself, meaning that a wrapper class can't get access to it 
either.

And its just a syntax problem.  I currently simply have not enough knowledge 
about the CPython API lanuages one to be able to even do a simple call ... 
:-\

Regards,
Rudy Wieser


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


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
MRAB,

> It could be something like this:
[snip example code]

Thank you very much.  Your "Call the other method" line shows me that I've 
been overthinking things. :-(

After that I decided to see if I could give the "py_proc1" function two 
arguments, which worked.  That means that the prepending of "foo" (to the 
origional one) has been changed into transferring it on its own (much easier 
for both the caller as well as the callee).

Regards,
Rudy Wieser


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


wordsearch

2019-11-19 Thread jezkator
Hi, I have got a problem in my searchword. Everything runs properly. Output 
writes word, coordinates and direction, but i need, that output have same 
arrangement as second file
First file includes board, where program search:
xmuinjekci
evelkochov
cadvouhrac
feminizaci
pyzlanpbik
ldvojlinky
osvrhloubd
dqldrvandy
yevergreen
olympskout

and second includes words:
dvojlinky
feminizaci
velkochov
dvouhra
olympskou
plody
dyn
rab
svrhlou
np
jo
lordem
velko
injekci
skout
mva
vandy
dvou
evergreen
ech
zla
kb
un
hrr
aj
ona

Python Code: 


def find_words(file_inputs, words):
with open(file_inputs) as file:
for line in file:
line = line.replace('\n', '')
line = line.lower()
words.append(line)
 
def get_search_board(file_inputs, search_board):
with open(file_inputs) as file:
for line in file:
if len(line) > 6:
line = line.lower()
search_board += line
length = search_board.index('\n') + 1
return search_board, length
 
def main():
words = []
search_board = ''
z = input().split()
file_input = z[0]
file_inputs = z[1]
find_words(file_inputs, words)
search_board, length = get_search_board(file_input, search_board)
lines = {}
 
lines["1"] = []
 
letters = [(letter, divmod(index, length))
   for index, letter in enumerate(search_board)]
 
lines['0'] = letters
 
for i in range(length):
for j in range(i, len(letters), length):
lines["1"].append(letters[j])
 
for direction, tuple in lines.items():
string = ''.join([i[0] for i in tuple])
for word in words:
if word in string:
coordinates = tuple[string.index(word)][1]
print(word,coordinates[0], coordinates[1], direction)
 
main()

Output:
plody 4 0 1
dyn 6 9 1
rab 2 7 1
jo 0 5 1
lordem 4 3 1
mva 0 1 1
ech 0 6 1
kb 5 8 1
un 6 7 1
hrr 6 4 1
aj 4 4 1
ona 2 4 1
dvojlinky 5 1 0
feminizaci 3 0 0
velkochov 1 1 0
dvouhra 2 2 0
olympskou 9 0 0
svrhlou 6 1 0
np 4 5 0
velko 1 1 0
injekci 0 3 0
skout 9 5 0
vandy 7 5 0
dvou 2 2 0
evergreen 8 1 0
zla 4 2 0

but i need output like this

Output:
dvojlinky 5 1 0
feminizaci 3 0 0
velkochov 1 1 0
dvouhra 2 2 0
olympskou 9 0 0
plody 4 0 1
dyn 6 9 1
rab 2 7 1
svrhlou 6 9 0
np 4 5 0
jo 0 5 1
lordem 4 3 1
velko 1 1 0
injekci 0 3 0
skout 9 5 0
mva 0 1 1
vandy 7 5 0
dvou 2 2 0
evergreen 8 1 0
ech 0 6 1
zla 4 2 0
kb 5 8 1
un 6 7 1
hrr 6 4 1
aj 4 4 1
ona 2 4 1

Can u help me please?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wordsearch

2019-11-19 Thread Richard Damon
On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> Hi, I have got a problem in my searchword. Everything runs properly. Output 
> writes word, coordinates and direction, but i need, that output have same 
> arrangement as second file
> First file includes board, where program search:

Look at our code, and what controls the order you data is output. Change
it so that the data is processed in the order you want the output.

-- 
Richard Damon

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


Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

2019-11-19 Thread Veek M
Basically I want to call a method and pretty print the object contents 
for some code I'm playing with.

Instead of manually writing all this crud. Something like a python object 
explorer.



def foo(a, x = 10):
2 + 2

def bar():
pass

class A:
pass

class Foo(A, object):
def __init__(self):
2 + 2

def mymethod(self):
2 + 2

f = Foo()

import inspect
f = inspect.currentframe()
print f.f_locals, '\n\n', f.f_globals

print f.f_lasti, f.f_back, f.f_code, f.f_lineno

print f.f_trace
#print f.f_builtins

print f.f_code.co_name
print f.f_code.co_filename
print f.f_code.co_argcount
print f.f_code.co_varnames
print f.f_code.co_nlocals
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Launching a Script on the Linux Platform

2019-11-19 Thread Barry


> On 18 Nov 2019, at 22:42, Wildman via Python-list  
> wrote:
> 
> On Mon, 18 Nov 2019 22:15:31 +0100, Peter J. Holzer wrote:
> 
>>> On 2019-11-18 15:01:57 -0600, Wildman via Python-list wrote:
>>> On Tue, 19 Nov 2019 05:09:07 +1100, Chris Angelico wrote:
 On Tue, Nov 19, 2019 at 5:06 AM Wildman via Python-list
  wrote:
> On Sun, 17 Nov 2019 18:27:45 +, Barry Scott wrote:
>> Because you are installing from a deb you know the exact path to the 
>> python you
>> need to use. There is no need to use the /usr/bin/env to search the path 
>> and
>> potential break your code, because a version of python that you do not 
>> expect is on
>> the path.
> 
> I don't understand.  The deb does not install python so I
> fail to see how I would know the exact path.
> 
> As to env breaking my code, never heard of such a thing.
> 
 
 The deb should depend on an appropriate Python package. Then you can
 assume and expect that this version of Python is installed.
>>> 
>>> Yes, of course, python(3) is listed as a "depends" in the deb
>>> control file.  That does insure that python is installed but
>>> in no way does that tell me the path of the python executable.
>> 
>> The debian packaging guidelines tell you where the execuable has to be.
>> If you install the python package you can be very sure that the
>> executable will be in /usr/bin. And this is the executable you want to
>> use. You don't want to use some other random program called "python"
>> (which may or may not be an interpreter for some version of the Python
>> language) which just happens to be in the user's path.
>> 
>>hp
> 
> Yes, /usr/bin is the likely place to find the python executable
> but a guideline is not a guarantee.  

It will be in /usr/bin because the python package cannot change that with
users getting very upset.

> I have always been taught
> it is never a good idea to use a hard path unless it is something
> installed with your program or something created by your program.
> That approach has not failed me.

That is not true for packagers, the reverse is true use exact paths.

The use of env to find a program on the path is reasonable if you cannot know
where python might be installed. Often the case when publishing scripts.

Barry

> 
> -- 
>  GNU/Linux user #557453
> The cow died so I don't need your bull!
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Is there a piece of code ('inspect') that displays all/most of the attributes/methods in a frame, traceback, generator object in a readable fashion

2019-11-19 Thread Antoon Pardon
Maybe you should have a look at:
http://code.activestate.com/recipes/52215-get-more-information-from-tracebacks/

On 19/11/19 15:08, Veek M wrote:
> Basically I want to call a method and pretty print the object contents 
> for some code I'm playing with.
>
> Instead of manually writing all this crud. Something like a python object 
> explorer.
>
>
>
> def foo(a, x = 10):
> 2 + 2
>
> def bar():
> pass
>
> class A:
> pass
>
> class Foo(A, object):
> def __init__(self):
> 2 + 2
>
> def mymethod(self):
> 2 + 2
>
> f = Foo()
>
> import inspect
> f = inspect.currentframe()
> print f.f_locals, '\n\n', f.f_globals
>
> print f.f_lasti, f.f_back, f.f_code, f.f_lineno
>
> print f.f_trace
> #print f.f_builtins
>
> print f.f_code.co_name
> print f.f_code.co_filename
> print f.f_code.co_argcount
> print f.f_code.co_varnames
> print f.f_code.co_nlocals

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


Re: wordsearch

2019-11-19 Thread jezkator
Dne úterý 19. listopadu 2019 13:33:53 UTC+1 Richard Damon napsal(a):
> On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> > Hi, I have got a problem in my searchword. Everything runs properly. Output 
> > writes word, coordinates and direction, but i need, that output have same 
> > arrangement as second file
> > First file includes board, where program search:
> 
> Look at our code, and what controls the order you data is output. Change
> it so that the data is processed in the order you want the output.
> 
> -- 
> Richard Damon

I know, that the best way, how i can learn that is by myself, but can u do that 
with my code and post here, please?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wordsearch

2019-11-19 Thread Chris Angelico
On Wed, Nov 20, 2019 at 2:46 AM  wrote:
>
> Dne úterý 19. listopadu 2019 13:33:53 UTC+1 Richard Damon napsal(a):
> > On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> > > Hi, I have got a problem in my searchword. Everything runs properly. 
> > > Output writes word, coordinates and direction, but i need, that output 
> > > have same arrangement as second file
> > > First file includes board, where program search:
> >
> > Look at our code, and what controls the order you data is output. Change
> > it so that the data is processed in the order you want the output.
> >
> > --
> > Richard Damon
>
> I know, that the best way, how i can learn that is by myself, but can u do 
> that with my code and post here, please?

Nope.

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


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread Michael Torrie
On 11/19/19 1:09 AM, R.Wieser wrote:
> Michael
> 
>> Does this have to be done in the C API?
> 
> As far as I can tell, yes.  What I need to do is not exposed by the 
> extension itself, meaning that a wrapper class can't get access to it 
> either.

Sure but the Python methods themselves are exposed and accessible and
according to your previous posts, all you want to do is add an argument
to a call to the existing method.  If that's true, then you should be
able to do that part from pure Python.  The beauty of the C API is that
anything you define there should be visible and accessible from pure
Python world.

I can understand that the pure C stuff is not accessible of course. But
the snippets you've shown so far don't show any of that.

> And its just a syntax problem.  I currently simply have not enough knowledge 
> about the CPython API lanuages one to be able to even do a simple call ... 
> :-\

Are you able to post the C code, or at least enough of it that can
actually compile? It'd be much easier to help if we had something to
work with.  We're working in the dark here so it's difficult to know
exactly where to direct you.  It's always best on the list to work with
complete, standalone, minimal examples.

Looking at existing examples, as well as the C API documentation, are
how I figured out how to use it some years back when I needed to do a
small thing in C, although I've forgotten most of it now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to delay until a next increment of time occurs ?

2019-11-19 Thread Michael Torrie
On 11/19/19 12:57 AM, R.Wieser wrote:
> First things first: For some reason I see your message coming in empty, but 
> with two attachments.   An "att*.txt" one with the actual message contents, 
> and a "signature.asc".  Makes it kind of hard to read ...

His message is a (standard) PGP-signed message. Perhaps your email
client or news reader doesn't deal with PGP signatures?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread Michael Torrie
On 11/19/19 9:00 AM, Michael Torrie wrote:
> Sure but the Python methods themselves are exposed and accessible and
> according to your previous posts, 

I meant to say the class methods defined by the C code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wordsearch

2019-11-19 Thread Richard Damon
On Nov 19, 2019, at 10:56 AM, Chris Angelico  wrote:
> 
> On Wed, Nov 20, 2019 at 2:46 AM  wrote:
>> 
>> Dne úterý 19. listopadu 2019 13:33:53 UTC+1 Richard Damon napsal(a):
 On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> Hi, I have got a problem in my searchword. Everything runs properly. 
> Output writes word, coordinates and direction, but i need, that output 
> have same arrangement as second file
> First file includes board, where program search:
>>> 
>>> Look at our code, and what controls the order you data is output. Change
>>> it so that the data is processed in the order you want the output.
>>> 
>>> --
>>> Richard Damon
>> 
>> I know, that the best way, how i can learn that is by myself, but can u do 
>> that with my code and post here, please?
> 
> Nope.
> 
> ChrisA
> 

Think what order you want your output.
Make your main loop go through the data in that order
For each of the data, find the answer for that data
Print the results.

You should be able to figure this out.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wordsearch

2019-11-19 Thread jezkator
Dne úterý 19. listopadu 2019 17:07:36 UTC+1 Richard Damon napsal(a):
> On Nov 19, 2019, at 10:56 AM, Chris Angelico  wrote:
> > 
> > On Wed, Nov 20, 2019 at 2:46 AM  wrote:
> >> 
> >> Dne úterý 19. listopadu 2019 13:33:53 UTC+1 Richard Damon napsal(a):
>  On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> > Hi, I have got a problem in my searchword. Everything runs properly. 
> > Output writes word, coordinates and direction, but i need, that output 
> > have same arrangement as second file
> > First file includes board, where program search:
> >>> 
> >>> Look at our code, and what controls the order you data is output. Change
> >>> it so that the data is processed in the order you want the output.
> >>> 
> >>> --
> >>> Richard Damon
> >> 
> >> I know, that the best way, how i can learn that is by myself, but can u do 
> >> that with my code and post here, please?
> > 
> > Nope.
> > 
> > ChrisA
> > 
> 
> Think what order you want your output.
> Make your main loop go through the data in that order
> For each of the data, find the answer for that data
> Print the results.
> 
> You should be able to figure this out.


Ok, so first (outer) loop will be for word in words, than for direction, tuple
... But now is problem that it prints 10 times but just the last one is 
complete and ok
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Speeding up a test process with a local pypi and/or web proxy?

2019-11-19 Thread Dan Stromberg
On Fri, Nov 15, 2019 at 1:11 PM Dan Stromberg  wrote:

> Hi folks.
>
> I'm looking at a test process that takes about 16 minutes for a full run.
>
Anyone?


> Naturally, I'd like to speed it up.  We've already parallelized it -
> mostly.
>
> It seems like the next thing to look at is setting up a local pypi, and
> building some of the packages that're compiled from C/C++ every time we do
> a full test run.  (We're using docker and building dependencies for each
> full test run)
>
> Also, we could conceivably set up a web proxy...?
>
> Does having a local pypi obviate the web proxy?
>
> And what local pypi servers do folks recommend for speed?
>
> We need support mostly for CPython 3.x, but we still have a little CPython
> 2.x we require, and it's possible we'll need the 2.x for a while.
>
> Thanks!
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wordsearch

2019-11-19 Thread jezkator
Dne úterý 19. listopadu 2019 17:14:06 UTC+1 jezk...@gmail.com napsal(a):
> Dne úterý 19. listopadu 2019 17:07:36 UTC+1 Richard Damon napsal(a):
> > On Nov 19, 2019, at 10:56 AM, Chris Angelico  wrote:
> > > 
> > > On Wed, Nov 20, 2019 at 2:46 AM  wrote:
> > >> 
> > >> Dne úterý 19. listopadu 2019 13:33:53 UTC+1 Richard Damon napsal(a):
> >  On 11/19/19 6:47 AM, jezka...@gmail.com wrote:
> > > Hi, I have got a problem in my searchword. Everything runs properly. 
> > > Output writes word, coordinates and direction, but i need, that 
> > > output have same arrangement as second file
> > > First file includes board, where program search:
> > >>> 
> > >>> Look at our code, and what controls the order you data is output. Change
> > >>> it so that the data is processed in the order you want the output.
> > >>> 
> > >>> --
> > >>> Richard Damon
> > >> 
> > >> I know, that the best way, how i can learn that is by myself, but can u 
> > >> do that with my code and post here, please?
> > > 
> > > Nope.
> > > 
> > > ChrisA
> > > 
> > 
> > Think what order you want your output.
> > Make your main loop go through the data in that order
> > For each of the data, find the answer for that data
> > Print the results.
> > 
> > You should be able to figure this out.
> 
> 
> Ok, so first (outer) loop will be for word in words, than for direction, tuple
> ... But now is problem that it prints 10 times but just the last one is 
> complete and ok

OK, I got it, thnx for help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread R.Wieser
Michael,

> Sure but the Python methods* themselves are exposed and accessible
> and according to your previous posts, all you want to do is add an
> argument to a call to the existing method.  If that's true, then you
> should be able to do that part from pure Python.

>* class methods defined by the C code

Feel free to post code showing that it can be done.   The extension is
RPi.GPIO, the method is "output", and the extra argument is the pinnaming
scheme (BCM or BOARD).   Success! :-p

> I can understand that the pure C stuff is not accessible of course.
> But the snippets you've shown so far don't show any of that.

Where did you think that "static PyObject *py_proc1(PyObject *self, PyObject
*args)" came from, or why I said "I've also tried to go the C way" ?
Besides that, the subject line should have been a dead giveaway by
itself ...

> We're working in the dark here

Are you sure ?   MRAB didn't seem to have too much problems with both
recognising and understanding what I was busy with - he posted a spot-on
example, containing not more, but also not anything less than what I was
asking for.

> Looking at existing examples, as well as the C API documentation

I did not find any example that showed me what I needed to know - simply one
CPython function calling another one.And yes, I've found multiple
documentation pages, including the "Extending and Embedding the Python
Interpreter" ones.  Alas, no dice.

Most of that documentation is only good when you already know what you are
looking for, and need to make sure of its exact usage.  Not so much the
other way around, when you have no clue and are searching for what you need
to use to solve a particular problem (even one as stupid as just calling
another method)


By the way, the whole solution consists outof the following:

static PyObject *py_proc1(PyObject *self, int ExtraArg, PyObject *args)
{

  Py_RETURN_NONE
}

static PyObject *py_proc2(PyObject *self, PyObject *args)
{
   return py_proc1(self, 42, args)
}

Regards,
Rudy Wieser




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


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread Luciano Ramalho
Now that’s a novel approach to asking for free help: pretending to be
smarter than the people who are trying to help you.

On Tue, 19 Nov 2019 at 14:17 R.Wieser  wrote:

> Michael,
>
> > Sure but the Python methods* themselves are exposed and accessible
> > and according to your previous posts, all you want to do is add an
> > argument to a call to the existing method.  If that's true, then you
> > should be able to do that part from pure Python.
>
> >* class methods defined by the C code
>
> Feel free to post code showing that it can be done.   The extension is
> RPi.GPIO, the method is "output", and the extra argument is the pinnaming
> scheme (BCM or BOARD).   Success! :-p
>
> > I can understand that the pure C stuff is not accessible of course.
> > But the snippets you've shown so far don't show any of that.
>
> Where did you think that "static PyObject *py_proc1(PyObject *self,
> PyObject
> *args)" came from, or why I said "I've also tried to go the C way" ?
> Besides that, the subject line should have been a dead giveaway by
> itself ...
>
> > We're working in the dark here
>
> Are you sure ?   MRAB didn't seem to have too much problems with both
> recognising and understanding what I was busy with - he posted a spot-on
> example, containing not more, but also not anything less than what I was
> asking for.
>
> > Looking at existing examples, as well as the C API documentation
>
> I did not find any example that showed me what I needed to know - simply
> one
> CPython function calling another one.And yes, I've found multiple
> documentation pages, including the "Extending and Embedding the Python
> Interpreter" ones.  Alas, no dice.
>
> Most of that documentation is only good when you already know what you are
> looking for, and need to make sure of its exact usage.  Not so much the
> other way around, when you have no clue and are searching for what you need
> to use to solve a particular problem (even one as stupid as just calling
> another method)
>
>
> By the way, the whole solution consists outof the following:
>
> static PyObject *py_proc1(PyObject *self, int ExtraArg, PyObject *args)
> {
> 
>   Py_RETURN_NONE
> }
>
> static PyObject *py_proc2(PyObject *self, PyObject *args)
> {
>return py_proc1(self, 42, args)
> }
>
> Regards,
> Rudy Wieser
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Luciano Ramalho
|  Author of Fluent Python (O'Reilly, 2015)
| http://shop.oreilly.com/product/0636920032519.do
|  Technical Principal at ThoughtWorks
|  Twitter: @ramalhoorg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread Luciano Ramalho
I apologize to all but the intended recipient for this. I’d have given him
feedback in private if I knew his email.

I will take leave from the list now. Keep up the good work, friendly
responders.

On Tue, 19 Nov 2019 at 17:13 Luciano Ramalho  wrote:

> Now that’s a novel approach to asking for free help: pretending to be
> smarter than the people who are trying to help you.
>
> On Tue, 19 Nov 2019 at 14:17 R.Wieser  wrote:
>
>> Michael,
>>
>> > Sure but the Python methods* themselves are exposed and accessible
>> > and according to your previous posts, all you want to do is add an
>> > argument to a call to the existing method.  If that's true, then you
>> > should be able to do that part from pure Python.
>>
>> >* class methods defined by the C code
>>
>> Feel free to post code showing that it can be done.   The extension is
>> RPi.GPIO, the method is "output", and the extra argument is the pinnaming
>> scheme (BCM or BOARD).   Success! :-p
>>
>> > I can understand that the pure C stuff is not accessible of course.
>> > But the snippets you've shown so far don't show any of that.
>>
>> Where did you think that "static PyObject *py_proc1(PyObject *self,
>> PyObject
>> *args)" came from, or why I said "I've also tried to go the C way" ?
>> Besides that, the subject line should have been a dead giveaway by
>> itself ...
>>
>> > We're working in the dark here
>>
>> Are you sure ?   MRAB didn't seem to have too much problems with both
>> recognising and understanding what I was busy with - he posted a spot-on
>> example, containing not more, but also not anything less than what I was
>> asking for.
>>
>> > Looking at existing examples, as well as the C API documentation
>>
>> I did not find any example that showed me what I needed to know - simply
>> one
>> CPython function calling another one.And yes, I've found multiple
>> documentation pages, including the "Extending and Embedding the Python
>> Interpreter" ones.  Alas, no dice.
>>
>> Most of that documentation is only good when you already know what you are
>> looking for, and need to make sure of its exact usage.  Not so much the
>> other way around, when you have no clue and are searching for what you
>> need
>> to use to solve a particular problem (even one as stupid as just calling
>> another method)
>>
>>
>> By the way, the whole solution consists outof the following:
>>
>> static PyObject *py_proc1(PyObject *self, int ExtraArg, PyObject *args)
>> {
>> 
>>   Py_RETURN_NONE
>> }
>>
>> static PyObject *py_proc2(PyObject *self, PyObject *args)
>> {
>>return py_proc1(self, 42, args)
>> }
>>
>> Regards,
>> Rudy Wieser
>>
>>
>>
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> --
> Luciano Ramalho
> |  Author of Fluent Python (O'Reilly, 2015)
> | http://shop.oreilly.com/product/0636920032519.do
> |  Technical Principal at ThoughtWorks
> |  Twitter: @ramalhoorg
>
-- 
Luciano Ramalho
|  Author of Fluent Python (O'Reilly, 2015)
| http://shop.oreilly.com/product/0636920032519.do
|  Technical Principal at ThoughtWorks
|  Twitter: @ramalhoorg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread Michael Torrie
On 11/19/19 10:12 AM, R.Wieser wrote:
> Feel free to post code showing that it can be done.   The extension is
> RPi.GPIO, the method is "output", and the extra argument is the pinnaming
> scheme (BCM or BOARD).   Success! :-p

If you mentioned RPi.GPIO before, I apologize for my mistake.  That's
very helpful to know.

As for posting code to show it can be done, If I knew what the pin
naming scheme was (how do you use it from python?), and if I knew how
you modified py_output_gpio to do something with that, I sure would give
it a shot.

>> We're working in the dark here
> 
> Are you sure ?   
> MRAB didn't seem to have too much problems with both
> recognising and understanding what I was busy with - he posted a spot-on
> example, containing not more, but also not anything less than what I was
> asking for.

MRAB understood and answered the specific question, yes.

But I thought, and remain convinced, that there were probably other ways
of solving it that didn't involve mucking with C code. Because forking
the RPi.GPIO code means that every time there's a change or update to it
you know have to redo everything each time.

You mentioned you're working with RPi.GPIO, so why not just use the real
function names in your questions?  After grepping I've determined that
you are really wanting to work with the C function py_output_gpio().
Why not just say that?  Doesn't take very much extra time but will get
more people willing to respond who might know.

> I did not find any example that showed me what I needed to know - simply one
> CPython function calling another one.And yes, I've found multiple
> documentation pages, including the "Extending and Embedding the Python
> Interpreter" ones.  Alas, no dice.
Fair enough.

> By the way, the whole solution consists outof the following:
> 
> static PyObject *py_proc1(PyObject *self, int ExtraArg, PyObject *args)
> {
> 
>   Py_RETURN_NONE
> }
> 
> static PyObject *py_proc2(PyObject *self, PyObject *args)
> {
>return py_proc1(self, 42, args)
> }

Glad it worked out for you.  That "int ExtraArg" bit looks a bit
strange; I thought everything that was exposed to the Python side of
things had to be wrapped in PyObject.  Guess I'm wrong?

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


Re: Writing a CPython extension - calling another sibbling method ?

2019-11-19 Thread DL Neil via Python-list

On 20/11/19 9:20 AM, Luciano Ramalho wrote:

I apologize to all but the intended recipient for this. I’d have given him
feedback in private if I knew his email.

I will take leave from the list now. Keep up the good work, friendly
responders.



Please reconsider. Should your relationship with the 'good folks' be 
governed by someone/anyone else?



There is no need to tell you that are many innocent reasons why we 
misunderstand each other's motives or intent, particularly in a 
multi-cultural context; just as there are folk who attempt to 'take 
advantage'. Grossly generalised examples
- each academic year a new crop of PyStudents seems to crop-up, thinking 
we'll *do* their 'homework' for them...

- some parts of British humor is impenetrable to those born south of Dover
- Dutch/German positivity can be interpreted as brusque or even 
arrogant, in some parts of the world
- Kiwi/Aussie humor as often involves insult (which is not meant to be 
taken seriously) as it does self-deprecation

- Self-deprecation is not 'the American way'...
- Monty Python humor is its own (lack of) explanation!

That said, I am asking (elsewhere, but please feel free...'here') if the 
standards and conventions of the Python Foundation apply to this/these 
list(s)? Such requires a balance between an individual's right to 
privacy, and the open-ness with which we conduct Python-business, ie 
without insult, derision, victimisation, etc, etc...

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Friday finking: TDD and EAFP

2019-11-19 Thread Peter J. Holzer
On 2019-11-18 19:00:41 -0500, Mark Turner wrote:
[trivial test]

> I think this simple test like has value. It’s just not where you
> expect it to be. In order to get this test to pass you have to have
> your development environment set up, your testing environment set up
> and perhaps some basic dependencies resolved.

That's a good point. 

Especially if your environment is a bit complex (as it invariably is
when you want to test web applications, for example), it is a very good
idea to start really simple just to make sure you have your environment
set up correctly.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[RELEASE] Python 3.9.0a1 available for testing

2019-11-19 Thread Łukasz Langa
Go get it here: https://www.python.org/downloads/release/python-390a1/ 

This is an early developer preview of Python 3.9

Python 3.9 is still in development. This releasee, 3.9.0a1 is the first of six 
planned alpha releases. Alpha releases are intended to make it easier to test 
the current state of new features and bug fixes and to test the release 
process. During the alpha phase, features may be added up until the start of 
the beta phase (2020-05-18) and, if necessary, may be modified or deleted up 
until the release candidate phase (2020-08-10). Please keep in mind that this 
is a preview release and its use is not recommended for production environments.

Major new features of the 3.9 series, compared to 3.8

Many new features for Python 3.9 are still being planned and written. Among the 
new major new features and changes so far:

PEP 602 , Python adopts a stable 
annual release cadence
BPO 38379 , garbage collection does not 
block on resurrected objects;
BPO 38692 , os.pidfd_open added that allows 
process management without races and signals;
A number of standard library modules (audioop, ast, grp, _hashlib, pwd, 
_posixsubprocess, random, select, struct, termios, zlib) are now using the 
stable ABI defined by PEP 384 .
(Hey, fellow core developer, if a feature you find important is missing from 
this list, let Łukasz know .)
The next pre-release of Python 3.9 will be 3.9.0a2, currently scheduled for 
2019-12-16.

- Ł


signature.asc
Description: Message signed with OpenPGP
-- 
https://mail.python.org/mailman/listinfo/python-list


Pickle failed __getstate__ on my customized class inherited dict

2019-11-19 Thread lampahome
I make a class Wrapper inherited from dict and met problem when I want to
pickle it.

Is there anyway to make __getstate__ of Wrapper to output a normal
dict?(Output a dict will help pickleing easily)


=== code ===
import pickle
class Wrapper(dict):
def __getattr__(self, attr):
return self[attr]
def __getstate__(self):
# blablabla

d=Wrapper(zip((1,2), (3,4)))
pickle.dumps(d)
=== code ===

When I tried overwrite __getstate__ to below:
def __getstate__(self):
return self.__repr__()
pickle it will shows:
b'\x80...__main__...Wrapper...' <- I don't know why it shows the class name.
That makes me confused.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pickle failed __getstate__ on my customized class inherited dict

2019-11-19 Thread dieter
lampahome  writes:
> I make a class Wrapper inherited from dict and met problem when I want to
> pickle it.
>
> Is there anyway to make __getstate__ of Wrapper to output a normal
> dict?(Output a dict will help pickleing easily)
>
>
> === code ===
> import pickle
> class Wrapper(dict):
> def __getattr__(self, attr):
> return self[attr]
> def __getstate__(self):
> # blablabla
>
> d=Wrapper(zip((1,2), (3,4)))
> pickle.dumps(d)
> === code ===

You have forgotten to tell us which problem the code above revealed.

> When I tried overwrite __getstate__ to below:
> def __getstate__(self):
> return self.__repr__()
> pickle it will shows:
> b'\x80...__main__...Wrapper...' <- I don't know why it shows the class name.
> That makes me confused.

It should not: pickling a class instance entails pickling a class
reference and the instance's state. The class name is part
of the class reference.

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