Re: Pickle Problem

2009-03-04 Thread Lie Ryan
Fab86 wrote: Is there another way rather than closing the file? Is it possible to delete all within the file? Thanks Delete the old file then opening (and creating) it again is the easiest way? If you need the data from the old file, you can rename the old file and reopen (and create) a new

Re: Peculiar swap behavior

2009-03-04 Thread Lie Ryan
andrew cooke wrote: Delaney, Timothy (Tim) wrote: Tim Chase wrote: # swap list contents...not so much... >>> m,n = [1,2,3],[4,5,6] >>> m[:],n[:] = n,m >>> m,n ([4, 5, 6], [4, 5, 6]) [...] For these types of things, it's best to expand the code out. The appropriate expansion of: m,n = [

Re: Can't override class |__new__

2009-03-05 Thread Lie Ryan
jelle feringa wrote: Hi, I'm working with a C++ module ( CGAL, comp.geom. with exact arithmic ) and am having troubles finding a way to override how the modules returns objects. What I'm trying to do is to extend the Facet class, but when I try to use my version of the class, the parent class is

Re: Can't override class |__new__

2009-03-05 Thread Lie Ryan
jelle feringa wrote: CGAL.Facet = OtherFacet CGAL.Polyhedron.Facet = OtherFacet p = CGAL.Polyhedron_3() You're not creating Facet object here, not even Polyhedron.Facet. Right, which is not the point; I'm trying to override the Facet, a topological entity of which a Polyhedron is composed o

Re: Can Python do shopping cart?

2009-03-06 Thread Lie Ryan
Muddy Coder wrote: Hi Folks, I know PHP can do shopping cart, such as Zen Cart. I wonder can Python do such a thing? Thanks! Muddy Coder Python is Turing Complete -- http://mail.python.org/mailman/listinfo/python-list

Re: Should I use stackless python or threads?

2009-03-06 Thread Lie Ryan
Minesh Patel wrote: On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone wrote: On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel wrote: I am trying to figure out the best approach to solve this problem: I want to poll various directories(can be run in the main thread). Once I notice a file has

Re: python image - ignore values in resize

2009-03-06 Thread Lie Ryan
Travis Kirstine wrote: I have be attempting to resize (downsample) a RGB image using the python image library resize function. Everything works fine but I would like to exclude black values 0,0,0 from the calculations. I have tried creating a alpha mask based on black values then performing the

Re: wxPython fast and slow

2009-03-06 Thread Lie Ryan
iu2 wrote: Do you have any idea of what is going wrong? I think this might be related to the OS's process prioritization, focused Windows would get more priority than background window. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing/Crawler Questions - solution

2009-03-07 Thread Lie Ryan
bruce wrote: john... again the problem i'm facing really has nothing to do with a specific url... the app i have for the usc site works... but for any number of reasons... you might get different results when running the app.. -the server could be screwed up.. -data might be cached -data mi

Re: create boolean

2009-03-07 Thread Lie Ryan
Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n which seems to work but is that normally how you would do it? It can be assumed that n is always None or a list that

Re: "/a" is not "/a" ?

2009-03-07 Thread Lie Ryan
Steven D'Aprano wrote: Albert Hopkins wrote: I would think (not having looked) that the implementation of == would first check for identity (for performance reasons)... For some types, it may. I believe that string equality testing first tests whether the two strings are the same string, then

Re: Is there a better way of doing this?

2009-03-07 Thread Lie Ryan
mattia wrote: Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto: En Fri, 06 Mar 2009 21:31:01 -0200, mattia escribió: Thanks, I've found another solution here: http://www.obitko.com/tutorials/ genetic-algorithms/selection.php so here is my implementation: def get_fap(fitness

Re: "/a" is not "/a" ?

2009-03-08 Thread Lie Ryan
Mel wrote: wrote: Steven D'Aprano writes: It is never correct to avoid using "is" when you need to compare for identity. When is it ever necessary to compare for identity? Ho-hum. MUDD game. def broadcast (sender, message): for p in all_players: if p is not sender:

Re: "/a" is not "/a" ?

