Searching for files


Hi

I have this code:
Import glob
For files in glob.glob('*.txt')
To search current dir for all txt files. But i also want to search for .ini files so i was thinking:
For files in glob.glob('*.txt, *.ini')
I know that dont work but you get the idea So any ideas how i can search for both .txt .ini files in current dir


Thanx
Posted On: Friday 28th of December 2012 05:27:36 AM Total Views:  224
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




complex representation

From the nothing-is-so-trivial-it's-not-worth-a-usenet-post file: Shouldn't the default representation of complex numbers be like that of floats That is, have a decimal point >>> 1 1 >>> 1.0 1.0 >>> 1j 1j >>> 1.0j 1j >>> 1.0+1.0j (1+1j) In the relevant bit of floatobject.c, there's a comment explaining that 1.0 isn't accidental: /* Subroutine for float_repr and float_print. We want float numbers to be recognizable as such, i.e., they should contain a decimal point or an exponent. However, %g may print the number as an integer; in such cases, we append ".0" to the string. */ ISTM the same reasoning applies equally to complex numbers. My interest arose because of what I think is a bug in pypy's complex printing: Python 2.4.1 (pypy 1.0.0 build 56124) on linux2 Type "help", "copyright", "credits" or "license" for more information. ``RPython: we use it so you don't have to'' >>>> (1.1+1.1j)**200 (240733537691613523198532543387690598400L+236495565429619338248192Lj) This strangeness comes about because a hack used to recover cpython's behaviour fails at large values. (x.real == floor(x.real), so it decides the value's an integer, and returns the repr of int(x.real).) It's trivial to fix but I think cpython's behaviour is slightly odd here, and the real and imaginary parts of the complex repr should be identical to those of the underlying floats. Or is there some reason I'm missing that things are the way they are
VIEWS ON THIS POST

153

Posted on:

Wednesday 7th November 2012
View Replies!

Re: passing arguments with ampersands

En Sat, 18 Aug 2007 09:24:35 -0300, SHY escribi: > theres no special portion of code, just the one that handles filenames > with > spaces. > the problem is that when i associate a file extension to my application > and > i open it, the filename is not quoted before passed as an arguement. i > dont > know if its the problem of windows or something, or it was just my fault > when i incorrectly associated the extension. How did you associate it Usually the registry entries are: HKCR\.ext = filetype HKCR\filetype = File Description HKCR\filetype\shell\open\command = "path\to\your\program" "%1" (Note the double quotes around %1) Get it right at the registry, and forget all that trickery joining sys.argv parts -- Gabriel Genellina
VIEWS ON THIS POST

175

Posted on:

Wednesday 7th November 2012
View Replies!

ANN: Vampire 1.7 is now available.

Vampire 1.7 is now available. http://www.dscpl.com.au/projects/vampire http://www.dscpl.com.au/downloads/va...0050608.tar.gz Vampire is an extension module for mod_python, which provides a more flexible dispatch mechanism for basic content handlers, as well as an alternative implementation of the mod_python.publisher module. A range of other useful features are also provided which make using mod_python a much more pleasant experience. Note that Vampire is not strictly a framework in itself, it is essentially glue to help you make it easier to use mod_python. For a quick overview of the features that Vampire provides check out: http://www.dscpl.com.au/projects/vam...mpire-001.html For a full list of changes in this new version check out: http://www.dscpl.com.au/projects/vampire/changes.html As usual, some bugs have been fixed in this version, along with some new features and improvements. One of the more significant changes is the ability to optionally install import hooks so that the "import" syntax can be used to import file based modules using the Vampire module importing and caching system. This means that if using Cheetah Templates and a template extends another, a change in the base class template will now result in the derived template being automatically reloaded without the derived class template needing to be recompiled. Another change is the inclusion of a new wrapper class and changes to some of the existing wrapper classes, such that if a class type is wrapped, an instance of that class will be created automatically to handle each request thus making it easier to construct servlet like handlers. The range of examples included has been expanded upon, with better examples on use of HTMLTemplate, Cheetah Templates, PSP, sessions and the forms based login mechanism, as well as more basic examples of using the wrapper classes to enhance basic content handlers. Enjoy. -- Graham Dumpleton
VIEWS ON THIS POST

