Re: Pythonic style

2020-09-21 Thread Léo El Amri via Python-list
On 21/09/2020 15:15, Tim Chase wrote: > You can use tuple unpacking assignment and Python will take care of > the rest for you: > > so you can do > > def fn(iterable): > x, = iterable > return x > > I'm not sure it qualifies as Pythonic, but it uses Pythonic features > like tuple unpac

Re: Pythonic style

2020-09-21 Thread Léo El Amri via Python-list
On 21/09/2020 00:34, Stavros Macrakis wrote: > I'm trying to improve my Python style. > > Consider a simple function which returns the first element of an iterable > if it has exactly one element, and throws an exception otherwise. It should > work even if the iterable doesn't terminate. I've writ

Re: Asyncio Queue implementation suggestion

2020-09-17 Thread Léo El Amri via Python-list
On 17/09/2020 16:51, Dennis Lee Bieber wrote: > On Wed, 16 Sep 2020 13:39:51 -0400, Alberto Sentieri <2...@tripolho.com> > declaimed the following: > >> devices tested simultaneously, I soon run out of file descriptor. Well, >> I increased the number of file descriptor in the application and then

Re: Asyncio Queue implementation suggestion

2020-09-17 Thread Léo El Amri via Python-list
Hello Alberto, I scrambled your original message a bit here. > Apparently asyncio Queues use a Linux pipe and each queue require 2 file > descriptors. Am I correct? As far as I know (And I know a bit about asyncio in CPython 3.5+) asyncio.queues.Queue doesn't use any file descriptor. It is imple

Re: There is LTS?

2020-08-24 Thread Léo El Amri via Python-list
On 24/08/2020 04:54, 황병희 wrote: > Hi, just i am curious. There is LTS for *Python*? If so, i am very thank > you for Python Project. Hi Byung-Hee, Does the "LTS" acronym you are using here stands for "Long Term Support" ? If so, then the short answer is: Yes, kind of. There is a 5 years maintena

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Léo El Amri via Python-list
On 05/11/2018 16:38, i...@koeln.ccc.de wrote: > I just saw, actually > using the same loop gets rid of the behavior in this case and now I'm > not sure about my assertions any more. It's fixing the issue because you're running loop with the run_forever(). As Ian and myself pointed out, using both

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Léo El Amri via Python-list
On 05/11/2018 07:55, Ian Kelly wrote: >> I assume it's kind of a run_forever() with some code before it >> to schedule the coroutine. > > My understanding of asyncio.run() from > https://github.com/python/asyncio/pull/465 is that asyncio.run() is > more or less the equivalent of loop.run_until_com

Re: Asyncio tasks getting cancelled

2018-11-04 Thread Léo El Amri via Python-list
On 04/11/2018 20:25, i...@koeln.ccc.de wrote: > I'm having trouble with asyncio. Apparently tasks (asyncio.create_task) > are not kept referenced by asyncio itself, causing the task to be > cancelled when the creating function finishes (and noone is awaiting the > corresponding futue). Am I doing s

Re: Package creation documentation?

2018-10-16 Thread Léo El Amri via Python-list
Hello Spencer, On 16/10/2018 17:15, Spencer Graves wrote: > Where can I find a reasonable tutorial on how to create a Python > package? IMO, the best documentation about this is the tutorial: https://docs.python.org/3/tutorial/modules.html#packages > According to the Python 3 Glossar

Re: Package creation documentation?

2018-10-16 Thread Léo El Amri via Python-list
Given your coding experience also you may want to look at https://docs.python.org/3/reference/import.html#packages, which is the technical detail of what a package is (And "how" it's implemented). -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio await different coroutines on the same socket?

2018-10-03 Thread Léo El Amri via Python-list
Hello Russell, On 03/10/2018 15:44, Russell Owen wrote: > Using asyncio I am looking for a simple way to await multiple events where > notification comes over the same socket (or other serial stream) in arbitrary > order. For example, suppose I am communicating with a remote device that can > r

Re: [OT] master/slave debate in Python

2018-09-26 Thread Léo El Amri via Python-list
On 26/09/2018 06:34, Ian Kelly wrote: > Chris Angelico wrote: >> What I know about them is that they (and I am assuming there are >> multiple people, because there are reports of multiple reports, if >> that makes sense) are agitating for changes to documentation without >> any real backing. > >

