Bruno Desthuilliers <[EMAIL PROTECTED]>
writes:
> Use dicts, not lists or tuples:
>
> a = dict(name='yadda', val=42)
> print a['name']
> print a['val']
I guess you will then need a list or tuple to store the dicts?
I might have made it with a list of class instances:
class a:
def __init__(s
greg <[EMAIL PROTECTED]> writes:
> Be careful with this. If you have two values that are
> very close together, but on different sides of a rounding
> boundary, they will end up as distinct keys even though
> they "should" be regarded as equal.
I don't think this is a big problem. It will only gi
Steve Holden <[EMAIL PROTECTED]> writes:
> Alex Martelli wrote:
[snip]
Thanks a lot for your intersting answers. I will start out taking a
look at bisect.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.python
Hi
I am making a script to optimiza by dynamic programming. I do not know
the vertices and nodes before the calculation, so I have decided to
store the nodes I have in play as keys in a dict.
However, the dict keys are then floats and I have to round the values
of new possible nodes in each step.
iwinux <[EMAIL PROTECTED]> writes:
> To build python with mingw, there is a common way.
> First you should install msys, which can be downloaded from mingw's website.
> Run msys and type 'cd /path/to/source'.
> Then type "./configure & make & make install".
> And you will get a python built with m
[EMAIL PROTECTED] writes:
> Is there any way to run python through emacs or xemacs without having
> it hang or is shell support broken?
Doing it from eshell gives the same problem :-(
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
Rugbyklubben Speed Scandinavi
"Nick Vatamaniuc" <[EMAIL PROTECTED]> writes:
> if l[-1].setdefault(a+c, x+e) l[-1][a+c]=x+e
Thanks for the answer. I will try it.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
Rugbyklubben Speed Scandinavian Open 7s Rugby http://www.rkspeed.dk
--
http:
"Justin Azoff" <[EMAIL PROTECTED]> writes:
> last[keytotal] = min(last.get(keytotal), valtotal)
> comes close to working - it would if you were doing max.
Thanks, I think this would help.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
Rugbyklubben Speed Scan
John Machin <[EMAIL PROTECTED]> writes:
> 2. Put spaces around operators -- in general, RTFStyleGuide
>http://www.python.org/dev/peps/pep-0008
I din't know it. Thanks.
> Only you know what *really* meaningful names you should be using.
I have better names in my running code.
> mykey = a +
Brian Elmegaard <[EMAIL PROTECTED]> writes:
At least it was clumsy to post a wrong example.
This shows what = find clumsy.
c=1
x=2
l=list()
l.append(dict())
l[0][5]=0
l.append(dict())
for a, e in l[-2].iteritems():
# Can this be written better?
if a+c in l[-1]:
if l
Hi
I have written the following which works, but I would like to write it
less clumsy. I have a dictionary in which I loop through the keys for
a dynamic programming algorithm. If a key is present I test if its
value is better than the current, if it is not present I just create
it. Would it be p
"sturlamolden" <[EMAIL PROTECTED]> writes:
> I believe MinGW can link .lib C libraries files from Visual Studio. But
> there are no .a for Python24.dll as far as I can tell.
But afaik you don't need one.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://ww
Neal Becker <[EMAIL PROTECTED]> writes:
> release. Since mingw is usually current, I haven't checked, but they may
> be using 4.1 now.
It is not, it is 3.4.2.
http://www.mingw.org/download.shtml#hdr2
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.
Robert Kern <[EMAIL PROTECTED]> writes:
> Martin v. Löwis wrote:
>> Robert Kern wrote:
>>
>>>Oh, that's right, you need an import library for Python24.dll .
>>
>> That shouldn't be a problem: that library is included with Python.
>
> For mingw, too? I.e. a .a not a .lib?
It is possible to load
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> a better optimizer usually results in programs that run faster, not slower.
Got it the wrong after some editing ;-(
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.py
Robert Kern <[EMAIL PROTECTED]> writes:
> If you meant writing extension modules for Python instead of extending
> distutils,
I thought about extending distutils to make non-python installers. I
may have misunderstood the answers I got.
http://groups.google.com/group/comp.lang.python/browse_thre
"Martin v. Löwis" <[EMAIL PROTECTED]> writes:
> It would certainly be possible to distribute a gcc-compiled python.
> However, what is the point in doing so? Cygwin already includes
> a gcc-compiled Python, for Windows:
Interesting.
> That is simply not true.
Actually, you answered me then too
Robert Kern <[EMAIL PROTECTED]> writes:
> the gcc project is to provide a portable compiler, not one that
> generates the best code for any given platform. And in that goal, it
> succeeds remarkably well.
Will a python program be slower on the same machine running windows
compared to linux?
What
Robert Kern <[EMAIL PROTECTED]> writes:
> - gcc does not optimize particularly well.
But well enough for other platforms.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence Oluyede <[EMAIL PROTECTED]> writes:
> (despite the ongoing Pypi project and Eby's efforts in setuptools)
> you have to do it manually :)
Great, there is progress in this.
> How many modules do you really use? It's a matter of minutes.
Yes, but 60 minutes make an hour. I installed 2.4
"BartlebyScrivener" <[EMAIL PROTECTED]> writes:
> Are you saying you're on Windows?
Yes
> http://www.activestate.com/Products/ActivePython/
> It's a one-click, msi install with everything you need for win32,
> including IDE etc.
I don't it includes every possible module, e.g., py2exe, ctypes,
m
Hi,
Every time I upgrade python I also have to download all packages and
reinstall them.
http://www.voidspace.org.uk/python/articles/upgrading_python.html
tells me that this is only a problem on windows for some reasons that
have to do with binary distributions, compiling and more.
This leads m
bruno at modulix <[EMAIL PROTECTED]> writes:
> I should just take some time and learn to read !-)
Then I am better of than you. I just had to learn the syntax of a
language :-)
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> With this method in the class, your solution is easier than ever:
Nice solution.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.python.org/mailman/listinfo/python-l
Michael <[EMAIL PROTECTED]> writes:
> Based on the code that runs, you want* this:
>
> [(y[x+1].x-y[x].x) for x in range(len(y)-1) ]
Yes.
> Since personally I find that a lot clearer than:
>
> map(float.__sub__, [X.x for X in y[1:]], [X.x for X in y[:-1] ])
Me too.
--
Brian (remove the sport
bruno at modulix <[EMAIL PROTECTED]> writes:
> May I suggest that you first learn the language syntax and basics ?-)
I'll try
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.python.org/mailman/listinfo/python-li
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> What you probably think you want is something like this:
Thanks, that made it run.
Now I need to study what classmethods are.
> I say "think you want" because I don't know what problem you are trying to
> solve with this messy, self-referential, piec
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Can you explain more carefully what you are trying to do? If you want the
> square of the maximum value, just do this:
I want to get the value of another attribute of the instance with
maximum x.
I know I could do it like you suggest for the case wi
James Stroud <[EMAIL PROTECTED]> writes:
> You should look into __cmp__ and other magic methods. This is probably
> the type of functionality you seem to be after.
Good example, I need to look at the magic methods.
What I want is to get the value of another variable in C. Would I need to
use __re
bruno at modulix <[EMAIL PROTECTED]> writes:
> So it's time to move to 2.4x !-)
I guess so.
> What is "going wrong" exactly ?
def _add_instance(cls, instance):
_add_instance=classmethod(_add_instance)
cls._instances.append(instance)
gives me:
d:/DTU/80494 $ python.exe ooo.py
Tr
bruno at modulix <[EMAIL PROTECTED]> writes:
> Now how you could do it the OO way (Q&D, not really tested):
Something goes wrong in my 2.3 when I change the syntax to
_add_instance=classmethod(_add_instance).
If I understand this correctly the class is keeping track of the
instances of itself. T
"Matt Hammond" <[EMAIL PROTECTED]> writes:
> y_max = max([e.x for e in y])
Would there be a way to refer back to the e with maximum x, or how
could I find other attributes of it?
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
"Matt Hammond" <[EMAIL PROTECTED]> writes:
> Hmmm, rereading, I think you're right ... and I think I'm confused too :-)
You both are.
> Attempt #2:
>
> yz = [ (y1.x - y2.x) for (y1,y2) in zip(y[:-1], y[1:]) ]
>
> Frankly, a for loop with an index would probably be easier to read :)
Me too,
Steven D'Aprano <[EMAIL PROTECTED]> writes:
Thanks for the answers. They are very useful.
> self.args = (x, y, z) # save a copy of the arguments
As always python makes it easy.
max(obj.lister())
> 4
Actually I wanted to get the maximum of attributes of several
instances. List com
"Matt Hammond" <[EMAIL PROTECTED]> writes:
> See "List comprehensions" in python docs:
Great, thanks for the hint.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I am struggling to understand how to really appreciate object
orientation. I guess these are FAQ's but I have not been able to find
the answers. Maybe my problem is that my style and understanding are
influenced by matlab and fortran.
I tried with the simple example below and ran into several
[EMAIL PROTECTED] writes:
> Others recommended wxPython, PyQt and various derivatives. The trouble
> is there's too much choice!
Agreed, I tried to find /the answer/ some time ago, and I got to the
same conclusion. In addition it is even more difficult to find the
advantages and disadvantages
"Matthias R." <[EMAIL PROTECTED]> writes:
> Unfortunately matplotlib is only a 2D-plotting library.
>
> Do you know another one with 3D-capabilities as well?
> That would be very nice,
You can quite easily write a function that produces metapost
code. Featpost is the best 3d-lib for that, afaik
Joseph Garvin <[EMAIL PROTECTED]> writes:
> I'm curious -- what is everyone's favorite trick from a non-python
> language?
Metapost solution of linear equations:
x1+9=x2-8=2;
> And -- why isn't it in Python?
I'd like to know too.
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu
[EMAIL PROTECTED] writes:
> http://kscraft.sourceforge.net/convert_xhtml.php?doc=pyqt-windows-install.xhtml
Which, afaics, unfortunately requires either that you have msvc or
that you compile python and every addon with mingw :-(
--
Brian (remove the sport for mail)
http://www.et.dtu.dk/staff/b
40 matches
Mail list logo