Re: How does Python's OOP feel?

2009-05-26 Thread Teguh Iskanto
Ikon wrote:
>I'm rather new to Python. I have PHP for my main language and I do
>some Java. They all have a very strict OO schema. As I red through
>Python's tutorial it seams it has nothing of those rules. No statical,
>abstract classes, functions, or variables.
>
>I wish someone, who has experience in both Java/PHP/C# and Python
>would tell me how mush better/worse is it to program in a language
>that misses most of the OO parts!
>

Here's a view from a seasonal programmer :

My day job is mostly doing some networking/security stuffs,
I only do programmings only if I had to (like creating
tools/automation/etc) or if no one in my network team was able/didn't
want to do it :(
Just a couple months back we had an engineering issue and we needed to
create/design a robust broker system that works in a background.
This system would take orders from different systems in a form of XML
and should be able to 'talk' to cluster firewalls (range in hundreds
of firewalls) and should be able to add/remove/check/verify/edit
objects on the individual firewall.

Knowing the complexity of the problem and the time constraint that we
had (my manager gave me 2.5 months to get this thing to work) , I had
no other resolution other than turning my self into python. At first I
was a bit doubtful but I kept moving on esp knowing that running a big
and complex project with perl would be like 'digging my own graveyard'
(especially in terms of modularity & maintenance ).

As it turned out, I enjoyed doing big projects with python especially
with its OOP style : simple & really easy --without having to go into
too much OOP details or bogged down with OOP theory-- it just works !
and  it's as easy as if you're running a 'plug & play' module and
playing LEGO. Long story short, I was able to present the whole system
in time and the system is now being used in production for a mission
critical F/W deployment ( I've used pyexpect,XML and Threading to
speed up the process )

The good thing about python is : it 'tastes' like what it was being
advertised (eg: Makes things easy and makes complex problem possible )
and I agree 100% with that. If a seasonal programmer like me find it
easy, then it should be much easier for you.

BTW: Before this project, I've programmed in C/PHP/Perl/Tcl but never
had a chance to really try Python in a full-blown OOP complex project.
HTH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What text editor is everyone using for Python

2009-05-26 Thread Teguh Iskanto
Have you tried vim ? it has got tons of tons of features, like ( just
to name a few)  : file manager, color syntax, tab screen,
command/syntax completion (cache only) , vertical split, horizontal
split, colorful diffing, create a patch, etc .. you name it  !! .
There's also plugins / script that people share @
http://www.vim.org/scripts/index.php. Also Vim comes in Windows/Unix
version :)

IMO, you don't even need an IDE, if you combined vim + "screen" ( man
screen ) as both are really powerful tools
for example: you're working in the office and connected to your remote
CVS server, with "screen" you can lock the screen with password &
detach it. once you're @ home and want to continue to work , you just
need to log in to that cvs server again and do "screen -r" and voila
your session is still there :)

BTW: "screen" does split screen too :)

HTH




On Wed, May 27, 2009 at 2:56 PM, Ankit  wrote:
> On May 26, 6:04 pm, J Kenneth King  wrote:
>> Lacrima  writes:
>> > 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?
>>
>
> I will suggest u to use TEXTPAD 4 on windows and
> Emacs or Vi or RocketEdit on your Linux machine
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DB-API execute params, am I missing something?

2009-05-27 Thread Teguh Iskanto
On Thu, May 28, 2009 at 11:12 AM, Lawrence D'Oliveiro
 wrote:

> In message <784h2cf1kem0...@mid.uni-berlin.de>, Diez B. Roggisch wrote:
>
> > Lawrence D'Oliveiro wrote:
> >
> >> In message , Dennis
> >> Lee Bieber wrote:
> >>
> >>> Notice that db.literal() call? That's part of the mechanism used to
> >>> escape and quote parameters -- it only returns strings that are safe
> for
> >>> insertion into the SQL statement.
> >>
> >> Does it deal with "like"-wildcards?
> >
> > Why shouldn't it?
> >
> > cursor.execute("select * from table where column like %s", "%name%")
>
> What if the string you're searching for includes a "%" or "_" character?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

>>> A="0"
>>> B="%"
>>>
>>> print "select * from test_table where a like '%%%s%%' " %A
select * from test_table where a like '%0%'
>>>
>>> print "select * from test_table where a like '%%%s%%' " %B
select * from test_table where a like '%%%'
>>>

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


Re: extract to dictionaries

2009-05-28 Thread Teguh Iskanto
You can create this modularly by :
1. parse the file and cut this into different chunks ( look for 'end' ) then
you have two chunks for param 1 & 2
2. once you have those chunks then process each chunk with your own
processing based on your parameters ( 1 or 2 )
3. then based on your individual param, create a process to populate your
dict
4. done

hint: "pydoc string"  ( I'm assuming that you already know about regex, if
not then use this : "pydoc re"  )
BTW: I've used this methods to parse  cisco/contivity configs

HTH

On Fri, May 29, 2009 at 9:03 AM, Marius Retegan
wrote:

> Hello
> I have simple text file that I have to parse. It looks something like
> this:
>
> parameters1
> key1 value1
> key2 value2
> end
>
> parameters2
> key1 value1
> key2 value2
> end
>
> So I want to create two dictionaries parameters1={key1:value1,
> key2:value2} and the same for parameters2.
>
> I woud appreciate any help that could help me solve this.
> Thank you
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DB-API execute params, am I missing something?

2009-05-28 Thread Teguh Iskanto
On Fri, May 29, 2009 at 3:21 PM, Dennis Lee Bieber wrote:

>
>This won't work as the DB-API is going to quote the parameter, and
> the final result would be '%'whatever'%'. Essentially, you must put the
> wildcard marker on the actual parameter before feeding it to the API.
> --
>WulfraedDennis Lee Bieber   KD6MOG
>wlfr...@ix.netcom.com   wulfr...@bestiaria.com
>HTTP://wlfraed.home.netcom.com/
>(Bestiaria Support Staff:   web-a...@bestiaria.com)
>HTTP://www.bestiaria.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


it works for me :)

mysql> select * from test_table ;
+--+--+--+
| a| b| c|
+--+--+--+
| 0| 0| 0|
| 1| 1| 1|
| 2| 2| 2|
| 3| 3| 3|
| 4| 4| 4|
| 5| 5| 5|
| 6| 6| 6|
| 7| 7| 7|
| 8| 8| 8|
| 9| 9| 9|
| 10   | 10   | 10   |
| 11   | 11   | 11   |
| 12   | 12   | 12   |
| 13   | 13   | 13   |
| 14   | 14   | 14   |
| 15   | 15   | 15   |
| 16   | 16   | 16   |
| 17   | 17   | 17   |
| 18   | 18   | 18   |
| 19   | 19   | 19   |
| 20   | 20   | 20   |
| 21   | 21   | 21   |
| 22   | 22   | 22   |
| 23   | 23   | 23   |
| 24   | 24   | 24   |
| 25   | 25   | 25   |
| 26   | 26   | 26   |
| 27   | 27   | 27   |
| 28   | 28   | 28   |
| 29   | 29   | 29   |
+--+--+--+
30 rows in set (0.00 sec)


>>> import MySQLdb
>>> conn = MySQLdb.connect (host='localhost', user='root', passwd='crappy',
db='testme')
>>> input_crap = "0"
>>> conn.query("select * from test_table where a like '%%%s%%'" %input_crap)
>>> result = conn.store_result()
>>> rows = result.num_rows()
>>> cols = result.num_fields()
>>> data = result.fetch_row(rows,1)
>>> print data
({'a': '0', 'c': '0', 'b': '0'}, {'a': '10', 'c': '10', 'b': '10'}, {'a':
'20', 'c': '20', 'b': '20'})
>>>

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


Re: How does Python's OOP feel?

2009-05-30 Thread Teguh Iskanto
On Sat, May 30, 2009 at 2:50 PM, Benjamin Kaplan  wrote:

>
>
> On Fri, May 29, 2009 at 9:41 PM, Lie Ryan  wrote:
>
>> Ikon wrote:
>> > I'm rather new to Python. I have PHP for my main language and I do
>> > some Java. They all have a very strict OO schema. As I red through
>> > Python's tutorial it seams it has nothing of those rules. No statical,
>> > abstract classes, functions, or variables.
>> >
>> > I wish someone, who has experience in both Java/PHP/C# and Python
>> > would tell me how mush better/worse is it to program in a language
>> > that misses most of the OO parts!
>>
>> import antigravity
>
>
> You forgot the link. http://www.xkcd.com/353/
>


ha ha ha ha +1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re:

2009-06-02 Thread Teguh Iskanto
how about this :
- dump those data with sort enabled
- use diff to those two dumps  , eg: diff dump_a dump_b

if you don't know what diff is , try : man diff

HTH


On Tue, Jun 2, 2009 at 2:50 AM, Kiran Siddiqui
wrote:

>  hi have to parse a very complex dumps(whatever it is), i have done the
> parsing thruogh python.since the parsed data is very huge in amount, i have
> to feed it in the database (SQL), I have also done this... now the thing is
> i have to compare the data now present in the sql.
>
>
>
> in actual i have to compare the data of 1st dump with the data of the 2nd
> dump. the both dump have the same fields(attributes) but the values of
> their field may be change... so i have to detect this change.. for this i
> have to do the comparison...
>
>
>
> i.e, let i have a tableA ,its 1st row carry the data of dump1 and then on
> the 2nd day the data comes from dump2 go into the next row of tableA. and i
> have to compare both rows.
>
>
>
>  but i dont have the idea how to do this all using python as my front end.
>
>
>
> plz pl anyone help me:(
>
>
>
> --
> See all the ways you can stay connected to friends and 
> family
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list