Re: [Tutor] Getting at sqlite schema info from within Python?

2007-06-25 Thread Terry Carroll
On Tue, 26 Jun 2007, John Fouhy wrote:

> On 26/06/07, Terry Carroll <[EMAIL PROTECTED]> wrote:
> >
> > Is there any way of getting to the schema of an sqlite database from
> > within Python? In particular, a list of tables in the DB.
> 
> Try 'select * from sqlite_master'.

You rock.  Thanks.

And, now that I know that trick, googling on sqlite_master leads me to 
http://www.sqlite.org/faq.html#q7 which explains the format.

Honest, I really did spend quite some time reading the sqlite docs and
trying things; somehow I missed the FAQ.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting at sqlite schema info from within Python?

2007-06-25 Thread John Fouhy
On 26/06/07, Terry Carroll <[EMAIL PROTECTED]> wrote:
>
> Is there any way of getting to the schema of an sqlite database from
> within Python? In particular, a list of tables in the DB.

Try 'select * from sqlite_master'.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Getting at sqlite schema info from within Python?

2007-06-25 Thread Terry Carroll

Is there any way of getting to the schema of an sqlite database from 
within Python? In particular, a list of tables in the DB.

>From the sqlite command line, I can use the sqlite 

 .tables

command to get a list of tables in the database; and then the 

 PRAGMA TABLE_INFO(tablename)

to get the information on the various fields in the table.

>From within Python, though, I can't find a way to get the table names.  
If I know the table names, the PRAGMA approach works to get at the field
info; but I can't figure out how to find the table names first.

Trying to use the sqlite .tables command via Python gives me:

>>> c.execute(".tables;")
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.OperationalError: near ".": syntax error

...which makes some sense; it isn't SQL.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Bundle help!

2007-06-25 Thread Reed O'Brien


On Jun 25, 2007, at 9:56 PM, Sara Johnson wrote:

I'm to use the bundle method to append some information to a list.   
I have no idea how to do that!  I have Python for Dummies and I  
think I need Python for Complete Idiots because I am not seeing how  
to do this!!  I have basic C+ knowledge and about 6 programs to  
write (in one month's time!) and I know NOTHING!!  HELP!!!


Sara

8:00? 8:25? 8:40? Find a flick in no time
with theYahoo! Search movie showtime shortcut.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



Sara:

Guessing:
http://numpy.scipy.org/
http://www.danbbs.dk/~kibria/software.html#qpnumpy
close?


But if it is as simple as just adding to a list:
In [2]: L = [1,2,3,4,5,6]

In [3]: L.append(['a','b', 'c'])

In [4]: L.append(7)

In [5]: L
Out[5]: [1, 2, 3, 4, 5, 6, ['a', 'b', 'c'], 7]

HTH
~r
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Bundle help!

2007-06-25 Thread Kent Johnson
Sara Johnson wrote:
> I'm to use the bundle method to append some information to a list.  I 
> have no idea how to do that!

What is the bundle method? What have you tried so far? What are you 
trying to accomplish?

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Bundle help!

2007-06-25 Thread Sara Johnson
I'm to use the bundle method to append some information to a list.  I have no 
idea how to do that!  I have Python for Dummies and I think I need Python for 
Complete Idiots because I am not seeing how to do this!!  I have basic C+ 
knowledge and about 6 programs to write (in one month's time!) and I know 
NOTHING!!  HELP!!!
   
  Sara

 
-
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-06-25 Thread Kent Johnson
Robert Hicks wrote:
> I have a script at work where I have a list of id numbers and I am doing a:
> 
> for line in ehFile:

That is fine

>  for id in line:

I don't know what this is for - line is a string, iterating it will give 
you every character is the line.
>   
> I am then going through that file and finding the line the id is on and 
> printing the next line out. It takes a few seconds to see the output to 
> the screen (the Perl version whips by) which got me to thinking I could 
> be doing it faster (as I want to move it from Perl to Python).
> 
> If you need all the code I can post that tomorrow or I can try any ideas 
> posted to this.

A bit more code would help.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fastest way to iterate through a file

2007-06-25 Thread Robert Hicks
I have a script at work where I have a list of id numbers and I am doing a:

for line in ehFile:
 for id in line:

I am then going through that file and finding the line the id is on and 
printing the next line out. It takes a few seconds to see the output to 
the screen (the Perl version whips by) which got me to thinking I could 
be doing it faster (as I want to move it from Perl to Python).

If you need all the code I can post that tomorrow or I can try any ideas 
posted to this.

Thanks!

Robert

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python port scanner

2007-06-25 Thread János Juhász
Dear dos,

>>hello i am looking into writing a simple python port scanner but i cant 
find
>>any good tutorials online if anyone can help or knows of any tutorials 
that
>>could help it would be great. this would be my first program like this 
so i
>>might need a little extra help

I just recommend to take a look on twisted 
http://www.oreilly.com/catalog/twistedadn/
It is a nice book.

There is an example on how to do it with twisted among the examples in 
chapter 2.


You can read it on safari.

Janos___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python port scanner

2007-06-25 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Well, take a look at the socket module and nonblocking mode.

But truly, it's not a good "first" program, not for Python, not for C.

Andreas

max . wrote:
> hello i am looking into writing a simple python port scanner but i cant
> find
> any good tutorials online if anyone can help or knows of any tutorials that
> could help it would be great. this would be my first program like this so i
> might need a little extra help
> 
> 
> thanks
> 
> 
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGf5mPHJdudm4KnO0RAjM0AKChWMXvTVp1+0ihZTau+A+RLnYzMACg4SJc
B7ypBQx/I9EIwYIfosxjNTI=
=LMoL
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python maintenance taks

2007-06-25 Thread Noufal Ibrahim
Hello everyone,
I seem to recall that there was a site (on the python wiki IIRC) that 
listed relatively simple python bugs (in the actual C code inside the 
interpreter) that needed to be fixed. It was advertised as good starting 
point for novices. I can't seem to find it. Does anyone here have an 
idea of where this is (if it exists)?

Thanks much.


-- 
~noufal
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor