Re: Style question for conditional execution

2010-11-24 Thread Asun Friere
On Nov 25, 7:43 am, Paul Rubin wrote: > Gerald Britton writes: > >     if v: > >         f() > > > I might, however, think more in a functional-programming direction. > > Then I might write: > > >     v and f() > > Python has conditional expressions.  The above would be: > >     f() if v else Non

Re: DTD Parsing

2010-11-10 Thread Asun Friere
On Nov 10, 5:00 pm, Stefan Behnel wrote: > Give lxml.objectify a try. It doesn't use DTDs, but does what you want. Yes I should take the time to familiarise myself with the lxml API in general. I mostly use libxml2 and libxslt nowadays. For simple stuff (like this) I use a StateParser which is

Re: DTD Parsing

2010-11-10 Thread Asun Friere
On Nov 10, 6:36 pm, Ian Kelly wrote: > That's five whole lines of code.  Why go to all that trouble when you > can just do this: > > import config > > I kid, but only partially.   For myself, generally because I only become aware of the module, or the module is only written after I written some

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 4:11 pm, Stefan Behnel wrote: > What's your interest in parsing a DTD if you're not up to validating XML? Spitting out boilerplate code. Just at the moment I'm creating a stub XSLT sheet, which creates a template per element (from a 3rd party DTD with 143 elements, yuk!) containing n

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 2:02 pm, Christian Heimes wrote: > Back to the initial question: I highly recommend LXML for any kind of > XML processing, validation, XPath etc. Sorry Christian, didn't realise at first that that was a response to MY intial question. But does lxml actually have something for parsing

Re: DTD Parsing

2010-11-09 Thread Asun Friere
On Nov 10, 2:02 pm, Christian Heimes wrote: > Am 10.11.2010 03:44, schrieb Felipe Bastos Nunes: > > > I'd like to know too. I work with java and jdom, but I'm doing > > personal things in python, and plan to go full python in the next 2 > > years. Xml is my first option for configuration files and

DTD Parsing

2010-11-09 Thread Asun Friere
Now that PyXML (and thus xmlproc) is defunct, does anyone know any handy modules (apart from re :) for parsing DTDs? -- http://mail.python.org/mailman/listinfo/python-list

Re: python command line manual

2010-05-24 Thread Asun Friere
On May 25, 8:52 am, Peng Yu wrote: > I mainly check online python manual. But I feel that it would be nice > if there is command line manual available (just like perl command line > manual). Could you please let me know if such command line manual > available? > > -- > Regards, > Peng It's not re

Re: enhancing 'list'

2010-01-17 Thread Asun Friere
On Jan 18, 9:37 am, samwyse wrote: > Consider this a wish list.  I know I'm unlikely to get any of these in > time for for my birthday, but still I felt the need to toss it out and > see what happens. > > Lately, I've slinging around a lot of lists, and there are some simple > things I'd like to d

Re: Apple Mac OS X 10.6 support & compatability with Python 3 ?

2009-12-16 Thread Asun Friere
On Dec 17, 4:41 am, pdlem...@earthlink.net wrote: > Does anyone have experience with OS X ? Could I use WConio in a > Windows emulator ?  I have no experience with MACs and am debating > whether to send this back before opening. You don't need an emulator per se. You can reboot a Mac into Window

Re: switch

2009-12-11 Thread Asun Friere
On Dec 11, 1:38 am, Tim Chase wrote: > It's clean if it were the solution to my problem Picking out that line first, just to be clear about this. You missed the disclaimer. This was never meant to be a solution to your problem. It was solution to the problem contained in the code you posted.

Re: switch

2009-12-10 Thread Asun Friere
On Dec 10, 6:57 am, Tim Chase wrote: > Carl Banks wrote: > > What if the object is a string you just read from a file? > > > How do you dispatch using polymorphism in that case? > > This is where I most miss a switch/case statement in Python...I > do lots of text-file processing (cellular provider

Re: switch

2009-12-10 Thread Asun Friere
On Dec 10, 2:00 pm, Carl Banks wrote: > On Dec 9, 5:02 pm, Asun Friere wrote: > > > On Dec 9, 7:08 pm, Carl Banks wrote: > > > > What if the object is a string you just read from a file? > > > > How do you dispatch using polymorphism in that case? > >

Re: switch

2009-12-09 Thread Asun Friere
On Dec 9, 7:08 pm, Carl Banks wrote: > What if the object is a string you just read from a file? > > How do you dispatch using polymorphism in that case? This would be a pertinent question, were I advocating that _all_ switch statements should, or even can, be replaced with "dispatch using polymo

Re: switch

2009-12-09 Thread Asun Friere
On Dec 9, 5:39 pm, Steven D'Aprano wrote: > On Tue, 08 Dec 2009 21:36:23 -0800, Asun Friere wrote: > > On Dec 9, 4:02 pm, Kee Nethery wrote: > >> I string together a bunch of elif statements to simulate a switch > > >> if foo == True: > >>         b

Re: switch

2009-12-08 Thread Asun Friere
On Dec 9, 5:12 pm, Steven D'Aprano wrote: > On Tue, 08 Dec 2009 21:02:44 -0800, Kee Nethery wrote: > > I string together a bunch of elif statements to simulate a switch > > > if foo == True: > >    blah > > elif bar == True: > >    blah blah > > elif bar == False: > >    blarg > > elif > > Ar

Re: switch

2009-12-08 Thread Asun Friere
On Dec 9, 4:02 pm, Kee Nethery wrote: > I string together a bunch of elif statements to simulate a switch > > if foo == True: >         blah > elif bar == True: >         blah blah > elif bar == False: >         blarg > elif This code is probably symptomatic of poor design. (Not to mention

Re: Evil trend report - cancelled

2009-09-07 Thread Asun Friere
On Sep 7, 1:07 pm, John Nagle wrote: > >     Accidentally posted a private e-mail.  Cancelled.  Sorry. > You think you can get out of it that easily? You've exposed yourself as an enemy of the Empire now! You'd better look over your shoulder for guys dressed in black cloaks breathing heavily ..

Re: Web Services examples using "raw" xml?

2009-08-24 Thread Asun Friere
On Aug 25, 5:41 am, John Gordon wrote: > >   File "/usr/lib/python2.3/site-packages/suds/client.py", line 59 >     @classmethod >     ^ > SyntaxError: invalid syntax > If memory serves me correctly, decorators were introduced in python2.4. That would account for your SyntaxError. -- http://mai

Re: hashability

2009-08-12 Thread Asun Friere
On Aug 12, 5:14 pm, Dennis Lee Bieber wrote: > c1 = C() > c2 = C() > > {c1:4}[c2] > > to behave? That IS the equivalent of your statement -- two instances are > two distinctly different entities... > Thankyou, that is EXACTLY the mistake I made that sent me off into lunacy. At the risk of furth

Re: hashability

2009-08-12 Thread Asun Friere
On Aug 12, 4:52 pm, James Stroud wrote: > Sorry for being a twit. Don't be ridiculous. You haven't been a twit, I have! I've just had a complete "blonde" moment here (with apologies to any real blondes out there. My only excuse is that I've been up to 02:30 for the last three nights running (

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 3:52 pm, Chris Rebert wrote: > Thought Experiment: > Consider, for each dict, the case of pickling it twice to 2 separate files. > When loaded from both files into the same program, the spam-ham dicts > will work as expected between each other. > The dicts with C()s will not. For examp

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 3:32 pm, James Stroud wrote: > You should be more imaginative. I'm by no means discounting that there might be some actual problem you're trying to solve here, but I honestly can't see it. There really is no need to get personal about this, so rather than asking for a level of imagin

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 12:15 pm, James Stroud wrote: > I realize I left out my use. The intent of the function is to flag > objects that will make useful keys for a persistent dictionary. The > {C():4}[C()] example demonstrates why I want to avoid certain types of > keys--I don't want users to do things like

Re: hashability

2009-08-11 Thread Asun Friere
On Aug 12, 10:54 am, James Stroud wrote: > I wrote the function to test hashability of arbitrary objects. My reason > is that the built-in python (2.5) hashing is too permissive for some > uses. A symptom of this permissiveness comes from the ability to > successfully hash() arbitrary objects: A

Re: Announcing PythonTurtle

2009-08-03 Thread Asun Friere
On Aug 4, 6:35 am, r wrote: [snip] > > I can remember the first time i used turtle (in python stdlib) and i > kept saying to myself... > >     "Were the heck is this damn turtle?!?!" (>_<) > > :-) In Python2.6, try this: >>> turtle.shape('turtle') -- http://mail.python.org/mailman/listinfo/py

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread Asun Friere
On Jul 16, 2:14 pm, alex23 wrote: ... > AND > you're citing back what I myself wrote in the link to which I also > referred the OP - whom (sic) has subsequently posted his success with this > technique - so I'm not really sure what the point is here other than > "if you have a different use case

Re: Can module tell if running from interpreter vs Windows command line ?

2009-07-15 Thread Asun Friere
On Jul 16, 10:47 am, alex23 wrote: ... > This older post should > help:http://groups.google.com/group/comp.lang.python/browse_frm/thread/6c5... > > But the quick answer is to import sys into your program, and do a test > on hasattr(sys, 'ps1'), which is only created when running the > interacti

Re: missing 'xor' Boolean operator

2009-07-15 Thread Asun Friere
On Jul 15, 5:44 pm, Mark Dickinson wrote: > On Jul 15, 5:07 am, "Dr. Phillip M. Feldman" > wrote: [snip] > >    for arg in args: > >       if bool(arg): result= not result > > It's more idiomatic to say "if arg: ..." rather than "if bool > (arg): ...". > Ah yes, but not once conditional tests,

Re: Clarity vs. code reuse/generality

2009-07-07 Thread Asun Friere
On Jul 7, 3:05 pm, Steven D'Aprano wrote: [snip] > Sense is, if you like, a "signed direction". Or to put it another way, in the graphical representation of a vector, 'direction' is the line, 'sense' is the arrowhead. -- http://mail.python.org/mailman/listinfo/python-list

Re: Good books in computer science?

2009-06-19 Thread Asun Friere
On Jun 15, 1:00 am, rustom wrote: > > For every one Horowitz there are a thousand wannbes thumping on the > piano trying to become Horowitz. > The traction that practice gives is maximal only in the beginning. Funny but I was watching an interview/conversation between and older composer and a you

Re: waling a directory with very many files

2009-06-17 Thread Asun Friere
On Jun 15, 6:35 am, Andre Engels wrote: > What kind of directories are those that just a list of files would > result in a "very large" object? I don't think I have ever seen > directories with more than a few thousand files... (a...@lucrezia:~/pit/lsa/act:5)$ ls -1 | wc -l 142607 There, you'

Re: Regarding Python is scripting language or not

2009-06-17 Thread Asun Friere
On Jun 18, 5:03 am, Terry Reedy wrote: > That depends on what you mean by 'put into classes' (and 'everything'). > > If you mean 'be an instance of a class', which I think is the most > natural reading, then Python *is* object-oriented and, if I understand > what I have read correctly (so that in

Re: newbie question

2008-11-27 Thread Asun Friere
On Nov 27, 9:05 pm, Bruno Desthuilliers wrote: > The problem is that you often have more to do in the __main__ section of > a script than just calling one simple function, and you don't > necessarily want to pollute the module's namespace with all this code. As I said, it's probably just me ;)

Re: newbie question

2008-11-26 Thread Asun Friere
On Nov 27, 6:11 am, Nan <[EMAIL PROTECTED]> wrote: > Hello, >    I just started to use Python. I wrote the following code and > expected 'main' would be called. > > def main(): >   print "hello" > > main Not an answer to your question, but I dislike functions named 'main' because the situation the

Re: import foo vs. python -m foo

2008-10-28 Thread Asun Friere
On Oct 29, 7:35 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > It probably contains buggy code inside "if __name__ == '__main__': ...". Or the code contains a run-time error? -- http://mail.python.org/mailman/listinfo/python-list

Re: Triple-quoted strings hath not the Python-nature

2008-10-21 Thread Asun Friere
That should be "Triple-quoted strings HAVE not the Python-nature." 'Hath' is the archaic 3rd person SINGULAR form of 'to have,' as in "a tripple-quoted string hath ..." -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with Iteration

2008-10-19 Thread Asun Friere
On Oct 20, 6:10 am, Aaron Brady <[EMAIL PROTECTED]> wrote: [snip] > If customers are stupid, should you sell stupid software? That's a hypothetical question with which we need never concern ourselves. After all, by definition customers are not stupid, but "always right." -- http://mail.python.

Re: OOP books?

2008-10-15 Thread Asun Friere
On Oct 16, 7:12 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: [snip] > Not a word about Python in it, > but:http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-... > > A must-read if you want to understand OO (MHO of course). Yes, if only to see how many of the design patt

Re: Wait or not?

2008-09-30 Thread Asun Friere
On Oct 1, 9:20 am, Eric <[EMAIL PROTECTED]> wrote: > I've been wanting to learn Python for a while now but I can't decide > on whether to wait for Python 3's final release and learn it or just > go ahead and learn 2.x. Would it be hard to make the transition being > a noob? If you only want to lea

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 11:57 am, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 24, 8:40 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > > ... I think > > your last version ('%d thing%s' % (i, 's' if i != 1 else ''

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 3:16 am, Pete Forman <[EMAIL PROTECTED]> wrote: > Asun Friere <[EMAIL PROTECTED]> writes: > > > A canonical use of the conditional operator is in > > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). &

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 3:16 am, Pete Forman <[EMAIL PROTECTED]> wrote: > Asun Friere <[EMAIL PROTECTED]> writes: > > > A canonical use of the conditional operator is in > > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). &

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 24, 9:52 am, Neal Becker <[EMAIL PROTECTED]> wrote: > In hindsight, I am disappointed with the choice of conditional syntax. I > know it's too late to change. The problem is > > y = some thing or other if x else something_else > > When scanning this my eye tends to see the first phrase an

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Asun Friere
On Sep 24, 8:10 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > Side note: > > sys.exit() is just another way to write raise SystemExit. The function > is defined as: > As can be seen if you were ever silly enough to call sys.exit() in IDLE. ;) -- http://mail.python.org/mailman/listinfo/python-

Re: Is 'x' an instance of a new-style class?

2008-09-16 Thread Asun Friere
On Sep 16, 8:05 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > "Gabriel Genellina" <[EMAIL PROTECTED]> writes: > > In Python you would write isinstance(x, object). > > It will return True for all Python objects (except perhaps those that > fiddle with metaclasses), not only for instances of new-sty

Re: lacking follow-through

2008-09-07 Thread Asun Friere
On Sep 8, 7:00 am, castironpi <[EMAIL PROTECTED]> wrote: > I am concerned by the lack of follow-through on some responses to > recent ideas I have described. Do I merely have a wrong understanding > of group policy? [snip] Perhaps the wrong idea of what the group is. I would have thought that i

Re: no string.downer() ?

2008-08-27 Thread Asun Friere
On Aug 28, 11:34 am, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 28, 11:25 am, Asun Friere <[EMAIL PROTECTED]> wrote: > > > On Aug 28, 10:28 am, John Machin <[EMAIL PROTECTED]> wrote: > > > > Out of the possible diagnoses (trolling, incredible stupidit

Re: no string.downer() ?

2008-08-27 Thread Asun Friere
On Aug 28, 10:28 am, John Machin <[EMAIL PROTECTED]> wrote: > Out of the possible diagnoses (trolling, incredible stupidity, feeble > joke attempt) of the cause of the ensuing upper/downer question, I'm > going with the third. Never ascribe to humour that which can be adequately explained by incr

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Asun Friere
On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: > Hi, > > Wouldn't it be nicer to have 'in' return values (or keys) for both > arrays and dictionaries. > NO! When you iterate over a list (or even a array) it is the members of the list in the order they appear that is of interest.

Re: Python does not get environment variable when using cron.

2008-08-18 Thread Asun Friere
On Aug 18, 11:17 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > > The easiest solution (in my opinion) is to write a bash script to > execute your Python script, and use that bash script to add those > environment variables. Agreed. Wrap it in a shell script, easier to read and grow than a on

Re: Python does not get environment variable when using cron.

2008-08-18 Thread Asun Friere
On Aug 19, 2:37 am, "Stephen Cattaneo" <[EMAIL PROTECTED]> wrote: > - What did you run in the cronjob to get back all those variables? > > set; echo "-"; echo "import os; print > os.environ" | python > > Cheers, > > S As I should have noted from $BASH_EXECUTION_STRING. I'd be hal

Re: Python does not get environment variable when using cron.

2008-08-17 Thread Asun Friere
On Aug 18, 11:15 am, "Stephen Cattaneo" <[EMAIL PROTECTED]> wrote: > Hello all, > > I am attempting to execute an automated test (written in Python) via > cron. I have to check the HOSTNAME variable as part of the test, oddly > under cron the HOSTNAME environment variable is not in the os.environ

Re: os.system question

2008-08-12 Thread Asun Friere
On Aug 13, 8:58 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 11 Aug 2008 19:28:13 -0700, Asun Friere wrote: > > > but if I was in a hurry to find out who I was I would be tempted still > > to use the deprecated "os.popen('whoami

Re: os.system question

2008-08-11 Thread Asun Friere
On Aug 8, 6:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Aug 6, 8:07 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: > > > >>> import os > > >>> foo = os.system('whoami') > > kevin > > >>> print foo > > 0 > > >>> > > > The standard output of the system command 'whoami' is my login name. Yet

Re: Function editing with Vim throws IndentError

2008-07-22 Thread Asun Friere
On Jul 23, 7:02 am, ptn <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I have a weird problem. Say I have a .py file with some functions in > it, like this: > > # (...) > def foo(): > print("bar") > > When I open it and add a line to one of the functions, > > # (...) > def

Re: singletons

2008-07-16 Thread Asun Friere
On Jul 17, 8:20 am, Craig Allen <[EMAIL PROTECTED]> wrote: > Is it pythonic? You probably can't get anymore pythonic than something written by the BDFL. In describing the use of __new__ in Unifying types and classes in Python 2.2 he gives this recipe for a Singleton. class Singleton(object):

Re: how to convert '8868' to u'\u8868'

2008-06-24 Thread Asun Friere
On Jun 25, 11:30 am, CodeHunter <[EMAIL PROTECTED]> wrote: > a = '8868' > b = u'\u8868' > > I want to convert a to b > > who can help me ? > > thank you very much! unicode(a) -- http://mail.python.org/mailman/listinfo/python-list

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

2008-06-17 Thread Asun Friere
On Jun 17, 5:33 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 17 Jun 2008 02:25:42 -0300, Lie <[EMAIL PROTECTED]> escribió: > > > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)' > > and 'not(id(a) == id(b))' > > No. ... > ... The above statement is not. A counter

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

2008-05-19 Thread Asun Friere
On May 20, 6:58 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 19 mai, 22:29, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > (snip) > > > The main > > concept here: identity [usually] implies equality, > > I really enjoyed the "usually" disclaimer !-) Well you have to be careful in case so

Re: Make Python create a tuple with one element in a clean way

2008-05-11 Thread Asun Friere
On May 11, 10:54 pm, [EMAIL PROTECTED] wrote: > To create a tuple with one element, you need to do this: > > >>> my_tuple = (1,)# Note the trailing comma after the value 1 > >>> type(my_tuple) > > > You needn't at all. You could simply do this: >>> your_tuple = 1, You see, it's not the par

Re: Python MIDI in 2008

2008-05-07 Thread Asun Friere
On May 6, 7:43 pm, Max M <[EMAIL PROTECTED]> wrote: > This is old in the sense that it has been a while since I wrote it. But > it is virtually bug free, so nothing much is happening. > > The midi standard does not change so there is no real reason to > change/upgrade it. Maybe you should add a m

Re: ROUNDING???

2008-02-18 Thread Asun Friere
On Feb 19, 2:05 pm, 7stud <[EMAIL PROTECTED]> wrote: > An integer divided by an integer produces an integer. In computer > programming, that's called 'integer arithmetic', and any fractional > part of the result is chopped off(not rounded). In case you care, the "chopped off" bit is given by the

Re: Seemingly odd 'is' comparison.

2008-02-18 Thread Asun Friere
On Feb 19, 1:45 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Asun Friere" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | The advice not to identity test strings and numbers (since they are > | interred in the main implemen

Re: Seemingly odd 'is' comparison.

2008-02-18 Thread Asun Friere
On Feb 19, 9:44 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Except for documented singletons such as modules and None, which objects > have the same identity is platform dependent, version dependent, and even > dependent on the execution history of your code. The advice no

Re: Seemingly odd 'is' comparison.

2008-02-18 Thread Asun Friere
On Feb 19, 12:27 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > But given the nature of immutables I meant to write "given the nature of mutables" of course ... :/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Double underscores -- ugly?

2008-02-18 Thread Asun Friere
benhoyt wrote: > Is it just me that thinks "__init__" is rather ugly? I used to hate looking at and having the type out all those underscores (surely two leading or one on either side would do?), but I've gotten so used to it by now the eyes don't see and the fingers work by themselves. > Not to

Re: Seemingly odd 'is' comparison.

2008-02-18 Thread Asun Friere
On Feb 19, 9:44 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Except for documented singletons such as modules and None, which objects > have the same identity is platform dependent, version dependent, and even > dependent on the execution history of your code. The advice no

Re: *Oven-roasted* garlic?

2008-02-12 Thread Asun Friere
On Feb 13, 12:31 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote: > *Oven-roasted* garlic? OK, that's just weird. Not weird -- delicious! Try doing it like this: Take a whole knob unpeeled dribble on some olive oil and black pepper and bake in a medium oven for 10-15 mins. Pull apart into individual

Re: Removing Pubic Hair Methods

2008-01-30 Thread Asun Friere
On Jan 31, 3:13 am, Steve Holden <[EMAIL PROTECTED]> wrote: > Wildemar Wildenburger wrote: > > Well, you never go wrong with apply(genital(), females), do you? Never?! class PowerSocket () : def __init__ (self, plug=female, active=False) : self.plug = plug self.active = active females

Re: Appropriate use of Property()

2008-01-30 Thread Asun Friere
On Jan 30, 5:03 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 29 ene, 23:17, [EMAIL PROTECTED] wrote: > > > Property() can be used to rid ourselves of the extra effort of using > > two different methods (getAttrib() setAttrib()) for access of an > > attribute without giving direct access to

Re: Removing objects

2008-01-22 Thread Asun Friere
On Jan 23, 6:16 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > >>> x.pop(x.index(c)) Umm, of course you would simply use x.remove(c) ... force of (bad) habit. %/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing objects

2008-01-22 Thread Asun Friere
On Jan 23, 5:59 pm, [EMAIL PROTECTED] wrote: > I am writing a game, and it must keep a list of objects. I've been > representing this as a list, but I need an object to be able to remove > itself. It doesn't know it's own index. If I tried to make each object > keep track of it's own index, it woul

Re: Python beginner!

2007-11-18 Thread Asun Friere
On Nov 17, 12:41 am, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > It is true that I could have been way more polite. I don't see how. You said "please" read it. You didn't make fun of the poor spelling and said nothing rude. I can't agree that the response "reeks of arrogance." I've seen

Re: Learning Python : >>> import math doesn't work ?

2007-11-18 Thread Asun Friere
On Nov 19, 3:46 pm, windspy <[EMAIL PROTECTED]> wrote: > use it like: x = math.sqrt (100) and math.sin(x) alternatively import like this: from math import sqrt, sin ... and use it like you have. -- http://mail.python.org/mailman/listinfo/python-list

Re: best way of dealing with currency?

2007-10-16 Thread Asun Friere
On Oct 17, 10:56 am, Mark Shroyer <[EMAIL PROTECTED]> wrote: > On 2007-10-16, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > The module decimal. But in the end, you might not be able to recreate > > the same values as excel, due to the unknown intricacies of excel. > > But it can be done! All it

Re: jack audio connection kit

2007-09-25 Thread Asun Friere
On Sep 26, 4:44 am, patrick <[EMAIL PROTECTED]> wrote: > hello everyone, > > is there a way to make python output audio in jack:http://jackaudio.org/ > > jack is the best audio solution for linux, mac and lately windows. i > found 1 project called pyjack, but the author remove the software from > h

Re: Sets in Python

2007-09-18 Thread Asun Friere
On Sep 19, 10:39 am, sapsi <[EMAIL PROTECTED]> wrote: > My question is, > 1) Why can't lists be hashed? They are mutable. -- http://mail.python.org/mailman/listinfo/python-list

Re: /dev/null as a file-like object, or logging to nothing

2007-09-10 Thread Asun Friere
On Sep 11, 10:22 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>, Sion Arrowsmith wrote: > > > Torsten Bronger <[EMAIL PROTECTED]> wrote: > > > Windows has a NUL: device which behaves like /dev/null . > > It's not a device, it's a reserve

Re: Python is overtaking Perl

2007-09-03 Thread Asun Friere
On Sep 4, 11:49 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Who knows? The graph has no labeling or calibration for the y-axis, so > it's meaningless. > Well yes, some calibration would make it more meaningful, but it is at least labeled 'Search Volume.' What's worse the calibration chang

Re: Python is overtaking Perl

2007-09-03 Thread Asun Friere
On Sep 4, 10:49 am, Sulsa <[EMAIL PROTECTED]> wrote: > On Tue, 04 Sep 2007 00:32:23 - > > Ben <[EMAIL PROTECTED]> wrote: > > Here are the statistics from Google Trends: > > >http://benyang22a.blogspot.com/2007/09/perl-vs-python.html > > This chart is showing that amount of python programers is

Re: Pythonic way of reading a textfile line by line without throwing an exception

2007-08-28 Thread Asun Friere
On Aug 29, 9:49 am, "Deivys Ramirez" <[EMAIL PROTECTED]> wrote: > What's the "pythonic" way of reading a text file, line by line, > without throwing an exception when there's nothing to be read? > > I've been trying to map my while(!eof(fp)) mindset to the file object > Python gives me when I call

Re: Newbee Question

2007-08-21 Thread Asun Friere
On Aug 21, 5:51 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > On Aug 21, 5:41 pm, Asun Friere <[EMAIL PROTECTED]> wrote:> over = > Decimal('1.40) > > oops, that should of course be: > over = Decimal('1.40') oh boy ... and it should also be normal =

Re: Newbee Question

2007-08-21 Thread Asun Friere
On Aug 21, 5:41 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > over = Decimal('1.40) oops, that should of course be: over = Decimal('1.40') -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbee Question

2007-08-21 Thread Asun Friere
Oh well since a few solutions have already been posted I thought I might add another, just so you at the very least you have to do some work making up your mind which one to choose. Using an incremental approach just to be different ... from decimal import Decimal normal = Decimal('0.04') over =

Re: str().join() isn't working

2007-08-20 Thread Asun Friere
On Aug 21, 4:34 am, [EMAIL PROTECTED] wrote: > to concatenate 2 lists to each other before it does the join, ... is > impossible in Python. The "+" operator is only for addition and for > two or more strings. Really? >>> [1,2,3] + [4,5,6] [1, 2, 3, 4, 5, 6] -- http://mail.python.org/mailman/lis

Re: Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-24 Thread Asun Friere
On Jul 25, 8:51 am, Boris Dušek <[EMAIL PROTECTED]> wrote: > In Python, I found that "file" objects exist. While specifying > argument types in Python is not possible as in Java, it is possible to > check whether an object is an instance of some class and that's what I > need - I need to check if

Re: In a dynamic language, why % operator asks user for type info?

2007-07-17 Thread Asun Friere
On Jul 17, 5:38 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > indeed anything which has an __int__ method may be > passed to the %d formatter: Anything?! Sorry to be persnickety here, but what about this: class C : def __int__ (self) : pass '%d' % C() or this: def foo (val) : return val foo

Re: In a dynamic language, why % operator asks user for type info?

2007-07-16 Thread Asun Friere
In practice the different placeholders give you a handle to achieve different formatting effects. Compare for example: for x in range(15) : print '%02d' % x against: for x in range(15) : print '%02s' % x #the '0' in this case being redundant Or again: from math import pi print '%.4f' %

Re: pattern match !

2007-07-15 Thread Asun Friere
On Jul 11, 9:29 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > import re > P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM') > S="hpsmh-1.1.1.2-0-RHEL3-Linux.RPM" > PO= P.match(S) > if PO : >print PO.group(1) Isn't a regexp overkill here when this will do: head = filename[:filename.index

Re: pattern match !

2007-07-10 Thread Asun Friere
On Jul 11, 1:40 pm, [EMAIL PROTECTED] wrote: > Extract the application name with version from an RPM string like > hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0 > from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3- > Linux.RPM. Now that list-like splicin

Re: Comparing modified elements in Sets

2007-07-10 Thread Asun Friere
On Jul 10, 5:57 am, [EMAIL PROTECTED] wrote: > I'd like to be able to compare set 1 with set 2 and have it match > filename1 and filename3, or compare set 1 with 3 and get back > filename1, filename2. etc. > > Is there a way for me to do this inside the compare function, rather > than having to ma

Re: Unable to strip \n characters

2007-05-23 Thread Asun Friere
On May 22, 6:37 am, aiwarrior <[EMAIL PROTECTED]> wrote: > On May 21, 7:05 am, Asun Friere <[EMAIL PROTECTED]> wrote: > > > On May 20, 10:49 pm, Michael Bentley <[EMAIL PROTECTED]> > > wrote: > > > > On May 20, 2007, at 7:41 AM, Michael Bentle

Re: howto check does module 'asdf' exist? (is available for import)

2007-05-22 Thread Asun Friere
On May 21, 11:17 pm, dmitrey <[EMAIL PROTECTED]> wrote: > howto check does module 'asdf' exist (is available for import) or no? try : import asdf del asdf except ImportError : print "module asdf not available" else : print "module asdf available for loading" You can generalise this, but at

Re: howto check does module 'asdf' exist? (is available for import)

2007-05-21 Thread Asun Friere
On May 21, 11:17 pm, dmitrey <[EMAIL PROTECTED]> wrote: > howto check does module 'asdf' exist (is available for import) or no? try : import asdf del asdf except ImportError : #do stuff ... > (without try/cache of course) Oops sorry, you didn't want it the obvious way ... but why ever not?

Re: Types in Python (was: managed lists?)

2007-05-21 Thread Asun Friere
On May 22, 10:28 am, Ben Finney <[EMAIL PROTECTED]> wrote: > "Jorgen Bodde" <[EMAIL PROTECTED]> writes: > > Right now i have a list in a class that I export as a member > > variable to the outside world, it is a standard list (e.g. [] ) but > > I wish to have a stronger type checking when adding ob

Re: Types in Python (was: managed lists?)

2007-05-21 Thread Asun Friere
On May 22, 10:28 am, Ben Finney <[EMAIL PROTECTED]> wrote: > "Jorgen Bodde" <[EMAIL PROTECTED]> writes: > > Right now i have a list in a class that I export as a member > > variable to the outside world, it is a standard list (e.g. [] ) but > > I wish to have a stronger type checking when adding ob

Re: Unable to strip \n characters

2007-05-20 Thread Asun Friere
On May 20, 10:49 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > On May 20, 2007, at 7:41 AM, Michael Bentley wrote: > > > (upload.strip()) > > Oops: (upload.strip(),) or upload.strip() Superfluous though the braces around your original were, it should still run ... ie. (a) == a -- http://mail.

Re: How do I count the number of spaces at the left end of a string?

2007-05-16 Thread Asun Friere
On May 17, 8:18 am, Steven Howe <[EMAIL PROTECTED]> wrote: > walterbyrd wrote: > > I don't know exactly what the first non-space character is. I know the > > first non-space character will be * or an alphanumeric character. > > using builtin function rindex But only if there is a guarantee that a

Re: How do I tell the difference between the end of a text file, and an empty line in a text file?

2007-05-16 Thread Asun Friere
On May 17, 7:47 am, walterbyrd <[EMAIL PROTECTED]> wrote: > Python's lack of an EOF character is giving me a hard time. The difference is simply that an empty line contains a '\n' while EOF does not. If you strip() your line before testing you will have trouble. But the minimal cases you post (p

  1   2   >