HTTPS request

2007-09-05 Thread ashish
Hi , I want to send HTTPs put request to the server .Can any one help me how to do that . I am using this code import httplib from group import * class HTTPS: def __init__(self,ip,port=443): self.ip=ip self.port=port self.conn = httpl

Re: Calling a dos batch file from python

2007-09-05 Thread n o s p a m p l e a s e
On Sep 4, 5:01 pm, [EMAIL PROTECTED] wrote: > On Sep 4, 8:42 am, n o s p a m p l e a s e <[EMAIL PROTECTED]> > wrote: > > > Suppose I have a batch file called mybatch.bat and I want to run it > > from a python script. How can I call this batch file in python script? > > > Thanx/NSP > > The subproc

Calling a matlab script from python

2007-09-05 Thread n o s p a m p l e a s e
Suppose I have a matlab script mymatlab.m. How can I call this script from a python script? Thanx/NSP -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter(2)

2007-09-05 Thread Eric Brunel
On Tue, 04 Sep 2007 15:42:09 +0200, vijayca <[EMAIL PROTECTED]> wrote: > my python installation is:Active python 2.5.1 > i am using Red Hat Linux > i have the Tkinter module installed but any simple script produces an > error > > script: > from Tkinter import Label > widget = Label(None, text=

Catching gtk.STOCK_SIGNALS

2007-09-05 Thread Kveldulv
Hi all, I made simple GUI with Glade, window and toolbar with one button that calls dialog with stock yes or no buttons. It's loaded with: def callDialog(self, widget): self.wTree = gtk.glade.XML(self.gladefile, "yesorno") self.dlg = self.wTree.get_widget("yesorno")

Re: Calling a matlab script from python

2007-09-05 Thread A.T.Hofkamp
On 2007-09-05, n o s p a m p l e a s e <[EMAIL PROTECTED]> wrote: > Suppose I have a matlab script mymatlab.m. How can I call this script > from a python script? use the mlabwrap module Albert -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling a dos batch file from python

2007-09-05 Thread Wesley Brooks
I looked into this a little while ago so I could get the MAC address of a machine while on linux or windows. Here's a simplified version that just does the windows side; self.macMatch = re.compile(r"((\w\w[:-]){5}\w\w)") data = os.popen("ipconfig /all", 'r') text = data.read() tup = self.macMatch.

Re: Parse or Pass?

2007-09-05 Thread A.T.Hofkamp
On 2007-09-05, Martin P. Hellwig <[EMAIL PROTECTED]> wrote: > Martin v. Löwis wrote: > Eingeben = Input: (A bit of) data from outside the function > Ausgeben = Output: (A bit of) data to display, network > connection or file > Zurückgeben = Return: (altered)(bits of) data (from Input) > to Out

Re: Printing lists in columns

2007-09-05 Thread cjt22
Thanks guys, I really appreciate it. I have never used google groups before and am so impressed with how helpful you all are. It is also lovely that none of you mock my little knowledge of Python but just want to improve it. I have another question in relation to the izip_longest function (I persu

Re: Undeterministic strxfrm?

2007-09-05 Thread Tuomas
Gabriel Genellina wrote: > I think it's not in the issue tracker - see > http://xforce.iss.net/xforce/xfdb/34060 > The fix is already in 2.5.1 > http://www.python.org/download/releases/2.5.1/NEWS.txt Thanks Gabriel, I'll try Python 2.5.1. >> Reading the rev 54669 it seems to me, that the bug

Re: Printing lists in columns

2007-09-05 Thread Amit Khemka
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thanks guys, I really appreciate it. I have never used google groups > before and am so impressed with how helpful you all are. It is also lovely > that none of you mock my little knowledge of Python but just want to > improve it. And we ar

Accessing Module variables from another Module

2007-09-05 Thread cjt22
Hi I am new to Python (I have come from a large background of Java) and wondered if someone could explain to me how I can access variables stored in my main module to other functions within other modules called from this module for example file: main.py from Storage import store from Initialise

RE: Printing lists in columns

2007-09-05 Thread Ryan Ginstrom
> On Behalf Of [EMAIL PROTECTED] > bo, daf, da > pres, ppar, xppc > magnjklep, *, dsa > *, *, nbi > > But I want it justified, i.e: > > bo , daf, da > pres , ppar, xppc > magnjklep,*, dsa > *,*, nbi Once you have a nice rectangular list of lists, you might want to

Multi Heritage with slots

2007-09-05 Thread Alexandre Badez
Hye, I'm developing a little app, and I want to make multi heritage. My problem is that my both parent do have __slots__ define. So I've got something like: class foo(object): __slots__ = ['a', 'b'] pass class foo2(object): __slots__ = ['c', 'd'] pass class crash(foo, foo2):

2 python questions!

2007-09-05 Thread resist_think
Hi python community! First question has to do with threading support. There is the following simple case: I have a dictionnary that gets it's values -which are url's-from a function. Sort of dictionnary['1'] = "http://www.google.com"; dictionnary['2'] = "http://www.python.com"; I need to

decorator and signal handler

2007-09-05 Thread stalex
Hi all, I wrote the following code since I want to try using a decorator to install signal handler: ## The test.py script # import os import time import signal def sigHandler(sid): def handler(f): signal.signal(sid, f) return f return handler class Test(o

creating really big lists

2007-09-05 Thread Dr Mephesto
Hi! I would like to create a pretty big list of lists; a list 3,000,000 long, each entry containing 5 empty lists. My application will append data each of the 5 sublists, so they will be of varying lengths (so no arrays!). Does anyone know the most efficient way to do this? I have tried: list =

Re: Python is overtaking Perl

2007-09-05 Thread Bryan Olson
The expression "faint praise" comes to mind. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list

Re: REGULAR EXPRESSION

2007-09-05 Thread Ricardo Aráoz
AniNair wrote: > On Sep 5, 4:35 am, Ricardo Aráoz <[EMAIL PROTECTED]> wrote: >> Steve Holden wrote: >>> AniNair wrote: hi.. I am trying to match '+ %&/-' etc using regular expression in expressions like 879+34343. I tried \W+ but it matches only in the beginning of the string Plz

Re: creating really big lists

2007-09-05 Thread Paul Rudin
Dr Mephesto <[EMAIL PROTECTED]> writes: > Hi! > > I would like to create a pretty big list of lists; a list 3,000,000 > long, each entry containing 5 empty lists. My application will append > data each of the 5 sublists, so they will be of varying lengths (so no > arrays!). > > Does anyone know th

concise code (beginner)

2007-09-05 Thread bambam
I have about 30 pages (10 * 3 pages each) of code like this (following). Can anyone suggest a more compact way to code the exception handling? If there is an exception, I need to continue the loop, and continue the list. Steve. --- for dev in devs try:

Re: doctest and decorators

2007-09-05 Thread Daniel Larsson
The __module__ attribute is set, but the problem is the test in doctest.py(DocTestFinder._from_module) ... elif inspect.isfunction(object): return module.__dict__ is object.func_globals elif inspect.isclass(object): return module.__name__ == object._

Re: concise code (beginner)

2007-09-05 Thread Diez B. Roggisch
bambam wrote: > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > > --- >

Re: creating really big lists

2007-09-05 Thread Diez B. Roggisch
Paul Rudin wrote: > Dr Mephesto <[EMAIL PROTECTED]> writes: > >> Hi! >> >> I would like to create a pretty big list of lists; a list 3,000,000 >> long, each entry containing 5 empty lists. My application will append >> data each of the 5 sublists, so they will be of varying lengths (so no >> arra

Re: concise code (beginner)

2007-09-05 Thread Wesley Brooks
Try adding all the functions into a list such as; funcList = [dev.read1, dev.read2, dev.read3] for func in funcList: for dev in devs: try: func() except: print exception remove dev from devs Wes. On 05/09/07, bambam <[EMAIL PROTECTED]> wrote: >

Re: concise code (beginner)

2007-09-05 Thread Daniel Larsson
def process_devs(devs, fun): for dev in devs: try: fun(dev) except: print exception remove dev from devs return devs process_devs(devs, lambda d: d.read1()) process_devs(devs, lambda d: d.read2()) ... On 9/5/07, bambam <[EMAIL PROTECT

Re: concise code (beginner)

2007-09-05 Thread Francesco Guerrieri
On 9/5/07, bambam <[EMAIL PROTECTED]> wrote: > > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > >

Re: concise code (beginner)

2007-09-05 Thread Wesley Brooks
Sorry, just seen a mistake in my code, however Diez beat me to what I was actually thinking! Wes On 05/09/07, Wesley Brooks <[EMAIL PROTECTED]> wrote: > Try adding all the functions into a list such as; > > funcList = [dev.read1, dev.read2, dev.read3] > > for func in funcList: >for dev in dev

Re: concise code (beginner)

2007-09-05 Thread Bruno Desthuilliers
bambam a écrit : > I have about 30 pages (10 * 3 pages each) of code like this > (following). Can anyone suggest a more compact way to > code the exception handling? If there is an exception, I need > to continue the loop, and continue the list. > > Steve. > > ---

Re: decorator and signal handler

2007-09-05 Thread Michele Simionato
On Sep 5, 11:39 am, stalex <[EMAIL PROTECTED]> wrote: > Hi all, > > I wrote the following code since I want to try using a decorator to > install signal handler: I do have a decorator for exactly that purpose in my code. Here it is: def on(sig): ''' A factory of decorators for signal hand

Re: creating really big lists

2007-09-05 Thread Bryan Olson
Paul Rudin wrote: > Dr writes: >> I would like to create a pretty big list of lists; a list 3,000,000 >> long, each entry containing 5 empty lists. My application will append >> data each of the 5 sublists, so they will be of varying lengths (so no >> arrays!). >> >> Does anyone know the most effic

Re: creating really big lists

2007-09-05 Thread Paul Rudin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > Paul Rudin wrote: > >> Dr Mephesto <[EMAIL PROTECTED]> writes: >> >>> Hi! >>> >>> I would like to create a pretty big list of lists; a list 3,000,000 >>> long, each entry containing 5 empty lists. My application will append >>> data each of the 5 s

Re: decorator and signal handler

2007-09-05 Thread Daniel Larsson
On 9/5/07, stalex <[EMAIL PROTECTED]> wrote: > > Hi all, > > I wrote the following code since I want to try using a decorator to > install signal handler: > > ## The test.py script > # > import os > import time > import signal > > def sigHandler(sid): > def handler(f): >

Re: doctest and decorators

2007-09-05 Thread Michele Simionato
On 9/5/07, Daniel Larsson <[EMAIL PROTECTED]> wrote: > Here's my two files again: > > # decorator.py > import functools > > def simplelog(f): > @functools.wraps(f) > def new_f(*args, **kwds): > print "Wrapper calling func" > return f(*args, **kwds) > return new_

Re: creating really big lists

2007-09-05 Thread Dr Mephesto
yep, thats why I'm asking :) On Sep 5, 12:22 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Paul Rudin wrote: > > Dr Mephesto <[EMAIL PROTECTED]> writes: > > >> Hi! > > >> I would like to create a pretty big list of lists; a list 3,000,000 > >> long, each entry containing 5 empty lists. My ap

Re: Multi Heritage with slots

2007-09-05 Thread Eric Brunel
On Wed, 05 Sep 2007 11:01:56 +0200, Alexandre Badez <[EMAIL PROTECTED]> wrote: > Hye, > > I'm developing a little app, and I want to make multi heritage. > My problem is that my both parent do have __slots__ define. > > So I've got something like: > > class foo(object): > __slots__ = ['a', '

Wanted: safe codec for filenames

2007-09-05 Thread Torsten Bronger
Hallöchen! I'd like to map general unicode strings to safe filename. I tried punycode but it is case-sensitive, which Windows is not. Thus, "Hallo" and "hallo" are mapped to "Hallo-" and "hallo-", however, I need uppercase Latin letters being encoded, too, and the encoding must contain only lowe

Re: Printing lists in columns

2007-09-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Thanks guys, I really appreciate it. I have never used google groups > before Actually, comp.lang.python is a usenet newsgroup, not a google group. Google only gives you a web fronted (and archives...) for that group. I personnaly access it with my MUA. > and am so

Looping through File Question

2007-09-05 Thread planetmatt
I am a Python beginner. I am trying to loop through a CSV file which I can do. What I want to change though is for the loop to start at row 2 in the file thus excluding column headers. At present I am using this statement to initiate a loop though the records: for line in f.readlines(): How do

Re: Looping through File Question

2007-09-05 Thread Francesco Guerrieri
On 9/5/07, planetmatt <[EMAIL PROTECTED]> wrote: > > I am a Python beginner. I am trying to loop through a CSV file which > I can do. What I want to change though is for the loop to start at > row 2 in the file thus excluding column headers. > > At present I am using this statement to initiate a

Re: Looping through File Question

2007-09-05 Thread vijayca
On Sep 5, 3:58 pm, planetmatt <[EMAIL PROTECTED]> wrote: > I am a Python beginner. I am trying to loop through a CSV file which > I can do. What I want to change though is for the loop to start at > row 2 in the file thus excluding column headers. > > At present I am using this statement to initi

Re: Looping through File Question

2007-09-05 Thread Amit Khemka
On 9/5/07, Francesco Guerrieri <[EMAIL PROTECTED]> wrote: > On 9/5/07, planetmatt <[EMAIL PROTECTED]> wrote: > > I am a Python beginner. I am trying to loop through a CSV file which > > I can do. What I want to change though is for the loop to start at > > row 2 in the file thus excluding column

Re: So what exactly is a complex number?

2007-09-05 Thread Grzegorz Słodkowicz
>> In fact, a proper vector in physics has 4 features: point of >> application, magnitude, direction and sense. >> > > so whats the "point of application" of the sum of two vectors? Do > tell. I believe vectors can only be added if they have the same point of application. The result is then

Re: Looping through File Question

2007-09-05 Thread John Machin
On Sep 5, 8:58 pm, planetmatt <[EMAIL PROTECTED]> wrote: > I am a Python beginner. I am trying to loop through a CSV file which > I can do. What I want to change though is for the loop to start at > row 2 in the file thus excluding column headers. > > At present I am using this statement to initi

Re: Accessing Module variables from another Module

2007-09-05 Thread Daniel Larsson
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi > > I am new to Python (I have come from a large background of Java) and > wondered if someone could explain to me how I can access variables > stored in my main module to other functions within other modules > called > from this module

Re: 2 python questions!

2007-09-05 Thread Christof Winter
[EMAIL PROTECTED] wrote: [...] > Now the second question has to do with images retrieval and > manipulation. Which libraries do you propose to work with to > retrieve and resize images from the web? urllib.urlretrieve() and Python Imaging Library (PIL) -- http://mail.python.org/mailman/listin

Re: FCGI app reloading on every request

2007-09-05 Thread Sion Arrowsmith
John Nagle <[EMAIL PROTECTED]> wrote: >Tried putting this in the .htaccess file: > > >SetHandler fcgid-script >Options ExecCGI >allow from all > > > >ErrorDocument 403 "File type not supported." > > > Even with that, a ".foo" file gets executed as a CGI script, >and so does a ".fcgi" file.

Re: So what exactly is a complex number?

2007-09-05 Thread Boris Borcic
Roy Smith wrote: > Boris Borcic <[EMAIL PROTECTED]> wrote: >> Complex numbers are like a subclass of real numbers > > I wouldn't use the term "subclass". Really you should name yourself as the author when you butcher someone else's prose to such a degree. Suppose I had written "Complex numbers

Help me understand this script

2007-09-05 Thread Ryan J Nauman
Can someone help me understand this script please? I understand everything except for the anagram function. Could you break it down into more than 1 line of code for me or explain it? (I understand WHAT it does but HOW?) Thanks. Script >> ### # SCRABBLE.PY # # purpose: # find usable "bi

关于用urllib post消息的问题。

2007-09-05 Thread liangxuliang79
想从www.mmmppp333.com下载本书,http://ishare.iask.sina.com.cn/cgi-bin/ fileid.cgi?fileid=844050 但是我post fileid=844050过去后, 当你post东西过去后,fileid=844050,然后server会回复回来header,header中的local还是location忘记 了,中的信息是一个指向另外的链接,这个链接就是mp3的实际地址,但是我试了几次,local中的信息不是mp3的地址,还是我刚刚发的地址,不知道 为什么。也不知道我哪里出错了。 而且我跟了一下python中urllib的信

Re: So what exactly is a complex number?

2007-09-05 Thread Boris Borcic
Paul Rubin wrote: > Also, for > example, the derivative of a complex valued function means something > considerably stronger than the derivative of a real valued function. I vaguely remember (it has been decades) an amazingly beautiful russian doll system of four of five theorems, the first hypot

Re: Accessing Module variables from another Module

2007-09-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hi > > I am new to Python (I have come from a large background of Java) and > wondered if someone could explain to me how I can access variables > stored in my main module to other functions within other modules > called > from this module > (snip code) > I am curren

Re: Multi Heritage with slots

2007-09-05 Thread Alexandre Badez
On Sep 5, 12:42 pm, "Eric Brunel" <[EMAIL PROTECTED]> wrote: > Seehttp://mail.python.org/pipermail/python-list/2006-December/418768.html > > Basically, the general advice you're likely to get here is: don't use > __slots__, or at least don't use __slots__ with inheritance. > > BTW, what are you try

Re: Looping through File Question

2007-09-05 Thread planetmatt
On 5 Sep, 12:34, John Machin <[EMAIL PROTECTED]> wrote: > On Sep 5, 8:58 pm, planetmatt <[EMAIL PROTECTED]> wrote: > > > I am a Python beginner. I am trying to loop through a CSV file which > > I can do. What I want to change though is for the loop to start at > > row 2 in the file thus excluding

threads

2007-09-05 Thread vijayca
i have written a script that spawns some threads all run in parallel now i need to stop all the threads once i press a key(example: "\n") how to do it... -- http://mail.python.org/mailman/listinfo/python-list

Re: creating really big lists

2007-09-05 Thread Aahz
In article <[EMAIL PROTECTED]>, Dr Mephesto <[EMAIL PROTECTED]> wrote: > >I would like to create a pretty big list of lists; a list 3,000,000 >long, each entry containing 5 empty lists. My application will append >data each of the 5 sublists, so they will be of varying lengths (so no >arrays!). W

Re: Calling a matlab script from python

2007-09-05 Thread Alexander Schmolck
n o s p a m p l e a s e <[EMAIL PROTECTED]> writes: > Suppose I have a matlab script mymatlab.m. How can I call this script > from a python script? You could use . 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi Heritage with slots

2007-09-05 Thread Simon Brunning
On 9/5/07, Alexandre Badez <[EMAIL PROTECTED]> wrote: > I use __slots__ not for memory optimization nor doing java. > I use __slots__ because my class are used by other lib, and in the > past, some of them misspell some attributes and involved a very > annoying comportment of the global application

StringIO MySQL data blob Image problem

2007-09-05 Thread dimitri pater
Hi, I am trying to insert an image, which is stored as a blob in MySQL, into a table using Reportlab. I have tried this: from StringIO import StringIO cfoto = StringIO(result[0][1]) # where result[0][1] is the 'blob' cfoto.seek(0) foto=cfoto.getvalue But when I do: print foto, I see something si

Re: Accessing Module variables from another Module

2007-09-05 Thread cjt22
On Sep 5, 1:22 pm, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > > Hi > > > I am new to Python (I have come from a large background of Java) and > > wondered if someone could explain to me how I can access variables > > stored in my main module to other functions within other module

Re: Multi Heritage with slots

2007-09-05 Thread Michele Simionato
On Sep 5, 2:52 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > On 9/5/07, Alexandre Badez <[EMAIL PROTECTED]> wrote: > > > I use __slots__ not for memory optimization nor doing java. > > I use __slots__ because my class are used by other lib, and in the > > past, some of them misspell some attrib

Re: threads

2007-09-05 Thread Diez B. Roggisch
vijayca wrote: > i have written a script that spawns some threads > all run in parallel > now i need to stop all the threads once i press a key(example: "\n") > how to do it... That's a FAQ. Search this NG/ML for exhaustive discussions. The quick answer is: - you can't stop externally

handling modules in packages

2007-09-05 Thread Tommy Grav
Hi, I am working on a package that contains a number of different modules: > ls pyAstro __init__.py constants.py conversion.py observation.py orbit.py transformation.py however, I find that several of the modules have the same import statements: orbit.py: import numpy import constants impo

Re: Looping through File Question

2007-09-05 Thread John Machin
On Sep 5, 10:26 pm, planetmatt <[EMAIL PROTECTED]> wrote: > On 5 Sep, 12:34, John Machin <[EMAIL PROTECTED]> wrote: > > > > > On Sep 5, 8:58 pm, planetmatt <[EMAIL PROTECTED]> wrote: > > > > I am a Python beginner. I am trying to loop through a CSV file which > > > I can do. What I want to change

Re: StringIO MySQL data blob Image problem

2007-09-05 Thread Tim Golden
dimitri pater wrote: I am trying to insert an image, which is stored as a blob in MySQL, into a table using Reportlab. [... snip stuff involving StringIO and getvalue / tostring etc. ...] This is also the string I see in the table, in stead of the actual image. [.. snip more stuff ...] th

Re: creating really big lists

2007-09-05 Thread John Machin
On Sep 5, 7:50 pm, Dr Mephesto <[EMAIL PROTECTED]> wrote: > Hi! > > I would like to create a pretty big list of lists; a list 3,000,000 > long, each entry containing 5 empty lists. My application will append > data each of the 5 sublists, so they will be of varying lengths (so no > arrays!). Will

Re: creating really big lists

2007-09-05 Thread Hrvoje Niksic
Dr Mephesto <[EMAIL PROTECTED]> writes: > I would like to create a pretty big list of lists; a list 3,000,000 > long, each entry containing 5 empty lists. My application will > append data each of the 5 sublists, so they will be of varying > lengths (so no arrays!). > > Does anyone know the most e

Re: Help me understand this script

2007-09-05 Thread Gerardo Herzig
Ryan J Nauman wrote: >Can someone help me understand this script please? >I understand everything except for the anagram function. Could you break >it down into more than 1 line of code for me or explain it? (I understand >WHAT it does but HOW?) Thanks. > >Script >> > >### ># SCRABBLE.PY ># >#

python exec behaves inconsistent with respect to module imports

2007-09-05 Thread [EMAIL PROTECTED]
Hello I am completely puzzled why the following exec code does not work: mycode = "import math\ndef f(y):\nprint math.floor(y)\nf(3.14)" def execute(): exec mycode execute() I get the error: [EMAIL PROTECTED]:/opt/qbase# python error1.py Traceback (most recent call last): File "error

Re: Accessing Module variables from another Module

2007-09-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Sep 5, 1:22 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] a écrit : >> >>> Hi >>> I am new to Python (I have come from a large background of Java) and >>> wondered if someone could explain to me how I can access variables >>> stored in my m

Re: Multi Heritage with slots

2007-09-05 Thread Alexandre Badez
On Sep 5, 2:56 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Sep 5, 2:52 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > > > On 9/5/07, Alexandre Badez <[EMAIL PROTECTED]> wrote: > > > > I use __slots__ not for memory optimization nor doing java. > > > I use __slots__ because my class are

Checking if elements are empty

2007-09-05 Thread Doran, Harold
Dear list: Suppose I have a string as follows x = ' \t'ff' I can split this up as y = x.split('\t') Which gives [ ' ', 'ff'] len(y) 2 Is there a way to check if the first element of y is null? -- http://mail.python.org/mailman/listinfo/python-list

Re: handling modules in packages

2007-09-05 Thread Steve Holden
Tommy Grav wrote: > Hi, > >I am working on a package that contains a number of > different modules: > > > ls pyAstro > __init__.py > constants.py > conversion.py > observation.py > orbit.py > transformation.py > > however, I find that several of the modules have the > same import statements

Re: handling modules in packages

2007-09-05 Thread Diez B. Roggisch
Tommy Grav wrote: > Hi, > >I am working on a package that contains a number of > different modules: > > > ls pyAstro > __init__.py > constants.py > conversion.py > observation.py > orbit.py > transformation.py > > however, I find that several of the modules have the > same import statement

Re: python exec behaves inconsistent with respect to module imports

2007-09-05 Thread Daniel Larsson
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello > > I am completely puzzled why the following exec code does not work: > > mycode = "import math\ndef f(y):\nprint math.floor(y)\nf(3.14)" > def execute(): > exec mycode > execute() > > > I get the error: > > [EMAIL PROTECTED

Re: handling modules in packages

2007-09-05 Thread Tommy Grav
>> > The simplest thing to do would be to have PyAstro.__init__.py > import all > the sub-modules, and define __all__ as the set of names that the > package > should inject into importing modules. > > Then you could write (for example) > > from PyAstro import numpy, constants, conversion, obsrv

Re: handling modules in packages

2007-09-05 Thread Daniel Larsson
On 9/5/07, Tommy Grav <[EMAIL PROTECTED]> wrote: > > >> > > The simplest thing to do would be to have PyAstro.__init__.py > > import all > > the sub-modules, and define __all__ as the set of names that the > > package > > should inject into importing modules. > > > > Then you could write (for examp

Re: python exec behaves inconsistent with respect to module imports

2007-09-05 Thread Peter Otten
Am Wed, 05 Sep 2007 13:12:24 + schrieb [EMAIL PROTECTED]: > I am completely puzzled why the following exec code does not work: > > mycode = "import math\ndef f(y):\nprint math.floor(y)\nf(3.14)" > def execute(): > exec mycode > execute() > > > I get the error: > > [EMAIL PROTECTED]

Re: Checking if elements are empty

2007-09-05 Thread Steve Holden
Doran, Harold wrote: > Dear list: > > Suppose I have a string as follows > > x = ' \t'ff' > >>> x = ' \t'ff' File "", line 1 x = ' \t'ff' ^ SyntaxError: invalid syntax >>> I presume you meant x = ' \t\'ff' > I can split this up as > > y = x.split('\t') > > Which

PythonAlley.com

2007-09-05 Thread Shawn Milochik
I bought the domain PythonAlley.com (and PerlAlley.com and RubyAlley.com) not too long ago. I had the inspiration to make some kind of community site thing, but never did get around to it. Does anyone have any ideas as to what a wonderful use for PythonAlley.com would be? I'd really like to do som

Re: So what exactly is a complex number?

2007-09-05 Thread El Pitonero
On Sep 1, 3:54 am, Grzegorz S odkowicz <[EMAIL PROTECTED]> wrote: > > You're mixing definition with application. You didn't say a word about > what complex numbers are, not a word about the imaginary unit, where > does it come from, why is it 'imaginary' etc. > ... > I'd also like to see a three-

Re: Checking if elements are empty

2007-09-05 Thread Chris Mellon
On 9/5/07, Steve Holden <[EMAIL PROTECTED]> wrote: > Doran, Harold wrote: > > > > Is there a way to check if the first element of y is null? > > > > len(y[0]) == 0 > > would be the obvious way, assuming "null" means "the null string". > Better spelled as if y[0]: -- http://mail.python.org/mailm

Re: Checking if elements are empty

2007-09-05 Thread Daniel Larsson
On 9/5/07, Chris Mellon <[EMAIL PROTECTED]> wrote: > > On 9/5/07, Steve Holden <[EMAIL PROTECTED]> wrote: > > Doran, Harold wrote: > > > > > > > Is there a way to check if the first element of y is null? > > > > > > > len(y[0]) == 0 > > > > would be the obvious way, assuming "null" means "the null

Re: handling modules in packages

2007-09-05 Thread Bruno Desthuilliers
Tommy Grav a écrit : (snip) > > So am I understanding it right that a second import numpy statement > in a different module (and thus a different namespace) just results in > a binding to the already existing numpy "object"? Yes. And FWIW, you can drop the quotes around the word 'object', becaus

Re: python exec behaves inconsistent with respect to module imports

2007-09-05 Thread [EMAIL PROTECTED]
Hi Thank you for the explanation It seems that python behaves different for variables created in the toplevel namespace, versus deeper namespaces. CODE: def g(): a=2 print "a in LOC:",locals().has_key('a') print "a in GLO:",globals().has_key('a') def f(): print "a in LOC:",locals().

Re: FCGI app reloading on every request - solved

2007-09-05 Thread John Nagle
Sion Arrowsmith wrote: > John Nagle <[EMAIL PROTECTED]> wrote: > >> Tried putting this in the .htaccess file: >> >> >>SetHandler fcgid-script >>Options ExecCGI >>allow from all >> >> >> >>ErrorDocument 403 "File type not supported." >> >> >>Even with that, a ".foo" file gets executed as a C

Re: Noob: What is a slot? Me trying to understand another's code

2007-09-05 Thread Marc 'BlackJack' Rintsch
On Tue, 04 Sep 2007 13:03:16 -0500, Carnell, James E wrote: > I am thinking about purchasing a book, but wanted to make sure I could > get through the code that implements what the book is about (Artificial > Intelligence a Modern Approach). Anyway, I'm not a very good programmer > and OOP is stil

ZSI sample and issues with the WSDL

2007-09-05 Thread David Ross
First two appologies, this is probably not a Python question, more SOAP. And second, there is every possibilty I am terminally confused having looked at this for two days now. What I want is to create a Python SOAP server. I am using the sample which comes with ZSI, namely the Echo.wsdl and assoc

Re: PythonAlley.com

2007-09-05 Thread O.R.Senthil Kumaran
* Shawn Milochik <[EMAIL PROTECTED]> [2007-09-05 10:27:08]: > I bought the domain PythonAlley.com (and PerlAlley.com and > > Does anyone have any ideas as to what a wonderful use for > PythonAlley.com would be? I'd really like to do something with at If "you" don't have an idea, most likely other

Re: Checking if elements are empty

2007-09-05 Thread O.R.Senthil Kumaran
> Doran, Harold wrote: > > I presume you meant > > x = ' \t\'ff' > > > > Is there a way to check if the first element of y is null? > > You can use startswith() method of string objects. if x.startswith(' '): print True -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http:/

sqlite3.OperationalError: Could not decode to UTF-8 column

2007-09-05 Thread Filipe Sousa
Hi I'm trying to use sqlite with python 2.5 but I have this problem: Traceback (most recent call last): File "converter.py", line 13, in c_old.execute('select id_aluno, nome from aluno') sqlite3.OperationalError: Could not decode to UTF-8 column 'nome' with text 'Ana Margarida Fernandes

Text processing and file creation

2007-09-05 Thread [EMAIL PROTECTED]
I have a text source file of about 20.000 lines. >From this file, I like to write the first 5 lines to a new file. Close that file, grab the next 5 lines write these to a new file... grabbing 5 lines and creating new files until processing of all 20.000 lines is done. Is there an efficient way to d

Re: PythonAlley.com

2007-09-05 Thread Shawn Milochik
On 9/5/07, O.R.Senthil Kumaran <[EMAIL PROTECTED]> wrote: > * Shawn Milochik <[EMAIL PROTECTED]> [2007-09-05 10:27:08]: > > I bought the domain PythonAlley.com (and PerlAlley.com and > > > > Does anyone have any ideas as to what a wonderful use for > > PythonAlley.com would be? I'd really like to d

Re: REGULAR EXPRESSION

2007-09-05 Thread Shawn Milochik
> Hi.. Thanks alot for finding time to help a beginner like me. What I > am trying to do is validate the input i get. I just want to take > numbers and numbers only. So if the input is 23+1 or 2/3 or 9-0 or > 7/0 , I want to find it using reg exp. I know there are other ways to > do this... but i t

Re: Text processing and file creation

2007-09-05 Thread kyosohma
On Sep 5, 11:13 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have a text source file of about 20.000 lines.>From this file, I like to > write the first 5 lines to a new file. Close > > that file, grab the next 5 lines write these to a new file... grabbing > 5 lines and creating new files

Re: Text processing and file creation

2007-09-05 Thread Arnau Sanchez
[EMAIL PROTECTED] escribió: > I have a text source file of about 20.000 lines. >>From this file, I like to write the first 5 lines to a new file. Close > that file, grab the next 5 lines write these to a new file... grabbing > 5 lines and creating new files until processing of all 20.000 lines is

Re: sqlite3.OperationalError: Could not decode to UTF-8 column

2007-09-05 Thread Carsten Haese
On Wed, 2007-09-05 at 16:40 +0100, Filipe Sousa wrote: > Hi > > I'm trying to use sqlite with python 2.5 but I have this problem: > > Traceback (most recent call last): >File "converter.py", line 13, in > c_old.execute('select id_aluno, nome from aluno') > sqlite3.OperationalError: Coul

Re: python exec behaves inconsistent with respect to module imports

2007-09-05 Thread Peter Otten
Am Wed, 05 Sep 2007 14:45:11 + schrieb [EMAIL PROTECTED]: > So now get back to my exec code in the previous post. > The exec applies a mixture of both rules > 1. The exec looks at its namespace to apply the rule for globals(). > Since I'm not at top-level, variables are not auto-populated in t

Re: Text processing and file creation

2007-09-05 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I would use a counter in a for loop using the readline method to > iterate over the 20,000 line file. file objects are iterables themselves, so there's no need to do that by using a method. > Reset the counter every 5 lines/ iterations and close the file. I'd use a

Re: Text processing and file creation

2007-09-05 Thread Shawn Milochik
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I have a text source file of about 20.000 lines. > >From this file, I like to write the first 5 lines to a new file. Close > that file, grab the next 5 lines write these to a new file... grabbing > 5 lines and creating new files until proces

  1   2   >