Re: using python in web applications

2011-09-13 Thread alex23
On Sep 10, 1:54 pm, "Littlefield, Tyler"  wrote:
> I'm not feeling particularly masochistic, so I do not want to develop
> this project in PHP; essentially I'm looking to build a web-based MMO.

Google have been promoting the use of appengine along with HTML5 & JS
to produce games. One advantage of using GAE to host the server is it
takes care of the scaling for you.

I found these presentations fascinating:
http://cc-2011-html5-games.appspot.com/#1
http://io-2011-html5-games-hr.appspot.com/#1

This article covers the process in a little more depth:
http://clouddbs.blogspot.com/2011/02/how-to-write-html5-game-in-30-days-with.html

Google are also aggregating platform-specific info here:
http://code.google.com/games

Hope this helps (and let us know when you have something to show off!)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Easiest framework to develop simple interactive web site in python?

2011-09-13 Thread John Reid

On 12/09/11 19:37, Stefaan Himpe wrote:

The simplest one to learn is web2py http://www.web2py.com
No configuration needed, just unpack and get started.
It also has very good documentation and tons of little examples to get
things done.

The other options you mentioned are good too :)



OK I've had a look at bottle, cherrypy and web2py and they look fairly 
straightforward. I'll check out some more and see where I get to. Thanks 
for the tips,

John.

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


Re: Easiest framework to develop simple interactive web site in python?

2011-09-13 Thread limodou
On Tue, Sep 13, 2011 at 3:30 PM, John Reid  wrote:
> On 12/09/11 19:37, Stefaan Himpe wrote:
>>
>> The simplest one to learn is web2py http://www.web2py.com
>> No configuration needed, just unpack and get started.
>> It also has very good documentation and tons of little examples to get
>> things done.
>>
>> The other options you mentioned are good too :)
>>
>
> OK I've had a look at bottle, cherrypy and web2py and they look fairly
> straightforward. I'll check out some more and see where I get to. Thanks for
> the tips,
> John.
>

maybe you can also try out uliweb.

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
UliWeb <>: http://code.google.com/p/uliweb/
My Blog: http://hi.baidu.com/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread jmfauth
On 12 sep, 23:39, "Rhodri James"  wrote:


> Now read what Steven wrote again.  The issue is that the program contains  
> characters that are syntactically illegal.  The "engine" can be perfectly  
> correctly translating a character as a smart quote or a non breaking space  
> or an e-umlaut or whatever, but that doesn't make the character legal!
>

Yes, you are right. I did not understand in that way.

However, a small correction/precision. Illegal character
do not exit. One can "only" have an ill-formed encoded code
points or an illegal encoded code point representing a
character/glyph.

Basically, in the present case. The issue is most probably
a mismatch between the coding directive and the real
coding, with "no coding directive" == 'ascii'.


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


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Steven D'Aprano
On Tue, 13 Sep 2011 05:49 pm jmfauth wrote:

> On 12 sep, 23:39, "Rhodri James"  wrote:
> 
> 
>> Now read what Steven wrote again.  The issue is that the program contains
>> characters that are syntactically illegal.  The "engine" can be perfectly
>> correctly translating a character as a smart quote or a non breaking
>> space or an e-umlaut or whatever, but that doesn't make the character
>> legal!
>>
> 
> Yes, you are right. I did not understand in that way.
> 
> However, a small correction/precision. Illegal character
> do not exit. One can "only" have an ill-formed encoded code
> points or an illegal encoded code point representing a
> character/glyph.

You are wrong there. There are many ASCII characters which are illegal in
Python source code, at least outside of comments and string literals, and
possibly even there.

>>> code = "x = 1 + \b 2"  # all ASCII characters
>>> print(code)
x = 1 + 2
>>> exec(code)
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1
x = 1 + 2
^
SyntaxError: invalid syntax


Now, imagine that somehow a \b ASCII backspace character somehow gets
introduced into your source file. When you go to run the file, or import
it, you will get a SyntaxError. Changing the encoding will not help.



-- 
Steven

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


Michael Jordan 23.

2011-09-13 Thread fashion t shirts seller
In addition to the expression of this athletes foot propulsion
technology that they run very fast from the other major areas,
including Air Jordan 2009, satin sheets and the rear panel of nba
basketball shoes, said middle layer blown-glass is a unique movement
in each shoes. The silk is inspired by the belief that People Michael
Jordan in basketball is very similar to the art of personal
http://www.cheap-nbabasketballshoes.com/defense to defend themselves
in a sport of fencing. Sheets are used to remind the importance of the
defensive players wore light clothing fencers irony. Hologram of a
diamond shape to be included in the ankle support and insurance,
leather, also used in the nba players 
http://www.cheap-nbabasketballshoes.com/shoes,
so that it is not only a function of the courts, but Ye Hao looked at
the court. Jordan brand sports shoes, which add an additional buffer
to keep athletes safe and comfortable ankle. In order to fully
understand this work into the design of 
http://www.cheap-nbabasketballshoes.com/sports
shoes, a person must do a careful observation and analysis of every
part of the shoes. For example, the end including the full range of
models, which helps to increase the grip, the needle in the upper two
rows and deliberately sewn three rows below it in order to reflect the
famous Michael Jordan 23. http://www.cheap-nbabasketballshoes.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread jmfauth
On 13 sep, 10:15, Steven D'Aprano  wrote:

The intrinsic coding of the characters is one thing,
The usage of bytes stream supposed to represent a text
is one another thing,

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


Re: Should a beginner do some coding excises? How can I find the sources?