2009-03-08 Thread Lie Ryan
Robert Kern wrote: On 2009-03-07 08:14, Christian Heimes wrote: Steven D'Aprano wrote: Yes. Floating point NANs are required to compare unequal to all floats, including themselves. It's part of the IEEE standard. As far as I remember that's not correct. It's just the way C has interpreted the

Re: help with printing to stdout...

2009-03-08 Thread Lie Ryan
Chris Rebert wrote: On Sun, Mar 8, 2009 at 1:37 AM, Daniel Dalton wrote: Hi, I've got a program here that prints out a percentage of it's completion. Currently with my implimentation it prints like this: 0% 1% 2% 3% 4% etc taking up lots and lots of lines of output... So, how can I make it wr

Re: 2.6.1 - simple division

2009-03-08 Thread Lie Ryan
farsi...@gmail.com wrote: On Mar 8, 2:16 pm, farsi...@gmail.com wrote: 4 / 5.0 0.84 This one is a common FAQ. Basically floating point is never to be trusted. This issue is quite language agnostic, however some language decided to "hide" the issue, python does not. For more

Re: Callback from c thread with ctypes

2009-03-08 Thread Lie Ryan
Victor Lin wrote: On 3月8日, 下午9時56分, "Diez B. Roggisch" wrote: Victor Lin schrieb: Hi, I am going to develop a c library binding with ctypes. That c library will call callback from worker threads it created. Here comes the problem : Will the GIL be acquired before it goes into Python functio

Re: create boolean

2009-03-08 Thread Lie Ryan
Scott David Daniels wrote: Lie Ryan wrote: Fencer wrote: The literal translation of that would be: if n is not None and n != []: b = True else: b = False it is a bit verbose, so one might want to find something shorter b = True if n is not None and n != [] else False I always feel if

Re: 2.6.1 - simple division

2009-03-08 Thread Lie Ryan
Duncan Booth wrote: farsi...@gmail.com wrote: Thanks all, that's very helpful, sorry to waste your time with a common question. I have tried the decimal module and will definitely keep using it if I need to do this kind of calculation again. Try to remember though that the decimal module simp

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Lie Ryan
Hello, This is an idea about something I'd like to see implemented in python. I understand that's the purpose of PEPs, so I'll write it as a PEP, but send it here to receive your valuable feedback. Abstract This is a proposal to increase the richness of for loops, only to the extent that it

Re: Is python worth learning as a second language?

2009-03-09 Thread Lie Ryan
ZikO wrote: Hi I hope I won't sound trivial with asking my question. I am a C++ programmer and I am thinking of learning something else because I know second language might be very helpful somehow. I have heard a few positive things about Python but I have never writen any single line in pyt

Re: Is python worth learning as a second language?

2009-03-09 Thread Lie Ryan
Michele Simionato wrote: On Mar 9, 12:47 pm, Tim Wintle wrote: My slight issue with this list that I think things are in too many places. Yeah, that issue did pass through my head when I posted it, but I was too lazy to do proper listing of various language from various paradigms. I thoug

Re: Set & Frozenset?

2009-03-10 Thread Lie Ryan
Matt Nordhoff wrote: Alan G Isaac wrote: Hans Larsen schrieb: How could I "take" an elemment from a set or a frozenset On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote: You iterate over them. If you only want one value, use iter(the_set).next() I recall a claim that f

Re: Set & Frozenset?

2009-03-11 Thread Lie Ryan
R. David Murray wrote: Lie Ryan wrote: Matt Nordhoff wrote: Alan G Isaac wrote: Hans Larsen schrieb: How could I "take" an elemment from a set or a frozenset On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote: You iterate over them. If you only want one value

Re: functions - where to store them

2009-03-11 Thread Lie Ryan
plsulliv...@gmail.com wrote: I have several functions which I would like to store in a different directory so several programs can use them. I can't seem to find much information about how to call a function if the function code is not actually in the script itself. The problem: do I have to cut

Re: UnicodeEncode Error ?

2009-03-11 Thread Lie Ryan
Rama Vadakattu wrote: While doing the below 1) fetch html page 2) extract title using BeatifulSoup 3) Save into the database. iam getting the below error (at the bottom). Few observations which i had: 1) type of variable which holds this title is 2) iam getting this problem when th

Re: Why is lambda allowed as a key in a dict?

2009-03-11 Thread Lie Ryan
Terry Reedy wrote: r wrote: On Mar 11, 3:40 pm, Craig Allen wrote: On Mar 10, 1:39 pm, Paul Rubin wrote: Identical strings don't necessarily have the same id: A more verbose way to put this is "Requesting a string with a value that is the same an an existi

Re: unbiased benchmark

2009-03-12 Thread Lie Ryan
Martin P. Hellwig wrote: Philip Semanchuk wrote: On Mar 12, 2009, at 4:20 PM, Daniel Fetchinson wrote: Even more amazingly, it takes approximately 30% less time to say 'ruby' than to say 'python'!!! But "python" scores 55% more points than "ruby" in Scrabble, so that's understandable. It

Re: loop performance in global namespace (python-2.6.1)

2009-03-12 Thread Lie Ryan
John Machin wrote: On Mar 13, 2:41 am, spir wrote: Le Thu, 12 Mar 2009 11:13:33 -0400, Kent Johnson s'exprima ainsi: Because local name lookup is faster than global name lookup. Local variables are stored in an array in the stack frame and accessed by index. Global names are stored in a dict

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-12 Thread Lie Ryan
Hendrik van Rooyen wrote: "Ulrich Eckhardt" wrote: IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? Seriously, the problem I see with this proposal is that its aim to be as short as possible actually

Re: "import" not working?

2009-03-12 Thread Lie Ryan
Scott David Daniels wrote: Aahz wrote: In article , Rhodri James wrote: ... sys.path.append("C:\\DataFileTypes") My preference: sys.path.append(r"C:\DataFileTypes") This doesn't work if you need to add a trailing backslash, though. Also my preference (except, due to aging eyes and bad font

Re: __import__ with dict values

2009-03-12 Thread Lie Ryan
Gabriel Genellina wrote: En Thu, 12 Mar 2009 09:27:35 -0200, alex goretoy escribió: note i would still like to be able to do __import__("sys")."path" p = __import__("sys").path That's a convoluted way of doing: import sys p = sys.path (except that the latter one inserts "sys" in the curr

Re: Raw String Question

2009-03-13 Thread Lie Ryan
MRAB wrote: In Python 3.x a backslash doesn't have a special meaning in a raw string, except that it can prevent a following quote from ending the string, but the backslash is still included. Why? How useful is that? I think it would've been simpler if a backslash had _no_ special effect, not ev

Re: "import" not working?

2009-03-13 Thread Lie Ryan
Steve Holden wrote: Lie Ryan wrote: Scott David Daniels wrote: Aahz wrote: In article , Rhodri James wrote: ... sys.path.append("C:\\DataFileTypes") My preference: sys.path.append(r"C:\DataFileTypes") This doesn't work if you need to add a trailing backslash, th

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [andrew cooke] would it break anything to also allow format(1234567, 'd') # what we have now '1234567' format(1234567, '.d') # proposed new option '1.234.567' format(1234.5, ',2f') # proposed new option '1234,50' format(1234.5, '.,2f') # pr

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: Motivation: Provide a simple, non-locale aware way to format a number with a thousands separator. Adding thousands separators is one of the simplest ways to improve the professional appearance and readability of output exposed to end users. In

Re: __import__ with dict values

2009-03-13 Thread Lie Ryan
Gabriel Genellina wrote: En Fri, 13 Mar 2009 17:12:49 -0200, alex goretoy escribió: wow, ok, thank you Gabriel, I wasn't aware of x,'y',z This is what I decided to go with for now in one of my classes, but another class will need a modified version of this, as mentioned x,'y',z B=

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0: http://docs.python.org/library/string.html#formatspec ---

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [Lie Ryan] > In the finance world, output with commas is the norm. I can't cite any source, but I am skeptical with that. No doubt that you're skeptical of anything you didn't already know ;-) I'm a CPA, was a 15 year division contr

Re: String to sequence

2009-03-14 Thread Lie Ryan
mattia wrote: Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia : How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence: ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','S

Re: List the moduels of a package

