Olivier Langlois wrote:
> I would like to make a string comparison that would return true without
> regards of the number of spaces and new lines chars between the words
>
> like 'A B\nC' = 'A\nBC'
>
import string
NULL = string.maketrans("","")
WHITE = string.whitespace
def compare(a,b)
Per wrote:
> Thanks Ron,
> surely set is the simplest way to understand the question, to see
> whether there is a non-empty intersection. But I did the following
> thing in a silly way, still not sure whether it is going to be linear
> time.
> def foo():
> l = [...]
> s = [...]
> dic =
Olivier Langlois wrote:
> Hi Michael!
>
> Your suggestion is fantastic and is doing exactly what I was looking
> for! Thank you very much.
> There is something that I'm wondering though. Why is the solution you
> proposed wouldn't work with Unicode strings?
>
Simply, that str.translate with two a
Alex Martelli wrote:
> Michael Spencer <[EMAIL PROTECTED]> wrote:
>>
>> Here, str.translate deletes the characters in its optional second argument.
>> Note that this does not work with unicode strings.
>
> With unicode, you could do something strictly equ
Lonnie Princehouse wrote:
>> What's your use case exactly ?
>
> I'm trying to use a function to implicitly update a dictionary. The
> whole point is to avoid the normal dictionary semantics, so kw['x'] = 5
> unfortunately won't do.
>
> I think bytecode hacks may be the way to go
>
I once messed
Fredrik Lundh wrote:
>
" hello world ".split()
> ['hello', 'world']
a.split() == b.split() is a convenient test, provided you want to normalize
whitespace rather than ignore it. I took the OP's requirements to mean that
'A B' == 'AB', but this is just a guess.
Michael
--
http://mail.
bruno at modulix wrote:
> Ziga Seilnacht wrote:
>> bruno at modulix wrote:
>>
>>> Hi
>>>
>>> I'm currently playing with some (possibly weird...) code, and I'd have a
>>> use for per-instance descriptors, ie (dummy code):
>>
>>
>>
>>> Now the question: is there any obvious (or non-obvious) drawback
Joseph Turian wrote:
> In another thread, it was recommended that I wrap a dictionary in a
> class.
> How do I do so?
>
>Joseph
>
> that thread:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/9a0fbdca450469a1/b18455aa8dbceb8a?q=turian&rnum=1#b18455aa8dbceb8a
>
Perhaps li
Bruno Desthuilliers wrote:
> Michael Spencer a écrit :
>> I may be missing the subtlety of what you're up to, but why is
>> overriding __getattribute__ more desirable than simply defining the
>> descriptor in a subclass?
>
> The code snippet I gave as an exa
kpp9c wrote:
> I have a question... and ... whew ... i am gonna be honest, i haven't
> the slightest clue how to even start ... i am not sure if i used up all
> my good will here or can take a mulligan.. i love to try to at least
> post some lame broken code of my own at first... but like i said, n
[EMAIL PROTECTED] wrote:
> Nevermind, I didn't understand the problem/question... Sorry.
>
> Bye,
> bearophile
>
Really? Your solution looks fine to me.
In any case, here's an alternative approach to the (based on the same
understanding of the problem as bearophile's, but with the additional
Kamilche wrote:
> Hi everyone. I'm trying to convert a string that looks like this:
>
> gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS', text2 = 'more
> text without quotes', fmtline = "@VALUE @SIGNAL", signals = [('FPS',
> None), ('FPS2', 'something')]
>
> to a dict that looks like this
Kamilche wrote:
> Thanks! It's interesting, and nearly what I want, but not quite there.
>
> When I run my sample code through it, I get a syntax error because it's
> not a valid expression. If I were to put a 'dict(' in front and a ')'
> at the end, THEN it nearly works - but it gives me an
> 'Un
[EMAIL PROTECTED] wrote:
> The python code below is adapted from a Haskell program written by
> Tomasz
> Wielonka on the comp.lang.functional group. It's more verbose than his
> since I wanted to make sure I got it right.
>
> http://groups.google.com/group/comp.lang.functional/browse_frm/thread...
Cloudthunder wrote:
> Sorry, I don't understand, how does this solve my problem?
>
__getattr__ and __setattr__ allow you to set up dynamic delegation e.g.,
class Foo(object):
def __init__(self, **kw):
self.__dict__.update(kw)
def methFoo(self, x):
return "Foo.methFoo(%
Sandra-24 wrote:
> No it's not an academic excercise, but your right, the situation is
> more complex than I originally thought. I've got a minor bug in my
> template code, but it'd cause more trouble to fix than to leave in for
> the moment.
>
> Thanks for your input!
> -Sandra
>
Take a look at
John Salerno wrote:
> Ben Cartwright wrote:
>
>> Definitely go for (1). The Morris sequence is a great candidate to
>> implement as a generator. As a generator, it will be more flexible and
>> efficient than (2).
>
> Actually I was just thinking about this and it seems like, at least for
> my
John Salerno wrote:
> Michael Spencer wrote:
>
>> itertools.groupby makes this very straightforward:
>
> I was considering this function, but then it seemed like it was only
> used for determing consecutive numbers like 1, 2, 3 -- not consecutive
> equivalent numbers l
Steven Bethard wrote:
> Azolex wrote:
>> Steven Bethard wrote:
>>> and named, nested hierarchies like XML documents could be created
>>> like::
>>>
>>> create ETobject html:
>>> "This statement would generate an ElementTree object"
>>>
>>> create ETobject head:
>>> "
. 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
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
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
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
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
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
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
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
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
401 - 428 of 428 matches
Mail list logo