2011-09-13 Thread sillyou su
On Sep 13, 1:14 pm, memilanuk  wrote:
> On 09/12/2011 09:20 PM, sillyou su wrote:
>
> > I'm reading "Learning Python"( Chinese version). Before I go through
> > the whole book, I want to do some excises matching each charter.
> > Any tips? Any better advice?
>
> For the code examples, have you tried looking up the home page for the
> book?  Google for 'oreilly learning python' and find the correct edition
> that you have.
>
> If its the 4th ed (current), you should end up on a page like this:
>
> http://shop.oreilly.com/product/9780596158071.do
>
> Down in the right hand side-bar, there should be a menu 'Essential
> Links' and one of the options is 'Download code' or something along
> those lines.  The link should take you to a zip file with all the code
> examples in the book.
>
> As far as practice exercises... maybe something like
> codingbat.com/python would be helpful.  Its not related to the book at
> all, and doesn't go nearly as in depth... but its kind of neat to play
> with and see how your code works when someone else is grading it! (at
> least for me).
>
> HTH,
>
> Monte

codingbat.com/python!
The website is really interesting.
Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


problem:import csv data

2011-09-13 Thread 守株待兔
import sqlite3 
con = sqlite3.connect('/home/stock.db')
cur = con.cursor()
cur.execute('''CREATE TABLE quote (ticker TEXT,date TEXT, popen TEXT, high 
TEXT, low TEXT,vol TEXT,adjclose TEXT);''')
i=/tmp/data.csv
cur.execute('.separator "," ')
cur.execute('.import  %s  quote'  %  i)
con.commit()
cur.close()
con.close()

the output is :
cur.execute('.separator"," ')
sqlite3.OperationalError: near ".": syntax error

how to fix it?-- 
http://mail.python.org/mailman/listinfo/python-list


send string to input of another process

2011-09-13 Thread Alex Naumov
Hello everybody,

I'm looking for some solution, maybe someone of you can help me.

I call another process via os.system("process") and it waits for some input.
I have to write a comment (for example, like using svn or git), and after
that to close input (for example, like ":wq" using vim).
How can I give/write this comment and put it in the input for next process
(which start after)?


Thanks a lot for your time and help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread ron
On Sep 12, 4:49 am, Steven D'Aprano  wrote:
> On Mon, 12 Sep 2011 06:43 pm Stefan Behnel wrote:
>
> > I'm not sure what you are trying to say with the above code, but if it's
> > the code that fails for you with the exception you posted, I would guess
> > that the problem is in the "[more stuff here]" part, which likely contains
> > a non-ASCII character. Note that you didn't declare the source file
> > encoding above. Do as Gary told you.
>
> Even with a source code encoding, you will probably have problems with
> source files including \xe2 and other "bad" chars. Unless they happen to
> fall inside a quoted string literal, I would expect to get a SyntaxError.
>
> I have come across this myself. While I haven't really investigated in great
> detail, it appears to happen when copying and pasting code from a document
> (usually HTML) which uses non-breaking spaces instead of \x20 space
> characters. All it takes is just one to screw things up.
>
> --
> Steven

Depending on the load, you can do something like:

"".join([x for x in string if ord(x) < 128])

It's worked great for me in cleaning input on webapps where there's a
lot of copy/paste from varied sources.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem:import csv data

2011-09-13 Thread Miki Tebeka
.separator (and .import) are not SQL commands but "sqlite3" commands.
You can get the same effect with the following code:

with open('/tmp/data.csv') as fo:
reader = csv.reader(fo)
cur.executemany('INSERT INTO quote VALUES (?, ?, ?, ?, ?, ?, ?)'), 
reader)

HTH
--
Miki Tebeka 
http://pythonwise.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


The Usenet newsgroup news:comp.lang.python ...

2011-09-13 Thread mano mano
Mikael Lyngvig accurately summarizes comp.lang.python discussion of
the technical merits of Tkinter, wxPython, and Python-bound JPI.
Malcolm Tredinnick ...

http://123maza.com/48/doll789/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Vlastimil Brom
2011/9/13 ron :
>
> Depending on the load, you can do something like:
>
> "".join([x for x in string if ord(x) < 128])
>
> It's worked great for me in cleaning input on webapps where there's a
> lot of copy/paste from varied sources.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Well, for this kind of dirty "data cleaning" you may as well use e.g.

>>> u"äteöxt ÛÜÝ wiÉÊËÌthÞßà áânoûüýþn ASɔɕɖCɗɘəɚɛIɗɘəɚɛIεζ iηθιn 
>>> жзbetийклweeჟრსn .ტუ..ფ".encode("ascii", "ignore").decode("ascii")
u'text  with non ASCII in between ...'
>>>

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


Re: PC locks up with list operations

2011-09-13 Thread Carl Banks
On Wednesday, August 31, 2011 5:49:24 AM UTC-7, Benjamin Kaplan wrote:
> 32-bit or 64-bit Python? A 32-bit program will crash once memory hits
> 2GB. A 64-bit program will just keep consuming RAM until your computer
> starts thrashing. The problem isn't your program using more RAM than
> you have, just more RAM than you have free. Last time I faced a
> situation like this, I just decided it was better to stick to the
> 32-bit program and let it crash if it got too big.

On my 64-bit Linux system, I got a memory error in under a second, no thrashing.

I have no swap.  It's overrated.


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


ACCU conference call for proposals

2011-09-13 Thread Jon Jagger

ACCU is a non-profit organisation run by software enthusiasts for
software enthusiasts.

ACCU warmly invites you to propose a session for this leading software
development conference.

Call for Proposals - ACCU 2012
April 24-28, 2012. Barcelo Oxford Hotel, Oxford, UK
Submission website: https://www.conftool.pro/accu2012/
Submission deadline: 16th of October 2011
twitter: @accu2012 #accu2012

More details can be found here
http://accu.org/index.php/conferences/accu_conference_2012/accu2012_Call_for_Papers

The conference has always benefited from the strength of its
programme. Please help us make 2012 another successful event.

Jon Jagger
Conference Chair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send string to input of another process

2011-09-13 Thread Kushal Kumaran
On 13 Sep 2011 17:53, "Alex Naumov"  wrote:
>
> Hello everybody,
>
> I'm looking for some solution, maybe someone of you can help me.
>
> I call another process via os.system("process") and it waits for some
input. I have to write a comment (for example, like using svn or git), and
after that to close input (for example, like ":wq" using vim).
> How can I give/write this comment and put it in the input for next process
(which start after)?
>
>

