Re: Wikicodia - The code snippets wiki

2007-07-28 Thread Tina I
Wikicodia Admin wrote:
 Dears,
 
 Wikicodia is a wiki based project for sharing code snippets. We're
 collecting large number of code snippets for all code-based
 programming languages, scripts, shells and consoles. We wish you could
 help us. We're still BETA. Your suggestions, ideas and criticisms are
 very welcomed. We're waiting for you contributions. You can easily
 share and search our snippet using our Google Desktop Gadget. Share
 your Python snippets to help the world :)
 
 http://www.wikicodia.com
 
 Thanks
 Wikicodia Admin
 
Just in case you are not aware of it; there already exists a fairly 
identical service called The Rosetta Code at http://www.rosettacode.org/

Maybe you could join forces instead? ;-)

Tina
PS: I'm not affiliated with Rosetta in any way...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Submit form, open result in a browser

2007-07-27 Thread Tina I
theju wrote:
 Is there a way to submit a form and then open the resulting page in the
 default browser? (Writing the form submission code is not a problem by
 the way)
 
 There is a library called Client Form that does this for you.
 wwwsearch.sourceforge.net/ClientForm/
 
 After the form is submitted through ClientForm open the resulting
 response using the webbrowser module.
 
 Cheers
 Thejaswi Puthraya
 

ClientForm is absolutely perfect! Less than 10 lines of extra code and 
the job is done :)

Thanks!
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Submit form, open result in a browser

2007-07-27 Thread Tina I
Hi,

Is there a way to submit a form and then open the resulting page in the 
default browser? (Writing the form submission code is not a problem by 
the way)
I guess what I'm asking is how I can get the resulting URL and feed it 
to the webbrowser module.
I need to do it this way because the site owners will not let me parse 
the page and show the result inside my application... loss of 
advertising revenue I guess. And since it's just a small added feature 
to the application, opening it in a browser is fine. I just need to get 
an idea on how to do it...

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python extra

2007-07-11 Thread Tina I
[EMAIL PROTECTED] wrote:
 On Jul 8, 12:59?pm, Neal Becker [EMAIL PROTECTED] wrote:
 Just a little python humor:

 http://www.amazon.com/Vitamin-Shoppe-Python-Extra-tablets/dp/B00012NJ...
 
 Aren't there any female Python programmers?
 
No, of course not.
Oh, and guys: If you take those pills please observe the warning; 
Safety information: Do not use if you are pregnant or nursing!
:P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Goto

2007-06-17 Thread Tina I
Daniel Nogradi wrote:
 How does one effect a goto in python? I only want to use it for debug.
 I dasn't slap an if clause around the portion to dummy out, the
 indentation police will nab me.
 
 
 http://entrian.com/goto/
LOL!! * major flashback to horrible BASIC programs from the eighties *

Back then I took a course in structured BASIC programming (now there is 
a contradiction in terms) and the instructor warned about goto time and 
time again. But his biggest mistake was to tell us that if we had to use 
goto at least we should explain it in a comment. So we would turn in 
programs with sections like:

100 IF S$=YES THEN GOTO 150
110 REM Go to line 150 if S$ is Yes


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


Re: Unsubscribing from the mailing list

2007-05-28 Thread Tina I
[EMAIL PROTECTED] wrote:
 Hi All,
 
 I do not know if this is the correct group to ask this question. But
 since mailman is python-based I thought i would ask here.
 
 I had subscribed to a mailing list called [EMAIL PROTECTED]
 adventitiously. I then wanted to reverse my decision and so tried to
 unsubscribe from the mailing list. The web interface told that I had
 to enter my username and then click unsubscribe. I did so. I was
 responded with the message that A confirmation mail has been sent.
 However I did not get any mail of that sort. Due to this I am not able
 to unsubscribe and I get loads of emails from that mailing list every
 day.
 
 Can somebody help me get out of this mess??
 
 Thanks,
 Sundar
 
Umm... why not ask on [EMAIL PROTECTED] ??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing programs depending on third party modules.

2007-05-16 Thread Tina I
David Boddie wrote:
 On May 16, 7:44 am, Tina I [EMAIL PROTECTED] wrote:
 
 A binary would be ideal. I'll look into the freeze modules and
 Pyinstaller. Even if they don't handle huge things like Qt it would be a
 step in the right direction if it handles smaller third part modules.
 And maybe the smartest thing to do would be to dump PyQt and just
 go for tkinter, however ugly it is :/
 
 It's may be worth reading this message before making such a drastic
 decision:
 
 http://www.riverbankcomputing.com/pipermail/pyqt/2007-May/016092.html
 
 David ;-)
 
Oh... now I feel stupid... I'm on the PyQt list but somehow missed that 
topic.
Thanks!

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


Re: Distributing programs depending on third party modules.

2007-05-16 Thread Tina I
Kevin Walzer wrote:
 Tina I wrote:
 Kevin Walzer wrote:
 
 
 And maybe the smartest thing to do would be to dump PyQt and just go 
 for tkinter, however ugly it is :/
 
 Tkinter doesn't have to be ugly.
 
 I sell a proprietary Tkinter app commercially on OS X:
 
 http://www.codebykevin.com/phynchronicity-running.png
 

Thanks, looks very nice :)
I'll play around with Tkinter a little and maybe try it out for my next 
project just for fun.

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


Distributing programs depending on third party modules.

2007-05-15 Thread Tina I
Hi list,

Is there a preferred way to distribute programs that depends on third 
party modules like PyQt, Beautifulsoup etc? I have used setuptools and 
just having the setup script check for the existence of the required 
modules. If they're not found I have it exit with a message that it need 
this or that installed.

But this is not very convenient for the end user and I have got a few 
complaints about it. Am I missing something in setuptools or is there a 
better way to do it (except for bundling the modules in the package 
which seem like a rather nasty workaround)?

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing programs depending on third party modules.

2007-05-15 Thread Tina I
Kevin Walzer wrote:
 
 What platform are you doing this on? On the Linux platform, dependency 
 hell of this sort is pretty much unavoidable, because there are so many 
 different packaging systems (apt, rpm, and so on): it's standard to let 
 the package manager handle these dependencies. And yes, it is 
 frustrating for end users.
I mainly write apps for Linux although some are in theory cross platform 
(but I don't have Windows to test on so I don't really care about that 
part). Of course catering to every concievable package management system 
is impossible so I'm looking for something to make it easy for people to 
use the app as it is.
 
 There are other methods for distributing frozen binaries, including 
 the freeze module that ships with Python itself, cx_freeze, and 
 PyInstaller: these three may work on Linux/Unix as well as Windows (they 
 are not supported on the Mac). But the methods above are generally the 
 ones most widely used.
 
A binary would be ideal. I'll look into the freeze modules and 
Pyinstaller. Even if they don't handle huge things like Qt it would be a 
step in the right direction if it handles smaller third part modules.
And maybe the smartest thing to do would be to dump PyQt and just go for 
tkinter, however ugly it is :/

Anyways, thanks for the help people
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Init style output with python?

2007-05-06 Thread Tina I
Maxim Veksler wrote:

 Is there are frame work or something in python that would allow me to
 do this (quickly) ?
 If not, ideas how I should I be getting this boring task of:
 1. get screen width

You can look into the 'curses' module and do something like:

screen = curses.initscreen()
maxheight, maxwith = screen.getmaxyx()

In my experience curses can be a bit tricky to work with but the online 
tutorials have some nice examples that help you avoid some of the 
pitfalls (like messing up your terminal)

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


Re: how update a qListView in backgroud

2007-05-02 Thread Tina I
Reinaldo Carvalho wrote:
 Hi,
 
 I programming with qt module and i have a qWidgetTab with a qListView
 inside, and i need update the qListView every 5 seconds, how do this
 on transparent mode to user. I do a function to update, but i dont
 know call then.
 
 I will start this update when user select this tab, and stop whe user
 leave this tab. I need a thread ot something else?
 
Assuming PyQt4 here:
Check out QTimer. Have it start when the user selects the tab and have 
it timeout every five seconds calling the update function.

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


Re: lowercase class names, eg., qtgui ? (PyQt4)

2007-04-26 Thread Tina I
Glen wrote:
 Hello,
 
 In the file generated by pyuic4 from Designer's .ui file I noticed the use
 of lower case class names (I'm assuming these are the names of classes,
 not modules).  For example:
 
 It imports thusly:
 
 from PyQt4 import QtGui
 
 then uses things like:
 self.gridlayout = qtgui.qgridlayout(dldialog)
 
 What exactly is going on here?  Are these instances that are defined
 somewhere else (their not in the local scope.)? Can I do the same in my
 code when I import something?
 
 Thanks,
 
 Glen
 
 Glen
 
