Re: newbie question

2005-02-09 Thread Dan Perl
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello All, > What is the python equivalent of the following statement? > > while (n--) Like other posters said, you should give more details with your question. What do you mean by equivalent? The following is *functionally* equival

Re: newbie question

2005-02-09 Thread Dan Perl
"Cameron Laird" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In article <[EMAIL PROTECTED]>, > Dan Perl <[EMAIL PROTECTED]> wrote: > . > . > . >>has the conciseness of the C statement. The pre- and post-increment >>and -de

Re: newbie question

2005-02-10 Thread Dan Perl
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: >> OTOH, I was thinking of saying in my previous posting that I prefer >> for n in range(start, 0, -1): >> to >> n = start >> while (n--

Re: goto, cls, wait commands

2005-02-11 Thread Dan Bishop
Harlin wrote: > No goto needed. If this makes no sense (which it may not if all you've > been exposed to is BASIC) it wouldn't be a bad idea to Google why you > should never use a goto statement. "GOTO" isn't even needed in QBasic (except for "ON ERROR GOTO"). -- http://mail.python.org/mailman/l

Re: Python in Makefile Question

2005-02-11 Thread Dan Bishop
Efrat Regev wrote: > Hello, > > I'd like to ask a question concerning a python script in a makefile. > Suppose I have a C++ project (sorry for raising this in a Python newsgroup), > with some makefile for it. Before compiling the code, I'd like to check that > there are no C++ convention violat

Re: check if object is number

2005-02-11 Thread Dan Bishop
Steven Bethard wrote: > Is there a good way to determine if an object is a numeric type? > Generally, I avoid type-checks in favor of try/except blocks, but I'm > not sure what to do in this case: > > def f(i): > ... > if x < i: > ... > > The problem is, no erro

Re: For American numbers

2005-02-13 Thread Dan Bishop
Nick Craig-Wood wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: > > Only for hard drive manufacturers, perhaps. > > > > For the rest of the computer world, unless I've missed > > a changing of the guard or something, "kilo" is 1024 > > and "mega" is 1024*1024 and so forth... > > Yes. Unless y

Re: more os.walk() issues... probably user error

2005-02-16 Thread Dan Perl
"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > rbt wrote: >> This function is intended to remove unwanted files and dirs from >> os.walk(). It will return correctly *IF* I leave the 'for fs in >> fs_objects' statement out (basically leave out the entire purpose of the >> f

Re: more os.walk() issues... probably user error

2005-02-16 Thread Dan Perl
"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def build_clean_list(self, path): > > file_skip_list = ['search_results.txt'] > dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] > > fs_objects = os.walk(path, topdown=True) > ## for fs

Re: os.walk()

2005-02-17 Thread Dan Perl
"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Could someone demonstrate the correct/proper way to use os.walk() to skip > certain files and folders while walking a specified path? I've read the > module docs and googled to no avail and posted here about other os.walk > is

Access to formatting controls from within __repr__ or __str__?

2005-02-17 Thread Dan Sommers
on of "set output format" methods is possible, but that solution makes me cringe. Thank you, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Never play leapfrog with a unicorn. -- http://mail.python.org/mailman/listinfo/python-list

Re: Access to formatting controls from within __repr__ or __str__?

2005-02-18 Thread Dan Sommers
On 18 Feb 2005 01:25:06 -0800, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> So my question is: Is there a way to pass options "through" a format >> string to the __str__ and __repr__ functions? For example, can I >>

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Dan Sommers
. My algorithm is less clear at first glance (and even second and third glance), but nearly idiomatic to those of us who spent lots of time writing embedded assembly code. If you have the space to spare, a lookup table (pre-calculated or created during your program's initial

Re: python2.4 generator expression > python2.3 list expression

2005-02-22 Thread Dan Sommers
the "+=" operator over those same bits again. Make that *three* sets of bits. I stand humbled. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to interrupt time.sleep ?

2005-02-22 Thread Dan Sommers
t; > If it can't be canceled what's the other solution to > "wait certain time/or press any button to continue" problem ? Use the select module. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Dynamically pass a function arguments from a dict

2005-02-23 Thread Dan Eloff
oo=''): print bar, zoo How can you determine that func2 will only accept bar and zoo, but not foo and call the function with bar as an argument? I know CherryPy does this, but it's not obvious from the source how they pulled it off. -Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically pass a function arguments from a dict

2005-02-23 Thread Dan Eloff
seems A good module (huge, very comprehensive) for this kinda thing can be found at: http://lfw.org/python/inspect.py Thanks very much! -Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: How Do I get Know What Attributes/Functions In A Class?

2005-02-23 Thread Dan Eloff
Use the dir() function dir(myClass) returns a list of strings -Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: rounding problem

2005-02-23 Thread Dan Bishop
tom wrote: > On Wed, 23 Feb 2005 19:04:47 -0600, Andy Leszczynski wrote: > > > It is on Windows, Linux, Python 2.3: > > > > [GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2 Type "help", > > "copyright", "credits" or "license" for more information. > > >>> a=1.1 > > >>> a > > 1.1

Re: wanted: C++ parser written in Python

2005-02-25 Thread dan . gass
rsion, but the area that you would be looking at is not changing so I would go ahead and download the latest that is there. TestGen can be found at sourceforge.net/projects/testgen Regards, Dan Gass -- http://mail.python.org/mailman/listinfo/python-list

netmask arithmetic?

2005-02-25 Thread Dan Stromberg
Before I go and reinvent the wheel, does anyone already have python code that can do netmask arithmetic - for example, determining if a list of hostnames are on subnets described by a list of networks+netmasks like: 128.200.34.0/24 128.195.16.128/25 ...and so on? Thanks! -- http://mail.python

psyco -and- python -O

2005-02-27 Thread Dan Stromberg
Is it useful to combine psyco with python -O, or do they conflict? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: accessor/mutator functions

2005-02-28 Thread Dan Sommers
27;s my basic thought process. Sorry about the rant. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: accessor/mutator functions

2005-02-28 Thread Dan Sommers
On Mon, 28 Feb 2005 23:08:04 GMT, Andrew Dalke <[EMAIL PROTECTED]> wrote: > On Mon, 28 Feb 2005 15:50:22 -0500, Dan Sommers wrote: >> The reason their code is so inflexible is that they've filled their >> classes with boiler plate get/set methods. >> >> Wh

Re: accessor/mutator functions

2005-02-28 Thread Dan Sommers
On Tue, 01 Mar 2005 01:39:13 +0100, Thomas Lotze <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> I think I'd add a change_temperature_to method that accepts the >> target temperature and some sort of timing information, depending on >> how the rest of the pro

Re: accessor/mutator functions

2005-02-28 Thread Dan Sommers
On Tue, 01 Mar 2005 02:27:03 GMT, Andrew Dalke <[EMAIL PROTECTED]> wrote: > Me: >>> What's wrong with the use of attributes in this case and how >>> would you write your interface? > Dan Sommers: >> I think I'd add a change_temperature_to method t

Re: accessor/mutator functions

2005-03-01 Thread Dan Sommers
On Tue, 01 Mar 2005 05:37:44 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: > Indeed, but it also comes down to control paradigm. I don't *know*, > but I'll make a guess that Dan, who admits to being "old school", > hasn't done a lot of work with GUIs, whic

Re: accessor/mutator functions

2005-03-01 Thread Dan Sommers
uld probably be done through a defined interface. I wish I'd said it that well in the first place myself. :-) Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: function with a state

2005-03-09 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > Xah Lee <[EMAIL PROTECTED]> wrote: > > > is it possible in Python to create a function that maintains a > > variable value? > > Yes. There's no concept of a 'static' function variable as such, but > there are many other ways to achieve the same thing. > > > globe=0; > > d

Re: Why is lower() deprecated and how should I replace it?

2005-03-13 Thread Dan Bishop
gf gf wrote: > I read that lower() is deprecated. Unfortunately, I > can't find the preferred way of lowercasing a string. > What is it? Instead of string.lower(s), use s.lower() -- http://mail.python.org/mailman/listinfo/python-list

[OT] Who Knows of a Good Computational Physics Textbook?

2005-03-13 Thread Dan Sommers
aspects of the course. If you know of some place I can go in order to find the right questions to ask (and possibly the right place to ask them!), then don't be afraid to let me know that, too. Thanks, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c =

Re: [OT] Who Knows of a Good Computational Physics Textbook?

2005-03-16 Thread Dan Sommers
Thank you beliavsky, Sean, and Scott for the pointers. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Dan Sommers
er came up. I'm not sure how to separate the two cases (accumulating scalars vs. accumulating a list), though. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Dan Sommers
On Sat, 19 Mar 2005 15:17:59 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > [Dan Sommers] >> Curious that in this lengthy discussion, a method name of >> "accumulate" never came up. I'm not sure how to separate the two >> cases (a

ANN: TestGen 0.05 C/C++ Test Generator Released

2004-11-29 Thread Dan Gass
TestGen 0.05 is now available and contains significant enhancements. What's New -- Significant Enhancements/Changes 1) added manipc.py, a generic C/C++ source manipulator that can be used for function/method isolation and stubbing for the purposes of unit testing with any test frame

Re: database questions ala newbie pythonist

2004-12-02 Thread Dan Sommers
theory, already been debugged). See also PEP 249, <http://www.python.org/peps/pep-0249.html>. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Never play leapfrog with a unicorn. -- http://mail.python.org/mailman/listinfo/python-list

inheritance problem with 2 cooperative methods

2004-12-02 Thread Dan Perl
like the idea of creating 2 methods in each class and I haven't been able to think of a way to solve the problem with just one change in the base class that would be inherited by all the subclasses. Anyone has any ideas? Thanks. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: inheritance problem with 2 cooperative methods

2004-12-02 Thread Dan Perl
Thank you very much, Greg, that does the job! Somehow I couldn't see it and I needed someone to point out to me. Dan "Greg Ewing" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: >> So far, so good! But let's assume that I want

Re: inheritance problem with 2 cooperative methods

2004-12-03 Thread Dan Perl
A == self.__class__: self.setConfig(config) I didn't like it though because it has to be done like this in every subclass's __init__. And it's a problem that I didn't realize at the time if a subclass just does not need to override __init__ (then the configuration is just not set)

Re: Need help on program!!!

2004-12-03 Thread Dan Perl
gram to do this, plz help!" To the OP: you can't seriously expect us to actually write the program for you, what kind of help are you looking for? Dan "Miklós P" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Seems very much like homework to me.

Re: Need help on program!!!

2004-12-03 Thread Dan Perl
t that he developed? Most of us here have been students (or still are) and may sympathize with the OP, but personally I have been also a TA so I have seen the other side and that's where my sympathy lies now. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help on program!!!

2004-12-03 Thread Dan Perl
"Miklós P" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > "Dan Perl" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> "Hopefully" for whom? For us, who may have to work with him someday or &

Re: Python-Help ( Mean,Median & Mode)

2004-12-05 Thread Dan Bishop
"Alfred Canoy" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Hello, > > I revised my source code. It was doing great but I'm having problem listing > all the numbers that I'd input. How can I input all the numbers that I > selected? The source code and the output below: > >

Re: dictionary initialization

2004-12-09 Thread Dan Perl
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi Dan > > I must confess that upon rereading my words, there is some irony there > (but not really sarcasm, is there?). However, I *really* tried to keep > my tone, well, professional. I realise I did

Re: results of division

2004-12-09 Thread Dan Bishop
Brad Tilley wrote: > Hello, > > What is the proper way to limit the results of division to only a few > spaces after the decimal? I don't need rocket-science like precision. > Here's an example: If your only complaint is that it's ugly to display 17 digits, then use the % operator to display how

Re: Persistent objects

2004-12-12 Thread Dan Perl
Then if you > exit the app and restart it later, there'd be a way to bring d back > into the process and have that Frob instance be there. I haven't used it myself, but this sounds to me a lot like metakit (http://www.equi4.com/metakit.html). Have you considered that and do

Re: from string to raw string

2004-12-15 Thread Dan Perl
ncode, and codecs in the library reference and I found out more about them. I'm sure it's going to be useful. Thanks! Dan "Scott David Daniels" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: >> Is there a way to convert a re

Re: Python IDE

2004-12-16 Thread Dan Perl
liberals" for our friends in the US. ;-) (for the sarcasm challenged) Dan "fuzzylollipop" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > no it was a sideways remark at all the software socialists that thing > EVERYTHING should be free, never said anything ab

Re: Python IDE

2004-12-16 Thread Dan Perl
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Dan Perl" <[EMAIL PROTECTED]> writes: > >> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> A: What's the m

Re: [OT] Python IDE

2004-12-17 Thread Dan Perl
"Fuzzyman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Dan Perl wrote: >> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > "Dan Perl" <[EMAIL PROTECTED]> writes: >

Re: BASIC vs Python

2004-12-17 Thread Dan Bishop
Peter Otten wrote: > Peter Hickman wrote: > > > Mike Meyer wrote: > >> BASIC as implented by Microsoft for the Apple II and the TRS 80 (among > >> others) is simply the worst programming language I have ever > >> encountered. Assembler was better - at least you had recursion with > >> assembler. >

Re: while 1 vs while True

2004-12-12 Thread Dan Bishop
Timothy Fitz wrote: > [ http://www.python.org/moin/PythonSpeed ] > "Starting with Py2.3, the interpreter optimizes 'while 1' to just a > single jump. In contrast "while True" takes several more steps. While > the latter is preferred for clarity, time-critical code should use the > first form." > >

Re: from string to raw string

2004-12-14 Thread Dan Perl
Yeah, you're right. I got it all twisted in my mind. It's late and I must be getting tired. Thanks. Dan "Brian Beck" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: >> Is there a way to convert a regular string to a raw st

from string to raw string

2004-12-14 Thread Dan Perl
;t see any utilities like that. So, any suggestions? Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE

2004-12-16 Thread Dan Perl
you couldn't see my warning sign for the sarcasm impaired? Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2004-12-19 Thread Dan Bishop
David Wurmfeld wrote: > I am new to python; any insight on the following would be appreciated, even > if it is the admonition to RTFM (as long as you can direct me to a relevant > FM) http://www.python.org/doc/ > Is there a standard approach to enumerated types? I could create a > dictionary with

Re: A rational proposal

2004-12-20 Thread Dan Bishop
Mike Meyer wrote: > "John Roth" <[EMAIL PROTECTED]> writes: > > > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> PEP: XXX > >> Title: A rational number module for Python ... > >> Rationals will mix with all other numeric types. When combined with an > >> integer

HTML purifier using BeautifulSoup?

2004-12-21 Thread Dan Stromberg
Has anyone tried to construct an HTML janitor script using BeautifulSoup? My situation: I'm trying to convert a series of web pages from .html to palmdoc format, using plucker, which is written in python. The plucker project suggests passing html through "tidy", to get well-formed html for pluc

Re: list Integer indexing dies??

2004-12-23 Thread Dan Bishop
Jeff Shannon wrote: > Ishwor wrote: > > >On Thu, 23 Dec 2004 13:33:16 -0300, Batista, Facundo > ><[EMAIL PROTECTED]> wrote: > > > > > >>[Ishwor] > >> > >>#- > What should 035[0] cough up? Be carefull it should > >>#- > >>#- >>>035[0] > >>#- 3 # my own opinion. > >> > >> > >why 3? The reason we get

Re: String backslash characters

2004-12-23 Thread Dan Bishop
PD wrote: > Hello, > > I am new to python, but i am quite curious about the following. > > suppose you had > > print '\378' > > which should not work because \377 is the max. then it displays two > characters (an 8 and a heart in my case...). What else does'nt quite > make sense is that if this is

Re: A Revised Rational Proposal

2004-12-26 Thread Dan Bishop
Mike Meyer wrote: > This version includes the input from various and sundry people. Thanks > to everyone who contributed. > > > PEP: XXX > Title: A rational number module for Python ... > Implicit Construction > - > > When combined with a floating type - either complex or fl

Re: A Revised Rational Proposal

2004-12-26 Thread Dan Bishop
Mike Meyer wrote: > This version includes the input from various and sundry people. Thanks > to everyone who contributed. > > > PEP: XXX > Title: A rational number module for Python ... > Implementation > == > > There is currently a rational module distributed with Python, and a >

Re: A Revised Rational Proposal

2004-12-26 Thread Dan Bishop
Dan Bishop wrote: > Mike Meyer wrote: > > This version includes the input from various and sundry people. > Thanks > > to everyone who contributed. > > > > > > > PEP: XXX > > Title: A rational number module for Python > ... > > Implemen

Re: A Revised Rational Proposal

2004-12-26 Thread Dan Bishop
Steven Bethard wrote: > Dan Bishop wrote: > > Mike Meyer wrote: > >> > >>PEP: XXX > > > > I'll be the first to volunteer an implementation. > > Very cool. Thanks for the quick work! > > For stdlib acceptance, I'd suggest a few

Re: embedding: forcing an interpreter to end

2004-12-26 Thread dan charnitsky
>> I may need to reconsider if Python is appropriate; >> the other possibiities are javascript or lua. > Lisp/Scheme? > (See http://tinyscheme.sourceforge.net/download.html Thanks for the pointer. After some preliminary evaluation, I'll probably try to move forward prototyping with Lua. I't look

Re: DB-API format string conventions

2004-12-28 Thread Dan Sommers
OH, I am a very big fan of the cohesion and layering concepts I learned from years and years of structured programming, and a lot of my ideas of what should be separate from what have fallen by the wayside. > So ... anybody for a DB-API 2.1 with mandatory pyformat support and

Re: ANN: IPython 0.6.5 is out

2004-12-28 Thread Dan Christensen
S at this moment). I've never been able to get color working when using ipython within emacs (21.3). I just see various control codes in the *Python Output* buffer. I'm using ipython 1.8, python-mode 4.69 from CVS and ansi-color 3.4.5. Any suggestions? Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-29 Thread Dan Sommers
tty sure that  and  were guillmots, but google sure > preferred the sea bird when I asked it. They're guillemets (with an "e"); this is a [relatively] well-known Adobe SNAFU. (A quick google search or two failed to find an authoritative reference, but I know that such references are o

Re: Python scope is too complicated

2005-03-20 Thread Dan Bishop
jfj wrote: > Max wrote: > > Yeah, I know. It's the price we pay for forsaking variable declarations. > > But for java programmers like me, Py's scoping is too complicated. > > Please explain what constitutes a block/namespace, and how to refer to > > variables outside of it. > > > Some may disagree

[Python-Announce] cfgparse v01_01 released

2005-03-23 Thread Dan Gass
enabled by default. + May be extended to support syntax such as XML. Enjoy, Dan Gass -- http://mail.python.org/mailman/listinfo/python-list

mime to text in python?

2005-03-24 Thread Dan Stromberg
I'm looking for a python program that can: 1) Convert mime to text 2) Is callable from a .procmailrc 3) Would at least keep pgp signed text, if not actually verify the signatures 4) It'd be beyond cool if it could also render .jpeg attachments as ANSI text graphics :) 5) Maybe even convert wo

Re: Version Number Comparison Function

2005-03-25 Thread Dan Sommers
>> '3.2.2' < '3.4' True >>> Beyond that, there seems to be sufficient variation between version number schemes, and something "interesting" often happens immediately before the final version (e.g. "1.0rc4" becomes "1.0"), that yo

Re: html tags and python

2005-03-25 Thread Dan Bishop
Kane wrote: > If I understand what you are asking then Python & CGI are a poor > solution. It would be easy to have one page ask for the month, click > submit, then have a second page ask for the exact date. Easy; but > terrible design. An improvement is to just have the dropdown listbox go from

Re: tree data structure

2005-03-25 Thread Dan Bishop
vivek khurana wrote: > Hi! all > > i am a new member on this list. I have to implement > tree data structure using python. How it can be done > in python. Is there an existing data structure which > can be used as tree? Tuples can be used as trees: you can let them represent (data, left_child, rig

Re: Little Q: how to print a variable's name, not its value?

2005-03-28 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > No doubt I've overlooked something obvious, but here goes: > > Let's say I assign a value to a var, e.g.: > myPlace = 'right here' > myTime = 'right now' > > Now let's say I want to print out the two vars, along with their names. > I could easily do this: > print "myPlac

Re: string goes away

2005-03-31 Thread Dan Christensen
ot;map(string.upper, slist)" 1000 loops, best of 3: 522 usec per loop $ /usr/lib/python2.4/timeit.py -s "slist=['aB'*100 for i in range(100)]" "[s.upper() for s in slist]" 1000 loops, best of 3: 461 usec per loop Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Combining digit in a list to make an integer

2005-04-01 Thread Dan Bishop
Harlin Seritt wrote: > I have the following: > > num1 = ['1', '4', '5'] > > How can I combine the elements in num1 to produce an integer 145? int(''.join(num1)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Combining digit in a list to make an integer

2005-04-01 Thread Dan Bishop
Harlin Seritt wrote: > If anyone has time, would you mind explaining the code that Dan Bishop > was so kind as to point out to me: > > int(''.join(num1)) > > This worked perfectly for me, however, I'm not sure that I understand > it very well. join(...) S.

Re: string goes away

2005-04-03 Thread Dan Bishop
John J. Lee wrote: > Duncan Booth <[EMAIL PROTECTED]> writes: > [...] > >str.join(sep, list_of_str) > [...] > > Doesn't work with unicode, IIRC. >>> u" ".join(["What's", "the", "problem?"]) u"What's the problem?" -- http://mail.python.org/mailman/listinfo/python-list

sparse sets of integers?

2005-04-04 Thread Dan Stromberg
Does anyone have a python implementation (or python C/C+ extension) that would allow me to perform set operations (union, intersection, difference, number of elements, &c) over very large collections of integers? Some of the sets may have over 10**11 (probably less than 10**13 though) integers in

Re: sorting a list and counting interchanges

2005-04-06 Thread Dan Bishop
Paul Rubin wrote: > John Machin <[EMAIL PROTECTED]> writes: ... > > 3. Of what practical use (or even esoteric academic interest) is the > > parity of the number of interchanges? > > It is of considerable interest in combinatorics. The group of even > permutations on N elements is called the alter

bourne shell parser in python

2005-04-07 Thread Dan Stromberg
Hi folks. We have a huge collection of sysadmin knowledge that's encoded in a vast array of bourne shell scripts. I'm now beginning to think that a transition to cfengine or similar might be a good idea, but I'm loathe to toss out all that /bin/sh code that's kept us from having to worry about n

Re: curious problem with large numbers

2005-04-08 Thread Dan Bishop
Chris Fonnesbeck wrote: > I have been developing a python module for Markov chain Monte Carlo > estimation, in which I frequently compare variable values with a very > large number, that I arbitrarily define as: > > inf = 1e1 Don't forget that you can write your own Infinity. (Warning: Buggy

Re: Are circular dependencies possible in Python?

2005-04-09 Thread Dan Sommers
d function > B could call function A - or is that not possible? Perhaps if you can post a minimal example that shows us what you're running into, someone here will know how to help. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a very specific type of embedded GUI kit

2005-04-12 Thread Dan Sommers
on/howto/curses/>. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dan Bishop
Dick Moores wrote: > I need to figure out how to compute pi to base 12, to as many digits as > possible. I found this reference, , > but I really don't understand it well enough. How many stars are in "*"? You probably answered "25".

Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dan Bishop
Dick Moores wrote: > Dan Bishop wrote at 04:07 4/13/2005: ... > >For a floating-point number x, the representation with d "decimal" > >places count be found by taking the representation of int(round(x * > >radix ** d)) and inserting a "." d places from

Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dan Bishop
Scott David Daniels wrote: > Roy Smith wrote: > > In article <[EMAIL PROTECTED]>, > > "Dan Bishop" <[EMAIL PROTECTED]> wrote: > > > >>But there's no reason other than tradition why you should arrange them > >>into groups of

Re: preallocate list

2005-04-13 Thread Dan Christensen
test.py > time1: 3.352000 > time2: 3.672000 If you use lst = range(10) or even better lst = [None]*10 then test1 is more than twice as fast as test2: time1: 2.437730 time2: 5.308054 (using python 2.4). Your code lst = [0 for i in range(10)] made python do an extra 10-iteration loop. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble using \ to escape %

2005-04-15 Thread Dan Bishop
Lucas Machado wrote: > I'm writing a python script that modifies the smb.conf file, and i need > to write the characters '%U' in the file. I tried making a string like > so: > > str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%U" % (list[0], list[1], > list[0], list[1]) > > but i keep getting: "TypeErro

terminal shutdown

2005-04-17 Thread Dan Richert
d be greatly greatly appreicated. thanks, dan -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: Veusz 0.5 - a scientific plotting package

2005-04-17 Thread Dan Christensen
splay and user-interfaces, and > numarray for handling the numeric data. Veusz is designed to produce > publication-ready Postscript output. Just curious how veusz compares to other python plotting libraries, such as matplotlib... Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Slight discrepancy with filecmp.cmp

2005-04-18 Thread Dan Sommers
out your wife's eyes debugging your brain, but since I would like to remain married, I will not make it. :-/ Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Îâ à Îâ à c = 1 -- http://mail.python.org/mailman/listinfo/python-list

To decode the Subject =?iso-8859-2?Q?=... in email in python

2005-04-20 Thread Dan Polansky
bject, returning a unicode string? The use would be like human_readable = cool_library.decode_equals(message['Subject']) Thank you, Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Why Python does *SLICING* the way it does??

2005-04-21 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > What languages besides Python use the Python slicing convention? Java uses it for the "substring" method of strings. > In C starting at > 0 may be justified because of the connection between array subscripting > and pointer arithmetic, but Python is a higher-level lang

Re: Why Python does *SLICING* the way it does??

2005-04-21 Thread Dan Bishop
Antoon Pardon wrote: > Op 2005-04-21, Steve Holden schreef <[EMAIL PROTECTED]>: > > [EMAIL PROTECTED] wrote: ... > >> Along the same lines, I think the REQUIREMENT that x[0] rather than > >> x[1] be the first element of list x is a mistake. At least the > >> programmer should have a choice, as in F

Re: To decode the Subject =?iso-8859-2?Q?=... in email in python

2005-04-22 Thread Dan Polansky
Max, thanks; that was helpful. Roman, your explanation was helpful as well. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Variables

2005-04-23 Thread Dan Bishop
Richard Blackwood wrote: > Steven Bethard wrote: > > > Richard Blackwood wrote: > > > >> Indeed, this language is math. My friend says that foo is a constant > >> and necessarily not a variable. If I had written foo = raw_input(), > >> he would say that foo is a variable. > > > > > > Then what does

Re: How to "generalize" a function?

2005-04-24 Thread Dan Sommers
hey may mean something to you and to people who read your program, but they mean nothing to Python. So just use generic names: for line in conf: if regex.search( line ) theLine = line theLineNum = conf.index( theLine ) etc. HTH, Dan -- Dan Sommers <http://www.to

Re: creating very small types

2005-04-27 Thread Dan Bishop
Michael Spencer wrote: > andrea wrote: > >>>I was thinking to code the huffman algorithm and trying to compress > >>>something with it, but I've got a problem. > >>>How can I represent for example a char with only 3 bits?? > > >>>I had a look to the compression modules but I can't understand them m

<    7   8   9   10   11   12   13   14   15   16   >