Re: learning curve

2012-12-28 Thread Terry Reedy

On 12/27/2012 8:20 PM, Verde Denim wrote:

Just getting into Py coding and not understanding why this code doesn't
seem to do anything -


Part of your 'learning curve' should be learning to write informative 
subjects lines. The above says almost nothing. For this I suggest 
"Problem with classes and tkinter". In this case, you specifically need 
to add the tkinter startup code; check the example in the manual. If you 
do add that, you code may run, but it may required advice with someone 
with tkinter expertise (and interest) beyond mind.


Also, if you are just starting, I recommend you start with 3.3 unless 
you have a good reason to start with an older version. (IE, you need to 
use a third party library that only runs with 2.x.)



# File: dialog2.py
import dialog_handler

class MyDialog(dialog_handler.Dialog):
 def body(self, master):
 Label(master, text="First:").grid(row=0)
 Label(master, text="Second:").grid(row=1)
 self.e1 = Entry(master)
 self.e2 = Entry(master)
 self.e1.grid(row=0, column=1)
 self.e2.grid(row=1, column=1)
 return self.e1 # initial focus

 def apply(self):
 first = string.atoi(self.e1.get())
 second = string.atoi(self.e2.get())
 print first, second # or something

# File: dialog_handler.py

from Tkinter import *
import os

class Dialog(Toplevel):

 def __init__(self, parent, title = None):
 Toplevel.__init__(self, parent)
 self.transient(parent)

 if title:
 self.title(title)
 self.parent = parent
 self.result = None
 body = Frame(self)
 self.initial_focus = self.body(body)
 body.pack(padx=5, pady=5)
 self.buttonbox()
 self.grab_set()

 if not self.initial_focus:
 self.initial_focus = self

 self.protocol("WM_DELETE_WINDOW", self.cancel)
 self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
   parent.winfo_rooty()+50))
 self.initial_focus.focus_set()
 self.wait_window(self)

 #
 # construction hooks
 def body(self, master):
 # create dialog body.  return widget that should have
 # initial focus.  this method should be overridden
 pass

 def buttonbox(self):
 # add standard button box. override if you don't want the
 # standard buttons
 box = Frame(self)

 w = Button(box, text="OK", width=10, command=self.ok,
default=ACTIVE)
 w.pack(side=LEFT, padx=5, pady=5)
 w = Button(box, text="Cancel", width=10,
command=self.cancel)
 w.pack(side=LEFT, padx=5, pady=5)

 self.bind("", self.ok)
 self.bind("", self.cancel)

 box.pack()

 #
 # standard button semantics
 def ok(self, event=None):
 if not self.validate():
 self.initial_focus.focus_set() # put focus back
 return
 self.withdraw()
 self.update_idletasks()
 self.apply()
 self.cancel()

 def cancel(self, event=None):
 # put focus back to the parent window
 self.parent.focus_set()
 self.destroy()

 #
 # command hooks
 def validate(self):
 return 1 # override

 def apply(self):
 pass # override




--
Terry Jan Reedy

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


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Yuvraj Sharma
Use IDLE
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Andrew Berg
On 2012.12.28 00:51, Jamie Paul Griffin wrote:
> The benefit of the tmux client (terminal multiplexer) is that I can see
> all the screens at the same time and quickly switch between them. I
> believe Linux has screen(1) which does the same thing. 

tmux is generally easily available for Linux, and these days, there's
really no reason to use screen unless you absolutely cannot use tmux for
some reason.

To answer the OP's question, it's mostly personal preference. Use
whatever makes you productive.
-- 
CPython 3.3.0 | Windows NT 6.2.9200.16461
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Chris Angelico
On Fri, Dec 28, 2012 at 8:52 PM, Andrew Berg  wrote:
> On 2012.12.28 00:51, Jamie Paul Griffin wrote:
>> The benefit of the tmux client (terminal multiplexer) is that I can see
>> all the screens at the same time and quickly switch between them. I
>> believe Linux has screen(1) which does the same thing.
>
> tmux is generally easily available for Linux, and these days, there's
> really no reason to use screen unless you absolutely cannot use tmux for
> some reason.

Hmm, interesting. I often use screen when I need a terminal on a
remote system (via ssh) and I'm mobile on my laptop, with periodic
connection dropouts. With screen(1), I can cope with that, but it's a
bit ugly at times.

*puts tmux on his "look into this some day" list*

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


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Kwpolska
On Thu, Dec 27, 2012 at 9:01 PM, mogul  wrote:
> 'Aloha!
Hello!
> I'm new to python, got 10-20 years perl and C experience, all gained on unix 
> alike machines hacking happily in vi, and later on in vim.

You are already awesome,

> Now it's python, and currently mainly on my kubuntu desktop.

and now you just became more awesome.  (sans the Kubuntu part, but I
do not care.)

> Do I really need a real IDE, as the windows guys around me say I do, or will 
> vim, git, make and other standalone tools make it the next 20 years too for 
> me?

Do you really think that those Windows idiots know what they are
talking about?  It’s Windows, for fuck’s sake.  The only OS in the
market that does not give a shit about POSIX.  Windows does need an
IDE, then, because it is really hard to do anything useful without
one.  Sure, this mail was sent from Windows, but I am using it for
gaming purposes.  If I want to do some programming, Linux is the
proper environment.  For me, it is Arch Linux with KDE and Konsole,
running tabs of vim (with [python-mode][]) and ipython.  And other
useful tools (among others, Chrome with the docs.)

[python-mode]: https://github.com/klen/python-mode

> Oh, by the way, after 7 days I'm completely in love with this python thing. I 
> should have made the switch much earlier!

That is great news.

-- 
Kwpolska 
stop html mail  | always bottom-post
www.asciiribbon.org | www.netmeister.org/news/learn2quote.html
GPG KEY: 5EAAEA16
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Custom alphabetical sort

2012-12-28 Thread wxjmfauth
Le vendredi 28 décembre 2012 00:17:53 UTC+1, Ian a écrit :
> On Thu, Dec 27, 2012 at 3:17 PM, Terry Reedy  wrote:
> 
> >> PS Py 3.3 warranty: ~30% slower than Py 3.2
> 
> >
> 
> >
> 
> > Do you have any actual timing data to back up that claim?
> 
> > If so, please give specifics, including build, os, system, timing code, and
> 
> > result.
> 
> 
> 
> There was another thread about this one a while back.  Using IDLE on Windows 
> XP:
> 
> 
> 
> >>> import timeit, locale
> 
> >>> li = ['noël', 'noir', 'nœud', 'noduleux', 'noétique', 'noèse', 'noirâtre']
> 
> >>> locale.setlocale(locale.LC_ALL, 'French_France')
> 
> 'French_France.1252'
> 
> 
> 
> >>> # Python 3.2
> 
> >>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from 
> >>> __main__ import li", number=10))
> 
> 1.1581226105552531
> 
> 
> 
> >>> # Python 3.3.0
> 
> >>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from 
> >>> __main__ import li", number=10))
> 
> 1.4595282361305697
> 
> 
> 
> 1.460 / 1.158 = 1.261
> 
> 
> 
> >>> li = li * 100
> 
> >>> import random
> 
> >>> random.shuffle(li)
> 
> 
> 
> >>> # Python 3.2
> 
> >>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from 
> >>> __main__ import li", number=1000))
> 
> 1.233450899485831
> 
> 
> 
> >>> # Python 3.3.0
> 
> >>> min(timeit.repeat("sorted(li, key=locale.strxfrm)", "import locale; from 
> >>> __main__ import li", number=1000))
> 
> 1.5793845307155152
> 
> 
> 
> 1.579 / 1.233 = 1.281
> 
> 
> 
> So about 26% slower for sorting a short list of French words and about
> 
> 28% slower for a longer list.  Replacing the strings with ASCII and
> 
> removing the 'key' argument gives a comparable result for the long
> 
> list but more like a 40% slowdown for the short list.



Not related to this thread, for information.

My sorting algorithm is doing a little bit more than a 
"locale.strxfrm". locale.strxfrm works precisely fine with
the list I gave as an exemple, it fails in many cases. One
of the bottlenecks is the "œ", which must be seen as "oe".
It is not the place to discuss this kind of linguistic aspects
here.

My algorithm does not use unicodedata or unicode normalization.
Mainly a lot of chars / substrings substitution for the
creation of the primary keys.

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


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread gst
Le jeudi 27 décembre 2012 21:01:16 UTC+1, mogul a écrit :
> 'Aloha!
> 

holà !

> 
> I'm new to python, got 10-20 years perl and C experience, all gained on unix 
> alike machines hacking happily in vi, and later on in vim.
> 

About same than me, though I had not to use/work with perl for new projects, 
only in maintaining some existing stuffs in some previous jobs.


> 
> Now it's python, and currently mainly on my kubuntu desktop.
> 
> Do I really need a real IDE, as the windows guys around me say I do, or will 
> vim, git, make and other standalone tools make it the next 20 years too for 
> me? 
> 

Obviously I have same comments than others ;) though I think it mainly depends 
on the project.. I do think/experience that big projects get some real 
advantage of advanced IDE, like eclipse/pycharm and others "big" python IDE. 
Now which one to use is mainly a matter of taste, as always.


> 
> Oh, by the way, after 7 days I'm completely in love with this python thing. 
> 

as others said: welcome to the club :)


