Re: Native MP3 Decoder?

2006-09-30 Thread MonkeeSage
[EMAIL PROTECTED] wrote: > If anyone knows of another project like this, an alternative that I > haven't found yet, or has experience in mp3 decoding, please respond > with your thoughts. There's pymad ( http://spacepants.org/src/pymad/ ); haven't tried but it should work everywhere libmad does.

Re: preemptive OOP?

2006-09-30 Thread MonkeeSage
John Salerno wrote: > LOL. Yeah, I guess so. I kind of expected the answer to be "yes, always > go with OOP in preparation for future expansion", but I should have > known that Python programmers would be a little more pragmatic than that. :) Depends on the design philosophy of a particular progra

Re: for: else: - any practical uses for the else clause?

2006-09-30 Thread MonkeeSage
BJörn Lindqvist wrote: > The code that you write in the positions A and B really are misplaced. > They arent part of the iteration of list. The two tasks, find item and > do something with item should be separated. I think it is useful to have them joined. Consider a contrived example: for i in (

Re: builtin regular expressions?

2006-09-30 Thread MonkeeSage
Roy Smith wrote: > More to the point: > > You can stick it in a bottle, you can hold it in your hand, AMEN! That's simply an implementation detail of perl regexps; it doesn't really address the issue. For example, in ruby a regexp is an object. Matches are also objects when one uses the String#mat

Re: changing numbers to spellings

2006-09-30 Thread MonkeeSage
[EMAIL PROTECTED] wrote: > Hey, > > Sorry to bother everybody again, but this group seems to have quite a > few knowledgeable people perusing it. Hi Tanner, I've seen a few of those people; but let a dummy (me) try to help. ;) As to the numbers to names question: do you need to know the names of

Re: builtin regular expressions?

2006-10-01 Thread MonkeeSage
Mirco Wahab wrote: > Therefore, I'd like to have a usable and understandable > example of Regex-object juggling, that shows clearly > what its real benefit is (or gives an idea of - ). Here are some benefits: DRY - You can assign a regexp to a variable and pass it around or call specific instance

Re: The Python world tries to be polite [formerly offensive to another language]

2006-10-01 Thread MonkeeSage
Ant wrote: > Don't think so, I followed the thread along a little, and it seems to > be correct. In addition, they seem to have the ¥ character as the Perl > 6 equivalent of zip(). Those crazy guys. Yup, I don't think it was a joke either; there are several other "hyper" operators already in pugs:

Re: The Python world tries to be polite [formerly offensive to another language]

2006-10-01 Thread MonkeeSage
Ant wrote: > Don't think so, I followed the thread along a little, and it seems to > be correct. In addition, they seem to have the ¥ character as the Perl > 6 equivalent of zip(). Those crazy guys. Yup, I don't think it was a joke either; there are several other "hyper" operators already in pugs:

Re: builtin regular expressions?

2006-10-01 Thread MonkeeSage
Max M wrote: > When I used to program in Perl I used regex' for lots of stuff. In > python I probably use them once every half year. I sinply do not need them. I think you can pretty much do it either way without any big benefits / losses. There are edge-cases that will break a praser just like th

Re: changing numbers to spellings

2006-10-01 Thread MonkeeSage
Tim Williams wrote: > my_nums = { 1 : 'One' , 2 : 'Two' , 3 : 'Three' , 4 : 'Four' } # etc etc > print my_nums[x] That's what I suggested, but since a list is already zero indexed I used that rather than a dictionary. And Paul Rubin posted a very nice solution that handles numbers larger than 9.

Re: Making sure script only runs once instance at a time.

2006-10-02 Thread MonkeeSage
Here's a class using Fredrik's suggestions to provide generic, cross-platform file locking (only tested on *nix however, with the two test files listed [i.e., run test1.py in one terminal then test2.py in another]): http://pastie.caboo.se/15851 Ps. The lockfile should also always be cleaned up (e

Re: Making sure script only runs once instance at a time.

2006-10-02 Thread MonkeeSage
Eric S. Johansson wrote: > the problem with this solution is that it does not handle the read > nonexclusive/write exclusive locking model. In this model, reads don't > block, they only register that the request is in process. writes lock > request block until all outstanding reads have completed

Re: I need Cryptogrphy in Python please .

2006-10-03 Thread MonkeeSage
NicolasG wrote: > I have installed .NET framework latest release. The SDK is different from the framework. ;) > Can some one guide me how to fix the problem above or point me to > another Cyrptography library that I can use easily ? Prebuilt binaries: http://www.voidspace.org.uk/python/modules.s

