Re: from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
Should mention this also affects Protocol[Buzz] On Fri, Jun 30, 2023, 5:35 PM Joseph Garvin wrote: > ``` > from __future__ import annotations > from typing import Generic, TypeVar > > T = TypeVar("T") > class Foo(Generic[T]): ... > class Bar(Foo[Buzz]): ..

from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
``` from __future__ import annotations from typing import Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): ... class Bar(Foo[Buzz]): ... # NameError here class Buzz: ... ``` This will error, despite the __future__ import, because cpython is trying to look up Buzz before it's defined, even

bug?: python-config --ldflags gives incorrect output

2009-08-15 Thread Joseph Garvin
On the latest stable ubuntu: $ python-config --ldflags -L/usr/lib/python2.6/config -lpthread -ldl -lutil -lm -lpython2.6 In case the user is statically linking, I believe the -lpython2.6 should go before the other -l's. Also, -lz is missing so whenever you try to link against python you get tons

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Joseph Garvin
On Thu, Jun 4, 2009 at 2:35 PM, Thomas Heller wrote: > [Please keep the discussion on the list] > > All in all, as I said, IMO it is too complicated to figure out the binary > layout of the C++ objects (without using a C++ compiler), also there are > quite some Python packages for accessing them.

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Joseph Garvin
On Thu, Jun 4, 2009 at 3:23 PM, Brian wrote: > What is the goal of this conversation that goes above and beyond what > Boost.Python + pygccxml achieve? I can't speak for others but the reason I was asking is because it's nice to be able to define bindings from within python. At a minimum, compili

Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-02 Thread Joseph Garvin
So I was curious whether it's possible to use the ctypes module with C++ and if so how difficult it is. I figure in principal it's possible if ctypes knows about each compiler's name mangling scheme. So I searched for "ctypes c++" on Google. The third link will be "Using ctypes to Wrap C++ Librari

optparse question, passing unknown flags to subprocess

2009-05-20 Thread Joseph Garvin
I'm working on a python script that takes several command line flags, currently parsed by hand. I'd like to change the script to parse them with OptionParser from the optparse module. However, currently the script invokes a subprocess, and any flags the script doesn't understand it assumes are mean

Re: Painful?: Using the ast module for metaprogramming

2009-04-05 Thread Joseph Garvin
On Mon, Apr 6, 2009 at 1:33 AM, "Martin v. Löwis" wrote: >> -If I have the source to a single function definition and I pass it to >> ast.parse, I get back an ast.Module. Why not an ast.FunctionDef? > > Because it is easier for processing if you always get the same type of > result. Typically, you

Painful?: Using the ast module for metaprogramming

2009-04-05 Thread Joseph Garvin
I decided to try using the ast module to see how difficult or not it was to use for metaprogramming. So I tried writing a decorator that would perform a simple transformation of a function's code. It was certainly not as easy as I had guessed, but I did succeed so it's not impossible. The issues I

Re: Generators vs. Functions?

2006-02-04 Thread Joseph Garvin
Wolfgang Keller wrote: >If this is actually also true in the general case, and not due to eventual >non-representativeness of the test mentioned above, is it simply due to a >less-than-optimum implementation of generators in the current Pyython >interpreter and thus likely to change in the futu

Re: Accessing next/prev element while for looping

2005-12-18 Thread Joseph Garvin
Steven D'Aprano wrote: >On Sun, 18 Dec 2005 23:36:29 +1100, Steven D'Aprano wrote: > > > >>Python lists aren't linked lists? They are arrays. >> >> > >[slaps head for the stupid typo] >That should have been a full stop, not question mark. Python lists are not >linked lists, period. > > > >

Accessing next/prev element while for looping

2005-12-18 Thread Joseph Garvin
When I first came to Python I did a lot of C style loops like this: for i in range(len(myarray)): print myarray[i] Obviously the more pythonic way is: for i in my array: print i The python way is much more succinct. But a lot of times I'll be looping through something, and if a certain

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Joseph Garvin
Tom Anderson wrote: >Jeff Epler's proposal to use unicode operators would synergise most >excellently with this, allowing python to finally reach, and even surpass, >the level of expressiveness found in languages such as perl, APL and >INTERCAL. > >tom > > > What do you mean by unicode operat

Re: SuSe 10.0 missing Idle

2005-11-10 Thread Joseph Garvin
Steve wrote: >Hello, > >Hopefully this is not to of topic. I just installed SuSe 10.0 > and although python installed but no Idle. I can't seem to find it in >the list of available packages either. I was wondering if someone might >steer me in the right direction. I've just started learni

Re: Decline and fall of scripting languages ?

2005-08-06 Thread Joseph Garvin
Paul Rubin wrote: >Cliff Wells <[EMAIL PROTECTED]> writes: > > >>It didn't say what they left PHP, Perl and Python for (if you are to >>even believe their findings). >> >>PHP has been losing programmers in droves... to Ruby on Rails, but I'm >>not sure how that is bad news for scripting-language

Re: ANN : dxPython 0.3.0

2005-08-05 Thread Joseph Garvin
Atila Olah wrote: >In my opinion, you shoud make an (100%) English version of the site, if >you want more developers to join worldwide. > > > Isn't there some sort of Python directx thingy already? Surprised. -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread Joseph Garvin
[EMAIL PROTECTED] wrote: >I've heard 2 people complain that word 'global' is confusing. > >Perhaps 'modulescope' or 'module' would be better? > >Am I the first peope to have thought of this and suggested it? > >Is this a candidate for Python 3000 yet? > >Chris > > > Hmm.. instead of 'global', ho