> I should have made the switch much earlier!

Don't be afraid of the late switch : you'll very quickly make amazing stuffs 
with Python and anyway it's (always) better late than never and it could be 
better now than some few years ago (I begin to make the switch about 3-4 years 
ago and now I have the luck to work for a company where I'm 100% working with 
Python :)). 
Python3(.2+) effectively corrects some, I'd say, youth problems related to 
python2 and it's now quite highly deployed and about all majors libraries are 
already supporting it, if not they are about all on their way to do it sooner 
than later ;)

 
> /mogul %-)

good work/fun with Python,

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


email.message.Message - as_string fails

2012-12-28 Thread Helmut Jarausch
Hi,

I'm trying to filter an mbox file by removing some messages.
For that I use 
Parser= FeedParser(policy=policy.SMTP)
and 'feed' any lines to it.
If the mbox file contains a white line followed by '^From ',
I do

Msg= Parser.close()

(lateron I delete the Parser and create a new one by
Parser= FeedParser(policy=policy.SMTP)
)

I can access parts of the message by  Msg['Message-ID'], e.g.
but even for the very first message, trying to print it or convert it to a 
string
by  MsgStr=Msg.as_string(unixfrom=True)

lets Python (3.3.1_pre20121209) die with

Traceback (most recent call last):
  File "Email_Parse.py", line 35, in 
MsgStr=Msg.as_string(unixfrom=True)
  File "/usr/lib64/python3.3/email/message.py", line 151, in as_string
g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib64/python3.3/email/generator.py", line 112, in flatten
self._write(msg)
  File "/usr/lib64/python3.3/email/generator.py", line 171, in _write
self._write_headers(msg)
  File "/usr/lib64/python3.3/email/generator.py", line 198, in _write_headers
self.write(self.policy.fold(h, v))
  File "/usr/lib64/python3.3/email/policy.py", line 153, in fold
return self._fold(name, value, refold_binary=True)
  File "/usr/lib64/python3.3/email/policy.py", line 176, in _fold
(len(lines[0])+len(name)+2 > maxlen or
IndexError: list index out of range


What am I missing?

Many thanks for a hint,
Helmut.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python lists

2012-12-28 Thread Manatee
I read in this:
['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N', '10', '2', 
'', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
'490-1521-1-ND', '']

Then I need to convert it to this:
[['C100', 'C117'], 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', 
'2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
'490-1521-1-ND', '']]

The objectinve is too make the first instance a list of lists and have 
component values enclosed in a list. Then I will print out the components, each 
on its own line, followed by the description; for instance.
C100, 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', '2', '', '30', 
'15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', '490-1521-1-ND', ''
c117, 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', '2', '', '30', 
'15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', '490-1521-1-ND', ''

The file is read in from a comma delimited file. I can't seem to work this out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread python培训
too much ide for python
PyCharm 
PyDev(Eclipse) 
Pyscripter 

Sublime Text 
TextMate UliPad
Vim

for beginner best choiceidle
-- 
http://mail.python.org/mailman/listinfo/python-list


Facing issue with Python loggin logger for printing object value

2012-12-28 Thread Morten Engvoldsen
Hi Team,
i am new to python and i am using python loggin for log the value of the
object. Below is my code :

class field:
field_name = ""
length = 0
type = 0
value = ""

def __init__(self, field_name, length, type, value):
self.field_name = field_name
self.length = length
self.type = type
self.value = value

def toString(self):
if self.type == 2:
return self.value.zfill(self.length)
else:
return self.value.ljust(self.length).upper()
class record:
fields = []

def setValue(self, field_name, value):
for element in self.fields:
if field_name == element.field_name:
element.value = value

def toString(self):
_tempStr = ""
for element in self.fields:
_tempStr = _tempStr + element.toString()
if len(_tempStr) < 80:
return _tempStr
else:
_lines = len(_tempStr) / 80
_i = 0
_tempStr2 = ""
_newline = ""
while _i < _lines:
_tempStr2 = _tempStr2 + _newline + _tempStr[_i*80:(_i+1)*80]
_newline = "\n"
_i = _i + 1

return _tempStr2
class First_betfor00(record):

def __init__(self):
self.fields = [field("APPLICATION-HEADER", 40, 1, ""),
  field("TRANSACTION-CODE", 8, 0, "BETFOR00"),
  field("ENTERPRISE-NUMBER", 11, 2, ""),
  field("DIVISION", 11, 1, ""),
  field("SEQUENCE-CONTROL", 4, 2, ""),
  field("RESERVED-1", 6, 1, ""),
  field("PRODUCTION-DATE", 4, 1, "MMDD"),
  field("PASSWORD", 10, 1, ""),
  field("VERSION", 10, 1, "VERSJON002"),
  field("NEW-PASSWORD", 10, 1, ""),
  field("OPERATOR-NO", 11, 1, ""),
  field("SIGILL-SEAL-USE", 1, 1, ""),
  field("SIGILL-SEAL-DATE", 6, 1, ""),
  field("SIGILL-SEAL-KEY", 20, 1, ""),
  field("SIGILL-SEAL-HOW", 1, 1, ""),
  field("RESERVED-2", 143, 1, ""),
  field("OWN-REFERENCE-BATCH", 15, 1, ""),
  field("RESERVED-3", 9, 1, ""),
  ]
class account(osv.osv_memory):
 _name = 'account'

 def create(self,cr,uid,ids,context):
 logger = logging.getLogger('account')
 hdlr = logging.FileHandler('/var/tmp/account')
 formatter = logging.Formatter('%(asctime)s, %(levelname)s,
%(message)s')
 hdlr.setFormatter(formatter)
 logger.addHandler(hdlr)

 batch = ""
 recordCounter = 1
 dateMMDD = time.strftime('%m%d')

 betfor00 = Format_betfor00()
 betfor00.setValue("APPLICATION-HEADER",
applicationHeader.toString())
 betfor00.setValue("ENTERPRISE-NUMBER", enterpriseNumber)
 betfor00.setValue("PRODUCTION-DATE", dateMMDD)
 batch = betfor00.toString()

line_counter = line_counter + 1
log.debug('%(batch)s')
return {'type': 'state', 'state':'end'}
account()


In the above code i am trying to capture the value of 'batch' in the log
file, but when i check log file it doesn't have any value printed. my
question is is it correct way to capture the object value that is
   log.debug('%(batch)s')

I will really appreciate the answer. Thanks in advance..

Regards,
Morten
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python lists

2012-12-28 Thread Roy Smith
In article <[email protected]>,
 Manatee  wrote:

> I read in this:
> ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N', '10', '2', 
> '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', '']
> 
> Then I need to convert it to this:
> [['C100', 'C117'], 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', 
> '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', '']]

You want to convert it into a syntax error???

You've got an extra ']' in there somewhere.  I'm guessing it's the one 
at the end, but that's just a guess.  Could you clarify what you meant?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python lists

2012-12-28 Thread Manatee
On Friday, December 28, 2012 9:14:57 AM UTC-5, Manatee wrote:
> I read in this:
> 
> ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N', '10', '2', 
> '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', '']
> 
> 
> 
> Then I need to convert it to this:
> 
> [['C100', 'C117'], 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', 
> '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', '']]
> 
> 
> 
> The objectinve is too make the first instance a list of lists and have 
> component values enclosed in a list. Then I will print out the components, 
> each on its own line, followed by the description; for instance.
> 
> C100, 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', '2', '', 
> '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', ''
> 
> c117, 'X7R 0.033uF 10% 25V  0603', '0603-C_L', '0603-C_N', '10', '2', '', 
> '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D', 'Digi-Key', 
> '490-1521-1-ND', ''
> 
> 
> 
> The file is read in from a comma delimited file. I can't seem to work this 
> out.

Forgot to list my code, here is my code:

import csv
list = []
t = [0]
with open('38366 Rev 6_12_12_2012_0602pm.csv', 'rb') as f:
  reader = csv.reader(f)
  for row in reader:
repeat_info = row[1:]
for ref_des in row[0]:
t[0] = ref_des
print t + row[1:] 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to detect the character encoding in a web page ?

2012-12-28 Thread python培训
在 2012年12月24日星期一UTC+8上午8时34分47秒,iMath写道:
> how to detect the character encoding  in a web page ?
> 
> such as this page 
> 
> 
> 
> http://python.org/

first setup  chardet 


import chardet
#抓取网页html
html_1 = urllib2.urlopen(line,timeout=120).read()
#print html_1
mychar=chardet.detect(html_1)
#print mychar
bianma=mychar['encoding']
if bianma == 'utf-8' or bianma == 'UTF-8':
#html=html.decode('utf-8','ignore').encode('utf-8')
   html=html_1
else :
html =html_1.decode('gb2312','ignore').encode('utf-8')
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Python Meeting Düsseldorf - 22.01.2013

2012-12-28 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 meeting in Düsseldorf, Germany]


ANKÜNDIGUNG

 Python Meeting Düsseldorf

 http://pyddf.de/

   Ein Treffen von Python Enthusiasten und Interessierten
in ungezwungener Atmosphäre.

  Dienstag, 22.01.2013, 18:00 Uhr
Clara Schumann Raum
  DJH Düsseldorf


Diese Nachricht können Sie auch online lesen:
http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2013-01-22


EINLEITUNG

Das Python Meeting Düsseldorf (http://pyddf.de/) ist eine neue
lokale Veranstaltung in Düsseldorf, die sich an Python Begeisterte
in der Region wendet.

Wir starten bei den Treffen mit einer kurzen Einleitung und gehen
dann zu einer Reihe Kurzvorträgen (Lightning Talks) über, bei denen
die Anwesenden über neue Projekte, interessante Probleme und
sonstige Aktivitäten rund um Python berichten können.

Anschließend geht es in eine Gaststätte, um die Gespräche zu
vertiefen.

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

   http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/


ORT

Für das Python Meeting Düsseldorf haben wir den Clara Schumann
Raum in der modernen Jugendherberge Düsseldorf angemietet:

Jugendherberge Düsseldorf
Düsseldorfer Str. 1
40545 Düsseldorf
Telefon: +49 211 557310
http://www.duesseldorf.jugendherberge.de

Die Jugendherberge verfügt über eine kostenpflichtige Tiefgarage (EUR
2,50 pro Stunde, maximal EUR 10,00). Es ist aber auch möglich per
Bus und Bahn anzureisen. Der Raum befindet sich im 1.OG links.


PROGRAMM

Das Python Meeting Düsseldorf nutzt eine Mischung aus Open Space
und Lightning Talks:

Die Treffen starten mit einer kurzen Einleitung. Danach geht es
weiter mit einer Lightning Talk Session, in der die Anwesenden
Kurzvorträge von fünf Minuten halten können.

Hieraus ergeben sich dann meisten viele Ansatzpunkte für
Diskussionen, die dann den Rest der verfügbaren Zeit in Anspruch
nehmen können.

Für 19:45 Uhr haben wir in einem nahegelegenen Restaurant Plätze
reserviert, damit auch das leibliche Wohl nicht zu kurz kommt.

Lightning Talks können vorher angemeldet werden, oder auch
spontan während des Treffens eingebracht werden. Ein Beamer mit
XGA Auflösung steht zur Verfügung. Folien bitte als PDF auf USB
Stick mitbringen.

Lightning Talk Anmeldung bitte formlos per EMail an [email protected]


KOSTENBETEILIGUNG

Das Python Meeting Düsseldorf wird von Python Nutzern für Python
Nutzer veranstaltet.

Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren,
bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00
inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.


ANMELDUNG

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir
bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung
eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an [email protected]


WEITERE INFORMATIONEN

Weitere Informationen finden Sie auf der Webseite des Meetings:

http://pyddf.de/

Mit freundlichen Grüßen,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 28 2012)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2013-01-22: Python Meeting Duesseldorf ... 25 days to go

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Source code of Windows installer for Python interactive interpreter

2012-12-28 Thread philip . a . molloy
I am writing a command-line application for Windows. I would like to review the 
Python source code to find out how to install my application so that it doesn't 
have to be called using the path and file name (i.e. being able to type 
`python` into the Command prompt, instead of 
`C:\path\to\executable\python.exe`). How does Python achieve this?

Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable 
using the Batch PATH built-in command? If so, where?

The Python language source code[1] includes two seemingly relevant directories, 
`PC` and `PCbuild`. Otherwise I'm lost. This is likely a very simple statement 
buried in the complex Python source code.

Thanks,
Phil

[1]: http://www.python.org/download/releases/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Facing issue with Python loggin logger for printing object value

2012-12-28 Thread Dave Angel
On 12/28/2012 09:27 AM, Morten Engvoldsen wrote:
> Hi Team,
> i am new to python

Welcome.

>  and i am using python loggin for log the value of the
> object. Below is my code :
>
> class field:
> field_name = ""
> length = 0
> type = 0
> value = ""
>
> def __init__(self, field_name, length, type, value):
> self.field_name = field_name
> self.length = length
> self.type = type
> self.value = value
>
> def toString(self):
> if self.type == 2:
> return self.value.zfill(self.length)
> else:
> return self.value.ljust(self.length).upper()
> class record:
> fields = []
>
> def setValue(self, field_name, value):
> for element in self.fields:
> if field_name == element.field_name:
> element.value = value
>
> def toString(self):
> _tempStr = ""
> for element in self.fields:
> _tempStr = _tempStr + element.toString()
> if len(_tempStr) < 80:
> return _tempStr
> else:
> _lines = len(_tempStr) / 80
> _i = 0
> _tempStr2 = ""
> _newline = ""
> while _i < _lines:
> _tempStr2 = _tempStr2 + _newline + _tempStr[_i*80:(_i+1)*80]
> _newline = "\n"
> _i = _i + 1
>
> return _tempStr2
> class First_betfor00(record):
>
> def __init__(self):
> self.fields = [field("APPLICATION-HEADER", 40, 1, ""),
>   field("TRANSACTION-CODE", 8, 0, "BETFOR00"),
>   field("ENTERPRISE-NUMBER", 11, 2, ""),
>   field("DIVISION", 11, 1, ""),
>   field("SEQUENCE-CONTROL", 4, 2, ""),
>   field("RESERVED-1", 6, 1, ""),
>   field("PRODUCTION-DATE", 4, 1, "MMDD"),
>   field("PASSWORD", 10, 1, ""),
>   field("VERSION", 10, 1, "VERSJON002"),
>   field("NEW-PASSWORD", 10, 1, ""),
>   field("OPERATOR-NO", 11, 1, ""),
>   field("SIGILL-SEAL-USE", 1, 1, ""),
>   field("SIGILL-SEAL-DATE", 6, 1, ""),
>   field("SIGILL-SEAL-KEY", 20, 1, ""),
>   field("SIGILL-SEAL-HOW", 1, 1, ""),
>   field("RESERVED-2", 143, 1, ""),
>   field("OWN-REFERENCE-BATCH", 15, 1, ""),
>   field("RESERVED-3", 9, 1, ""),
>   ]
> class account(osv.osv_memory):
>  _name = 'account'
>
>  def create(self,cr,uid,ids,context):
>  logger = logging.getLogger('account')
>  hdlr = logging.FileHandler('/var/tmp/account')
>  formatter = logging.Formatter('%(asctime)s, %(levelname)s,
> %(message)s')
>  hdlr.setFormatter(formatter)
>  logger.addHandler(hdlr)
>
>  batch = ""
>  recordCounter = 1
>  dateMMDD = time.strftime('%m%d')
>
>  betfor00 = Format_betfor00()
>  betfor00.setValue("APPLICATION-HEADER",
> applicationHeader.toString())
>  betfor00.setValue("ENTERPRISE-NUMBER", enterpriseNumber)
>  betfor00.setValue("PRODUCTION-DATE", dateMMDD)
>  batch = betfor00.toString()
>
> line_counter = line_counter + 1
> log.debug('%(batch)s')
> return {'type': 'state', 'state':'end'}
> account()

Is this code supposed to represent the whole program, or are you
"simplifying" for us by leaving stuff out ?  Or worse, are you retyping
all or parts of it ?  Please use cut & paste to create the message, tell
us the exact environment you're using, and how you tried running the script.

When I try to run this on Python 2.7, the first thing I get is
"unexpected indent".   After fixing that, I get NameError: name 'osv' is
not defined.  After kludging something up for that, I get the same
result you describe.  The program does nothing.


This code has nearly the same problem as your different code of 4 days
ago.  You have only one line of top-level code, and it does nothing
useful.  So of those four classes, only one gets instantiated.  And
since 'account' has no __init__() method (nor any __new__() method),
nothing happens during instantiation.  And you toss out the new account
object and exit the program.

Perhaps you meant to save the account class instance with some name. 
And perhaps you meant to then call create() on it with 4 explicit
arguments.  But after I make some changes like that, I get the error: 
NameError: global name 'logging' is not defined.  Then when I fix that,
I see NameError: global name 'time' is not defined.  Then when i fix
that, I see NameError: global name 'Format_betfor00' is not defined. 
When i change that to First_betfor00, I see NameError: global name
'applicationHeader' is not defined.

By this time, my file has diverged significantly from yours.  I can see
more typos in the lines ahead (log instead of logger, for one), but I
don't have the patience.

Just where did this "program" come from?  And how much experience do

Meaning of `\newline` as escape sequence

2012-12-28 Thread Marco

Hi all, in the documentation:

http://docs.python.org/3.3/reference/lexical_analysis.html

the escape sequence `\newline` is expained as "Backslash and newline 
ignored". What does it mean?

Thanks in advance, M.
--
Marco
--
http://mail.python.org/mailman/listinfo/python-list


Re: Meaning of `\newline` as escape sequence

2012-12-28 Thread Chris Angelico
On Sat, Dec 29, 2012 at 2:42 AM, Marco  wrote:
> Hi all, in the documentation:
>
> http://docs.python.org/3.3/reference/lexical_analysis.html
>
> the escape sequence `\newline` is expained as "Backslash and newline
> ignored". What does it mean?

It means this:

>>> foo = "This is\
 one string."
>>> foo
'This is one string.'

Note that the leading space isn't an indent - it's just part of the
quoted string. There's no newline in the resulting string, unlike what
happens with a triple-quoted string. The backslash and line break are
both ignored, meaning that the string is exactly the same as if they
hadn't been there.

But be careful with this sort of thing - a single trailing space on
the line with the backslash will break the string syntactically. The
backslash has to be the absolute last character on the line.

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


Re: Source code of Windows installer for Python interactive interpreter

2012-12-28 Thread Andrew Berg
On 2012.12.28 09:30, [email protected] wrote:
> Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable 
> using the Batch PATH built-in command? If so, where?
As of Python 3.3, there is a py.exe in the system32 directory that
launches the appropriate version of Python for your application if you
specify one in a shebang line.

http://www.python.org/dev/peps/pep-0397/
-- 
CPython 3.3.0 | Windows NT 6.2.9200.16461
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Source code of Windows installer for Python interactive interpreter

2012-12-28 Thread Dave Angel
On 12/28/2012 10:30 AM, [email protected] wrote:
> I am writing a command-line application for Windows. I would like to review 
> the Python source code to find out how to install my application so that it 
> doesn't have to be called using the path and file name (i.e. being able to 
> type `python` into the Command prompt, instead of 
> `C:\path\to\executable\python.exe`). How does Python achieve this?

