Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Lacrima
On Jul 24, 11:20 am, Raymond Hettinger wrote: > On Jul 24, 12:47 am, Lacrima wrote: > > > > > Hi! > > > I have two super classes: > > > class SuperClass1(object): > >     def __init__(self, word): > >         print word > > > class Su

Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Lacrima
Hi! I have two super classes: class SuperClass1(object): def __init__(self, word): print word class SuperClass2(object): def __init__(self, word, word2): print word, word2 Also I have subclass of these classes: class SubClass(SuperClass1, SuperClass2): def __init__(

Re: String Formatting Operations for decimals.

2010-04-01 Thread Maxim Lacrima
Hello, Chris! Thanks for your really quick reply! It works! On 1 April 2010 12:14, Chris Rebert wrote: > On Thu, Apr 1, 2010 at 2:08 AM, Lacrima wrote: > > Hello! > > > > I need to format a decimal (floating point) number in the following > > way: > > 10 re

String Formatting Operations for decimals.

2010-04-01 Thread Lacrima
Hello! I need to format a decimal (floating point) number in the following way: 10 results in '10' 10.5 results in '10.5' 10.50 results in '10.5' 10.5678 results in 10.57 How can I achieve this using standard Python string formatting operations? Something like '%.2f' works almost as expected: >>>

Re: Advanced Python Programming Oxford Lectures [was: Re: *Advanced* Python book?]

2010-03-26 Thread Lacrima
On Mar 26, 10:22 am, Michele Simionato wrote: > On Mar 25, 2:24 pm, Michele Simionato > wrote: > > > On Mar 25, 1:28 pm, Ethan Furman wrote: > > > > Michele, > > > > Was wondering if you'd had a chance to re-post your lectures -- just did > > > a search for them and came up empty, and I would lo

Re: Can't install ssl for Python2.5

2010-03-10 Thread Lacrima
On Mar 10, 11:23 pm, "Martin v. Loewis" wrote: > > I don't know how to solve this problem and I am looking forward for > > help. > > Try running "python setup.py install" directly, after downloading and > unpacking the package. > > Regards, > Martin Thanks a lot! It helped! -- http://mail.python

Can't install ssl for Python2.5

2010-03-10 Thread Lacrima
Hello! I use Ubuntu 9.10 Karmic Koala. It has Python 2.6 as default installation. And I installed Python 2.5 alongside (for the need of Google AppEngine). But it seems like my Python 2.5 installation lacks ssl support. I can't import ssl and starting appengine server fails with "'module' object ha

Using mock library (written by Michael Foord)

2010-02-25 Thread Lacrima
Hello! I use mock library http://www.voidspace.org.uk/python/mock/. There is no user group for the library, so I post in comp.lang.python and hope that people who use it will help me. The library allows to patch objects, using patch decorator. Patching is done only within the scope of the functio

Re: Which mock library do you prefer?

2010-02-21 Thread Lacrima
On Feb 18, 3:20 am, Ben Finney wrote: > Lacrima writes: > > Right, isolation [of test cases] is essential. But I can't decide to > > which extent I should propagate isolation. > > You used “propagate” in a sense I don't understand there. > > > For examp

Re: Which mock library do you prefer?

2010-02-17 Thread Lacrima
On Feb 16, 10:30 pm, Ben Finney wrote: > Lacrima writes: > > And I have already refused to write totally isolated tests, because it > > looks like a great waste of time. > > It only looks like that until you chase your tail in a long, fruitless > debugging session because

Re: Which mock library do you prefer?

2010-02-17 Thread Lacrima
On Feb 16, 7:38 pm, Phlip wrote: > > This paper _almost_ gets the > idea:http://www.netobjectives.com/download/Code%20Qualities%20and%20Practi... > > > Do you run your tests after the fewest possible edits? Such as 1-3 > lines of code? > Hi! I run my tests all the time (they almost replaced debu

Re: Which mock library do you prefer?

2010-02-16 Thread Lacrima
On Feb 15, 9:56 pm, Phlip wrote: > Lacrima wrote: > > Thanks for your reply! Isn't what you are talking about integration > > tests? And unit tests should be fully isolated? So even for method > > 'some_method()' of class A I should mock instance of class

Re: Which mock library do you prefer?

2010-02-16 Thread Lacrima
On Feb 16, 2:17 am, Ben Finney wrote: > Lacrima writes: > > Minimock has wider usage and community, but I have some troubles using > > it. Maybe I am wrong, but with minimock you always have to keep track > > the order of imports in your test modules. Well, may be I just

Re: Which mock library do you prefer?

2010-02-15 Thread Lacrima
On Feb 15, 6:57 pm, Phlip wrote: > Lacrima wrote: > > I am newbie mastering test driven development. I can't clarify myself > > which mock library to use. > > There are number of them and which one do you prefer? > > > Two libraries that attracted my attenti

Which mock library do you prefer?

2010-02-15 Thread Lacrima
Hello! I am newbie mastering test driven development. I can't clarify myself which mock library to use. There are number of them and which one do you prefer? Two libraries that attracted my attention are: * minimock * dingus As for me the latest one, dingus, is the easiest (see this screencast: h

Re: what test runner should I use?

2010-01-21 Thread Lacrima
On Jan 19, 12:56 pm, Chris Withers wrote: > Hi All, > > I'm wondering what test runner I should use. Here's my list of requirements: > > - cross platform (I develop for and on Windows, Linux and Mac) > > - should not prevent tests from running with other test runners >    (so no plugins/layers/etc

Re: Anybody use web2py?

2009-12-21 Thread Lacrima
On Dec 20, 1:35 am, mdipierro wrote: > Errata. I said "The dal supports transactions" where I meant "the dal > supports migrations". > Of course it also supports "transactions" as well as "distributed > transactions". Sorry, if this is not related to this topic. Does web2py support distributed t

TDD with nose or py.test

2009-11-30 Thread Lacrima
Hello! I am learning TDD with Python and there is not much information about this topic. Python is shipped with unittest module. That is fine, but I also discovered other libraries: nose and py.test. They promise to make life yet easier for a developer. But I still can't figure out, which combinat

Sqlite3. Substitution of names in query.

2009-10-30 Thread Lacrima
Hello! I use sqlite3 module for my sqlite database. I am trying to substitute table name in sql query. >>> import sqlite3 >>> con = sqlite3.connect('mydb') >>> cur = con.execute("select * from table where name='Joe'") That's ok >>> cur = con.execute("select * from table where name=?", ('Joe',))

Re: anydbm, gdbm, dbm

2009-10-28 Thread Lacrima
On Oct 27, 4:36 pm, Tim Chase wrote: > Lacrima wrote: > > I want to store some data, using anydbm module. > > According to docs the object returned by anydbm.open() supports most > > of the same functionality as dictionaries; keys and their > > corresponding values ca

anydbm, gdbm, dbm

2009-10-27 Thread Lacrima
Hello! I want to store some data, using anydbm module. According to docs the object returned by anydbm.open() supports most of the same functionality as dictionaries; keys and their corresponding values can be stored, retrieved, and deleted... I don't understand how I can make a table in DBM data

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 4:05 pm, Jean-Michel Pichavant wrote: > Lacrima wrote: > > Hello! > > > I am newbie in python and I have really simple question, but I need > > your advice to know how to do best. > > I need to store a number of dictionaries in certain place. I

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 3:31 pm, "Diez B. Roggisch" wrote: > Lacrima wrote: > > Hello! > > > I am newbie in python and I have really simple question, but I need > > your advice to know how to do best. > > I need to store a number of dictionaries in certain place. I&#x

Design question.

2009-07-20 Thread Lacrima
Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store them in a separate module. Like this: dicts.py --- dict1 = {} dict2 = {} dict3

Re: urllib with x509 certs

2009-07-17 Thread Lacrima
Hello! I've solved this problem, using pyCurl. Here is sample code. import pycurl import StringIO b = StringIO.StringIO() c = pycurl.Curl() url = 'https://example.com/' c.setopt(pycurl.URL, url) c.setopt(pycurl.WRITEFUNCTION, b.write) c.setopt(pycurl.CAINFO, 'cert.crt') c.setopt(pycurl.SSLKEY, 'm

Re: Emacs Python-mode. Newbie problem.

2009-07-09 Thread Lacrima
On Jul 9, 8:42 pm, Piet van Oostrum wrote: > >>>>> Lacrima (L) wrote: > >L> Thank you for really useful and detailed explanation. Now I can test > >L> my code usingEmacs. > >L> But I think it works for me in a little bit different way. > >L&g

Re: Emacs Python-mode. Newbie problem.

2009-07-09 Thread Lacrima
On Jul 9, 2:31 pm, Piet van Oostrum wrote: > >>>>> Lacrima (L) wrote: > >L> Thanks for your reply! > >L> My file name is 'trains.py'. > >L> When I do C-h k C-c RET, it shows me help from manual: "C-c RET runs > >L> the comm

Re: Emacs Python-mode. Newbie problem.

2009-07-08 Thread Lacrima
On Jul 8, 10:54 pm, Piet van Oostrum wrote: > >>>>> Lacrima (L) wrote: > >L> Hello! > >L> I have just started using Emacs to write python scripts. > >L> I installed python-mode.el > >L> Then I just tried this code: > >L> print '

Emacs Python-mode. Newbie problem.

2009-07-08 Thread Lacrima
Hello! I have just started using Emacs to write python scripts. I installed python-mode.el Then I just tried this code: print 'hello world' When I press C-c RET, new blank window is opened and emacs says: (Shell command succeeded with no output) So where is my 'hello world'? When I do C-c C-c,

Re: urllib with x509 certs

2009-07-04 Thread Lacrima
On Jul 4, 12:38 pm, "Martin v. Löwis" wrote: > > This works Ok! But every time I am asked to enter PEM pass phrase, > > which I specified during dividing my .p12 file. > > So my question... What should I do to make my code fetch any url > > automatically (without asking me every time to enter pass

Re: urllib with x509 certs

2009-07-04 Thread Lacrima
On Jul 4, 11:24 am, Chris Rebert wrote: > On Sat, Jul 4, 2009 at 1:12 AM, Lacrima wrote: > > Hello! > > > I am trying to use urllib to fetch some internet resources, using my > > client x509 certificate. > > I have divided my .p12 file into mykey.key and mycert.cer f

urllib with x509 certs

2009-07-04 Thread Lacrima
Hello! I am trying to use urllib to fetch some internet resources, using my client x509 certificate. I have divided my .p12 file into mykey.key and mycert.cer files. Then I use following approach: >>> import urllib >>> url = 'https://example.com' >>> xml = ''' ... somexml ''' >>> opener = urllib.U

Re: What text editor is everyone using for Python

2009-05-26 Thread Lacrima
I am new to python. And now I am using trial version of Wing IDE. But nobody mentioned it as a favourite editor. So should I buy it when trial is expired or there are better choices? -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple question about accessing instance properties.

2009-05-21 Thread Lacrima
On May 21, 7:04 pm, MRAB wrote: > Lacrima wrote: > > Hello! > > > I think I have a very simple question, but I can't understand how to > > access object properties in a way described below. > > For example I have an instance of any class: > > &g

Simple question about accessing instance properties.

2009-05-21 Thread Lacrima
Hello! I think I have a very simple question, but I can't understand how to access object properties in a way described below. For example I have an instance of any class: >>> class Person: def __init__(self): self.name = 'John' self.email = 'j...@example.c

Re: Checking for required arguments when instantiating class.

2009-05-07 Thread Lacrima
On May 6, 3:36 pm, Chris Rebert wrote: > On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum wrote: > > > > >>>>>> Lacrima (L) wrote: > > >>L> Hello! > >>L> For example I have two classes: > > >>>>>>

Re: Checking for required arguments when instantiating class.

2009-05-06 Thread Lacrima
> >>> class First: > >         def __init__(self, *args, **kwargs): >                 pass > > >>> class Second: > >         def __init__(self, somearg, *args, **kwargs): >                 self.somearg = somearg > > How can I test that First class takes 1 required argument and Second > class takes

Checking for required arguments when instantiating class.

2009-05-06 Thread Lacrima
Hello! For example I have two classes: >>> class First: def __init__(self, *args, **kwargs): pass >>> class Second: def __init__(self, somearg, *args, **kwargs): self.somearg = somearg How can I test that First class takes 1 required argument and

Re: Restart generator when it is exhausted.

2009-04-29 Thread Lacrima
On Apr 28, 6:38 pm, "J. Cliff Dyer" wrote: > On Tue, 2009-04-28 at 10:41 +, Duncan Booth wrote: > > Lacrima wrote: > > > > If it is not possible what are common techniques to use iterator or > > > generator objects that allow restarting when it is need

Re: Restart generator when it is exhausted.

2009-04-28 Thread Lacrima
On Apr 28, 1:04 pm, Chris Rebert wrote: > On Tue, Apr 28, 2009 at 2:54 AM, Lacrima wrote: > > Hello! > > > I am quite new to Python and I have maybe simple (or maybe not) > > question. > > > Is it possible to restart generator when it is exhausted? > > No.

Restart generator when it is exhausted.

2009-04-28 Thread Lacrima
Hello! I am quite new to Python and I have maybe simple (or maybe not) question. Is it possible to restart generator when it is exhausted? For example: >>> a = ['a', 'b', 'c'] >>> g = (i for i in a) >>> g.next() 'a' >>> g.next() 'b' >>> g.next() 'c' >>> g.next() Traceback (most recent call last):