Re: universal unicode font for reportlab

2008-09-11 Thread Duncan Booth
Duncan Booth [EMAIL PROTECTED] wrote: I may have made some blindingly obvious beginners mistake I made the blindingly stupid beginners mistake of cleaning up the code before posting it and breaking it in the process. The 'if' should of course say: if len(sys.argv) 1: However my original

Re: universal unicode font for reportlab

2008-09-10 Thread Duncan Booth
as though it just embeds the entire font. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: format string to certain line width

2008-08-13 Thread Duncan Booth
this may not do what you wanted. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: decorating base methods

2008-08-13 Thread Duncan Booth
) Is this correct approach? How can avoid call to Base.A(...)? Decorators are just syntactic sugar for calling a function, so for this situation you probably want to ignore the sugar and use the decorator directly: class Derived(Base): A = decorator(Base.A) -- Duncan Booth http

Re: File reading across network (windows)

2008-08-12 Thread Duncan Booth
else: raise RuntimeError(We connected without doing the net use!) NetUseAdd(None, sharename, password, username=username) with open(os.path.join(sharename, default.tag), r) as f: print f.read() NetUseDel(sharename) --- -- Duncan Booth http

Re: dict.update() useful or not?

2008-08-11 Thread Duncan Booth
Steven D'Aprano [EMAIL PROTECTED] wrote: dict1.update(dict2) is of course equivalent to this code: for key, value in dict2.iteritems(): dict1[key] = value Note that it replaces values in dict1 with the value taken from dict2. I don't know about other people, but I more often want to

Re: Missing exceptions in PEP 3107

2008-08-10 Thread Duncan Booth
Christoph Zwerschke [EMAIL PROTECTED] wrote: That would be possible. But I still think it makes sense to separate them, like so: def foo(a: a info, b: b info) - ret info raise exc info: return hello world And then the annotation dictionary would contain another key raise

Re: Missing exceptions in PEP 3107

2008-08-10 Thread Duncan Booth
Christoph Zwerschke [EMAIL PROTECTED] wrote: But maybe the PEP should then at least mention what's the currently recommended way to make annotations about thrown exceptions. There is no currently recommended way to make such annotations, so how could the PEP mention it? I think the problem

Re: Best practise implementation for equal by value objects

2008-08-07 Thread Duncan Booth
easily fail: lst = [1, 2, 3] lst[1] = lst eval(repr(lst)) Traceback (most recent call last): File pyshell#6, line 1, in module eval(repr(lst)) File string, line 1 [1, [...], 3] ^ SyntaxError: invalid syntax -- Duncan Booth http://kupuguy.blogspot.com -- http

Re: URLs and ampersands

2008-08-06 Thread Duncan Booth
) if code in name2codepoint: return unichr(name2codepoint[code]) return match.group(0) if isinstance(s, str): s = s.decode(encoding) return EntityPattern.sub(unescape, s) -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org

Re: URLs and ampersands

2008-08-05 Thread Duncan Booth
this for you. What parser are you using? -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I check nbr of cores of computer?

2008-07-31 Thread Duncan Booth
or Mac, I have no idea. One way on windows: import win32pdhutil def howmanycores(): for i in range(): try: win32pdhutil.GetPerformanceAttributes(Processor(%d) % i,% Processor Time) except: break return i print howmanycores() 2 -- Duncan Booth http

Re: interpreter vs. compiled

