Would someone like to suggest a replacement for this? It works ok,
but it doesn't look like any of the other code:
tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
for port in tempList:
pagefound = False
for i in range(self.parent.GetPageCount()):
page=self.parent.GetPage
Wos! Several different thoughts:
An object using yield to return only the relevant pages, one at a time.
Pop to remove the items from the list.
A dictionary to map between the strings and the integers.
The dictionary was particularly unexpected. Eventually, I
plan to change the string ports to de
Would someone like to suggest a replacement for this? This is a
function that returns different kinds of similar objects, depending
on what is asked for. PSP and PWR are classes. I don't really
want to re-write the calling code very much: I'm just wondering
if the function can be replaced with som
Thank you, so generallizing:
(1) Python re-evaluates the loop range on every loop, and
(2) Python does short-circuit evaluation of conditions, in predictable
order.
Sorry about the bad question.
"Zentrader" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does page count change?
difference, a\b, a.~b, ['a','c']
Steve.
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>> Would someone like to suggest a replacement for this? It works ok,
>> but it doesn't look like any of th
op?
Steve.
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> En Thu, 23 Aug 2007 23:54:14 -0300, bambam <[EMAIL PROTECTED]> escribi?:
>
>> After examining your suggestion, I realised that another thing
>> I am interested in could be g
Psp()
elif DeviceType=="Power Supply"
return Pwr()
What about the parameter "DeviceType"?
Also, I see what you mean now, DEVICE_DICT is upper
case because it is a 'constant' -- I'd missed that point.
Steve.
"Bruno Desthuilliers" <[EMAIL
ence for matching off and netting out are standard
operations.
Still, any built in feature would probably be too simple to
use in any but the simplest cases.
Steve.
"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>
>> Exce
> virtually the only ones that feel the need to rub our nationality into
I'd always assumed (I never spent much time) that Germans were
another culture that had the habit of greeting groups on entrance.
Australians, English, and most of North America just don't have
that habit.
Steve.
"Wildemar
That looks good, and perhaps a difference operator
would be too simple to be useful anyway.
Steve.
"Mikael Olofsson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
>
> bambam wrote:
>>
>> In this case it doesn't matter - my lists don
t away from standard Python.
Steve.
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>>> The reason that lists don't have set-like methods is because
>>> lists aren't sets -- lists can contain duplicate
cGuire" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Aug 23, 11:50 pm, "bambam" <[EMAIL PROTECTED]> wrote:
>> Thank you, so generallizing:
>>
>> (1) Python re-evaluates the loop range on every loop, and
>> (2) Python does short-c
ve it in every loop
Is self.parent.GetPageCount() 'retrieved every loop'?
Steve.
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> En Sun, 26 Aug 2007 22:58:35 -0300, bambam <[EMAIL PROTECTED]> escribi?:
>
>> Ok, many
ge? i.e. is it necessary to retrieve it in every loop
Is self.parent.GetPageCount() 'retrieved every loop'?
Steve.
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>> That is, is it defined what Python does for
Is it safe to write
A = [x for x in A if x in U]
or is that undefined? I understand that the slice operation
can be used to make a temporary copy, so I could write
A=[x for x in A[:] if x in U]
but I've just copied that without any understanding.
Steve.
"bambam" <[EMAIL PR
could create an object of the base Device class, and at init
I could make sure the methods were connected for a Psp or
a Pwr device. When (if ever) is that a good idea?
Steve.
"Dan Bishop" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Aug 23, 10:21 pm, "
Thank you.
Steve.
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam <[EMAIL PROTECTED]> wrote:
>
>> Is it safe to write
>>
>> A = [x for x in A if x in U]
>>
>> or is that undefined? I understand
. I'm not sure if the
place I am looking at right now is supposed to support
duplicates or not: duplicates are permitted, but they
cause report anomalies.
Steve.
"Paul Rubin" <http://[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "bambam" <[EMAIL
Thank you.
I'm glad to see that I don't need to choose between two
opposing viewpoints :~)
Steve.
--
http://mail.python.org/mailman/listinfo/python-list
"Bruno Desthuilliers" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
>
> As a side note, in Python, inheritance ...
> ... should usually not be used for typing.
:~(
I'm sorry, I don't even know what that means... The code I
have inherited from someone only a little more knowledgeabl
I have about 30 pages (10 * 3 pages each) of code like this
(following). Can anyone suggest a more compact way to
code the exception handling? If there is an exception, I need
to continue the loop, and continue the list.
Steve.
---
for dev in devs
try:
in the
question at all levels.
Note that this achieves synchronous parallel processing --
another area I know nothing about -- but I'm just starting
with the code as I got it, and coding so far was focused
on hardware integration.
Steve.
"bambam" <[EMAIL PROTECTED]> wrote in
.
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 06 Sep 2007 15:44:57 +1000,
> "bambam" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> Try something like this: define a module holding t
> Removing from a list while you iterate will had quadratic performance
Anecdote:
I was doing a route-finding program for a railway
ticketing system. My replacement explained to my boss
that it couldn't be done: the problem was one of that
class of problems that has no good optimum solution.
M
istory?
Steve.
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Fri, 07 Sep 2007 12:03:26 +1000, bambam wrote:
>
>> Hi Steven.
>>
>> Looking at your code, why are you naming the value __all__? It looks
>> like a
ink at the risk making the call
environment more complex.
Still, the main thing is that I hadn't even thought of doing it
that way.
Thank you,
Steve.
"Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> In message <[EMAIL PROTECTED]
I have a number of news readers here, but all of them work
better with top-posting, and in none of them is top posting
a problem. What software are you using?
Steve.
"Lawrence D'Oliveiro" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> In message <
import works in the main section of the module, but does
not work as I hoped when run inside a function.
That is, the modules import correctly, but are not visible to
the enclosing (global) scope.
Questions:
(1) Where can I read an explanation of this?
(2) Is there a work around?
BTW, sys.module
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sep 10, 10:52 pm, "bambam" <[EMAIL PROTECTED]> wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is,
"J. Cliff Dyer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is, the modules import correctly, but
"Steve Holden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> bambam wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is, the modules import correctly, but
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Wed, 17 Oct 2007 13:41:06 +0200, Hrvoje Niksic wrote:
>
>> The current implementation of += uses __add__ for addition and __iadd__
>> for addition that may or may not be in-place. I'd like to know the
>> rational
Are function variables thread safe?
def f(a):
# whatever
return float(a)
Is that OK?
def f(a):
#whatever
b=a:
#whatever:
return float(b)
Is that OK?
Steve.
--
http://mail.python.org/mailman/listinfo/python-list
I wish to create a generic container object, devlist, such that
devlist.method(arguments)
runs as
for each dev in devlist.pool:
dev.method(arguments)
and
s = devlist.method(arguments)
runs as
for each dev in devlist.pool:
s.append(dev.method(arguments))
...but
Original languages were line oriented, newer languages were
block oriented.
Original languages has line comments. Newer languages had
block comments, and had line comments added back in.
So I would read that as line comments being more fundamental,
but people who used line comments got so sick of
I started with ths:
--
def open_pipe():
pipe=PIPE()
print pipe
return pipe
pipe=open_pipe()
pipe.parent = self.parent
print pipe
--
It didn't do what I wanted: when I printed the pipe the second time it was
not the same object as
Second try (correction)
I started with ths:
--
def open_pipe():
pipe=PIPE()
print pipe
return pipe
pipe=open_pipe()
pipe.parent = self.parent
print pipe
--
It didn't do what I wanted: when I printed the pipe the second time i
Thank you.
So example 2 was clearly wrong, and example 1 was not clear :~).
pipe is a serial port object: when I print pipe it shows first that it is
connected to port 5, then that it is connected to port 6. I'll discard
the clearly wrong code, and concentrate on the unclear code: probably
by th
Junk E-Mail Options, Protection is set to High. All of my messages are
coming through with a SCL of 9 (I checked), but none of them are going to
the Junk E-Mail folder.
I thought this was a server-side rule?
Can anyone explain, and also tell me what I need to do?
--
http://mail.python.org/ma
I have a class containing a series of classes like this:
class Th(Externaldevice):
class _Communicate(commandset2.CommandSet_Communicate):
def __getattribute__(self,attrname):
attr =
commandset2.CommandSet_Communicate.__getattribute__(self,attrname)
if "__call__" in dir(attr):
Wrong message, wrong group. Sorry.
"bambam" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Junk E-Mail Options, Protection is set to High. All of my messages are
> coming through with a SCL of 9 (I checked), but none of them are going to
> the Junk E-M
a common location, modify code so that
changes only affect areas that encapsulate side effects. This code allows
top level code to pretend that the intermediate code has not changed.
regards
(david)
"bambam" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
"Carl Banks" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Feb 27, 12:44 am, "bambam" <[EMAIL PROTECTED]> wrote:
>> In retrospect, the project has three parts: remove
>> side effects, push side effects to a common location, modify
43 matches
Mail list logo