Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2022年3月30日星期三 UTC+1 16:38:26, 写道: > > On 30 Mar 2022, at 16:11, Edward Spencer wrote: > > > > 在 2021年9月3日星期五 UTC+1 18:50:51, 写道: > >>>> On 2 Sep 2021, at 23:38, Dieter Maurer wrote: > >>> > >>> Edward Spencer wrote at 2021-9-2

Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2021年9月3日星期五 UTC+1 18:50:51, 写道: > > On 2 Sep 2021, at 23:38, Dieter Maurer wrote: > > > > Edward Spencer wrote at 2021-9-2 10:02 -0700: > >> Sometimes I like to pass the logging level up to the command line params > >> so my user can specific what level

Add a method to list the current named logging levels

2021-09-02 Thread Edward Spencer
t be accessed because they change (and in fact, between python 2 and 3, they did). Any thoughts? Thanks, Ed Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Hi Sorry if I haven't stated my requirements clearly. I just wanted a way to import at least two python files in parallel and I wanted to know how this can be done or a reason why its bad as stated in another post. Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Why is importing modules in parallel bad? Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:44:46 UTC+1, Rhodri James wrote: > On 05/11/2019 18:33, Spencer Du wrote: > > I want to execute at least two python files at once when imported but > > I dont know how to do this. Currently I can only import each file one > > after another bu

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:41:59 UTC+1, Bob Gailer wrote: > On Nov 5, 2019 1:35 PM, "Spencer Du" wrote: > > > > Hi > > > > I want to execute at least two python files at once when imported but I > dont know how to do this. Currently I can only import

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 21:05:02 UTC+1, Terry Reedy wrote: > On 11/5/2019 1:33 PM, Spencer Du wrote: > > > I want to execute at least two python files at once when imported but I > > dont know how to do this. Currently I can only import each file one after > > an

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Tuesday, 5 November 2019 19:37:32 UTC+1, Karsten Hilbert wrote: > > I want to execute at least two python files at once when imported but I > > dont know how to do this. > > Currently I can only import each file one after another but what i want is > > each file to be imported > > at the same

Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
On Wednesday, 6 November 2019 09:05:42 UTC+1, Christian Gollwitzer wrote: > Am 06.11.19 um 03:59 schrieb Dennis Lee Bieber: > > On Tue, 5 Nov 2019 10:33:20 -0800 (PST), Spencer Du > > declaimed the following: > > > >> Hi > >> > >> I want t

How execute at least two python files at once when imported?

2019-11-05 Thread Spencer Du
sed") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a stage!" + "\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Stages() as stages: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(stages, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

How can I set the value of the textedit box and slider of ui with the value from a config file when it has been created?

