Re: Python (and me) getting confused finding keys

2009-12-22 Thread Lie Ryan
On 12/23/2009 3:33 AM, John wrote: Hi there, I have a rather lengthy program that troubles me for quite some time. After some debugging, I arrived at the following assertion error: for e in edges.keys(): assert edges.has_key(e) Oops!? Is there ANY way that something like this can possi

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Lie Ryan
On 12/23/2009 8:41 PM, lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module. I need t

Re: code review

2009-12-23 Thread Lie Ryan
On 12/23/2009 11:02 PM, Zubin Mithra wrote: Hello, I`m pretty new to developing applications using python and i would like advance on this script i recently created which helps linux programmers on the linux terminal. The code is very simple to understand(i hope) and serves a simple purpose; how

Re: More On the Strange Problem

2009-12-23 Thread Lie Ryan
On 12/24/2009 8:00 AM, MRAB wrote: >>> print first_twin == second_twin True err... I don't think there is any situation where first_twin == second_twin wouldn't be considered a bug. They look similar, they act similar, and they quack the same; though you can almost always treat them the sa

Re: creating ZIP files on the cheap

2009-12-23 Thread Lie Ryan
On 12/24/2009 7:34 AM, samwyse wrote: I've got an app that's creating Open Office docs; if you don't know, these are actually ZIP files with a different extension. In my case, like many other people, I generating from boilerplate, so only one component (content.xml) of my ZIP file will ever chan

Re: Object Relational Mappers are evil (a meditation)

2009-12-24 Thread Lie Ryan
On 12/24/2009 12:11 PM, Terry Reedy wrote: This buggy idiom survived many years of Python development, missed by virtually everyone. The last statement is false. The hazard of using and/or was well-known back in '97 or so when I discovered or learned it and I believe it was mentioned in the FAQ

Re: Join a thread and get the return value of a function

2009-12-24 Thread Lie Ryan
On 12/25/2009 12:23 AM, mattia wrote: Hi all, is there a way in python to get back the value of the function passed to a thread once the thread is finished? Something like pthread_join() in C? Thanks, Mattia use a Queue to pass the value out? -- http://mail.python.org/mailman/listinfo/python-l

Re: Problem with Dynamically unloading a module

2009-12-24 Thread Lie Ryan
On 12/24/2009 11:51 PM, Jean-Michel Pichavant wrote: But what he *can* do is to learn how importing works. I'm not sure it's terribly helpful to tell somebody all the things they can't do instead of what they can. Hacking python imports would not be in the top of the list of things I would tea

Re: Join a thread and get the return value of a function

2009-12-24 Thread Lie Ryan
On 12/25/2009 2:02 AM, mattia wrote: Il Fri, 25 Dec 2009 00:35:55 +1100, Lie Ryan ha scritto: On 12/25/2009 12:23 AM, mattia wrote: Hi all, is there a way in python to get back the value of the function passed to a thread once the thread is finished? Something like pthread_join() in C

Re: Threading with queues

2009-12-24 Thread Lie Ryan
On 12/24/2009 2:11 PM, Gib Bogle wrote: Lie Ryan wrote: On 12/22/2009 10:47 AM, Gib Bogle wrote: It turns out that this code isn't a great demo of the advantages of threading, on my system anyway. The time taken to execute doesn't vary much when the number of threads is set anywhere

Re: Missing collections

2009-12-27 Thread Lie Ryan
On 12/27/2009 4:53 PM, Bearophile wrote: - frozenDict perhaps we could extend namedtuple to become the "frozenDict" - persistentList, persistentDict aren't they database? Am I missing something here? Regarding the standard library of Python 3, it's easy enough to create for mistake a modu

Re: Difference Between Two datetimes

2009-12-27 Thread Lie Ryan
On 12/28/2009 5:42 PM, W. eWatson wrote: You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2, 13, 1, 15). If I now use t2=datetime.datetime.strptime("2009/01/04 13:01:15","%Y/%m/%d %H:%M:%S") I get tw as datetime.datetime(2009, 1, 4, 13, 1, 15) Then t2-t1 gives, datetime.timede

Re: Simple distributed example for learning purposes?

2009-12-28 Thread Lie Ryan
On 12/27/2009 7:46 AM, Shawn Milochik wrote: The special features of the Shrek DVD showed how the rendering took so much processing power that everyone's workstation was used overnight as a rendering farm. Some kind of video rendering would make a great example. However, it might be a lot of ov

Re: Difference Between Two datetimes

2009-12-28 Thread Lie Ryan
On 12/29/2009 1:12 AM, Roy Smith wrote: Hint #3: If you don't pay attention to this, you will be bitten twice a year. Not really. Some areas don't have DST and the answer to that is always exactly 5 months. -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple distributed example for learning purposes?

2009-12-28 Thread Lie Ryan
On 12/28/2009 11:59 PM, Shawn Milochik wrote: With address data: one address may have suite data and the other might not the same city may have multiple zip codes why is that even a problem? You do put suite data and zipcode into different database fields right? inc

Re: How to iterate the input over a particular size?

2009-12-28 Thread Lie Ryan
On 12/28/2009 8:54 PM, Peter Otten wrote: Francesco Bochicchio wrote: One with lazy chunks: from itertools import chain, islice def chunks(items, n): items = iter(items) for first in items: yield chain((first,), islice(items, n-1)) [list(chunk) for chun

Re: Windows, IDLE, __doc_, other

2009-12-28 Thread Lie Ryan
On 12/29/2009 5:10 AM, W. eWatson wrote: Lie Ryan wrote: If you're on Windows, don't use the "Edit with IDLE" right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start menu. When I go to Start and select IDLE, Saves or Ope

Re: clean data [was: Simple distributed example for learning purposes?]

2009-12-29 Thread Lie Ryan
On 12/29/2009 9:14 AM, Ethan Furman wrote: Lie Ryan wrote: On 12/28/2009 11:59 PM, Shawn Milochik wrote: With address data: one address may have suite data and the other might not the same city may have multiple zip codes why is that even a problem? You do put suite data and zipcode into

Re: Python OOP Problem

2009-12-29 Thread Lie Ryan
On 12/29/2009 3:01 PM, Миклухо wrote: On 28 дек, 18:29, "Martin v. Loewis" wrote: In this case (you just started to learn Python), I recommend to take an explicit approach. Create a dictionary that maps class names to classes: name2class = { "MyObject" : MyObject, "MyOtherObjec

Re: I think I found a bug in Python 2.6.4 (in the inspect module)

2009-12-30 Thread Lie Ryan
On 12/30/2009 9:10 AM, inhahe wrote: Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. import inspect def a(b=1): pass inspect.getargvalues(a) Traceback (most recent call last):

Re: Windows, IDLE, __doc_, other

2009-12-30 Thread Lie Ryan
On 12/30/2009 6:21 AM, W. eWatson wrote: Lie Ryan wrote: On 12/29/2009 5:10 AM, W. eWatson wrote: Lie Ryan wrote: If you're on Windows, don't use the "Edit with IDLE" right-click hotkey since that starts IDLE without subprocess. Use the shortcut installed in your Start

Re: Dynamic text color

2009-12-31 Thread Lie Ryan
On 1/1/2010 2:24 AM, Dave McCormick wrote: If I count characters from the beginning how do I know what line the text is on? Would you mind making your last hint a bit stronger... From http://infohost.nmt.edu/tcc/help/pubs/tkinter/text-index.html: """ + n chars From the given index, move f

Re: multivariable assignment

2010-01-01 Thread Lie Ryan
On 1/1/2010 3:13 AM, davidj411 wrote: I am not sure why this behavior is this way. at beginning of script, i want to create a bunch of empty lists and use each one for its own purpose. however, updating one list seems to update the others. a = b = c = [] a.append('1') a.append('1') a.append('1'

Re: Where is "urllib2" module in windows python3.1.1?

2010-01-01 Thread Lie Ryan
On 1/2/2010 12:46 AM, Hidekazu IWAKI wrote: Hi; I'd like to import "urllib2" in windows python 3.1.1, but I'm not able to do it. So, I researched the library directory; the result is following: . . 2009/06/07 19:1161,749 unittest.py 2010/01/01 22:18 urllib 2007/12

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Lie Ryan
On 1/1/2010 3:47 PM, Peng Yu wrote: I observe that python library primarily use exception for error handling rather than use error code. In the article API Design Matters by Michi Henning Communications of the ACM Vol. 52 No. 5, Pages 46-56 10.1145/1506409.1506424 http://cacm.acm.org/magazines/

Re: Bare Excepts

2010-01-02 Thread Lie Ryan
On 1/2/2010 9:42 PM, Steven D'Aprano wrote: On Fri, 01 Jan 2010 15:27:57 -0800, myle wrote: Why we should prefer ``if: ...'' over a ``try: ... except something: pass'' block? We shouldn't, not in general. One exception (pun intended) is if the try-block have a side effect that is difficul

Re: detect interactivity

2010-01-03 Thread Lie Ryan
On 12/30/2009 11:25 PM, Roald de Vries wrote: Actually, performance is not much if an issue for what I want to do; it's mainly interest in 'how should I do this in general'. I'll just leave in all the code, and if it becomes a real issue, I'll separate the code over an interactive and a non-inter

Re: What is the best data structure for a very simple spreadsheet?

2010-01-03 Thread Lie Ryan
On 1/3/2010 10:27 PM, vsoler wrote: 1) what are, in your opinion, the basic elements of the Cell class? The "user-entered formula" and "effective value". A Cell containing a formula "abc" has a value of "abc"; a cell containing the formula "=1+5" has a value of "6". You could use the 'proper

Re: Exception as the primary error handling mechanism?

2010-01-04 Thread Lie Ryan
On 1/5/2010 1:31 PM, r0g wrote: Michi wrote: On Jan 4, 1:30 pm, Steven D'Aprano wrote: In some, limited, cases you might be able to use the magic return value strategy, but this invariably leads to lost programmer productivity, more complex code, lowered readability and usability, and more

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Lie Ryan
On 1/6/2010 1:48 AM, r0g wrote: Steven D'Aprano wrote: On Tue, 05 Jan 2010 13:06:20 +, r0g wrote: If that's the case how can you expect it to validate anything at all in production? The asserts still operate so long as you don't use the -O switch. Do you mean for debugging in situ or so

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Lie Ryan
On 1/7/2010 2:12 AM, Phlip wrote: On Jan 5, 10:54 pm, Benjamin Kaplan wrote: {41: None}[41] ? In cases where None is a valid result, you can't use it to signal failure.. Asked and answered. You change the "sentinel" in .fetch to something else. I believe Ben Kaplan's point is that if dict

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Lie Ryan
On 1/7/2010 3:41 AM, Phlip wrote: Steve Holden wrote: y'all just keep defending the approach to programming that *you* think is best. Speak for yourself... Everyone speaks for themselves, is that a problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: File transfer with python

2010-01-06 Thread Lie Ryan
On 1/7/2010 5:00 AM, Valentin de Pablo Fouce wrote: My intention is to be able to transfer files from one computer to another in this environment. Do you have a USB flashdrive? Looking (and surfing) at internet the only suggestion given is to use low level sockets for this file transfer. Is t

Re: Exception as the primary error handling mechanism?

2010-01-07 Thread Lie Ryan
On 1/7/2010 10:43 PM, Roel Schroeven wrote: - I tend to think that not following that practice trains me to be careful in all cases, whereas I'm afraid that following the practice will make me careless, which is dangerous in all the cases where the practice won't protect me. That's a sign of a

Re: Recommended "new" way for config files

2010-01-07 Thread Lie Ryan
On 1/8/2010 3:10 AM, Peter wrote: Is there a strategy that should be prefered for new projects ? The answer is, it depends. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help to pass self.count to other classes.

2010-01-08 Thread Lie Ryan
On 1/8/2010 3:56 PM, Steven D'Aprano wrote: Unfortunately this won't do what you expect, because sys.ps1 and ps2 should be either strings, or objects with a __str__ method. They aren't called to generate the prompt. but their __str__ does get called to generate the prompt. import sys class kb

Re: PIL how to display multiple images side by side

2010-01-09 Thread Lie Ryan
On 1/9/2010 8:43 AM, suresh.amritapuri wrote: Hi, In PIL, how to display multiple images in say m rows and n colums when I have m*n images. suresh Tkinter has PhotoImage widget and PIL has support for this widget: http://www.pythonware.com/library/pil/handbook/imagetk.htm -- http://mail.pyt

Re: decode(..., errors='ignore') has no effect

2010-01-12 Thread Lie Ryan
On 01/12/10 23:50, Jens Müller wrote: >> To convert unicode into str you have to *encode()* it. >> >> u"...".decode(...) will implicitly convert to ASCII first, i. e. is >> equivalent to >> >> u"...".encode("ascii").decode(...) >> >> Hence the error message > > Ah - yes of course. > > And how can

Re: Bugs in CPython 3.1.1 [wave.py]

2010-01-13 Thread Lie Ryan
Alf P. Steinbach wrote: > * Stefan Behnel: >> Alf P. Steinbach, 13.01.2010 06:39: >>> * Steven D'Aprano: On Tue, 12 Jan 2010 23:42:28 +0100, Alf P. Steinbach wrote: > It is hopeless, especially for a newbie, to create correct Python > 2.x+3.x compatible code, except totally trivial stu

Re: os.system function

2010-01-13 Thread Lie Ryan
On 01/13/10 04:59, r0g wrote: > so you may want to look into pythons core GUI library, TKL. I know Tk and Tcl has been close since their childhood; did they get married too? -- http://mail.python.org/mailman/listinfo/python-list

Re: Those two controversial 2nd & 3rd paragraphs of my ch 1

2010-01-14 Thread Lie Ryan
On 01/14/10 11:08, Alf P. Steinbach wrote: > * Daniel Fetchinson: >> >> Nobody is deliberately trying to keep people from porting! I think you >> misunderstand what is being said, these two statements are very >> different: (1) single code base working on both python versions (2) >> creating a seco

Re: a problem with writing a generator

2010-01-14 Thread Lie Ryan
On 01/15/10 01:49, Steven D'Aprano wrote: > On Thu, 14 Jan 2010 15:11:29 +0100, Paweł Banyś wrote: > >> Hello, >> >> Please forgive me if I repeat the subject anyhow. I am trying to write a >> simple program in Python which scans a config file in search for >> "include" lines. If those lines are f

Re: A simple-to-use sound file writer

2010-01-14 Thread Lie Ryan
On 01/15/10 05:42, Alf P. Steinbach wrote: > I'm beginning to believe that you maybe didn't grok that simple procedure. > > It's very very very trivial, so maybe you were looking for something > more intricate -- they used to say, in the old days, "hold on, this > proof goes by so fast you may n

Re: maintain 2 versions of python on my computer

2010-01-14 Thread Lie Ryan
On 01/14/10 22:21, luis wrote: > > Hi > > I am not an expert in programming and using Python for its simplicity > > I have 2 versions of python installed on my computer (windos xp) to > begin the transition from version 2.4 to 2.6 or 3. maintaining the > operability of my old scripts > > Is the

Re: Executable standalone *.pyc after inserting "#!/usr/bin/python"or other options

2010-01-14 Thread Lie Ryan
On 01/15/10 09:33, Martin v. Loewis wrote: > > P.S. The approach you present for Lua indeed does not work for > Python. Actually the approach should work, though with a little workaround; you can write your wrapper (e.g. #!/usr/bin/mypython) that simply strips the first line and pass the file to

Re: dict's as dict's key.

2010-01-15 Thread Lie Ryan
On 01/14/10 05:33, Albert van der Horst wrote: > (I encountered this before. A dictionary is a natural for a > boardgame position, i.e. chess. Now we want to look up chess > positions.) or use collections.namedtuple -- http://mail.python.org/mailman/listinfo/python-list

Re: setattr() oddness

2010-01-16 Thread Lie Ryan
On 01/16/10 10:10, Sean DiZazzo wrote: > Interesting. I can understand the "would take time" argument, but I > don't see any legitimate use case for an attribute only accessible via > getattr(). Well, at least not a pythonic use case. mostly for people (ab)using attributes instead of dictionary.

Re: Using invalid.com email addresses

2010-01-16 Thread Lie Ryan
On 01/16/10 19:56, Ben Finney wrote: > Paul Rubin writes: > >> I'd think whoever registered that domain would have known what they >> were getting into when they registered it. Same with "example.com" and >> so forth. > > Which doesn't make it any more appropriate to act as though you have > fre

Re: chr(12) Form Feed in Notepad (Windows)

2010-01-16 Thread Lie Ryan
On 01/17/10 02:37, W. eWatson wrote: > D'Arcy J.M. Cain wrote: >> On Fri, 15 Jan 2010 20:17:35 -0800 >> "W. eWatson" wrote: >>> Could be, but I have no way of easily knowing. In any case, I was >>> trying to write a simple report that could be printed with titles at >>> the top of each page. If th

Re: dict's as dict's key.

2010-01-17 Thread Lie Ryan
On 01/17/10 12:29, Ethan Furman wrote: > Lie Ryan wrote: >> On 01/14/10 05:33, Albert van der Horst wrote: >> >>> (I encountered this before. A dictionary is a natural for a >>> boardgame position, i.e. chess. Now we want to look up chess >>> position

Re: The answer

2010-01-17 Thread Lie Ryan
On 01/18/10 13:30, Jive Dadson wrote: > Okay, with your help I've figured it out. Instructions are below, but > read the caveat by Ben Fenny in this thread. All this stuff is good for > one default version of Python only. The PYTHONPATH described below, for > example, cannot specify a version nu

Re: Python decorator syntax limitations

2010-01-18 Thread Lie Ryan
On 01/19/10 03:44, Jonathan S wrote: > Any suggestions? I have my reasons for doing this, (news_page is a > class, and __call__ is used to wrap the template.) > I'm sure this is a limitation in the syntax, but would parenthesis > somewhere help? The restriction[1] is put in there since Guido has a

Re: how to check if a module is importable?

2010-01-20 Thread Lie Ryan
On 01/20/10 19:58, Robert P. J. Day wrote: > > finally getting back to clawing my way thru the python 3 book so > probably a number of newbie questions coming up. first one -- can i > check if a module is importable (equivalently, exists on sys.path, i > assume) without trying to import it firs

Re: examining an initial, pristine python3 shell session

2010-01-20 Thread Lie Ryan
On 01/20/10 22:59, Robert P. J. Day wrote: > then i might go a bit further to examine some of *those* objects. i > admit it might seem a bit dry, but i think it would be handy to have a > handle on what a clean shell session looks like before starting to > import things, then seeing how that impor

Re: myths about python 3

2010-01-27 Thread Lie Ryan
On 01/28/10 01:32, Jean-Michel Pichavant wrote: > Daniel Fetchinson wrote: Hi folks, I was going to write this post for a while because all sorts of myths periodically come up on this list about python 3. I don't think the posters mean to spread false information on purpose

interaction of mode 'r+', file.write(), and file.tell(): a bug or undefined behavior?

2010-01-28 Thread Lie Ryan
In the code: """ f = open('input.txt', 'r+') for line in f: s = line.replace('python', 'PYTHON') # f.tell() f.write(s) """ When f.tell() is commented, 'input.txt' does not change; but when uncommented, the f.write() succeeded writing into the 'input.txt' (surprisingly, but not entirel

Re: Stuck on a three word street name regex

2010-01-28 Thread Lie Ryan
On 01/28/10 11:28, Brian D wrote: > I've tackled this kind of problem before by looping through a patterns > dictionary, but there must be a smarter approach. > > Two addresses. Note that the first has incorrectly transposed the > direction and street name. The second has an extra space in it befo

Re: python 3's adoption

2010-01-28 Thread Lie Ryan
On 01/28/10 19:37, Paul Rubin wrote: > Jonathan Gardner writes: >> If you're going to have statements, you're going to need the null >> statement. That's "pass". > > Why? Expressions are statements, so you could just say "pass" (in > quotes, denoting a string literal), or 0, or None, os anything

Re: python 3's adoption

2010-01-28 Thread Lie Ryan
On 01/28/10 20:12, Alf P. Steinbach wrote: > * Steven D'Aprano: >> On Wed, 27 Jan 2010 18:29:25 +0100, Alf P. Steinbach wrote:> >> Instead of: >> >> print >>fileObj, x, y, z >> >> you use regular function syntax with a meaningful keyword: >> >> print(x, y, z, file=fileObj) >> >> If you want suppres

Re: [Tutor] Help required

2009-09-26 Thread Lie Ryan
waqas ahmad wrote: Now i want to search all those pages, where i have *NOT* written "#acl InternationalGroup:read" *But* i have written only "CatInternational" in the page text. You can split the two queries into two regexes: import re acl = re.compile(r'#acl InternationalGroup:read') cat =

Re: print()

2009-10-17 Thread Lie Ryan
mattia wrote: Another question (always py3). How can I print only the first number after the comma of a division? e.g. print(8/3) --> 2.667 I just want 2.6 (or 2.66) Are you sure you don't want that to be 2.7 or 2.67? Then you can use: n = int(n * 10**2) / 10**2 else if 2.7 pr 2.67 is

Re: More & More Fun w/ Pics & MySQL

2009-10-17 Thread Lie Ryan
Carsten Haese wrote: Victor Subervi wrote: [snip...] print 'Content-type: image/jpeg' print 'Content-Encoding: base64' print print pic().encode('base64') print '' [snip...] Why are you printing "" at the end of a page that is supposed to be a base64-encoded JPEG file? I'm testing my "psych

Re: a gap of do....while?

2009-10-18 Thread Lie Ryan
Chris Rebert wrote: On Sat, Oct 17, 2009 at 10:22 PM, StarWing wrote: okay, I think somethings dowhile is useful, but why python didn't have it? For simplicity of syntax and less duplication among the basic syntactic constructs. Less language features means less decisions to make. -- ht

Re: The rap against "while True:" loops

2009-10-18 Thread Lie Ryan
Paul Rubin wrote: Steven D'Aprano writes: For the record, the four lines Paul implies are "confusing" are: try: d[key] += value except KeyError: d[key] = value Consider what happens if the computation of "key" or "value" itself raises KeyError. Isn't key and value just a simple var

Re: The rap against "while True:" loops

2009-10-18 Thread Lie Ryan
Ben Finney wrote: Lie Ryan writes: Paul Rubin wrote: Steven D'Aprano writes: For the record, the four lines Paul implies are "confusing" are: try: d[key] += value except KeyError: d[key] = value Consider what happens if the computation of "key" or "

Re: help to convert c++ fonction in python

2009-10-18 Thread Lie Ryan
Thomas wrote: If you change your last line from: print s to: print u you'll get different results :) if you change: s1 = base64.b64decode( s ) into s = base64.b64decode( s ) you'll get the same result again. -- http://mail.python.org/mailman/listinfo/python-list

Re: More & More Fun w/ Pics & MySQL

2009-10-18 Thread Lie Ryan
Carsten Haese wrote: Victor Subervi wrote: Thank you all. I have __no__idea__ why the link I sent you, that you tested, __didn't__ work for me. Was it a problem with the browser? My Magic 8-Ball says "Unclear. Ask again later." Regarding Carsten's misunderstanding of my mentioning of comment

Re: Reverse Iteration Through Integers

2009-10-18 Thread Lie Ryan
Benjamin Middaugh wrote: I'm trying to make an integer that is the reverse of an existing integer such that 169 becomes 961. I guess I don't know enough yet to figure out how to do this without a ton of awkward-looking code. I've tried for loops without much success. I guess I need a good way o

Re: Checking a Number for Palindromic Behavior

2009-10-21 Thread Lie Ryan
ru...@yahoo.com wrote: 1) It may look like a homework problem to you but it probably isn't. Seehttp://groups.google.com/group/comp.lang.python/msg/8ac6db43b09fdc92 Homework comes in many forms - school driven homework should be treated the same as self driven research, IMO. You're not doing it

Re: Windows file paths, again

2009-10-21 Thread Lie Ryan
Dan Guido wrote: Hi Anthony, Thanks for your reply, but I don't think your tests have any control characters in them. Try again with a \v, a \n, or a \x in your input and I think you'll find it doesn't work as expected. A path read from a file, config file, or winreg would never contain contr

Re: Checking a Number for Palindromic Behavior

2009-10-21 Thread Lie Ryan
ru...@yahoo.com wrote: On 10/21/2009 01:40 AM, Lie Ryan wrote: ru...@yahoo.com wrote: 1) It may look like a homework problem to you but it probably isn't. Seehttp://groups.google.com/group/comp.lang.python/msg/8ac6db43b09fdc92 Homework comes in many forms - school driven homework shou

Re: equivalent to globals(), locals() for nonlocal variables?

2009-10-22 Thread Lie Ryan
geremy condra wrote: I decided to play around with nonlocal declarations today, and was somewhat surprised when a call to nonlocals() resulted in 'nonlocals is not defined'. Is there an a standard equivalent to globals() or locals() for variables in outer nested scopes? Geremy Condra Not that

Re: Help with my program

2009-10-23 Thread Lie Ryan
tanner barnes wrote: Ok so im in need of some help! I have a program with 2 classes and in one 4 variables are created (their name, height, weight, and grade). What im trying to make happen is to get the variables from the first class and use them in the second class.

Re: a simple unicode question

2009-10-27 Thread Lie Ryan
Chris Jones wrote: On Wed, Oct 21, 2009 at 12:35:11PM EDT, Nobody wrote: [..] Characters outside the 16-bit range aren't supported on all builds. They won't be supported on most Windows builds, as Windows uses 16-bit Unicode extensively: I knew nothing about UTF-16 & friends before this thre

Re: cool-compiling python 3

2009-10-29 Thread Lie Ryan
Rustom Mody wrote: I guess this is a bit OT but anyhow. I just finished compiling compiling python 3 on ubuntu and discovered that my laptop has a builtin toaster :-; Yeah I know this is not a python issue and probably modern laptops are meant to run wondrous beautiful elephantaneous th

Re: disutils, project structure & developing - n00b question

2009-10-29 Thread Lie Ryan
Simon Forman wrote: In order for "from pymlb import fetcher" no work you must make the './pymlb' directory into a "package" by adding a file called __init__.py (it can be empty.) Then make sure the "top" directory (i.e. '.' in your example) is in the python PATH. There are a couple of ways to

Re: spring effect in Python

2009-10-30 Thread Lie Ryan
pochis40 wrote: I'm trying to write in Python something similar to this: (Java) http://java.sun.com/applets/jdk/1.4/demo/applets/GraphLayout/example1.html or these: (Proce55ing) http://www.cricketschirping.com/processing/ExportAtlas/ or http://www.cricketschirping.com/weblog/2005/12/11/force-dire

Re: Aaaargh! "global name 'eggz' is not defined"

2009-10-30 Thread Lie Ryan
Aahz wrote: In article , Robert Kern wrote: I like using pyflakes. It catches most of these kinds of typo errors, but is much faster than pylint or pychecker. Coincidentally, I tried PyFlakes yesterday and was unimpressed with the way it doesn't work with "import *". If only IDLE's Intell

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-05 Thread Lie Ryan
Peng Yu wrote: Suppose I have a list of strings, A. I want to compute the list (call it B) of strings that are elements of A but doesn't match a regex. I could use a for loop to do so. In a functional language, there is way to do so without using the for loop. In functional language, there is n

Re: IOError: [Errno 28] No space left on device

2009-11-17 Thread Lie Ryan
hong zhang wrote: List, My python script has a strange error. cont_tx = 1 for i in glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'): with open(i, 'w') as f: print >>f, cont_tx work perfectly. But following get error like: print >>f, cont_tx IOEr

Re: IOError: [Errno 28] No space left on device

2009-11-17 Thread Lie Ryan
hong zhang wrote: --- On Tue, 11/17/09, Tim Chase wrote: From: Tim Chase Subject: Re: IOError: [Errno 28] No space left on device To: "Lie Ryan" Cc: python-list@python.org Date: Tuesday, November 17, 2009, 7:47 PM for i in glob.glob('/sys/kernel/debug/ieee80211/p

Re: question about tree in python

2009-11-18 Thread Lie Ryan
nospam wrote: How should I write a tree using diconary. I have used a dictonary to make a tree. dictionary tree? root = { 'node_a': { 'node_a_a': 'blah', 'node_a_b': 'foo', 'node_a_c': 'bar', }, 'node_b': { 'node_b_a': 'soo', 'node_b_b': 'fle

Re: plotting arrow in python

2009-11-21 Thread Lie Ryan
rudra wrote: Dear friends, I am very new in python. Actually, I think I will not do much python then using it to plotting data. I have not done any "real" thing in python, so plz be easy. Now , the problem I have a data set: 0.0 0.0 0.1 0.0 0.1 0.1 0.1 0.0 0.5 like that! the first two column are

Re: Sorting: too different times. Why?

2009-11-22 Thread Lie Ryan
n00m wrote: The second part of the compound if is backwards. So if this is headed for production code, it better get fixed. DaveA Not sure I'm understanding your remark. Maybe he meant, that this: if v1.x < v2.x and v1.y > v2.y should be: if v1.x < v2.x and v1.y < v2.y ? -- http://mail.pyth

Re: Split class across multiple files

2009-11-22 Thread Lie Ryan
eric.frederich wrote: I have a class which holds a connection to a server and a bunch of services. In this class I have methods that need to work with that connection and services. Right now there are about 50 methods some of which can be quite long. From an organizational standpoint, I'd like t

Re: What is the naming convention for accessor of a 'private' variable?

2009-11-22 Thread Lie Ryan
Peng Yu wrote: On Wed, Nov 18, 2009 at 8:47 PM, Chris Rebert wrote: On Wed, Nov 18, 2009 at 6:27 PM, Peng Yu wrote: http://www.python.org/dev/peps/pep-0008/ The above webpage states the following naming convention. Such a variable can be an internal variable in a class. I'm wondering what is

Re: creating pipelines in python

2009-11-22 Thread Lie Ryan
per wrote: hi all, i am looking for a python package to make it easier to create a "pipeline" of scripts (all in python). what i do right now is have a set of scripts that produce certain files as output, and i simply have a "master" script that checks at each stage whether the output of the pre

Re: Trying to understand += better

2009-11-22 Thread Lie Ryan
Roy Smith wrote: If I've got an object foo, and I execute: foo.bar += baz exactly what happens if foo does not have a 'bar' attribute? It's pretty clear that foo.__getattr__('bar') gets called first, but it's a little murky after that. Assume for the moment that foo.__getattr__ ('bar') return

Re: Implementation of Book Organization tool (Python2.[x])

2009-11-22 Thread Lie Ryan
~km wrote: Hi together, I'm a python-proficient newbie and want to tackle a program with Python 2.x, which basically organizes all my digital books (*.pdf, *.chm, etc..) and to give them specific "labels", such as: "Author" -> string "Read" -> boolean "Last Opened:" -> string and so on.. Now m

Re: problem manipulating a list belonging to a class

2009-11-22 Thread Lie Ryan
Marc Leconte wrote: class Toto(object): def __init__(self, number, mylist=[]): self.number=number self.mylist=mylist pass pass Why are you using pass to end your blocks? -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand += better

2009-11-22 Thread Lie Ryan
Roy Smith wrote: In article <4b0a01a...@dnews.tpgi.com.au>, Lie Ryan wrote: The semantic of the in-place operator is something like: x += y becomes x = x.__iadd__(y) thus foo.bar += baz becomes foo.bar = foo.bar.__iadd__(baz) So the call sequence is, foo.__getattr__('bar')

Re: Capturing output of os.system to a string

2009-11-23 Thread Lie Ryan
gerry.butler wrote: How do I capture output to a string? For example, the output of os.system('whoami'). I guess I need to redirect stdout, but I'm a total beginner, and I haven't been able to find out from the tutorials how to do this. You can't with os.system; use subprocess module instead.

Re: profiling differences using an extra function call

2009-11-23 Thread Lie Ryan
marc magrans de abril wrote: Hi, I was a trying to profile a small script and after shrinking the code to the minimum I got a interesting profile difference. Given two test functions test1 and test2, that only differs from an extra level of indirection (i.e. find_substr), That's because there

Re: Where to put the error handing test?

2009-11-23 Thread Lie Ryan
Peng Yu wrote: Suppose that I have function f() that calls g(), I can put a test on the argument 'x' in either g() or f(). I'm wondering what is the common practice. My thought is that if I put the test in g(x), the code of g(x) is safer, but the test is not necessary when g() is called by h().

Re: More precise document on os.path.normpath()

2009-11-23 Thread Lie Ryan
Peng Yu wrote: After I tried os.path.normpath(), it is clear that the function doesn't return the trailing '/', if the path is a directory. But this fact is not documented. Should this be documented in future release of python. Also, I found the documentation of some functions in os.path are not

Re: Line Breaks

2009-11-23 Thread Lie Ryan
D'Arcy J.M. Cain wrote: On Mon, 23 Nov 2009 14:46:23 -0500 Susan Day wrote: First, it does in fact ignore all line breaks, not just double line breaks. Here's what I'm doing: session.sendmail(clientEmail, ourEmail2, header+msg) The email sent out has the message sans breaks. You should really

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Lie Ryan
Alf P. Steinbach wrote: And I'm hesitant to just delete index file, hoping that it'll rebuild. it'll be rebuild the next time you start Thunderbird: (MozillaZine: http://kb.mozillazine.org/Disappearing_mail) * It's possible that the ".msf" files (index files) are corrupted. To rebuild the in

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Lie Ryan
Ethan Furman wrote: Good tools to know about, and a consistent naming pattern also makes life easier (which I have since done ;). Let's head towards murkier waters (at least murkier to me -- hopefully they can be easily clarified): some of the attributes are read-only, such as record count

Re: Where to put the error handing test?

2009-11-24 Thread Lie Ryan
Peng Yu wrote: On Tue, Nov 24, 2009 at 4:58 AM, Dave Angel wrote: I'll put an extra emphasis on this: Your question is so open-ended as to be unanswerable. I'll still confused by the guideline that an error should be caught as early

Re: Beginning Question about Python functions, parameters...

2009-11-25 Thread Lie Ryan
astral orange wrote: As for the "class Name():" example above? Even though I haven't seen exactly what purpose 'self' serves In many other programming language, self (or this, or Me) refers the the current class instance. In some languages, you can refer to an instance attribute without an e

<    3   4   5   6   7   8   9   10   11   12   >