FlashMX and Py2exe doesn't fly...
Flash and Python could be a VERY powerful pair of tools for building quick apps, Yet I don't see much on the web about it. I was excited to see that it is possible to make them play together here: http://www.klaustrofobik.org/blog/archives/000235.html Unfortunately, these folks seem to have gotten stuck on compiling the py files to exe, and since I don't see reference to it anywhere else, I was wondering if anyone here knew why it didn't work, or if anyone had ideas about how to make it work. Normally I would put some test code here, but I'm way out of my league. Just insanely curious... Any thoughts??? Thanks, -J -- http://mail.python.org/mailman/listinfo/python-list
Re: pulling multiple instances of a module into memory
in spam.py, how about something like this: try: eggs.someFunction() except: import eggs -- http://mail.python.org/mailman/listinfo/python-list
Re: FlashMX and Py2exe doesn't fly...
Wow, that was easy! Thanks Myles!!! -- http://mail.python.org/mailman/listinfo/python-list
the python way?
Hi All,
I've been lurking the list for a month and this is my first post. I am
hoping this post is appropriate here, otherwise, my apologies.
I'm somewhat new to Python, (I'm reading all the tutorials I can find,
and have read through Andre Lessa's Developers Handbook.)
I am trying to learn the Python way of thinking as well as the syntax.
I popped this bit of code together for fun, based on a previous post
regarding randomizing a word.
This shuffles a word, then splits out the vowels and then reassembles
it with the vowels interpolated between consonants.
(To create plausible sounding gibberish)
The code just seems kind of bulky to me. I am wondering, is this an
efficient way to do things, or am I making things harder than
necessary?
#--begin code--
"""scrambles a word, but creates plausable gibberish"""
import random
def shuffled(s):
""" scrambles word"""
l = list(s)
random.shuffle(l)
return ''.join(l)
def contains(alist,b):
"""...is letter b in list a..."""
ret = []
for all in alist:
#print all
if all==b:
return 1
return 0
def newZip(a1,a2):
""" reassemble """
l1=len(a1)
l2=len(a2)
longest = [a1,a2][l10:
ret = ret + longest.pop()
if len(shortest)>0:
ret = ret + shortest.pop()
return ret
def reinterpolate(word):
""" main function """
wlist = shuffled(list(word))
vlist = list('aeiouy') # ok, y isn't really a vowel, but...
vees = filter(lambda x: contains(vlist,x),wlist)
cons = filter(lambda x: not(contains(vlist,x)),wlist)
a=list(vees)
b=list(cons)
return newZip(a,b)
word = "encyclopedia"
print reinterpolate(word)
#---end code---
BTW: I'm just curious, is there an easier way to copy-paste code
snippets from the interpreter so that it removes the '... ' and the
'>>> ' from the examples? I'm using search and replace now
which works, but if there is a better way, I'd like to know.
thanks in advance,
-J
--
http://mail.python.org/mailman/listinfo/python-list
Re: the python way?
Wow... Thanks for all the tips guys... I will study the above examples. ...down to 8 lines of exquisitely readable code... Wow... Python rocks... (still aspiring to greatness myself,) cheers, -John x=["ohndes","j","wu","x[1][0]+x[0][:3]+chr(((len(x))*16))+x[2]+x[0][2:]+`round(1)`[1]+x[3][17]+x[0][0]+chr(ord(x[0][2])-1)"] print eval(x[3]) -- http://mail.python.org/mailman/listinfo/python-list
Re: split up a list by condition?
Reinhold, Thanks for your response in the previous thread. Yours is an interesting question. I haven't come up with a solution, but I did realize that in the previous problem, the source 'word' doesn't really need to stay intact... So perhaps a solution along these lines? >>> for a in enumerate(wlist): ... if a[1] in vowels: ... vees.append(wlist.pop(a[0])) I don't know if it's possible to cram a 'pop' command into the single line solution though. I look forward to seeing other tricks to this end... :) -- http://mail.python.org/mailman/listinfo/python-list
Re: split up a list by condition?
> vees, cons = [], [] > [(vees, cons)[ch in vocals].append(ch) for ch in wlist] Wow, that's horribly twisted Reinhold... I spent about an hour last night trying something similar, to no end... :) Neat tricks people... I like Duncan's use of "or" to solve it. I didn't see that in the python docs on list comprehension. Very cool. There is a special place in my heart for obfuscated Python, but of course, not in production code if there is a clearer solution available. -- http://mail.python.org/mailman/listinfo/python-list
Programmatic links in a TKinter TextBox
I've been hacking around this for a few days and have gotten close to
what I want... but not quite...
The TKinter Docs provide this example:
# configure text tag
text.tag_config("a", foreground="blue", underline=1)
text.tag_bind("a", "", show_hand_cursor)
text.tag_bind("a", "", show_arrow_cursor)
text.tag_bind("a", "", click)
text.config(cursor="arrow")
#add text
text.insert(INSERT, "click here!", "a")
#add a link with data
text.insert(END, "this is a ")
text.insert(END, "link", ("a", "href"+href))
What I don't understand is how the function "click" sees the "href"
text.
def click(self, data):
#this doesn't work
print data
The print statement inside function "click" displays:
If I try to access the link data like this "data[0]" I get an error.
I'm not planning to use web links, I just need each link to send unique
data to the "click" function.
How can I retrieve the custom link data from within my function???
--
http://mail.python.org/mailman/listinfo/python-list
Re: Programmatic links in a TKinter TextBox
Many thanks Jeff!!!
This is what should be in the TK docs. Your example was very clear.
And now I've learned some new stuff... :)
For my project, I needed to add three pieces of data per link like
this:
text.insert(Tkinter.END, "link", ("a", "href:"+href,"another:This Is
More Data", "last:and one more bit for fun"))
I tweaked the above example here to catch multiple bits by adding a
couple elif statements to the for loop, and removing the break lines.
def click(event):
w = event.widget
x, y = event.x, event.y
tags = w.tag_names("@%d,%d" % (x, y))
for t in tags:
if t.startswith("href:"):
print "clicked href %s" % t[5:]
#commented out the break
elif t.startswith("another:"):
print "clicked href %s" % t[8:]
# commented out the break
elif t.startswith("last:"):
print "clicked href %s" % t[5:]
else:
print "clicked without href"
return "break"
Thanks again, I hope others will find this as useful as I did..
--
http://mail.python.org/mailman/listinfo/python-list