I use linux, ubuntu.  But I help others that use Windows, when necessary.

Last time I installed python from python.org on a Windows machine (years
ago), it didn't do such niceties for me.  For that and other reasons, I
switched to using the (free) version from ActiveState.  It has a number
of Windows extensions, and one of the extensions was actually fixing the
path and the registry so that Python was directly available at the
command line.

That all could have changed, of course.  But I'm assuming you just want
to fix Windows, not somehow duplicate whatever the installer didn't do?

Take a look in your install directory, same one that python.exe is
located in, and see if there is a batch file there, and whether it knows
where to find Python.exe.  If so, just copy that to somewhere on your
PATH, and you should be golden.  I always had a c:\bat directory on my
PATH for other purposes, so that was a perfect place to put it.

> Is the Python directory (i.e. "C:\Python33") assigned to the PATH variable 
> using the Batch PATH built-in command? If so, where?

That's another option.  Of course, if everyone did that, the  PATH could
get mighty long.  And describing how to change the PATH globally is
tricky, since Microsoft seems to change it with every release of
Windows.  If you were trying to do that programmatically, there is a
registry entry somewhere.  And if I needed to find the right registry
entry, I'd put a weird directory name into the PATH the official way,
then use  regedit and F3 to search for the weird name.

-- 

DaveA

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


Wrapping statements in Python in SPSS

2012-12-28 Thread alankrinsky
I am working with Python looping in SPSS. What are the limits for the

for var1, var2, var3 in zip(Variable1, Variable2, Variable3): 

statement in the Python looping function within SPSS? I am getting an error 
message, I presume because of wrapping or length. Imagine the above statement, 
but expanded, as I am working with more than 28 variables in this loop, and 
even making the names really short is making the statement too long. Is it 
impossible to wrap and make this work? I know there are ways to wrap strings, 
including lists of variables, but here I have a statement/function.

Thank you for any help!

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


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Chris Angelico
On Sat, Dec 29, 2012 at 3:01 AM,   wrote:
> I am working with Python looping in SPSS. What are the limits for the
>
> for var1, var2, var3 in zip(Variable1, Variable2, Variable3):
>
> statement in the Python looping function within SPSS? I am getting an error 
> message, I presume because of wrapping or length. Imagine the above 
> statement, but expanded, as I am working with more than 28 variables in this 
> loop, and even making the names really short is making the statement too 
> long. Is it impossible to wrap and make this work? I know there are ways to 
> wrap strings, including lists of variables, but here I have a 
> statement/function.

At what point are you wrapping it? Can you show the wrapped form and
the error message?

As a general rule, you can safely wrap anything that's inside parentheses.

for (
  var1,
  var2,
  var3
) in zip(
  Variable1,
  Variable2,
  Variable3
):
  pass

That may be a tad excessive, but you get the idea :)

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


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread alankrinsky
Chris,

I tried placing in the format you suggested and received this error message:

END PROGRAM.
Traceback (most recent call last):
  File "", line 396, in 
ValueError: incomplete format key





On Friday, December 28, 2012 11:10:10 AM UTC-5, Chris Angelico wrote:
> On Sat, Dec 29, 2012 at 3:01 AM, alan wrote: > I am working with Python 
> looping in SPSS. What are the limits for the > > for var1, var2, var3 in 
> zip(Variable1, Variable2, Variable3): > > statement in the Python looping 
> function within SPSS? I am getting an error message, I presume because of 
> wrapping or length. Imagine the above statement, but expanded, as I am 
> working with more than 28 variables in this loop, and even making the names 
> really short is making the statement too long. Is it impossible to wrap and 
> make this work? I know there are ways to wrap strings, including lists of 
> variables, but here I have a statement/function. At what point are you 
> wrapping it? Can you show the wrapped form and the error message? As a 
> general rule, you can safely wrap anything that's inside parentheses. for ( 
> var1, var2, var3 ) in zip( Variable1, Variable2, Variable3 ): pass That may 
> be a tad excessive, but you get the idea :) ChrisA

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


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Peter Otten
[email protected] wrote:

> I tried placing in the format you suggested and received this error
> message:
> 
> END PROGRAM.
> Traceback (most recent call last):
>   File "", line 396, in 
> ValueError: incomplete format key

You seem to have a malformed format string. Example:

Correct:

>>> "Wonderful %(what)s" % dict(what="Spam")
'Wonderful Spam'

Broken (not the missing ')'):

>>> "Wonderful %(whats" % dict(what="Spam")
Traceback (most recent call last):
  File "", line 1, in 
ValueError: incomplete format key


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


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Chris Angelico
On Sat, Dec 29, 2012 at 3:43 AM,   wrote:
> Chris,
>
> I tried placing in the format you suggested and received this error message:
>
> END PROGRAM.
> Traceback (most recent call last):
>   File "", line 396, in 
> ValueError: incomplete format key

I don't think the code I gave could produce that. You'll need to show
a bit more of your code, including at least line 396, possibly some
context. Unless one of the other members here has a working crystal
ball - mine's cooling down after excessive use.

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


Re: email.message.Message - as_string fails