Re: [OT] master/slave debate in Python

2018-09-24 Thread Léo El Amri via Python-list
On 24/09/2018 18:30, Dan Purgert wrote: > Robin Becker wrote: >> [...] just thought control of the wrong sort.. > > Is there "thought control of the right sort"? We may have to ask to Huxley -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] master/slave debate in Python

2018-09-24 Thread Léo El Amri via Python-list
On 24/09/2018 14:52, Robin Becker wrote: > On 23/09/2018 15:45, Albert-Jan Roskam wrote: >> *sigh*. I'm with Hettinger on this. >> >> https://www.theregister.co.uk/2018/09/11/python_purges_master_and_slave_in_political_pogrom/ >> >> > I am as well. Don't fix what is not broken. The semantics (in >

>< swap operator

2018-08-13 Thread Léo El Amri via Python-list
On 13/08/2018 21:54, skybuck2...@hotmail.com wrote: > I just had a funny idea how to implement a swap operator for types: > > A >< B > > would mean swap A and B. I think that: a, b = b, a is pretty enough -- https://mail.python.org/mailman/listinfo/python-list

Python 3.6 Logging time is not listed

2018-08-13 Thread Léo El Amri via Python-list
On 13/08/2018 19:23, MRAB wrote: > Here you're configuring the logger, setting the name of the logfile and > the logging level, but not specifying the format, so it uses the default > format: > >> logging.basicConfig(filename='example.log',level=logging.DEBUG) > > Here you're configuring the logg

Re: asyncio: Warning message when waiting for an Event set by AbstractLoop.add_reader

2018-08-12 Thread Léo El Amri via Python-list
I found out what was the problem. The behavior of my "reader" (The callback passed to AbstractEventLoop.add_reader()) is to set an event. This event is awaited for in a coroutine which actually reads what is written on a pipe. The execution flow is the following: * NEW LOOP TURN * The selector aw

Re: Embedded Python and multiprocessing on Windows?

2018-08-09 Thread Léo El Amri via Python-list
On 09/08/2018 19:33, Apple wrote:> So my program runs one script file, and multiprocessing commands from that script file seem to fail to spawn new processes. > > However, if that script file calls a function in a separate script file that > it has imported, and that function calls multiprocessin

Re: asyncio: Warning message when waiting for an Event set by AbstractLoop.add_reader

2018-08-03 Thread Léo El Amri via Python-list
understand how all the thing is behaving in the shadows. Maybe I'm simply doing something wrong. But it would mean that the documentation is lacking some details, or maybe that I'm just really stupid on this one. On 03/08/2018 07:05, dieter wrote: > Léo El Amri

asyncio: Warning message when waiting for an Event set by AbstractLoop.add_reader

2018-08-02 Thread Léo El Amri via Python-list
Hello list, During my attempt to bring asyncio support to the multiprocessing Queue, I found warning messages when executing my code with asyncio debug logging enabled. It seems that awaiting for an Event will make theses messages appears after the second attempt to wait for the Event. Here is a

Why is multiprocessing.Queue creating a thread ?

2018-07-29 Thread Léo El Amri via Python-list
Hello list, This is a simple question: I wonder what is the reason behind multiprocessing.Queue creating a thread to send objects through a multiprocessing.connection.Connection. I plan to implement an asyncio "aware" Connection class. And while reading the source code of the multiprocessing modul

Re: Treatment of NANs in the statistics module

2018-03-17 Thread Léo El Amri
option. Going with (1) would force Python developers to write implementation specific code (Oh rather "implementation-defined-prone" code). In this case (5) goes easy with Python-side code. Options from (2) to (4) force Python developers to adopt a behavior. It's not necessarily a bad thing, but since (5) allows flexibility at no cost I don't see why we shouldn't go with it. -- Léo El Amri -- https://mail.python.org/mailman/listinfo/python-list

Re: Fourth example from PEP 342

2018-01-20 Thread Léo El Amri
On 20/01/2018 11:55, Thomas Jollans wrote: > control is returned to t.resume. nonblocking_accept is supposed to be a > coroutine > Ergo, it schedules the nonblocking_accept coroutine (‘value’) to be > called on the next iteration, and keeps the running listen_on coroutine > (‘coroutine’) on the sta

Fourth example from PEP 342

2018-01-19 Thread Léo El Amri
Hello list, I am currently trying to learn co-routine/asynchronous mechanisms in Python. I read the PEP 342, but I stumble on the fourth example. I don't understand what the lines "data = yield nonblocking_read(sock)" in echo_handler() and "connected_socket = yield nonblocking_accept(sock)" in lis

Re: python-daemon for Python v3

2014-08-22 Thread Y@i$el
A mi si me ha dado problemas. No tengo forma de decirle que se ejecute como usuario www-data y cuando lo intento deja de funcionar abruptamente. Saludos. -- https://mail.python.org/mailman/listinfo/python-list

[Ann] New super python vm

2009-04-01 Thread El Loco
Hi all, This is to announce that right after a few weeks after our first coding sprint, our project, "Unswallowed-snot", has already achieved substantial results. In our tests, runtime performance shows a 150x slowdown. This is due mainly to our lead developer (myself) still not knowing enough pyt

Re: So what exactly is a complex number?

2007-09-07 Thread El Pitonero
On Sep 5, 7:27 am, El Pitonero <[EMAIL PROTECTED]> wrote: > > I am a bit surprised that today, September 2007, in a thread about > complex numbers, no one has mentioned about geometric algebra. Here is a good reference for whoever is interested. It's quite accessible to gen

Re: So what exactly is a complex number?

2007-09-05 Thread El Pitonero
On Sep 1, 3:54 am, Grzegorz S odkowicz <[EMAIL PROTECTED]> wrote: > > You're mixing definition with application. You didn't say a word about > what complex numbers are, not a word about the imaginary unit, where > does it come from, why is it 'imaginary' etc. > ... > I'd also like to see a three-

Re: Subprocess with a Python Session?

2006-12-07 Thread El Pitonero
Paul Boddie wrote: > Shane Hathaway wrote: > > > > Make sure the pipes are unbuffered. Launch the process with "python -u" > > and flush() the streams after writing. (That's the issue I've > > encountered when doing this before.) > > The -u option is critical, yes. I wrote some code recently whic

Re: time.clock()

2006-07-14 Thread El Duderino
Tobiah wrote: > Am I barking up the wrong tree? I don't think so, time.clock() has always worked fine for me. You can also try time.time(). It is not as precise, but it might be sufficient for your needs. -- http://mail.python.org/mailman/listinfo/python-list

RE: Event objects Threading on Serial Port on Win32

2006-07-03 Thread el cintura partida
Muchas gracias Gabriel por haberme informado, vos si que es un profesional de la programación. Un saludo, David --- Gabriel <[EMAIL PROTECTED]> escribió: > David: > Tube el mismo problema que vos con el hilo del > ejemplo de pyserial. Me > paso que en Linux andaba bien, ob

Re: New Python Logo Revealed

2006-04-03 Thread El Loco
Alec Jang wrote: > I guess it is absolutely a joke. If not, there will be a disaster, and > that means ruby will rule the world. Yes, we'll become slaves, our leaders crucified, and our culture will vanish forever... -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs. Lisp -- please explain

2006-02-20 Thread El Loco
ll! (Hint: he's a c++ hacker who wanted to build a tracking system for terrorists in middle east, but the project got halted when Guido Van Rossum, who's real name is Abdul Al Wazari, convinced him to use python). Now the system is so so slow that Ben Laden never gets caught! El Loco -- http

Re: Spanish Translation of any python Book?

2006-01-13 Thread Olaf \&quot;El Blanco\"
:) So Sorry! "gene tani" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] > > Olaf "El Blanco" wrote: >> Maybe there is someone that speak spanish. I need the best spanish book >> for >> learning python. >> > > you