2009-03-15 Thread Lie Ryan
mattia wrote: Hi all, how can I list the modules provided by a package? >>> import package >>> help(package) -- http://mail.python.org/mailman/listinfo/python-list

Re: WINXP vs. LINUX in threading.Thread

2009-04-22 Thread Lie Ryan
Diez B. Roggisch wrote: Kent schrieb: hello all, i want to add a "new update notification" feature to my wxPython appl. The codes below do the job. The logic is simple enough, I don't think it needs to be explained. since sometimes, under windows, proxy setting was a script. and was set in IE.

Re: can't find the right simplification

2009-04-23 Thread Lie Ryan
Stef Mientki wrote: hello, I've a program where you can connect snippets of code (which I call a "Brick") together to create a program. To make it easier to create these code snippets, I need some simplifications. For simple parameters ( integer, tupple, list etc) this works ok, and is done

Re: and [True,True] --> [True, True]?????

2009-04-23 Thread Lie Ryan
Steven D'Aprano wrote: On Mon, 20 Apr 2009 15:13:15 -0500, Grant Edwards wrote: I fail to see the difference between "length greater than 0" and "list is not empty". They are, by definition, the same thing, aren't they? For built-in lists, but not necessarily for arbitrary list-like sequenc

Re: and [True,True] --> [True, True]?????

2009-04-23 Thread Lie Ryan
Gerhard Häring wrote: len() make it clear that the argument is a sequence. Not necessarily. Classes that overrides __len__ may fool that assumption (well, in python classes that overrides special functions may do anything it is never intended to do). I often think an "if item:" as "is item

Re: Why bool( object )?

2009-04-27 Thread Lie Ryan
Aaron Brady wrote: What is the rationale for considering all instances true of a user- defined type? User-defined objects (or type) can override .__len__() [usually container types] or .__nonzero__() to make bool() returns False. Is it strictly a practical stipulation, or is there somethi

Re: Using ascii numbers in regular expression

2009-04-30 Thread Lie Ryan
MRAB wrote: You're almost there: re.subn('\x61','b','') or better yet: re.subn(r'\x61','b','') Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw string? -- http://mail.python.org/mailman/listinfo/python-list

Re: sorted() erraticly fails to sort string numbers

2009-04-30 Thread Lie Ryan
John Posner wrote: uuid wrote: I am at the same time impressed with the concise answer and disheartened by my inability to see this myself. My heartfelt thanks! Don't be disheartened! Many people -- myself included, absolutely! -- occasionally let a blind spot show in their messages to this li

Re: print(f) for files .. and is print % going away?

2009-04-30 Thread Lie Ryan
Esmail wrote: Hello all, I use the print method with % for formatting my output to the console since I am quite familiar with printf from my C days, and I like it quite well. There has never been print-with-formatting in python, what we have is the % string substitution operator, which is a s

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Lie Ryan
Lacrima wrote: class First: def __init__(self, *args, **kwargs): pass class Second: def __init__(self, somearg, *args, **kwargs): self.somearg = somearg How can I test that First class takes 1 required argument and Second class takes no require

Re: Self function

2009-05-06 Thread Lie Ryan
Luis Zarrabeitia wrote: Btw, is there any way to inject a name into a function's namespace? Following the python tradition, maybe we should try to create a more general solution! How about a mechanism to pass arguments that are optional to accept? So (in the general case) the caller can call a

Re: list comprehension question

2009-05-07 Thread Lie Ryan
Steven D'Aprano wrote: "If you’ve got the stomach for it, list comprehensions can be nested. They are a powerful tool but – like all powerful tools – they need to be used carefully, if at all." How does this discourage the use of list comprehensions? At most, it warns that complicated list com

Re: list comprehension question

2009-05-07 Thread Lie Ryan
Lie Ryan wrote: Steven D'Aprano wrote: "If you’ve got the stomach for it, list comprehensions can be nested. They are a powerful tool but – like all powerful tools – they need to be used carefully, if at all." How does this discourage the use of list comprehensions? At most,

Re: list comprehension question

