Re: Why the nonsense number appears?

2005-10-31 Thread Dan Bishop
Steve Horsley wrote: > Ben O'Steen wrote: > > On Mon, October 31, 2005 10:23, Sybren Stuvel said: > >> Ben O'Steen enlightened us with: > >>> Using decimal as opposed to float sorts out this error as floats are > >>> not built to handle the size of number used here. > >> They can handle the size ju

Re: Most efficient way of storing 1024*1024 bits

2005-11-02 Thread Dan Bishop
Tor Erik Sønvisen wrote: > Hi > > I need a time and space efficient way of storing up to 6 million bits. The most space-efficient way of storing bits is to use the bitwise operators on an array of bytes: import array class BitList(object): def __init__(self, data=None): self._data = arr

Re: Floating numbers and str

2005-11-09 Thread Dan Bishop
Grant Edwards wrote: > On 2005-11-09, Tuvas <[EMAIL PROTECTED]> wrote: > > > I would like to limit a floating variable to 4 signifigant digits, when > > running thorugh a str command. > > Sorry, that's not possible. Technically, it is. >>> class Float4(float): ...def __str__(self): ...

Re: Underscores in Python numbers

2005-11-20 Thread Dan Bishop
Roy Smith wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > That's a tad unfair. Dealing with numeric literals with lots of digits is > > a real (if not earth-shattering) human interface problem: it is hard for > > people to parse long numeric strings. > > There are plenty of ways to make num

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Dan Bishop
Steve R. Hastings wrote: > I have been studying Python recently, and I read a comment on one > web page that said something like "the people using Python for heavy math > really wish they could define their own operators". The specific > example was to define an "outer product" operator for matric

Re: (newbie) N-uples from list of lists

2005-11-23 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > Hello, > > i think it could be done by using itertools functions even if i can not > see the trick. i would like to have all available "n-uples" from each > list of lists. > example for a list of 3 lists, but i should also be able to handle any > numbers of items (any len

Re: Death to tuples!

2005-11-27 Thread Dan Bishop
Mike Meyer wrote: > It seems that the distinction between tuples and lists has slowly been > fading away. What we call "tuple unpacking" works fine with lists on > either side of the assignment, and iterators on the values side. IIRC, > "apply" used to require that the second argument be a tuple; i

Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-04 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > I am trying to run an exe within a python script, but I'm having > trouble with spaces in the directory name. ... > So, it looks to me like the space in the path for the argument is > causing it to fail. Does anyone have any suggestions that could help > me out? Does C:

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: > > > [EMAIL PROTECTED] wrote: > > > > > and, as you just found out, a rather restrictive one > > > > > at that. > > > > > > > > In part because Python's designers failed to make "print" a function > > > > or provide

Re: Python riddle

2005-12-05 Thread Dan Bishop
kyle.tk wrote: > SPE - Stani's Python Editor wrote: > > I know that this code is nonsense, but why does this print 'Why?' > > > > a = 1 > > if a >2: > > try: > > 5/0 > > except: > > raise > > else: > > print 'why?' > > last time i checked this should print 'why?' > I hav

Re: new in programing

2005-12-09 Thread Dan Bishop
Cameron Laird wrote: ... > for hextuple in [(i, j, k, l, m, n) > for i in range(1, lim + 1) \ > for j in range (1, lim + 2) \ > for k in range (1, lim + 3) \ > for l in range (1, lim + 4) \ > for m in range (1, lim + 5) \ > for n in range (1,

Re: OT: spacing of code in Google Groups

2004-12-31 Thread Dan Bishop
M.E.Farmer wrote: > Grant Edwards wrote: > >Not sure what Google Groups does to it... > The usual... it mangles it. > I don't get it, Google uses Python too, they know it is whitespace > signifigant. And for a long time, Google groups postings *were* whitespace significant. But the new interface

Re: Calling Function Without Parentheses!

2005-01-02 Thread Dan Bishop
Kamilche wrote: > What a debug nightmare! I just spent HOURS running my script through > the debugger, sprinkling in log statements, and the like, tracking down > my problem. > > I called a function without the ending parentheses. I sure do WISH > Python would trap it when I try to do the following

Re: BASIC vs Python

2005-01-05 Thread Dan Bishop
Christos TZOTZIOY Georgiou wrote: > On 17 Dec 2004 15:53:51 -0800, rumours say that "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> might have written: > > >> The BASICs of my youth also supported graphics and sounds. > >> > >> PLAY "CGFED>CC > > >Now wait a minute, shouldn't that be... > > > >PLAY "CG

Re: Long strings as function parameters

2005-01-09 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > I would like to have functions that operate on long strings, 10-100 MB. > In C I would of course pass a pointer to the string for a quick > function call. What is an efficient way to do this in python? > Cheers, In Python, *every* expression is a pointer. This fact is

Re: else condition in list comprehension

2005-01-09 Thread Dan Bishop
Luis M. Gonzalez wrote: > Hi there, > > I'd like to know if there is a way to add and else condition into a > list comprehension. I'm sure that I read somewhere an easy way to do > it, but I forgot it and now I can't find it... > > for example: > z=[i+2 for i in range(10) if i%2==0] > what if I wan

Re: Python.org, Website of Satan

2005-01-13 Thread Dan Bishop
DogWalker wrote: > "Luis M. Gonzalez" <[EMAIL PROTECTED]> said: > > >[EMAIL PROTECTED] wrote: > >> python.org = 194.109.137.226 > >> > >> 194 + 109 + 137 + 226 = 666 > >> > >> What is this website with such a demonic name and IP address? What > >> evils are the programmers who use this language up

Re: why are some types immutable?

2005-01-16 Thread Dan Bishop
Roy Smith wrote: > Torsten Mohr <[EMAIL PROTECTED]> wrote: > > reading the documentation (and also from a hint from this NG) > > i know now that there are some types that are not mutable. > > > > But why is it this way? > > > > From an overhead point of view i think it is not optimal, > > for examp

Re: Integration with java

2005-01-18 Thread Dan Bishop
Istvan Albert wrote: > Joachim Boomberschloss wrote: > > > the code is already written in Python, using the > > standard libraries and several extension modules > > One thing to keep in mind is that Jython does not > integrate CPython, instead it "understands" python code > directly. So if you ha

Re: python/cgi/html bug

2005-01-18 Thread Dan Bishop
Dfenestr8 wrote: > Hi. > > I've written a cgi messageboard script in python, for an irc chan I happen > to frequent. > > Bear with me, it's hard for me to describe what the bug is. So I've > divided this post into two sections: HOW MY SCRIPTS WORKS, and WHAT THE > BUG IS. > ... > The problem is wh

Re: pure python code to do modular-arithmetic unit conversions?

2005-01-21 Thread Dan Bishop
Dan Stromberg wrote: > Is there already a pure python module that can do modular-arithmetic unit > conversions, like converting a huge number of seconds into months, > weeks... Use the divmod function. SECONDS_PER_MONTH = 2629746 # 1/4800 of 400 Gregorian years def convert_seconds(seconds): "R

Re: string.atoi and string.atol broken?

2005-01-25 Thread Dan Bishop
Peter Otten wrote: > Mike Moum wrote: > > > s.atoi('4',3) should result in 11 > > > > s.atoi('13',4) should result in 31 > > > > s.atoi('12',4) should result in 30 > > > > s.atoi('8',4) is legitimate, but it generates an error. > > > > Is this a bug, or am I missing something obvious? > > You and a

Re: Converting strings to dates

2005-02-04 Thread Dan Bishop
Chermside, Michael wrote: > I'm trying to convert a string back into a datetime.date. > > First I'll create the string: > > > Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import time, da

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread Dan Bishop
Brian van den Broek wrote: > Hi all, > > I guess it is more of a maths question than a programming one, but it > involves use of the decimal module, so here goes: > > As a self-directed learning exercise I've been working on a script to > convert numbers to arbitrary bases. It aims to take any of w

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread Dan Bishop
Devan L wrote: > Claiming that sum etc. do the same job is the whimper of > someone who doesn't want to openly disagree with Guido. > > Could you give an example where sum cannot do the job(besides the > previously mentioned product situation? Here's a couple of examples from my own code: # from

Re: Create datetime instance using a tuple.

2005-07-06 Thread Dan Bishop
Qiangning Hong wrote: > On 6 Jul 2005 02:01:55 -0700, Negroup <[EMAIL PROTECTED]> wrote: > > Hi, all. > > I would like to know if it is possible to create a datetime instance > > using a tuple instead of single values. > > > > I mean: > > >>> from datetime import datetime > > >>> t = (1, 2, 3) > >

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Dan Bishop
Devan L wrote: > > Here's a couple of examples from my own code: > > > > # from a Banzhaf Power Index calculator > > # adds things that aren't numbers > > return reduce(operator.add, > > (VoteDistributionTable({0: 1, v: 1}) for v in electoral_votes)) > > return sum([VoteDistributionTable({0:1,

Re: Inconsistency in hex()

2005-07-12 Thread Dan Bishop
Steven D'Aprano wrote: > hex() of an int appears to return lowercase hex digits, and hex() of a > long uppercase. > > >>> hex(75) > '0x4b' > >>> hex(75*256**4) > '0x4BL' > > By accident or design? Apart from the aesthetic value that lowercase hex > digits are ugly, should we care? > > It wo

Re: goto

2005-07-18 Thread Dan Bishop
rbt wrote: > On Mon, 2005-07-18 at 12:27 -0600, Steven Bethard wrote: > > Hayri ERDENER wrote: > > > what is the equivalent of C languages' goto statement in python? > > > > Download the goto module: > > http://www.entrian.com/goto/ > > And you can use goto to your heart's content. And to the

Re: consistency: extending arrays vs. multiplication ?

2005-07-23 Thread Dan Bishop
Soeren Sonnenburg wrote: > Hi all, > > Just having started with python, I feel that simple array operations '*' > and '+' don't do multiplication/addition but instead extend/join an > array: > > a=[1,2,3] > >>> b=[4,5,6] > >>> a+b > [1, 2, 3, 4, 5, 6] > > instead of what I would have expected: > [5

Re: Comparison of functions

2005-07-31 Thread Dan Bishop
Steven D'Aprano wrote: > On Sat, 30 Jul 2005 16:43:00 +, Adriano Varoli Piazza wrote: > > > If you want to treat numbers as strings, why not convert them before > > sorting them? > > Because that changes the object and throws away information. I think he meant doing something like ->>> lst =

Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Dan Bishop
Terry Reedy wrote: > "Daniel Schüle" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] ... > > unfortunately there is no arg method to get the angle > > of the complex number > > I agree that this is a deficiency. I would think .angle() should be a > no-param method like .conjugate(),

Re: Question About Logic In Python

2005-09-18 Thread Dan Bishop
James H. wrote: > Greetings! I'm new to Python and am struggling a little with "and" and > "or" logic in Python. Since Python always ends up returning a value > and this is a little different from C, the language I understand best > (i.e. C returns non-zero as true, and zero as false), is there a

Re: Questions about mathematical signs...

2005-02-06 Thread Dan Bishop
Jeff Epler wrote: > On Sun, Feb 06, 2005 at 12:26:30PM -0800, administrata wrote: > > Hi! I'm programming maths programs. > > And I got some questions about mathematical signs. ... > > 2. Inputing fractions like (a / b) + (c / d), It's tiring work too. > >Can it be simplified? > > Because of th

Re: negative integer division

2005-02-08 Thread Dan Bishop
Mark Jackson wrote: > Imbaud Pierre <[EMAIL PROTECTED]> writes: > > integer division and modulo gives different results in c and python, > > when negative numbers > > are involved. take gdb as a widely available c interpreter > > print -2 /3 > > 0 for c, -1 for python. > > more amazing, modulos o

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: 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: 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

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: 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: 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: 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

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: 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

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: 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

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

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: 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: 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

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: 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: 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

Re: Python Challenge ahead [NEW] for riddle lovers

2005-04-30 Thread Dan Bishop
darren kirby wrote: > quoth the Shane Hathaway: > > pythonchallenge wrote: > > > For the riddles' lovers among you, you are most invited to take part > > > in the Python Challenge, the first python programming riddle on the net. > > > > > > You are invited to take part in it at: > > > http://www.py

Re: double underscore attributes?

2005-12-10 Thread Dan Bishop
[EMAIL PROTECTED] wrote: ... > Every time I use dir(some module) I get a lot of attributes with double > underscore, for example __add__. Ok, I thought __add__ must be a method > which I can apply like this ... > I tried > >>> help(5.__add__) > > but got > SyntaxError: invalid syntax That's becaus

Re: Converting milliseconds to human time

2006-01-06 Thread Dan Bishop
Harlin Seritt wrote: > I would like to take milliseconds and convert it to a more > human-readable format like: > > 4 days 20 hours 10 minutes 35 seconds > > Is there something in the time module that can do this? I havent been > able to find anything that would do it. The datetime module has some

Re: On Numbers

2006-01-15 Thread Dan Bishop
Alex Martelli wrote: > Paul Rubin wrote: > > > Mike Meyer <[EMAIL PROTECTED]> writes: > > > I'd like to work on that. The idea would be that all the numeric types > > > are representations of reals with different properties that make them > > > appropriate for different u

Re: range() is not the best way to check range?

2006-07-17 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > it seems that range() can be really slow: ... > if i in range (0, 1): This creates a 10,000-element list and sequentially searches it. Of course that's gonna be slow. -- http://mail.python.org/mailman/listinfo/python-list

Re: question about what lamda does

2006-07-17 Thread Dan Bishop
[EMAIL PROTECTED] wrote: > Hey there, > i have been learning python for the past few months, but i can seem to > get what exactly a lamda is for. It defines a function. f = lambda x, y: expression is equivalent to def f(x, y): return expression Note that lambda is an expression while def is

Re: range() is not the best way to check range?

2006-07-17 Thread Dan Bishop
Leif K-Brooks wrote: > [EMAIL PROTECTED] wrote: > > or is there an alternative use of range() or something similar that can > > be as fast? > > You could use xrange: > > [EMAIL PROTECTED]:~$ python -m timeit -n1 "1 in range(1)" > 1 loops, best of 3: 260 usec per loop > [EMAIL PROTECTED]

Re: range() is not the best way to check range?

2006-07-18 Thread Dan Bishop
Paul Boddie wrote: > Yes, he wants range to return an iterator, just like xrange more or > less does now. Given that xrange objects support __getitem__, unlike a > lot of other iterators (and, of course, generators), adding > __contains__ wouldn't be much of a hardship. Certainly, compared to > ot

Re: range() is not the best way to check range?

2006-07-19 Thread Dan Bishop
Paul Boddie wrote: > John Machin wrote: > > On 19/07/2006 1:05 AM, Dan Bishop wrote: > > > > > > xrange already has __contains__. > > > > As pointed out previously, xrange is a function and one would not expect > > it to have a __contains__ meth

Re: what is the keyword "is" for?

2006-08-15 Thread Dan Bishop
Sybren Stuvel wrote [on the difference between is and ==]: > Obviously "a is b" implies "a == b", Not necessarily. >>> a = b = 1e1000 / 1e1000 >>> a is b True >>> a == b False -- http://mail.python.org/mailman/listinfo/python-list

Re: what is the keyword "is" for?

2006-08-15 Thread Dan Bishop
Steve Holden wrote: > daniel wrote: > > Martin v. Löwis wrote: > [...] > >>For some objects, "change the object" is impossible. If you have > >> > >>a = b = 3 > >> > >>then there is no way to change the object 3 to become 4 (say); > >>integer objects are "immutable". So for these, to make a change

Re: trouble using "\" as a string

2006-08-19 Thread Dan Bishop
OriginalBrownster wrote: > Hi there... > > I'm still pretty new to turbogears. but i have gotten pretty familiar > with it > > i'm just trying to clear something up, i'm having a difficult time > using \ when declaring a string expression > > such as tempname="\"..it says that the line is single qo

Re: Hands on Documentation for Python methods and Library

2006-10-04 Thread Dan Bishop
On Oct 4, 11:54 pm, Wijaya Edward <[EMAIL PROTECTED]> wrote: > Hi, > > One can do the following with Perl > > $ perldoc -f chomp > $ perldoc -f function_name > > or > > $ perldoc List::MoreUtils > $ perldoc Some::Module > > Can we do the same thing in Python? You can use the help() function at the

Re: printing variables

2006-10-05 Thread Dan Bishop
On Oct 5, 9:47 pm, [EMAIL PROTECTED] wrote: > hi > say i have variables like these > > var1 = "blah" > var2 = "blahblah" > var3 = "blahblahblah" > var4 = "" > var5 = "...".. > > bcos all the variable names start with "var", is there a way to > conveniently print those variables out... > eg prin

Re: Automatic import PEP

2006-10-06 Thread Dan Bishop
On Sep 22, 10:09 pm, Connelly Barnes <[EMAIL PROTECTED]> wrote: > Hi, > > I wrote the 'autoimp' module [1], which allows you to import lazy modules: > > from autoimp import * (Import lazy wrapper objects around all modules; > "lazy >modules" will turn into normal mo

Re: Dive Into Java?

2006-10-09 Thread Dan Bishop
On Oct 9, 11:40 am, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: ... > >> because [Java] wanted to be new and good but took over much of C++'s > >> syntax and made it even weirder, > > Even weirder? Care to explain?Example: > > int spam = 5; > > but > > String eggs = new

Re: Python is fun (useless social thread) ;-)

2006-06-15 Thread Dan Bishop
John Salerno wrote: > So out of curiosity, I'm just wondering how everyone else came to learn > [Python] I first heard about Python in the footnotes for Bruce Eckels' book "Thinking in Java", which I had bought for a Java course I took in 2000. Eventually, I decided to take a look at python.org,

Re: How to truncate/round-off decimal numbers?

2006-06-20 Thread Dan Bishop
MTD wrote: > > The system cannot > > accurately represent some integers, > > Er, I meant FLOATS. Doh. You were also right the first time. But it only applies to integers with more than 53 bits. -- http://mail.python.org/mailman/listinfo/python-list

Re: A critique of cgi.escape

2006-09-25 Thread Dan Bishop
Fredrik Lundh wrote: > Jon Ribbens wrote: > > > Making cgi.escape always escape the '"' character would not break > > anything, and would probably fix a few bugs in existing code. Yes, > > those bugs are not cgi.escape's fault, but that's no reason not to > > be helpful. It's a minor improvement wi

Re: A critique of cgi.escape

2006-09-26 Thread Dan Bishop
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Fredrik > Lundh wrote: > > > Max M wrote: > > > >> It also makes the escaped html harder to read for standard cases. > > > > and slows things down a bit. > > > > (cgi.escape(s, True) is slower than cgi.escape(s), for reasons that are > >

Re: does anybody earn a living programming in python?

2006-09-27 Thread Dan Bishop
Paul Boddie wrote: > George Sakkis wrote: > > [Oslo, Norway short of 300-500 Java developers] > > > Um, how many of these "lots of Java developers looking for work" live > > in, or are willing to relocate to, Oslo? > > Well, I really meant to say that the "lots of Java developers" I've > seen actua

Re: Resuming a program's execution after correcting error

2006-09-28 Thread Dan Bishop
Sheldon wrote: > Hi. > > Does anyone know if one can resume a python script at the error point > after the error is corrected? > I have a large program that take forever if I have to restart from > scratch everytime. The error was the data writing a file so it seemed > such a waste if all the data

Re: automatically grading small programming assignments

2006-12-14 Thread Dan Bishop
On Dec 14, 8:36 pm, Brian Blais <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: > > Then on your PC you can > >> run a script that loads each of such programs, and runs a good series > >> of tests, to test their quality... > > What happens if someone-- perhaps not

Re: Fall of Roman Empire

2006-12-24 Thread Dan Bishop
Dec 20, 10:36 am, Felix Benner <[EMAIL PROTECTED]> wrote: > static int main(int argc, char **argv) { > char *god_name; > if (argc) > god_name = argv[1]; > else > god_name = "YHWH"; > metaPower God = getGodByName(god_name); > u

Re: Iterate through list two items at a time

2007-01-02 Thread Dan Bishop
On Jan 2, 7:57 pm, "Dave Dean" <[EMAIL PROTECTED]> wrote: > Hi all, > I'm looking for a way to iterate through a list, two (or more) items at a > time. Basically... > > myList = [1,2,3,4,5,6] > > I'd like to be able to pull out two items at a time... def pair_list(list_): return [list_[i:

Re: pow() works but sqrt() not!?

2007-01-04 Thread Dan Bishop
On Jan 4, 10:00 am, "siggi" <[EMAIL PROTECTED]> wrote: > Thanks for that, too! > > Would be interesting to learn how these different algorithms [for pow] > influence the > precision of the result!? For an integer (i.e., int or long) x and a nonnegative integer y, x**y is exact: >>> 101 ** 12

Re: What is proper way to require a method to be overridden?

2007-01-04 Thread Dan Bishop
On Jan 4, 11:57 pm, belinda thom <[EMAIL PROTECTED]> wrote: ... > So, back to my question: is a catalog of standard python errors > available? I've looked on the python site but had no success. >>> [name for name in dir(__builtins__) if name.endswith('Error')] ['ArithmeticError', 'AssertionError',

Re: Dividing integers...Convert to float first?

2007-01-05 Thread Dan Bishop
On Jan 5, 11:47 am, Thomas Ploch <[EMAIL PROTECTED]> wrote: > Jonathan Smith schrieb: > > > Thomas Ploch wrote: > >> [EMAIL PROTECTED] schrieb: > >>> I'm still pretty new to Python. I'm writing a function that accepts > >>> thre integers as arguments. I need to divide the first integer by te > >>>

Re: Maths error

2007-01-08 Thread Dan Bishop
On Jan 8, 3:30 pm, Rory Campbell-Lange <[EMAIL PROTECTED]> wrote: > >>> (1.0/10.0) + (2.0/10.0) + (3.0/10.0) > 0.60009 > >>> 6.0/10.0 > 0.59998 > > Is using the decimal module the best way around this? (I'm expecting the first > sum to match the second). Probably not. Dec

  1   2   3   >