Take a look at the subprocess module, especially the communicate method.
Note that you will not be able to script screen-oriented programs like vim
using this, unless it has some mode where you can drive it by piping
commands on stdin.

If you want to provide commit messages, I'm sure your vc system accepts
those on the command line instead.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Alec Taylor
Hmm, nothing mentioned so far works for me...

Here's a very small test case:

>>> python -u "Convert to Creole.py"
  File "Convert to Creole.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file Convert to Creole.py
on line 1, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
>>> Exit Code: 1

Line 1: a=u'''≤'''.encode("ascii", "ignore").decode("ascii")

On Tue, Sep 13, 2011 at 11:33 PM, Vlastimil Brom
 wrote:
> 2011/9/13 ron :
>>
>> Depending on the load, you can do something like:
>>
>> "".join([x for x in string if ord(x) < 128])
>>
>> It's worked great for me in cleaning input on webapps where there's a
>> lot of copy/paste from varied sources.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
> Well, for this kind of dirty "data cleaning" you may as well use e.g.
>
 u"äteöxt ÛÜÝ wiÉÊËÌthÞßà áânoûüýþn ASɔɕɖCɗɘəɚɛIɗɘəɚɛIεζ iηθιn 
 жзbetийклweeჟრსn .ტუ..ფ".encode("ascii", "ignore").decode("ascii")
> u'text  with non ASCII in between ...'

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


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Jussi Piitulainen
Alec Taylor writes:

> Hmm, nothing mentioned so far works for me...
> 
> Here's a very small test case:
> 
> >>> python -u "Convert to Creole.py"
>   File "Convert to Creole.py", line 1
> SyntaxError: Non-ASCII character '\xe2' in file Convert to Creole.py
> on line 1, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details
> >>> Exit Code: 1
> 
> Line 1: a=u'''≤'''.encode("ascii", "ignore").decode("ascii")

The people who told you to declare the source code encoding in the
source file would like to see Line 0.

See .

[1001] ruuvi$ cat ctc.py
# coding=utf-8
print u'''x ≤ 1'''.encode("ascii", "ignore").decode("ascii")
[1002] ruuvi$ python ctc.py
x  1
[1003] ruuvi$ 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: Itertools module needs attention

2011-09-13 Thread Ian Kelly
On Mon, Sep 12, 2011 at 4:04 PM, rantingrick  wrote:
>
> 
> #                          Quote                           #
> 
> # The itertools module is great HOWEVER i believe most     #
> # people are recreating the functionalities due to the     #
> # insanely cryptic and/or missing examples from each       #
> # method                                                   #
> 

Have you looked at the online itertools documentation at all?

http://docs.python.org/library/itertools.html