48

Posted on:

Wednesday 7th November 2012
View Replies!

[ANN] Virtual Worlds Open Grid Protocols testing library in Python(pyogp)

A new open source project has been started by Linden Lab, makers of the Second Life virtual worlds, and the Second Life Architecture Working Group (AWG) to test LL's proposed virtual worlds Open Grid Protocols (OGP) that will allow any virtual world to support multi-world login, between-world teleport and other transportation mechanisms, as well as asset/property and currency sharing between worlds. https://wiki.secondlife.com/w/index....G_Test_Harness The code is released to all comers in Python under an Apache v2 agreement, although contributions require the signing of Linden Lab's developer contribution agreement (giving LL equal copyrights to the original contributer--a boilerplate LL corporate requirement that likely is redundant given the nature of Apache v2). svn: http://svn.secondlife.com/trac/linde...cts/2008/pyogp. Second Life contribution agreement: http://secondlifegrid.net.s3.amazona...ution_agmt.pdf irc: irc://irc.freenode.net/#pyogp AWG homepage: https://wiki.secondlife.com/wiki/AWG AWG discussion group homepage: https://wiki.secondlife.com/wiki/Category:AW_Groupies AWG-related pages, irc channels and forums: https://wiki.secondlife.com/wiki/Cat...rnal_Resources The near-term AWG goal is to create a set of open standard protocols that: 1) Enable third parties to run servers that connect to the Second Life Grid platform 2) Scale the Second Life Grid architecture to support the industry-projected situation in the next 10 years, where virtual worlds will comprise at least 60 million regions, 2 billion users and in-world concurrency of 50-100 million residents. https://wiki.secondlife.com/wiki/SLGOGP_Draft_1 https://wiki.secondlife.com/wiki/SLG...eport_Strawman The long-term goal is to design a set of protocols and standards that will enable almost any virtual world of any kind to "plug into" this system to varying degrees, from support for a "universal avatar" to full support for all Second Life features and/or the ability to inform universal 3D viewers what features are supported (or not) in any given virtual world. More info on pyogp and the AWG can be obtained on the website or via irc. Lawson English AKA Saijana Kuhn, AWGroupies admin
VIEWS ON THIS POST

62

Posted on:

Saturday 10th November 2012
View Replies!

Re: merge two ranges

On Jul 17, 1:29 pm, anoweb wrote: > I have two ranges of numbers and I need to determine if they overlap > or adjacent and if so return a new range containing the values. The > values are low and high for each pair, such that the first value of > the tuple is always less than or equal to the second value in the > tuple. > > for example: > a = (0, 5) > b = (5, 10) > > print getAdjacent(a, b) # output: (0, 10) > print getAdjacent(b, a) # output: (0, 10) > print getOverlap(a, b) # output: None > print getOverlap(b, a) # output: None > > a = (0, 7) > b = (3, 10) > print getAdjacent(a, b) # output: None > print getAdjacent(b, a) # output: None > print getOverlap(a, b) # output: (0, 10) > print getOverlap(b, a) # output: (0, 10) > > a = (0, 90) > b = (5, 10) > print getAdjacent(a, b) # output: None > print getAdjacent(b, a) # output: None > print getOverlap(a, b) # output: (0, 90) > print getOverlap(b, a) # output: (0, 90) > > a = (0, 5) > b = (12, 20) > print getAdjacent(a, b) # output: None > print getAdjacent(b, a) # output: None > print getOverlap(a, b) # output:None > print getOverlap(b, a) # output: None > > any easy way of doing this It's not really hard to come up with a quick and dirty solution; however if this isn't a homework or a toy program, take a look at the interval module (http://cheeseshop.python.org/pypi/interval/1.0.0) for a more thought-out design. HTH, George
VIEWS ON THIS POST

