Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-16 Thread Andrew Koenig
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dave Hansen wrote: >> So lose the "if." >> >>R = C then A else B I think that part of the argument for the "A if C else B" syntax is that "then" is not currently a reserved word. -- http://mail.python.org/mailman

Re: wxPython Licence vs GPL

2005-11-23 Thread Andrew Koenig
"John Perks and Sarah Mount" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > we have some Python code we're planning to GPL. However, bits of it were > (This assumes the wxPython Licence is compatible with the GPL -- if not, > do we just cosmetically change any remaining lines, so n

Re: Which License Should I Use?

2005-11-27 Thread Andrew Koenig
"mojosam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I will be doing the bulk of the coding on my own time, because I need > to be able to take these tools with me when I change employers. > However, I'm sure that in the course of using these tools, I will need > to spend time

Re: Which license should I use?

2005-11-27 Thread Andrew Koenig
""Björn Lindström"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Mike Meyer <[EMAIL PROTECTED]> writes: > If they have the rights to the code, they can sell it, under the GPL or > any license of their choosing. In addition, if you GPL it, your employer > will be able to sell it,

Re: Which License Should I Use?

2005-11-27 Thread Andrew Koenig
"mojosam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would have to talk to a lawyer to be sure, but right now, I think I > can argue that anything I do on my own time belongs to me. I'm > technically a consultant right now (even though I'm spending 40 > hours/week with the o

Re: Which License Should I Use?

2005-11-27 Thread Andrew Koenig
"Robert Kern" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You're in something of a gray area, but one that has seen a lot of > litigation. Although you are "technically" a consultant, you are > probably considered an employee with regards to the "work made for hire" > doctrine.

Re: Which License Should I Use?

2005-11-29 Thread Andrew Koenig
"Robert Kern" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andrew Koenig wrote: >> I'm pretty sure that there was a change to the copyright laws a few years >> ago (perhaps as part of the DMCA), that made it clear that you own >> e

Re: Which License Should I Use?

2005-11-29 Thread Andrew Koenig
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Definitely not. The most recent change to the copyright laws made > works of music recorded to fullfill a contract "work for hire" by > default. If there's a contract -- i.e., a written agreement, then why does it matter?

Re: counting items

2005-01-12 Thread Andrew Koenig
"It's me" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What's the best way to count number of items in a list? > > For instance, > > a=[[1,2,4],4,5,[2,3]] > > I want to know how many items are there in a (answer should be 7 - I don't > want it to be 4) How about this? def t

Re: Adjusting the 1024 byte stdin buffer limit

2005-01-17 Thread Andrew Koenig
"brucoder" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Are there runtime settings that can be used to adjust the default 1024 > byte stdin buffer limit or a buildtime setting in pyconfig.h? I have a > need to pump this up to permit input of a large data block via stdin. What d

Re: a question

2005-01-19 Thread Andrew Koenig
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The error you get is NOT a syntax error: > > >>> cmd = '%s format %s \ > ... over %d lines' % ('my', 'string', 2) > >>> cmd > 'my format string over 2 lines' > >>> > > The interpreter is probably complaining because

Re: [OT] Good C++ book for a Python programmer

2005-01-19 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The 4th edition of the well-known "C++ Primer", with Moo as a new > co-author, will soon be published. It is a > more comprehensive and much longer book. It is also organized more traditionally than "Accelerated C++." "Accelerated C

Re: Zen of Python

2005-01-22 Thread Andrew Koenig
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > in some early C++ compilers, the scope for "x" was limited to the scope > containing the for loop, not the for loop itself. some commercial > compilers > still default to that behaviour. Indeed--and the standards com

Re: Zen of Python

2005-01-22 Thread Andrew Koenig
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > It's really irrelevant whether anyone is using a feature or not. If > the feature is documented as being available, it means that removing > it is an incompatible change that can break existing code which > current

Re: Zen of Python

2005-01-22 Thread Andrew Koenig
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > It's not obvious to me how the compiler can tell. Consider: > >x = 3 >if frob(): > frobbed = True > squares = [x*x for x in range(9)] >if blob(): > z = x > > Should the compiler issue

Re: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Andrew Koenig
"Ralf W. Grosse-Kunstleve" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >class grouping: > >def __init__(self, .x, .y, .z): ># real code right here > Emulation using existing syntax:: >def __init__(self, x, y, z): >self.x = x >

Re: breaking out of nested loop

2005-07-12 Thread Andrew Koenig
"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What is the appropriate way to break out of this while loop if the for > loop finds a match? Make it a function and use a "return" statement to break out. -- http://mail.python.org/mailman/listinfo/python-list

Re: iterative lambda construction

2005-02-21 Thread Andrew Koenig
"markscottwright" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Just for the hell of it, I've been going through the old Scheme-based > textbook "Structure and Interpretation of Computer Programs" and seeing > what I can and can't do with python. I'm trying to create a function >

Re: function with a state

2005-03-06 Thread Andrew Koenig
"Xah Lee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > globe=0; > def myFun(): > globe=globe+1 > return globe > > apparently it can't be done like that. I thought it can probably be > done by prefixing the variable with some package context... You can do this: globe=0

Re: how to drop all thread ??

2004-11-29 Thread Andrew Koenig
This reply is off topic but I couldn't resist: The best way to get rid of thread is to adopt a kitten. In fact, one of my cats is named Snobol because she is such a good string manipulator. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help With Hiring Python Developers

2004-12-06 Thread Andrew Koenig
"Aahz" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > APL. I've heard programmers making similar comments (including possibly > Michael's nameless acquaintance). Especially programmers who've never used it. To me, grousing about APL's unusual character set sounds a lot like grou

MIDI library recommendations, please?

2004-12-20 Thread Andrew Koenig
Are there widely used and recommended Python libraries that will let me 1) Interpret and generate MIDI messages easily? 2) Allow me to select and communicate with MIDI devices attached to my computer? I know that (2) is platform-dependent, so if there isn't a multiplatform version of (

Re: objects as mutable dictionary keys

2004-12-27 Thread Andrew Koenig
"Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This strikes me because if one can do this with instances of user > defined classes why not with lists? Trying to use lists as dict > keys yields "TypeError: list objects are unhashable". So why are > list objects unhashab

Re: objects as mutable dictionary keys

2004-12-27 Thread Andrew Koenig
"Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This leads to the question: > > Why does (t1 == t2 => d[t1] identical to d[t2]) hold for user defined > objects and not for lists? My answer: because the cmp function looks at > id() for user defined objects and at list co

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Andrew Koenig
"Jordan Rastrick" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def combineIntoRecord(): # This is an acceptor function > optionalline = None # We may not get given a value for this line > accept firstline > accept secondline > if condition(secondline): >

Re: Suggesting a new feature - "Inverse Generators"

2005-03-26 Thread Andrew Koenig
"Jordan Rastrick" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > But I'm not so much interested in alternate solutions to the problem > itself, which is to be honest trivial. I'm intereseted in the > implications of the imaginary solution of the Acceptor function. Of course. But

Stylistic question about inheritance