2009-05-07 Thread Lie Ryan
Scott David Daniels wrote: John Posner wrote: Shane Geiger wrote: if type(el) == list or type(el) is tuple: A tiny improvement: if type(el) in (list, tuple): or (even better) if isinstance(el, (list, tuple)) However, it is my contention that you shouldn't be flattening by typ

Re: Logging exceptions to a file

2009-05-07 Thread Lie Ryan
Pierre GM wrote: All, I need to log messages to both the console and a given file. I use the following code (on Python 2.5) import logging # logging.basicConfig(level=logging.DEBUG,) logfile = logging.FileHandler('log.log') logfile.setLevel(level=logging.INFO) logging.getLogger('').addHandler(l

Re: Simple programme - Just want to know whether this is correct way of coding

2009-05-08 Thread Lie Ryan
guptha wrote: Hi group, This is my first programme in python ,I need to know whether my code is in the right path of performance I wrote a code using multithreading to send mails Can't you use BCC? The code Works fine ,but I doubt about the performance issue ,My intention is to send mails co

Re: I'm intrigued that Python has some functional constructions in the language.

2009-05-08 Thread Lie Ryan
Casey Hawthorne wrote: I'm intrigued that Python has some functional constructions in the language. Would it be possible to more clearly separate the pure code (without side effects) from the impure code (that deals with state changes, I/O, etc.), so that the pure code could be compiled and have

Re: itertools question

2009-05-14 Thread Lie Ryan
Neal Becker wrote: Is there any canned iterator adaptor that will transform: in = [1,2,3] into: out = [(1,2,3,4), (5,6,7,8),...] That is, each time next() is called, a tuple of the next N items is returned. An option, might be better since it handles infinite list correctly: >>>

Re: itertools question

2009-05-14 Thread Lie Ryan
Chris Rebert wrote: They really should just add grouper() to itertools rather than leaving it as a recipe. People keep asking for it so often... I've just added it to the issue tracker: http://bugs.python.org/issue6021 -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a Par construct to Python?

2009-05-21 Thread Lie Ryan
Carl Banks wrote: There must be another reason (i.e, the refcounts) to argue _for_ the GIL, Why? Nobody likes GIL, but it just have to be there or things starts crumbling... Nobody would actually argue _for_ GIL, they just know from experience, that people that successfully GIL in the past,

Re: Performance java vs. python

2009-05-21 Thread Lie Ryan
Sion Arrowsmith wrote: OTOH, I consider it a productive day if I end up with fewer lines of code than I started with. A friend once justified a negative LOC count as being the sign of a good day with the following observation: Code that doesn't exist contains no bugs. Code that doesn't exist t

Re: What is the difference between init and enter?

2009-05-26 Thread Lie Ryan
Diez B. Roggisch wrote: John wrote: I'm okay with init, but it seems to me that enter is redundant since it appears that anything you want to execute in enter can be done in init. About what are you talking? Diez Do you mean __init__ and __enter__? They are used for two completely diffe

Re: How to test python snippets in my documents?

2009-05-26 Thread Lie Ryan
Matthew Wilson wrote: I'm using a homemade script to verify some code samples in my documentation. Here it is: #! /usr/bin/env python2.6 # vim: set expandtab ts=4 sw=4 filetype=python: import doctest, os, sys def main(s): "Run doctest.testfile(s, None)" retur

Re: What text editor is everyone using for Python

2009-05-29 Thread Lie Ryan
norseman wrote: > jeffFromOz wrote: >> On May 26, 10:07 pm, Lacrima wrote: >>> I am new to python. >>> And now I am using trial version of Wing IDE. >>> But nobody mentioned it as a favourite editor. >>> So should I buy it when trial is expired or there are better choices? >> >> No one mentioned t

Re: How does Python's OOP feel?

2009-05-29 Thread Lie Ryan
Ikon wrote: > I'm rather new to Python. I have PHP for my main language and I do > some Java. They all have a very strict OO schema. As I red through > Python's tutorial it seams it has nothing of those rules. No statical, > abstract classes, functions, or variables. > > I wish someone, who has ex

Re: newbie: popen question