Hi,

Are you sure? That's strange. I have never seen that. Here is a snippet 
of one of my typical .py files generated by 'pyuic4':

self.gridlayout = QtGui.QGridLayout(self.centralwidget)
self.gridlayout.setMargin(9)
self.gridlayout.setSpacing(6)
self.gridlayout.setObjectName(gridlayout)

self.hboxlayout = QtGui.QHBoxLayout()
self.hboxlayout.setMargin(0)
self.hboxlayout.setSpacing(6)
self.hboxlayout.setObjectName(hboxlayout)

self.hboxlayout1 = QtGui.QHBoxLayout()
self.hboxlayout1.setMargin(0)
self.hboxlayout1.setSpacing(6)
self.hboxlayout1.setObjectName(hboxlayout1)

Upper case all the way...

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


Re: Catching a specific IO error

2007-04-25 Thread Tina I
Gabriel Genellina wrote:
 You can get the 2 as the errno exception attribute. BTW, 2 == errno.ENOENT
 
  try:
  export = open(self.exportFileName , 'w')
  except IOError, e:
 if e.errno==errno.ENOENT:
 # handle the No such file or directory error
  # calling an error handling method.
 
 See http://docs.python.org/lib/module-exceptions.html
 
 --Gabriel Genellina

Perfect! Just what I was looking for. Thank you! :)

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


Catching a specific IO error

2007-04-24 Thread Tina I
Hi group :)

I have this standard line:

export = open(self.exportFileName , 'w')

'exportFileName' is a full path given by the user. If the user gives an 
illegal path or filename the following exception is raised:
IOError: [Errno 2] No such file or directory: /some/path/file.txt

So at the moment I do this:

try:
export = open(self.exportFileName , 'w')
export.write(Something)
export.close()
except IOError:
# calling an error handling method.

Now, this works but of course it catches every IOError, and I can not 
figure out how to restrict it to only catch the [Errno 2]?

Thanks
Tina

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


Re: Beginner: Formatting text output (PyQt4)

2007-04-18 Thread Tina I
Glen wrote:


 Hello again,  I don't blame anyone for not answering my last post,
 since
 I obviously hadn't spent much time researching, but I've come a little
 ways and have another question.

 How can I better format text output to a QTextEdit object?  I'm
 inserting 5 columns into each row.  When I write the info to a file, it
 looks like the following:

 42: 115 26: 114 35: 112 19: 108 16: 107 45: 107 40:
 106  5: 105 41: 104  2: 103
  9: 102 48: 102 15: 101 22: 101 27: 101
 39: 101 43: 101 10: 100  6:  99 34:  99 32:  98 49:
 98 20:  97 30:  97  8:  96 17:  96 38:  96 12:  95
 14:  95 37:  95
  4:  94 13:  94 44:  94 36:  93  3:  92
 24:  92 28:  92 31:  91 29:  89  7:  88
  1:  87 18:  85 46:  85 33:  84 11:  83
 23:  83 47:  82 25:  80 21:  79 50:  56 52:  39 51:
 38 53:  36 54:  25 55:  18

 When I write the contents of the file to my TextEdit object it comes out
 uneven, something like this:
 42: 11526: 11435: 11219: 10816: 107 45: 10740: 106
 5: 10541: 104 2: 103 9: 10248: 10215: 10122: 101 27:
 101 39: 10143: 10110: 1006:  9934:  99 32:  9849: 98
20:  9730:  978:  96 17:  9638:  9612:  9514: 95
   37:  95 4:  9413:  9444:  9436:  933:  92 24:  92 28:
 9231:  9129:  897:  88
  1:  8718:  8546:  8533:  8411:  83
 23:  8347:  8225:  8021:  7950:  56 52:  3951:  38
 53:  3654:  2555:  18

 What seems to be happening is that the font that pyqt is using is not
 fixed width, so I did this:
  qTxtFormat = QTextCharFormat()
  qTxtFormat.setFontFixedPitch(True)
  ui.textEdit.setCurrentCharFormat(qTxtFormat)

 Also, I tried using the pyqt formatting such as the following:

  qStr = QtCore.QString( QtCore.QString( str(tL2[i][0])
  ).rightJustified(2) + ':' + QtCore.QString( str(tL2[i][1])
  ).rightJustified(4) )
 This still gives me uneven columns.

 Any suggestions?

 Thanks,

 Glen
 