2008-07-31 Thread Duncan Booth
MIPS Linux HPPA Linux (from http://www.mono-project.com/Supported_Platforms) So I'd say .Net scores pretty highly on the portability stakes. (Although of course code written for .Net might not do so well). -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo

Re: block/lambda

2008-07-29 Thread Duncan Booth
thing. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Module clarification

2008-07-28 Thread Duncan Booth
topics are covered. The tutorial explains both modules and packages: http://docs.python.org/tut/node8.html What it doesn't cover is that you can import modules or packages directly from a zip file. Then read about eggs. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org

RE: __del__ methods

2008-07-19 Thread Duncan Booth
Robert Rawlins [EMAIL PROTECTED] wrote: I've just recently (in the past week) started using the __del__ method to log class instance destruction so I can keep a track of when objects are created and destroyed, in order to help me trace and fix memory leaks. That sounds like an appropriate

RE: __del__ methods

2008-07-19 Thread Duncan Booth
Robert Rawlins [EMAIL PROTECTED] wrote: I like this idea, I can definitely see the benefits to working with this concept. One things I will take this quick opportunity to ask, even though it's a little OT: What is the benefit of extending the base 'object' class? What does that give me that

Re: Change PC to Win or Windows

2008-07-19 Thread Duncan Booth
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 19 Jul 2008 11:02:51 -0500, Grant Edwards wrote: On 2008-07-19, Dennis Lee Bieber [EMAIL PROTECTED] wrote: Which term applied to the TRS-80, the Apple II, Altair even... Not that I remember. I had a homebrew S-100 bus system,

Re: create instance attributes for every method argument

2008-07-19 Thread Duncan Booth
Berco Beute [EMAIL PROTECTED] wrote: I remember reading somewhere how to create an instance attribute for every method argument, but although Google is my friend, I can't seem to find it. This could likely be done way more elegant: = class Test(object): def

Re: properly delete item during for item in...

2008-07-17 Thread Duncan Booth
mk [EMAIL PROTECTED] wrote: Iterating over a copy may _probably_ work: t=['a', 'c', 'b', 'd'] for el in t[:]: del t[t.index(el)] t [] However, is it really safe? Defining safe as works reliably in every corner case for every indexable data type? No, because you

Re: decorating a method in multiple child classes

2008-07-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: I wish to decorate all of the CX.func() in the same way. One way to do this is to add a decorator to each of the derived classes. But this is tedious and involves modifying multiple files. Is there a way to modify the parent class and have the same effect? Or

Re: x, = y (???)

2008-07-17 Thread Duncan Booth
kj [EMAIL PROTECTED] wrote: I still don't get it. If we write y = 'Y' x, = y what's the difference now between x and y? And if there's no difference, what's the point of performing such unpacking? None whatsoever when the string has only one character, but with 2 characters it

Re: heapq question

2008-07-13 Thread Duncan Booth
Giampaolo Rodola' [EMAIL PROTECTED] wrote: Having said that I'd like to understand if there are cases where deleting or moving an element of the heap, causes heappop() to return an element which is not the smallest one. Yes, of course there are: any time you delete element 0 of the heap you

Re: heapq question

2008-07-13 Thread Duncan Booth
Giampaolo Rodola' [EMAIL PROTECTED] wrote: Thanks, that's what I wanted to know. I understand that heapq is not that efficient to implement timeouts as I thought at first. It would have been perfect if there were functions to remove arbitrary elements withouth needing to re-heapify() the

Re: strip() using strings instead of chars

2008-07-12 Thread Duncan Booth
Christoph Zwerschke [EMAIL PROTECTED] wrote: Duncan Booth schrieb: if url.startswith('http://'): url = url[7:] If I came across this code I'd want to know why they weren't using urlparse.urlsplit()... Right, such code can have a smell since in the case of urls, file names

Re: why is self used in OO-Python?

2008-07-12 Thread Duncan Booth
ssecorp [EMAIL PROTECTED] wrote: 1. Why do I have to pass self into every method in a class? Since I am always doing why cant this be automated or abstracted away? Are the instances where I won't pass self? I imagine there is some tradeoff involved otherwise it would have been done away

Re: heapq question

2008-07-12 Thread Duncan Booth
Giampaolo Rodola' [EMAIL PROTECTED] wrote: My question is the following: is it safe to avoid to re-heapify() a heap when I remove or move an element which is not the first one? Example: from heapq import * heap = [2,4,6,7,1,2,3] heapify(heap) del heap[4] # Am I forced to heapify() the

Re: strip() using strings instead of chars

2008-07-11 Thread Duncan Booth
Christoph Zwerschke [EMAIL PROTECTED] wrote: In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url[7:] If I came across this code I'd want to know why they weren't using

Re: formatting list - comma separated (slightly different)

2008-07-09 Thread Duncan Booth
Michiel Overtoom [EMAIL PROTECTED] wrote: I occasionally have a need for printing lists of items too, but in the form: Butter, Cheese, Nuts and Bolts. The last separator is the word 'and' instead of the comma. The clearest I could come up with in Python is below. I wonder if there is a more

Re: Unnormalizing normalized path in Windows

2008-06-29 Thread Duncan Booth
Julien [EMAIL PROTECTED] wrote: In Windows, when a path has been normalized with os.path.normpath, you get something like this: C:/temp/my_dir/bla.txt # With forward slashes instead or backward slashes. Is it possible to revert that? magic_function('C:/temp/my_dir/bla.txt')

Re: I Need A Placeholder

2008-06-26 Thread Duncan Booth
Ampedesign [EMAIL PROTECTED] wrote: I'm trying to build a try/except case, and I want to have the except function like such: try: # Do some code here var = 1 # For example except: #Do nothing here The only problem is if I leave a comment only in the except

Re: url.encore/quote

2008-06-26 Thread Duncan Booth
zowtar [EMAIL PROTECTED] wrote: urlencode({'page': i, 'order': 'desc', 'style': 'flex power'}) return: page=1order=descstyle=flex+power but I want: page=1order=descstyle=flex%20power and url.quote don't put the 's and ='s any idea guys? Why does it matter to you? The + means exactly

Re: Functions that raise exceptions.

2008-06-25 Thread Duncan Booth
Alex G [EMAIL PROTECTED] wrote: Does anyone know how I would go about conditionally raising an exception in a decorator (or any returned function for that matter)? For example: def decorator(arg): def raise_exception(fn): raise Exception return raise_exception class

Re: Functions that raise exceptions.

2008-06-25 Thread Duncan Booth
Alex G [EMAIL PROTECTED] wrote: class classA(object): @decorator('argument') def some_method(self): print An exception should be raised when I'm called, but not when I'm defined Will result in an exception on definition. Well, yes it would. That's because what you defined

Re: Ruby doctest

2008-06-23 Thread Duncan Booth
allowing debugging in context. http://github.com/tablatom/rubydoctest/wikis/special-directives Whereas Python has the more wordy version which works anywhere in ordinary code or in doctests: import pdb; pdb.set_trace() -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org

Re: -1/2

2008-06-23 Thread Duncan Booth
-0.5 C:\python25\python -Qwarn -c print -1/2 -c:1: DeprecationWarning: classic int division -1 -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: advanced listcomprehenions?

2008-06-20 Thread Duncan Booth
with that really neat pow() call. If runtime came into it then one of the previous solutions or (as Mark already said) a straightforward sometable[i% 15] is going beat something like this hands-down. This is coding for fun not profit. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org

Re: Regular expression

2008-06-20 Thread Duncan Booth
used utf-8, so string.decode('utf-8') should give you a unicode string to work with. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Python class questions

2008-06-20 Thread Duncan Booth
). If you wish to do something special when an import fails then you simply put try:..except: around the import at the top level in a module and handle it there: you don't need to put either the import or the handler inside a function. -- Duncan Booth http://kupuguy.blogspot.com -- http