Re: Python Programming Contest

2005-07-16 Thread Joseph Garvin
Someone correct me if I'm wrong -- but isn't this the Shortest Path problem? I don't foresee anyone getting a more efficient solution than what they can find in hundreds of algorithms textbooks. If this is indeed the case it should just come down to whoever can pull the narliest tricks to creat

Re: Porting from Python 2.3 to 2.4

2005-07-13 Thread Joseph Garvin
Anand wrote: >Hi > > Are there any tools that would help in porting code from >Pyton 2.3 to 2.4 ? I have gone through the whatsnew documents >and created a document comparing Python 2.4 to 2.3. But so far >has not been able to find any tool that will signal code in >Python 2.3 that can cause err

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Joseph Garvin
Peter Hansen wrote: >(I believe this is something Guido considers an "abuse of *args", but I >just consider it an elegant use of zip() considering how the language >defines *args. YMMV] > >-Peter > > An abuse?! That's one of the most useful things to do with it. It's transpose. -- http://ma

Re: Any Lua Coders About?

2005-07-13 Thread Joseph Garvin
Wendell III wrote: >Hey, > >I'm looking for a few good Lua guys with some IM network experience. >Anyone around fit that criteria? > >Bestest, >-Wendell > > I'd say it's a no brainer to try lua's mailing list ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating anonymous functions using eval

2005-07-12 Thread Joseph Garvin
Robert Kern wrote: >Not everyone is reading this list in a conveniently threaded >form > > Why not? Just about every modern newsgroup reader and e-mail app has a threaded view option. -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on Guido's ITC audio interview

2005-07-07 Thread Joseph Garvin
Everyone complaining about Eclipse in this thread needs to go try 3.1. The interface is much much much more responsive. Also, everyone keeps discussing Eclipse as something that gives Java a leg up on Python. *Ahem* PyDev :) Which you should also give another try if you haven't in a few version

Re: Python for everything?

2005-07-03 Thread Joseph Garvin
Mike Meyer wrote: >You wind up >having to invoke the function through your data object, and then pass >the data object in - sort of as an explicit "self". > > > Yeah, and us pythonists hate explicit self! ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for everything?

2005-07-03 Thread Joseph Garvin
Larry Bates wrote: >poorly. When new version of Python ships, you just learn what is new. >If you try to keep up with C, C++, Visual Basic, ... it gets to be >impossible. > >Hope information helps. > >Larry Bates > > > Huh? Part of C++'s problem is that it takes too long for obvious good stuff

Re: Favorite non-python language trick?

2005-06-24 Thread Joseph Garvin
enthusiasm over Lua's trick, and I'm glad that C/C++ can do it, but the original issue was non-python language tricks in general. Lets keep the thread on track. So far we've got lisp macros and a thousand response's to the lua trick. Anyone else have any actual non-python lang

Favorite non-python language trick?

2005-06-23 Thread Joseph Garvin
As someone who learned C first, when I came to Python everytime I read about a new feature it was like, "Whoa! I can do that?!" Slicing, dir(), getattr/setattr, the % operator, all of this was very different from C. I'm curious -- what is everyone's favorite trick from a non-python language? An

Re: Loop until condition is true

2005-06-18 Thread Joseph Garvin
Peter Otten wrote: >I found 136 occurrences of "do {" versus 754 of "while (" and 1224 of "for >(" in the Python 2.4 source, so using these rough estimates do-while still >qualifies as "rarely used". > >Peter > > > That's 136 times you'd have to use an ugly hack instead. I definitely wouldn't m

Re: Safe eval, or how to get list from string

2005-05-15 Thread Joseph Garvin
[EMAIL PROTECTED] wrote: >>http://twistedmatrix.com/users/moshez/unrepr.py >>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469 >> >> > >Thanks, this helps - but I was looking at using no additional modules, >or using something that came bundled in with python 2.3 > >I just discove

Re: How "return" no return ?

2005-05-12 Thread Joseph Garvin
Ximo wrote: >Hello, I want that the return sentence don't return anything, how can I do >it?. If i do only return it returns None, and pass don't run too. > >Can anyone help me?, thanks. >XIMO > > > > Returning None is the same as returning nothing. What exactly are you trying to do? -- http:

Re: Python Args By Reference

2005-05-10 Thread Joseph Garvin
ncf wrote: >Hello all, I was wondering if there was any way to pass arguments >(integer and such) by reference (address of), rather than by value. > >Many thanks in advance. > >-Wes > > > All mutable types in python are passed by reference automatically. -- http://mail.python.org/mailman/listi

Re: Solipsis: Python-powered Metaverse

2005-05-10 Thread Joseph Garvin
Terry Reedy wrote: >Today I followed a link to an interesting Python application I have not >seen mentioned here before: http://solipsis.netofpeers.net/wiki/HomePage/. > >"A peer-to-peer system for a massively multi-participant virtual world " > >It is a France Telecom R&D project, LGPL licenced

Re: Installing Python 2.4 on Linux

2005-04-08 Thread Joseph Garvin
Another solution is to just install 2.4 and then make an alias for yum='/usr/bin/python2.3 yum' or whatever the path is :) Edward Diener wrote: > I can install Python 2.4 on the Fedora 3 Linux system, but after I do > a number of Linux utilities and commands, like yum, stop working > because they