2012-12-28 Thread Chris Rebert
On Dec 28, 2012 4:26 AM, "Helmut Jarausch" 
wrote:
>
> Hi,
>
> I'm trying to filter an mbox file by removing some messages.
> For that I use
> Parser= FeedParser(policy=policy.SMTP)
> and 'feed' any lines to it.
> If the mbox file contains a white line followed by '^From ',
> I do
>
> Msg= Parser.close()
>
> (lateron I delete the Parser and create a new one by
> Parser= FeedParser(policy=policy.SMTP)
> )
>
> I can access parts of the message by  Msg['Message-ID'], e.g.
> but even for the very first message, trying to print it or convert it to
a string
> by  MsgStr=Msg.as_string(unixfrom=True)
>
> lets Python (3.3.1_pre20121209) die with
>
> Traceback (most recent call last):
>   File "Email_Parse.py", line 35, in 
> MsgStr=Msg.as_string(unixfrom=True)
>   File "/usr/lib64/python3.3/email/message.py", line 151, in as_string
> g.flatten(self, unixfrom=unixfrom)
>   File "/usr/lib64/python3.3/email/generator.py", line 112, in flatten
> self._write(msg)
>   File "/usr/lib64/python3.3/email/generator.py", line 171, in _write
> self._write_headers(msg)
>   File "/usr/lib64/python3.3/email/generator.py", line 198, in
_write_headers
> self.write(self.policy.fold(h, v))
>   File "/usr/lib64/python3.3/email/policy.py", line 153, in fold
> return self._fold(name, value, refold_binary=True)
>   File "/usr/lib64/python3.3/email/policy.py", line 176, in _fold
> (len(lines[0])+len(name)+2 > maxlen or
> IndexError: list index out of range
>
>
> What am I missing?

Perhaps the message is malformed. What does Msg.defects give you?

Could you post the line strings you fed to the parser that together
constitute the first message (redacted if necessary)?

P.S. Your naming conventions (with respect to capitalization) disagree with
those of Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread alankrinsky
I think 396 just comes from the end of the Python loop, without indicating 
which line in the loop is at issue.

Here is the full code from this section of the loop:


for (
msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6, dspd7, dspd8, 
dspd9, dspd10, dspd11, dspd12, 
period1, period2, period3, period4, period5, period6, period7, period8, 
period9, period10, period11, period12 
) in zip(
Measure, BreakVariable, Dimension, Sources, DimensionSourceTimeFrame1, 
DimensionSourceTimeFrame2, DimensionSourceTimeFrame3, 
DimensionSourceTimeFrame4, 
DimensionSourceTimeFrame5, DimensionSourceTimeFrame6, 
DimensionSourceTimeFrame7, DimensionSourceTimeFrame8, 
DimensionSourceTimeFrame9, 
DimensionSourceTimeFrame10, DimensionSourceTimeFrame11, 
DimensionSourceTimeFrame12, 
TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5, TimeFrame6, 
TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10, TimeFrame11, TimeFrame12
): 


 spss.Submit(r"""


Alan


On Friday, December 28, 2012 12:12:27 PM UTC-5, Chris Angelico wrote:
> On Sat, Dec 29, 2012 at 3:43 AM, alan wrote: > Chris, > > I tried placing in 
> the format you suggested and received this error message: > > END PROGRAM. > 
> Traceback (most recent call last): > File "", line 396, in  > 
> ValueError: incomplete format key I don't think the code I gave could produce 
> that. You'll need to show a bit more of your code, including at least line 
> 396, possibly some context. Unless one of the other members here has a 
> working crystal ball - mine's cooling down after excessive use. ChrisA

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


Re: Python lists

2012-12-28 Thread Alex
Manatee wrote:

> On Friday, December 28, 2012 9:14:57 AM UTC-5, Manatee wrote:
> > I read in this:
> > 
> > ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N',
> > '10', '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D',
> > 'Digi-Key', '490-1521-1-ND', '']
> > 
> > 
> > 
> > Then I need to convert it to this:
> > 
> > [['C100', 'C117'], 'X7R 0.033uF 10% 25V  0603', '0603-C_L',
> > '0603-C_N', '10', '2', '', '30', '15463-333', 'MURATA',
> > 'GRM188R71E333KA01D', 'Digi-Key', '490-1521-1-ND', '']]
> > 

l = ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N',
'10', '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D',
'Digi-Key', '490-1521-1-ND', '']

[item.split(',') if i == 0 else item for i, item in enumerate(l)]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Mitya Sirenef

On 12/28/2012 12:33 PM, [email protected] wrote:
I think 396 just comes from the  end of the Python loop, without indicating which line in the loop is 

at issue.
>
> Here is the full code from this section of the loop:
>
>
> for (
> msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6, dspd7, 
dspd8, dspd9, dspd10, dspd11, dspd12,
> period1, period2, period3, period4, period5, period6, period7, 
period8, period9, period10, period11, period12

> ) in zip(
> Measure, BreakVariable, Dimension, Sources, 
DimensionSourceTimeFrame1, DimensionSourceTimeFrame2, 
DimensionSourceTimeFrame3, DimensionSourceTimeFrame4,
> DimensionSourceTimeFrame5, DimensionSourceTimeFrame6, 
DimensionSourceTimeFrame7, DimensionSourceTimeFrame8, 
DimensionSourceTimeFrame9,
> DimensionSourceTimeFrame10, DimensionSourceTimeFrame11, 
DimensionSourceTimeFrame12,
> TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5, 
TimeFrame6, TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10, 
TimeFrame11, TimeFrame12

> ):
>
>
> spss.Submit(r"""
>
>
> Alan
>
>

By the way, when lines run so long they can get hard to manage, edit,
understand, et cetera. You should consider setting things up cleanly
before doing the loop and using a list of names for columns like so:


def main():
l1, l2   = [1,2], [3,4]
zipped   = zip(l1, l2)
colnames = "first second".split()

for columns in zipped:
coldict = dict(zip(colnames, columns))
print("coldict", coldict)

main()


This produces output:

coldict {'second': 3, 'first': 1}
coldict {'second': 4, 'first': 2}

.. and then you can pass the coldict on to your string.

 - mitya


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Mitya Sirenef

On 12/28/2012 12:55 PM, Mitya Sirenef wrote:

On 12/28/2012 12:33 PM, [email protected] wrote:
I think 396 just comes from the  end of the Python loop, without 
indicating which line in the loop is 

at issue.
>
> Here is the full code from this section of the loop:
>
>
> for (
> msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6, dspd7, 
dspd8, dspd9, dspd10, dspd11, dspd12,
> period1, period2, period3, period4, period5, period6, period7, 
period8, period9, period10, period11, period12

> ) in zip(
> Measure, BreakVariable, Dimension, Sources, 
DimensionSourceTimeFrame1, DimensionSourceTimeFrame2, 
DimensionSourceTimeFrame3, DimensionSourceTimeFrame4,
> DimensionSourceTimeFrame5, DimensionSourceTimeFrame6, 
DimensionSourceTimeFrame7, DimensionSourceTimeFrame8, 
DimensionSourceTimeFrame9,
> DimensionSourceTimeFrame10, DimensionSourceTimeFrame11, 
DimensionSourceTimeFrame12,
> TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5, 
TimeFrame6, TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10, 
TimeFrame11, TimeFrame12

> ):
>
>
> spss.Submit(r"""
>
>
> Alan
>
>

By the way, when lines run so long they can get hard to manage, edit,
understand, et cetera. You should consider setting things up cleanly
before doing the loop and using a list of names for columns like so:


def main():
l1, l2   = [1,2], [3,4]
zipped   = zip(l1, l2)
colnames = "first second".split()

for columns in zipped:
coldict = dict(zip(colnames, columns))
print("coldict", coldict)




Should really be 'for column in zipped:' !

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


issue with loggin

2012-12-28 Thread Morten Engvoldsen
Hi Dave,
Thanks for looking into my issue.  You cannot run the program since it is
in Openerp where python is used as programming language. Here python 2.7 is
used. Sorry i didn't mention all the detail.

My program is able to write log for other message in the log file. here
'batch' is an object and when i try to log the value of 'batch'  with
logger.debug('The value is %s' %batch) , it doesn't log the value. I am not
sure if it is the correct if it correct formatting syntax for displaying
Object value.

Thanks in advance again.. I am new to Python but not in programming
language..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wrapping statements in Python in SPSS

2012-12-28 Thread Mitya Sirenef

On 12/28/2012 01:05 PM, Mitya Sirenef wrote:

On 12/28/2012 12:55 PM, Mitya  Sirenef wrote:

>> On 12/28/2012 12:33 PM, [email protected] wrote:
>>> I think 396 just comes from the end of the Python loop, without 
indicating which line in the loop is

>> at issue.
>> >
>> > Here is the full code from this section of the loop:
>> >
>> >
>> > for (
>> > msr, brk, dmn, src, dspd1, dspd2, dspd3, dspd4, dspd5, dspd6, 
dspd7, dspd8, dspd9, dspd10, dspd11, dspd12,
>> > period1, period2, period3, period4, period5, period6, period7, 
period8, period9, period10, period11, period12

>> > ) in zip(
>> > Measure, BreakVariable, Dimension, Sources, 
DimensionSourceTimeFrame1, DimensionSourceTimeFrame2, 
DimensionSourceTimeFrame3, DimensionSourceTimeFrame4,
>> > DimensionSourceTimeFrame5, DimensionSourceTimeFrame6, 
DimensionSourceTimeFrame7, DimensionSourceTimeFrame8, 
DimensionSourceTimeFrame9,
>> > DimensionSourceTimeFrame10, DimensionSourceTimeFrame11, 
DimensionSourceTimeFrame12,
>> > TimeFrame1, TimeFrame2, TimeFrame3, TimeFrame4, TimeFrame5, 
TimeFrame6, TimeFrame7, TimeFrame8, TimeFrame9, TimeFrame10, 
TimeFrame11, TimeFrame12

>> > ):
>> >
>> >
>> > spss.Submit(r"""
>> >
>> >
>> > Alan
>> >
>> >
>>
>> By the way, when lines run so long they can get hard to manage, edit,
>> understand, et cetera. You should consider setting things up cleanly
>> before doing the loop and using a list of names for columns like so:
>>
>>
>> def main():
>> l1, l2 = [1,2], [3,4]
>> zipped = zip(l1, l2)
>> colnames = "first second".split()
>>
>> for columns in zipped:
>> coldict = dict(zip(colnames, columns))
>> print("coldict", coldict)
>>
>
>
> Should really be 'for column in zipped:' !
>
> -m
>

Doh - the code is good, but I got a little confused with variable names.
This should be more like it:

def main():
c1, c2   = [1,2], [3,4]
zipped   = zip(c1, c2)
colnames = "first second".split()

for values in zipped:
valdict = dict(zip(colnames, values))
print("valdict", valdict)

main()


 -m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: learning curve

2012-12-28 Thread Verde Denim
On 12/27/2012 09:32 PM, alex23 wrote:
> On Dec 28, 11:20 am, Verde Denim  wrote:
>> Just getting into Py coding and not understanding why this code doesn't
>> seem to do anything -
> 
> Is that the sum total of your code? You're not showing any
> instantiation of your classes.
Yes, as a matter of fact, it is the example verbatim from the tutorial
pages that I found. Apparently, it isn't the best example... Thanks for
the heads up.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with loggin

2012-12-28 Thread Dave Angel
On 12/28/2012 01:15 PM, Morten Engvoldsen wrote:
> Hi Dave,
> Thanks for looking into my issue.  You cannot run the program since it is
> in Openerp where python is used as programming language. Here python 2.7 is
> used. Sorry i didn't mention all the detail.
>
> My program is able to write log for other message in the log file. here
> 'batch' is an object and when i try to log the value of 'batch'  with
> logger.debug('The value is %s' %batch) , it doesn't log the value. I am not
> sure if it is the correct if it correct formatting syntax for displaying
> Object value.
>
> Thanks in advance again.. I am new to Python but not in programming
> language..
>
>

You started a new thread, instead of replying in the same one.  This
will confuse most people, and frustrate the rest.

I'm going to try to paste your response into the other thread "Facing
issue with Python loggin logger for printing object value", and hope
nobody else replies here.


-- 

DaveA

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


Re: Facing issue with Python loggin logger for printing object value

2012-12-28 Thread Dave Angel
On 12/28/2012 09:27 AM, Morten Engvoldsen wrote:
> Hi Team,
> i am new to python and i am using python loggin for log the value of the
> object. Below is my code :
>
> class field:
> field_name = ""
> length = 0
> type = 0
> value = ""
>
> def __init__(self, field_name, length, type, value):
> self.field_name = field_name
> self.length = length
> self.type = type
> self.value = value
>
> def toString(self):
> if self.type == 2:
> return self.value.zfill(self.length)
> else:
> return self.value.ljust(self.length).upper()
> class record:
> fields = []
>
> def setValue(self, field_name, value):
> for element in self.fields:
> if field_name == element.field_name:
> element.value = value
>
> def toString(self):
> _tempStr = ""
> for element in self.fields:
> _tempStr = _tempStr + element.toString()
> if len(_tempStr) < 80:
> return _tempStr
> else:
> _lines = len(_tempStr) / 80
> _i = 0
> _tempStr2 = ""
> _newline = ""
> while _i < _lines:
> _tempStr2 = _tempStr2 + _newline + _tempStr[_i*80:(_i+1)*80]
> _newline = "\n"
> _i = _i + 1
>
> return _tempStr2
> class First_betfor00(record):
>
> def __init__(self):
> self.fields = [field("APPLICATION-HEADER", 40, 1, ""),
>   field("TRANSACTION-CODE", 8, 0, "BETFOR00"),
>   field("ENTERPRISE-NUMBER", 11, 2, ""),
>   field("DIVISION", 11, 1, ""),
>   field("SEQUENCE-CONTROL", 4, 2, ""),
>   field("RESERVED-1", 6, 1, ""),
>   field("PRODUCTION-DATE", 4, 1, "MMDD"),
>   field("PASSWORD", 10, 1, ""),
>   field("VERSION", 10, 1, "VERSJON002"),
>   field("NEW-PASSWORD", 10, 1, ""),
>   field("OPERATOR-NO", 11, 1, ""),
>   field("SIGILL-SEAL-USE", 1, 1, ""),
>   field("SIGILL-SEAL-DATE", 6, 1, ""),
>   field("SIGILL-SEAL-KEY", 20, 1, ""),
>   field("SIGILL-SEAL-HOW", 1, 1, ""),
>   field("RESERVED-2", 143, 1, ""),
>   field("OWN-REFERENCE-BATCH", 15, 1, ""),
>   field("RESERVED-3", 9, 1, ""),
>   ]
> class account(osv.osv_memory):
>  _name = 'account'
>
>  def create(self,cr,uid,ids,context):
>  logger = logging.getLogger('account')
>  hdlr = logging.FileHandler('/var/tmp/account')
>  formatter = logging.Formatter('%(asctime)s, %(levelname)s,
> %(message)s')
>  hdlr.setFormatter(formatter)
>  logger.addHandler(hdlr)
>
>  batch = ""
>  recordCounter = 1
>  dateMMDD = time.strftime('%m%d')
>
>  betfor00 = Format_betfor00()
>  betfor00.setValue("APPLICATION-HEADER",
> applicationHeader.toString())
>  betfor00.setValue("ENTERPRISE-NUMBER", enterpriseNumber)
>  betfor00.setValue("PRODUCTION-DATE", dateMMDD)
>  batch = betfor00.toString()
>
> line_counter = line_counter + 1
> log.debug('%(batch)s')
> return {'type': 'state', 'state':'end'}
> account()
>
>
> In the above code i am trying to capture the value of 'batch' in the log
> file, but when i check log file it doesn't have any value printed. my
> question is is it correct way to capture the object value that is
>log.debug('%(batch)s')
>
> I will really appreciate the answer. Thanks in advance..
>
> Regards,
> Morten
>
>
Then Morten wrote (starting a redundant thread with different subject line):

Hi Dave,
Thanks for looking into my issue.  You cannot run the program since it is
in Openerp where python is used as programming language. Here python 2.7 is
used. Sorry i didn't mention all the detail.

My program is able to write log for other message in the log file. here
'batch' is an object and when i try to log the value of 'batch'  with
logger.debug('The value is %s' %batch) , it doesn't log the value. I am not
sure if it is the correct if it correct formatting syntax for displaying
Object value.

Thanks in advance again.. I am new to Python but not in programming
language..



Does this "openerp' environment ignore syntax errors?  Can you see when things 
go wrong, or are you stuck with only looking at the zero-length log file ?

After "fixing" perhaps a half-dozen errors in that one create() method, and 
fixing lots of other stuff so I could run it at all, I came across the 
particular clue you're probably missing.

 logger.setLevel(logging.DEBUG)


Without that, the logger doesn't know which messages should be logged.





-- 

DaveA

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


Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
When I use a config file things seem to work (in other projects), but for my 
current code I hoped to configure logging from Python.

I distilled my problem down to the following test, which does not print 
anything.  Please can someone explain why?  I was expecting the module's logger 
to delegate to root, which has the DEBUG level set.

from logging import DEBUG, root, getLogger
from unittest import TestCase

class LoggingTest(TestCase):

def test_direct(self):
root.setLevel(DEBUG)
getLogger(__name__).debug("hello world")

Thanks,
Andrew
-- 
http://mail.python.org/mailman/listinfo/python-list


Reverse Engineering of JFK Assassination Plan Featuring The Killer Queen

2012-12-28 Thread Betty fdffdfdsfdsfdsf
Interested in who really killed JFK? Who gave the orders? What famous
movies and songs told you about it a long time ago?

All details explained in 86-page pdf document available for free
download at:

http://jackieiskillerqueen.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
similarly, if i run the following, i see only "done":

  from logging import DEBUG, root, getLogger

  if __name__ == '__main__':
  root.setLevel(DEBUG)
  getLogger(__name__).debug("hello world")
  print('done')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused about logger config from within Python (3)

2012-12-28 Thread Peter Otten
andrew cooke wrote:

> similarly, if i run the following, i see only "done":
> 
>   from logging import DEBUG, root, getLogger
> 
>   if __name__ == '__main__':
>   root.setLevel(DEBUG)
>   getLogger(__name__).debug("hello world")
>   print('done')

You need a handler. The easiest way to get one is logging.basicConfig().

>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> logging.getLogger().debug("goodbye, cruel world")
DEBUG:root:goodbye, cruel world

Other revolutionary ideas: read the docs 
 ;)

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


Gvim, bug or feature?

2012-12-28 Thread Pengfei Hao
When you are using gvim, the command line vim can not open a current
directory os.py, do you think this is a bug or a feature? I like python and
I like gvim, but the vim of gvim is now a python program , it will import
module like  os.py first in current directory, so any file the same name as
os.py will cause the vim startup failure. I find this today and I was
shocked about the truth, a editor will be affected by the filename you want
to edit!

What do you think about this?
-- 
http://mail.python.org/mailman/listinfo/python-list


noob can't install python modules/scripts

2012-12-28 Thread lostguru
hi, I'm not that new to programming (java) but I'm a pathetic newbie when it 
comes to python. I just started learning today and I'm trying to install 
third-party modules/scripts (I don't know the difference at the moment) so that 
they'll work in python; namely, easy_install/pip/distribute and beautifulsoup4

python version is 2.7.3; platform is windows 7, 64-bit

when I first installed python, I couldn't get it to run from the command line 
just by typing "python"; installing activepython (also 64-bit) seemed to have 
solved the problem (I later added C:\Python27 and C:\Python27\Scripts to the 
%PATH% environmental variable, not sure if this changed anything however)

the only problem now is that I can't install any modules for python (that or 
they're installed and not working); I'm aware that my 64-bit installation needs 
the respective 64-bit versions of all of the modules I want installed, so I 
made sure to download those; but running/installing all of those has yielded no 
reaction

using easy_install as an example, I downloaded the .py script the website told 
me to use for 64-bit installations, and ran it; as far as I know nothing 
happened (was I supposed to put it in a specific folder first before running 
it?) and trying to type "easy_install" into python gives me this:
Traceback (most recent call last):
  File "", line 1, in 
easy_install
NameError: name 'easy_install' is not defined

trying to type "easy_install BeautifulSoup4" gives me this:
SyntaxError: invalid syntax

I'm at a loss as to why none of this works; did I not set up Python correctly? 
or was there some step I missed/ignored? any help or input would be much 
appreciated at this stage
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: email.message.Message - as_string fails

2012-12-28 Thread Terry Reedy

On 12/28/2012 7:22 AM, Helmut Jarausch wrote:

Hi,

I'm trying to filter an mbox file by removing some messages.
For that I use
Parser= FeedParser(policy=policy.SMTP)
and 'feed' any lines to it.
If the mbox file contains a white line followed by '^From ',
I do

Msg= Parser.close()

(lateron I delete the Parser and create a new one by
Parser= FeedParser(policy=policy.SMTP)
)

I can access parts of the message by  Msg['Message-ID'], e.g.
but even for the very first message, trying to print it or convert it to a 
string
by  MsgStr=Msg.as_string(unixfrom=True)

lets Python (3.3.1_pre20121209) die with

Traceback (most recent call last):
   File "Email_Parse.py", line 35, in 
 MsgStr=Msg.as_string(unixfrom=True)
   File "/usr/lib64/python3.3/email/message.py", line 151, in as_string
 g.flatten(self, unixfrom=unixfrom)
   File "/usr/lib64/python3.3/email/generator.py", line 112, in flatten
 self._write(msg)
   File "/usr/lib64/python3.3/email/generator.py", line 171, in _write
 self._write_headers(msg)
   File "/usr/lib64/python3.3/email/generator.py", line 198, in _write_headers
 self.write(self.policy.fold(h, v))
   File "/usr/lib64/python3.3/email/policy.py", line 153, in fold
 return self._fold(name, value, refold_binary=True)
   File "/usr/lib64/python3.3/email/policy.py", line 176, in _fold
 (len(lines[0])+len(name)+2 > maxlen or
IndexError: list index out of range


The only list index visible is 0 in lines[0]. If this raises, lines is 
empty. You could trace back to see where lines is defined. I suspect it 
is all or part of the Msg you started with.


I believe that some of email was rewritten for 3.3, so it is possible 
that you found a bug based on an untrue assumption. It is also possible 
that you missed a limitation in the doc, or tripped over an intended but 
not written limitation. So I hope you do the tracing, so if doc or code 
need a fix, a tracker issue can be opened.


--
Terry Jan Reedy

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


Re: Gvim, bug or feature?

2012-12-28 Thread Pengfei Hao
Sorry, this seems a temporary bug of gvim, and they already fix it, post
closed.


2012/12/28 Pengfei Hao 

> When you are using gvim, the command line vim can not open a current
> directory os.py, do you think this is a bug or a feature? I like python and
> I like gvim, but the vim of gvim is now a python program , it will import
> module like  os.py first in current directory, so any file the same name as
> os.py will cause the vim startup failure. I find this today and I was
> shocked about the truth, a editor will be affected by the filename you want
> to edit!
>
> What do you think about this?
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Westley Martínez
On Thu, Dec 27, 2012 at 12:01:16PM -0800, mogul wrote:
> 'Aloha!
> 
> I'm new to python, got 10-20 years perl and C experience, all gained on unix 
> alike machines hacking happily in vi, and later on in vim.
> 
> Now it's python, and currently mainly on my kubuntu desktop.
> 
> Do I really need a real IDE, as the windows guys around me say I do, or will 
> vim, git, make and other standalone tools make it the next 20 years too for 
> me? 
> 
> Oh, by the way, after 7 days I'm completely in love with this python thing. I 
> should have made the switch much earlier!
> 
> /mogul %-)

I only use vim for everything.  IDEs just seem to get in my way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learning curve

2012-12-28 Thread Terry Reedy

On 12/28/2012 1:29 PM, Verde Denim wrote:

On 12/27/2012 09:32 PM, alex23 wrote:

On Dec 28, 11:20 am, Verde Denim  wrote:

Just getting into Py coding and not understanding why this code doesn't
seem to do anything -


Is that the sum total of your code? You're not showing any
instantiation of your classes.

Yes, as a matter of fact, it is the example verbatim from the tutorial
pages that I found. Apparently, it isn't the best example...


Let us say that it was an example of how to write classes, with usage 
left as an exercise for the reader ;-)


--
Terry Jan Reedy

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


Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten  wrote:
> Other revolutionary ideas: read the docs 
> 
>  ;)

how do you think i knew about the root handler without reading the damn docs 
you condescending asshole?

anyway, thanks for the help.

andrew

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


Re: noob can't install python modules/scripts

2012-12-28 Thread lostguru
I guess I should add that the python installation is 64-bit as well


thanks again!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused about logger config from within Python (3)

2012-12-28 Thread Dave Angel
On 12/28/2012 09:29 PM, andrew cooke wrote:
> On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten  wrote:
>

> reading the damn docs you condescending *?
>

You've made four posts this year to this forum, in two threads, to ask
for help.  In that same year, Peter Otten has voluntarily helped others
with 325 messages.  As far as I can see, he hasn't started any threads,
just helped where he could.  So your way of giving thanks to him, and to
the hundreds of others who give so generously of their time, is to call
him a potty-name?

People like you make me rethink my own commitment to helping. 
Fortunately, there aren't too many of you.

-- 

DaveA

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


cunfused why gevent block redis' socket request?

2012-12-28 Thread Tony Shao
GOAL:spawn a few greenlet worker deal with the data pop from redis (pop from 
redis and then put into queue)

RUNNING ENV: ubuntu 12.04
PYTHON VER: 2.7
GEVENT VER: 1.0 RC2
REDIS VER:2.6.5
REDIS-PY VER:2.7.1

from gevent import monkey; monkey.patch_all()
import gevent
from gevent.pool import Group
from gevent.queue import JoinableQueue
import redis

tasks = JoinableQueue()
task_group = Group()

def crawler():
while True:
if not tasks.empty():
print tasks.get()
gevent.sleep()

task_group.spawn(crawler)
redis_client = redis.Redis()
data = redis_client.lpop('test') #<--Block here
tasks.put(data)


Try to pop data from redis, but it blocked..and no exception raised...just 
freeze
and remove spawn method ,it will worked..
i feel confuse what happened, plz help!
thk u!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noob can't install python modules/scripts

2012-12-28 Thread Steven D'Aprano
On Fri, 28 Dec 2012 17:45:56 -0800, lostguru wrote:

> using easy_install as an example, I downloaded the .py script the
> website told me to use for 64-bit installations, and ran it; 

"The website"? There's more than one website on the Internet. Which 
website are you referring to? What .py script did you download? How did 
you run it? Details are important!


> as far as I
> know nothing happened (was I supposed to put it in a specific folder
> first before running it?) and trying to type "easy_install" into python
> gives me this:
> Traceback (most recent call last):
>   File "", line 1, in 
> easy_install
> NameError: name 'easy_install' is not defined
> 
> trying to type "easy_install BeautifulSoup4" gives me this:
> SyntaxError: invalid syntax

It looks like you tried to run the easy_install command from inside the 
Python interactive interpreter, rather than from your system shell.

The system shell (command.com or cmd.exe I guess) will have a $ or % sign 
as the prompt. Python usually has >>> as the prompt, although if you are 
running ActivePython it may be something else. You need to run the 
"easy_install BeautifulSoup4" command from the system shell, not Python.


Try that, and if there's another error, please copy and paste the exact 
command you used, and the full error message.



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


Re: Confused about logger config from within Python (3)

2012-12-28 Thread Steven D'Aprano
On Fri, 28 Dec 2012 11:57:29 -0800, andrew cooke wrote:

> When I use a config file things seem to work (in other projects), but
> for my current code I hoped to configure logging from Python.
> 
> I distilled my problem down to the following test, which does not print
> anything.  Please can someone explain why?  I was expecting the module's
> logger to delegate to root, which has the DEBUG level set.
> 
> from logging import DEBUG, root, getLogger 
> from unittest import TestCase
> 
> class LoggingTest(TestCase):
> def test_direct(self):
> root.setLevel(DEBUG)
> getLogger(__name__).debug("hello world")


Nothing gets printed because you don't do anything except define a class. 
Try instantiating the class, then calling the test_direct method. The 
most convenient way to do so is with the unittest module:

# after defining the class above
import unittest
unittest.main()


which then prints:

py> unittest.main()
No handlers could be found for logger "__main__"
.
--
Ran 1 test in 0.045s

OK


So you need a handler.


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


Re: noob can't install python modules/scripts

2012-12-28 Thread lostguru
On Friday, December 28, 2012 11:12:19 PM UTC-5, Steven D'Aprano wrote:
> "The website"? There's more than one website on the Internet. Which 
> 
> website are you referring to? What .py script did you download? How did 
> 
> you run it? Details are important!
> 
sorry about that; I was using the setuptools package from pypi python [ 
http://pypi.python.org/pypi/setuptools ]; I downloaded the ez_setup.py file 
from under the 64-bit windows installation section and ran that (by double 
clicking on it, I hope this wasn't another noob mistake lol)
> 
> It looks like you tried to run the easy_install command from inside the 
> 
> Python interactive interpreter, rather than from your system shell.
> 
> 
> 
> The system shell (command.com or cmd.exe I guess) will have a $ or % sign 
> 
> as the prompt. Python usually has >>> as the prompt, although if you are 
> 
> running ActivePython it may be something else. You need to run the 
> 
> "easy_install BeautifulSoup4" command from the system shell, not Python.
> 
> 
> 
> 
> 
> Try that, and if there's another error, please copy and paste the exact 
> 
> command you used, and the full error message.
> 
running easy_install from the command line worked and BeautifulSoup4 seems to 
have installed, thanks for pointing out my mistake

the only problem I have now is that importing beautifulsoup into a .py file I 
wrote generates an error (I'm using ActiveState Komodo Edit 7, is there another 
program you would recommend to a beginner like me?)

trying to run the script gives an import error:
ImportError: No module named BeautifulSoup

importing other modules like os and urllib that came with the python 
installation work without problems

looking online, all I've found were other accounts talking about a 
beautifulsoup.py that should be in the C:\Python27\Lib\site-packages directory, 
but I've found no such thing from the installation anywhere in the Python 
folder (funnily enough, I did a drive search with Everything and found a 
BeautifulSoup.py in my autodesk maya installation)

am I somewhere near the mark? or am I off completely?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the name of a function while defining it

2012-12-28 Thread Tim Roberts
Abhas Bhattacharya  wrote:
>
>Now, for your questions:
>If i call one() and two() respectively, i would like to see "one" and "two".
>I dont have much knowledge of lambda functions, neither am i going to use
>them, so that's something I cant answer.

My point is not that these are special cases to consider, but rather that
all of these are the GENERAL case.  A function, now matter how it was
created, is an anonymous object that lives out in object space.  Like all
objects, a function object can be bound to many different names.  An object
doesn't know just one name, and when a function object is invoked, it has
NO IDEA what name was used to invoke it.  The information is simply not
available.
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused about logger config from within Python (3)

2012-12-28 Thread Steven D'Aprano
On Fri, 28 Dec 2012 16:41:20 -0800, andrew cooke wrote:

> similarly, if i run the following, i see only "done":
> 
>   from logging import DEBUG, root, getLogger
> 
>   if __name__ == '__main__':
>   root.setLevel(DEBUG)
>   getLogger(__name__).debug("hello world")
>   print('done')


In Python 2.7, the above prints:

py> from logging import DEBUG, root, getLogger
py> root.setLevel(DEBUG)
py> getLogger(__name__).debug("hello world"); print("done")
No handlers could be found for logger "__main__"
done


In Python 3.2 and 3.3, the message about no handlers is not printed, 
which is an interesting difference. (Somebody who knows more about the 
logging package than I do might be able to state why that difference.) So 
it would help if you told us what version of Python you're running.

This works as expected:


py> lg = getLogger(__name__)
py> lg.level = logging.DEBUG
py> lg.debug("hello world"); print("done")
DEBUG:__main__:hello world
done

since the default logging level is WARNING, as the tutorial explains:

[quote]
The default level is WARNING, which means that only events of this level 
and above will be tracked, unless the logging package is configured to do 
otherwise.
[end quote]

http://docs.python.org/dev/howto/logging.html



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


Re: pickle module doens't work

2012-12-28 Thread Tim Roberts
Omer Korat  wrote:
>
>So it means pickle doesn't ever save the object's values, only how it was 
>created? 

You say that as though there were a difference between the two.  There
isn't.  An object is just a dictionary of values.  If you set an object
member to a string, then that object's dictionary for that member name
contains a string.  It doesn't contain some alternative packed binary
representation of a string.

>Say I have a large object that requires a lot of time to train on data. It
>means pickle doesn't save its values, so you have to train it every time
>anew? Is there no way to save its trained values?

When you say "train on data", what do you mean?  If your training creates
computed data in other members, those members and their values should also
be saved in the pickle.
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2012-12-28 Thread Chris Angelico
On Sat, Dec 29, 2012 at 1:02 PM, Westley Martínez  wrote:
> I only use vim for everything.  IDEs just seem to get in my way.

I've just (like ten minutes ago) come across a perfect example of what
makes an IDE useful. My mother maintains a collection of documents
(book indexes, historical records, catalogs of items the society owns,
etc) in a word processor called DeScribe. She just wanted to add a
plain text file to the collection, such that she can search it for a
text string (it's an OCR transcription of an old book, I think), and
put it into DeScribe even though it doesn't need any of its
facilities, just so it'd be there with all her others. An IDE is the
right thing for her. For me, though, it's no value.

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