[issue28002] ast.unparse can't roundtrip some f-strings

2020-04-19 Thread Simon Percivall
Simon Percivall added the comment: Any and all code from astunparse is certainly available for inclusion. Go ahead. -- nosy: +simon.percivall ___ Python tracker <https://bugs.python.org/issue28

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-11 Thread Simon Percivall
Simon Percivall added the comment: It think it's important to document this caveat in `get_type_hints`, that there is virtually _no_ way to use it safely with a class, and that there will always be a high risk of getting an exception unless using this function in a highly controlled setting

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-03 Thread Simon Percivall
New submission from Simon Percivall: For classes with ForwardRef annotations, typing.get_type_hints is unusable. As example, we have two files: a.py: class Base: a: 'A' class A: pass b.py: from a import Base class MyClass(Base): b: 'B' class B: pass >>> from typi

[issue29167] Race condition in enum.py:_decompose()

2017-01-07 Thread Simon Percivall
Simon Percivall added the comment: Run this a couple of times (it fails for me the first time, but it's a race, so YMMV): ``` import enum from concurrent.futures import ThreadPoolExecutor class MyEnum(enum.IntFlag): one = 1 with ThreadPoolExecutor() as executor: print(list

[issue29167] Race condition in enum.py:_decompose()

2017-01-05 Thread Simon Percivall
New submission from Simon Percivall: When called by `_create_pseudo_member_()`, the dictionary iteration of `_value2member_map` in `_decompose()` in enum.py may lead to a "RuntimeError: dictionary changed size during iteration". For me, it happened in `re.compile`. ``` Traceback (m

[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation

2008-03-18 Thread Simon Percivall
Simon Percivall [EMAIL PROTECTED] added the comment: It's still a problem, as the test case demonstrates. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2074 __ ___ Python-bugs

[issue2074] pprint._safe_repr() unsafe on ordering differently types objects with same str represenation

2008-02-11 Thread Simon Percivall
New submission from Simon Percivall: _safe_repr() tries to handle the case where two objects are unorderable by ordering on (str(type(key)), key, value), but this fails when str(type(key)) is equal for two objects, but key is different and unorderable. Easy fix: order just on the string

[issue1358] Compile error on OS X 10.5

2007-11-22 Thread Simon Percivall
Simon Percivall added the comment: It has to do with the MACOSX_DEPLOYMENT_TARGET. If it's set to 10.4, the legacy version of setpgrp is used (with args), it it's 10.5, setpgrp expects no arguments. It seems configure won't detect the difference. -- nosy: +percivall

Re: pytz giving incorrect offset and timezone

2007-07-12 Thread Simon Percivall
On Jul 12, 11:47 am, Sanjay [EMAIL PROTECTED] wrote: Hi All, Using pytz, I am facing a problem with Asia/Calcutta, described below. Asia/Calcutta is actually IST, which is GMT + 5:30. But while using pytz, it was recognized as HMT (GMT + 5:53). While I digged into the oslan database, I see

Re: socket programming related.

2007-07-11 Thread Simon Percivall
On Jul 12, 2:35 am, [EMAIL PROTECTED] wrote: On Jul 11, 7:32 pm, [EMAIL PROTECTED] wrote: I have just started working in network programming using python. written code for socket connection between client and server. Client sent data to server for server processing (also server echoing

Re: where the extra space comes from on the stdout

2006-10-02 Thread Simon Percivall
alf wrote: Hi, I can not find out where the extra space comes from. Run following: import os,sys while 1: print 'Question [Y/[N]]?', if sys.stdin.readline().strip() in ('Y','y'): #do something pass $ python q.py Question [Y/[N]]?y Question [Y/[N]]?y

Re: Help in using introspection to simplify repetitive code

2006-08-20 Thread Simon Percivall
[EMAIL PROTECTED] wrote: Hello. I'm writing a proxy class, i.e: a class whose methods mostly delegate their functionality to other class object. Most of the methods (which are quite a lot) defined in the class would end up being: def thisIsTheMethodName(self):

Re: FIXED: Re: optparse multiple arguments

2006-06-30 Thread Simon Percivall
Ritesh Raj Sarraf wrote: Ritesh Raj Sarraf wrote: I just noticed that the args variable is holding values b and c. the args variables comes from: (options, args) = parser.parse_args() I guess I only need to figure out now is why args isn't storing argument a also... Ritesh I

Re: numeric/numpy/numarray

2006-06-13 Thread Simon Percivall
Bryan wrote: hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, Numarray is a re-implementation of an older Python array module called Numeric

Re: Python less error-prone than Java

2006-06-03 Thread Simon Percivall
Actually, you're wrong on all levels. First: It's perfectly simple in Java to create a binary sort that sorts all arrays that contain objects; so wrong there. Secondly: The bug has nothing to do with static typing (I'm guessing that's what you meant. Both Python and Java are strongly typed). The

Re: Pyrex speed

2006-05-27 Thread Simon Percivall
You can gain substantial speed-ups in very certain cases, but the main point of Pyrex is ease of wrapping, not of speeding-up. Depending on what you're doing, rewriting in Pyrex or even in C, using the Python/C API directly, might not gain you much. --

Re: elementtidy, \0 chars and parsing from a string

2006-05-09 Thread Simon Percivall
Well, it seems you can do: parser = elementtidy.TidyHTMLTreeBuilder.TidyHTMLTreeBuilder() parser.feed(your_str) tree = elementtree.ElementTree.ElementTree(element=parser.close()) Look at the parse() method in the ElementTree class. -- http://mail.python.org/mailman/listinfo/python-list

Re: gcc errors

2006-04-27 Thread Simon Percivall
It doesn't think you're on an intel box, it thinks you want to compile universal libraries, since you installed a universal python. The problem is likely to be that you haven't installed SDK's for intel as well as powerpc when you installed Apple's Developer Tools. Do that, and it should work ...

Re: calling a class method

2006-03-01 Thread Simon Percivall
Read this: http://users.rcn.com/python/download/Descriptor.htm Long story short: The type of the instance is passed along together with the instance itself. -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError when subclassing 'list'

2006-02-26 Thread Simon Percivall
The error you're seeing is because you've rebound 'list' to something else. Try putting list = type([]) somewhere above your code. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem?

2006-01-06 Thread Simon Percivall
Don't use self.__class__, use the name of the class. -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree - Why not part of the core?

2005-12-07 Thread Simon Percivall
Before that can happen we'll need some better management of co-existing different versions of a package. You'll want to be able to use newer versions of external packages without breakage in the standard library. -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple server/client application

2005-10-24 Thread Simon Percivall
You're calling the grid() method on the Entry object you're instanciating. Are you sure that the grid() method returns the Entry object so that you're actually binding it to self.myAddress? -- http://mail.python.org/mailman/listinfo/python-list

Re: subtle side effect of generator/generator expression

2005-10-16 Thread Simon Percivall
If you find that you want to iterate over an iterable multiple times, have a look at the solution that the tee() function in the itertools module provides (http://docs.python.org/lib/itertools-functions.html). (Have a look at the rest of the itertools module as well, for that matter.) --

Re: Python interpreter bug

2005-10-07 Thread Simon Percivall
Why would it be a bug? You've made it so that every instance of OBJ is equal to every other instance of OBJ. The behaviour is as expected. -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing class variable at class creation time

2005-09-23 Thread Simon Percivall
It might be that I'm complicating something easy here, but I immediately thought of import sys class A: X = 2 def F(): f = sys._getframe().f_back print f.f_locals[X] F() -- http://mail.python.org/mailman/listinfo/python-list

Re: threads/sockets quick question.

2005-09-19 Thread Simon Percivall
Why do you check if the module threading is less than 50? (this is why nothing happens, it's always false). From where do you get port_counter in method run() of scanThread? (this would make every call to run() raise an exception. -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible bug in metaclass resolution order ?

2005-09-18 Thread Simon Percivall
If you have read the document I referred you to, did you also read the example where classes M1, M2, M3 and M4 were defined? A quote from the discussion of that example: For class D, the explicit metaclass M1 is not a subclass of the base metaclasses (M2, M3), but choosing M3 satisfies the

Re: Possible bug in metaclass resolution order ?

2005-09-18 Thread Simon Percivall
I definitely think that it's the intended behaviour: the example shows how and why it works; and I definitely agree that it should be documented better. -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible bug in metaclass resolution order ?

2005-09-17 Thread Simon Percivall
Have you read the Metaclasses part of Unifying types and classes in Python 2.2? (http://www.python.org/2.2.3/descrintro.html#metaclasses) It discusses and explains the issues you seem to have. -- http://mail.python.org/mailman/listinfo/python-list

Re: sizeof(long) from python

2005-09-04 Thread Simon Percivall
Take a look at the struct module (http://docs.python.org/lib/module-struct.html), it does what you want. -- http://mail.python.org/mailman/listinfo/python-list

Re: python classes taught

2005-08-19 Thread Simon Percivall
Yeha, sure. The Royal Institute of Technology in Stockholm, Sweden teaches Python for some of its introductory programming and algorithm courses. -- http://mail.python.org/mailman/listinfo/python-list

Re: What are __slots__ used for?

2005-07-05 Thread Simon Percivall
Most have already been said, but have a look at http://docs.python.org/ref/slots.html for authoritative documentation. -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHONSTARTUP and the -i command line option

2005-06-03 Thread Simon Percivall
After entering the interpreter, you could do an execfile on the .pythonrc file. -- http://mail.python.org/mailman/listinfo/python-list

Re: __call__

2005-05-28 Thread Simon Percivall
Look at http://docs.python.org/ref/callable-types.html class Test(object): ... def __call__(self): ... print the instance was called ... t = Test() t() the instance was called Is this what you wanted? -- http://mail.python.org/mailman/listinfo/python-list

Re: vim configuration for python

2005-05-25 Thread Simon Percivall
I don't know if the binary editions include the Misc directory, but if you download the Python source you'll find a directory called Misc. In it, there's a vimrc file. -- http://mail.python.org/mailman/listinfo/python-list

Re: line-by-line output from a subprocess

2005-05-23 Thread Simon Percivall
Okay, so the reason what you're trying to do doesn't work is that the readahead buffer used by the file iterator is 8192 bytes, which clearly might be too much. It also might be because the output from the application you're running is buffered, so you might have to do something about that as

Re: overhead of starting threads

2005-05-23 Thread Simon Percivall
How much you gain by starting threads is also determined by what you're doing in those threads. Remember (or learn): In CPython only one thread at a time can execute python code, so depending on your task threading might gain you little. If you're doing I/O or calling functions written in C (and

Re: line-by-line output from a subprocess

2005-05-23 Thread Simon Percivall
Jp Calderone wrote: Or, doing the same thing, but with less code: Hmm ... What have I been smoking? -- http://mail.python.org/mailman/listinfo/python-list

Re: readline module and white-space

2005-05-20 Thread Simon Percivall
Take a look at readline.get_completer_delims() and readline.set_completer_delims(). -- http://mail.python.org/mailman/listinfo/python-list

Re: MacOS X drag drop?

2005-05-15 Thread Simon Percivall
Take a look at Platypus at http://sveinbjorn.sytes.net/platypus. It will make it easier for you. -- http://mail.python.org/mailman/listinfo/python-list

Re: handling more databases with ZEO

2005-05-07 Thread Simon Percivall
You should take a look at http://www.zope.org/Wikis/ZODB/FrontPage/guide/index.html -- http://mail.python.org/mailman/listinfo/python-list

Re: def a((b,c,d),e):

2005-04-18 Thread Simon Percivall
You can always unpack a tuple that way, like in: . import sys . for (index, (key, value)) in enumerate(sys.modules.iteritems()): pass -- http://mail.python.org/mailman/listinfo/python-list

Re: readonly class attribute ?

2005-03-15 Thread Simon Percivall
Start the attribute name with _ and don't document it. If clients mess with it, they're to blame. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create stuffit files on Linux?

2005-03-15 Thread Simon Percivall
Stuffit Expander can handle zip, rar, tar, gz, etc, etc, etc. Don't worry. -- http://mail.python.org/mailman/listinfo/python-list

Re: __getitem__ method on (meta)classes

2005-03-14 Thread Simon Percivall
Well, they're not synonymous. At least not in that context. If you haven't already tried it, what you're doing will fail for instances as well. Look in typeobject.c to see why. The gist of it is that the special methods are looked up on the type rather than the instance (on the metaclass rather

Re: Python info

2005-03-14 Thread Simon Percivall
Well, the source code is pretty well documented if you want to get to know the implementation. Read the Extending and Embedding tutorial and the Python/C API reference, then start digging through the code. Performance comparisons are broadly available, and always suspect. --

Re: decorating classes with metaclass

2005-03-14 Thread Simon Percivall
Class decoration was discussed back when (you can search for the thread in python-dev); not as an alias to metaclasses but discussed as having exactly the same semantics as function decoration. Maybe the idea has more merit as being another way of setting the __metaclass__ attribute; on the other

Re: issues installing readine-1.12 on WinXP

2005-03-13 Thread Simon Percivall
That shouldn't happen AFAICT. Check line 108 in keysyms.py and make sure it says vk = VkKeyScan(ord(char)). -- http://mail.python.org/mailman/listinfo/python-list

Re: issues installing readine-1.12 on WinXP

2005-03-13 Thread Simon Percivall
Possibly. Is the ` sign available as an unmodified key? -- http://mail.python.org/mailman/listinfo/python-list

Re: issues installing readine-1.12 on WinXP

2005-03-13 Thread Simon Percivall
Well, just modify the source in that case. -- http://mail.python.org/mailman/listinfo/python-list

Re: function expression with 2 arguments

2005-03-06 Thread Simon Percivall
Actually, lambda forms are quite precisely documented at http://docs.python.org/ref/lambdas.html if you feel than reading the tutorial (specifically http://docs.python.org/tut/node6.html section 4.7.5) is too base for you. -- http://mail.python.org/mailman/listinfo/python-list

Re: programmatically calling a function

2005-03-05 Thread Simon Percivall
You might also want to take a peek at the getattr() function: http://docs.python.org/lib/built-in-funcs.html#l2h-31 -- http://mail.python.org/mailman/listinfo/python-list