Re: python string comparison oddity

2008-06-19 Thread Duncan Booth
into a script rather than running it interactively (the string '--' will be re- used within a single compilation unit). So even if you understand all of the choices made in your particular release of Python (and they do vary between releases) it would be very unwise to rely on this behaviour. -- Duncan

Re: advanced listcomprehenions?

2008-06-19 Thread Duncan Booth
have 4 elements: [[str(i), 'FizzBuzz', 'Fizz', 'Buzz'][25/(pow(i, 4, 15) + 1)%4] for i in xrange(1, 101)] I feel it is even more elegant with the lookup table in its natural order: [['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i in xrange(1, 101)] :) -- Duncan Booth

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-19 Thread Duncan Booth
): keys = range(N) m1 = memory() print m1 d = {} for i in keys: d[i] = None m2 = memory() print m2 print float((m2 - m1) * 1024) / N main(2000) -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Interpreting string containing \u000a

2008-06-18 Thread Duncan Booth
\u000d\u000aWorld print s Hello\u000d\u000aWorld s.decode('iso-8859-1').decode('unicode-escape') u'Hello\r\nWorld' -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing module PIL vs beautifulSoup.

2008-06-18 Thread Duncan Booth
[EMAIL PROTECTED] wrote: I downloaded BeautifulSoup.py from http://www.crummy.com/software/BeautifulSoup/ and being a n00bie, I just placed it in my Windows c:\python25\lib\ file. When I type import beautifulsoup from the interactive prompt it works like a charm. This seemed too easy in

Re: Does '!=' equivelent to 'is not'

2008-06-17 Thread Duncan Booth
Leo Jay [EMAIL PROTECTED] wrote: same objects are equal, but equal don't have to be the same object. same objects are often equal, but not always: inf = 2e200*2e200 ind = inf/inf ind==ind False ind is ind True -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Duncan Booth
' type.__class__ type 'type' Old style classes don't have a class attribute, but you shouldn't be using old style classes anyway and so long as you use type(x) to access its class rather than accessing the __class__ attribute directly that doesn't particularly matter. -- Duncan Booth http

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Duncan Booth
cannot subclass 'object'. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: get keys with the same values

2008-06-12 Thread Duncan Booth
): print k, list(v) 1 ['a', 'e'] 2 ['c'] 3 ['b', 'd'] 4 ['f'] or if you want a dictionary: dict((k,list(v)) for (k,v) in itertools.groupby(sorted(d, key=get), key=get)) {1: ['a', 'e'], 2: ['c'], 3: ['b', 'd'], 4: ['f']} -- Duncan Booth http://kupuguy.blogspot.com -- http