2005-03-31 Thread Andrew Koenig
Suppose I want to define a class hierarchy that represents expressions, for use in a compiler or something similar. We might imagine various kinds of expressions, classified by their top-level operator (if any). So, an expression might be a primary (which, in turn, might be a variable or a con

Re: Stylistic question about inheritance

2005-03-31 Thread Andrew Koenig
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Well, Python seems to get along fine without the ability to do > isinstance(foo,file_like_object); probably better off in the end for > it. So I'd say you should generally not do it. Inheritence is for > when different c

Re: Stylistic question about inheritance

2005-03-31 Thread Andrew Koenig
""Martin v. Löwis"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > You would normally try to avoid type queries, and rely on virtual > methods instead, if possible. Of course. > It seems likely for the application > that code can be shared across different subclasses, for example

Re: Stylistic question about inheritance

2005-03-31 Thread Andrew Koenig
"Lonnie Princehouse" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If you try this sort of inheritance, I'd recommend writing down the > formal grammar before you start writing classes. Don't try to define > the grammar through the inheritance hierarchy; it's too easy to > accide

Re: instance name

2005-04-02 Thread Andrew Koenig
"max(01)*" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > is there a way to define a class method which prints the instance name? The term "the instance name" is misleading, because it assumes, without saying so explicitly, that every instance has a unique name. In fact, there i

I must be missing something obvious in installing Python 3.4.2...

2015-01-12 Thread Andrew Koenig
Downloaded and installed 64-bit Python 3.4 and pywin32-219. Both installed smoothly on my 64-bit Win7 machine. I added C:\Python34 to the search path. If I launch a Windows command window and run python -m ensurepip I get the following: Ignoring indexes: https://pypi.python.org/simple/

Re: I must be missing something obvious in installing Python 3.4.2...

2015-01-12 Thread Andrew Koenig
python --version reports 3.4.2, which is what I expected. I see no PYTHONPATH variable, or any environment variable with a name beginning PY (either upper or lower case). -- https://mail.python.org/mailman/listinfo/python-list

Re: I must be missing something obvious in installing Python 3.4.2...

2015-01-12 Thread Andrew Koenig
It runs and creates a classes.txt file with 803 lines. The first few: -> '$cpfile12' -> '$crfile12' -> '$cxfile12' -> '*' -> '.$cp' -> '.$cr' -> '.$cx' -> '.386' -> '.3ds' A few lines in the middle that might be relevant: -> '.py' -> '.pyc' -> '.pyo' -> '.pys' -> '.pyw' And the la

Re: I must be missing something obvious in installing Python 3.4.2...

2015-01-12 Thread Andrew Koenig
Not sure that would be a good idea: There are 22 such keys, as opposed to only two keys with Windows ID strings that don't end in nulls. I found this article: http://www.swarley.me.uk/blog/2014/04/23/python-pip-and-windows-registry-corruption/ with the comment "If you are happy to completely rem

Re: I must be missing something obvious in installing Python 3.4.2...

2015-01-12 Thread Andrew Koenig
Fixed it! The aforementioned article is correct. I downloaded the RegDelNull program mentioned in the article (http://technet.microsoft.com/en-us/sysinternals/bb897448.aspx) and ran it on hkcr, hkcu, hklm, hku, and hkcc (short for HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_

Re: in Python

2005-12-15 Thread Andrew Koenig
"Andy Leszczynski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can do elegantly in Python: > > if condition: >a=1 > else: >a=2 I believe that before long Python will support a=1 if condition else 2 -- http://mail.python.org/mailman/listinfo/python-list

Augmented generators?

2006-01-10 Thread Andrew Koenig
Can anyone think of an easy technique for creating an object that acts like a generator but has additional methods? For example, it might be nice to be able to iterate through an associative container without having to index it for each element. Right now, I can say i = iter(d) and then r

Re: How do I pass a list to a __init__ value/definition?

2006-07-25 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > class MultipleRegression: >def __init__(self, dbh, regressors, fund): >self.dbh = dbh >self.regressors = regressors > > and I want to be able to enter regressors as a list like > MultipleRegression(dbh, [1,2,3,4], 5

Re: Job advert: Your help needed

2006-02-17 Thread Andrew Koenig
"Paul Boots" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul Boots > [EMAIL PROTECTED] > +354 664 1748 Iceland? really?? -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__() not called automatically

2005-05-26 Thread Andrew Koenig
"Sakesun Roykiattisak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does c++ call base class constructor automatically ?? > If I'm not wrong, in c++ you also have to call base class constructor > explicitly. In C++, if you don't call a base-class constructor (I am saying "a" ra

Re: software testing articles

2007-05-11 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Have you ever been interested in software testing? Giving you an in > depth analysis/knowledge on software testing!! Looking around the site at random, I saw no "in depth analysis/knowledge" of anything. -- http://mail.python.org/

Re: how to convert an integer to a float?

2007-03-05 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, I have the following functions, but ' dx = abs(i2 - i1)/min(i2, > i1)' always return 0, can you please tell me how can i convert it from > an integer to float? I don't think that's what you really want to do. What you really want

How to copy a file on Windows while preserving permissions

2007-04-12 Thread Andrew Koenig
The answer to this question probably involves pywin32 or a similar library. I would like to copy a file from one place to another on a Windows machine while preserving as much of the file permissions as it is possible to preserve with whatever my program's privileges happen to be. If the file i

Re: try...except...finally problem in Python 2.5

2007-02-14 Thread Andrew Koenig
"redawgts" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I keep getting this error "local variable 'f' referenced before > assignment" in the finally block when I run the following code. > >try: >f = file(self.filename, 'rb') >f.seek(DATA_OFFSET) >

Re: Sub-sort after sort

2007-11-02 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would want to sort by name first, then sub sort by location. Any > ideas? Thanks! In Python 2.3 and later, sorting is stable -- so you can sort successively in reverse order. In other words, sort the list by location, then sort th

Re: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
"Colin J. Williams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Alternatively, as someone else suggested, an analogue of the Pascal "with" > could be used: > > def abs(self): > with self: > return math.sqrt(x**2 + y**2 + z**2) How does your suggested "with" statement know

RE: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
> I am not advocating this, but this could be: > def abs(self): >with self: > with math: >return sqrt(x**2 + y**2 + z**2) > The idea being that "with self" use > creates a new namespace: >newGlobal= oldGlobal + oldLocal >newLocal= names from self You don't know what thos

Re: How to Teach Python "Variables"

2007-11-25 Thread Andrew Koenig
"Aurélien Campéas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I mean : aren't C variables also bindings from names to objects ? Or what > ? No, they're not. In C, when you execute x = y; you cause x to become a copy of y. In Python, when you execute x = y you ca

Plotting package?

2006-04-25 Thread Andrew Koenig
This may be a foolish question, but what's the most straightforward way to plot a bunch of data in Python? That is, I want to write a program that does some number crunching, and then I want to change some parameters and watch how the changes affect the results. I could produce a file to hand

Re: list example

2006-04-25 Thread Andrew Koenig
"PAolo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > for i in range(1,10): >if i%2: >odd.append(i) >else: >even.append(i) In 2.5 you'll be able to say for i in range(1,10): (odd if i%2 else even).append(i) Whether you

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] a écrit : > Floating point numbers just don't have the required precision to represent > 2.0 - 1e-050. For your specific problem, if you really want the result to > be < 2.0, the the best you can do is

Re: bug in modulus?

2006-05-02 Thread Andrew Koenig
"Andrew Koenig" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I disagree. For any two floating-point numbers a and b, with b != 0, it > is always possible to represent the exact value of a mod b as a > floating-point number--at least on every floating

Re: Checking if a variable is a dictionary

2008-03-10 Thread Andrew Koenig
>> if type(a) is dict: >> print "a is a dictionnary!" > class MyDict(dict): > pass > a = MyDict() > type(a) is dict > => False isinstance(a, dict) => True So the question you need to answer is whether you want to determine whether an object is exactly of type dict, or whether it you a

Re: Reference or Value?

2009-02-22 Thread Andrew Koenig
"andrew cooke" wrote in message news:mailman.464.1235320654.11746.python-l...@python.org... > as far as i understand things, the best model is: > > 1 - everything is an object > 2 - everything is passed by reference > 3 - some objects are immutable > 4 - some (immutable?) objects are cached/reus

Re: What are the syntax for &&, ||

2008-11-25 Thread Andrew Koenig
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> How do I do in Python? > if condition1 and condition2: # && > doThis > elif condition3 or condition4: # || > doThat > See the pattern? if condition1 and condition2: doThis elif condition3 or condition4: doTha

Re: Avoiding local variable declarations?

2008-11-13 Thread Andrew Koenig
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >return chr( random.randrange(0, 26) + [26,97][random.randrange(0, > 100) > 50] return chr(random.randrange(0, 26) + (97 if random.randrange(0,100) > 50 else 26)) -- http://mail.python.org/mailman/listinfo/python-li

Re: Python's doc problems: sort

2008-06-01 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I want to emphasize a point here, as i have done quite emphatically in > the past. The Python documentation, is the world's worst technical > writing. As far as technical writing goes, it is even worse than > Perl's in my opinion. I t

Re: Given a string - execute a function by the same name

2008-05-08 Thread Andrew Koenig
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. No, actually, you woudn't :-) Doing so means that if your programs input specification ever changes, you have to rename all

What has become of the Python 2004 papers?

2006-03-11 Thread Andrew Koenig
http://www.python.org/community/pycon/dc2004 seems to have vanished... -- http://mail.python.org/mailman/listinfo/python-list

RE: What has become of the Python 2004 papers?

2006-03-11 Thread Andrew Koenig
> Try here: > > http://us.pycon.org/zope/original/pycon/pastevents/dc2004 > I see summaries of the paper, but when I follow the link for the papers themselves, it leads to the same dead end. -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-24 Thread Andrew Koenig
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyway this would be an argument only against the variant of typecasting a > float with a fractional part. But what about the other variant which > raises an error if there is a fractional part, but works if the