> py> ''.join(list(itertools.dropwhile(lambda x:x==" ", "    hello
> word    ")))
> 'hello word    '
> py> ''.join(list(itertools.takewhile(lambda x:x==" ", "    hello
> word    ")))
> '    '

These are too complex to be good examples.  Drop the lambda and
replace it with a built-in.  Also, str.join is perfectly capable of
taking an iterator as its argument.  There is no reason at all to
construct a list first.

> py> print itertools.compress.__doc__
> compress(data, selectors) --> iterator over selected data
> Return data elements corresponding to true selector elements.
> Forms a shorter iterator from selected data elements using the
> selectors to choose the data elements.
>
> 
> #                          Quote                           #
> 
> # WTF! Would you like to define a Python "selector". Could #
> # it be that we should be using "selector function" or     #
> # "predicate function" instead?                            #
> 

Notice that it says "selector elements", not "selector functions".
You have misconstrued what this function does.  Hint: it does not use
predicates at all.

I can agree though that this could probably use a simple example in
the doc string.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Prasad, Ramit
Written by Kayode Odeyemi
Well, I did try using super(), but I got this:
>>> class B(A):
... def __init__(self, module):
... super(A, self).log('system')
...
>>> c = B('module')
=
You should be passed super the current class you want the super class of, not 
the type of the super class. So it should be:
super(B, self).log('system') # Notice that it passed class B


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423





This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  -- 
http://mail.python.org/mailman/listinfo/python-list


RE: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Prasad, Ramit
>You should be passed super the current class you want the super class of, not 
>the type of the super class. So it should be:
>super(B, self).log('system') # Notice that it passed class B

Ugh, apologies for the poor English; my tea has not kicked in.

That first line would be more understandable as:  'You should pass the current 
class (B) you want the super class of, not the type of the super class (A) 
itself. So it should be:'

To clarify, by passing A to super it retrieves the definition for the base 
class (object) which does not have the function you are trying to access.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Kayode Odeyemi
On Tue, Sep 13, 2011 at 5:46 PM, Prasad, Ramit wrote:

> >You should be passed super the current class you want the super class of,
> not the type of the super class. So it should be:
>
> >super(*B*, self).log('system') # Notice that it passed class B
>
> ** **
>
> Ugh, apologies for the poor English; my tea has not kicked in.
>
> ** **
>
> That first line would be more understandable as:  ‘You should pass the
> current class (B) you want the super class of, not the type of the super
> class (A) itself. So it should be:’
>
> ** **
>
> To clarify, by passing A to super it retrieves the definition for the base
> class (object) which does not have the function you are trying to access.*
> ***
>
> ** **
>
> Ramit
>

Thanks for helping me clarify on how to use super() in Py2+. That really
worked!

>>> class B(A):
... def __init__(self, module):
... self.module = A.log(self, module)
... print self.module # printing here is completely unnecessary
in a good OOP language
...
>>> c = B('system')
logged
>>> class B(A):
... def __init__(self, module):
... print super(B, self).log('system') # printing here is
completely unnecessary in a good OOP language
...
>>> c = B('system')
logged
>>>

When an instance of a class is created, all codes within that instance block
should be executed. That's my understanding of OOP.

Thanks everyone!


> 
>
> ** **
>
> ** **
>
> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
>
> 712 Main Street | Houston, TX 77002
>
> work phone: 713 - 216 - 5423
>
> 
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of securities,
> accuracy and completeness of information, viruses, confidentiality, legal
> privilege, and legal entity disclaimers, available at
> http://www.jpmorgan.com/pages/disclosures/email.
>



-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Ian Kelly
On Tue, Sep 13, 2011 at 10:56 AM, Kayode Odeyemi  wrote:
 class B(A):
> ...     def __init__(self, module):
> ...             self.module = A.log(self, module)
> ...             print self.module # printing here is completely unnecessary
> in a good OOP language
> ...
 c = B('system')
> logged
 class B(A):
> ...     def __init__(self, module):
> ...             print super(B, self).log('system') # printing here is
> completely unnecessary in a good OOP language
> ...
 c = B('system')
> logged

> When an instance of a class is created, all codes within that instance block
> should be executed. That's my understanding of OOP.

The initializer should be executed, which is what Python does.  Your
initializer then calls A.log, which does nothing interesting at all.

My question is, what exactly is it that you intend A.log to do?  As
written, it does not do any logging.  It merely constructs a string
and then returns it.  Neither constructing a string, nor returning a
string, imply logging it or printing it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Vlastimil Brom
2011/9/13 Alec Taylor :
> Hmm, nothing mentioned so far works for me...
>
> Here's a very small test case:
>
 python -u "Convert to Creole.py"
>  File "Convert to Creole.py", line 1
> SyntaxError: Non-ASCII character '\xe2' in file Convert to Creole.py
> on line 1, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details
 Exit Code: 1
>
> Line 1: a=u'''≤'''.encode("ascii", "ignore").decode("ascii")
>
> On Tue, Sep 13, 2011 at 11:33 PM, Vlastimil Brom
>  wrote:
>> 2011/9/13 ron :
>>>
>>> Depending on the load, you can do something like:
>>>
>>> "".join([x for x in string if ord(x) < 128])
>>>
>>> It's worked great for me in cleaning input on webapps where there's a
>>> lot of copy/paste from varied sources.
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>> Well, for this kind of dirty "data cleaning" you may as well use e.g.
>>
> u"äteöxt ÛÜÝ wiÉÊËÌthÞßà áânoûüýþn ASɔɕɖCɗɘəɚɛIɗɘəɚɛIεζ iηθιn 
> жзbetийклweeჟრსn .ტუ..ფ".encode("ascii", "ignore").decode("ascii")
>> u'text  with non ASCII in between ...'
>
>>
>> vbr
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>

Ok, in that case the encoding probably would be utf-8; \xe2 is just
the first part of the encoded data

>>> u'≤'.encode("utf-8")
'\xe2\x89\xa4'
>>>

Setting this encoding at the beginning of the file, as mentioned
before, might solve the problem while retaining the symbol in question
(or you could move from syntax error to some unicode related error
depending on other circumstances...).

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


Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Dave Angel

On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote:


When an instance of a class is created, all codes within that instance block
should be executed. That's my understanding of OOP.

I don't understand this phrasing at all.   Could you show a specific 
example of something that does not execute code you think should be 
executed?  I suspect you're just confused by things the interactive 
session is printing out, which are not part of the language, and work a 
bit differently.


DaveA

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


Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Kayode Odeyemi
On Tue, Sep 13, 2011 at 8:31 PM, Dave Angel  wrote:

> I suspect you're just confused by things the interactive session is
> printing out, which are not part of the language, and work a bit
> differently.


You are right. This is where I missed it. The command interface requires a
print command, as against using a return statement.

My apologies.



-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: unpyc3 - a python bytecode decompiler for Python3

2011-09-13 Thread Arnaud Delobelle
Hi all,

Unpyc3 can recreate Python3 source code from code objects, function
source code from function objects, and module source code from .pyc
files. The current version is able to decompile itself successfully
:). It has been tested with Python3.2 only.

It currently reconstructs most of Python 3 (see TODO below) constructs
but probably needs to be tested more thoroughly. All feedback welcome.

Unpyc3 is a single file and is available at http://code.google.com/p/unpyc3/

Example:

>>> from unpyc3 import decompile
>>> def foo(x, y, z=3, *args):
...global g
...for i, j in zip(x, y):
...if z == i + j or args[i] == j:
...g = i, j
...return
...
>>> print(decompile(foo))
def foo(x, y, z=3, *args):
global g
for i, j in zip(x, y):
if z == i + j or args[i] == j:
g = i, j
return

TODO:

* Support for keyword-only arguments
* Handle assert statements
* Show docstrings for functions and modules
* Nice spacing between function/class declarations

Have fun!

Note: unpyc3 is totally unrelated to another project called "unpyc"
which I discovered when I tried to register the same project name on
google code.

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


Need some experience

2011-09-13 Thread Tim Hanson
I have been a desktop Linux user for better than eleven years, as a hobby.  
Back when we still did most of our computing on desktops I even set up a 
rudimentary server setup in my home.  Nothing fancy or anything, but I was 
proud of it and of the fact that it was built Microsoft free.  I have no 
formal education in IT nor programming.  Retired now, my career was finance; I 
was an IRS field agent.

Since retiring two years ago, I have renewed my interest in software.  I know 
some C and lately decided to learn Python.  I have worked through a couple of 
the introductory texts and have a feeling for the OOP model, although I won't 
be able to  call myself an experienced practitioner anytime soon.

I am looking for an open source project that will allow me to develop my 
skills further.

Financially, I'm set; I'm not looking for a job.  I'm looking for some drudge 
work, where I can look at other peoples' code and make a contribution.  
Naturally I do not want to do this forever; I'm hoping to get up to speed with 
my skill set so I can work to more complexity later.

Does anyone have some ideas that would help me?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Thomas Jollans
On 13/09/11 22:25, Tim Hanson wrote:
> I have been a desktop Linux user for better than eleven years, as a hobby.  
> Back when we still did most of our computing on desktops I even set up a 
> rudimentary server setup in my home.  Nothing fancy or anything, but I was 
> proud of it and of the fact that it was built Microsoft free.  I have no 
> formal education in IT nor programming.  Retired now, my career was finance; 
> I 
> was an IRS field agent.
> 
> Since retiring two years ago, I have renewed my interest in software.  I know 
> some C and lately decided to learn Python.  I have worked through a couple of 
> the introductory texts and have a feeling for the OOP model, although I won't 
> be able to  call myself an experienced practitioner anytime soon.
> 
> I am looking for an open source project that will allow me to develop my 
> skills further.
> 
> Financially, I'm set; I'm not looking for a job.  I'm looking for some drudge 
> work, where I can look at other peoples' code and make a contribution.  
> Naturally I do not want to do this forever; I'm hoping to get up to speed 
> with 
> my skill set so I can work to more complexity later.
> 
> Does anyone have some ideas that would help me?

This is becoming something of an FAQ - I don't suppose there's a canned
response link somewhere ? ;-)

I like to recommend CPython itself — which is a bit hypocritical, as I
haven't touched it in quite a while. It has a constantly overflowing bug
tracker where I'm sure you can find a lot of fascinating problems that
need solving. The community, I have found, is welcoming and friendly.
Much of the standard library is written in Python, but if you know C,
you can have a go at the C code as well.

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


Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 01:37:05 pm Thomas Jollans wrote:
> On 13/09/11 22:25, Tim Hanson wrote:
> > I have been a desktop Linux user for better than eleven years, as a
> > hobby. Back when we still did most of our computing on desktops I even
> > set up a rudimentary server setup in my home.  Nothing fancy or
> > anything, but I was proud of it and of the fact that it was built
> > Microsoft free.  I have no formal education in IT nor programming. 
> > Retired now, my career was finance; I was an IRS field agent.
> > 
> > Since retiring two years ago, I have renewed my interest in software.  I
> > know some C and lately decided to learn Python.  I have worked through a
> > couple of the introductory texts and have a feeling for the OOP model,
> > although I won't be able to  call myself an experienced practitioner
> > anytime soon.
> > 
> > I am looking for an open source project that will allow me to develop my
> > skills further.
> > 
> > Financially, I'm set; I'm not looking for a job.  I'm looking for some
> > drudge work, where I can look at other peoples' code and make a
> > contribution. Naturally I do not want to do this forever; I'm hoping to
> > get up to speed with my skill set so I can work to more complexity
> > later.
> > 
> > Does anyone have some ideas that would help me?
> 
> This is becoming something of an FAQ - I don't suppose there's a canned
> response link somewhere ? ;-)
> 
> I like to recommend CPython itself — which is a bit hypocritical, as I
> haven't touched it in quite a while. It has a constantly overflowing bug
> tracker where I'm sure you can find a lot of fascinating problems that
> need solving. The community, I have found, is welcoming and friendly.
> Much of the standard library is written in Python, but if you know C,
> you can have a go at the C code as well.
> 
> Thomas

That's not a bad idea.  From the past I know that bug fixing is a great way to 
learn a language.  If you know a specific site to key in on, feel free to send 
me there.  Otherwise I'll poke around the Python site and find it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 01:37:05 pm Thomas Jollans wrote:
> On 13/09/11 22:25, Tim Hanson wrote:
> > I have been a desktop Linux user for better than eleven years, as a
> > hobby. Back when we still did most of our computing on desktops I even
> > set up a rudimentary server setup in my home.  Nothing fancy or
> > anything, but I was proud of it and of the fact that it was built
> > Microsoft free.  I have no formal education in IT nor programming. 
> > Retired now, my career was finance; I was an IRS field agent.
> > 
> > Since retiring two years ago, I have renewed my interest in software.  I
> > know some C and lately decided to learn Python.  I have worked through a
> > couple of the introductory texts and have a feeling for the OOP model,
> > although I won't be able to  call myself an experienced practitioner
> > anytime soon.
> > 
> > I am looking for an open source project that will allow me to develop my
> > skills further.
> > 
> > Financially, I'm set; I'm not looking for a job.  I'm looking for some
> > drudge work, where I can look at other peoples' code and make a
> > contribution. Naturally I do not want to do this forever; I'm hoping to
> > get up to speed with my skill set so I can work to more complexity
> > later.
> > 
> > Does anyone have some ideas that would help me?
> 
> This is becoming something of an FAQ - I don't suppose there's a canned
> response link somewhere ? ;-)
> 
> I like to recommend CPython itself — which is a bit hypocritical, as I
> haven't touched it in quite a while. It has a constantly overflowing bug
> tracker where I'm sure you can find a lot of fascinating problems that
> need solving. The community, I have found, is welcoming and friendly.
> Much of the standard library is written in Python, but if you know C,
> you can have a go at the C code as well.
> 
> Thomas
Never mind.  I found it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Christian Heimes
Am 13.09.2011 22:52, schrieb Tim Hanson:
> That's not a bad idea.  From the past I know that bug fixing is a great way 
> to 
> learn a language.  If you know a specific site to key in on, feel free to 
> send 
> me there.  Otherwise I'll poke around the Python site and find it.

It's a great idea. We are always looking for volunteers that help the
community to reduce the amount of open bugs. The bug tracker at
http://bugs.python.org/ even has a category for beginners. You just have
to search for keyword -> easy and you'll get a bunch of low hanging
fruits to pick from.

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


Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 02:36:52 pm Christian Heimes wrote:
> Am 13.09.2011 22:52, schrieb Tim Hanson:
> > That's not a bad idea.  From the past I know that bug fixing is a great
> > way to learn a language.  If you know a specific site to key in on, feel
> > free to send me there.  Otherwise I'll poke around the Python site and
> > find it.
> 
> It's a great idea. We are always looking for volunteers that help the
> community to reduce the amount of open bugs. The bug tracker at
> http://bugs.python.org/ even has a category for beginners. You just have
> to search for keyword -> easy and you'll get a bunch of low hanging
> fruits to pick from.

This is exactly what I'm looking for. I don't know who is the "volunteer"  
here, me for obvious reasons, or the Python community for doing some free 
hand-holding.  Now I know how I'll spend the next year.  Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


ImportError: cannot import name dns

2011-09-13 Thread Jack Bates
Why is the following ImportError raised?

$ ./test
Traceback (most recent call last):
  File "./test", line 3, in 
from foo import dns
  File "/home/jablko/foo/dns.py", line 1, in 
from foo import udp
  File "/home/jablko/foo/udp.py", line 1, in 
from foo import dns
ImportError: cannot import name dns
$

I reproduce this error with the following four files and five lines:

== foo/dns.py ==
from foo import udp

== foo/udp.py ==
from foo import dns

== foo/__init__.py ==
(empty)

== test ==
#!/usr/bin/env python

from foo import dns
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Ben Finney
Tim Hanson  writes:

> On Tuesday, September 13, 2011 02:36:52 pm Christian Heimes wrote:
> > We are always looking for volunteers that help the community to
> > reduce the amount of open bugs. The bug tracker at
> > http://bugs.python.org/ even has a category for beginners. You just
> > have to search for keyword -> easy and you'll get a bunch of low
> > hanging fruits to pick from.
>
> This is exactly what I'm looking for. I don't know who is the "volunteer"  
> here, me for obvious reasons, or the Python community for doing some free 
> hand-holding.  Now I know how I'll spend the next year.  Thank you!

Excellent attitude. Thank you in advance for contributing to the Python
community.

-- 
 \“With Lisp or Forth, a master programmer has unlimited power |
  `\ and expressiveness. With Python, even a regular guy can reach |
_o__)   for the stars.” —Raymond Hettinger |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Usenet newsgroup news:comp.lang.python ...

2011-09-13 Thread Ben Finney
mano mano  writes:

> Mikael Lyngvig accurately summarizes comp.lang.python discussion

No, you're posting spam links. Go away and spend the rest of your
miserable life in a deep hole.

-- 
 \  “If society were bound to invent technologies which could only |
  `\   be used entirely within the law, then we would still be sitting |
_o__)   in caves sucking our feet.” —Gene Kan, creator of Gnutella |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: The Usenet newsgroup news:comp.lang.python ...

2011-09-13 Thread Prasad, Ramit
>> Mikael Lyngvig accurately summarizes comp.lang.python discussion

>No, you're posting spam links. Go away and spend the rest of your
>miserable life in a deep hole.

I was wondering since the text seemed like plausible non-spam (to me). 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Usenet newsgroup news:comp.lang.python ...

2011-09-13 Thread Chris Angelico
On Wed, Sep 14, 2011 at 8:53 AM, Prasad, Ramit
 wrote:
> I was wondering since the text seemed like plausible non-spam (to me).
>

I suspect it was autogenerated from subject lines of recent emails.
It'd not be hard to design a template that covers comp.lang.* or even
comp.*.

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


RE: ImportError: cannot import name dns

2011-09-13 Thread Prasad, Ramit
-Original Message-
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
Jack Bates
Sent: Tuesday, September 13, 2011 5:28 PM
To: [email protected]
Subject: ImportError: cannot import name dns

Why is the following ImportError raised?

$ ./test
Traceback (most recent call last):
  File "./test", line 3, in 
from foo import dns
  File "/home/jablko/foo/dns.py", line 1, in 
from foo import udp
  File "/home/jablko/foo/udp.py", line 1, in 
from foo import dns
ImportError: cannot import name dns
$

I reproduce this error with the following four files and five lines:

== foo/dns.py ==
from foo import udp

== foo/udp.py ==
from foo import dns

== foo/__init__.py ==
(empty)

== test ==
#!/usr/bin/env python

from foo import dns


===
 
It is a circular dependency. Dns will try to import udp which will in turn 
import dns (again) in an endless cycle; instead an ImportError is raised. 

Circular dependency is a Bad Thing.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Terry Reedy



It's a great idea. We are always looking for volunteers that help the
community to reduce the amount of open bugs. The bug tracker at
http://bugs.python.org/ even has a category for beginners. You just have
to search for keyword ->  easy and you'll get a bunch of low hanging
fruits to pick from.


This is exactly what I'm looking for. I don't know who is the "volunteer"
here, me for obvious reasons, or the Python community for doing some free
hand-holding.  Now I know how I'll spend the next year.  Thank you!


Also consider the core-mentorship mailing list and the dev guide at
http://docs.python.org/devguide
--
Terry Jan Reedy

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


Offer various hats including Red Bull Hats on http://www.mlbhatshop.com/

2011-09-13 Thread zhenzhen zhang
Defending MX2 champion Ken is currently leading the MX2 championship
while Max Nagl heads to his favourite track of the season looking for
points to close the gap on fellow Red Bull Teka KTM Factory Racing
team http://www.mlbhatshop.com/  rider Tony Cairoli.  by red bull
hats.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need some experience

2011-09-13 Thread Tim Hanson
On Tuesday, September 13, 2011 06:12:27 pm Terry Reedy wrote:
> >> It's a great idea. We are always looking for volunteers that help the
> >> community to reduce the amount of open bugs. The bug tracker at
> >> http://bugs.python.org/ even has a category for beginners. You just have
> >> to search for keyword ->  easy and you'll get a bunch of low hanging
> >> fruits to pick from.
> > 
> > This is exactly what I'm looking for. I don't know who is the "volunteer"
> > here, me for obvious reasons, or the Python community for doing some free
> > hand-holding.  Now I know how I'll spend the next year.  Thank you!
> 
> Also consider the core-mentorship mailing list and the dev guide at
> http://docs.python.org/devguide

This is equally helpful.  Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: Itertools module needs attention

2011-09-13 Thread rantingrick
On Sep 13, 10:45 am, Ian Kelly  wrote:

> Have you looked at the online itertools documentation at all?
>
> http://docs.python.org/library/itertools.html

Yes the online docs are much better. I really like the source code
showing the inner workings of the methods. However i always get upset
when i see poorly thought out doc-strings. My philosophy is that we
should use the built in help function first and only visit the
documentation if more instruction is needed.


I may need to create another PyWart on the topic of doc-strings and
how the author of these strings needs to forget everything he knows
and imagine he is a complete python neophyte. I remember my initial
frustrations learning about functions (in another life it seems) and
my inability to grasp the concept was due to poor examples. I believe
the author use the Fibonacci sequence as an example (Python docs use
this example also). What an idiot!

What does conditionals, linear assignment, loops, the print function,
in-place addition, logic, blah, blah, have to do with understanding a
function... NOTHING! The most basic and by far the best first example
for functions (in any language) is this...

def add(x, y):
return x + y

Followed by this...

def sub(x,y):
return x - y

Simple and to the point. It simply reeks of "ah ha"! I dare anyone to
create a better introductory function example. Dear Tutorial Writer:
When writing tutorials please check your ego at the door. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


GIL switch interval

2011-09-13 Thread Matt Joiner
i'm curious as to what can be done with (and handled better) by
adjusting sys.setswitchinterval
i've opened a question on SO for this, that people might find of
interest: 
http://stackoverflow.com/questions/7376776/sys-setswitchinterval-in-python-3-2-and-beyond
-- 
http://mail.python.org/mailman/listinfo/python-list


Connection reset by peer

2011-09-13 Thread 守株待兔
there is a multi-threads program  dowloading  data from yahoo,the main 
structure is as the following(omit something  unimportant )


class   webdata(object):
def  __init__(self,name):
self.jobs = Queue.Queue()
if  x  in  name:
self.jobs.put(x)
def  download(self):
   try:
weburl=self.jobs.get()
url = weburl
hx = httplib2.Http()
resp, content = hx.request(url, headers=headers)   
print
self.jobs.task_done()
except:
print  url,"wrong"
self.jobs.task_done()
   
def  run(self):   
for i in range(30):
  threading.Thread(target=self.download).start()  
self.jobs.join()
   
if  __name__=="__main__": 
 webdata('quote').run()



quote  is  a  list  which  i want to download,i was confused ,this program  can 
download something,
can't download something,
when i cancel  try,except , i get the output:
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1436, 
in request
(response, content) = self._request(conn, authority, uri, request_uri, 
method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 
1188, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, 
headers)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 
1171, in _conn_request
content = response.read()
  File "/usr/lib/python2.7/httplib.py", line 541, in read
return self._read_chunked(amt)
  File "/usr/lib/python2.7/httplib.py", line 590, in _read_chunked
value.append(self._safe_read(chunk_left))
  File "/usr/lib/python2.7/httplib.py", line 647, in _safe_read
chunk = self.fp.read(min(amt, MAXAMOUNT))
  File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer

i  want to know,  my  computer(client)  reset  it  ,or  the yahoo (server)  
reset it ,what is the peer??-- 
http://mail.python.org/mailman/listinfo/python-list


stackoverflow and c.l.py (was: GIL switch interval)

2011-09-13 Thread Stefan Behnel

Matt Joiner, 14.09.2011 04:23:

i'm curious as to what can be done with (and handled better) by
adjusting sys.setswitchinterval
i've opened a question on SO for this, that people might find of
interest: http://stackoverflow.com[...]


I wonder why people ask this kind of question on stackoverflow, and then 
come here asking people to go over there, read the question, and 
(potentially) provide an answer.


IMHO, c.l.py is a much better place to ask Python(-related) questions than 
stackoverflow. It's also a much better place to search for an answer that 
is already available in the archives.


Stefan

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


Re: stackoverflow and c.l.py (was: GIL switch interval)

2011-09-13 Thread Steven D'Aprano
On Wed, 14 Sep 2011 02:12 pm Stefan Behnel wrote:

> Matt Joiner, 14.09.2011 04:23:
>> i'm curious as to what can be done with (and handled better) by
>> adjusting sys.setswitchinterval
>> i've opened a question on SO for this, that people might find of
>> interest: http://stackoverflow.com[...]
> 
> I wonder why people ask this kind of question on stackoverflow, and then
> come here asking people to go over there, read the question, and
> (potentially) provide an answer.

You should post that question on stackoverflow, and ask them to reply here.



-- 
Steven

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


Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2011-09-13 Thread Vincent Vande Vyvre


  
  
Le 13/09/11 22:20, Arnaud Delobelle a écrit :

  Hi all,

Unpyc3 can recreate Python3 source code from code objects, function
source code from function objects, and module source code from .pyc
files. The current version is able to decompile itself successfully
:). It has been tested with Python3.2 only.