Re: re quiz

2008-06-12 Thread Duncan Booth
the \\ will prevent any of them being interpreted as special so if you aren't wanting to substitute any groups into the string just try repl.replace('\\', r'\\') -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: using re module to find but not alone ... is this a BUG in re?

2008-06-12 Thread Duncan Booth
all and then fix up the result: text = r'frob this avoid this \, OK?' text.replace('', r'\').replace(r'\\', r'\') 'frob this \\ avoid this \\, OK?' -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How to view how much memory some process use in Windows?

2008-06-11 Thread Duncan Booth
this in linux or how to reduce Python programs memory usage. Perhaps http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303339 -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: basic code of what I am doing

2008-06-11 Thread Duncan Booth
Alexnb [EMAIL PROTECTED] wrote: path = self.e.get() path = \ + path + \ os.startfile(path) Why are you adding spurious quote marks round the filename? os.startfile() will strip them off, but you don't need them. The help for os.startfile() does say though that the

Re: Python doesn't understand %userprofile%

2008-06-10 Thread Duncan Booth
[EMAIL PROTECTED] wrote: In xp when I try os.path.getmtime(%userprofile/dir/file%) Python bites back with cannot find the path specified Since my script has to run on machines where the username is unspecified I need a fix. Thanks in advance. os.path.expanduser(~/dir/file) 'C:\\Documents

Re: Parsing a path to components

2008-06-09 Thread Duncan Booth
') ['', 'frodo', 'foo', 'bar'] With your code you just get two empty strings as the leadin: normpath(abspath(r'\\frodo\foo\bar')).split(os.sep) ['', '', 'frodo', 'foo', 'bar'] -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Can this be done with list comprehension?

2008-06-08 Thread Duncan Booth
Lie [EMAIL PROTECTED] wrote: On Jun 8, 7:27 am, Terry Reedy [EMAIL PROTECTED] wrote: Karlo Lozovina [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | I figured that out few minutes ago, such a newbie mistake :). The | fix I came up with is: | |  result = ['something'] +

Re: Code correctness, and testing strategies

2008-06-03 Thread Duncan Booth
the design of the code. I felt the room go cold: they said the customer has to sign off the design before we start coding, and once they've signed it off we can't change anything. I wish I'd had your words then. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman

Re: php vs python

2008-06-02 Thread Duncan Booth
Arnaud Delobelle [EMAIL PROTECTED] wrote: I find that eloquent Python speakers often tend to write a for loop when mere good ones will try to stick a list comprehension in! +1 QOTW -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Duncan Booth
for 'hiding' then just use two leading underscores. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Shed my a light :)