63

Posted on:

Saturday 10th November 2012
View Replies!

Re: Parsing HTML?

On Wed, 2008-04-02 at 21:59 -0700, Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > ...
VIEWS ON THIS POST

49

Posted on:

Saturday 10th November 2012
View Replies!

SC-Track Roundup 0.7.6 - an issue tracking system

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Roundup is a simple-to-use and -install issue-tracking system with command-line, web and e-mail interfaces. It is based on the winning design from Ka-Ping Yee in the Software Carpentry "Track" design competition. Roundup now has ...
VIEWS ON THIS POST

73

Posted on:

Saturday 10th November 2012
View Replies!

simple web-server

hello python users, could you point me to a very simple (single file is best) web-server I want to serve a few web-forms and run some shell scripts when the forms are submitted. I might add Ajax later (this is ...
VIEWS ON THIS POST

82

Posted on:

Saturday 10th November 2012
View Replies!

Re: embedded python in c++ packaging

En Thu, 07 Feb 2008 16:18:57 -0200, Joshua Kugler escribi: > Furkan Kuru wrote: >> >> I have been developing an application in C++ that embeds Python >> interpreter. It takes advantage of too many modules from Python. >> ...
VIEWS ON THIS POST

199

Posted on:

Saturday 10th November 2012
View Replies!

Python 3000 and import __hello__

Just playing around with Python3000 a2 release on Windows XP 32-bit x86. import __hello__ doesn't print 'hello world...' as it does on 2.5 The import doesn't fail or generate errors... just no output. Perhaps this is by design Brad...
VIEWS ON THIS POST

111

Posted on:

Saturday 10th November 2012
View Replies!

Movie Stars As Sources Of Wisdom

Why do many people look to movie stars for answers to some of life's most challenging questions While we have great respect for the art of acting, as explicated from Stanislavsky to Strasberg, the latter of whom we knew well ...
VIEWS ON THIS POST

37

Posted on:

Saturday 10th November 2012
View Replies!

simple string formatting question

I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ...
VIEWS ON THIS POST

99

Posted on:

Saturday 10th November 2012
View Replies!

Re: sorting contacts alphabetically, sorted by surname

Marie Hughes wrote: > HI > > I have to write a program that contains a text file in the following format: > > Academic Position Room Ext. Email > Prof Marie Maguire Head of > School M9002 0000 lp.muire@ulioooor.ac.uk ...
VIEWS ON THIS POST

131

Posted on:

Saturday 10th November 2012
View Replies!

RELEASED Python 3.0rc2

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team and the Python community, I am happy to announce the second release candidate for Python 3.0. This is a release candidate, so while it is not suitable ...
VIEWS ON THIS POST

62

Posted on:

Saturday 10th November 2012
View Replies!

length of a tuple or a list containing only one element

Hi everybody, I have a question about the difference of behavior of "len" when applied on tuples or on lists. I mean: $ len( ( 'foo', 'bar' ) ) 2 $ len( ( 'foo' ) ) 3 $ len( [ ...
VIEWS ON THIS POST

82

Posted on:

Saturday 10th November 2012
View Replies!

Understanding this generator function

, This is an example of a generator function: ===== def counter(start_at=0): count = start_at while True: val = (yield count) if val is not None: count = val else: count += 1 ====== >>> count = counter(5) >>> count.next() ...
VIEWS ON THIS POST

141

Posted on:

Sunday 11th November 2012
View Replies!

passing arguments to exec

i want to execute a python script using exec open('script.py'). how do I pass arguments...
VIEWS ON THIS POST

123

Posted on:

Sunday 11th November 2012
View Replies!

Re: Win32 trouble with threading, signals, and sleep()

Lowell eman wrote: > I'm running into this issue on Windows with the follow exception at > the time when the signal handler is called: > > Traceback (most recent call last): > ... > self.done.wait(30) > File "D:\Python24\lib\threading.py", line ...
VIEWS ON THIS POST

162

Posted on:

Sunday 11th November 2012
View Replies!

Re: regex doubts

Mr SZ wrote: > I am taking a string as an input from the user and it should only > contain the chars:L , M or R > > I tried the folllowing in kodos but they are still not ...
VIEWS ON THIS POST

193

Posted on:

Sunday 11th November 2012
View Replies!

PyOhio registration is open

Registration is open for PyOhio, the daylong regional miniconference on July 26 in Columbus, OH. http://www.pyohio.org/reg/register/ Registration is free, but registering early guarantees your spot and helps the organizers schedule talks to avoid conflicts. See you on July 26 in ...
VIEWS ON THIS POST

333

Posted on:

Sunday 11th November 2012
View Replies!

struct.pack behavior

Can anyone explain to me why struct.pack('HB',1,2) gives 3 bytes, whereas struct.pack('BH',1,2) gives 4 bytes -Steven...
VIEWS ON THIS POST

83

Posted on:

Sunday 11th November 2012
View Replies!

Re: The best way to package a Python module?

On Mon, 16 Jun 2008 08:39:52 +1000, Ben Finney wrote: >Jean-Paul Calderone writes: > >> On Mon, 16 Jun 2008 01:37:47 +0900, js wrote: >> >By "package", I meant APT, Ports for BSD, MacPorts, etc. >> >> ...
VIEWS ON THIS POST

89

Posted on:

Sunday 11th November 2012
View Replies!

Re: investigate python auth problem

David Hláik wrote: > > I have reproduced steps, to show you sample on another module and its > results in INN (becouse i really like to solve this Since I don't see anything related to python-ldap please don't follow-up ...
VIEWS ON THIS POST

113

Posted on:

Sunday 11th November 2012
View Replies!

Re: Removing Space and "-" from a string

Shakir, > I have thousands of records in MS Access database table, which records I > am fetching using python script. One of the columns having string like > '8 58-2155-58' > > Deed output: '858215558' > > I want ...
VIEWS ON THIS POST

59

Posted on:

Sunday 11th November 2012
View Replies!

kate hudson wallpapers

Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S...
VIEWS ON THIS POST

97

Posted on:

Sunday 11th November 2012
View Replies!

Python - CGI - XML - XSD

Hi , Quick question. I've got an XML schema file (XSD) that I've written, that works fine when my data is present as an XML file. (Served out by apache2.) Now when I call python as a cgi script, and ...
VIEWS ON THIS POST

32

Posted on:

Sunday 11th November 2012
View Replies!

Minimalistic Software Transactional Memory

I'm interested in writing a simple, minimalistic, non persistent (at this stage) software transactional memory (STM) module. The idea being it should be possible to write such a beast in a way that can be made threadsafe fair easily. ...
VIEWS ON THIS POST

82

Posted on:

Sunday 11th November 2012
View Replies!

Modules and descriptors

As I understand it, the appeal of properties (and descriptors in general) in new-style classes is that they provide a way to "intercept" direct attribute accesses. This lets us write more clear and concise code that accesses members directly without ...
VIEWS ON THIS POST

38

Posted on:

Monday 12th November 2012
View Replies!

ctypes

I am trying to call a funtinon in a third party dll that spawns another exe and I am using ctypes. Python does not complain at all but the other process does not get spawned. It appears that I am ...
VIEWS ON THIS POST

44

Posted on:

Monday 12th November 2012
View Replies!

Re: Network-Packets

-On [20080102 16:00], Sunil Ghai (sunilkrghai@gmail.com) wrote: >I know this is not the right place for asking about this but i am sure some of >you must have an idea about this. The networking community would be more appropriate, methinks. ...
VIEWS ON THIS POST

36

Posted on:

Monday 12th November 2012
View Replies!

connect to server question

Is there a way to connect to servers on OS X using Python Here's the code I presently use in a Bash Shell script: /bin/mkdir -p /Volumes/A_Share /sbin/mount_afp "afp://username assword@ServerBox/A_Share" "/ Volumes/A_Share" Can something similar be done with Python
VIEWS ON THIS POST

68

Posted on:

Monday 12th November 2012
View Replies!

looking for ocbc example

I am sure this is what I want: http://www.python.org/topics/database/docs.html "The documentation for the PythonWin ODBC module." but it is 404. google isn't being nice. Anyone know where I can find some simple examples I have used odbc in other environments, ...
VIEWS ON THIS POST

258

Posted on:

Monday 12th November 2012
View Replies!

Finding lowest value in dictionary of objects, how?

I'm new to Python and working on a school assignment. I have setup a dictionary where the keys point to an object. Each object has two member variables. I need to find the smallest value contained in this group ...
VIEWS ON THIS POST

41

Posted on:

Monday 12th November 2012
View Replies!

Re: When I do from lxml import etree I've this error : AttributeError:'module' object has no attribute 'BytesIO'

Le Mon, 25 Aug 2008 13:50:50 +0000, KLEIN Stéphane a écrit : > > > I'm on Ubuntu 8.04.1 > > I've installed lxml with easy_install lxml command. > > Now, when I load etree I've this error : > ...
VIEWS ON THIS POST

153

Posted on:

Sunday 25th November 2012
View Replies!

You advice please

, I'm a Java/Java EE developer and I'm playing with Python these days. I like the Python language so much and I like its communities and the Django framework. My friends are about to open a Ruby/Rails shop and they ...
VIEWS ON THIS POST

176

Posted on:

Sunday 25th November 2012
View Replies!

Simple Doc Test failing without any reason [Help Needed]

The following following code fails with the failiure:- File "test.py", line 27, in __main__.sanitize_number Failed example: sanitize_number('0321-4683113') Expected: '03214683113' Got: '03214683113' Expected and Got looks the same. The value should verify. What am I doing wrong here
VIEWS ON THIS POST

108

Posted on:

Sunday 25th November 2012
View Replies!

simple way to touch a file if it does not exist

what are the simple ways I could think of os.open(), os.exec(touch file) are there any simpler methods...
VIEWS ON THIS POST

77

Posted on:

Sunday 25th November 2012
View Replies!

Python module for reading FilePro files?

Does anyone know of a Python package or module to read data files from the venerable old Filepro crossplatform database/IDE...
VIEWS ON THIS POST

133

Posted on:

Sunday 25th November 2012
View Replies!

Re: Search the command history - Python Shell

> Are there any simillar key combination in Python Shell like Linux Ctrl+R > (reverse-i-search) to search the command history It must depend on how your version of Python was built...mine here on my Linux box has exactly that functionality. ...
VIEWS ON THIS POST

59

Posted on:

Sunday 25th November 2012
View Replies!

Re: wxEVT_SCROLL_ENDSCROLL

try wx.EVT_SCROLL_ENDSCROLL Jack Holt wrote: > , > > I got the following error: > > Traceback (most recent call last): > File "vplayer.py", line 15, in > File "config.pyo", line 3, in > File "wx\__init__.pyo", line ...
VIEWS ON THIS POST

61

Posted on:

Sunday 25th November 2012
View Replies!

Re: Fw: Undeliverable Message

> Heres the code > > def increment(digits,symbols): > overflow=True > digitpos=-1 > while overflow and -digitpos<=len(digits): > digitsymbolindex=symbols.index(digits[digitpos]) > ...
VIEWS ON THIS POST

51

Posted on:

Sunday 25th November 2012
View Replies!

SUMMON 1.8.4 RELEASED: rapid prototyping of 2D visualizations

SUMMON 1.8.4 SUMMON is a python extension module that provides rapid prototyping of 2D visualizations. By heavily relying on the python scripting language, SUMMON allows the user to rapidly prototype a custom visualization for their data, without the overhead of ...
VIEWS ON THIS POST

85

Posted on:

Sunday 25th November 2012
View Replies!

[help request] how to set sys.stderr to object of cStringIO type

I am in a perculiar situation. I want to use PyRun_SimpleString for creating Python functions in embedded Python in C++. But there could be cases when Python function code compilation could fail & PyRun_SimpleString will return -1 as return status. ...
VIEWS ON THIS POST

217

Posted on:

Sunday 25th November 2012
View Replies!

gtk.TreeView cell inconsistent state

In the below code setting cell to inconsistent sets entire column inconsistent (renderer).However, I need a third state off | on | inconsistent . How can I change one path->cell
VIEWS ON THIS POST

123

Posted on:

Monday 26th November 2012
View Replies!

Re: help displaying pdf thru client/server

On Wed, 19 Dec 2007 13:50:10 -0600, Larry Bates wrote: >PaulS wrote: >> Connecting to a Linux server from XP pc using a telnet program, I run a >> report and convert it to a pdf document(using Reportlab) which ...
VIEWS ON THIS POST

93

Posted on:

Monday 26th November 2012
View Replies!

My pyguessinggame

Could someone look this over (Toggle Plain Text) #import whrandom def start(): answer=randint(1,101) #the answer guessnum=0 #number of user guesses guess=raw_imput ('guess my number, it is between 1 and 100') #user's guess while guess!= answer: guessnum=guessnum+1 if(guess = 101): print'no the answer is below 101' elif (guess > answer): print 'Too high' elif (guess answer): print 'Too high' elif (guess
VIEWS ON THIS POST

64

Posted on:

Tuesday 27th November 2012
View Replies!

Function won't exit on return!

(Toggle Plain Text) # def find_items(url): # try: # url = urllib.urlopen(url).read() # except: # return None # while True: # web_page = 'some url' # fs_item = url.find(r'some text') # fs_item += 9 # fe_item= url.find(r'"',fs_item) # item.append(web_page[:]+url[fs_item:fe_item]) # ps_s = url.find(r'"some text">Next') # if ps_s is -1: no_next = 1 # else: no_next = 0 # if not no_next: # ps_s-=25 # ps_e = url.find(r'"',ps_s) # next_page = '' # next_page= next_page + web_page[:] + url[ps_s:ps_e] # for items in range(1,25): # ss_item = url.find(r'some text',fe_item) # if ss_item is -1: break # ss_value = ss_item # char_to_kill = url[ss_item-1:ss_item] # if url[ss_item-1:ss_item] is char_to_kill: ss_item = url.find(r'some text'ss_value+9) # if ss_item is -1: # if no_next is 1: # return item #
VIEWS ON THIS POST

60

Posted on:

Wednesday 28th November 2012
View Replies!

What's with the baggage? py2exe/compilers

Hi people, i've just been reading some of the threads about the py2exe thing. everytime someone asks about turning their .py into .exe this comes up and they say that it actualy packs the python.exe and other stuff into the executable... isn't that unnecessary I dont know too much about this (only started learning python and Java recently) but i'm sure thats not how it would be done professioanlly, like with the day-today exec.s that uses. Is there actually a way to turn code into executable, or have i missed something BTW, how hard is it to advance from console programming to GUI programming, in python
VIEWS ON THIS POST

82

Posted on:

Friday 28th December 2012
View Replies!

Calculating

I will can't at this second at library but, when I get home I will hey you got any ideas. I have ubuntu but, when I save a file as .py now it opens up a text editor how can i change this
VIEWS ON THIS POST

69

Posted on:

Friday 28th December 2012
View Replies!

I'm a new to Python

, nice forums you have here. Anyway I've started to learn python, today infact, as I've heard its a good language to learn, I have some experience in BASIC and a little in C from using Linux. I was wondering if there was a function in Python that did the same as mid$() in BASIC, I've searched for tutorials on string manipulation etc, but could not find anything on this function.
VIEWS ON THIS POST

300

Posted on:

Friday 28th December 2012
View Replies!