It currently reconstructs most of Python 3 (see TODO below) constructs
but probably needs to be tested more thoroughly. All feedback welcome.

Unpyc3 is a single file and is available at http://code.google.com/p/unpyc3/

Example:


  

  
from unpyc3 import decompile
def foo(x, y, z=3, *args):

  

  
  ...global g
...for i, j in zip(x, y):
...if z == i + j or args[i] == j:
...g = i, j
...return
...

  

  
print(decompile(foo))

  

  
  def foo(x, y, z=3, *args):
global g
for i, j in zip(x, y):
if z == i + j or args[i] == j:
g = i, j
return

TODO:

* Support for keyword-only arguments
* Handle assert statements
* Show docstrings for functions and modules
* Nice spacing between function/class declarations

Have fun!

Note: unpyc3 is totally unrelated to another project called "unpyc"
which I discovered when I tried to register the same project name on
google code.



Hi, trying your code, I have had numbers of errors:

  File "unpyc3.py", line 55, in 
    SETUP_WITH,
NameError: name 'SETUP_WITH' is not defined

commented it

  File "unpyc3.py", line 58, in 
    STORE_DEREF, DELETE_DEREF,
NameError: name 'DELETE_DEREF' is not defined

commented it

  File "unpyc3.py", line 96, in dec_module
    stream = open(pyc_path, "rb")