Do you need to use QTextEdit for the output? Sounds like maybe you 
should look at for example the QTableWidget or maybe the QTreeWidget?

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


Re: Append data to a list within a dict

2007-04-15 Thread Tina I
Alex Martelli wrote:
 Tina I [EMAIL PROTECTED] wrote:
...
 He he... at the age of 40 I'm well beyond school work ;)
 
 Why would that be?  My wife's over 40, yet she's a student (currently at
 Stanford -- they were overjoyed to admit her, with lot of life
 experience as well as previous studies, apparently).  She's not taking
 elementary courses on Python (having co-written a book on Python,
 tech-reviewed a few, and having been the first woman coopted as a member
 of the PSF:-), but she _has_ been taken equivalent ones on Java and C++
 (languages she didn't previously know), as well as calculus,
 neurophysiology, and other strange things that are part of the Symbolic
 Systems studies.
 
 Down with ageism!-)
 
 
 Alex
  
It's not really ageism, just how I feel *my self* about going back to 
school. I'm not done learning though, it's just that I can give my self 
the luxury of learning whatever I want, just what I want at the pace 
that I want. And since I happen to like computers that's mostly what I 
concentrate about. Right now I'm hooked on Python, but also messing 
about with PHP and Javascript. Tried some Java but didn't like it... 
Threw out Windows a couple of years ago and have spent quite some time 
learning the ins and outs of Linux.

So even if I probably will never go back to school I'm looking forward 
to many many years learning new and exciting things :)

Tina
(Sorry for the way OT post. I just couldn't stop my own ramble ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append data to a list within a dict

2007-04-14 Thread Tina I
Paul Rubin wrote:
 Tina I [EMAIL PROTECTED] writes:
 ListDict = {
 'one' : ['oneone' , 'onetwo' , 'onethree'],
 'two' : ['twoone' , 'twotwo', 'twothree'],
 'three' : ['threeone' , 'threetwo', threethree']}

 Now I want to append 'twofour' to the list of the 'two' key but I
 can't figure out how to that?
 
 Is this a class exercise?  Hint:
   1) figure out how to access the list of the 'two' key
   2) append 'twofour' to it.
He he... at the age of 40 I'm well beyond school work ;)
But thanks anyway

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


Re: Append data to a list within a dict

2007-04-14 Thread Tina I
Michael Bentley wrote:
 
 On Apr 14, 2007, at 12:39 AM, Tina I wrote:
 
 Say I have the following dictionary:

 ListDict = {
 'one' : ['oneone' , 'onetwo' , 'onethree'],
 'two' : ['twoone' , 'twotwo', 'twothree'],
 'three' : ['threeone' , 'threetwo', threethree']}

 Now I want to append 'twofour' to the list of the 'two' key but I can't
 figure out how to that?
 Some pointers would be greatly appreciated.
 
 ListDict['two'].append('twofour')
 
 But you'll have to insert the missing single quote before threethree 
 first.
 
 hope this helps,
 Michael
Great! Thanks!
And the missing singlequote was just a typo, my actual dictionary is way 
bigger so I just made up this as an example.

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


Append data to a list within a dict

2007-04-13 Thread Tina I
Hello group,

Say I have the following dictionary:

ListDict = {
'one' : ['oneone' , 'onetwo' , 'onethree'],
'two' : ['twoone' , 'twotwo', 'twothree'],
'three' : ['threeone' , 'threetwo', threethree']}

Now I want to append 'twofour' to the list of the 'two' key but I can't 
figure out how to that?
Some pointers would be greatly appreciated.

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __init__.py

2007-03-27 Thread Tina I
Jorgen Grahn wrote:
 On Mon, 26 Mar 2007 08:27:19 +0200, Tina I [EMAIL PROTECTED] wrote:
 Tina I wrote:
 When looking at other peoples code (to learn from it) I keep seeing an 
 empty file named __init__.py. What's the purpose of this?

 Thanks
 Tina
 Duh! Never mind... found it.
 Kinda neat actually :)
 
 /What/ was neat? It's polite in cases like this to explain what the
 answer or solution was.
 
 I have never seen an empty __init__.py, and I'd like to know what its
 purpose could be.
 
 BR,
 /Jorgen
 
Sorry, it was just that it was so easy to find right there in the 
documentation. I had just missed it the first time around. So I kinda 
assumed that since it was spelled out so well in the doc I was asking a 
very stupid question.
But anyway, it can be found here: 
http://www.python.org/doc/2.1.3/tut/node8.html#SECTION00840

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


__init__.py

2007-03-25 Thread Tina I
When looking at other peoples code (to learn from it) I keep seeing an 
empty file named __init__.py. What's the purpose of this?

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __init__.py

2007-03-25 Thread Tina I
Tina I wrote:
 When looking at other peoples code (to learn from it) I keep seeing an 
 empty file named __init__.py. What's the purpose of this?
 
 Thanks
 Tina

Duh! Never mind... found it.
Kinda neat actually :)

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


Re: Need help to learn Python

2007-03-23 Thread Tina I
PythonBiter wrote:
 Hi everyone,
 
 I'm very new in this Group as well Python language. I want to learn
 Python. So could you please advice me, and guide me how can i become
 master in Python !
 
 
 Thanks,
 Partha
 
Lots of great resources for beginners: 
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: difference between urllib2.urlopen and firefox view 'page source'?

2007-03-20 Thread Tina I
cjl wrote:
 Hi.
 
 I am trying to screen scrape some stock data from yahoo, so I am
 trying to use urllib2 to retrieve the html and beautiful soup for the
 parsing.
 
 Maybe (most likely) I am doing something wrong, but when I use
 urllib2.urlopen to fetch a page, and when I view 'page source' of the
 exact same URL in firefox, I am seeing slight differences in the raw
 html.
 
 Do I need to set a browser agent so yahoo thinks urllib2 is firefox?
 Is yahoo detecting that urllib2 doesn't process javascript, and
 passing different data?
 
 -cjl
 
Unless the data you you need depends on the site detecting a specific 
browser you will probably receive a 'cleaner' code that's more easily 
parsed if you don't set a user agent. Usually the browser optimization 
they do is just eye candy, bells and whistles anyway in order to give 
you a more 'pleasing experience'. I doubt that your program will care 
about that ;)

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


Re: getting user id (from an arbitrary sys user)

2007-03-14 Thread Tina I
Gerardo Herzig wrote:
 hi all. What i need to know is if there is some function like 
 os.getuid(), but taking an argument (the username, off course), so i can 
 do getuid('myuser')
 
 Thanks you dudes!
 
 Gerardo
How about simply:

import commands
userid = commands.getoutput(id -u username)

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


Re: PyQt4: Clickable links in QLabel?

2007-03-07 Thread Tina I
David Boddie wrote:
 On Thursday 01 March 2007 09:00, Tina I wrote:
 
 A short and sweet question: Is it possible to put a clickable link in a
 QLabel that will open in the systems default browser?
 
 Yes.
 
 I tried to put in some HTML but it did (of course?) simply display the
 code instead of a link. I also tried to set openExternalLinks 'true' but
 then pyuic4 bombed.
 
 Well, that shouldn't happen. :-(
 
 Can you send a bug report to the PyQt mailing list (assuming you're
 subscribed to it) with the error message or backtrace that you get
 when this happens?
 
 I see that QLabel does not have a html text format but I'm still hoping
 it's possible. I really need a link on my main window form.
 
 If you enclose the HTML with qt and /qt tags, the HTML should be
 displayed properly. Any other matching tags should also work, so you
 could use p and /p if you want.
 
 Setting the label's openExternalLinks property to True should then
 enable what you want. You can try this out by previewing the form in
 Qt Designer.
 
 David
Thanks David,

This is embarrassing... but my PyQt4 was too old *blush*
I can't believe I didn't think of double checking what version I had 
installed. A swift upgrade and it works like a charm :)

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


PyQt4: Clickable links in QLabel?

2007-03-01 Thread Tina I
Hi everyone,

A short and sweet question: Is it possible to put a clickable link in a 
QLabel that will open in the systems default browser?
I tried to put in some HTML but it did (of course?) simply display the 
code instead of a link. I also tried to set openExternalLinks 'true' but 
then pyuic4 bombed.
I see that QLabel does not have a html text format but I'm still hoping 
it's possible. I really need a link on my main window form.

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


HTML to dictionary

2007-02-27 Thread Tina I
Hi everyone,

I have a small, probably trivial even, problem. I have the following HTML:
 b
  METAR:
 /b
 ENBR 270920Z 0KT  FEW018 02/M01 Q1004 NOSIG
 br /
 b
  short-TAF:
 /b
 ENBR 270800Z 270918 VRB05KT  FEW020 SCT040
 br /
 b
  long-TAF:
 /b
 ENBR 271212 VRB05KT  FEW020 BKN030 TEMPO 2012 2000 SNRA VV010 BECMG 2124 
 15012KT
 br /

I need to make this into a dictionary like this:

dictionary = {METAR: : ENBR 270920Z 0KT  FEW018 02/M01 Q1004 
NOSIG , short-TAF: : ENBR 270800Z 270918 VRB05KT  FEW020 SCT040 
, long-Taf: : ENBR 271212 VRB05KT  FEW020 BKN030 TEMPO 2012 2000 
SNRA VV010 BECMG 2124 15012KT}

I have played around with BeautifulSoup but I'm stuck at stripping off 
the tags and chop it up to what I need to put in the dict. If someone 
can offer some hints or example to get me going I would greatly 
appreciate it.

Thanks!
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML to dictionary

2007-02-27 Thread Tina I
Tina I wrote:
 Hi everyone,
 
 I have a small, probably trivial even, problem. I have the following HTML:
 b
  METAR:
 /b
 ENBR 270920Z 0KT  FEW018 02/M01 Q1004 NOSIG
 br /
 b
  short-TAF:
 /b
 ENBR 270800Z 270918 VRB05KT  FEW020 SCT040
 br /
 b
  long-TAF:
 /b
 ENBR 271212 VRB05KT  FEW020 BKN030 TEMPO 2012 2000 SNRA VV010 
 BECMG 2124 15012KT
 br /
 
 I need to make this into a dictionary like this:
 
 dictionary = {METAR: : ENBR 270920Z 0KT  FEW018 02/M01 Q1004 
 NOSIG , short-TAF: : ENBR 270800Z 270918 VRB05KT  FEW020 SCT040 
 , long-Taf: : ENBR 271212 VRB05KT  FEW020 BKN030 TEMPO 2012 2000 
 SNRA VV010 BECMG 2124 15012KT}
 
 I have played around with BeautifulSoup but I'm stuck at stripping off 
 the tags and chop it up to what I need to put in the dict. If someone 
 can offer some hints or example to get me going I would greatly 
 appreciate it.
 
 Thanks!
 Tina
Forgot to mention that the METAR:, short-TAF, and long-TAF is 
always named as such wheras the line of data (ENBR 271212 VRB05KT  
FEW020 BKN030 TEMPO 2012 2000 SNRA VV010 ) is dynamic and can be 
anything...

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


Re: HTML to dictionary

2007-02-27 Thread Tina I
Thanks people, I learned a lot!! :)

I went for Herbert's solution in my application but I explored, and 
learned from, all of them.

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


irclib problems

2007-02-11 Thread Tina I
I'm playing around with the 'irclib' library working with the first 
example at 
http://www.devshed.com/c/a/Python/IRC-on-a-Higher-Level-Concluded/

When copying the example verbatim and running it from a console it works 
flawlessly. It connects to the server, join the channel and sits there 
'forever'...

However, I want to use it in a PyQt application and have done the following.
I have created a module named 'irclibtest.py' that looks like this:

### irclibtest start ###
import irclib
irclib.DEBUG = True

class Conn:
 def __init__(self):
 # Network information
 self.network = '192.x.x.x'
 self.port = 6667
 self.channel = '#test'
 self.nick = 'IRClibt'
 self.name = 'Python Test'

 # Subclass SimpleIRCClient
 class ClientClass ( irclib.SimpleIRCClient ):
 pass

 # Create an instance of ClientClass and connect.
 self.client = ClientClass()
 self.client.connect ( self.network, self.port, self.nick, 
ircname = self.name )
 self.client.connection.join ( self.channel )
##irclibtest end ###

And my main Qt application:

### Main application start ###
#!/usr/bin/python
# -*- coding: utf-8 -*-


import sys, irclib
from PyQt4 import QtGui , QtCore
from tircUI import Ui_MainWindow
from irclibtest import Conn

class TircMain(QtGui.QMainWindow , Conn):
 def __init__(self):
 QtGui.QMainWindow.__init__(self )
 Conn.__init__(self)
 self.ui = Ui_MainWindow()
 self.ui.setupUi(self)

 self.connect(self.ui.sendButton, QtCore.SIGNAL(clicked()), 
self.doSend)

 def doSend(self):
 ''' Just a test to see if I can send to channel'''
 self.client.connection.privmsg('#test' , 'Test text')

if __name__ == __main__:
 app = QtGui.QApplication(sys.argv)
 f = TircMain()
 f.show()
 sys.exit(app.exec_())
### Main application end ##

The problem is that this pings out (PING timeout). As far as I 
understand it rclib.SimpleIRCClient is supposed to handle PING-PONG with 
the server so I don't understand why it does not in my Qt test, but it 
does 'raw'.
I can send to the channel right up to the point it times out by the way.

Anyone know what I'm missing here?

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: interacting with shell - another newbie question

2007-02-10 Thread Tina I
James wrote:
 Hello,
 
 I work in this annoying company where I have to autheticate myself to
 the company firewall every 30-50 minutes in order to access the
 internet.  (I think it's a checkpoint fw).
 
 I have to run telnet what.ever.ip.address 259 then it prompts me
 with userid, then password, then I have to select 1.  Then the
 program closes itself and the internet is enabled.
 
 I would like to automate this process with Python and run it every 30
 miniutes so I don't have to keep typing in these userid/password
 everytime.  How can this be done?  Is there a module I can use to
 interact with the shell? (I'm running linux)
 
 Thank you.
 
 James
 
Sounds like the perfect way to get fired. To be sure though, remember to 
store your password in clear text ;)
However bizarre the security measures seem it's obviously in place to 
make sure it's *you* sitting at the computer. Scripting the 
authentication process is equal to simply removing it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hacking in python

2007-02-10 Thread Tina I
zefciu wrote:
 enes naci wrote:
 i would like to know about hacking in python too whether its illegal or
 not is not the point and anyway it doesn't mean i'm gong to use it.

 
 If you mean hacking as modyfying the code of interpreter of libraries -
 it is perfectly legal, as Python is Open Source.
 
 If you mean hacking as cracking into computer systems, then what's the
 difference if it's with Python or anything else.
 
 If you mean hacking as gaining excellency in programming - then why
 should it be?
 
 Greets
 zefciu
It's really sad. I saw this poor schmuck on Want to be a millionaire 
once. His second question was What is a hacker? I don't remember all 
of the alternatives but two of them was A computer programmer and 
Someone illegally using a computer.
He answered 'computer programmer'... guess what was the 'correct one'.

I guess he was lucky though... it could have been the one million question.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling J from Python

2007-02-08 Thread Tina I
Hendrik van Rooyen wrote:
 
  I am under the impression that Loki had a daughter called Hel ...
 
 - Hendrik
 
Yes. And Hel was the queen of the underworld which was also called 'Hel' 
(Which of course is 'hell', in modern Norwegian : helvete)

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


Re: Newbie Question

2007-02-08 Thread Tina I
azrael wrote:
 but look out for pyqt. there is one thing in the eula i don't like.
 there is written that if you use qtWidgets and they like the
 aplication, you have to give up all your rights of the aplication.
 patent, idea, money everything is gone. i know this is open source,
 but maybe one day i will manage to sell an apliction for big money.

That is not exactly correct. Both PyQt and Qt it self is available under 
two different licenses. The GPL versions require that your applications 
has to be released as free software compatible with the GPL. Development 
of commercial closed source applications require a commercial license.

In reality you are free to sell your application as long as it remain 
free (as in freedom) and open source (some argues this is impossible and 
some argue it's no problem. Decide for your self). By nature a GPL'ed 
application can not be patented or even contain patented code as this 
violates the freedom part of the License.

But you have a point though: Always read the license, terms and 
conditions for the tools you want to use. It can really save you some 
serious trouble.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling J from Python

2007-02-07 Thread Tina I
Gosi wrote:
 On Feb 7, 3:46 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 In [EMAIL PROTECTED], Gosi wrote:
 I like to use J for many things and I think that combining Python and
 J is a hell of a good mixture.
 I was able to follow this sentence up to and including the word hell...  
 :-)

 Ciao,
 Marc 'BlackJack' Rintsch
 
 
 That is a start.
 
 Hell is also what most example start with as in Hello something
 Hell in northern countries is very cold.
 Hell in middle east is very hot.
 I do not know which is your Hell hot or cold.
 Hell o veröld
 
It's also a village in Norway: http://en.wikipedia.org/wiki/Hell,_Norway
:D
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Prefered install method?

2007-01-26 Thread Tina I
Diez B. Roggisch wrote:
 These days, it's setuptools. Google for it. It will let you distribute 
 your application in a convenient way as so-called EGG (basically a 
 ZIP-file), additionally you will get support for installing scripts in 
 /usr/bin or wherever you like, and you have versioning support.
 
 If you plan to release the app publically, it will also handle the 
 upload to the PyPI, the python package index - also known(?) as cheeseshop.
 
 Diez

Great! Obviously exactly what I'm looking for. I already had it 
installed even, and it seem to be quite well documented and noob friendly.

Thanks :)
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Prefered install method?

