[Tutor] Python file escaping issue?

2010-02-21 Thread Sithembewena Lloyd Dube
ew_file.write(line) new_file.close() assignment_file.close() When the code runs, the file path has the slashes converted to double slashes. When try to escape them, i just seemto add more slashes. What am i missing? -- Regards, Sithembewena

Re: [Tutor] Python file escaping issue?

2010-02-21 Thread Sithembewena Lloyd Dube
@Wayne, sorry to have replied to you directly.. On Sun, Feb 21, 2010 at 9:23 PM, Sithembewena Lloyd Dube wrote: > Solved by moving the file just under C:\ > > Must be an issue with directory name spaces. > > By the way, my code was riddled with bugs. readlines() returns a list

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
Wow, thank you Steve. This certainly answers a few questions i've had simmering for a while. On Mon, Feb 22, 2010 at 1:01 AM, Steven D'Aprano wrote: > On Mon, 22 Feb 2010 05:22:10 am Sithembewena Lloyd Dube wrote: > > Hi all, > > > > I'm trying to read

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
; The string holds 1 char; its representation (also a string, indeed) holds > 4. > > > The best advice is to remember that Windows allows both forward and > > backwards slashes as the path separator, and just write all your paths > > using the forw

Re: [Tutor] Python file escaping issue?

2010-02-22 Thread Sithembewena Lloyd Dube
I believe i encountered repr()in the Python tutorial, but i had not kept the relevance of it in my memory.. On Mon, Feb 22, 2010 at 9:35 PM, Sithembewena Lloyd Dube wrote: > @spr, thanks for the explanation, especially on representations of strings. > To think that i freely used repr(vari

[Tutor] Using Beautiful Soup to find an HTML element by its class attribute

2010-05-30 Thread Sithembewena Lloyd Dube
specific table row whose only identifying attribute is its CSS class? Thanks. -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Using Beautiful Soup to find an HTML element by its class attribute

2010-05-30 Thread Sithembewena Lloyd Dube
indAll('tr', class="rs1") print weather_row The call to soup.findAll is failing because "class" is a reserved keyword in Python. Using BeautifulSoup, how can I find a specific table row whose only identifying attribute is its CSS class? Thanks. -- Regards, Sithembe

Re: [Tutor] Using Beautiful Soup to find an HTML element by its class attribute

2010-05-30 Thread Sithembewena Lloyd Dube
Thanks all, I found the solution: using the attributes dictionary as follows: weather_row = soup.findAll('tr', { "class" : "rs1" }) Many thanks. On Mon, May 31, 2010 at 1:32 AM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I am using urllib to scrape

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
er > recommendations about doing some parts different. > > Kind regards, > Nethirlon > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
^^ I meant time.sleep(x), rather. Please excuse the double post. On Wed, Jun 23, 2010 at 4:29 PM, Sithembewena Lloyd Dube wrote: > My two cents' worth added below. Seems to do what you want. You probably > want to call sys.wait(x) after printing an error, so it can be read befor

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
gt; Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] OT: need computer advice from wise Tutors

2010-06-26 Thread Sithembewena Lloyd Dube
_ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor mailli

Re: [Tutor] OT: need computer advice from wise Tutors

2010-06-26 Thread Sithembewena Lloyd Dube
e: > On Sat, Jun 26, 2010 at 11:55, Sithembewena Lloyd Dube > wrote: > > Richard, I think you may go ahead without trepidation. I am not a Windows > > fan at all, I prefer Ubuntu. But I started using Win. 7 at work about a > > month ago, and I have to say it hasn't give

[Tutor] Using Django with TortoiseSVN (overwriting files)

2010-08-16 Thread Sithembewena Lloyd Dube
, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Using Django with TortoiseSVN (overwriting files)

2010-08-16 Thread Sithembewena Lloyd Dube
er on the server or the local machines; it's best to keep those out of > SVN, or have a little if-else clause in settings.py that takes care > server-dependent settings. > Otherwise, all your code can (and should) be machine/server agnostic, an

[Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Sithembewena Lloyd Dube
Hi folks, Supposing I had the float 4.4348 and I wished to round it off to the nearest half-integer upwards or downwards, how would I go about it? Many thanks... -- Regards, Sithembewena Lloyd Dube http://www.lloyddube.com ___ Tutor maillist

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Sithembewena Lloyd Dube
I realise that one cannot have a half integer :) I meant how would one round off to the first decimal nearest to either 0.5, or a whole number. Ugh...does anyone get what I'm trying to articulate? :) On Fri, Oct 8, 2010 at 2:51 PM, Sithembewena Lloyd Dube wrote: > Hi folks, > > S

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Sithembewena Lloyd Dube
ulate? :) > > Multiply by 2, round(), divide by 2? > > > > > > On Fri, Oct 8, 2010 at 2:51 PM, Sithembewena Lloyd Dube < > zebr...@gmail.com> wrote: > > Hi folks, > > > > Supposing I had the float 4.4348 and I wished to round it off to the >

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-08 Thread Sithembewena Lloyd Dube
gt; r >> [1.0, 1.0, 1.0, 1.5, 1.5, 1.5, 1.5, 1.5, 2.0, 2.0] >> >>> >> >> > -- > Joel Goldstick > > > _______ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: >

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-11 Thread Sithembewena Lloyd Dube
Thanks everyone. On Fri, Oct 8, 2010 at 11:44 PM, Wayne Werner wrote: > On Fri, Oct 8, 2010 at 7:58 AM, Sithembewena Lloyd Dube > wrote: > >> I realise that one cannot have a half integer :) I meant how would one >> round off to the first decimal nearest to either 0

Re: [Tutor] Rounding a Python float to the nearest half integer

2010-10-11 Thread Sithembewena Lloyd Dube
a floating point number. Precision may be > negative. > === > > >>> round(1.23423,2) > 1.23 > >>> round(1.23623,2) > 1.24 > > > HTH. > > On Mon, Oct 11, 2010 at 13:51, Sithembewena Lloyd Dube > wrote: > >> Thanks everyone. >>

Re: [Tutor] Moving my C++ code to Python?

2010-10-17 Thread Sithembewena Lloyd Dube
>>> > >>> python_stuff.process(largestuff, otherparams1) # It's important that > this data can be read (and I hope written) by python code > >>> python_stuff.process(largestuff, otherparams2) > >>> > >>> c_stuff.write(largestuff) #write result > &g

Re: [Tutor] Moving my C++ code to Python?

2010-10-17 Thread Sithembewena Lloyd Dube
> > [1] > http://blog.chrischou.org/2010/02/28/simple-benchmark-between-cython-and-boost-python/ > > Thank you, > Paul > > And a link I found today. > [2] > http://koichitamura.blogspot.com/2008/06/various-ways-to-integrate-python-and-c.html > > On Sun, Oct 17, 2010 at 1:56 PM, Sit

Re: [Tutor] Trying to parse a HUGE(1gb) xml file in python

2010-12-20 Thread Sithembewena Lloyd Dube
> -- > Brett Ritter / SwiftOne > swift...@swiftone.org > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Regards, Sithembewena Lloyd Dube <<338.gif>>_

[Tutor] Parsing an XML document using ElementTree

2011-05-24 Thread Sithembewena Lloyd Dube
teger (to see that the document is traversed) I get the same result - the int remains at 0. >>> i = 0 >>> for node in xml_content.getiterator('contest'): ... i += 1 ... >>> i 0 What am I getting wrong? Any hints would be appreciated. -- Regards, Sithemb

Re: [Tutor] Parsing an XML document using ElementTree

2011-05-25 Thread Sithembewena Lloyd Dube
way = contest_child_node.text contest_list.append(contest) try: os.remove(current_path) except: pass return contest_list Many thanks! On Tue, May 24, 2011 at 12:35 PM, Stefan Behnel wrote: > Sithembewena Lloyd Dube, 24.05.2011 11:59: >

Re: [Tutor] Parsing an XML document using ElementTree

2011-06-10 Thread Sithembewena Lloyd Dube
Hi Stefan, Thanks for the code review :) Only just noticed this. On Wed, May 25, 2011 at 3:10 PM, Stefan Behnel wrote: > Sithembewena Lloyd Dube, 25.05.2011 14:40: > > Thanks for all your suggestions. I read up on gzip and urllib and also >> learned in the process that I could

Re: [Tutor] Error handling

2012-03-24 Thread Sithembewena Lloyd Dube
; > > Why wouldn't it be errno.e instead of e.errno? > >> >> -- >> Colton Myers >> >> > > > -- > Michael J. Lewis > > mjole...@gmail.com > 415.815.7257 > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, Sithembewena Lloyd Dube ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Barcode decoder in Python

2012-06-26 Thread Sithembewena Lloyd Dube
, Sithembewena Lloyd Dube ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Generating random alphanumeric codes

2012-06-26 Thread Sithembewena Lloyd Dube
HI, Would anyone have tips on how to generate random 4-digit alphanumeric codes in python? Also, how does one calculate the number of possible combinations? Thanks in advance. -- Regards, Sithembewena Lloyd Dube ___ Tutor maillist - Tutor

[Tutor] 2 vs 3

2015-09-05 Thread Sithembewena Lloyd Dube
Hi all, A colleague and I are embarking on a project for a client. We have agreed to implement a REST API in Falcon (www.falconframework.org) and colleague wants to implement it in Python 3. Are there any advantages/ disadvantages of using Python 3? I have always stuck to Python 2. -- Kind rega

Re: [Tutor] 2 vs 3

2015-09-05 Thread Sithembewena Lloyd Dube
@Steven, @Mark, Thanks for the feedback. On Sat, Sep 5, 2015 at 5:37 PM, Mark Lawrence wrote: > On 05/09/2015 14:25, Steven D'Aprano wrote: > >> On Sat, Sep 05, 2015 at 03:06:25PM +0200, Sithembewena Lloyd Dube wrote: >> >>> Hi all, >>> >>>

Re: [Tutor] 2 vs 3

2015-09-07 Thread Sithembewena Lloyd Dube
This has turned into a very interesting discussion. Thank you to everyone who's participating and sharing nuggets of information on 2 vs 3. On Mon, Sep 7, 2015 at 1:58 PM, Steven D'Aprano wrote: > On Mon, Sep 07, 2015 at 11:01:00AM +0100, Alan Gauld wrote: > > On 07/09/15 10:32, Laura Creighton

[Tutor] PyCountry currency formatting woes

2014-05-04 Thread Sithembewena Lloyd Dube
Hi everyone, I have a function which accepts an alpha2 country code and a price string, where the aim is to get the country's currency and use the currency.letter property of that currency to format the supplied price string. The above works fine so far - yet it falls over when called with German

Re: [Tutor] PyCountry currency formatting woes

2014-05-04 Thread Sithembewena Lloyd Dube
e? On Sun, May 4, 2014 at 10:25 PM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I have a function which accepts an alpha2 country code and a price string, > where the aim is to get the country's currency and use the currency.letter > property of that currency to format the

Re: [Tutor] PyCountry currency formatting woes

2014-05-06 Thread Sithembewena Lloyd Dube
Thanks for this response, this is exactly what I needed to know. On Mon, May 5, 2014 at 6:26 AM, Marc Tompkins wrote: > On Sun, May 4, 2014 at 1:55 PM, Sithembewena Lloyd Dube > wrote: > >> Thanks, i was actually getting the error information to update the post. >> Apoligi

Re: [Tutor] PyCountry currency formatting woes

2014-05-08 Thread Sithembewena Lloyd Dube
Thank you all, babel works just fine. I also tried ccy, which isn't bad either - except that it returns non-unicode currency letters for countries in the Eurozone. On Mon, May 5, 2014 at 10:10 AM, Peter Otten <__pete...@web.de> wrote: > Sithembewena Lloyd Dube wrote: >

[Tutor] Preparing virtualenvwrapper for Django 1.6 development

2014-08-22 Thread Sithembewena Lloyd Dube
Hi everyone, I am developing on a Windows 8.1 machine and wold like to setup virtualenvironment via virtualenvwrapper so as to have a properly set up Python development environment. I am referring to Jeff Knupp's guide at http://www.jeffknupp.com/blog/2013/12/18/starting-a-django-16-project-the-r