def get_value():
for i in range(10):
for j in range(10):
print i, j
if j == 6:
return fn(i, j)
I guess to an extent it would depend on the exact situation as to
which of these is more suitable. Are there any other recommended
solutions to this?
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
3k a) when frameworks/modules that
they use are available and b) if and when doing so would be
advantageous.
I suspect that many of the projects I have that are solid and are in
no imminent need of development will remain <3k for several years.
Cheers,
--
Ant
--
http://mail.python.org/mai
On Oct 22, 10:44 am, Paul Brauner <[EMAIL PROTECTED]> wrote:
> Hi, I'm working on a project that outputs several languages including
> (hopefully) python. My problem is that the generic backend architecture
> has not been designed to output correctly indented code, and that would
> be helpful if th
a = a+1
elif a < b:
b = b-1
if b > a: a = a-1
# end if
else:
print 'oops!'
# end if
# end def foobar
The help in the script looks pretty good.
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 22, 1:26 pm, Py-Fun <[EMAIL PROTECTED]> wrote:
> I'm stuck trying to write a function that generates a factorial of a
> number using iteration and not recursion. Any simple ideas would be
> appreciated.
The following simple adder functions should give you an idea of how
recursion can be re
ional tests etc. Take a
look at
http://antroy.blogspot.com/2007/04/swing-testing-with-jython-and-jemmy.html
for an example of how I have successfully used Jython for Swing
testing. More information can be found on
http://www.jython.org/Project/index.html
Cheers,
--
Ant.
--
http://mail.pyt
On Nov 1, 9:12 am, Anand <[EMAIL PROTECTED]> wrote:
...
> This code works for dictionaries of any nested level.
At least up to the max recursion depth.
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
parallel processing and mathematical processing that seems
faster in Jython. It's be interesting to see a proper comparison of
how different types of program run.
The VM startup overhead is much slower mind, but then that's only an
issue for very small programs.
Cheers,
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 1, 1:23 pm, Ant <[EMAIL PROTECTED]> wrote:
> On Nov 1, 11:37 am, Ze'ev <[EMAIL PROTECTED]> wrote:
> ...
>
> > ...> Jython is currently significantly slower than Python.
>
> > ...
> > Not according to this
> > :http://blogs.
around the component, which comes with some nice
features and syntax files for a number of languages.
If you are going to make use of python on the windows platform, I would
highly recommend the pywin32 extension.
Regards,
Ant
W. Watson wrote:
> I downloaded python-2.5.msi and installed it
On Feb 6, 12:21 am, greg <[EMAIL PROTECTED]> wrote:
...
> Yes, but with Python you wouldn't have to spend a
> couple of weeks sitting and thinking before starting
> to type that line...
This is a good point often overlooked. You often get these threads on
c.l.python about "How can I do this in one
e trying to do exactly here?
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 6, 9:59 am, Shriphani <[EMAIL PROTECTED]> wrote:
...
> My main intention is to state that each of the variables namely a, b,
> c, ## can take value from 1 to 9.
> How do I go about this ?
It sounds like you are after something like:
for var in (a, b, c, d, e, f):
assert var in [1, 2, 3,
ht that pygame would satisfy the
graphical side of things.
--
Ant
--
http://mail.python.org/mailman/listinfo/python-list
maSeparate = foldr(lambda x, y: "%s%s%s" % (x, "," if x else "",
y), "")
commaSeparate(myList)
Of course the lambda function in this case could be a named function,
helping with both readability and reuse, but I think the latter is
conceptually easier to grasp when reading the code.
Discuss.
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 22, 7:14 pm, oj <[EMAIL PROTECTED]> wrote:
> On Nov 22, 3:02 pm, Ant <[EMAIL PROTECTED]> wrote:
...
> It's basically just one line to implement:
>
> foldr = lambda f, i: lambda s: reduce(f, s, i)
>
> It's just reduce with currying, I'm not su
duce() is going away, not just
> from the built-ins but (I believe) from the standard library as well.
I thought that at the last count it was merely being moved out into
functools (or somewhere similar).
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 23, 9:31 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 23 Nov 2007 00:50:30 -0800, Ant wrote:
> > So my point really is that foldr (perhaps renamed to make_reducer or
> > something) could create idioms that are more readable than using
&g
On Nov 23, 4:09 am, "kyo guan" <[EMAIL PROTECTED]> wrote:
...
> >>> '120.exe'.rstrip('.exe')
Another approach since you seem to be working with filenames is using
the os.path module:
>>> import os.path as path
>>> s = "test.torrent"
>>> t = "test.exe"
>>> u = "test"
>>> path.splitext(s)[0]
'test'
, pythonw
runs the script as a background process. I'd imagine that it is the
same for the Mac, and I shouldn't think it has anything to do with
your problem here.
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 30, 9:10 am, SMALLp <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I'm new in wxPython and before i start doing anything I have one qustion.
>
> Shoul I use some of editors like boa, spe or shoud i use my favorite
> text editor!
>
> i used IDLE on windows and it seamd nice. Now i have linux install
Python on xkcd:
http://xkcd.com/353/
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
time insertion anywhere in the list.
>
> It's on the shelf between the jar of phlogiston and the perpetual
> motion machine.
lol!
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
(OT) I don't have the same issue with Syntax highlighting, and I use
jEdit as my main Python editor (Though some of the dedicated Python
IDE's have some nice refactoring/code completion stuff, none has the
raw editing power of jEdit).
I'm using jEdit 4.3 pre3 - though I don't recall any problems w
If you just want the items concatenated with a comma separator, the
following is what you need:
>>> list_arr = ["one", "two", "three"]
>>> list = ",".join(list_arr)
>>> print(list)
one,two,three
--
http://mail.python.org/mailman/listinfo/python-list
Why does the function have to be unnamed? you can easly nest function
definitions and refer to them. IIRC the lambda form is probably going
to be removed at some point, as it is not needed:
def outerfn():
dostuff()
def inner(x,y):
out = (x^y)
print out
return out
No, I remembered correctly:
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
but probably not until Python 3.0.
--
http://mail.python.org/mailman/listinfo/python-list
Fair enough. I've just found this as well, which implies that lambda
isn't being killed off in 3.0:
http://www.python.org/dev/peps/pep-3100/
In particular:
"Lambdas will have to be parenthesized [23]"
--
http://mail.python.org/mailman/listinfo/python-list
Python ruined my life.
I am a Java programmer by profession, and ever since learning Python, I
find it a real chore to open Eclipse and write Java code (or worse -
the XML config files that seem to glue J2EE together). And while I
spend some of my spare time liberated by Python, I spend 10 times a
Sorry dude, but it looks like a hairdryer! Imagine it at 16x16 pixels
or smaller, and it'll look like little more than a circle with two
sticks. The current image scales well.
I think that the current logo is fine. Much more professional than the
old image. The + formation is positive enough, and
> So switch jobs -- it's a good time.
If it were that easy I would.. However, I have family commitments
keeping me in Yorkshire (UK) (as well as the fact that I really like
the area!), and the jobs in the area are all Java, .NET (predominantly
C#) and C++.
Always on the lookout for Python work th
Take a look at the newgroup archives over the last week or two - there
seem to have been a glut of people coming from Java to Python and
asking the same sort of questions. There were some links to a bunch of
Python 'gotcha' pages which will be useful.
For my part, I came from Java to Python, and f
Did you not read the first post?
> All the nice methods would be appreciated (getLeaves, isLeaf, isRoot,
> depthfirst, breadthfirst,...)
--
http://mail.python.org/mailman/listinfo/python-list
I was looking for a tree implementation a while back, but got no real
pointers. Seems that there are no tree data model modules out there -
which surprises me, since it is such a fundamental data structure.
I ended up using a very basic tree data class - I didn't need all of
the methods you mentio
Damn! Missed the boat ;-)
--
http://mail.python.org/mailman/listinfo/python-list
I don't think he was explicitly wanting to initialize things to zero,
but rather unpack an arbitrary sequence into a tuple (could perhaps be
the fibonnacci sequence for example).
How about:
>>> def zeros(count):
... for i in range(count):
... yield 0
...
>>> a,b,c = zeros(3)
>>> a
0
>
A script I use for comparing files by MD5 sum uses the following
function, which you may find helps:
def getSum(self):
md5Sum = md5.new()
f = open(self.filename, 'rb')
for line in f:
md5Sum.update(line)
f.close()
return md5Sum
Considering that the current:
import pprint
pprint.pprint(x)
is hardly lengthy, I can't see how either of the alternatives proposed
are any better.
> python.pprint.pprint(x)
6 characters shorter, but considerably more keystrokes if you are using
pprint more than once. Is it worth adding the 'py
I think Duncan has hit the nail on the head here really. I totally
agree that conceptually using tabs for indentation is better than using
spaces. Pragmatically though, you can't tell in an editor where spaces
are used and where tabs are used.
Perhaps if editors colored the background of tab chara
> Ant wrote:
> > spaces. Pragmatically though, you can't tell in an editor where spaces
> > are used and where tabs are used.
> Um, I don't follow this. If you can't tell the editor where
> tabs/spaces are used, who does?
Re-read my post. Note the key word &
> Not that it's relevant, but I've never actually encountered anyone who
> mixed tabs and spaces.. I've lived a sheltered life I guess.
It's not individuals using a mixture, but when working in a development
team of some kind. Consider person A who writes a file using spaces for
indent. Person B t
> > I don't know whether python can warn me through beeping like C
> > program(e.g.:printf("%c", '\07');)
>
> This is information that is easily lost; what if no-one is in hearing
> range when the beep occurs?
Indeed, *does* it still beep if there is no-one around to hear it?
--
http://mail.pyth
o
his ISP. Given that it has gone this far, wouldn't it be fair to give
the guy a break on the condition that if he wants to post to a variety
of newgroups, that he does it individually rather than as a cross post?
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
> Surely Voltaire didn't support speaking in inappropriate fora?
Who knows? But the fora Xah posts to are few (5 or so?) and
appropriate. "Software needs Philosophers" wasn't even his rant, but
was certainly appropriate to all groups he posted to.
If you don't like Xah's posts, then don't read th
John Bokma wrote:
> That's because you're clueless.
Well argued. No really. Not quite sure what you base the allegations on
of course.
John, you're well out of order getting this guy into problems with his
ISP. Ken Tilton has it spot on - if everyone who wasn't interested in
what he had to say ig
Getting eloquent isn't he? ;-)
--
http://mail.python.org/mailman/listinfo/python-list
It really depends on how you are trying to pass the dictionary across
to Java, what sort of objects are in the dictionary etc. Could you
provide some more background?
BTW the Java implementation of Python is now called Jython (and has
been for some years!).
--
http://mail.python.org/mailman/list
This will work fine in simple cases and if the dictionaries are passed
around in repr() form.
If they are being passed pickled in some way, or the values in the
dictionary are anything other than strings, lists, dictionaries or
combinations of these then you will need something like Jython.
--
h
e out there for extracting files from an ISO?
2) Is there a module out there for extracting icons from a Windows
exe?
Cheers,
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 2, 7:07 pm, Rob Williscroft <[EMAIL PROTECTED]> wrote:
> Ant wrote in news:34a84caa-5387-40a2-a808-
> > 1) Is there a module out there for extracting files from an ISO?
>
> There are command line programs that can do this:
>
> http://cdrecord.berlios.de/old/priv
Hi all,
The Jython team got an honourable mention on the Headius blog this
morning. Apparently they have got Django working with the latest
builds of Jython: http://headius.blogspot.com/2008/01/jythons-back-baby.html
So congratulations!
--
Ant.
--
http://mail.python.org/mailman/listinfo/python
are doing. Of course this could also be achieved by
doing pairs.sort() and pairs.reverse() before iterating over the pairs
list.
Cheers,
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
a troll - so many people who would actually be
able to assist you (such as the PIL, pygame and numpy/scipy
communities) may have ignored this thread.
Cheers,
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
In the spirit of "Simple is better than complex." and totally
bypassing the intention of quines (though not necessarily the
definition):
--- probably_not_a_real_quine.py
import sys
for line in open(sys.argv[0]):
print line,
--
;-)
--
Ant
he possibility of more Python jobs
out there for us all in the future given the ubiquity of the JVM in
the enterprise and willingness of corporations to accept such
endorsements!
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
A 0-width positive lookahead is probably what you want here:
>>> s = """
... hdhd http://mysite.com/blah.html";>Test String OK
...
... """
>>> p = r'href="(http://mysite.com/[^"]+)">(.*)(?=)'
>>> m = re.search(p, s)
>>> m.group(1)
'http://mysite.com/blah.html'
>>> m.group(2)
'Test String OK'
The
On Nov 29, 8:44 pm, Josh <[EMAIL PROTECTED]> wrote:
> If you were a beginning programmer and willing to make an investment in
> steep learning curve for best returns down the road, which would you pick?
Personally I'd choose Vim for the following reasons:
1) Vim is ubiquitous on Linux/Unix server
On Jan 5, 9:47 am, "Jack.Chu" wrote:
> Hello guys:
> I created a simple tool to count how I wasted my time day by day
> ;-)http://www.flickr.com/photos/34017...@n07/3169438647/sizes/o/
Looks interesting - did you have some sort of time machine to be
spending that much time in Chrome at the end o
You could look at something like the following to turn the class
iteslf into a decorator (changed lines *-ed):
> class TaggedWrapper():
>
* def __init__(self, logMixin, stream):
> self.__tag = '%...@%s' % (logMixin.describe(), stream)
> logMixin._debug('Created %s' % self)
>
>
On Jan 8, 9:06 pm, "Tim Arnold" wrote:
> Is there any lib or recipe(s) for doing something like this via python?
Look into the PyWin32 extension module. It gives access to Windows
internals including the COM interface. You'll need to do some research
into how to automate the GUI you're using from
On Oct 22, 10:03 am, "wooly booly" <[EMAIL PROTECTED]> wrote:
> I would like to execute a Python script from Windows command line:
>
> Python myscript.py
>
> This works if myscript.py resides in the current folder. My question is:
> Is it possible to execute the command above from another folder?
>
On Jan 15, 6:43 am, "James Mills"
wrote:
...
> That is a good idea :) Windows teaches you nothing!
Not true. Windows teaches you the art of the workaround...
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 24, 7:59 am, Sreejith K wrote:
...
> data is the whole file, but 'less' gives only the two lines...
>From this statement (that you are using less), it appears that you are
redirecting sys.stdout to a file or similar - if that is the case, you
may need to flush or close the output file befo
a little 1 man company called Zabkat.
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
not "C:\Python 2.6". I'd
be carefull of changing the default install directory of Python,
particularly if you are "non-techy" as some packages installers may
look for Python in the default location.
--
Ant
--
http://mail.python.org/mailman/listinfo/python-list
so points can be easily
correlated, but overlayed so that each line has a different scale on
the y-axis. The closest I can get is to have two subplots, one above
the other.
Thanks in advance,
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
On May 14, 3:52 pm, Hyuga wrote:
...
> On the other hand, I just took a peek at the matplotlib example
> gallery, which is very diverse, and it has an example that I think is
> exactly what you're looking
> for:http://matplotlib.sourceforge.net/examples/api/two_scales.html
Superb - spot on. Than
On May 20, 6:46 pm, namekuseijin wrote:
> anyway, again, thanks for the laughs.
I'm a Java developer in my day job, and I use Jython for testing out
ideas and prototyping, due to the way Jython makes writing Java so
much easier... Those examples were spot on - things weren't much
simpler before g
On May 25, 6:35 pm, LittleGrasshopper wrote:
> With so many choices, I was wondering what editor is the one you
> prefer when coding Python, and why. I normally use vi, and just got
I use GVim or vim if on a terminal. There are quite a few plugins and
scripts I find invaluable, but most are not p
;parser.py", line 50, in ?
print comb.parseString(text + text2)
.
. [Stacktrace snipped]
.
raise exc
pyparsing.ParseException: Expected start of line (at char 81), (line:9,
col:1)
Any help appreciated!
Cheers,
--
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
will provide a base for extending the list format.
Thanks,
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
some respect for majority's rules.
> This is childish.
Do some research before flaming on a subject on which you only have
one side of the story.
--
Ant
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 31, 5:40 pm, Rui Maciel <[EMAIL PROTECTED]> wrote:
...
> So far the decision seems to be a no brainer. Yet, Python 3000 will arrive
> in a few months. As it isn't backwards compatible with today's Python,
> there is the risk that no matter what I learn until then, I will end up
> having to r
On Apr 3, 12:37 pm, [EMAIL PROTECTED] wrote:
> What's the neatest and/or most efficient way of testing if one of a
A different approach:
>>> words = ["he", "sh", "bla"]
>>> name = "blah"
>>> True in (word in name for word in words)
True
>>> name = "bling"
>>> True in (word in name for word in wo
On Apr 3, 2:27 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
...
> It's even prettier in 2.5:
>
> any(word in name for word in words)
>
> George
And arguably the most readable yet!
--
http://mail.python.org/mailman/listinfo/python-list
Today's XKCD comic has a nice Python reference!
http://xkcd.com/413/
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 21, 12:23 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> http://xkcd.com/413/
>
> :)
Didn't realise you'd posted this when I posted my "Batteries
Included..." post. Amused me as well!
--
http://mail.python.org/mailman/listinfo/python-list
Does anyone
know if this is a known issue with screen/Python, or if there is a
workaround, as I'd prefer to have just a single Python instance
installed rather than having Cygwin python and windows Python both
installed.
Cheers,
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
CT, you will have to use Cygwin Python with screen.
Thanks for the info. Shame but - cygwin python for this setup it is
(Though I may hunt for a native windows port of screen rather than the
cygwin one.)
Cheers,
Ant.
--
http://mail.python.org/mailman/listinfo/python-list
I like it personally. Nice clean look and feel, and the logo is much
better than the old cheesy green python. Has a more professional feel
to it, which can be important if you want to use the language outside
of your free time...
--
http://mail.python.org/mailman/listinfo/python-list
e've got.
2) Some people on this newsgroup need to clean their fridges out more
often!
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
Are there any tree or graph modules available for python?
Cheers,
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
Thanks guys. The networkx and igraph packages look to have the sort of
features I want. I'm surprised there's nothing in the standard module
library really.
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
Look at the os module: http://docs.python.org/lib/os-file-dir.html
This has various functions you may find useful depending on how you
want to go about it, such as chmod and chown.
Cheers,
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
Looks like some good new stuff coming along. Does anyone know what's
happened to the path PEP (http://www.python.org/doc/peps/pep-0355/) - I
thought I'd seen somewhere that that was originally planned for 2.5...
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
It's easier than that in this case. Just unpack the icons in yout
Python directory over the top of the existing ones. The change should
get picked up the next time you log on.
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
decide
what "for all x" should mean. We may just as well decide that for
convenience: math.pi == 3.
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
f.
None of the pure python IDE's/editors out there come close to the likes
of jEdit, vim or emacs in terms of pure editing power.
--
Ant...
--
http://mail.python.org/mailman/listinfo/python-list
lol!
--
http://mail.python.org/mailman/listinfo/python-list
I've used Beautiful Soup, and it is a very pythonic way of accessing
the data in the HTML. It is actually very similar to the way you access
the DOM with JS - for example soup.html.body.h1 will give you the first
h1 tag.
There are also various other ways of searching the HTML in XPathish
ways (if
There are various ways you could do this:
If the number of results won't be too big:
...
for result in sth.fetchall():
print result
If it may be very large:
...
result = sth.fetchone()
while result:
print result
result = sth.fetchone()
Or perhaps nicer:
...
def result_iterator(res
Forget the last suggestion - I wasn't concentrating :-)
--
http://mail.python.org/mailman/listinfo/python-list
You are along the right lines. Try printing out the content of each URL
- one of the pages will match your expression, but has additional
instructions... I think you are reaching the end of their false trail
when you get None returned from the url.
The set of pages themselves are the linked list -
It's not just a Python thing, Java for example generally uses the
idiom:
for (Iterator it = list.iterator(); it.hasNext(); ) {
Object next = it.next();
//Do stuff to next
}
Horrible compared to the python idiom of course (though the latest
version supports for (x : list){})
Ruby has some
I assume that you are trying to pass data from one 'standalone' cgi
script to another cgi script (mail.py). Depending on what exactly you
are trying to do, you could either set the information in a cookie, or
simply have a hidden input () element in the HTML which gets populated by the initial
cgi
I get the strong feeling that nobody is really happy with the state of
Python GUIs.
Tkinter is not widely liked, but is widely distributed. WxPython and
PyGtk are both
powerful, but quirky in different ways. PyQt is tied to one platform.
And there are
dozens more.
Whether or not we like graphics p
On Jun 6, 2:22 pm, ant wrote:
> I get the strong feeling that nobody is really happy with the state of
> Python GUIs.
What an interesting set of responses I got!
And - even more interesting - how few of them actually seem to think
there is a problem, let
alone make any attempt to mo
I rather feel like I'm flogging a dead horse here, but time for
another mile...
First off, I'm not volunteering to lead this effort. I don't think
anyone should
even think about that until and unless the Python Powers That Be
actually
decide that it is worth doing. That is what I meant by 'strong
Since I started this thread, I feel a sense of responsibility for it,
in some bizarre way.
Not to prolong its existence, which is clearly a troubling one for
some, but to try to steer it towards some kind of consensus that will
irritate the least number of people. Or better, that will gain some
kin
I don't know whether this thread is going backwards, forwards or
sideways. But a lot of useful information is creeping out of the
woodwork.
I like the points about backwards compatibility. Presumably that
reason alone is enough to keep Tkinter in the standard library for a
long while.
But the poin
201 - 300 of 302 matches
Mail list logo