2007-01-25 Thread Tina I
Another noob question:
I have written my first linux application that might actually be of 
interest to others. Just for fun I also wrote an install script that put 
the files in the common directories for my distro (Debian). That is in 
/usr/local/. (This particular program can be run directly from the 
user's /home but as a learning experience I want to do it the 'coorect' way)

Now, I don't know if that is the way to do it with python applications. 
I also don't know if a custom install script is the norm. I have seen 
some use of makefiles and tried to find something about it but the 
manual for GNUMake really assume you are familiar with/ using C which 
I'm not. I have googled a lot for this but can't really find anything 
aimed for someone just learning programming with Python.

So my question is; What is the preferred/ common way to install a python 
application so it's not really distro specific? And are there any good 
resources on this on the web?

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


PyQt4 strangeness

2007-01-23 Thread Tina I
I'm trying to 'convert' my self from Qt3 to Qt4 (it rocks!) and one 
thing seem strange:
With Qt3 I usually did from qt import *, but this does not seem to 
work with Qt4. I have to use from PyQt4 import QtGui , QtCore and also 
have to use QtCore.something.

Like when connecting a button:

self.connect(self.ui.testButton, QtCore.SIGNAL(clicked()), 
self.doSomething)

Anyone know why this is? Or am I missing something very basic here? (I'm 
still very much a noob I guess)

I'm using the Debian packages by the way.

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 strangeness

2007-01-23 Thread Tina I
Phil Thompson wrote:
 The module structure of PyQt reflects the library structure of Qt. Qt4 has 
 different libraries to Qt3 so PyQt4 has different modules to PyQt3.
 
 The top level PyQt4 module ensures that PyQt3, PyQt4 (and eventually PyQt5) 
 can all be installed side by side in the same site-packages directory.
 
 The style of import statement you use is up to you. All of the PyQt4 examples 
 adopt the style you describe, but you can achieve the equivalent of your 
 current practice by doing the following instead...
 
 from PyQt4.Qt import *
 
 Phil
Ah, I see :)
Thanks for the explanation.

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


PyQt: QListviewItemIterator

2007-01-16 Thread Tina I
Hi,
I'm fairly new to both Python and Qt so please bare with me.

I have a QListView with a number of columns. In order to filter the 
output I iterate using QListViewItemIterator looking for the string 
entered by the user (filterString). Currently I do it this way:


it = QListViewItemIterator(self.authListView)
 try:
 while it:
 item = it.current()
 if item.text(0).contains(filterString) or 
item.text(1).contains(filterString) or item.text(2).contains(filterString):
 item.setVisible(1)
 else:
 item.setVisible(0)
 it +=1
 except AttributeError:
 pass


Basically I iterate through the ListView until it goes beyond the list 
and raise an exception, which I catch. It works but to be honest it 
looks and feels ugly; Do something until it goes wrong

So, question: How can I know I have reached the last item in the QListView?

Thanks
Tina
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt: QListviewItemIterator

2007-01-16 Thread Tina I
David Boddie wrote:
 
 When it.current() returns None. You can rewrite what you already
 have like this:
 
  it = QListViewItemIterator(self.authListView)
  while it.current():
  item = it.current()
  if item.text(0).contains(filterString) or \
 item.text(1).contains(filterString) or \
 item.text(2).contains(filterString):
 
  item.setVisible(1)
  else:
  item.setVisible(0)
  it += 1
 
 If you don't like calling item.current() twice for some reason,
 you could write this:
 
  it = QListViewItemIterator(self.authListView)
  item = it.current()
  while item:
  if item.text(0).contains(filterString) or \
 item.text(1).contains(filterString) or \
 item.text(2).contains(filterString):
 
  item.setVisible(1)
  else:
  item.setVisible(0)
  it += 1
  item = it.current()
 
 David

Ah, of course!
Thanks!!

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