Re: Reading a file in IDLE 3 on Mac-Lion

2012-09-23 Thread Ned Deily
In article <[email protected]>,
 Hans Mulder  wrote:
> On 22/09/12 09:30:57, Franck Ditter wrote:
> > In article <[email protected]>,
> >  Hans Mulder  wrote:
> >> On 21/09/12 16:29:55, Franck Ditter wrote:
> >>> I create a text file utf-8 encoded in Python 3 with IDLE (Mac Lion).
> >>> It runs fine and creates the disk file, visible with
> >>> TextWrangler or another.
> >>> But I can't open it with IDLE (its name is greyed).
> >>> IDLE is supposed to read utf-8 files, no ?
> >>> This works on Windows-7.
> >>
> >> There's a little pop-menu below the list of files.
> >>
> >> It allows you to choose which kind of files you want to open.
> >> By default, it is set to "Python files", which greys out all
> >> files, except those with a '.py' or '.pyw' extension.
> >> Setting it to "Text files" should help, or else try "All files".
> > Alas this pop-up menu is for Windows only, I don't
> > find it on MacOS-X.
> 
> It's there on my MacOS X 10.6.5 system.
> 
> If your 10.7 system doesn't show it, that's definitely a bug.

This appears to a difference in behavior between Carbon Tk 8.4 and Cocoa 
Tk 8.5 on OS X.  The python.org 32-bit-only installers are built to link 
with the former and, with 8.4, the Open file dialog box does have the 
file-type filter menu as Hans describes.  The python.org 64-/32-bit 
installers link with the newer Cocoa Tk 8.5 and, with it, the Open file 
dialog box does not have the filter menu.  I'm not sure there is 
anything that IDLE or Tkinter can do about that; any change may need to 
be by the Tcl/Tk folks.  But it would be good if you would open an issue 
at bugs.python.org so we can follow up on it.

-- 
 Ned Deily,
 [email protected]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Redirecting STDOUT to a Python Variable

2012-09-23 Thread Hans Mulder
On 22/09/12 23:57:52, [email protected] wrote:
> To capture the traceback, so to put it in a log, I use this
> 
> import traceback
> 
> def get_traceback(): # obtain and return the traceback
> exc_type, exc_value, exc_traceback = sys.exc_info()
> return ''.join(traceback.format_exception(exc_type, exc_value, 
> exc_traceback)) 

This could be coded more succinctly as

import sys, traceback

def get_traceback(): # obtain and return the traceback
return ''.join(traceback.format_exception(*sys.exc_info()))

> Suppose I have a script run by the scheduler, this captures the traceback 
> form any problems and emails them.
> 
> if __name__ == '__main__':
> try: 
> Runs_unattended()
> except:
> send_mail(send_from = yourEmailAddress,
>   send_to = [ yourEmailAddress ], subject = 'Runs_unattended',
>   text = '%s' % get_traceback(),
>   files = [], server=yourLocalSMTP)

Errhm, '%s' % get_traceback() is equiavalent to get_traceback()
How about:

if __name__ == '__main__':
try:
Runs_unattended()
except:
send_mail(send_from = yourEmailAddress,
  send_to = [ yourEmailAddress ],
  subject = 'Runs_unattended',
  text = get_traceback(),
  files = [],
  server=yourLocalSMTP)



Hope this helps,

-- HansM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exact integer-valued floats

2012-09-23 Thread Hans Mulder
On 23/09/12 01:06:08, Dave Angel wrote:
> On 09/22/2012 05:05 PM, Tim Roberts wrote:
>> Dennis Lee Bieber  wrote:
>>> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote:
 For non IEEE 754 floating point systems, there is no telling how bad the 
 implementation could be :(
>>> Let's see what can be found...
>>>
>>> IBM 360: Same as Sigma-6 (no surprise; hearsay is the Sigma was
>>> designed by renegade IBM folk; even down to using EBCDIC internally --
>>> but with a much different interrupt system [224 individual interrupt
>>> vectors as I recall, vs the IBM's 7 vectors and polling to find what
>>> device]).
>> The Control Data 6000/Cyber series had sign bit and 11-bit exponent, with
>> either a 48-bit mantissa or a 96-bit mantissa, packed into one or two
>> 60-bit words.  Values were not automatically normalized, so there was no
>> assumed 1 bit, as in IEEE-754.
> 
> And it's been a long time (about 39 years), but as I recall the CDC 6400
> (at least) had no integer multiply or divide.  You had to convert to
> float first.

You didn't have to convert if your ints would fit in 48 bits.
If that was the case, then using the float multiply and divide
instructions would do the trick.

> The other oddity about the CDC series is it's the last machine I've
> encountered that used ones-complement for ints, with two values for zero.

Floats still have 0.0 and -0.0, even in IEEE-754.


Was Python ever ported to such unusual hardware?


-- HansM



-- 
http://mail.python.org/mailman/listinfo/python-list


msmtp in python

2012-09-23 Thread 7segment
Hi. 

I have written a program to send email using python. However, I want to 
use msmtp for delegating the sending to my gmail account. So this part 
should be changed but I have no idea how! In theory the "sendmail" 
function should automatically call msmtp, but i don't know how to define 
"s" then.

s = smtplib.SMTP('localhost')
s.sendmail(me, family, msg.as_string())
s.quit()

Any help would be appreciated!
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] PyPyODBC 0.8.6 released!

2012-09-23 Thread 江文
PyPyODBC - A Pure Python ctypes ODBC module

Features
-Pure Python, compatible with IronPython and PyPy (tested on Win32)
-Almost totally same usage as pyodbc
-Simple and small - the whole module is implemented in a less
than 2000 lines python script

You can simply try pypyodbc in your existing pyodbc powered script
with the following changes:

#import pyodbc <-- The original pyodbc importing line
import pypyodbc as pyodbc
pyodbc.connect(...)  # pypyodbc is now doing pyodbc's job



History

Version 0.8.6 Sep 23 2012
Added ODBC pooling feature
Bit, GUID type support
Other fixes and improvements

Version 0.8.5 Sep 16 2012
Numeric type fix
Long and integer differentiate
Other pyodbc compatibility improvements;

Version 0.8.4 Sep 9 2012 Improved compatibility with pyodbc; Many
underlying bug fixes;

Version 0.8.3 Sep 1 2012 sql_longvarchar handling fix; performance optimization;

Version 0.8.2 Aug 27 2012 Differentiate sql_varchar and
sql_longvarchar; Initial support for SQLAlchemy;

Version 0.8.1 Aug 26 2012 Fixed the long type parameter issue; Added
support for IronPython;

Version 0.8 Aug 25 2012 Added getinfo method;

Version 0.7 Jul 28 2012 Fixed nchar/ntext/nvarchar string truncat problem ;

Version 0.6 Jul 4 2012 Added Cursor.commit() and Cursor.rollback();
Added readonly keyword to connect;

Version 0.5 Jun 23 2012 Initial release;
-- 
http://mail.python.org/mailman/listinfo/python-list


wheezy.web presentation - build modern, efficient web

2012-09-23 Thread Andriy Kornatskyy

Here are links to presentation held in Kyiv.Py (Ukraine) on September 22, 2012:

"wheezy.web introduction
a lightweight, high performance, high concurrency WSGI web
framework with the key features to build modern, efficient web"

Download from:

https://bitbucket.org/akorn/wheezy.web/downloads/

Files:

wheezy.web-introduction.pdf
wheezy.web-examine.pdf

Hope you find it interesting.

Thanks.

Andriy Kornatskyy 
-- 
http://mail.python.org/mailman/listinfo/python-list


A dateutil error has appeared, due to updates? How to fix?

2012-09-23 Thread tinnews
I have a python script which uses the dateutil module with the
following:-

import sys
import datetime
import icalendar
from dateutil.relativedelta import relativedelta

The section of code which uses relativedelta is as follows:-

#
#
# If the event is a repeating event with a start date in the
# past then we add the repeat interval until we find the next
# occurrence
#
if eventDate < datetime.date.today():
if event.has_key('RRULE'):
freq = event.decoded('RRULE')['FREQ'][0]
if event.decoded('RRULE').has_key('INTERVAL'):
interval = event.decoded('RRULE')['INTERVAL'][0]
else:
interval = 1;
if 'WEEKLY' == freq:
delta = relativedelta(weeks=+interval)
if 'MONTHLY' == freq:
delta = relativedelta(months=+interval)
if 'YEARLY' == freq:
delta = relativedelta(years=+interval)
while eventDate < datetime.date.today():
eventDate += delta
else:
continue# if it's a non-repeating event in the past


It used to work and all I have done meanwhile is to update my xubuntu
system as fixes are released.  I'm now getting the error:-

Traceback (most recent call last):
  File "/home/chris/bin/calics.py", line 62, in 
eventDate += delta
  File "/usr/lib/python2.7/dist-packages/dateutil/relativedelta.py", line 
261, in __radd__
day = min(calendar.monthrange(year, month)[1],
AttributeError: 'module' object has no attribute 'monthrange'

Have I lost a module somewhere in the updates or has something in
python changed such that my code no longer works as it used to?

Can anyone help diagnose this please.

-- 
Chris Green
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Blue Screen Python

2012-09-23 Thread 88888 Dihedral
Chris Angelico於 2012年9月22日星期六UTC+8下午10時10分12秒寫道:
> On Sat, Sep 22, 2012 at 11:07 PM, Steven D'Aprano
> 
>  wrote:
> 
> > As per their partnership agreement, IBM took over development of OS/2
> 
> > version 2 while Microsoft worked on developing version 3. OS/2 2.0 was
> 
> > significantly improved over the 1.x series.
> 
> >
> 
> > Then Microsoft reneged on the agreement to release OS/2 version 3, and
> 
> > instead re-badged it as Windows NT. One might say there was a little bit
> 
> > of bad blood over this, especially as IBM had good reason to think that
> 
> > Microsoft had been spending IBM's money on NT.
> 
> 
> 
> And ever since then, Microsoft's been doing its best to kill OS/2 off.
> 
> By the look of the database server sitting next to me, and the clients
> 
> scattered throughout the building, it seems they have yet to
> 
> succeed...
> 
> 
> 
> OS/2 and Linux interoperate quite happily, too. Standards so .
> 
> 
> 
> ChrisA

This is off topic in this forum. But we are getting so far at the MMU part. 
A cpu with an L1 and  an L2  caches of large sizes is better to be
equipped with  a VMS like OS in the thread and the heap managements.


But if the situation is different, some other alternative approaches
might be more appropriate.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A dateutil error has appeared, due to updates? How to fix?

2012-09-23 Thread Peter Otten
[email protected] wrote:

> I have a python script which uses the dateutil module with the
> following:-
> 
> import sys
> import datetime
> import icalendar
> from dateutil.relativedelta import relativedelta
> 
> The section of code which uses relativedelta is as follows:-
> 
> #
> #
> # If the event is a repeating event with a start date in the
> # past then we add the repeat interval until we find the next
> # occurrence
> #
> if eventDate < datetime.date.today():
> if event.has_key('RRULE'):
> freq = event.decoded('RRULE')['FREQ'][0]
> if event.decoded('RRULE').has_key('INTERVAL'):
> interval = event.decoded('RRULE')['INTERVAL'][0]
> else:
> interval = 1;
> if 'WEEKLY' == freq:
> delta = relativedelta(weeks=+interval)
> if 'MONTHLY' == freq:
> delta = relativedelta(months=+interval)
> if 'YEARLY' == freq:
> delta = relativedelta(years=+interval)
> while eventDate < datetime.date.today():
> eventDate += delta
> else:
> continue# if it's a non-repeating event in the
> past
> 
> 
> It used to work and all I have done meanwhile is to update my xubuntu
> system as fixes are released.  I'm now getting the error:-
> 
> Traceback (most recent call last):
>   File "/home/chris/bin/calics.py", line 62, in 
> eventDate += delta
>   File "/usr/lib/python2.7/dist-packages/dateutil/relativedelta.py",
>   line 261, in __radd__
> day = min(calendar.monthrange(year, month)[1],
> AttributeError: 'module' object has no attribute 'monthrange'
> 
> Have I lost a module somewhere in the updates or has something in
> python changed such that my code no longer works as it used to?
> 
> Can anyone help diagnose this please.

You probably have a file named calendar.py in your working directory:

$ python -c 'from dateutil.relativedelta import calendar; print 
calendar.__file__'
/usr/lib/python2.7/calendar.pyc
$ touch calendar.py
$ python -c 'from dateutil.relativedelta import calendar; print 
calendar.__file__'
calendar.py

Rename calendar.py in your working directory (and don't forget to delete the 
corresponding calendar.pyc) -- and dateutil should work again.

-- 
http://mail.python.org/mailman/listinfo/python-list


cant install livewires

2012-09-23 Thread james . kennedy
i cant install livewires and their help about making a directory is useless to 
me as i dont know how 
btw im using windows 7 
REALLY DESPERATE :)

-- 
 

Disclaimer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cant install livewires

2012-09-23 Thread Chris Angelico
On Sun, Sep 23, 2012 at 10:05 PM,   wrote:
> i cant install livewires and their help about making a directory is useless 
> to me as i dont know how
> btw im using windows 7
> REALLY DESPERATE :)