2008-06-02 Thread Duncan Booth
general case, you could just use the functions/methods directly instead of using their names: actions = (cp.Print, cp.sum, cp.divide, cp.myfunction) for nn in actions: nn(parameters) -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-30 Thread Duncan Booth
understand your problem: it's just a single thread so killfile or skip it. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: convert string containing list to list (or tuple) type

2008-05-30 Thread Duncan Booth
Poppy [EMAIL PROTECTED] wrote: a = ',P,' b = ',I,G,AQ,ET,K,BF,' c = ',DZ,' for ea in (a,b,c): print lst_codes(ea.strip(,)) Why not just use: ea.strip(',').split(',') ? -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-29 Thread Duncan Booth
to get caught by some other handler that was installed just because someone was too lazy to write a set statement followed by a writeline. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-29 Thread Duncan Booth
Dan Upton [EMAIL PROTECTED] wrote: On Thu, May 29, 2008 at 3:36 AM, Duncan Booth [EMAIL PROTECTED] wrote: Dave Parker [EMAIL PROTECTED] wrote: Catch doesn't return just error types or numbers, it can return any object returned by the statements that are being caught; catch doesn't care what

Re: Python and Flaming Thunder

2008-05-28 Thread Duncan Booth
. That means a bare except in Python no longer catches either of those: if you want to handle either of these exceptions you have to be explicit about it. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Showing the method's class in expection's traceback

2008-05-25 Thread Duncan Booth
Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 22 May 2008 07:55:44 -0300, Duncan Booth [EMAIL PROTECTED] escribió: Bruno Desthuilliers [EMAIL PROTECTED] wrote: Not to say that your concerns are pointless, and that things cannot be improved somehow, but this is not that trivial

Re: Why does python not have a mechanism for data hiding?

2008-05-25 Thread Duncan Booth
[EMAIL PROTECTED] wrote: Ben Finney: In Python, the philosophy we're all consenting adults here applies. Michael Foord: They will use whatever they find, whether it is the best way to achieve a goal or not. Once they start using it they will expect us to maintain it - and us telling them

Re: Code correctness, and testing strategies

2008-05-24 Thread Duncan Booth
David [EMAIL PROTECTED] wrote: Problem 2: Slows down prototyping In order to get a new system working, it's nice to be able to throw together a set of modules quickly, and if that doesn't work, scrap it and try something else. There's a rule (forget where) that your first system will

Re: Code correctness, and testing strategies

2008-05-24 Thread Duncan Booth
David [EMAIL PROTECTED] wrote: So, at what point do you start writing unit tests? Do you decide: Version 1 I am going to definitely throw away and not put it into production, but version 2 will definitely go into production, so I will start it with TDD?. If you are going to prototype

Re: Python and Flaming Thunder

2008-05-23 Thread Duncan Booth
, rationals, intervals and strings (and real numbers if you pay real money for them). Maybe I'm missing something though, because I don't see how you can do anything useful with out at least some sort of arrays (unless you are supposed to store numbers in long strings). -- Duncan Booth http

Re: php vs python

2008-05-23 Thread Duncan Booth
-php.html -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: php vs python

2008-05-23 Thread Duncan Booth
Michael Fesser [EMAIL PROTECTED] wrote: .oO(Duncan Booth) On those rare occasions when I've helped someone who wanted advice I've found that my Python oriented viewpoint can be quite hard to translate to PHP. For example I'd suggest 'oh you just encode that as utf8' only to be told

Re: Returning to 'try' block after catching an exception

2008-05-22 Thread Duncan Booth
bukzor [EMAIL PROTECTED] wrote: On May 21, 4:33 pm, Karlo Lozovina [EMAIL PROTECTED] wrote: André [EMAIL PROTECTED] wrote innews:a9913f2d-0c1a-4492-bf58-5c7 [EMAIL PROTECTED]: How about something like the following (untested) done = False while not done: try:

Re: Python and Flaming Thunder

2008-05-22 Thread Duncan Booth
of the read. That implies that any unchecked errors will go undetected. Ick. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Showing the method's class in expection's traceback

2008-05-22 Thread Duncan Booth
numbers for each class. That way any classname displayed would be based on the actual source nesting and even static methods or functions injected from another class would work 'correctly' (at some level). -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python

Re: conventions/requirements for 'is' vs '==', 'not vs '!=', etc

2008-05-20 Thread Duncan Booth
is broken. If you want to be able to test identity on strings safely then use the 'intern()' builtin to get repeatable behaviour. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: scaling problems

2008-05-20 Thread Duncan Booth
to make sure that page requests are as efficient as possible. In return you get an application which should scale well. There is nothing Python specific about the techniques, it is just that Python is the first (and so far only) language supported on the platform. -- Duncan Booth http

Re: Using Python for programming algorithms

2008-05-20 Thread Duncan Booth
is targetted at .Net. That compiles to a bytecode known as MSIL which is then interpreted and/or JIT compiled to machine code. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Classmethods are evil

2008-05-19 Thread Duncan Booth
and the caller would need to be careful to call the correct one. So we end up with functions from_keys_Foo_or_Baz(cls) and from_keys_Bar() which is an unmaintainable mess. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: secret code?

2008-05-18 Thread Duncan Booth
Sanoski [EMAIL PROTECTED] wrote: What would you guys says about this secret code? The key was apparently lost. The guy never sent it, and he was never seen again. It must stand for letters in the alphabet, but it almost looks like trajectory tables. I don't know. What do you guys think?

Re: Problem creating a shorcut

2008-05-16 Thread Duncan Booth
_winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, 'FirefoxURL\shell\open\command') and of course it throws an exception if firefox isn't installed. Then just replace %1 with the url to get the actual command you need. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman

Re: Variable by label

2008-05-16 Thread Duncan Booth
be done. I guess it is achievable. Thank you. vars()[foo] but if you are doing this you are almost certainly making your life harder than it needs to be. Usually you really just want to keep the values in a dict. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org

Re: [off-topic] Usenet