UnboundLocalError: local variable 'pyc_path' referenced before
assignment

change pyc_path to path

  File "unpyc3.py", line 98, in dec_module
    code = Code(code_obj)
  File "unpyc3.py", line 210, in __init__
    for v in code_obj.co_cellvars + code_obj.co_freevars]
AttributeError: 'NoneType' object has no attribute 'co_cellvars'

...

Cheers

-- 
  Vincent V.V.
  Oqapy . Qarte+7 . PaQager
  


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


memory error

2011-09-13 Thread questions anon
Hello All,
I keep coming across a memory error when processing many netcdf files. I
assume it has something to do with how I loop things and maybe need to close
things off properly.
In the code below I am looping through a bunch of netcdf files (each file is
hourly data for one month) and within each netcdf file I am outputting a
*png file every three hours.
This works for one netcdf file but when it begins to process the next netcdf
file I receive this memory error:

*Traceback (most recent call last):
  File
"d:/plot_netcdf_merc_multiplot_across_multifolders_mkdirs_memoryerror.py",
line 44, in 
TSFC=ncfile.variables['T_SFC'][:]
  File "netCDF4.pyx", line 2473, in netCDF4.Variable.__getitem__
(netCDF4.c:23094)
MemoryError*

To reduce processing requirements I have tried making the LAT and LON to
only use [0] but I also receive an error:

