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

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 raymond.hettin...@gmail.com wrote: On Jul 24, 12:47 am, Lacrima lacrima.ma...@gmail.com wrote: Hi! I have two super classes: class SuperClass1(object):     def __init__(self, word):         print word class SuperClass2(object):     def

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: 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 c...@rebertia.com wrote: On Thu, Apr 1, 2010 at 2:08 AM, Lacrima lacrima.ma...@gmail.com wrote: Hello! I need to format a decimal (floating point) number in the following way: 10 results

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

2010-03-27 Thread Lacrima
On Mar 26, 10:22 am, Michele Simionato michele.simion...@gmail.com wrote: On Mar 25, 2:24 pm, Michele Simionato michele.simion...@gmail.com wrote: On Mar 25, 1:28 pm, Ethan Furman et...@stoneleaf.us wrote: Michele, Was wondering if you'd had a chance to re-post your lectures -- just

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

Re: Can't install ssl for Python2.5

2010-03-10 Thread Lacrima
On Mar 10, 11:23 pm, Martin v. Loewis mar...@v.loewis.de 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! --

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

Re: Which mock library do you prefer?

2010-02-21 Thread Lacrima
On Feb 18, 3:20 am, Ben Finney ben+pyt...@benfinney.id.au wrote: Lacrima lacrima.ma...@gmail.com 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 example

Re: Which mock library do you prefer?

2010-02-17 Thread Lacrima
On Feb 16, 7:38 pm, Phlip phlip2...@gmail.com 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

Re: Which mock library do you prefer?

2010-02-17 Thread Lacrima
On Feb 16, 10:30 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Lacrima lacrima.ma...@gmail.com 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

Re: Which mock library do you prefer?

2010-02-16 Thread Lacrima
On Feb 16, 2:17 am, Ben Finney ben+pyt...@benfinney.id.au wrote: Lacrima lacrima.ma...@gmail.com 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

Re: Which mock library do you prefer?

2010-02-16 Thread Lacrima
On Feb 15, 9:56 pm, Phlip phlip2...@gmail.com 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 A (i.e. to mock 'self

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:

Re: Which mock library do you prefer?

2010-02-15 Thread Lacrima
On Feb 15, 6:57 pm, Phlip phlip2...@gmail.com 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 attention are: * minimock

Re: what test runner should I use?

2010-01-21 Thread Lacrima
On Jan 19, 12:56 pm, Chris Withers ch...@simplistix.co.uk 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

Re: Anybody use web2py?

2009-12-21 Thread Lacrima
On Dec 20, 1:35 am, mdipierro massimodipierr...@gmail.com 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

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

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',)) That's ok too

Re: anydbm, gdbm, dbm

2009-10-28 Thread Lacrima
On Oct 27, 4:36 pm, Tim Chase python.l...@tim.thechases.com 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 can

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

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 = {}

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 3:31 pm, Diez B. Roggisch de...@nospam.web.de 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've decided to store them

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 4:05 pm, Jean-Michel Pichavant jeanmic...@sequans.com 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've decided to store them

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,

Re: Emacs Python-mode. Newbie problem.

2009-07-09 Thread Lacrima
On Jul 8, 10:54 pm, Piet van Oostrum p...@cs.uu.nl wrote: Lacrima lacrima.ma...@gmail.com (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 'hello world' L When I press C-c RET, new blank

Re: Emacs Python-mode. Newbie problem.

2009-07-09 Thread Lacrima
On Jul 9, 2:31 pm, Piet van Oostrum p...@cs.uu.nl wrote: Lacrima lacrima.ma...@gmail.com (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 command py-execute-import-or-reload L    which

Re: Emacs Python-mode. Newbie problem.

2009-07-09 Thread Lacrima
On Jul 9, 8:42 pm, Piet van Oostrum p...@cs.uu.nl wrote: Lacrima lacrima.ma...@gmail.com (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 My file contains only the 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

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 = '''request ... somexmlsomexml/somexml /request'''

Re: urllib with x509 certs

2009-07-04 Thread Lacrima
On Jul 4, 11:24 am, Chris Rebert c...@rebertia.com wrote: On Sat, Jul 4, 2009 at 1:12 AM, Lacrimalacrima.ma...@gmail.com 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

Re: urllib with x509 certs

2009-07-04 Thread Lacrima
On Jul 4, 12:38 pm, Martin v. Löwis mar...@v.loewis.de 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

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

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 =

Re: Simple question about accessing instance properties.

2009-05-21 Thread Lacrima
On May 21, 7:04 pm, MRAB goo...@mrabarnett.plus.com 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: class Person:    def __init__(self

Re: Checking for required arguments when instantiating class.

2009-05-07 Thread Lacrima
On May 6, 3:36 pm, Chris Rebert c...@rebertia.com wrote: On Wed, May 6, 2009 at 5:24 AM, Piet van Oostrum p...@cs.uu.nl wrote: Lacrima lacrima.ma...@gmail.com (L) wrote: L Hello! L For example I have two classes: class First: L     def __init__(self, *args, **kwargs): L

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: 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 no required

Re: Restart generator when it is exhausted.

2009-04-29 Thread Lacrima
On Apr 28, 6:38 pm, J. Cliff Dyer j...@sdf.lonestar.org wrote: On Tue, 2009-04-28 at 10:41 +, Duncan Booth wrote: Lacrima lacrima.ma...@gmail.com wrote: If it is not possible what are common techniques to use iterator or generator objects that allow restarting when it is needed

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): File

Re: Restart generator when it is exhausted.

2009-04-28 Thread Lacrima
On Apr 28, 1:04 pm, Chris Rebert c...@rebertia.com wrote: On Tue, Apr 28, 2009 at 2:54 AM, Lacrima lacrima.ma...@gmail.com 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. You have