2009-05-29 Thread Lie Ryan
thebiggestbangthe...@gmail.com wrote: > On May 28, 5:31 am, Sebastian Wiesner wrote: >> >> >>> Your best bet is to make sudo not ask for a password. :) If you >>> don't have the rights, then you can use pexpect to do what you want to >>> do. http://pexpect.sourceforge.net/pexpect.html >>> See

Re: Class Methods help

2009-05-31 Thread Lie Ryan
bdsatish wrote: > Hi, > > I have a question regarding the difference b/w "class methods" and > "object methods". Consider for example: > > class MyClass: > x = 10 > > Now I can access MyClass.x -- I want a similar thing for functions. I > tried > > class MyClass: > def some_func(x

Re: Metaclass mystery

2009-06-01 Thread Lie Ryan
LittleGrasshopper wrote: > On May 31, 2:03 pm, a...@pythoncraft.com (Aahz) wrote: >> In article >> , >> >> LittleGrasshopper wrote: On May 31, 12:19=A0am, Arnaud Delobelle wrote: > [1]http://www.python.org/download/releases/2.2.3/descrintro/ >>> I'm about 2/3 of the way through this pa

Re: Challenge supporting custom deepcopy with inheritance

2009-06-02 Thread Lie Ryan
Gabriel Genellina wrote: > En Mon, 01 Jun 2009 14:19:19 -0300, Michael H. Goldwasser > escribió: > >> I can examine the inherited slots to see which special methods are >> there, and to implement my own __deepcopy__ accordingly. But to do >> so well seems to essentially require reimplementi

Re: Why date do not construct from date?

2009-06-02 Thread Lie Ryan
Gabriel Genellina wrote: > En Tue, 02 Jun 2009 03:14:22 -0300, Chris Rebert > escribió: > >> On Mon, Jun 1, 2009 at 10:25 PM, Alexandr N Zamaraev >> wrote: > >> import datetime as dt >> d = dt.date(2009, 10, 15) >> dt.date(d) >>> Traceback (most recent call last): >>> File "", line

Re: Why date do not construct from date?

2009-06-02 Thread Lie Ryan
Lie Ryan wrote: > Gabriel Genellina wrote: >> En Tue, 02 Jun 2009 03:14:22 -0300, Chris Rebert >> escribió: >> >>> On Mon, Jun 1, 2009 at 10:25 PM, Alexandr N Zamaraev >>> wrote: >>>>>>> import datetime as dt >>>>>>&

Re: Change PC to Win or Windows

2008-07-22 Thread Lie Ryan
On Mon, 2008-07-21 at 18:50 -0400, Derek Martin wrote: > On Mon, Jul 21, 2008 at 02:47:31PM -0700, Lie wrote: > > Common usage isn't always correct. > > Actually it is, inherently... When usage becomes common, the language > becomes redefined, and its correctness is the

Re: Insert character at a fixed position of lines

2008-07-26 Thread Lie Ryan
eferenced by f, i.e. "xxx.pdb". Btw, if you do f.write('line = line[:22] + "A" + line[23:]'), you'd output exactly that, and not inserting the 23rd character, you'd want to do this instead: f.write(line = line[:22] + "A" + line[23:]) > On Sat,

Re: What is not objects in Python?

2008-09-30 Thread Lie Ryan
On Mon, 2008-09-29 at 21:03 -0700, namekuseijin wrote: > On 28 set, 15:29, process <[EMAIL PROTECTED]> wrote: > > I have heard some criticism about Python, that it is not fully object- > > oriented. > > So what? > > > Why isn't len implemented as a str.len and list.len method instead of > > a len

Re: r""

2008-09-30 Thread Lie Ryan
On Tue, 30 Sep 2008 10:50:01 -0700, Kyle Hayes wrote: >> Please describe the actual problem you're trying to solve. In what way >> do slashes need to be "fixed," and why? > > Well, I have decided to build a tool to help us sync files in UNC paths. > I am just building the modules and classes righ

Re: [Tutor] Replacing cmd.exe with custom .py application

2008-09-30 Thread Lie Ryan
On Tue, 30 Sep 2008 15:09:06 -0400, Ezra Taylor wrote: > Is there something similar to /dev/null on Windows? I think it's called nul REM This is a batch file (.bat) echo "This won't show" > NUL I'm not sure how to use it in python though. -- http://mail.python.org/mailman/listinfo/python-list

Re: Output of pexpect

2008-10-01 Thread Lie Ryan
On Tue, 30 Sep 2008 20:48:12 -0700, Anh Khuong wrote: > I am using pexpect and I want to send output of pexpet to both stdout > and log file concurrently. Anybody know a solution for it please let me > know. One way is to create a file-like object that forked the output to stdout and the logfil

Re: ssh keepalive

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 00:30:59 -0700, loial wrote: > I have a problem with a ssh connection in python > > I get the error > > 'NoneType' object has no attribute 'exec_command' > > I am thinking that maybe the ssh connection is timeing out. > > Since I have no control over the configuration of th

Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 01:01:41 -0700, Phillip B Oldham wrote: > Are there any python event driven frameworks other than twisted? Most GUI package use event-driven model (e.g. Tkinter). -- http://mail.python.org/mailman/listinfo/python-list

Re: Tix: Windows XP: Problem - how to stop root window from popping up with Tix

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 11:33:59 +0100, dudeja.rajat wrote: > Hi, > > Im using Tix on widows XP and I've tried many ways to suppress the root > window. But so far I'm unable to do it. > > > Please suggest how can I suppress the root window. > > My code is as follows: > > import Tix > myRoot = Tix

Re: ssh keepalive

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:47:28 +, Marc 'BlackJack' Rintsch wrote: > On Wed, 01 Oct 2008 08:07:43 +, Lie Ryan wrote: > >>>>> a = [1, 3, 4, 2] >>>>> a = a.sort() >>>>> print a >> [None, None, None, None] > > *That* wou

Re: indirectly addressing vars in Python

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:53:08 -0400, Ross wrote: > Forgive my newbieness - I want to refer to some variables and indirectly > alter them. Not sure if this is as easy in Python as it is in C. > > Say I have three vars: oats, corn, barley > > I add them to a list: myList[{oats}, {peas}, {barley}

Re: text file

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 07:19:44 -0700, yqyq22 wrote: > My problem is how to translate this vbs in python: > > Dim fso > Dim strComputer > Set fso = CreateObject("Scripting.FileSystemObject") Set ElencoPC = > fso.OpenTextFile("elencoPC.txt" , 1, False) Do Until > ElencoPC.AtEndOfStream > strComputer =

Re: Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:46:33 -0400, Luis Zarrabeitia wrote: > Hi there. > > For most use cases I think about, the iterator protocol is more than > enough. However, on a few cases, I've needed some ugly hacks. > > Ex 1: > > a = iter([1,2,3,4,5]) # assume you got the iterator from a function and

Re: Isolated environment for execfile

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 11:11:29 +, Igor Kaplan wrote: > Hello python gurus. > > I got quite unusual problem and all my searches to find the answer on > my > own were not successful. > Here is the scenario: > I have the python program, let's call it script1.py, this program > needs to >

Re: parse a normal textfile

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 14:09:09 +0200, Tino Wildenhain wrote: > devi thapa wrote: >> hi all >> >>I have one normal text file. I need to parse the file, that >> too in an associative way . >> suppose that below is the normal textfile >> >> name='adf' >> id =1 >> value=344 >> >> > the

Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 18:09:20 +0200, Bruno Desthuilliers wrote: > Phillip B Oldham a écrit : >> On Oct 1, 4:12 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: >>> Please explain what you want to do. >> >> I'm primarily looking for alternatives to MVC frameworks for web >> development, particularly

Re: How to emit UTF-8 from console mode?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 08:17:15 -0700, Siegfried Heintze wrote: (snip) > The code was a little confusing because those two apostrophes look like > a double quote! Tips: use mono-spaced font. There is no ambiguity. (snip) > I think part of the problem is that Lucida Console is not as capable as

Re: string concatenate

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 09:41:57 -0700, sandric ionut wrote: > Hi: > > I have the following situation: >     nameAll = [] Here you defined nameAll as a list >     for i in range(1,10,1): That range is superfluous, you could write this instead[1]: for i in range(10): >     n = "name" + str([i])

Re: code critique requested - just 60 lines

2008-10-02 Thread Lie Ryan
On Thu, 02 Oct 2008 07:51:30 -0700, Terrence Brannon wrote: > Hi, I would like some feedback on how you would improve the following > program: > http://www.bitbucket.org/metaperl/ptc_math/src/21979c65074f/payout.py > > Basically, using non-strict dictionary keys can lead to bugs, so that > worrie

Re: windows help files ?

2008-10-02 Thread Lie Ryan
On Thu, 02 Oct 2008 17:13:50 +0200, Stef Mientki wrote: > Hello, > > I've 2 questions about python help files: Python help files or your program's help files? > 1. how can I launch the windows help file (CHM), from python with a > keyword as argument ? I'm not really sure, but isn't CHM obsol

Re: why? __builtins__ key added from eval

2008-10-02 Thread Lie Ryan
On Tue, 30 Sep 2008 16:04:34 -0500, William Purcell wrote: > I want to use eval to evaluate wx.TextCtrl inputs. How can I keep python > from adding the __builtins__ key to mydict when I use it with eval? > Other wise I have to __delitem__('__builtins__') everytime I use eval? > mydict = {'a'

Re: hex int and string

2009-11-27 Thread Lie Ryan
On 11/27/2009 8:28 PM, luca72 wrote: i'm using pyscard and for send a command he need a list like this: cmd = [0xdd,0xff, etc] the problem is that i get a text like dd and i need to trasform it in 0xdd for the list and if i use hex i have a sting that is not what i need >>> # Do you know th

Re: Feature request: String-inferred names

2009-11-28 Thread Lie Ryan
On 11/28/2009 3:08 PM, The Music Guy wrote: As for your code, I haven't seen it, so it would be hard for me to say exactly how the new syntax would come into play. What I can tell you, however, is that the parts of your code that would use it would probably be easier to read and change to anyone

Re: Some Basic questions on the use of CTRL and ALT Keys

2009-11-28 Thread Lie Ryan
On 11/28/2009 6:20 PM, joy99 wrote: I was writing a transliteration program from Bengali to English and vice versa. The program using Unicode chart is giving me perfect outputs in Bengali and vice versa with Bengali input -> English. I wanted to add some more power to the key board entry scheme,

Re: Feature request: String-inferred names

2009-11-28 Thread Lie Ryan
On 11/28/2009 10:38 PM, The Music Guy wrote: If you use it a lot, it is likely 1) you have abused class syntax for what should have been a dict or 2) what you need is to override __getattr__/__getattribute__ and __setattr__ Oh boy...here we go. :| ok, then what's your use case, AFAICT in the

Re: Python Programming Challenges for beginners?

2009-11-28 Thread Lie Ryan
On 11/28/2009 1:51 AM, n00m wrote: On Nov 27, 1:22 pm, Jon Clements wrote: Of course, if you take '~' literally (len(s)<= -10001) I reckon you've got way too many :) Jon. Then better: len(s)< abs(~1) PS It's a hard problem; so let's leave it alone I'm not going to write it, but I gue

Re: string payload expected: error

2009-11-29 Thread Lie Ryan
On 11/27/2009 8:43 PM, Ramdas wrote: I tried with MIMEBASE but it still fails.. I changed it to MIMEText, hoping that might trick __handletext to think its a string Anyway that also doesn't work. just pass the string directly to MIMEBase.set_payload: fp = open('...') msg1 = MIMEBase(maint

Re: mysqldb cursor returning type along with result ?

2009-11-29 Thread Lie Ryan
On 11/30/2009 12:14 AM, Paul O'Sullivan wrote: Just taken to Python (2.5)and started to look at some DB cursor stuff using MySQL. Anyway, after creating a query that in MySQL that has a result set of decimals I find that the cursor in python after a fetchall() returns a tuple that contains the f

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Lie Ryan
On 11/30/2009 1:25 AM, Russell Warren wrote: Maybe it's just that * is strictly for arguments, and trying it for generic tuple unpacking is abuse (which is down the corridor in 12A). Because (1, 2, *x) == (1, 2, 3, 4) is not tuple unpacking [!] Tuple unpacking is related with assignment, e.

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