2008-05-14 Thread Duncan Booth
hdante [EMAIL PROTECTED] wrote: How can I access Usenet without using Google Groups ? (my ISP doesn't have a NNTP server). Do you recommend doing so ? Yes, even those ISP's who do have a news server often seem to make a mess of maintaining it. I use news.individual.net which seems to do a

Re: list.__len__() or len(list)

2008-05-14 Thread Duncan Booth
Nikhil [EMAIL PROTECTED] wrote: Then why to have __len__() internal method at all when the built-in len() is faster? Because the internal method is used internally. The idea is that you define __len__() on your objects when appropriate. You are not expected to ever call it. --

Re: File Creation Not Working In A Thread Class?

2008-05-12 Thread Duncan Booth
bc90021 [EMAIL PROTECTED] wrote: On Sun, 11 May 2008 19:55:31 +, Duncan Booth wrote: 7stud [EMAIL PROTECTED] wrote:                             tempfileName = \proctemp\\                             + self.matrix[c][0] + _other.txt\ It wouldn't

Re: Python doesn't recognize quote types

2008-05-12 Thread Duncan Booth
Dennis Lee Bieber [EMAIL PROTECTED] wrote: The sloppy use of single quote for the apostrophe is unfortunate G True, but that problem is outside of the Python community's control. Given that people do often refer to single quote when they mean apostrophe the error message should be written

Re: do you fail at FizzBuzz? simple prog test

2008-05-12 Thread Duncan Booth
Ivan Illarionov [EMAIL PROTECTED] wrote: is there a better way than my solution? is mine ok? ['%s%s' % (not i%3 and 'Fizz' or '', not i%5 and 'Buzz' or '') or str(i) for i in xrange(1, 101)] -- Ivan or, more correctly, if you actually need to print:

Re: Python doesn't recognize quote types

2008-05-11 Thread Duncan Booth
[EMAIL PROTECTED] wrote: There's a thing that bugs me in Python. Look at this... print Testing\ SyntaxError: EOL while scanning single-quoted string Please focus on the part of the error message that states while scanning single-quoted string. How can Python claim it scanned a

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread Duncan Booth
bc90021 [EMAIL PROTECTED] wrote: The error message was at the top of the thread (am I incapable of posting it, or are you incapable of following a thread?), but here it is again: IOError: [Errno 2] no such file u'tempfileName' So which was it? At the top of the thread you said it was:

Re: File Creation Not Working In A Thread Class?

2008-05-11 Thread Duncan Booth
7stud [EMAIL PROTECTED] wrote:                                                                 tempfileName = \proctemp\\ + self.matrix[c][0] + _other.txt\ It wouldn't exactly result in either of the error messages you posted, but I expect the spurious quote marks round the filename will

Re: explain this function to me, lambda confusion

2008-05-09 Thread Duncan Booth
[EMAIL PROTECTED] wrote: Indeed, there are many ways this could be done. Some are more concise, some are more efficient. As I said, I did it the way I did it to try out lambdas. Your way achieves the result, rather elegantly I think, but teaches me nothing about using lambdas.

Re: prove

2008-05-09 Thread Duncan Booth
Lucas Prado Melo [EMAIL PROTECTED] wrote: Hello, How could I prove to someone that python accepts this syntax using the documentation (I couldn't find it anywhere): classname.functionname(objectname) Language reference, mostly section 5.3 Primaries call ::= primary (

Re: simple question about Python list

2008-05-09 Thread Duncan Booth
dmitrey [EMAIL PROTECTED] wrote: On 9 ôÒÁ, 13:17, Paul Hankin [EMAIL PROTECTED] wrote: On May 9, 11:04šam, dmitrey [EMAIL PROTECTED] wrote: list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5'] and list2 = [0, 2, 4] # integer elements howto (I mean most simple recipe, of

Re: Function creation (what happened?)

2008-05-09 Thread Duncan Booth
Viktor [EMAIL PROTECTED] wrote: Can somebody give me an explanation what happened here (or point me to some docs)? Code: HMMM = None def w(fn): print 'fn:', id(fn) HMMM = fn print 'HMMM:', id(HMMM) def wrapper(*v, **kw): fn(*v, **kw) wrapper.i = fn

Re: Feature suggestion: sum() ought to use a compensated summationalgorithm

2008-05-09 Thread Duncan Booth
Terry Reedy [EMAIL PROTECTED] wrote: Szabolcs Horvát [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Gabriel Genellina wrote: | | Python doesn't require __add__ to be associative, so this should | not be used as a general sum replacement. | | It does not _require_ this, but

Re: The del statement

2008-05-08 Thread Duncan Booth
Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three different things: (1) del x: Remove x from the current namespace (2) del x[i]:

Re: explain this function to me, lambda confusion

2008-05-08 Thread Duncan Booth
[EMAIL PROTECTED] wrote: Here is a simple lambda that implements an exclusive or: def XOR(x,y) : return lambda : ( ( x ) and not ( y ) ) or ( not ( x ) and ( y ) ) (Because of the resemblance to C macros, I have been cautious and written the lambda with lots of parentheses.) To use

Re: The del statement

2008-05-08 Thread Duncan Booth
Arnaud Delobelle [EMAIL PROTECTED] wrote: Duncan Booth wrote: Arnaud Delobelle [EMAIL PROTECTED] wrote: George Sakkis wrote: One of the few Python constructs that feels less elegant than necessary to me is the del statement. For one thing, it is overloaded to mean three

Re: Why don't generators execute until first yield?

2008-05-07 Thread Duncan Booth
Martin Sand Christensen [EMAIL PROTECTED] wrote: Now to the main point. When a generator function is run, it immediately returns a generator, and it does not run any code inside the generator. Not until generator.next() is called is any code inside the generator executed, giving it

Re: Why don't generators execute until first yield?

2008-05-07 Thread Duncan Booth
Martin Sand Christensen [EMAIL PROTECTED] wrote: Duncan == Duncan Booth [EMAIL PROTECTED] writes: [...] Duncan Now try: Duncan Duncanfor command in getCommandsFromUser(): Duncanprint the result of that command was, execute(command) Duncan Duncan where getCommandsFromUser

Re: Why don't generators execute until first yield?

2008-05-07 Thread Duncan Booth
Marco Mariani [EMAIL PROTECTED] wrote: Duncan Booth wrote: It does this: @greedy def getCommandsFromUser(): while True: yield raw_input('Command?') for cmd in getCommandsFromUser(): print that was command, cmd Command?hello Command?goodbye

<    1   2   3   4   5   6   7   8   9   10   >