On Tue, 15 Feb 2011 10:53:56 +0100 Andrea Crotti
wrote:
> Just a curiosity not a real problem, I want to pass from a string like
>
> xxaabbddee
> to
> xx:aa:bb:dd:ee
>
> so every two characters insert a ":".
> At the moment I have this ugly inliner
> interleaved = ':'.join(orig[x:x+2] f
Klaus Neuner wrote:
> > handlers = {
> > ".txt" : handle_txt,
> > ".py" : handle_py,
> > # etc
> > }
> >
>
> That is exactly what I would like to avoid: Having to map the function
> 'handle_txt' to '.txt'. Firstly, because I don't want to repeat
> anything and secondly, because I
VanceE wrote:
> for x in []:
> assert type(x) == type(())
>
> I expected an AssertionError but get no errors at all.
> Any explaination?
[] is an empty sequence, so your loop executes exactly 0 times. :)
for x in [None]:
assert ...
w.
--
http://mail.python.org/mailman/listinfo/py
"Daniel Fetchinson" wrote:
> Is it a feature that
>
> 1 or 1/0
>
> returns 1 and doesn't raise a ZeroDivisionError? If so, what's the rationale?
See: http://en.wikipedia.org/wiki/Short-circuit_evaluation
--
http://mail.python.org/mailman/listinfo/python-list
"David Hláčik" wrote:
> I have to create stable algorithm for sorting n numbers from interval
> [1,n^2] with time complexity O(n) .
Some kind of radix sort or counting sort. These algo. has O(n) complexity.
w.
--
http://mail.python.org/mailman/listinfo/python-list
frikk wrote:
> [...]
> As you can see- I am doing nothing other than drawing a lot of
> rectangles on the canvas.
You aren't drawing, but **creating** rectangle objects, as
a meth. name suggests. You find more info at tkinter.effbot.org.
> [...]
>
> def clear_grid():
canv.delete(ALL)
Helmut Jarausch wrote:
> Hi,
>
> I'm looking for an elegant solution to the following (quite common)
> problem:
>
> Given a string of substrings separated by white space,
> split this into tuple/list of elements.
> The problem are quoted substrings like
>
> abc "xy z" "1 2 3" "a \" x"
>
> should
escalation746 wrote:
> def ViewValuable():
[...]
> code = """
> Hello()
> Plus()
> Valuable()
> """
These names don't match. I replaced Valuable() with proper name,
and everything work fine.
w.
--
http://mail.python.org/mailman/listinfo/python-list
Matthew Wilson wrote:
> I want to write a function that each time it gets called, it returns a
> random choice of 1 to 5 words from a list of words.
>
> I can write this easily using for loops and random.choice(wordlist) and
> random.randint(1, 5).
>
> But I want to know how to do this using iterto
[EMAIL PROTECTED] wrote:
> I am playing with the atexit module but I don't find a way to see the
> difference
> between a script calling sys.exit() and the interpreting
> arriving at the end
> of the source code file. This has a semantic difference for my
> applications.
> Is there a way to determi
O.R.Senthil Kumaran wrote:
> Any suggestions on how can i make this checkbutton effect.
> 1) Press Enable IP, the Label IP should be shown.
> 2) Toggle Enable IP (So that its unset). the Label IP should not be shown.
>
> #!/usr/bin/python
> from Tkinter import *
> root = Tk()
> root.title('somethi
Gigs_ wrote:
> I'm working on tkinter paint program, mostly to learn tkinter canvas.
> I have method which create buttons for oval, rectangle, line, polygon etc.
> How to make oval button to be sunken when i click it and to remain
> sunken until i click on another button (like rectangle and than i
abcd wrote:
> My regex so far is: src=\"(.*)\" however the group in this case
> would end up being, image/blah/a.jpg" id="d">blah blah blah a>.
>
> how can I tell the regex group (.*) to end when it gets to the first
> " ?
Use non-greedy matching, i.e. src=\"(.*?)\" (question mark af
Dropkick Punt wrote:
prefixes = [ "the", "this", "that", "da", "d", "is", "are", "r", "you",
"u"]
>
> And I have a string, that I split() into a list.
>
sentence = "what the blazes is this"
sentence = sentence.split()
>
> Now I want to strip the sentence of all words in the
Dick Moores wrote:
> What do I do to see this?
For example Opera 9 and Firefox 1.5+ are able to view SVG files;
there is a free plugin for IrfanView.
w.
--
http://mail.python.org/mailman/listinfo/python-list
Dick Moores wrote:
>> Turtle module uses Tk canvas element to draw graphics ('_canvas'
>> attribute). I've written module, that exports canvas graphics to SVG
>> file: http://wmula.republika.pl/proj/canvas2svg/ -- it may be useful
>> for you.
>
> I afraid I'm totally unfamiliar with SVG. Would it
Rehceb Rotkiv wrote:
> I want to check whether, for example, the element myList[-3] exists. So
> far I did it like this:
>
> index = -3
> if len(myList) >= abs(index):
> print myList[index]
IMHO it is good way.
> Another idea I had was to (ab-?)use the try...except structure:
>
> index =
Dick Moores wrote:
> I accidentally stumbled across the Turtle Graphics module (turtle.py)
> the other day and have been having some fun with it.
>
> Now I'm wondering if there is a way to build into a script the saving of
> each window just before it is cleared. For example, here are a couple
IamIan wrote:
> I am confused as to why including 08 or 09 in a sequence (list or
> tuple) causes this error. All other numbers with a leading zero work.
All literals that start with "0" digit are considered as
octal numbers, i.e. only digits "0".."7" are allowed.
See octinteger lexical definitio
Ernesto García García wrote:
> Hi experts,
>
> How would you do this without the more and more indenting cascade of ifs?:
>
> match = my_regex.search(line)
> if match:
> doSomething(line)
> else:
> match = my_regex2.search(line)
> if match:
> doSomething2(line)
> else:
> match = m
Fabian Braennstroem wrote:
> Now, I would like to improve it by searching for different 'real'
> patterns just like using 'ls' in bash. E.g. the entry
> 'car*.pdf' should select all pdf files with a beginning 'car'.
> Does anyone have an idea, how to do it?
Use module glob.
--
http://mail.python.
Paul Kozik wrote:
> However, if I use xml.minidom.parse to parse the xml document, change
> a few attributes with setAttribute, then write back with toprettyxml,
> my XML file gets loaded up with spaces between many of the elements.
Use 'toxml' method, that writes XML document without any modifica
ianaré wrote:
> like this:
>
>
> list = ["Replace", "ChangeCase", "Move"]
> textVariable = list[n]
> self.operations.insert(pos, operations.[textVariable].Panel(self,
> main))
>
> Is something sort of like that possible?
Yes:
self.operations.insert(
pos,
getattr(operations, tex
swiftset wrote:
> I'm try to convert a glyph into a format I can easily numerically
> manipulate. So far I've figured out how to use ttfquery to get a list
> that represents the outline of a contour in a glyph:
>
> from ttfquery import describe, glyphquery, glyph
> f = describe.openFont("/usr/shar
[EMAIL PROTECTED] wrote:
> Hi, I am using gvim to edit python source files. When I press "*" or
> "#", I would want to search for the attribute name under the cursor
> and not the entire string.
> For example, If I have os.error and pressing * on top of error
> searches for os.error rather than er
jupiter wrote:
> I have a problem. I have a list which contains strings and numeric.
> What I want is to compare them in loop, ignore string and create
> another list of numeric values.
>
> I tried int() and decimal() but without success.
>
> eq of problem is
>
> #hs=string.split(hs)
> hs =["popo
Thomas Nelson wrote:
> My code:
>
> class Policy(list):
> def __cmp__(self,other):
> return cmp(self.fitness,other.fitness)
Define method __gt__.
--
http://mail.python.org/mailman/listinfo/python-list
abcd wrote:
> I am using fnmatch.fnmatch to find some files. The only problem I have
> is that it only takes one pattern...so if I want to search using
> multiple patterns I have to do something like
>
> patterns = ['abc*.txt', 'foo*']
>
> for p in patterns:
> if fnmatch.fnmatch(some_file
Fredrik Lundh wrote:
> Matthias Vodel wrote:
>
>> I want to change the beginning/end-coordinates of a canvas.line item.
>>
>> Something like:
>>
>> self.myCanvas.itemconfigure(item_id, coords=(x1_new, y1_new, x2_new, y2_new))
>
> self.myCanvas.coords(item_id, x1_new, y1_new, x2_new, y2_new)
Yo
Steve Bergman wrote:
> I'm looking for a module to do fuzzy comparison of strings. [...]
Check module difflib, it returns difference between two sequences.
--
http://mail.python.org/mailman/listinfo/python-list
vertigo wrote:
> i have:
> x = zeros([3,4],Float)
>
> how can i check how many rows and columns x have ?
> (what is the X and Y size of that table) ?
Data member x.shape (tuple) contains
dimensions of array.
--
http://mail.python.org/mailman/listinfo/python-list
Mudcat wrote:
> I have also determined that this is not a problem if the button is not
> packed inside the frame. So somehow the interaction of the internal
> button is causing this problem.
Problem is really strange, and seems to be a Tk issue, not Tkinter.
I've observed that if method configure
Mudcat wrote:
> [...]
You have to set cursor once, Tk change it automatically:
> def buildFrame(self):
> self.f = Frame(self.master, height=32, width=32, relief=RIDGE,
> borderwidth=2)
> self.f.place(relx=.5,rely=.5)
#self.f.bind( '', self.enterFr
Nick Craig-Wood wrote:
>> It's very mature, full-featured, and portable, and fairly easy to
>> learn as well.
>
> ...with native look and feel on each platform unlike GTK / TK
AFAIK Tk 8 uses platform's native widgets.
w.
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase wrote:
> print "a = %s" % repr(a)
or
print "a = %r" % (a,)
--
http://mail.python.org/mailman/listinfo/python-list
Alistair King wrote:
> is there a simple way of creating global variables within a function?
def foo(name):
globals()[name] = "xxx"
globals()[name + 'aa'] = "yyy"
globals()[name + 'ab'] = "zzz"
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> The problem is negative values. If the unit returns the hex value 'e7',
> it means -25, but python says it's 231:
> ---
int('e7', 16)
> 231
> ---
>
> Does anyone have a clue a to what I need to do?
def u2(x):
i
fl1p-fl0p wrote:
> import math
> math.pow(34564323, 456356)
>
> will give math range error.
>
> how can i force python to process huge integers without math range
> error? Any modules i can use possibly?
You have to use operator **, i.e. 34564323**456356
--
http://mail.python.org/mailman/listinfo
Ronny Mandal wrote:
> Assume we have a list l, containing tuples t1,t2...
>
> i.e. l = [(2,3),(3,2),(6,5)]
>
> And now I want to sort l reverse by the second element in the tuple,
> i.e the result should ideally be:
>
> l = [(6,5),(2,3),(3,2)]
>
>
> Any ideas of how to accomplish this?
def cmpfun
manstey wrote:
> in for loops like the following:
>
> word='abcade'
>
> for letter in word:
>print letter
>
>
> Is it possible to get the position of letter for any iteration through
> the loop?
for index, letter in enumerate(word):
print index, letter
--
http://mail.python.org/mailma
PAolo wrote:
> any comment, suggestion? Is there something not elegant?
Try this:
even = range(10)[0::2]
odd = range(10)[1::2]
--
http://mail.python.org/mailman/listinfo/python-list
41 matches
Mail list logo