Login Register


Sweet Python Techniques and Advices. filter_list
Author
Message
RE: Sweet Python Techniques and Advices. #11
(08-13-2014, 08:09 PM)h3r0 Wrote: Great resource, there are a lot of little gems in there. Thank you.

(08-13-2014, 06:04 PM)l4ur15 Wrote: Thank you very much! That's what they don't teach you in books...

Thank you both for the feedback.
This thread will be updated soon again!
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Sweet Python Techniques and Advices. #12
(08-13-2014, 08:09 PM)h3r0 Wrote: Great resource, there are a lot of little gems in there. Thank you.

(08-13-2014, 06:04 PM)l4ur15 Wrote: Thank you very much! That's what they don't teach you in books...

Thank you both for the feedback.
This thread will be updated soon again!
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Sweet Python Techniques and Advices. #13
(08-13-2014, 10:35 PM)L0aD1nG Wrote:
(08-13-2014, 05:53 PM)Psycho_Coder Wrote: for xml parsing use lxml its fast efficient and very user friendly

I am still using etree, I must check the others sometime. But still I find etree to be very clear.

EDIT: Does lxml.etree has a tostring() method that supports "pretty_print=True" as args?



Yes. Have a look : http://lxml.de/tutorial.html#the-e-factory

It has much more capabilities.
[Image: OilyCostlyEwe.gif]

Reply

RE: Sweet Python Techniques and Advices. #14
(08-13-2014, 10:35 PM)L0aD1nG Wrote:
(08-13-2014, 05:53 PM)Psycho_Coder Wrote: for xml parsing use lxml its fast efficient and very user friendly

I am still using etree, I must check the others sometime. But still I find etree to be very clear.

EDIT: Does lxml.etree has a tostring() method that supports "pretty_print=True" as args?



Yes. Have a look : http://lxml.de/tutorial.html#the-e-factory

It has much more capabilities.
[Image: OilyCostlyEwe.gif]

Reply

RE: Sweet Python Techniques and Advices. #15
(08-14-2014, 07:14 AM)Psycho_Coder Wrote:
(08-13-2014, 10:35 PM)L0aD1nG Wrote:
(08-13-2014, 05:53 PM)Psycho_Coder Wrote: for xml parsing use lxml its fast efficient and very user friendly

I am still using etree, I must check the others sometime. But still I find etree to be very clear.

EDIT: Does lxml.etree has a tostring() method that supports "pretty_print=True" as args?



Yes. Have a look : http://lxml.de/tutorial.html#the-e-factory

It has much more capabilities.

Thank you sir, I will check it out some time!
Thanks for the recommendation!
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Sweet Python Techniques and Advices. #16
(08-14-2014, 07:14 AM)Psycho_Coder Wrote:
(08-13-2014, 10:35 PM)L0aD1nG Wrote:
(08-13-2014, 05:53 PM)Psycho_Coder Wrote: for xml parsing use lxml its fast efficient and very user friendly

I am still using etree, I must check the others sometime. But still I find etree to be very clear.

EDIT: Does lxml.etree has a tostring() method that supports "pretty_print=True" as args?



Yes. Have a look : http://lxml.de/tutorial.html#the-e-factory

It has much more capabilities.

Thank you sir, I will check it out some time!
Thanks for the recommendation!
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Sweet Python Techniques and Advices. #17
Thank you! Totally worth to know this.

Reply

RE: Sweet Python Techniques and Advices. #18
Thank you! Totally worth to know this.

Reply

RE: Sweet Python Techniques and Advices. #19
(09-05-2014, 09:40 PM)Venatori Wrote: Very good post here! These technique's will definitely help me in my future Python endeavors!

I do have one question though. What is the actual benefit from your "raw_input()" advice?

Thank you for your good words.

Well in python 2.x sys.stdin.readline() it proves to be a little faster when its about taking inputs from the user cause it avoids some automated things that which built-in raw_input() does (like for example the '\n' striping which in some case you might don't need it). Also its good to mention here that this 'problem' is claimed to be fixed on Python3.x versions and input() function.

For example if its about to take massive inputs and use raw_input inside a loop, if you want to achieve best performance available its prefferable to use sys.stdin.readline().
I made a simple sample run for you in ipython take a look...

Spoiler: Sample Image
[Image: Iol9ZDs.png]



Although that the difference is not big, its still a difference.
Plus the difference in time can vary depending on the task you have to solve.

I hope this helps.
Sincerely,
L0aD1nG
(This post was last modified: 09-05-2014, 10:26 PM by krozz.)
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Sweet Python Techniques and Advices. #20
Hahaha you took that prettifyXMl code from my PINN modules that I shared Tongue hahaha okay no problem.
[Image: OilyCostlyEwe.gif]

Reply







Users browsing this thread: 1 Guest(s)