*Traceback (most recent call last):
  File
"d:/plot_netcdf_merc_multiplot_across_multifolders_mkdirs_memoryerror.py",
line 75, in 
x,y=map(*N.meshgrid(LON,LAT))
  File "C:\Python27\lib\site-packages\numpy\lib\function_base.py", line
3256, in meshgrid
numRows, numCols = len(y), len(x)  # yes, reversed
TypeError: len() of unsized object*

finally I have added gc.collect() in a couple of places but that doesn't
seem to do anything to help.
I am using :*Python 2.7.2 |EPD 7.1-2 (32-bit)| (default, Jul  3 2011,
15:13:59) [MSC v.1500 32 bit (Intel)] on win32*
Any feedback will be greatly appreciated!


from netCDF4 import Dataset
import numpy
import numpy as N
import matplotlib.pyplot as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
from netcdftime import utime
from datetime import datetime
import os
import gc

print "start processing"

inputpath=r'E:/GriddedData/Input/'
outputpath=r'E:/GriddedData/Validation/'
shapefile1="E:/test_GIS/DSE_REGIONS"
for (path, dirs, files) in os.walk(inputpath):
for dir in dirs:
print dir
sourcepath=os.path.join(path,dir)
relativepath=os.path.relpath(sourcepath,inputpath)
newdir=os.path.join(outputpath,relativepath)
if not os.path.exists(newdir):
os.makedirs(newdir)