Spanish Translation of any python Book?

2006-01-13 Thread Olaf \&quot;El Blanco\"
Maybe there is someone that speak spanish. I need the best spanish book for learning python. Thanks! -- * "...Winds and storms, embrace us now, Lay waste the light of day. Open gates to darker lands... We spread our wings and fly away..." **

python and MySQL - 3 questions

2005-10-09 Thread el chupacabra
I'm using mysqldb module and python 2.4. I'm a newbie. Thanks in advance. 1. Output desired: "hello" "world" I know that MySQL takes \n and \t and what not. But my python script, it takes that \n as literal. Meaning, when I retrieve the records, they show up like "hello \n world". How can

Re: updating local()

2005-10-06 Thread El Pitonero
Flavio wrote: > I wish all my problems involved just a couple of variables, but > unfortunately the real interesting problems tend to be complex... > > def fun(**kw): > a = 100 > for k,v in kw.items(): > exec('%s = %s'%(k,v)) > print locals() > > > >>> fun(**{'a':1,'b':2}) > {'a

Re: Will python never intend to support private, protected and public?

2005-10-04 Thread El Pitonero
Paul Rubin wrote: > > Let's see, say I'm a bank manager, and I want to close my cash vault > at 5pm today and set its time lock so it can't be opened until 9am > tomorrow, including by me. Is that "handcuffs"? It's normal > procedure at any bank, for good reason. It's not necessarily some > distr

Re: Will python never intend to support private, protected and public?

2005-10-02 Thread El Pitonero
Bengt Richter wrote: > > I decided to read this thread today, and I still don't know exactly > what your requirements are for "private" whatevers. No name collision in subclassing. Notice that even if you use self._x = 3 in a parent class, it can be overriden in a sub-sub-class accidentally. >

Re: Re: error processing variables

2005-09-09 Thread el chupacabra
>Your problem is that the def statement reassignes the name "toHPU" to a >function instead of a string. So when the code runs, you're passing a >function object to s.copy2. So...how do fix it? >> import shutil >> >> #variables >> s = shutil >> >> toHPU = "/etc/sysconfig/network/toHPU.wifi" >

Is there any module to play mp3 or wav format files?

2005-08-26 Thread el chupacabra
Is there any module to play mp3 or wav format files? any sample code available somewhere? thanks, el chupacabra --= Posted using GrabIt = --= Binary Usenet downloading made easy =- -= Get GrabIt for free from http://www.shemes.com/ =- -- http

Re: breaking a loop

2005-08-13 Thread Mosti El
I think u need break before exit() so if u want break from any loop just add break "el chupacabra" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, I'm just learning Pythonthanks in advance... > > Do you get out of this loop? > > Problem

breaking a loop

2005-08-11 Thread el chupacabra
Hi, I'm just learning Pythonthanks in advance... Do you get out of this loop? Problem: When I type 'exit' (no quotes) the program doesn't quit the loop...it actually attemps to find entries that containt the 'exit' string. Desired behavior: when I type 'exit' the program should quit. def s

Newbie Alert! Upgrading Python?

2005-07-10 Thread El
Hi, Sorry to bother you folks with a real newbie question, but I am sure that this is the place for me to ask. Python 1.5.1 (final) and Python Win32 Extensions are installed on my 4 year old computer. My computer has always been upgraded to include the latest programs and Windows updates. Ho

Re: how can I sort a bunch of lists over multiple fields?

2005-04-30 Thread El Pitonero
googleboy wrote: > > I am reading in a csv file that documents a bunch of different info on > about 200 books, such as title, author, publisher, isbn, date and > several other bits of info too. > ... > I really want to be able to sort the list of books based on other > criterium, and even multiple

Re: a=[ lambda t: t**n for n in range(4) ]

2005-04-22 Thread El Pitonero
Bengt Richter wrote: > I still don't know what you are asking for, but here is a toy, > ... > But why not spend some time with the tutorials, so have a few more cards in your deck > before you try to play for real? ;-) Communication problem. All he wanted is automatic evaluation a la spreadsheet

Re: Puzzling OO design problem

2005-04-09 Thread El Pitonero
It may be useful to separate the code into version-independent part and version-dependent part. Also, one can try to implement the higher-level logic directly in the class definition of A, B, etc., and then use the version objects only as patches for the details. That is, one can use place-holder c

Re: Decorator Base Class: Needs improvement.

2005-04-06 Thread El Pitonero
Bengt Richter wrote: > On 5 Apr 2005 19:28:55 -0700, "El Pitonero" <[EMAIL PROTECTED]> wrote: > > >Scott David Daniels wrote: > >> Ron_Adam wrote: > >> > ... > >> > >> def tweakdoc(name): > >> def decorato

Re: Decorator Base Class: Needs improvement.

2005-04-05 Thread El Pitonero
Scott David Daniels wrote: > Ron_Adam wrote: > > ... > > def tweakdoc(name): > def decorator(function): > function.__doc__ = 'Tweak(%s) %r' % (name, function.__doc__) > return function > return decorator > > What is confusing us about what you write is tha

Re: Docorator Disected

2005-04-03 Thread El Pitonero
Martin v. Löwis wrote: > Ron_Adam wrote: > > > > No, I did not know that you could pass multiple sets of arguments to > > nested defined functions in that manner. > > Please read the statements carefully, and try to understand the mental > model behind them. He did not say that you can pass around

Re: Docorator Disected

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > > So I didn't know I could do this: > > def foo(a1): > def fee(a2): > return a1+a2 > return fee > > fum = foo(2)(6) <-- !!! Ah, so you did not know functions are objects just like numbers, strings or dictionaries. I think you may have been influenced by othe

Re: Decorator Dissection

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > On 2 Apr 2005 08:39:35 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> > wrote: > > >There is actually nothing mysterious about decorators. > > I've heard this quite a few times now, but *is* quite mysterious if > you are not already familiar with how they work. Or instead of > mysteri

Re: Docorator Disected

2005-04-02 Thread El Pitonero
Ron_Adam wrote: > > # (0) Read defined functions into memory > > def decorator(d_arg): # (7) Get 'Goodbye' off stack > > def get_function(function): # (8) Get func object off stack > > def wrapper(f_arg):# (9) Get 'Hello' off stack > > new_arg = f_arg+'-'+d_arg >

Re: "static" variables in functions (was: Version Number Comparison Function)

2005-03-29 Thread El Pitonero
Christos TZOTZIOY Georgiou wrote: > > One of the previous related threads is this (long URL): > http://groups-beta.google.com/group/comp.lang.python/messages/f7dea61a92f5e792,5ce65b041ee6e45a,dbf695317a6faa26,19284769722775d2,7599103bb19c7332,abc53bd83cf8f636,4e87b44745a69832,330c5eb638963459,e4c8d

Re: Python for a 10-14 years old?

2005-03-24 Thread El Pitonero
Lucas Raab wrote: > [EMAIL PROTECTED] wrote: > > I am blessed with a *very* gifted nine-years old daughter... > > Now, I would like to teach her programming basics using Python > > Let her mess around with it on her own. I'm 15 and have been using > Python for 2-3 years and had nothing to really go

Re: importing two modules with the same name

2005-03-19 Thread El Pitonero
Tim Jarman wrote: > But if your foo is under your control, why not do everyone a favour and call > it something else? His case is a canonical example of a patch. Often you'd like to choose the "patch" approach because: (1) the third-party may eventually incorporate the changes themselves, hence y

Re: importing two modules with the same name

2005-03-19 Thread El Pitonero
Francisco Borges wrote: > There are 2 "foo" named modules, 'std foo' and 'my foo'. I want to be > able to import 'my foo' and then from within my foo, import 'std > foo'. Anyone can help?? In other words, you would like to make a "patch" on third-party code. There are many ways to do it. Here is j

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
George Sakkis wrote: > "Aahz" <[EMAIL PROTECTED]> wrote: > > In article <[EMAIL PROTECTED]>, > > Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > > > > >The proposed names could possibly be improved (perhaps tally() is more active > > >and clear than count()). > > > > +1 tally() > > -1 for count():

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Raymond Hettinger wrote: > > As written out above, the += syntax works fine but does not work with append(). > ... > BTW, there is no need to make the same post three times. The append() syntax works, if you use the other definition of safedict (*). There are more than one way of defining safedict

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Raymond Hettinger wrote: > Separating the two cases is essential. Also, the wording should contain strong > cues that remind you of addition and of building a list. > > For the first, how about addup(): > > d = {} > for word in text.split(): > d.addup(word) import copy class safe

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
Dan Sommers wrote: > On Sat, 19 Mar 2005 01:24:57 GMT, > "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > > > The proposed names could possibly be improved (perhaps tally() is more > > active and clear than count()). > > Curious that in this lengthy discussion, a method name of "accumulate" > never

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread El Pitonero
On Sat, 19 Mar 2005 01:24:57 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >I would like to get everyone's thoughts on two new dictionary methods: > >def count(self, value, qty=1): >try: >self[key] += qty >except KeyError: >self[

Re: Python becoming less Lisp-like

2005-03-15 Thread El Pitonero
Fernando wrote: > The real problem with Python is ... Python is > going the C++ way: piling feature upon feature, adding bells > and whistles while ignoring or damaging its core design. I totally agree. Look at a recent thread "Compile time evaluation (aka eliminating default argument hacks)" ht