2019-10-01 Thread Spencer Du
27;, 'intensity')) # if self.textbox.text() == "": # self.mySlider.setValue(0) # else: # self.mySlider.setValue(config.get('445nm', 'intensity')) if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() sys.exit(app.exec_()) config.py [445nm] intensity = 4 Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
label_3.setText(_translate("Laser", "515nm")) self.label_4.setText(_translate("Laser", "561nm")) self.label_5.setText(_translate("Laser", "594nm")) self.label_6.setText(_translate("Laser", "638nm")) self.label_7.setText(_translate("Laser", "LED")) self.pushButton_8.setText(_translate("Laser", "ON")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Laser = QtWidgets.QMainWindow() ui = Ui_Laser() ui.setupUi(Laser) Laser.show() sys.exit(app.exec_()) laserEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference class Laser(Actor): async def handle_message(self, message: Message): print("Laser") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a laser!" +"\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Laser() as laser: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(laser, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) Regards Spencer -- https://mail.python.org/mailman/listinfo/python-list

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
label_3.setText(_translate("Laser", "515nm")) self.label_4.setText(_translate("Laser", "561nm")) self.label_5.setText(_translate("Laser", "594nm")) self.label_6.setText(_translate("Laser", "638nm")) self.label_7.setText(_translate("Laser", "LED")) self.pushButton_8.setText(_translate("Laser", "ON")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Laser = QtWidgets.QMainWindow() ui = Ui_Laser() ui.setupUi(Laser) Laser.show() sys.exit(app.exec_()) laserEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference class Laser(Actor): async def handle_message(self, message: Message): print("Laser") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a laser!" +"\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Laser() as laser: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(laser, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) Regards Spencer -- https://mail.python.org/mailman/listinfo/python-list

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
label_3.setText(_translate("Laser", "515nm")) self.label_4.setText(_translate("Laser", "561nm")) self.label_5.setText(_translate("Laser", "594nm")) self.label_6.setText(_translate("Laser", "638nm")) self.label_7.setText(_translate("Laser", "LED")) self.pushButton_8.setText(_translate("Laser", "ON")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Laser = QtWidgets.QMainWindow() ui = Ui_Laser() ui.setupUi(Laser) Laser.show() sys.exit(app.exec_()) laserEmbedded.py import random import asyncio from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference class Laser(Actor): async def handle_message(self, message: Message): print("Laser") await asyncio.sleep(2) print("Unitialised") await asyncio.sleep(2) print("Initialising") await asyncio.sleep(2) print("Initialised") await asyncio.sleep(2) print("Configuring") await asyncio.sleep(2) print("Configured") await asyncio.sleep(2) await message.sender.tell(DataMessage(data="Hello World Im a laser!" +"\n", sender=self)) async def main(): # Let's create an instance of a Greeter actor and start it. async with Laser() as laser: # Then we'll just send it an empty message and wait for a response reply : DataMessage = await ask(laser, Message()) print(reply.data) asyncio.get_event_loop().run_until_complete(main()) Regards Spencer -- https://mail.python.org/mailman/listinfo/python-list

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
tton_7.setText(_translate("Laser", "ON")) self.label.setText(_translate("Laser", "445nm")) self.label_2.setText(_translate("Laser", "488nm")) self.label_3.setText(_translate("Laser", "515nm"))

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-26 Thread Spencer Du
Hi How do I publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value. Thanks # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'laser.ui' # # Created by: PyQt5 UI code generator 5.13.0 # # WARNING! All changes made in this fi

Re: TechRepublicDEVELOPERCXO JPMorgan's Athena has 35 million lines of Python code, and won't be updated to Python 3 in time

2019-09-15 Thread Spencer Graves
nceptually and practically the same kind of thing.   Spencer Graves Cheers, Gene Heskett -- https://mail.python.org/mailman/listinfo/python-list

Why is "Subscribing to topic topic/test" printed in console log before connect message?

2019-09-10 Thread Spencer Du
nt, userdata, msg): if msg.payload.decode() == "Hello world!": print("Yes!") Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me fix a problem

2019-09-06 Thread Spencer Du
On Friday, 6 September 2019 20:15:40 UTC+2, MRAB wrote: > On 2019-09-06 18:11, Spencer Du wrote: > > Hi > > > > I want to print yes in gui.py but it does not get printed because of the > > json. How do I fix this. Execute embedded.py and then gui.py to test. >

Re: Help me fix a problem

2019-09-06 Thread Spencer Du
On Friday, 6 September 2019 20:15:40 UTC+2, MRAB wrote: > On 2019-09-06 18:11, Spencer Du wrote: > > Hi > > > > I want to print yes in gui.py but it does not get printed because of the > > json. How do I fix this. Execute embedded.py and then gui.py to test. >

Re: Help me fix a problem

2019-09-06 Thread Spencer Du
On Friday, 6 September 2019 20:15:40 UTC+2, MRAB wrote: > On 2019-09-06 18:11, Spencer Du wrote: > > Hi > > > > I want to print yes in gui.py but it does not get printed because of the > > json. How do I fix this. Execute embedded.py and then gui.py to test. >

Help me fix a problem

2019-09-06 Thread Spencer Du
ibed to topic") def on_message(client, userdata, msg): print("message recieved= " + msg.payload.decode()) # print("File which you want to import(with .py extension)") print("message topic=", msg.topic) print("message qos="

How to remove a string from a txt file?

2019-09-04 Thread Spencer Du
Hi I want to remove a string from a txt file and then print out what I have removed. How do I do this. The txt file is in this format and should be kept in this format. txt.txt: laser,cameras, Thanks -- https://mail.python.org/mailman/listinfo/python-list

Help needed to run some code!!!!

2019-09-02 Thread Spencer Du
ded.py to execute after GUI.py has executed first. Thanks Spencer GUI.py import logging from datetime import timedelta import time from thespian.actors import * from transitions import Machine import paho.mqtt.client as mqtt import importlib import os import os.path import sys from

Help needed urgently for running some code!!!!

2019-09-02 Thread Spencer Du
Hi I want to execute "from devicesEmbedded import *": in GUI.py after all code in GUI.py is run. Also how do I make the devicesEmbedded.py reload and run when a txt file is created in the name of "list_of_devices.txt" in the GUI.py python program. GUI.py import logging from datetime import

Re: Hi how do I import files inside a txt file?

2019-09-02 Thread Spencer Du
On Monday, 2 September 2019 15:29:07 UTC+2, Joel Goldstick wrote: > On Mon, Sep 2, 2019 at 9:21 AM Spencer Du wrote: > > > > On Monday, 2 September 2019 15:03:52 UTC+2, Joel Goldstick wrote: > > > On Mon, Sep 2, 2019 at 8:46 AM Spencer Du wrote: > > > > &g

Re: Hi how do I import files inside a txt file?

2019-09-02 Thread Spencer Du
On Monday, 2 September 2019 15:03:52 UTC+2, Joel Goldstick wrote: > On Mon, Sep 2, 2019 at 8:46 AM Spencer Du wrote: > > > > On Monday, 2 September 2019 13:36:06 UTC+2, Pankaj Jangid wrote: > > > Spencer Du writes: > > > > > > > How do i import

Re: Hi how do I import files inside a txt file?

2019-09-02 Thread Spencer Du
On Monday, 2 September 2019 13:36:06 UTC+2, Pankaj Jangid wrote: > Spencer Du writes: > > > How do i import files inside a txt file if they exist in the current > > directory? > > > > Here is the current code but I dont know how to do it correctly. > >

Re: Hi how do I import files inside a txt file?

2019-09-02 Thread Spencer Du
On Monday, 2 September 2019 13:36:06 UTC+2, Pankaj Jangid wrote: > Spencer Du writes: > > > How do i import files inside a txt file if they exist in the current > > directory? > > > > Here is the current code but I dont know how to do it correctly. > >

Hi how do I import files inside a txt file?

2019-09-02 Thread Spencer Du
,test2 Each name refers to a python file. Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

How to create a list and append to list inside a mqtt and GUI program?

2019-09-01 Thread Spencer Du
Hi I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a GUI file if the file exists in current directory. I want to add the file name to a list when a file is imported and for each subsequent file that is imported I want the file name to be imported to the same list an

How to create list for stuff inside mqtt and GUI?.

2019-09-01 Thread Spencer Du via Python-list
Hi I have code for GUI and MQTT. In GUI.py I have "def loadGUI" which loads up a GUI file if the file exists in current directory. I want to add the file name to a list when a file is imported and for each subsequent file that is imported I want the file name to be imported to the same list an

How do I decouple these two modules?

2019-08-28 Thread Spencer Du via Python-list
ght_sheet_microscope/UI") def on_message(self, mqttc, userdata, message): msg = str(message.payload.decode("utf-8")) print("File which you want to import(with .py extension)") print("message topic=", message.topic) print("message qos=", message.qos) print("message retain flag=", message.retain) def run(self): self.connect("broker.hivemq.com", 1883, 60) Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: How do i execute some code when I have subscribed to a topic with a message payload for mqtt in python?

2019-08-08 Thread Spencer Du via Python-list
On Thursday, 8 August 2019 22:48:11 UTC+2, Spencer Du wrote: > Ok so here is some code below. How do I write an if code block to execute > some commands when I subscribe to the topic: > microscope/light_sheet_microscope/UI and which has a message which is a > device type publis

How do i execute some code when I have subscribed to a topic with a message payload for mqtt in python?

2019-08-08 Thread Spencer Du via Python-list
age to topic","microscope/light_sheet_microscope/UI") client.publish("microscope/light_sheet_microscope/UI",device) time.sleep(2) # wait print("subscribing ") client.subscribe("microscope/light_sheet_microscope/UI") client.loop_stop() #stop the loop Thanks Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: Your IDE's?

2019-03-25 Thread Spencer Graves
.com" is a URL being advertised for sale for $150,000.  "ping something.com" returns, "cannot resolve something.com:  Unknown host".   Clearly the original poster is playing games with us.       Spencer Cheers, Gene Heskett -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 random numbers

2019-01-14 Thread Spencer Graves
i + 1   This sounds like a homework problem for a class.  I don't know how this list treats such questions, but I suspect answering such questions may be discouraged.   Hint:  Read the documentation on "while" and then trace the iterations.       Spencer -- ht

Re: sampling from frequency distribution / histogram without replacement

2019-01-14 Thread Spencer Graves
been used extensively.  You'd have to work really hard to do better, in my judgment.       Spencer Graves DISCLAIMER:  I'm primarily an R guy and only use Python when I can't find a sensible way to do what I want in R. Duncan -- https://mail.python.org/mailman/listinfo/python-list

Re: Good editor for python

2018-11-11 Thread Spencer Graves
do this also, but I've not tried or verified them.   Spencer Graves On 2018-11-11 08:11, Andrew Z wrote: If you do scripts - emacs/vi is the way to go. If you need something more (like creating libraries, classes) go with pycharm. It is a professionally made IDE. Over past 2 years

Mixing R and Python in the same Jupyter Notebook and finding Python code within an RMarkdown document

2018-11-02 Thread Spencer Graves
R snippet, which does what I want (namely recording 5 seconds of whatever is connected to "audio in" or something similar on your computer and writing it to "KKFI2018-10-12t13_16-5sec.wav".   Thanks,   Spencer Graves -- https://mail.python.org/mailman/listinfo/python-list

Wikipedia on Python

2018-10-16 Thread Spencer Graves
fit lots of people.   If you have suggestions for how the article might be improved, you can post them to the "Talk" page associated with that article or send them to me.  If you are "autoconfirmed" with the Wikimedia system, you can make the changes your

Package creation documentation?

2018-10-16 Thread Spencer Graves
ot; for this, and what I should do after that?   I have decades of coding experience, but only a small portion of that was with Python, and that was roughly 7 years ago.   Thanks,   Spencer Graves [1] https://docs.python.org/3/glossary.html#term-package [2] https://packaging.pyth

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Spencer Graves
tarted with them after two days of effort.   2.  Find a reasonable "Introduction to Python" on the web. Others on this list should be able to suggest several.  I just found "https://docs.python.org/2/tutorial/introduction.html".  A web search for "an introduction to

Problems installing RStudio from Anaconda Navigator

2018-10-11 Thread Spencer Graves
ments tab create a new R/Python3.5 environment", then install RStudio into that new environment.[1]   So I killed the RStudio install and looked at the "Environments tab".  I'm new to Anaconda Navigator, and I didn't know what I was looking at so decided to ask here.  

Re: Multiple problems with Python 3.7 under Windows 7 Home Premium

2018-09-22 Thread Spencer Graves
udio in" on my Windows 7 machine.   Thanks again.   Spencer Graves On 2018-09-21 23:33, Terry Reedy wrote: On 9/21/2018 8:57 PM, MRAB wrote: On 2018-09-22 01:02, Michael Torrie wrote: On 09/21/2018 07:22 AM, Spencer Graves wrote: PYTHON - M PIP INSTALL PYAUDIO    &qu

Multiple problems with Python 3.7 under Windows 7 Home Premium

2018-09-21 Thread Spencer Graves
/ remove programs."   I repeated "Windows App Certification Kit", except that this time when the "Modify setup" window appeared, I clicked "repair". It came to that same point and gave the same error.   Suggestion?   Thanks,   Spencer -- https://mail.python.org/mailman/listinfo/python-list

Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
(I'm sorry for my delayed response -- I've been travelling and not had reliable Internet access.) On 2011-12-25, Ian Kelly wrote: > On Thu, Dec 22, 2011 at 1:21 AM, Spencer Pearson > wrote: >> I see a problem with this, though. The intersection of two lines is >>

Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
asonable. I'll definitely reconsider making the draw() method a requirement for all GeometricObjects. >> I've never modified an existing class before, and I fear the >> unfamiliar. If that's what you meant... it's really an acceptable >> thing to do? > > Yes,

Re: Adding an interface to existing classes

2012-01-05 Thread Spencer Pearson
(I'm sorry for my delayed response -- I've been travelling and not had reliable Internet access.) >> Spencer, i would re-think this entire project from the >> beginning. You are trying to make an object out of everything. You >> don't need to make an object of EV

Re: Adding an interface to existing classes

2011-12-24 Thread Spencer Pearson
On Dec 23, 9:13 am, Terry Reedy wrote: > On 12/22/2011 3:21 AM, Spencer Pearson wrote: > > > I'm writing a geometry package, with Points and Lines and Circles and > > so on, and eventually I want to be able to draw these things on the > > screen. I have two options

Adding an interface to existing classes

2011-12-22 Thread Spencer Pearson
ator for adding entries to draw_functions, but this is basically how it'd work. The second way feels kludgey to me, but I'm leaning towards it because it seems like so much less work and I'm out of ideas. Can anyone help, explaining either a different way to do it or why one of these isn't as bad as I think? Thanks for your time! -Spencer -- http://mail.python.org/mailman/listinfo/python-list

Instances' __setitem__ methods

2011-06-20 Thread Spencer Pearson
I was recently trying to implement a dict-like object which would do some fancy stuff when it was modified, and found that overriding the __setitem__ method of an instance did not act the way I expected. The help documentation (from help(dict.__setitem__)) claims that "d.__setitem__(k,v)" is equiva

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-08 Thread Spencer Pearson
All right, thank you for helping! I'd had a little voice in the back of my mind nagging me that it might not be logical to include a bunch of classes and function definitions in my startup file, but I never got around to splitting it up. The module/script distinction makes sense, and it seems more

Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Spencer Pearson
Hi! I'm writing a package with several files in it, and I've found that "isinstance" doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass( object ): pass if __name__ == '__main__': a = AClass() filetwo.is_acl

How to run python without python

2010-04-01 Thread Spencer
Is there a way to developing a script on linux and give it to someone on microsoft, so that they could run it on microsoft without installing python? Wayne -- http://mail.python.org/mailman/listinfo/python-list

Tuples vs. variable-length argument lists

2010-03-19 Thread Spencer Pearson
Hi! This might be more of a personal-preference question than anything, but here goes: when is it appropriate for a function to take a list or tuple as input, and when should it allow a varying number of arguments? It seems as though the two are always interchangeable. For a simple example... def

Fix problems with email list

2009-10-28 Thread Spencer Heckathorn
I am getting doubles of every email on this list. Is there a list manager I can inform? Please help this is getting very annoying and makes it very hard to follow along. Spencer -- http://mail.python.org/mailman/listinfo/python-list

Hello python users

2009-10-12 Thread Spencer Heckathorn
. I also want to make a synchronizing program. Lastly, I love poker and I would love even more to make a cool app for poker maybe an iPhone app or something I can post to the iGoogle page. So with that in mind where would you start? Thanks, Spencer -- http://mail.python.org/mailman/listinfo/python

Re: list comprehension question

2009-04-30 Thread Michael Spencer
Ross wrote: If I have a list of tuples a = [(1,2), (3,4), (5,6)], and I want to return a new list of each individual element in these tuples, I can do it with a nested for loop but when I try to do it using the list comprehension b = [j for j in i for i in a], my output is b = [5,5,5,6,6,6] inste

Re: efficiently checking for string.maketrans conflicts?

2009-04-22 Thread Michael Spencer
Saketh wrote: Thank you, Peter and Michael, for your solutions! I think that Michael's is what I was edging towards, but Peter's has demonstrated to me how efficient Python's set functions are. I have a lot more to learn about optimizing algorithms in Python... :) -- http://mail.python.org/mail

Re: generating random tuples in python

2009-04-22 Thread Michael Spencer
Robert Kern wrote: On 2009-04-20 23:04, per wrote: to be more formal by very different, i would be happy if they were maximally distant in ordinary euclidean space... so if you just plot the 3-tuples on x, y, z i want them to all be very different from each other. i realize this is obviously b

Re: efficiently checking for string.maketrans conflicts?

2009-04-20 Thread Michael Spencer
Saketh wrote: Hi everyone: I'm using "translation" in the sense of string.maketrans here. I am trying to efficiently compare if two string translations "conflict" -- that is, either they differently translate the same letter, or they translate two different letters to the same one. ... Anoth

Re: get rid of duplicate elements in list without set

2009-03-20 Thread Michael Spencer
Alexzive wrote: Hello there, I'd like to get the same result of set() but getting an indexable object. How to get this in an efficient way? Example using set A = [1, 2, 2 ,2 , 3 ,4] B= set(A) B = ([1, 2, 3, 4]) B[2] TypeError: unindexable object Many thanks, alex -- http://mail.python.org/m

Re: having a function called after the constructor/__init__ is done

2009-03-16 Thread Michael Spencer
thomas.han...@gmail.com wrote: ... So any ideas on how to get a function called on an object just after __init__ is done executing? -- http://mail.python.org/mailman/listinfo/python-list Yes, you *can* use metaclasses - you need to override the type.__call__ method, which is what normally ca

Re: [Py2exe-users] py2exe 0.6.9 released

2008-11-16 Thread Chris Spencer
After I "compile" my program with py2exe 0.6.9 with Python 2.6, I'm still getting the "Application Did Not Initialize Properly" error dialog whenever I run my code. What am I doing wrong? Note that py2exe 0.6.9 with Python 2.5 works just fine. Help! Chris. On Sat, 15 Nov 2008 23:21:15 -0800,

Re: sort functions in python

2008-02-08 Thread Michael Spencer
t3chn0n3rd wrote: > Do you think it is relatively easy to write sort algorithms such as > the common Bubble sort in Python as compared to other high level > programming langauges yes -- http://mail.python.org/mailman/listinfo/python-list

Re: which one is more efficient

2008-02-08 Thread Michael Spencer
ki lo wrote: > I have type variable which may have been set to 'D' or 'E' > > Now, which one of following statements are more efficient > > if type =='D' or type == 'E': > > or > > if re.search("D|E", type): > > Please let me know because the function is going to called 10s of > millions of t

Re: Why does list have no 'get' method?

2008-02-07 Thread Michael Spencer
Wildemar Wildenburger wrote: > Arnaud Delobelle wrote: >> Personally, between >> >> * foo if foo else bar >> * foo or bar >> >> I prefer the second. Maybe it could be spelt >> >> * foo else bar ? >> > How about > > val = foo rather than bar > > If that is not clear and obvios, I don't know what i

Re: 5 queens

2007-12-22 Thread Michael Spencer
cf29 wrote: > Greetings, > > I designed in JavaScript a small program on my website called 5 > queens. .. Has anyone tried to do a such script? If anyone is > interested to help I can show what I've done so far. Tim Peters has a solution to 8 queens in test_generators in the standard library

Re: Problem with generator expression and class definition

2007-12-07 Thread Michael Spencer
Terry Reedy wrote: > "Maric Michaud" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > |I faced a strange behavior with generator expression, which seems like a > bug, for both > | python 2.4 and 2.5 : > > Including the latest release (2.5.2)? > > | >>> class A : > | ... a = 1

Re: How does python build its AST

2007-12-07 Thread Michael Spencer
MonkeeSage wrote: > A quick question about how python parses a file into compiled > bytecode. Does it parse the whole file into AST first and then compile > the AST, or does it build and compile the AST on the fly as it reads > expressions? (If the former case, why can't functions be called before

Re: Why Python 3?

2007-12-05 Thread Michael Spencer
Kay Schluehr wrote: > > This unexpected attack in his rear frightened him so much, that he > leaped forward with all his might: the horse's carcase dropped on the > ground, but in his place the wolf was in the harness, and I on my part > whipping him continually: we both arrived in full career saf

Re: converting to and from octal escaped UTF--8

2007-12-02 Thread Michael Spencer
Michael Goerz wrote: > Hi, > > I am writing unicode stings into a special text file that requires to > have non-ascii characters as as octal-escaped UTF-8 codes. > > For example, the letter "Í" (latin capital I with acute, code point 205) > would come out as "\303\215". > > I will also have to r

Re: Interfaces to high-volume discussion forums

2007-12-01 Thread Michael Spencer
Dennis Lee Bieber wrote: > On Fri, 30 Nov 2007 11:36:44 -0800, Michael Spencer >> >> Can anyone recommend a solution that also synchronizes post read status? If >> Google Reader or something like it handled NNTP, I imagine I'd use it to >> achieve >>

Re: Interfaces to high-volume discussion forums

2007-11-30 Thread Michael Spencer
Ben Finney wrote: > > I'm not interested in learning some centralised web-application > interface, and far prefer the discussion forum to be available by a > standard *protocol*, that I can use my choice of *local client* > application with. > I agree: I use Thunderbird, and it works well. But

Re: Convert obejct string repr to actual object

2007-10-08 Thread Michael Spencer
Tor Erik Sønvisen wrote: > Hi, > > I've tried locating some code that can recreate an object from it's > string representation... > The object in question is really a dictionary containing other > dictionaries, lists, unicode strings, floats, ints, None, and > booleans. > > I don't want to use ev

Re: Dynamically creating class properties

2007-10-04 Thread Michael Spencer
Karlo Lozovina wrote: > > Any idea how to do that with metaclasses and arbitrary long list of > attributes? I just started working with them, and it's driving me nuts :). > > Thanks for the help, > best regards. > Try implementing a property factory function before worrying about the metaclas

Re: module confusion

2007-10-03 Thread Michael Spencer
+1 Subject line of the week (SLOTW) rjcarr wrote: > So my question is ... why are they [os.path and logging.handlers] different? [A] wrote: > Because you misspelled it. First, do a dir() on logging: [B] wrote: > No, he didn't... OP: logging is a package and logging.handlers is one module > in t

Re: I could use some help making this Python code run faster using only Python code.

2007-09-20 Thread Michael Spencer
Python Maniac wrote: > I am new to Python however I would like some feedback from those who > know more about Python than I do at this time. > > def scrambleLine(line): > s = '' > for c in line: > s += chr(ord(c) | 0x80) > return s > > def descrambleLine(line): > s = '' >

Re: subclass of integers

2007-09-14 Thread Michael Spencer
Mark Morss wrote: > I would like to construct a class that includes both the integers and > None. I desire that if x and y are elements of this class, and both > are integers, then arithmetic operations between them, such as x+y, > return the same result as integer addition. However if either x o

Re: Problem with filter()

2007-04-03 Thread Michael Spencer
Boudreau, Emile wrote: > Hey all, > So I'm trying to filter a list with the built-in function > filter(). My list looks something like this: > ['logs', 'rqp-8.2.104.0.dep', 'rqp-8.2.93.0.dep', > 'rqp-win32-app-8.2.96.0-inst.tar.gz', 'rqp-win32-app-8.2.96.0-inst.tar.gz'] > > Calling filte

Re: manually implementing staticmethod()?

2007-03-28 Thread Michael Spencer
"7stud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Can someone show me how to manually implement staticmethod()? Here is > my latest attempt: > Raymond Hettinger can: http://users.rcn.com/python/download/Descriptor.htm#static-methods-and-class-methods

Re: challenge ?

2007-03-22 Thread Michael Spencer
alain wrote: > I have a problem I wonder if it has been solved before. > I have a dictionnary and I want the values in the dictionnary to be > annotated with the rank that would be obtained by sorting the values > > def annotate_with_rank(my_dict): > > return my_annotated_dict >

Re: To count number of quadruplets with sum = 0

2007-03-15 Thread Michael Spencer
n00m wrote: > http://www.spoj.pl/problems/SUMFOUR/ > > 3 > 0 0 0 0 > 0 0 0 0 > -1 -1 1 1 > Answer for this input data is 33. > > My solution for the problem is > == > > import time > t = time.clock() > > q,w,e,r,sch,h = [],[],[

Re: Signed zeros: is this a bug?

2007-03-11 Thread Michael Spencer
Gabriel Genellina wrote: > > (I cannot find peephole.c on the source distribution for Python 2.5, but > you menctioned it on a previous message, and the comment above refers to > the peephole optimizer... where is it?) > The peephole optimizer is in compile.c - the entry point is optimize_c

Re: Flatten a two-level list --> one liner?

2007-03-07 Thread Michael Spencer
Sergio Correia wrote: > spam = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] > > Into something like > eggs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] > > There are *no* special cases (no empty sub-lists). eggs = [i for j in spam for i in j] Michael -- http://mail.python.org/mailman/listinfo/

Re: Python Source Code Beautifier

2007-02-27 Thread Michael Spencer
Franz Steinhaeusler wrote: > Use Spaces, size: 4 > detect mixed line ending > detect tabs mixed with space > trim trailing whitespaces. look at: tools/scripts/reindent.py > convert structs like: if (a > b): to if a > b: > fill in spaces, but not in functions between operators: > > a+=1 =>

Re: Overloading assignment operator

2007-01-29 Thread Michael Spencer
J. Clifford Dyer wrote: > I think that's the first time I've actually seen someone use a Monty > Python theme for a python example, and I must say, I like it. However, > "We are all out of Wensleydale." > > Cheers, > Cliff Oh, then you clearly don't waste nearly enough time on this newsgroup ;

Re: python poetry?

2006-12-19 Thread Michael Spencer
BartlebyScrivener wrote: > Python pseudo code limericks anywhere? I wrote the following in response to Steve Holden's limerick challenge a couple of years ago: # run me or voice the alphanumeric tokens from itertools import repeat for feet in [3,3,2,2,3]: print " ".join("DA-DA-DUM"

Re: Iterating over several lists at once

2006-12-13 Thread Michael Spencer
John Henry wrote: > Carl Banks wrote: > >> The function can be extended to allow arbitrary arguments. Here's a >> non-minmal recursive version. >> >> def cartesian_product(*args): >> if len(args) > 1: >> for item in args[0]: >> for rest in cartesian_product(*args[1:]): >>

Re: Defining classes

2006-12-13 Thread Michael Spencer
Nick Maclaren wrote: > > Well, I am already doing that, and regretting the fact that Python > doesn't seem to allow a class instantiation to return a new class :-) > >>> class Fake(object): ... def __new__(cls): ... return 42 ... >>> Fake() 42 >>> "instantiation" (i.e.

Re: Slicing / subsetting list in arbitrary fashion

2006-11-17 Thread Michael Spencer
Gregg Lind wrote: > I wish something like this was part of the standard python installation, > and didn't require one to use Numpy or Numarray. This sort of list > subsetting is useful in many, many contexts. > Many of numpy's multi-dimensional slicing and indexing operations are implemented

Re: How to identify generator/iterator objects?

2006-10-25 Thread Michael Spencer
Kenneth McDonald wrote: > I'm trying to write a 'flatten' generator which, when give a > generator/iterator that can yield iterators, generators, and other data > types, will 'flatten' everything so that it in turns yields stuff by > simply yielding the instances of other types, and recursively

Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-24 Thread Michael Spencer
Martin v. Löwis wrote: > Georg Brandl schrieb: >> Perhaps you can bring up a discussion on python-dev about your improvements >> and how they could be integrated into the standard library... > > Let me second this. The compiler package is largely unmaintained and > was known to be broken (and perh

Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-24 Thread Michael Spencer
Paul Boddie wrote: > Martin v. Löwis wrote: ...The compiler package is largely unmaintained and >> was known to be broken (and perhaps still is). > > I don't agree entirely with the "broken" assessment. Although I'm not > chasing the latest language constructs, the AST construction part of > the p

Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-23 Thread Michael Spencer
Georg Brandl wrote: > Michael Spencer wrote: >> Announcing: compiler2 >> - >> >> For all you bytecode enthusiasts: 'compiler2' is an alternative to the >> standard >> library 'compiler' package, with several adva

ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-19 Thread Michael Spencer
Announcing: compiler2 - For all you bytecode enthusiasts: 'compiler2' is an alternative to the standard library 'compiler' package, with several advantages. Improved pure-python compiler - Produces identical bytecode* to the built-in compile function for all /Lib and L

Re: Refactor a buffered class...

2006-09-07 Thread Michael Spencer
George Sakkis wrote: > Michael Spencer wrote: >> George Sakkis wrote: >>> Michael Spencer wrote: >>> >>>> def chunker(s, chunk_size=3, sentry=".", keep_first = False, keep_last = >>>> False): >>>> buffer=[] >

Re: Refactor a buffered class...

2006-09-06 Thread Michael Spencer
George Sakkis wrote: > Michael Spencer wrote: > >> Here's a small update to the generator that allows optional handling of the >> head >> and the tail: >> >> def chunker(s, chunk_size=3, sentry=".", keep_first = False, keep_last = >>

  1   2   3   4   5   >