Re: I need Cryptogrphy in Python please .

2006-10-03 Thread MonkeeSage
NicolasG wrote: > I need the modules source to use it with my web server. I thought you were trying to compile and install the pyCrypto extension? If that is the case, then download the installer from the page I linked to. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Howto pass Array/Hash into Function

2006-10-03 Thread MonkeeSage
Wijaya Edward wrote: > I wonder how can that be done in Python. def myfunc(plain_var, hash_ref, arref): # Do sth with those variables return Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Howto pass Array/Hash into Function

2006-10-03 Thread MonkeeSage
Wildemar Wildenburger wrote: > MonkeeSage wrote: > > Wijaya Edward wrote: > >> I wonder how can that be done in Python. > > > > def myfunc(plain_var, hash_ref, arref): > > # Do sth with those variables > > return > > At the risk of being a je

Re: was python implemented as a object oriented langage at the beginning ?

2006-10-03 Thread MonkeeSage
Bertrand Ballis wrote: > I heard a lot of people from the Ruby community claiming that Python, like > Perl, was a scripting langage that was changed aftewards to be object > compatible, and that was making it not as good as Ruby, object-oriented > from the begenning. Sounds like a bunch of hooey

Re: Python GUI + OpenGL

2007-03-02 Thread MonkeeSage
On Mar 2, 9:17 am, Achim Domma <[EMAIL PROTECTED]> wrote: > I need a OpenGL context without restrictions and some settings dialogs. > Is wx + PyOpenGL the way to go? Or could somebody recommend a better set > of tools/libs? You could use pygtk + pygtkglext. http://pygtk.org/ http://gtkglext.sourc

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > Wouldn't that be just as slow? Well, I'm not sure about speed, but with the lambda you're creating a new callable for f every time you call sortMoves. Intuitively, that seems like it would be more of a hit than just doing a lookup

Re: class declaration shortcut

2007-03-02 Thread MonkeeSage
On Feb 28, 1:26 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > I've come across a code snippet in www.rubyclr.com where they show how > easy it is to declare a class compared to equivalent code in c#. > I wonder if there is any way to emulate this in Python. I posted like 10 minutes ago, but

Re: class declaration shortcut

2007-03-02 Thread MonkeeSage
On Mar 2, 5:48 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > Thanks for your detailed reply! > So after all, the www.rubyclr.com code is not a fair comparison. > Because the c# code shows a class definition, and the ruby code shows > a struct definition, which is not equivalent to a class. >

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > I guess the thing is that I'd have to create a new callable no matter > how, as it is the only way to bring the extra variables into the getValue > function when called by sort. Yes, but you don't have to create it every time you

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 7:34 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > Well, you'd have to define the function inside the sortMoves function, as > it is where the variables exists. Oh, sorry, I wasn't thinking there! Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: class attrdict

2007-03-02 Thread MonkeeSage
On Mar 2, 9:25 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > The problem is mostly that, given an instance a of attrdict, whether you > can call (e.g.) a.update(foo) depends on whether you ever set > a['update'], making the whole program extremely fragile -- a very high > price to pay for some mod

Re: print a ... z, A ... Z, "\n"' in Python

2007-03-03 Thread MonkeeSage
js wrote: > A way I came up with is the following, but I'm sure this is ugly. You could abuse __getitem__ (terribly, heh!) and use slice syntax... class crange(): def __init__(self): self.valid = range(47,58) + range(65,91) + range(97,123) def __getitem__(self, s): if is

Re: class attrdict

2007-03-03 Thread MonkeeSage
On Mar 3, 1:29 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > It would be nice, yes, weren't it for the inevitable irregularity, one > way or another, caused by the clash between attributes and items. In thinking about it, I think this might fall under 'we're all consenting adults here'. I mean, y

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
On Mar 3, 3:38 pm, Bart Van Loon <[EMAIL PROTECTED]> wrote: > I'm looking for a portable (FreeBSD and Linux) way of getting typical > ifconfig information into Python. Here's a pure python version of the C extension, based on the recipes you posted. In this version, the 'addr' key will not exist f

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
On Mar 3, 7:17 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > I'm pretty sure the offsets would be different for BSD Then again, mabye not. http://freebsd.active-venture.com/FreeBSD-srctree/newsrc/compat/linux/linux_ioctl.h.html Regards, Jordan -- http://mail.python.org

Re: class attrdict

2007-03-03 Thread MonkeeSage
On Mar 3, 7:54 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > Besides missing the warning in the __init__, this also has pretty weird > behavior whenever subject to a .pop, .update, .setdefault, del of either > item or attr, etc, etc: the attributes and items "get out of sync" (and, > catching each

Re: portable Python ifconfig

2007-03-03 Thread MonkeeSage
Bart, Can you try this and let us know if it works for FreeBSD? import socket, fcntl, struct def _ifinfo(sock, addr, ifname): iface = struct.pack('256s', ifname[:15]) info = fcntl.ioctl(sock.fileno(), addr, iface) if addr == 0x8927: hwaddr = [] for char in info[18:24

Re: pop method question

2007-03-03 Thread MonkeeSage
Nick, In regards to stack-like objects, pop() implies mutation of the reciever and returning the item 'popped' off the stack. The same _semantic_ meaning can be used for pop() regarding dictionaries, even though the _implementation_ would be different: dict.pop(key) mutates the reciever and return

Yet another string interpolation function...

2007-03-04 Thread MonkeeSage
There are several string interpolation functions, as well as string.Template. But here's yet another. This one emulates ruby's inline interpolation syntax (using #{}), which interpolates strings as well as expressions. NB. It uses eval(), so only use it in trusted contexts! import sys, re def inte

Re: Python 2.5 incompatible with Fedora Core 6 - packaging problems again

2007-03-04 Thread MonkeeSage
On Mar 4, 12:03 pm, John Nagle <[EMAIL PROTECTED]> wrote: > Exactly. As I've pointed out before, Python doesn't play well with > others. The Python developers pass the buck to the Linux packager, the > Linux packager passes the buck to the Python developers, and thus > the user experience suc

Re: Is every number in a list in a range?

2007-03-05 Thread MonkeeSage
On Mar 5, 1:03 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I have a list ll of intergers. I want to see if each number in ll is > within the range of 0..maxnum How about: maxnum = 100 inlist = range(90, 120) for i in [i for i in inlist if i >= 0 and i <= maxnum]: # do something with i, i

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-05 Thread MonkeeSage
Adam, Sounds like a nice idea to me. Pretty ingenious use of the zip/ bytecode headers and all too. Post a message when you release it please. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Squisher -- a lightweight, self-contained alternative to eggs?

2007-03-05 Thread MonkeeSage
Stef, What Adam is talking about has nothing to do with windows or *nix. He's talking about packing one or more .py files into a single archive, which can be imported just like the regular .py files. This means you can distribute a whole bunch of module files/dirs as a single .pyc file. It just ma

Re: Interface Implementation in Python

2007-03-05 Thread MonkeeSage
On Mar 5, 6:25 pm, [EMAIL PROTECTED] wrote: > Hi, > > I would like to know the interface concept in Python.How the > Interface is defined and implemented in Python?. > > How to access the interface fromn Client? > > Thanks > PSB Not sure exactly what you mean, but in python (like most dynamic lan

Re: Is every number in a list in a range?

2007-03-05 Thread MonkeeSage
On Mar 5, 7:24 pm, Paul Rubin wrote: > This genexp is better than a loop because it bails out immediately > if it finds an out-of-range x. That's true: assuming that input is sequential. But if it's farily random (e.g., [10, 20, 12, 46, 202, 5, 102]), then you need a loo

Re: Is every number in a list in a range?

2007-03-05 Thread MonkeeSage
On Mar 5, 9:03 pm, Paul Rubin wrote: > Maybe I didn't undrestand the question. Say maxnum is 30 in your > example above. Then as soon as 46 is seen, you can stop checking, I > thought. Yes, as long as 29 doesn't follow 46. inlist = [1, 5, 23, 46, 29, 21] If you want

Re: Is every number in a list in a range?

2007-03-05 Thread MonkeeSage
On Mar 5, 9:19 pm, Paul Rubin wrote: > OK, I didn't read the question that way. I thought the person just > wanted a yes or no answer to whether the list contained any elements > outside the desired range. If the purpose is to select the elements > in the range, then us

Re: how can I find out the value of an environment variable?

2007-03-05 Thread MonkeeSage
On Mar 5, 8:22 pm, "ken" <[EMAIL PROTECTED]> wrote: > how can I find out the value of an environment variable in my pythong > script? > > Thank you. RTFM... os.getenv http://docs.python.org/lib/os-procinfo.html Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: SPE python IDE: Call for testers!

2007-03-06 Thread MonkeeSage
Very nice. One issue I've come across is that it doesn't seem to work with < wxwidgets-2.8 (segfault when trying to load a file), so you should probably set MIN_WX_VERSION to 2.8. Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Interface Implementation in Python

2007-03-06 Thread MonkeeSage
On Mar 6, 6:23 pm, [EMAIL PROTECTED] wrote: > I dont want to expose the above Point3D implementation to the user / > client side.To achieve that we can use interface concept.In Python to > use interface concept. In python you would use name mangling to hide parts of the interface from the public.

Re: finding monitor or screen resolution in Linux with standard python module

2007-03-07 Thread MonkeeSage
On Mar 7, 4:25 am, "akbar" <[EMAIL PROTECTED]> wrote: > I googled and searched in archive. All I can find is finding > resolution with Tkinter and pygame. Any idea to find monitor > resolution with standard python module? > I can check from output of: xprop -root > _NET_DESKTOP_GEOMETRY(CARDINAL) .

Re: catching exceptions from an except: block

2007-03-07 Thread MonkeeSage
On Mar 7, 4:58 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >except_retry: # the missing(???) keyword you're after What is 'except_retry'? To the OP, with the loop and the callables you could also break out of the loop when the condition is met and use the else condition to raise the ex

Re: Where to "import"?

2007-03-08 Thread MonkeeSage
On Mar 8, 5:49 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> > >>1/ better to stick to naming conventions (class names in CamelCase) > > > Ok. Thanks. > > FWIW:http://www.python.org/dev/peps/pep-0008/ By my reading, PEP8 doesn't specify CamelCase as preferred over the other styles it mentions. non_c

Re: Where to "import"?

2007-03-08 Thread MonkeeSage
Disregard my last message, I'm stupid. I totally missed that Bruno was talking about classname. Bruno is exactly right. -- http://mail.python.org/mailman/listinfo/python-list

Re: I am a new guy on python world

2007-03-08 Thread MonkeeSage
Welcome. :) Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to "import"?

2007-03-08 Thread MonkeeSage
On Mar 8, 10:27 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Class names should be CamelCase. Read it again, and notice the difference > between a "Descriptive" section and a "Prescriptive" one. Yes, I misread Bruno's comment (missed that he was speaking of class names). Disregard my post.

Re: Help controlling CDROM from python

2007-03-10 Thread MonkeeSage
On Mar 10, 8:27 am, Ognjen Bezanov <[EMAIL PROTECTED]> wrote: > My issue is that I need to be able to eject the CDROM tray even if there > is no disk inside. Here's a Q&D version (haven't tested the windows part, it's from an old mailing list post, but it looks correct): import os, sys if 'win'

Re: number generator

2007-03-10 Thread MonkeeSage
On Mar 10, 3:16 am, greg <[EMAIL PROTECTED]> wrote: > Another possibility is to generate a list of N non-random > numbers that sum to M, and then adjust them up or down > by random amounts. By performing up/down adjustments in > pairs, you can maintain the sum invariant at each step. > So then it's

Re: number generator

2007-03-10 Thread MonkeeSage
On Mar 10, 6:47 pm, Paul Rubin wrote: > The fencepost method still seems to be simplest: > > t = sorted(random.sample(xrange(1,50), 4)) > print [(j-i) for i,j in zip([0]+t, t+[50])] Simpler, true, but I don't think it gives any better distribution... import rand

Re: Help controlling CDROM from python

2007-03-10 Thread MonkeeSage
On Mar 10, 4:11 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > win32file.CreateFile(r'\\.\\' + drive, GENERIC_READ, > FILE_SHARE_READ, > None, OPEN_EXISTING, 0, 0) Oops! That should have been: h = win32file.Create

Re: Python in a desktop environment

2007-03-10 Thread MonkeeSage
On Mar 10, 9:23 pm, "David Cramer" <[EMAIL PROTECTED]> wrote: > If you had an application that you were about to begin development on > which you wanted to be cross platform (at least Mac and Windows), > would you suggest using c++ and Python? Depending on what exactly you're trying to do, a pure

Re: minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread MonkeeSage
" "first person shooter" programming language " OMG! Thank's freakin awsome, lol!!! -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-10 Thread MonkeeSage
On Mar 10, 11:26 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > To compare to the "cheat" method, calculate the mean and standard > deviation of this sample, and compare to those from the other method. I belieive you (mainly because I'm too lazy to write the sieve, hehe). ;) Regards, Jordan --

Re: number generator

2007-03-11 Thread MonkeeSage
On Mar 11, 2:16 am, greg <[EMAIL PROTECTED]> wrote: > MonkeeSage wrote: > > this ... requires that M be evenly divisible by N, > > No, it doesn't -- I never said the numbers had > to be *equal*. Sorry for not being clear. I was refering to my specific implementat

Re: Single string print statements on multiple lines.

2007-03-12 Thread MonkeeSage
HeEm wrote: > In my 100 level CS course, I was asked to create multiple lines of > output within a single string. Of course I know how to: If this is for a CS course, you shouldn't really be cheating and asking for an answer here, should you? I mean, the whole point of taking (and paying for!) a

Yet another unique() function...

2007-02-27 Thread MonkeeSage
Here's yet another take on a unique() function for sequences. It's more terse than others I've seen and works for all the common use cases (please report any errors on the recipe page): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502263 Regards, Jordan -- http://mail.python.org/mail

Re: Yet another unique() function...

2007-02-27 Thread MonkeeSage
On Feb 27, 8:55 pm, Paul Rubin wrote: > Paul Rubin writes: > > def unique(seq, keepstr=True): > > t = type(seq) > > if t==str: > > t = (list, ''.join)[bool(keepstr)] > > seen = [] > > return t(c for c in seq if (c not in

Re: Yet another unique() function...

2007-02-27 Thread MonkeeSage
On Feb 27, 9:03 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > On Feb 27, 8:55 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > > > > > Paul Rubin <http://[EMAIL PROTECTED]> writes: > > > def unique(seq, keepstr=True): > > > t =

Re: Yet another unique() function...

2007-02-28 Thread MonkeeSage
On Feb 28, 2:18 pm, Paul Rubin wrote: > Unicode fix (untested): > > def unique(seq, keepstr=True): > t = type(seq) > if t in (unicode, str): > t = (list, t('').join)[bool(keepstr)] > seen = [] > return t(c for c in seq if not (c in seen or seen.app

Re: Yet another unique() function...

2007-02-28 Thread MonkeeSage
Paul, In your case optimized version, in the second try clause using itertools, it should be like this, shouldn't it? return t(g.next()[1] for k,g in groupby(s, lambda (i,v): v)) ^^^ Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuples vs Lists: Semantic difference (was: Extract String From Enclosing Tuple)

2007-03-01 Thread MonkeeSage
On Mar 1, 5:02 am, [EMAIL PROTECTED] wrote: > I don't know Ruby, but I think it allows such purposes with a freezing > function. In ruby all objects can be frozen (freeze is a method on Object, from which all other objects derive), not just Arrays (Arrays == lists in python; ruby has no built-in c

Re: Yet another unique() function...

2007-03-01 Thread MonkeeSage
On Feb 28, 3:46 pm, Paul Rubin wrote: > I didn't think so but I can't conveniently test it for now. Maybe > tonight. After playing with it a bit (only have 2.5 on this box), it looks like you do need to subscript the next() call. For example, the return from "unique( [[

Re: xml minidom redundant children??

2007-03-01 Thread MonkeeSage
On Mar 1, 12:46 pm, [EMAIL PROTECTED] wrote: > As a newbie, I'm trying to simply parse a xml file using minidom, but > I don't know why I get some extra children(?). I don't know what is > wrong in xml file, but I've tried different xml files, still same > problem. Most simply, if you need to stic

A proposal for attribute lookup failures

2007-11-17 Thread MonkeeSage
Proposal: When an attribute lookup fails for an object, check the top-level (and local scope?) for a corresponding function or attribute and apply it as the called attribute if found, drop through to the exception otherwise. This is just syntactic sugar. Example: a = [1,2,3] a.len() #

Re: A proposal for attribute lookup failures

2007-11-18 Thread MonkeeSage
On Nov 18, 5:27 am, James Stroud <[EMAIL PROTECTED]> wrote: > It would be unoriginal of me to suggest that this violates the explicit > is better than implicit maxim. But it does. That's what I meant about hiding the complexity of an attribute failure. Though, sometimes implicit is acceptable (e.

Re: A proposal for attribute lookup failures

2007-11-18 Thread MonkeeSage
Ps. Just for kicks, here is a simple ruby 1.8 mock-up of the proposal (sorry for using ruby, but I don't know enough C to start hacking the CPython backend; I think that a higher-level example is conceptually clearer anyhow). Reference cycles are not detected in the example. #!/usr/bin/ruby class

Re: A proposal for attribute lookup failures

2007-11-18 Thread MonkeeSage
On Nov 18, 5:59 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote: > No need to excuse. I think Ruby provides a nice context for discussing > the semantics of top level "open classes". But I think those are > entirely different than your contextual bindings. Note I find your > proposal somewhat confusing

Re: Simple eval

2007-11-18 Thread MonkeeSage
As I see it, just as a matter of common sense, there will be no way to match the performance of the backend eval() with any interpreted code. At best, performance-wise, a preprocessor for the built-in eval() would be in order, filtering out the "unsafe" cases and passing the rest through. But what

Re: regular expression

2007-11-18 Thread MonkeeSage
On Nov 18, 3:54 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > What the heck is that format? XML's retarded cousin living in the attic? ROFL...for some reason that makes me think of wierd Ed Edison from maniac mansion, heh ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python too complex ?!?!?!

2007-11-18 Thread MonkeeSage
On Nov 17, 7:46 am, Brian <[EMAIL PROTECTED]> wrote: > Had a unsettling conversation with a CS instructor that > teaches at local high schools and the community > college. This person is a long-term Linux/C/Python > programmer, but he claims that the install, config, and > library models for C# hav

Re: newbie Q: sequence membership

2007-11-18 Thread MonkeeSage
On Nov 19, 12:32 am, saccade <[EMAIL PROTECTED]> wrote: > I am not a programmer so I feel odd commenting about language design > decisions. When my Prof. introduced python the first question that > popped into mind was that since "x=9; y=9; print x is y and x == y" > prints "True" is there a way t

Re: eof

2007-11-23 Thread MonkeeSage
On Nov 22, 11:04 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > I think it's too low level, and so doesn't do what naive users > expect. It's really only useful, even in C, as part of the > forensic study of a stream in an error state, [...] Indeed. I just wrote a little implementation of an IPS p

Re: foldr function in Python

2007-11-23 Thread MonkeeSage
On Nov 23, 8:56 pm, MonkeeSage <[EMAIL PROTECTED]> wrote: > This doesn't matter for non-associative functions > like "+", but it does for associative functions like "-". Err...that's backwards...should have been: This doesn't matter for asso

Re: foldr function in Python

2007-11-23 Thread MonkeeSage
On Nov 23, 7:05 pm, greg <[EMAIL PROTECTED]> wrote: > My feeling is that Python shouldn't provide a bunch of > different versions of the same function that differ only in > the degree of currying. If you want a particular curried > combination, it's easy enough to create it as needed using > lambd

Re: Clean way to get one's network IP address?

2007-11-23 Thread MonkeeSage
k you. For linux (and possibly other POSIX-like OS', though reported not to work on FreeBSD), see the pure python 'ifconfig' script I posted here: http://groups.google.com/group/comp.lang.python/browse_thread/thread/52ad421ed64ec3fc/13e2a0609920c27b?lnk=gst&q=monkeesage+hwadd

Re: eof

2007-11-23 Thread MonkeeSage
On Nov 23, 10:43 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > This is not the same as ISO C. f.tell could be equal to > File.size(f.path) and eof could be false. An extra read() is required. My bad. As you might have surmised, I'm not a genius when it comes to C. I thought that the eof f

Re: eof

2007-11-23 Thread MonkeeSage
On Nov 23, 10:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Ruby doesn't have the good ol' eof. Good old eof tests a single flag > and requires a pre read(). Ruby's eof blocks and does buffering (and > this is a very strong technical statement). Actually, to be a bit more technical, IO

Re: eof

2007-11-23 Thread MonkeeSage
On Nov 23, 6:56 pm, greg <[EMAIL PROTECTED]> wrote: > By not providing an eof() function, C -- and Python -- make > it clear that testing for eof is not a passive operation. > It's always obvious what's going on, and it's much harder to > make mistakes like the above. err...C has feof() in stdio

Re: Disk Space Script

2007-11-24 Thread MonkeeSage
On Nov 24, 11:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I would like to write a script in Python to email me when disk space > gets below a certain value. OK, I'll give you the easy way using your example and popen, and then a more complex example that doesn't rely on df/grep/awk an

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread MonkeeSage
I use the following for a progam I wrote using sqlite, to ensure maximum compatibility (since the API is the same, importing them both as 'sqlite' should be fine): try: from sqlite3 import dbapi2 as sqlite # python 2.5 except: try: from pysqlite2 import dbapi2 as sqlite except: print

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread MonkeeSage
On Nov 24, 6:42 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > This has nothing, absolutely NOTHING, to do with memoization. Memoization > trades off memory for time, allowing slow functions to return results > faster at the cost of using more memory. The OP wants to save memo

Re: the annoying, verbose self

2007-11-25 Thread MonkeeSage
I like the explicit "self", personally. It helps distinguish class methods from functions. When I see a "self" I think "A-ha, a class method". Of course, I could tell that from just the indentation and following that back to the class declaration, but as a quick reference I find it helpful. Besides

Re: the annoying, verbose self

2007-11-25 Thread MonkeeSage
The issue of lexical scope still looms large on the horizon. How does one distinguish between attributes (as scoped by the "with" clause), local/global variables, and function/method calls? There doesn't seem to be an easy way. You'd need multiple passes over the data to determine various scopes --

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread MonkeeSage
On Nov 25, 3:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > MonkeeSage <[EMAIL PROTECTED]> wrote: > > I use the following for a progam I wrote using sqlite, to ensure > > maximum compatibility (since the API is the same, importing them both > > as &#x

Re: spawning a process with subprocess

2007-11-26 Thread MonkeeSage
Hi Brian, Couple of things. You should use poll() on the Popen instance, and should check it explicitly against None (since a 0 return code, meaning exit successfully, will be treated as a false condition the same as None). Also, in your second example, you block the program when you call readline

Re: the annoying, verbose self

2007-11-27 Thread MonkeeSage
On Nov 27, 3:20 am, Roy Smith <[EMAIL PROTECTED]> wrote: > If you want to have a little fun: > > class peverse: > def __call__(self): > raise AttributeError ("peverse instance has no __call__ method") > > x = peverse() > x() That is "peverse", but still... from types import FunctionT

Re: Find & Replace hyperlinks in a string

2007-11-27 Thread MonkeeSage
On Nov 27, 1:37 am, Nico Grubert <[EMAIL PROTECTED]> wrote: > Hi there, > > I have a string containing some hyperlinks. I'd like to replace every > hyperlink with a HTML style link. > > Example: > > Replace >'http://www.foo.com/any_url' > with >'http://www.foo.com/any_url";>http://

Re: spawning a process with subprocess

2007-11-27 Thread MonkeeSage
On Nov 27, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > MonkeeSage <[EMAIL PROTECTED]> wrote: > > Couple of things. You should use poll() on the Popen instance, and > > should check it explicitly against None (since a 0 return code, > > meaning exit s

Re: the annoying, verbose self

2007-11-27 Thread MonkeeSage
On Nov 27, 4:22 am, Bruno Desthuilliers > You don't have to subclass function to define a callable type that > implements the descriptor protocol so it behaves just like a function in > the context of an attribute lookup. I'm aware, and I understand that python's types (as with other duck- typed

Re: A bug in Python's regular expression engine?

2007-11-27 Thread MonkeeSage
On Nov 27, 10:19 am, "Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote: > That is funny. Thank you for your help... > Just for clarification, what does the "r" in your code do? It means a "raw" string (as you know ruby, think of it like %w{}): This page explains a

Re: A bug in Python's regular expression engine?

2007-11-27 Thread MonkeeSage
On Nov 27, 10:52 am, MonkeeSage <[EMAIL PROTECTED]> wrote: > On Nov 27, 10:19 am, "Just Another Victim of the Ambient Morality" > > <[EMAIL PROTECTED]> wrote: > > That is funny. Thank you for your help... > > Just for clarification, what does t

Re: How to Teach Python "Variables"

2007-11-27 Thread MonkeeSage
On Nov 27, 11:50 am, Donn Cave <[EMAIL PROTECTED]> wrote: > In contrast, I suspect that someone who learns Python concepts > in terms of explanations like `boxes' or `pointers' or whatnot > is at some disadvantage while that lasts, like translating a > foreign language to your own instead of attac

Re: How to Teach Python "Variables"

2007-11-27 Thread MonkeeSage
On Nov 27, 2:49 pm, Aaron Watters <[EMAIL PROTECTED]> wrote: > In practice there is too much to understand all at > once and in the beginning you have to say "don't worry about that > right now, consider it magic..." Of course they should > eventually understand it. Of course. But then it really

Re: How to Teach Python "Variables"

2007-11-28 Thread MonkeeSage
On Nov 28, 8:35 am, Aaron Watters <[EMAIL PROTECTED]> wrote: > On Nov 27, 5:31 pm, MonkeeSage <[EMAIL PROTECTED]> wrote: > > > Of course. But then it really depends on the teaching methodology, > > doesn't it? There is no reason (well, barring the restraints of

Re: reading raw variables from file

2007-11-30 Thread MonkeeSage
On Nov 30, 10:05 am, "Martin Blume" <[EMAIL PROTECTED]> wrote: > "Bruno Desthuilliers" schrieb > > > > > >> I have a file that might contain literal python > > >> variable statements at every line. For example > > >> the file info.dat looks like this: > > >> users = ["Bob", "Jane"] > > >> status =

Re: "Python" is not a good name, should rename to "Athon"

2007-12-01 Thread MonkeeSage
On Dec 1, 4:11 am, Bjoern Schliessmann wrote: > [EMAIL PROTECTED] wrote: > > New name "Pytn" may be better, do you think so ? > > No. How would you pronounce it? Pai-tn? > > Why don't you create a fork where the only difference is the name? > > Regards, > > Björn > > -- > BOFH excuse #194: > > We

Re: "Show this file in explorer"

2007-12-01 Thread MonkeeSage
On Dec 1, 2:58 pm, farsheed <[EMAIL PROTECTED]> wrote: > But now I have a more technical question. when I run this command, I > saw that the windows explorer did not refresh,example: I have two > files in a folder and i use that command to select them from command > line, the first one will be sel

<    1   2   3   >