for ncfile in files:
if ncfile[-3:]=='.nc':
print "dealing with ncfiles:", ncfile
ncfile=os.path.join(sourcepath,ncfile)
#print ncfile
ncfile=Dataset(ncfile, 'r+', 'NETCDF4')
TSFC=ncfile.variables['T_SFC'][:,:,:]
TIME=ncfile.variables['time'][:]
LAT=ncfile.variables['latitude'][:]
LON=ncfile.variables['longitude'][:]
fillvalue=ncfile.variables['T_SFC']._FillValue
TSFC=MA.masked_values(TSFC, fillvalue)
ncfile.close()
gc.collect()
print "garbage collected"


for TSFC, TIME in zip((TSFC[1::3]),(TIME[1::3])):
print TSFC, TIME
#convert time from numbers to date and prepare it to have no
symbols for saving to filename
cdftime=utime('seconds since 1970-01-01 00:00:00')
ncfiletime=cdftime.num2date(TIME)
print ncfiletime
timestr=str(ncfiletime)
d = datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S')
date_string = d.strftime('%Y%m%d_%H%M')

#Set up basemap using mercator projection
http://matplotlib.sourceforge.net/basemap/doc/html/users/merc.html
map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,

llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')

# compute map projection coordinates for lat/lon grid.
x,y=map(*N.meshgrid(LON,LAT))
map.drawcoastlines(linewidth=0.5)
map.readshapefile(shapefile1, 'DSE_REGIONS')
map.drawstates()

plt.title('Surface temperature at %s UTC'%ncfiletime)
ticks=[-5,0,5,10,15,20,25,30,35,40,45,50]
CS = map.contourf(x,y,TSFC, ticks, cmap=plt.cm.jet)
l,b,w,h =0.1,0.1,0.8,0.8
cax = plt.axes([l+w+0.025, b, 0.025, h], )
cbar=plt.colorbar(CS, cax=cax, drawedges=True)

#save map as *.png and plot netcdf file

plt.savefig((os.path.join(newdir,'TSFC'+date_string+'UTC.png')))
plt.close()
gc.collect()
print "garbage collected again"
print "end of processing"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2011-09-13 Thread Arnaud Delobelle
On 14 September 2011 06:53, Vincent Vande Vyvre
 wrote:
>
> Hi, trying your code, I have had numbers of errors:

Hi Vincent, thanks for trying it.

>   File "unpyc3.py", line 55, in 
>     SETUP_WITH,
> NameError: name 'SETUP_WITH' is not defined
>
> commented it
>
>   File "unpyc3.py", line 58, in 
>     STORE_DEREF, DELETE_DEREF,
> NameError: name 'DELETE_DEREF' is not defined
>
> commented it

What version of Python are you running this on?  This is module is
written for Python 3.  It looks like you're using an old version of
Python (before the with statement was introduced - 2.5?)

>   File "unpyc3.py", line 96, in dec_module
>     stream = open(pyc_path, "rb")
> UnboundLocalError: local variable 'pyc_path' referenced before assignment
>
> change pyc_path to path

Thanks, I've fixed that.

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


Re: stackoverflow and c.l.py

2011-09-13 Thread Ethan Furman

Steven D'Aprano wrote:

On Wed, 14 Sep 2011 02:12 pm Stefan Behnel wrote:


Matt Joiner, 14.09.2011 04:23:

i'm curious as to what can be done with (and handled better) by
adjusting sys.setswitchinterval
i've opened a question on SO for this, that people might find of
interest: http://stackoverflow.com[...]

I wonder why people ask this kind of question on stackoverflow, and then
come here asking people to go over there, read the question, and
(potentially) provide an answer.


You should post that question on stackoverflow, and ask them to reply here.


+10!
--
http://mail.python.org/mailman/listinfo/python-list