May I recommend searching the web for 'make directory windows 7'? That
might help.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading a file in IDLE 3 on Mac-Lion

2012-09-23 Thread Kevin Walzer

On 9/23/12 3:33 AM, Ned Deily wrote:

This appears to a difference in behavior between Carbon Tk 8.4 and Cocoa
Tk 8.5 on OS X.  The python.org 32-bit-only installers are built to link
with the former and, with 8.4, the Open file dialog box does have the
file-type filter menu as Hans describes.  The python.org 64-/32-bit
installers link with the newer Cocoa Tk 8.5 and, with it, the Open file
dialog box does not have the filter menu.  I'm not sure there is
anything that IDLE or Tkinter can do about that; any change may need to
be by the Tcl/Tk folks.  But it would be good if you would open an issue
at bugs.python.org so we can follow up on it.


It's a function of NSOpenPanel, the underlying native dialog that 
supports the "open file" dialog on OS X. It doesn't have a "file filter" 
capability, and so it will only recognize hard-coded types that are 
passed to it, cf. py and txt files. "dat" isn't recognized, I tested it 
out. There's nothing to do here; it's an aspect of the native dialog.


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: cant install livewires

2012-09-23 Thread Mark Lawrence

On 23/09/2012 13:05, [email protected] wrote:

i cant install livewires and their help about making a directory is useless to 
me as i dont know how
btw im using windows 7
REALLY DESPERATE :)



Please don't shout.  And if my experience of the UK education system is 
anything to go by, nothing is ever desperate anyway.


Apart from that what have you tried and where did it go wrong?  "I can't 
install livewires" isn't much to go on.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Roy Smith
In article ,
 Andriy Kornatskyy  wrote:

> I have run recently a benchmark of a trivial 'hello world' application for 
> various python web frameworks (bottle, django, flask, pyramid, web.py, 
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find 
> it interesting:
> 
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> 
> Comments or suggestions are welcome.

That's a nice comparison, thanks for posting it.

One thing that's worth pointing out, however, is that in a real world 
application, as long as you're using something halfway decent, the speed 
of the framework is probably not going to matter at all.  It's much more 
likely that database throughput will be the dominating factor.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading a file in IDLE 3 on Mac-Lion

2012-09-23 Thread Kevin Walzer

On 9/23/12 8:45 AM, Kevin Walzer wrote:

There's nothing to do here; it's an aspect of the native dialog.


To clarify: there's nothing to do at the C level, which is where the 
native dialog is invoked. IDLE can probably be patched to accept other 
file types, such as "dat."


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: A dateutil error has appeared, due to updates? How to fix?

2012-09-23 Thread tinnews
Peter Otten <[email protected]> wrote:
> [email protected] wrote:
> 
[snip description of problem]

> > Have I lost a module somewhere in the updates or has something in
> > python changed such that my code no longer works as it used to?
> > 
> > Can anyone help diagnose this please.
> 
> You probably have a file named calendar.py in your working directory:
> 
> $ python -c 'from dateutil.relativedelta import calendar; print 
> calendar.__file__'
> /usr/lib/python2.7/calendar.pyc
> $ touch calendar.py
> $ python -c 'from dateutil.relativedelta import calendar; print 
> calendar.__file__'
> calendar.py
> 
> Rename calendar.py in your working directory (and don't forget to delete the 
> corresponding calendar.pyc) -- and dateutil should work again.
> 
Brilliant, you're absolutely right!  Thank you!  :-)

I'd written calendar.py doing something else entirely.  I must
remember not to use such 'obvious' names for things!

-- 
Chris Green
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seome kind of unblocking input

2012-09-23 Thread Ramchandra Apte
On Saturday, 22 September 2012 01:24:46 UTC+5:30, Dennis Lee Bieber  wrote:
> On Fri, 21 Sep 2012 02:13:28 -0700 (PDT), [email protected]
> 
> declaimed the following in gmane.comp.python.general:
> 
> 
> 
> > Since I'm using threads and pipes everything works ok, except that when i 
> > call input() there is no way that I could print something, is there any 
> > workaround for this??
> 
> > 
> 
> > Note: I don't need to catch any key's before enter or smtng, just be able 
> > to print while input() is waiting. I'm thinking that maybe there is a way 
> > for two threads to share one stdout, which should resolve this, but I can't 
> > make it work, since U can't pickle file like object(stdout) to pass it to 
> > other thread.
> 
> >
> 
> 
> 
>   Confusion abounds...
> 
> 
> 
>   You don't have to "pickle file like object..." for it to be used by
> 
> a Python THREAD... But your mention of pipes makes me think you are
> 
> using subprocesses and/or multiprocessing modules. Threads run in a
> 
> shared environment (you may need to put a lock around the file object so
> 
> that only one thread at a time does the I/O on that object), but
> 
> processes are independent memory spaces.
> 
> 
> 
>   However, you may also encounter OS specific behavior WRT
> 
> stdout/stderr when they are connected to a console. The OS itself may
> 
> block/buffer output when there is a pending input on the same console.
> 
> -- 
> 
>   Wulfraed Dennis Lee Bieber AF6VN
> 
> [email protected]://wlfraed.home.netcom.com/

You can clear the buffer by calling file.flush()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Stefan Behnel
Roy Smith, 23.09.2012 16:02:
> Andriy Kornatskyy wrote:
>> I have run recently a benchmark of a trivial 'hello world' application for 
>> various python web frameworks (bottle,�django, flask, pyramid, web.py, 
>> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
>> find 
>> it interesting:
>>
>> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
>>
>> Comments or suggestions are welcome.
> 
> That's a nice comparison, thanks for posting it.
> 
> One thing that's worth pointing out, however, is that in a real world 
> application, as long as you're using something halfway decent, the speed 
> of the framework is probably not going to matter at all.  It's much more 
> likely that database throughput will be the dominating factor.

Yes, that makes the comparison (which may or may not be biased towards his
own engine) a bit less interesting. Worth keeping this in mind:

http://www.codeirony.com/?p=9

Stefan


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Client Needs---QA Manual Tester at Sacramento, CA

2012-09-23 Thread Ramchandra Apte
On Saturday, 22 September 2012 04:09:55 UTC+5:30, ram dev  wrote:
> Good Day,
> 
> We have an urgent Contract Openings in Folsom, CA 
> 
> Looking forward to submit your resume for below mentioned Requirement…
> 
> If you are interested, Please forward your latest resume along with location 
> and pay rate details to [email protected]
> 
>  
> 
> Job Title: QA Engineer(Strong Web services Experience Needed)
> 
> Location: Sacramento, CA
> 
> Duration: 2 Years
> 
>  Required:
> 
> • Strong knowledge of SDLC
> 
> •  Manual testing experience should be 6+ years
> 
> •  Web services exp must be more than 4+ years
> 
> • Solid background of software testing methods, processes, tools
> 
> • Strong in XML,UNIX  and SQL 
> 
> • Advance level knowledge and hands-on experience with Test Planning, 
> Test Development, Test Data Setup, Test Execution and Test Reporting.
> 
> • Knowledge of variety of testing methods and direct experience in 
> test development and execution of functionality, integration, security, 
> transaction, error handling, performance of web applications.
> 
> • Expertise in testing web services API using Parasoft SOA Test or 
> SOAP UI.
> 
> • Hands-on experience with Quality Center/ALM 11.
> 
> • Experience working in Windows and Unix (Linux) environments.
> 
> • Team player with good mentoring and presentation skills 
> 
> Desired:
> 
> • ISO or Electricity Industry experience
> 
> • GUI and API test automation using HP Quick Test Pro
> 
> • Load/performance test automation using HP Load Runner
> 
> • Experience in integrating QTP, SOA Test, Load Runner or other test 
> automation tools with HP Quality Center
> 
> • Advance level experience in using and administering Quality Center, 
> developing workflows to customize QC using VB Script.
> 
> • Strong programming/scripting background in Java and Python. Able to 
> code review and develop unit test if needed. 
> 
> Environment: JBoss, Groovy and Grails, Oracle 11g, SQL, XNL, Actuate, 
> Reporting Services, SharePoint, Quality Center, Quick Test Pro, Load Runner, 
> SOA Test, Windows, Linux.
> 
> 
> 
> 
> 
> 
> 
> Thanks,
> 
> 
> 
> Ram Dev
> 
> Recruiter
> 
> Tech-Net Inc.
> 
> Tel: 916-458-4390 Ext 102
> 
> Email: [email protected] 
> 
> URL: www.tech-netinc.com

This is not related to Python; I have reported this in Google Groups.
-- 
http://mail.python.org/mailman/listinfo/python-list


QThread.terminate in Python 3

2012-09-23 Thread Lee Harr

Hi;

I have asked this on the PyQt list, but have not seen any
response yet. Hoping someone will be able to test this
on their system to see if they see the same problem.

The problem I am seeing is that terminating a QThread running
certain code will freeze the program, requiring it to be kill'd.

Adding a sleep will allow the QThread to be terminated, but
for my use I need to be able to terminate any arbitrary code.
I understand that use of QThread.terminate is discouraged,
but it has worked well previously and I would like to continue
this use if possible.

I see the problem on Python 3.2.3 with PyQt 4.9.1 on Ubuntu 12.4

With Python 2.7.3 with PyQt 4.9.1 there is no problem.

I am hoping to find out if this is a bug, and if so, where
I should report it (Python, PyQt, Qt, Linux, etc).

Thanks for any pointers.



Here is a program that shows the problem:


# test_qthread.py

#from __future__ import print_function

import time
from PyQt4 import QtCore


class CmdThread(QtCore.QThread):
    def run(self):
    while True:
    #print 'test'
    print('test')
    #time.sleep(0.2)


if __name__ == '__main__':
    t = CmdThread()
    print('thread set up')
    t.start()
    print('thread started')
    time.sleep(1)
    print('terminating thread')
    t.terminate()
    print('terminated')
    time.sleep(1)
    print('thread is running:', t.isRunning())

  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Capitalization for variable that holds a class

2012-09-23 Thread Chris Angelico
On Mon, Sep 24, 2012 at 1:48 AM, Joshua Landau
 wrote:
> Simple question:
>
> [myClass() for myClass in myClasses]
> vs
> [MyClass() for MyClass in myClasses]
>
> Fight.
>
> (When considering, substitute in a more real-world example like [Token() for
> Token in allTokens] or [token() for token in allTokens])

An interesting point! I assume you're basing this on the PEP 8 recommendation:
http://www.python.org/dev/peps/pep-0008/#class-names

Since there's no difference between a "class" and a "variable
containing a class" or a "pointer to a class" or any other such
concept, it makes sense to capitalize MyClass in your example, if you
are guaranteeing that they're all classes. And certainly a long-lived
variable ought to be named in CapWords. However, all you're really
doing is taking a bunch of callables, calling them, and making a list
of the results. I'd therefore be inclined to _not_ capitalize it. YMMV
though.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


For Counter Variable

2012-09-23 Thread jimbo1qaz
Am I missing something obvious, or do I have to manually put in a counter in 
the for loops? That's a very basic request, but I couldn't find anything in the 
documentation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Rodrick Brown
On Sep 23, 2012, at 12:42 PM, jimbo1qaz  wrote:

> Am I missing something obvious, or do I have to manually put in a counter in 
> the for loops? That's a very basic request, but I couldn't find anything in 
> the documentation.

for idx in : print (idx)

i.e.. for idx in range(10): print(idx)

> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


For Counter Variable

2012-09-23 Thread Oscar Benjamin
On Sep 23, 2012 5:42 PM, "jimbo1qaz"  wrote:
>
> Am I missing something obvious, or do I have to manually put in a counter
in the for loops? That's a very basic request, but I couldn't find anything
in the documentation.

Have you seen the enumerate function?

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Chris Angelico
On Mon, Sep 24, 2012 at 2:36 AM, jimbo1qaz  wrote:
> Am I missing something obvious, or do I have to manually put in a counter in 
> the for loops? That's a very basic request, but I couldn't find anything in 
> the documentation.

You mean, if you want the indices as well as the values? Try the
enumerate() function:

my_list = ["foo", "bar", "quux"]
for idx,val in enumerate(my_list):
print("Element "+str(idx)+" is: "+val)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list



Re: Client Needs---QA Manual Tester at Sacramento, CA

2012-09-23 Thread Mark Lawrence

On 23/09/2012 16:47, Ramchandra Apte wrote:

I've snipped all the crap that came from gmail.  Could you please get 
yourself a decent email client.




This is not related to Python; I have reported this in Google Groups.



Thanks for policing this, but how about reporting it on gmane and 
possibly other places while you're at it, or does the whole world now 
revolve around G$?


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Seome kind of unblocking input

2012-09-23 Thread Mark Lawrence

On 23/09/2012 16:49, Ramchandra Apte wrote:

On Saturday, 22 September 2012 01:24:46 UTC+5:30, Dennis Lee Bieber  wrote:

On Fri, 21 Sep 2012 02:13:28 -0700 (PDT), [email protected]

declaimed the following in gmane.comp.python.general:




Since I'm using threads and pipes everything works ok, except that when i call 
input() there is no way that I could print something, is there any workaround 
for this??







Note: I don't need to catch any key's before enter or smtng, just be able to 
print while input() is waiting. I'm thinking that maybe there is a way for two 
threads to share one stdout, which should resolve this, but I can't make it 
work, since U can't pickle file like object(stdout) to pass it to other thread.








Confusion abounds...



You don't have to "pickle file like object..." for it to be used by

a Python THREAD... But your mention of pipes makes me think you are

using subprocesses and/or multiprocessing modules. Threads run in a

shared environment (you may need to put a lock around the file object so

that only one thread at a time does the I/O on that object), but

processes are independent memory spaces.



However, you may also encounter OS specific behavior WRT

stdout/stderr when they are connected to a console. The OS itself may

block/buffer output when there is a pending input on the same console.

--

Wulfraed Dennis Lee Bieber AF6VN

 [email protected]://wlfraed.home.netcom.com/


You can clear the buffer by calling file.flush()



Shock, horror, probe, well I never did.  I'm sure that everyone is 
updating their Xmas and birthday card lists to ensure that you're not 
missed out having furnished a piece of information that doubtless not 
one other person on this group knew.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Mark Lawrence

On 23/09/2012 16:50, Stefan Behnel wrote:

Roy Smith, 23.09.2012 16:02:

Andriy Kornatskyy wrote:

I have run recently a benchmark of a trivial 'hello world' application for
various python web frameworks (bottle,�django, flask, pyramid, web.py,
wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find
it interesting:

http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html

Comments or suggestions are welcome.


That's a nice comparison, thanks for posting it.

One thing that's worth pointing out, however, is that in a real world
application, as long as you're using something halfway decent, the speed
of the framework is probably not going to matter at all.  It's much more
likely that database throughput will be the dominating factor.


Yes, that makes the comparison (which may or may not be biased towards his
own engine) a bit less interesting. Worth keeping this in mind:

http://www.codeirony.com/?p=9

Stefan




I'd like to say thanks for the link but unfortunately for me, but good 
news for you (plural), is that I've bust a gut laughing out loud, so I 
won't :)


Oh alright then thanks for the link.

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

If we take a look at web application we can split it into at least two parts, 
one that renders things out and the other one that does data extraction, e.g. 
from database (this is what you are pointing at).

If you made a first call to database you get your list and can easily cache it. 
The next call IS without impact that database call may cause... but you still 
keep serving pages out...

Thanks.

Andriy



From: [email protected]
Subject: Re: Fastest web framework
Date: Sun, 23 Sep 2012 10:02:28 -0400
To: [email protected]


In article ,
Andriy Kornatskyy  wrote:

> I have run recently a benchmark of a trivial 'hello world' application for
> various python web frameworks (bottle, django, flask, pyramid, web.py,
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find
> it interesting:
>
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
>
> Comments or suggestions are welcome.

That's a nice comparison, thanks for posting it.

One thing that's worth pointing out, however, is that in a real world
application, as long as you're using something halfway decent, the speed
of the framework is probably not going to matter at all. It's much more
likely that database throughput will be the dominating factor.

--
http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


write to a file two dict()

2012-09-23 Thread giuseppe . amatulli
Hi 
Have two dict() of the same length and i want print them to a common file.


a={1: 1, 2: 2, 3: 3}
b={1: 11, 2: 22, 3: 33}

in order to obtain 

1 1 1 11
2 2 2 22
3 3 3 33

I tried 

output = open(dst_file, "w")
for (a), b , (c) , d in a.items() , b.items() :
output.write("%i %i %i %i\n" % (a,b,c,d))
output.close()

but i get the error ValueError: need more than 3 values to unpack.

do you have some suggestions?.
Thanks 
Giuseppe


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Stefan Behnel
Andriy Kornatskyy, 23.09.2012 19:42:
> If we take a look at web application we can split it into at least two
> parts, one that renders things out and the other one that does data
> extraction, e.g. from database (this is what you are pointing at).
> 
> If you made a first call to database you get your list and can easily
> cache it. The next call IS without impact that database call may
> cause... but you still keep serving pages out...

Well, if it was really that easy, you wouldn't be using a database in the
first place but static pages, would you?

Stefan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread jimbo1qaz
On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
> Am I missing something obvious, or do I have to manually put in a counter in 
> the for loops? That's a very basic request, but I couldn't find anything in 
> the documentation.

Ya, they should really give a better way, but for now, enumerate works pretty 
well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Anyone able to help on installing packages?

2012-09-23 Thread John Mordecai Dildy
Hello everyone out there.  Ive been trying to install packages like distribute, 
nose, and virturalenv and believe me it is a hard process to do. I tried 
everything I could think of to install.

I have done the following:

pip install "package name"

easy_install "package name"

Would anyone help me at least to give directions for at least one of the 
package installation?

Would it work along with any other package installation (for example if you 
helped it show nose will it work with distribute, etc)?

Thank You all for your help
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

Few facts that doesn't make it less interesting:

(1) the test source code available
(2) the test itself is pretty famous
(3) you can re-run it
(4) or even better supply own that in your believe is 100% relevant

Not every project has problem with database performance. Some use caching... 
and pretty happy. In my case I have got 2x boost of web application performance 
just by switching to wheezy.template, that simple.

Thanks.

Andriy



> To: [email protected]
> From: [email protected]
> Subject: Re: Fastest web framework
> Date: Sun, 23 Sep 2012 17:50:20 +0200
>
> Roy Smith, 23.09.2012 16:02:
> > Andriy Kornatskyy wrote:
> >> I have run recently a benchmark of a trivial 'hello world' application for
> >> various python web frameworks (bottle,�django, flask, pyramid, web.py,
> >> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
> >> find
> >> it interesting:
> >>
> >> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> >>
> >> Comments or suggestions are welcome.
> >
> > That's a nice comparison, thanks for posting it.
> >
> > One thing that's worth pointing out, however, is that in a real world
> > application, as long as you're using something halfway decent, the speed
> > of the framework is probably not going to matter at all. It's much more
> > likely that database throughput will be the dominating factor.
>
> Yes, that makes the comparison (which may or may not be biased towards his
> own engine) a bit less interesting. Worth keeping this in mind:
>
> http://www.codeirony.com/?p=9
>
> Stefan
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write to a file two dict()

2012-09-23 Thread MRAB

On 2012-09-23 18:44, [email protected] wrote:

Hi
Have two dict() of the same length and i want print them to a common file.


a={1: 1, 2: 2, 3: 3}
b={1: 11, 2: 22, 3: 33}

in order to obtain

1 1 1 11
2 2 2 22
3 3 3 33

I tried

output = open(dst_file, "w")
for (a), b , (c) , d in a.items() , b.items() :
 output.write("%i %i %i %i\n" % (a,b,c,d))
output.close()

but i get the error ValueError: need more than 3 values to unpack.

do you have some suggestions?.


If they are guaranteed to have the same keys:

a = {1: 1, 2: 2, 3: 3}
b = {1: 11, 2: 22, 3: 33}
for k in a:
 output.write("%i %i %i %i\n" % (k, a[k], k, b[k]))

If they don't have the same keys, but are merely the same length, then
you'll first need to decide what it should do.
--
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Oscar Benjamin
On Sep 23, 2012 6:52 PM, "jimbo1qaz"  wrote:
>
> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
> > Am I missing something obvious, or do I have to manually put in a
counter in the for loops? That's a very basic request, but I couldn't find
anything in the documentation.
>
> Ya, they should really give a better way, but for now, enumerate works
pretty well.

I can't tell who you're responding to here. It would make more sense if you
quote from the post you're replying to.

Also, maybe there is a better way. Unfortunately your post was quite vague
so this is as good a response as you can hope for. Why don't you post a
code snippet representing what your trying to do? Then someone can tell you
a better way if there is one.

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

Good to know you are in a good humor today. You will be surprised... far not 
all share your point of view. ;-)

Few links for you to stop laughing that loud:
http://packages.python.org/wheezy.http/userguide.html#content-cache
http://packages.python.org/wheezy.caching/userguide.html#cachedependency

Andriy



> To: [email protected]
> From: [email protected]
> Subject: Re: Fastest web framework
> Date: Sun, 23 Sep 2012 18:20:03 +0100
>
> On 23/09/2012 16:50, Stefan Behnel wrote:
> > Roy Smith, 23.09.2012 16:02:
> >> Andriy Kornatskyy wrote:
> >>> I have run recently a benchmark of a trivial 'hello world' application for
> >>> various python web frameworks (bottle,�django, flask, pyramid, web.py,
> >>> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
> >>> find
> >>> it interesting:
> >>>
> >>> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> >>>
> >>> Comments or suggestions are welcome.
> >>
> >> That's a nice comparison, thanks for posting it.
> >>
> >> One thing that's worth pointing out, however, is that in a real world
> >> application, as long as you're using something halfway decent, the speed
> >> of the framework is probably not going to matter at all. It's much more
> >> likely that database throughput will be the dominating factor.
> >
> > Yes, that makes the comparison (which may or may not be biased towards his
> > own engine) a bit less interesting. Worth keeping this in mind:
> >
> > http://www.codeirony.com/?p=9
> >
> > Stefan
> >
> >
>
> I'd like to say thanks for the link but unfortunately for me, but good
> news for you (plural), is that I've bust a gut laughing out loud, so I
> won't :)
>
> Oh alright then thanks for the link.
>
> --
> Cheers.
>
> Mark Lawrence.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy


Good to know you are in a good humor today. You will be surprised... far not 
all share your point of view. ;-)

Few links for you to stop laughing that loud:
http://packages.python.org/wheezy.http/userguide.html#content-cache
http://packages.python.org/wheezy.caching/userguide.html#cachedependency

Andriy



> To: [email protected]
> From: [email protected]
> Subject: Re: Fastest web framework
> Date: Sun, 23 Sep 2012 18:20:03 +0100
>
> On 23/09/2012 16:50, Stefan Behnel wrote:
> > Roy Smith, 23.09.2012 16:02:
> >> Andriy Kornatskyy wrote:
> >>> I have run recently a benchmark of a trivial 'hello world' application for
> >>> various python web frameworks (bottle,�django, flask, pyramid, web.py,
> >>> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
> >>> find
> >>> it interesting:
> >>>
> >>> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> >>>
> >>> Comments or suggestions are welcome.
> >>
> >> That's a nice comparison, thanks for posting it.
> >>
> >> One thing that's worth pointing out, however, is that in a real world
> >> application, as long as you're using something halfway decent, the speed
> >> of the framework is probably not going to matter at all. It's much more
> >> likely that database throughput will be the dominating factor.
> >
> > Yes, that makes the comparison (which may or may not be biased towards his
> > own engine) a bit less interesting. Worth keeping this in mind:
> >
> > http://www.codeirony.com/?p=9
> >
> > Stefan
> >
> >
>
> I'd like to say thanks for the link but unfortunately for me, but good
> news for you (plural), is that I've bust a gut laughing out loud, so I
> won't :)
>
> Oh alright then thanks for the link.
>
> --
> Cheers.
>
> Mark Lawrence.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

Good to know you are in a good humor today. You will be surprised... far not 
all share your point of view. ;-)

Few links for you to stop laughing that loud:
http://packages.python.org/wheezy.http/userguide.html#content-cache
http://packages.python.org/wheezy.caching/userguide.html#cachedependency

Andriy



> To: [email protected]
> From: [email protected]
> Subject: Re: Fastest web framework
> Date: Sun, 23 Sep 2012 18:20:03 +0100
>
> On 23/09/2012 16:50, Stefan Behnel wrote:
> > Roy Smith, 23.09.2012 16:02:
> >> Andriy Kornatskyy wrote:
> >>> I have run recently a benchmark of a trivial 'hello world' application for
> >>> various python web frameworks (bottle,�django, flask, pyramid, web.py,
> >>> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
> >>> find
> >>> it interesting:
> >>>
> >>> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> >>>
> >>> Comments or suggestions are welcome.
> >>
> >> That's a nice comparison, thanks for posting it.
> >>
> >> One thing that's worth pointing out, however, is that in a real world
> >> application, as long as you're using something halfway decent, the speed
> >> of the framework is probably not going to matter at all. It's much more
> >> likely that database throughput will be the dominating factor.
> >
> > Yes, that makes the comparison (which may or may not be biased towards his
> > own engine) a bit less interesting. Worth keeping this in mind:
> >
> > http://www.codeirony.com/?p=9
> >
> > Stefan
> >
> >
>
> I'd like to say thanks for the link but unfortunately for me, but good
> news for you (plural), is that I've bust a gut laughing out loud, so I
> won't :)
>
> Oh alright then thanks for the link.
>
> --
> Cheers.
>
> Mark Lawrence.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


'str' object does not support item assignment

2012-09-23 Thread jimbo1qaz
spots[y][x]=mark fails with a "'str' object does not support item assignment" 
error,even though:
>>> a=[["a"]]
>>> a[0][0]="b"
and:
>>> a=[["a"]]
>>> a[0][0]=100
both work.
Spots is a nested list created as a copy of another list.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Capitalization for variable that holds a class

2012-09-23 Thread Tim Chase
On 09/23/12 11:12, Chris Angelico wrote:
> On Mon, Sep 24, 2012 at 1:48 AM, Joshua Landau
>  wrote:
>> Simple question:
>>
>> [myClass() for myClass in myClasses]
>> vs
>> [MyClass() for MyClass in myClasses]
>
> Since there's no difference between a "class" and a "variable
> containing a class" or a "pointer to a class" or any other such
> concept, it makes sense to capitalize MyClass in your example, if you
> are guaranteeing that they're all classes.

Having just written code very much like this in the last 24hr, my
own code reads something like

  my_list_of_classes = [
MyClassA,
MyClassB,
MyClassC,
]
  instances = [my_cls(args) for my_cls in my_list_of_classes]

I do come down on it being a variable (and thus
lowercase-with-underscores, according to PEP-8) because, well, it's
varying.  A class *definition* is generally expected to be
non-varying (or if it does, it's often a code smell) so it gets the
CapCamelCase.

So while ChrisA correctly claims that at the interpreter-level
"there's no difference between a 'class' and a 'variable containing
a class'", I'd say that at a programmer-level, there's a conceptual
difference between "expect this to vary" and "expect this to be the
same".  And I try to write my code for other programmers first, and
the interpreter second.

-tkc



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread jimbo1qaz
On Sunday, September 23, 2012 11:31:41 AM UTC-7, jimbo1qaz wrote:
> spots[y][x]=mark fails with a "'str' object does not support item assignment" 
> error,even though:
> 
> >>> a=[["a"]]
> 
> >>> a[0][0]="b"
> 
> and:
> 
> >>> a=[["a"]]
> 
> >>> a[0][0]=100
> 
> both work.
> 
> Spots is a nested list created as a copy of another list.

Yeah, it's a recursive function. Like it makes a difference.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

The problem is that easy if you have a complete control over what you are 
caching.

Complete control over cache may look a challenging task however with use of 
cache dependency you can lower it significantly. Take a look here:
http://packages.python.org/wheezy.caching/userguide.html#cachedependency

If you have a willing to go even further consider take a look at content 
caching:
http://packages.python.org/wheezy.http/userguide.html#content-cache

Serving static page out of your data is not that impossible... there are still 
exceptions, of cause.

Thanks.

Andriy



> To: [email protected]
> From: [email protected]
> Subject: Re: Fastest web framework
> Date: Sun, Sep 2 :: +0<<<
>
> Andriy Kornatskyy, ..2 ::
> > If we take a look at web application we can split it into at least two
> > parts, one that renders things out and the other one that does data
> > extraction, e.g. from database (this is what you are pointing at).
> >
> > If you made a first call to database you get your list and can easily
> > cache it. The next call IS without impact that database call may
> > cause... but you still keep serving pages out...
>
> Well, if it was really that easy, you wouldn't be using a database in the
> first place but static pages, would you?
>
> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread Ian Kelly
On Sun, Sep 23, 2012 at 12:31 PM, jimbo1qaz  wrote:
> spots[y][x]=mark fails with a "'str' object does not support item assignment" 
> error,even though:
 a=[["a"]]
 a[0][0]="b"
> and:
 a=[["a"]]
 a[0][0]=100
> both work.
> Spots is a nested list created as a copy of another list.

There's not enough information to go on here to even speculate what
might be causing the error, beyond "spots probably does not have the
structure you think it does".  Please post the code that you're
actually running along with the full error traceback, and then maybe
we can help you out.  Also try printing the value of spots just before
the assignment and see what it actually looks like.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone able to help on installing packages?

2012-09-23 Thread Oscar Benjamin
On Sep 23, 2012 6:56 PM, "John Mordecai Dildy"  wrote:
>
> Hello everyone out there.  Ive been trying to install packages like
distribute, nose, and virturalenv and believe me it is a hard process to
do. I tried everything I could think of to install.
>
> I have done the following:
>
> pip install "package name"
>
> easy_install "package name"

What happened when you ran those commands? Was there an error message? If
so can can you post the exact output?

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread MRAB

On 2012-09-23 19:31, jimbo1qaz wrote:

spots[y][x]=mark fails with a "'str' object does not support item assignment" 
error,even though:

a=[["a"]]
a[0][0]="b"

and:

a=[["a"]]
a[0][0]=100

both work.
Spots is a nested list created as a copy of another list.


The error suggests that spots[y] is actually a string. Printing
repr(spots) and repr(spots[y]) should tell you whether it is.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread jimbo1qaz
On Sunday, September 23, 2012 11:48:11 AM UTC-7, MRAB wrote:
> On 2012-09-23 19:31, jimbo1qaz wrote:
> 
> > spots[y][x]=mark fails with a "'str' object does not support item 
> > assignment" error,even though:
> 
>  a=[["a"]]
> 
>  a[0][0]="b"
> 
> > and:
> 
>  a=[["a"]]
> 
>  a[0][0]=100
> 
> > both work.
> 
> > Spots is a nested list created as a copy of another list.
> 
> >
> 
> The error suggests that spots[y] is actually a string. Printing
> 
> repr(spots) and repr(spots[y]) should tell you whether it is.

ya, I'm an idiot. I accidentally made a string instead of an array.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread Andrea Crotti

On 09/23/2012 07:31 PM, jimbo1qaz wrote:

spots[y][x]=mark fails with a "'str' object does not support item assignment" 
error,even though:

a=[["a"]]
a[0][0]="b"

and:

a=[["a"]]
a[0][0]=100

both work.
Spots is a nested list created as a copy of another list.


But
a = "a"
a[0] = 'c'
fails for the same reason, which is that strings in Python are immutable..
--
http://mail.python.org/mailman/listinfo/python-list


Re: 'str' object does not support item assignment

2012-09-23 Thread Mark Lawrence

On 23/09/2012 19:31, jimbo1qaz wrote:

spots[y][x]=mark fails with a "'str' object does not support item assignment" 
error,even though:

a=[["a"]]
a[0][0]="b"

and:

a=[["a"]]
a[0][0]=100

both work.
Spots is a nested list created as a copy of another list.



Looks to me as if there are three options.
a) raise a bug report on the Python bug tracker at bugs.python.org.
b) fix your code.

As option b) is the likely route, the way forward is to put print 
statements in your code so you can see what data you have *AND* what 
type it is.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Dwight Hutto
On Sun, Sep 23, 2012 at 5:19 AM, Andriy Kornatskyy
 wrote:
>
> I have run recently a benchmark of a trivial 'hello world' application for 
> various python web frameworks (bottle, django, flask, pyramid, web.py, 
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9

There are other considerations that must be made when running a 'hello world'.

-It is a basic string, but no numerical benchmarks.

-You've overlooked the fact that different OS's have other processes
at work, which need to be looked at

-and a function which performed several tasks(a string, and
numerical), and then returned the result on seveal operating systems,
with non-essential processes turned off

-etc

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-23 Thread Andriy Kornatskyy

> On Sun, Sep 23, 2012 at 5:19 AM, Andriy Kornatskyy
>  wrote:
> >
> > I have run recently a benchmark of a trivial 'hello world' application for 
> > various python web frameworks (bottle, django, flask, pyramid, web.py, 
> > wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9
>
> There are other considerations that must be made when running a 'hello world'.
>
> -It is a basic string, but no numerical benchmarks.

The basic string in return was chosen to benchmark framework code in processing 
a simple thing and measure the overhead related. In other words how effective 
the framework is inside.

> -You've overlooked the fact that different OS's have other processes
> at work, which need to be looked at
> -and a function which performed several tasks(a string, and
> numerical), and then returned the result on seveal operating systems,
> with non-essential processes turned off

There were minimal processes running on both client and server, and even if 
some have had CPU/network activity it was not so important to the workload both 
client and server experienced due to test performed. 

Hope I understood you correctly.

Thanks.

Andriy
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Dwight Hutto
> Hope I understood you correctly.
>

Well, lets break down timing something in a more scientific method
approach through questioning.

What's your processor speed?

What is the constant temperature of the internals of your system?

What OS, and version?

What other processes are running?


There's a scientific method to what you're benchmarking. There have to
be constants, and variables to benchmark with.

These will of course vary with other methods of approach with the same code.


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write to a file two dict()

2012-09-23 Thread 88888 Dihedral
[email protected]於 2012年9月24日星期一UTC+8上午1時44分30秒寫道:
> Hi 
> 
> Have two dict() of the same length and i want print them to a common file.
> 
> 
> 
> 
> 
> a={1: 1, 2: 2, 3: 3}
> 
> b={1: 11, 2: 22, 3: 33}
> 
> 
> 
> in order to obtain 
> 
> 
> 
> 1 1 1 11
> 
> 2 2 2 22
> 
> 3 3 3 33
> 
> 
> 
> I tried 
> 
> 
> 
> output = open(dst_file, "w")
> 
> for (a), b , (c) , d in a.items() , b.items() :
> 
> output.write("%i %i %i %i\n" % (a,b,c,d))
> 
> output.close()
> 
> 
> 
> but i get the error ValueError: need more than 3 values to unpack.
> 
> 
> 
> do you have some suggestions?.
> 
> Thanks 
> 
> Giuseppe

You can pickle the object directly in python. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone able to help on installing packages?

2012-09-23 Thread Oscar Benjamin
Please send your reply to the mailing list ([email protected]) rather
than privately to me.

On 23 September 2012 20:57, John Dildy  wrote:

> When I give input at the start of terminal using the command pip install
>  virtualenv:
>
> Downloading/unpacking virtualenv
>   Running setup.py egg_info for package virtualenv
>
> warning: no previously-included files matching '*' found under
> directory 'docs/_templates'
> warning: no previously-included files matching '*' found under
> directory 'docs/_build'
> Installing collected packages: virtualenv
>   Running setup.py install for virtualenv
> error: /Library/Python/2.7/site-packages/virtualenv.py: Permission
> denied
> Complete output from command /usr/bin/python -c "import
> setuptools;__file__='/var/folders/4r/jxvj6v_j5571vbjxkx_jbdy8gp/T/pip-build/virtualenv/setup.py';exec(compile(open(__file__).read().replace('\r\n',
> '\n'), __file__, 'exec'))" install --record
> /var/folders/4r/jxvj6v_j5571vbjxkx_jbdy8gp/T/pip-S9mDRc-record/install-record.txt
> --single-version-externally-managed:
> running install
>
> running build
>
> running build_py
>
> running install_lib
>
> copying build/lib/virtualenv.py -> /Library/Python/2.7/site-packages
>
> error: /Library/Python/2.7/site-packages/virtualenv.py: Permission denied
>

Your user account does not have permission to install the package in the
place where you want to install it.


>
> 
> Command /usr/bin/python -c "import
> setuptools;__file__='/var/folders/4r/jxvj6v_j5571vbjxkx_jbdy8gp/T/pip-build/virtualenv/setup.py';exec(compile(open(__file__).read().replace('\r\n',
> '\n'), __file__, 'exec'))" install --record
> /var/folders/4r/jxvj6v_j5571vbjxkx_jbdy8gp/T/pip-S9mDRc-record/install-record.txt
> --single-version-externally-managed failed with error code 1 in
> /var/folders/4r/jxvj6v_j5571vbjxkx_jbdy8gp/T/pip-build/virtualenv
> Storing complete log in /Users/jd3/Library/Logs/pip.log
>
> When I give the input of easy_install virtualenv:
>
> error: can't create or remove files in install directory
>
> The following error occurred while trying to add or remove files in the
> installation directory:
>
> [Errno 13] Permission denied:
> '/Library/Python/2.7/site-packages/test-easy-install-6258.write-test'
>

This problem is exactly the same. It doesn't matter whether you use pip or
easy_install, you need to be an administrator to install the package in
that location.  See the rest of the message:


> The installation directory you specified (via --install-dir, --prefix, or
> the distutils default setting) was:
>
> /Library/Python/2.7/site-packages/
>
> Perhaps your account does not have write access to this directory?  If the
> installation directory is a system-owned directory, you may need to sign in
> as the administrator or "root" account.  If you do not have administrative
> access to this machine, you may wish to choose a different installation
> directory, preferably one that is listed in your PYTHONPATH environment
> variable.
>

There are two ways around this:

1) Run those commands as root. I don't use OSX but I believe the command is:
$ sudo pip install virtualenv

2)  Install into your user directory. I don't know if there's anything that
needs to be done to make this work on OSX but I can do this with:
$ sudo pip install --user virtualenv

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone able to help on installing packages?

2012-09-23 Thread John Mordecai Dildy
On Sunday, September 23, 2012 1:48:52 PM UTC-4, John Mordecai Dildy wrote:
> Hello everyone out there.  Ive been trying to install packages like 
> distribute, nose, and virturalenv and believe me it is a hard process to do. 
> I tried everything I could think of to install.
> 
> 
> 
> I have done the following:
> 
> 
> 
> pip install "package name"
> 
> 
> 
> easy_install "package name"
> 
> 
> 
> Would anyone help me at least to give directions for at least one of the 
> package installation?
> 
> 
> 
> Would it work along with any other package installation (for example if you 
> helped it show nose will it work with distribute, etc)?
> 
> 
> 
> Thank You all for your help

I have just gotten help to have virtualenv installed now.

It was On OS X to do:

sudo pip install virtualenv

Now I have nose and distribute to have installed in python
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-23 Thread Alex Clark

On 2012-09-23 09:19:16 +, Andriy Kornatskyy said:



I have run recently a benchmark of a trivial 'hello world' application 
for various python web frameworks (bottle, django, flask, pyramid, 
web.py, wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... 
you might find it interesting:


http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html

Comments or suggestions are welcome.



Are you on Python Planet? If not, you might want to syndicate your blog 
there to reach more of the Python web framework crowd.





Thanks.

Andriy Kornatskyy




--
Alex Clark · http://pythonpackages.com


--
http://mail.python.org/mailman/listinfo/python-list


List Problem

2012-09-23 Thread jimbo1qaz
I have a nested list. Whenever I make a copy of the list, changes in one affect 
the other, even when I use list(orig) or even copy the sublists one by one. I 
have to manually copy each cell over for it to work.
Link to broken code: http://jimbopy.pastebay.net/1090401
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Capitalization for variable that holds a class

2012-09-23 Thread Steven D'Aprano
On Mon, 24 Sep 2012 02:12:25 +1000, Chris Angelico wrote:

> On Mon, Sep 24, 2012 at 1:48 AM, Joshua Landau
>  wrote:
>> Simple question:
>>
>> [myClass() for myClass in myClasses]
>> vs
>> [MyClass() for MyClass in myClasses]
>>
>> Fight.
>>
>> (When considering, substitute in a more real-world example like
>> [Token() for Token in allTokens] or [token() for token in allTokens])
> 
> An interesting point! I assume you're basing this on the PEP 8
> recommendation: http://www.python.org/dev/peps/pep-0008/#class-names
> 
> Since there's no difference between a "class" and a "variable containing
> a class" or a "pointer to a class" or any other such concept, it makes
> sense to capitalize MyClass in your example, if you are guaranteeing
> that they're all classes. And certainly a long-lived variable ought to
> be named in CapWords. However, all you're really doing is taking a bunch
> of callables, calling them, and making a list of the results. I'd
> therefore be inclined to _not_ capitalize it. YMMV though.

The difference is in the programmer's intention. I would go with:

[aclass() for aclass in MyClasses] 


to emphasise that aclass is intended as a temporary loop variable and not 
a long-lasting class definition.

So I guess I'm agreeing with Chris.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread jimbo1qaz
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one 
> affect the other, even when I use list(orig) or even copy the sublists one by 
> one. I have to manually copy each cell over for it to work.
> 
> Link to broken code: http://jimbopy.pastebay.net/1090401

No, actually that's the OK code. http://jimbopy.pastebay.net/1090494 is the 
broken one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Oscar Benjamin
On 23 September 2012 22:31, jimbo1qaz  wrote:

> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one
> by one. I have to manually copy each cell over for it to work.
> Link to broken code: http://jimbopy.pastebay.net/1090401


There are many things wrong with that code but I can't tell what you're
referring to. Can you paste the code into your post (rather than just a
link to it)? Can you also explain what you want it to do and at what point
it does the wrong thing?

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Chris Angelico
On Mon, Sep 24, 2012 at 7:44 AM, jimbo1qaz  wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one 
>> affect the other, even when I use list(orig) or even copy the sublists one 
>> by one. I have to manually copy each cell over for it to work.
>>
>> Link to broken code: http://jimbopy.pastebay.net/1090401
>
> No, actually that's the OK code. http://jimbopy.pastebay.net/1090494 is the 
> broken one.

The first thing I'd change about that code is the whole thing of using
try/exec/except to suppress IndexError. Definitely not good code. I'm
not wholly certain, but I think you might run into weird issues with
negative OOBounds indices (since Python treats a negative list index
as counting from the far end).

This is nothing to do with your originally requested issue, which I
can't see the cause of in your script there. But when you assign a
list, you just get another reference to the same list.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Dave Angel
On 09/23/2012 05:44 PM, jimbo1qaz wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one 
>> affect the other, even when I use list(orig) or even copy the sublists one 
>> by one. I have to manually copy each cell over for it to work.
>>
>> Link to broken code: http://jimbopy.pastebay.net/1090401
> No, actually that's the OK code. http://jimbopy.pastebay.net/1090494 is the 
> broken one.

I also would prefer an inline posting of the code, but if it's too big
to post here, it's probably too big for me to debug here.

The usual reason for such a symptom is a nested list, where you have
multiple references to the same inner list inside the outer.  When you
change one of those, you change all of them.

alist = [1, 2, 3]
blist = [alist, alist, alist]   #  or blist = alist * 3
print blist
alist.append(49)
print blist

davea@think:~/temppython$ python jimbo.py
[[1, 2, 3], [1, 2, 3], [1, 2, 3]]
[[1, 2, 3, 49], [1, 2, 3, 49], [1, 2, 3, 49]]

Solution to this is to make sure that only copies of alist get into
blist.  One way is

blist = [alist[:], alist[:], alist[:]]

More generally, you can get into this type of trouble whenever you have
non-immutable objects inside the list.

Understand, this is NOT a flaw in the language.  It's perfectly
reasonable to be able to do so, in fact essential in many cases, when
you want it to be the SAME item.


-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Steven D'Aprano
On Sun, 23 Sep 2012 14:31:48 -0700, jimbo1qaz wrote:

> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, 

Then you aren't making a copy.

py> first_list = [1, 2, 3]
py> second_list = first_list  # THIS IS NOT A COPY
py> second_list.append()
py> print first_list
[1, 2, 3, ]


> even when I use list(orig) 

Nonsense. Either you are confused, or there is something you aren't 
telling us. Calling list *does* make a copy:

py> first_list = [1, 2, 3]
py> second_list = list(first_list)
py> second_list.append()
py> print first_list
[1, 2, 3]

What aren't you telling us? My guess is that there are TWO lists 
involved, and you're only copying ONE:


py> a = [1, 2, 3]
py> a.append(["ham", "spam", "cheese"])
py> print a
[1, 2, 3, ['ham', 'spam', 'cheese']]
py> b = list(a)  # make a copy of a, but not the contents of a
py> b.append(99)  # change b
py> b[-1].append("tomato")
py> print a
[1, 2, 3, ['ham', 'spam', 'cheese', 'tomato']]

Notice that b is a copy of a: changing b does not change a. But the 
embedded list within a is *not* copied, so whether you append to that 
list via a or b is irrelevant, both see the same change because there is 
only one inner list in two places.

It might be more obvious if you give the shared sublist a name:

c = ['ham', 'spam', 'tomato']
a = [1, 2, 3, c]
b = [1, 2, 3, c]  # a copy of a, but not a copy of c

Now it should be obvious that any changes to c will show up in both a and 
b, regardless of how you change it. All three of these will have the 
exact same effect:

a[-1].append('eggs')
b[-1].append('eggs')
c.append('eggs')


The way to copy lists, and all their sublists, and their sublists, and so 
on all the way down, is with the copy module:

import copy
b = copy.deepcopy(a)

but if you are doing this a lot, (1) your code will be slow, and (2) you 
can probably redesign your code to avoid so many copies.

By the way, instead of dumping lots of irrelevant code on us, please take 
the time to narrow your problem down to the smallest possible piece of 
code. We're volunteers here, and you are not paying us to wade through 
your code trying to determine where your problem lies. That is up to you: 
you narrow down to the actual problem, then ask for help.

Please read http://sscce.org/ for more details of how, and why, you 
should do this.


Thank you.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Obnoxious postings from Google Groups (was: datetime issue)

2012-09-23 Thread Grant Edwards
On 2012-09-22, Hank Gay  wrote:
> On 2012-09-21 15:07:09 +, Grant Edwards said:
>> 
>> I told my news client years ago to filter out anything posted from
>> Google Groups -- and I know I'm not alone.  If one wants the best
>> chance of getting a question answered, using something other than
>> Google Groups is indeed a good idea.
>
> What's that filter look like?

Score:: =-
 Message-ID: .*googlegroups.com

-- 
Grant


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread jimbo1qaz
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one 
> affect the other, even when I use list(orig) or even copy the sublists one by 
> one. I have to manually copy each cell over for it to work.
> 
> Link to broken code: http://jimbopy.pastebay.net/1090401

OK, deepcopy fixed it!
And I fixed the catch indexerror thing too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Editing Inkscape SVG files with Python?

2012-09-23 Thread Steven D'Aprano
I have some SVG files generated with Inkscape containing many text blocks 
(over 100). I wish to programmatically modify those text blocks using 
Python. Is there a library I should be using, or any other guidelines or 
advice anyone can give me?

Googling for "python inkscape" comes up with too many hits for Inkscape's 
plugin system to be much help to me.


Thanks in advance.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Steven D'Aprano
On Sun, 23 Sep 2012 10:45:53 -0700, jimbo1qaz wrote:

> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
>> Am I missing something obvious, or do I have to manually put in a
>> counter in the for loops? That's a very basic request, but I couldn't
>> find anything in the documentation.
> 
> Ya, they should really give a better way, but for now, enumerate works
> pretty well.

Define "a better way". What did you have in mind that would work better?



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid identifier claimed to be valid by docs (methinks)

2012-09-23 Thread Ian Kelly
On Sun, Sep 23, 2012 at 4:24 PM, Joshua Landau
 wrote:
> The docs describe identifiers to have this grammar:
>
> identifier   ::=  xid_start xid_continue*
> id_start ::=   Nl, the underscore, and characters with the Other_ID_Start property>
> id_continue  ::=   categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
> xid_start::=   "id_start xid_continue*">
> xid_continue ::=   in "id_continue*">
>
> So I would assume that
> exec("a{} = None".format(char))
> would be valid if
>unicodedata.normalize("NFKC", char)  == "1"
> as
>exec("a1 = None")
> is valid.
>
> BUT "a¹ = None" is not valid*.
>
> *a, accessible through +1 if your keyboard's set up
> to do that stuff.
>
> Thank you for your times.

Or if you don't have a keyboard for that, you can do the same thing via:

exec("x\u00b9 = None")  # U+00B9 is superscript 1

On the other hand, this does work:

exec("x\u2071 = None")  # U+2071 is superscript i

So it seems to be only an issue with superscript and subscript digits.
 Looks like a compiler bug to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Editing Inkscape SVG files with Python?

2012-09-23 Thread Oscar Benjamin
On 23 September 2012 23:53, Steven D'Aprano <
[email protected]> wrote:

> I have some SVG files generated with Inkscape containing many text blocks
> (over 100). I wish to programmatically modify those text blocks using
> Python. Is there a library I should be using, or any other guidelines or
> advice anyone can give me?
>
> Googling for "python inkscape" comes up with too many hits for Inkscape's
> plugin system to be much help to me.
>

I thought for a moment that PyX would do it. I just checked their roadmap
though and SVG support is "not started":
http://pyx.sourceforge.net/roadmap.html

Since SVG files are a type of XML and you only want to modify the text
blocks can you not just use an XML library?

Alternatively, if you don't get an answer here it might be worth trying the
PyX-user list.

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Java singletonMap in Python

2012-09-23 Thread Mark Lawrence
Purely for fun I've been porting some code to Python and came across the 
singletonMap[1].  I'm aware that there are loads of recipes on the web 
for both singletons e.g.[2] and immutable dictionaries e.g.[3].  I was 
wondering how to combine any of the recipes to produce the best 
implementation, where to me best means cleanest and hence most 
maintainable.  I then managed to muddy the waters for myself by 
recalling the Alex Martelli Borg pattern[4].  Possibly or even probably 
the latter is irrelevant, but I'm still curious to know how you'd code 
this beast.


First prize for the best solution is a night out with me, no guesses 
what the second prize is :)


[1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html
[2]http://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python
[3]http://code.activestate.com/recipes/498072-implementing-an-immutable-dictionary/
[4]http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/
--
Cheers.

Mark Lawrence.



--
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Tim Chase
On 09/23/12 17:54, Steven D'Aprano wrote:
> On Sun, 23 Sep 2012 10:45:53 -0700, jimbo1qaz wrote:
>> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
>>> Am I missing something obvious, or do I have to manually put in a
>>> counter in the for loops? That's a very basic request, but I couldn't
>>> find anything in the documentation.
>>
>> Ya, they should really give a better way, but for now, enumerate works
>> pretty well.
> 
> Define "a better way". What did you have in mind that would work better?

I can only imagine jimbo1qaz intended "a more C-like way".  blech.

I **far** prefer The Python Way™.  The vast majority of the time,
I'm looping over some iterable where indices would only get in the
way of readability.  Tuple-unpacking the results of enumerate() is
an elegant way of getting both the items+indices on the seldom
occasion I need the index too (though I'm minorly miffed that
enumerate()'s starting-offset wasn't back-ported into earlier 2.x
versions and have had to code around it for 1-based indexing; either
extra "+1"s or whip up my own simple enumerate() generator).

-tkc


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid identifier claimed to be valid by docs (methinks)

2012-09-23 Thread Joshua Landau
On 23 September 2012 23:57, Ian Kelly  wrote:

> On Sun, Sep 23, 2012 at 4:24 PM, Joshua Landau
>  wrote:
> > The docs describe identifiers to have this grammar:
> >
> > identifier   ::=  xid_start xid_continue*
> > id_start ::=   Lo,
> > Nl, the underscore, and characters with the Other_ID_Start property>
> > id_continue  ::=   > categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
> > xid_start::=   is in
> > "id_start xid_continue*">
> > xid_continue ::=   normalization is
> > in "id_continue*">
> >
> > So I would assume that
> > exec("a{} = None".format(char))
> > would be valid if
> >unicodedata.normalize("NFKC", char)  == "1"
> > as
> >exec("a1 = None")
> > is valid.
> >
> > BUT "a¹ = None" is not valid*.
> >
> > *a, accessible through +1 if your keyboard's set
> up
> > to do that stuff.
> >On Sun, Sep 23, 2012 at 4:24 PM, Joshua Landau
>  wrote:
> > The docs describe identifiers to have this grammar:
> >
> > identifier   ::=  xid_start xid_continue*
> > id_start ::=   Lo,
> > Nl, the underscore, and characters with the Other_ID_Start property>
> > id_continue  ::=   > categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
> > xid_start::=   is in
> > "id_start xid_continue*">
>
> > Thank you for your times.
>
> Or if you don't have a keyboard for that, you can do the same thing via:
>
> exec("x\u00b9 = None")  # U+00B9 is superscript 1
>
> On the other hand, this does work:
>
> exec("x\u2071 = None")  # U+2071 is superscript i
>
> So it seems to be only an issue with superscript and subscript digits.
>  Looks like a compiler bug to me.
>

W007! Another compiler bug!

Thanks for finding one that works. I can confirm that the snippet sets
"xi", like the docs claim. Hence, yes, this does look like a compiler bug.
I'll post it on the tracker and try and make a test that catches the rest
if there are any.
-- 
http://mail.python.org/mailman/listinfo/python-list


pyOpenSSL -> m2crypto conversion?

2012-09-23 Thread Matej Cepl

Hi,

gajim (http://gajim.org, Jabber/XMPP instatnt messenger written in 
PyGtk) uses for crypto mix of some functions from the standard library, 
pyOpenSSL for SSL communication, and python-crypto for E2E (encryption 
of the messages ... uses RSA and AES; see 
https://trac.gajim.org/ticket/5294 for more details).


Now I would like to unify external crypto libraries just to m2crypto (a) 
I think using two crypto libraries is suspicious, b) I would like to 
eliminate use python-crypto to minimize general number of crypto 
libraries), for which I would like to first of all port pyOpenSSL-using 
code to m2crypto. Is there some HOWTO/blogpost/examples of doing so, or 
is there some help in m2crypto for that? Both libraries are bindings 
over OpenSSL, so I hope it wouldn't be that difficult.


https://bugs.launchpad.net/pyopenssl/+bug/236170/comments/22 seems to 
suggest that there might be some pyOpenSSL compatibility wrapper for 
m2crypto ... do I understand it correctly?


Any suggestoins, help is highly welcomed.

Thank you in advance,

Matěj Cepl
--
http://mail.python.org/mailman/listinfo/python-list


Re: Java singletonMap in Python

2012-09-23 Thread Oscar Benjamin
On 24 September 2012 00:14, Mark Lawrence  wrote:

> Purely for fun I've been porting some code to Python and came across the
> singletonMap[1].  I'm aware that there are loads of recipes on the web for
> both singletons e.g.[2] and immutable dictionaries e.g.[3].  I was
> wondering how to combine any of the recipes to produce the best
> implementation, where to me best means cleanest and hence most
> maintainable.  I then managed to muddy the waters for myself by recalling
> the Alex Martelli Borg pattern[4].  Possibly or even probably the latter is
> irrelevant, but I'm still curious to know how you'd code this beast.
>

What exactly is wanted when an attempt is made to instantiate an instance?
Should it raise an error or return the previously created instance?

This attempt makes all calls to __new__ after the first return the same
instance:

def singleton(cls):
instance = None
class sub(cls):
def __new__(cls_, *args, **kwargs):
nonlocal instance
if instance is None:
instance = super(sub, cls_).__new__(cls_, *args, **kwargs)
return instance
sub.__name__ == cls.__name__
return sub

@singleton
class A(object):
pass

print(A() is A())

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Alec Taylor
You can always use a counter if you don't like our fancy for-each loops;

foolist = [1,24,24,234,23,423,4]
for i in xrange(len(foolist)):
print foolist[i]

On Mon, Sep 24, 2012 at 9:29 AM, Tim Chase wrote:

> On 09/23/12 17:54, Steven D'Aprano wrote:
> > On Sun, 23 Sep 2012 10:45:53 -0700, jimbo1qaz wrote:
> >> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
> >>> Am I missing something obvious, or do I have to manually put in a
> >>> counter in the for loops? That's a very basic request, but I couldn't
> >>> find anything in the documentation.
> >>
> >> Ya, they should really give a better way, but for now, enumerate works
> >> pretty well.
> >
> > Define "a better way". What did you have in mind that would work better?
>
> I can only imagine jimbo1qaz intended "a more C-like way".  blech.
>
> I **far** prefer The Python Way™.  The vast majority of the time,
> I'm looping over some iterable where indices would only get in the
> way of readability.  Tuple-unpacking the results of enumerate() is
> an elegant way of getting both the items+indices on the seldom
> occasion I need the index too (though I'm minorly miffed that
> enumerate()'s starting-offset wasn't back-ported into earlier 2.x
> versions and have had to code around it for 1-based indexing; either
> extra "+1"s or whip up my own simple enumerate() generator).
>
> -tkc
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Tim Chase
On 09/23/12 18:52, Alec Taylor wrote:
> You can always use a counter if you don't like our fancy for-each loops;
> 
> foolist = [1,24,24,234,23,423,4]
> for i in xrange(len(foolist)):
> print foolist[i]

http://www.seas.upenn.edu/~lignos/py_antipatterns.html

The first one on the list of anti-patterns is doing exactly this.
Just don't.  Ewww.  Inefficient, ugly, and harder to read.

Part of learning to write in Python is, well, learning to write
*Python*, not {C,C++,Java,PHP}-in-Python.

-tkc




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Littlefield, Tyler

On 9/23/2012 3:44 PM, jimbo1qaz wrote:

On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:

I have a nested list. Whenever I make a copy of the list, changes in one affect 
the other, even when I use list(orig) or even copy the sublists one by one. I 
have to manually copy each cell over for it to work.

Link to broken code: http://jimbopy.pastebay.net/1090401

No, actually that's the OK code. http://jimbopy.pastebay.net/1090494 is the 
broken one.


I've not been following this thread fully, but why not just use 
x=list(y) to copy the list?
The issue is that when you assign i=[1,2,3] and then j = i, j is just a 
reference to i, which is why you change either and the other changes.


--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Editing Inkscape SVG files with Python?

2012-09-23 Thread Ben Finney
Steven D'Aprano  writes:

> I have some SVG files generated with Inkscape containing many text
> blocks (over 100). I wish to programmatically modify those text blocks
> using Python. Is there a library I should be using, or any other
> guidelines or advice anyone can give me?

My first step would be to use ‘lxml’ to manipulate an XML tree, since
that's what an SVG document contains.

Read the SVG file as a text string, de-serialise the text to an XML
tree. Match the nodes of interest using an XPath query, iterate over
them. Change the content of each node using Python text manipulation,
set the new value on the node. Re-serialise the tree to the SVG file.

-- 
 \   “I distrust those people who know so well what God wants them |
  `\to do to their fellows, because it always coincides with their |
_o__)  own desires.” —Susan Brownell Anthony, 1896 |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-23 Thread Mark Lawrence

On 24/09/2012 01:05, Tim Chase wrote:

On 09/23/12 18:52, Alec Taylor wrote:

You can always use a counter if you don't like our fancy for-each loops;

foolist = [1,24,24,234,23,423,4]
for i in xrange(len(foolist)):
 print foolist[i]


http://www.seas.upenn.edu/~lignos/py_antipatterns.html

The first one on the list of anti-patterns is doing exactly this.
Just don't.  Ewww.  Inefficient, ugly, and harder to read.

Part of learning to write in Python is, well, learning to write
*Python*, not {C,C++,Java,PHP}-in-Python.

-tkc



Maybe my mind is rather more warped than I thought it was, but my first 
impression was that foolist was a play on foolish.


I also like the anti-pattern on the link namely:-

for (index, value) in enumerate(alist):
print index, value

Fancy wasting time, money and effort typing those unnecessary round 
brackets.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


keeping information about players around

2012-09-23 Thread Littlefield, Tyler

ytHello all:
I've asked for a couple code reviews lately on a mud I've been working 
on, to kind of help me with ideas and a better design.


I have yet another design question.
In my mud, zones are basically objects that manage a collection of 
rooms; For example, a town would be it's own zone.
It holds information like maxRooms, the list of rooms as well as some 
other data like player owners and access flags.
The access flags basically is a list holding the uid of a player, as 
well as a bitarray of permissions on that zone. For example, a player 
might have the ability to edit a zone, but not create rooms.

So I have a couple of questions based on this:
First, how viable would it be to keep a sort of player database around 
with stats and that?
It could contain the player's level, as well as other information like 
their access (player, admin, builder etc), and then when someone does a 
whois on the player I don't have to load that player up just to get data 
about them. How would I keep the information updated? When I delete a 
player, I could just delete the entry from the database by uid.
Second, would it be viable to have both the name and the uid stored in 
the dictionary? Then I could look up by either of those?


Also, I have a couple more general-purpose questions relating to the mud.
When I load a zone, a list of rooms get stored on the zone, as well as 
world. I thought it might make sense to store references to objects 
located somewhere else but also on the world in WeakValueDictionaries to 
save memory. It prevents them from being kept around (and thus having to 
be deleted from the world when they lose their life), but also (I hope) 
will save memory. Is a weakref going to be less expensive than a full 
reference?
Second, I want to set up scripting so that you can script events for 
rooms and npcs. For example, I plan to make some type of event system, 
so that each type of object gets their own events. For example, when a 
player walks into a room, they could trigger some sort of trap that 
would poison them. This leads to a question though: I can store 
scripting on objects or in separate files, but how is that generally 
associated and executed?
Finally, I just want to make sure I'm doing things right. When I store 
data, I just pickle it all, then load it back up again. My world object 
has an attribute defined on it called picklevars, which is basically a 
list of variables to pickle, and my __getstate__ just returns a 
dictionary of those. All other objects are left "as-is" for now. Zones, 
(the entire zone and all it's rooms) get pickled, as well as players and 
then the world object for persistence. Is this the suggested way of 
doing things? I'll also pickle the HelpManager object, which will 
basically contain a list of helpfiles that can be accessed, along with 
their contents.

Thanks, and appologies for all the questions.

--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--
http://mail.python.org/mailman/listinfo/python-list


Pass numeric arrays from C extensions to Python

2012-09-23 Thread JBT
Hi,

I am looking for a way to pass numeric arrays, such as *float a[100]; double 
b[200];*, from C extension codes to python. The use case of this problem is 
that you have data stored in a particular format, NASA common data format (CDF) 
in my case, and there exists an official C library to read/create/edit such 
data, and you want to do data analysis in python. The problem comes down to how 
to feed the data into python.

I did some googling, but so far no luck. Can anyone help me? Thank you very 
much.

Cheers,
JBT

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List Problem

2012-09-23 Thread Chris Angelico
On Mon, Sep 24, 2012 at 10:56 AM, Littlefield, Tyler
 wrote:
> I've not been following this thread fully, but why not just use x=list(y) to
> copy the list?
> The issue is that when you assign i=[1,2,3] and then j = i, j is just a
> reference to i, which is why you change either and the other changes.

The problem is with lists as elements of that list, so the key is deepcopy.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pass numeric arrays from C extensions to Python

2012-09-23 Thread Oscar Benjamin
On 24 September 2012 02:39, JBT  wrote:

> Hi,
>
> I am looking for a way to pass numeric arrays, such as *float a[100];
> double b[200];*, from C extension codes to python. The use case of this
> problem is that you have data stored in a particular format, NASA common
> data format (CDF) in my case, and there exists an official C library to
> read/create/edit such data, and you want to do data analysis in python. The
> problem comes down to how to feed the data into python.
>

You probably want to wrap the c arrays in numpy.ndarray objects that can
then be accessed manipulated from Python. Numpy has a function that (I
think) does what you want called PyArray_SimpleNewFromData:
http://docs.scipy.org/doc/numpy/reference/c-api.array.html#PyArray_SimpleNewFromData

I recommend using Cython to create any extension modules that interact with
C libraries. In Cython you can:
1) Use the above function to create a numpy array.
2) Manipulate c-pointers directly to extract their data and insert it into
a standard Python container.
3) Write a simple extension type to wrap the pointer into an array type
that is accessible from Python.

In any case it seems that someone has already made a Python library for
accessing CDF data, called pycdf (I have no experience of using this
library):
http://spacepy.lanl.gov/doc/pycdf.html

Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Java singletonMap in Python

2012-09-23 Thread Steven D'Aprano
On Mon, 24 Sep 2012 00:14:23 +0100, Mark Lawrence wrote:

> Purely for fun I've been porting some code to Python and came across the
> singletonMap[1].  I'm aware that there are loads of recipes on the web
> for both singletons e.g.[2] and immutable dictionaries e.g.[3].  I was
> wondering how to combine any of the recipes to produce the best
> implementation, where to me best means cleanest and hence most
> maintainable.  I then managed to muddy the waters for myself by
> recalling the Alex Martelli Borg pattern[4].  Possibly or even probably
> the latter is irrelevant, but I'm still curious to know how you'd code
> this beast.
> 
> First prize for the best solution is a night out with me, no guesses
> what the second prize is :)
> 
> [1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/
Collections.html

Copied from that page:

"static Map singletonMap(Object key, Object value) 
Returns an immutable map, mapping only the specified key to the specified 
value."

I don't see the point of this. It takes a single key, with a single 
value, and is immutable so you can't change it or add new keys. What's 
the point? Why bother storing the key:value pair in a data structure, 
then look up the same data structure to get the same value every time?

# Pseudo-code
d = singletonMap(key, calculate(key))
# later:
value = d[key]  # there's only one key this could be
process(value)


Why not just store the value, instead of key, value and mapping?

value = calculate(key)
# later
process(value)



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid identifier claimed to be valid by docs (methinks)

2012-09-23 Thread Terry Reedy

On 9/23/2012 6:57 PM, Ian Kelly wrote:

On Sun, Sep 23, 2012 at 4:24 PM, Joshua Landau
 wrote:

The docs describe identifiers to have this grammar:

identifier   ::=  xid_start xid_continue*
id_start ::=  
id_continue  ::=  
xid_start::=  


xid_start is a subset of id_start


xid_continue ::=  


xid_continue is a subset of id_continue.


So I would assume that
 exec("a{} = None".format(char))
would be valid if
unicodedata.normalize("NFKC", char)  == "1"


Read more carefully the definition of xid_continue. The un-normalized 
character must also be in id_continue.



as
exec("a1 = None")
is valid.

BUT "a¹ = None" is not valid*.


>>> ud.category("\u00b9")
'No'

Category No is *not* in id_continue, and therefore not in xid_continue.


exec("x\u00b9 = None")  # U+00B9 is superscript 1

On the other hand, this does work:

exec("x\u2071 = None")  # U+2071 is superscript i

So it seems to be only an issue with superscript and subscript digits.
  Looks like a compiler bug to me.


The problem, if there were one, would be in the tokenizer that finds 
identifiers. However,


>>> exec("x\u00b9 = None")
...
x¹ = None
  ^
SyntaxError: invalid character in identifier

this is correct.

--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list


Re: Pass numeric arrays from C extensions to Python

2012-09-23 Thread Terry Reedy

On 9/23/2012 9:39 PM, JBT wrote:

Hi,

I am looking for a way to pass numeric arrays, such as *float a[100];
double b[200];*, from C extension codes to python. The use case of
this problem is that you have data stored in a particular format,
NASA common data format (CDF) in my case, and there exists an
official C library to read/create/edit such data, and you want to do
data analysis in python. The problem comes down to how to feed the
data into python.

I did some googling, but so far no luck. Can anyone help me? Thank
you very much.


I would look into numpy and scipy.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: cant install livewires

2012-09-23 Thread alex23
On Sep 23, 10:05 pm, [email protected] wrote:
> i cant install livewires and their help about making a directory is useless 
> to me as i dont know how
> btw im using windows 7
> REALLY DESPERATE :)

You're skimming and not reading the README correctly.

You are *only* instructed to make a directory if you're using a
version of Python before 1.6. I strongly suspect this not the case, so
you can instead follow the "Python 1.6 and above" instructions.

You will need to know the following:
1. How to unzip a zip file.
2. How to double-click on the "setup.py" file.

The instructions even explicitly mention that they've been simplified
to remove the need for Windows users to have to do something as
esoteric as open a command prompt.

Read the instructions. Carefully.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: One of my joomla webpages has been hacked. Please help.

2012-09-23 Thread alex23
On Sep 22, 4:45 am, Νίκος Γκρεεκ  wrote:
> One webpage of mine,http://www.varsa.gr/has been *hacked* 15 mins ago.

Here is your problem:

> joomla

If you're looking for a more secure solution:

http://plone.org/products/plone/security/overview
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: technologies synergistic with Python

2012-09-23 Thread alex23
On Sep 22, 8:16 am, Ethan Furman  wrote:
> What is the consensus... okay, okay -- what are some wide ranging
> opinions on technologies that I should know if my dream job is one that
> consists mostly of Python, and might allow telecommuting?

A "technology" that I consider *highly* synergistic with Python but
that seems to have permanent outsider status is Zope. (It has a
reputation for being baroque and/or over-engineered, but to me it just
seems to reflect almost 20 years of web development experience. I've
also become a big fan of its component architecture approach.)

CoffeeScript is a neat little language that compiles to JavaScript. It
borrows liberally from Python & Ruby, so you can write this:

foods = ['broccoli', 'spinach', 'chocolate']
eat food for food in foods when food isnt 'chocolate'

Instead of this:

foods = ['broccoli', 'spinach', 'chocolate'];
for (_k = 0, _len2 = foods.length; _k < _len2; _k++) {
  food = foods[_k];
  if (food !== 'chocolate') {
eat(food);
  }
}


Chris Angelico nailed it, though:

"Expand out in any direction at all, really. Anything'll make you
more
employable."

My only extension would be to pick the directions you find you enjoy
rather than the ones you think will make you more employable. I've
found it's more often than not the obscure experience I have that
makes me desirable to employers rather than the common ground they can
find anywhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little morning puzzle

2012-09-23 Thread alex23
On Sep 23, 1:44 pm, Dwight Hutto  wrote:
> Just because you can use a function, and make it look easier, doesn't
> mean the function you used had less code than mine, so if you look at
> the whole of what you used to make it simpler, mine was on point.

Word of advice: when we use "simpler" around these parts we're
referring to cognitive burden on the end developer and not the actual
amount of interpreter/library code utilised to solve the problem.

Ergo: 'enumerate()' is the correct suggestion over manually
maintaining your own index, despite it ostensibly being "more" code
due to its implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: request for another code review

2012-09-23 Thread alex23
On Sep 23, 6:14 am, "Littlefield, Tyler"  wrote:
> I've gotten a bit farther into my python mud, and wanted to request
> another code review for style and the like.

Are you familiar with codereview.stackexchange.com ?

(This isn't to dissuade you from posting such requests here, just to
help increase the chance of eyeballs on your code.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-23 Thread alex23
On Sep 21, 10:14 pm, xliiv  wrote:
> On Friday, September 21, 2012 1:08:23 PM UTC+2, Tarek Ziadé wrote:
> > Python Paste is probably what you are looking for - see

> It's a nice beast but:
> - it's not built in. Should it be? I think it should.

There needs to be a distinction at some point between Python as
runtime and development environments. If you assume that there are
more users of Python code than developers, then cluttering it with
more developer-only tools is a waste of resources for those end users.

Also: developers are fussy about their environments. One person's vi
is another person's emacs. We keep various package skeletons in our
git repository, and that works well for us, so adding Paste to Python
is just more useless kruft from our perspective.

And: easy_install/pip install paste isn't exactly crippling to type.

> - about readme and manifest.in:
> "You could add to your template a file called readme.rst"
> i dont want to add, i want it already added :)

If you'd just did as they asked, you'd already have this issue
resolved by now.

If you're waiting for the standard library to scratch your itch for
you, you're going to be waiting for a long, _long_ time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-23 Thread Terry Reedy

On 9/23/2012 11:59 PM, alex23 wrote:

On Sep 21, 10:14 pm, xliiv  wrote:

On Friday, September 21, 2012 1:08:23 PM UTC+2, Tarek Ziadé wrote:

Python Paste is probably what you are looking for - see



It's a nice beast but:
- it's not built in. Should it be? I think it should.


There needs to be a distinction at some point between Python as
runtime and development environments. If you assume that there are
more users of Python code than developers, then cluttering it with
more developer-only tools is a waste of resources for those end users.

Also: developers are fussy about their environments. One person's vi
is another person's emacs. We keep various package skeletons in our
git repository, and that works well for us, so adding Paste to Python
is just more useless kruft from our perspective.

And: easy_install/pip install paste isn't exactly crippling to type.


- about readme and manifest.in:
"You could add to your template a file called readme.rst"
i dont want to add, i want it already added :)


If you'd just did as they asked, you'd already have this issue
resolved by now.

If you're waiting for the standard library to scratch your itch for
you, you're going to be waiting for a long, _long_ time.


Batteries are batteries, not flashlights, phone, radios, toys, clickers, 
etc.


--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list


Re: A little morning puzzle

2012-09-23 Thread Ian Kelly
On Sat, Sep 22, 2012 at 9:44 PM, Dwight Hutto  wrote:
> Why don't you all look at the code(python and C), and tell me how much
> code it took to write the functions the other's examples made use of
> to complete the task.
>
> Just because you can use a function, and make it look easier, doesn't
> mean the function you used had less code than mine, so if you look at
> the whole of what you used to make it simpler, mine was on point.

I understood the sarcastic comments (the first one, at least) to be
referring to your solution as bad not due to complexity (I actually
thought it was quite simple), but because it does not solve the
problem as stated.  The problem posed by the OP was to find a set of
common keys that are associated with the same values in each dict.
Your solution takes only one predetermined key-value pair and counts
how many times it occurs in the dicts, which isn't even close to what
was requested.  With your comment of "Might be better ones, though", I
actually thought that you were aware of this and were being
intentionally satirical.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-23 Thread alex23
On Sep 24, 2:29 pm, Terry Reedy  wrote:
> Batteries are batteries, not flashlights, phone, radios, toys, clickers,
> etc.

I decided not to mention "venv" as it undermines my rant a little :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seome kind of unblocking input

2012-09-23 Thread Chris Angelico
On Mon, Sep 24, 2012 at 3:50 AM, Dennis Lee Bieber
 wrote:
> On Sun, 23 Sep 2012 18:13:57 +0100, Mark Lawrence
>  declaimed the following in
> gmane.comp.python.general:
>
>> On 23/09/2012 16:49, Ramchandra Apte wrote:
>
>> > You can clear the buffer by calling file.flush()
>> >
>>
>> Shock, horror, probe, well I never did.  I'm sure that everyone is
>> updating their Xmas and birthday card lists to ensure that you're not
>> missed out having furnished a piece of information that doubtless not
>> one other person on this group knew.
>
> It probably wouldn't have helped either... The OP was looking for,
> as I recall, some means by which a pending input would not block other
> output on a console... So what use is flushing a buffer?

It all depends on *why* pending input appears to be blocking other
output. I say "appears to be" because buffered output can indeed
appear to be blocked, but so can other things.

Flushing output is an easy thing to try. If it fails, back to square
one, but with more knowledge.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seome kind of unblocking input

2012-09-23 Thread Ramchandra Apte
On Sunday, 23 September 2012 23:20:37 UTC+5:30, Dennis Lee Bieber  wrote:
> On Sun, 23 Sep 2012 18:13:57 +0100, Mark Lawrence
> 
>  declaimed the following in
> 
> gmane.comp.python.general:
> 
> 
> 
> > On 23/09/2012 16:49, Ramchandra Apte wrote:
> 
> 
> 
> > > You can clear the buffer by calling file.flush()
> 
> > >
> 
> > 
> 
> > Shock, horror, probe, well I never did.  I'm sure that everyone is 
> 
> > updating their Xmas and birthday card lists to ensure that you're not 
> 
> > missed out having furnished a piece of information that doubtless not 
> 
> > one other person on this group knew.
> 
> 
> 
>   It probably wouldn't have helped either... The OP was looking for,
> 
> as I recall, some means by which a pending input would not block other
> 
> output on a console... So what use is flushing a buffer?
> 
> -- 
> 
>   Wulfraed Dennis Lee Bieber AF6VN
> 
> [email protected]://wlfraed.home.netcom.com/


Okay okay! My message was out-of-context.
Anyways, nobody in my age group knows that you can clear the buffer of a file 
in Python by calling file.flush().
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-23 Thread Ramchandra Apte
On Monday, 24 September 2012 09:59:12 UTC+5:30, Terry Reedy  wrote:
> On 9/23/2012 11:59 PM, alex23 wrote:
> 
> > On Sep 21, 10:14 pm, xliiv  wrote:
> 
> >> On Friday, September 21, 2012 1:08:23 PM UTC+2, Tarek Ziadé wrote:
> 
> >>> Python Paste is probably what you are looking for - see
> 
> >
> 
> >> It's a nice beast but:
> 
> >> - it's not built in. Should it be? I think it should.
> 
> >
> 
> > There needs to be a distinction at some point between Python as
> 
> > runtime and development environments. If you assume that there are
> 
> > more users of Python code than developers, then cluttering it with
> 
> > more developer-only tools is a waste of resources for those end users.
> 
> >
> 
> > Also: developers are fussy about their environments. One person's vi
> 
> > is another person's emacs. We keep various package skeletons in our
> 
> > git repository, and that works well for us, so adding Paste to Python
> 
> > is just more useless kruft from our perspective.
> 
> >
> 
> > And: easy_install/pip install paste isn't exactly crippling to type.
> 
> >
> 
> >> - about readme and manifest.in:
> 
> >> "You could add to your template a file called readme.rst"
> 
> >> i dont want to add, i want it already added :)
> 
> >
> 
> > If you'd just did as they asked, you'd already have this issue
> 
> > resolved by now.
> 
> >
> 
> > If you're waiting for the standard library to scratch your itch for
> 
> > you, you're going to be waiting for a long, _long_ time.
> 
> 
> 
> Batteries are batteries, not flashlights, phone, radios, toys, clickers, 
> 
> etc.
> 
> 
> 
> -- 
> 
> Terry Jan Reedy

Do remember to include laptops.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Editing Inkscape SVG files with Python?

2012-09-23 Thread Matej Cepl

On 24/09/12 00:53, Steven D'Aprano wrote:

Googling for "python inkscape" comes up with too many hits for Inkscape's
plugin system to be much help to me.


Aside from suggesting lxml, I would ask "So why not to follow the stream 
and create Inkscape plugin"? I have in similar situation created a 
plugin (https://gitorious.org/inkscape-ungroup-deep/) and I have to say 
it wasn't that difficult and results are pretty satisfactory.


Matěj
--
http://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.3.0 release candidate 3

2012-09-23 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I'm delighted to announce the
third release candidate of Python 3.3.0.

This is a preview release, and its use is not recommended in
production settings.

Python 3.3 includes a range of improvements of the 3.x series, as well
as easier porting between 2.x and 3.x.  Major new features and changes
in the 3.3 release series are:

* PEP 380, syntax for delegating to a subgenerator ("yield from")
* PEP 393, flexible string representation (doing away with the
distinction between "wide" and "narrow" Unicode builds)
* A C implementation of the "decimal" module, with up to 80x speedup
for decimal-heavy applications
* The import system (__import__) now based on importlib by default
* The new "lzma" module with LZMA/XZ support
* PEP 397, a Python launcher for Windows
* PEP 405, virtual environment support in core
* PEP 420, namespace package support
* PEP 3151, reworking the OS and IO exception hierarchy
* PEP 3155, qualified name for classes and functions
* PEP 409, suppressing exception context
* PEP 414, explicit Unicode literals to help with porting
* PEP 418, extended platform-independent clocks in the "time" module
* PEP 412, a new key-sharing dictionary implementation that
significantly saves memory for object-oriented code
* PEP 362, the function-signature object
* The new "faulthandler" module that helps diagnosing crashes
* The new "unittest.mock" module
* The new "ipaddress" module
* The "sys.implementation" attribute
* A policy framework for the email package, with a provisional (see
PEP 411) policy that adds much improved unicode support for email
header parsing
* A "collections.ChainMap" class for linking mappings to a single unit
* Wrappers for many more POSIX functions in the "os" and "signal"
modules, as well as other useful functions such as "sendfile()"
* Hash randomization, introduced in earlier bugfix releases, is now
switched on by default

In total, almost 500 API items are new or improved in Python 3.3.
For a more extensive list of changes in 3.3.0, see

  http://docs.python.org/3.3/whatsnew/3.3.html

To download Python 3.3.0 visit:

  http://www.python.org/download/releases/3.3.0/

Please consider trying Python 3.3.0 with your code and reporting any bugs
you may notice to:

  http://bugs.python.org/


Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.3's contributors)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEARECAAYFAlBf+0cACgkQN9GcIYhpnLBqfgCglbN63XUr2m4Ya4ff8Hza1Axl
SgMAniQZRJi8uYfeqltf5/G4QV/+SdWT
=KXTo
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >