Python bytecode STORE_NAME

2008-11-18 Thread schwarz
As part of some research I am doing a Python Virtual Machine in Java,
and the exact semantics of the STORE_NAME bytecode is unclear to be,
so I was hoping somebody here could clarify it.
The STORE_NAME bytecode is supposed to set a value for a name in the
current scope. However, the following piece of code:

def hello(who):
print "Hello", who
return hello(who)
print "Say:"
hello("World")

Results in this bytecode for the top level:
1, LOAD_CONST, 1
4, MAKE_FUNCTION, 0
7, STORE_NAME, 0
10, LOAD_CONST, 2
13, PRINT_ITEM, None
14, PRINT_NEWLINE, None
15, LOAD_NAME, 0
18, LOAD_CONST, 3
21, CALL_FUNCTION, 1
24, POP_TOP, None
25, LOAD_CONST, 0
28, RETURN_VALUE, None

And this bytecode for the hello function:
1, LOAD_CONST, 1
4, PRINT_ITEM, None
5, LOAD_FAST, 0
8, PRINT_ITEM, None
9, PRINT_NEWLINE, None
10, LOAD_GLOBAL, 1
13, LOAD_FAST, 0
16, CALL_FUNCTION, 1
19, RETURN_VALUE, None
20, LOAD_CONST, 0
23, RETURN_VALUE, None

The first column are the byte numbers, and the last column contains
the arguments to the byte codes if they take any.

The function is stored using STORE_NAME with offset 0 in the module
scope, but it is loaded from inside the hello method using LOAD_GLOBAL
with offset 1. My questions are: Does STORE_NAME add things to the
global scope when used top level? And why is the offset different?

The documentation contains nothing usable:
http://www.python.org/doc/2.5.2/lib/bytecodes.html

regards,
Mathias
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python bytecode STORE_NAME

2008-11-19 Thread schwarz
On 19 Nov., 10:14, Peter Otten <[EMAIL PROTECTED]> wrote:
>
> Every code object has its own co_names attribute (a tuple). The arguments
> are offsets into that tuple.
>
> Using Python 2.5 I can't reproduce your example, I get 0 offsets in both
> cases. Here's a simpler one:
>
> >>> import dis
> >>> def f():
>
> ...     x
> ...     y
> ...>>> def g():
>
> ...     y
> ...>>> dis.dis(f)
>
>   2           0 LOAD_GLOBAL              0 (x)
>               3 POP_TOP
>
>   3           4 LOAD_GLOBAL              1 (y)
>               7 POP_TOP
>               8 LOAD_CONST               0 (None)
>              11 RETURN_VALUE>>> dis.dis(g)
>
>   2           0 LOAD_GLOBAL              0 (y)
>               3 POP_TOP
>               4 LOAD_CONST               0 (None)
>               7 RETURN_VALUE>>> f.func_code.co_names
> ('x', 'y')
> >>> g.func_code.co_names
>
> ('y',)
>
> Peter

Ok, thanks a lot. That helped me understand the offsets. Your
disassembly misses the code in the global scope that creates the two
methods from the code objects. That code looks like this for your
example (dis won't give you this. I use a modified version of the
byteplay disassembler which can disassemble a module without loading
it):
1, LOAD_CONST, 1 //Loads the code object for function f
4, MAKE_FUNCTION, 0 //Creates a function from the code object
7, STORE_NAME, 0 //Stores it as 'f' using STORE_NAME
10, LOAD_CONST, 2 //Loads the code object for function g
13, MAKE_FUNCTION, 0 //Creates the function
16, STORE_NAME, 1 //Stores it as 'g' using STORE_NAME
19, LOAD_CONST, 0 //Loads None
22, RETURN_VALUE, None //Exists the program with status None

The two last bytecodes are there because I didn't use the interactive
mode. I guess I narrowed down my other question to whether the
semantics are that stuff saved using STORE_NAME in the global scope
can be loaded everywhere else using LOAD_GLOBAL. What baffled me was
that there is actually a STORE_GLOBAL byte code.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to improve the usability of nested packages

2012-11-03 Thread Michael Schwarz
Hi Terry

On 2012-W44-5, at 18:56, Terry Reedy wrote:

>> or would you maybe structure the library entirely different?
> 
> Based on my limited experience with subpackages* plus reports on this list 
> about problems, such as yours, I have concluded that subpackages are an 
> attractive nuisance that are generally more trouble than they are worth. I 
> suggest you consider sticking with your original flat (no subpackage) design. 
> (But maybe someone knows better than me how to make subpackages work ;-).

One thing that I would lose is the way I can choose very short names for the 
packages and modules that are imported into the local namespace (like sip or 
rtp) and also add new stuff without fearing a namespace conflict in one of the 
applications using the library.

I really hope there is a better way :-(.

Michael

smime.p7s
Description: S/MIME cryptographic signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to improve the usability of nested packages

2012-11-03 Thread Michael Schwarz
Hi Stefan

On 2012-W44-5, at 19:23, Stefan H. Holek wrote:

> That said, there are ways to avoid import cycles. One is to very carefully 
> craft your modules so they do not have to import from each other. Another is 
> to not have imports at the module level, but move them into the functions 
> where they are required.

I've also thought about that. I do not like the fact that I then need to 
educate the other developers about minute details of the import machinery just 
so they can add code to the library. I'm currently the only developer doing 
actual work in Python and would like to make the transition as painless as 
possible.

> Third, large libraries like the Zope Toolkit usually have mechanisms to defer 
> imports to some point after initial loading. You may want explore this 
> direction as well. [2]

Hmm, I like the idea but sadly it doesn't look very IDE-friendly.

Thanks for your tips!
Michael

[1]: http://docs.zope.org/zopetoolkit/codingstyle/python-style.html

smime.p7s
Description: S/MIME cryptographic signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some more odd behaviour from the Regexp library

2005-10-19 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 "David Veerasingam" <[EMAIL PROTECTED]> wrote:

> Can anyone explain why it won't give me my captured group?
> 
> In [1]: a = 'exit: gkdfjgfjdfsgdjglkghdfgkd'
> In [2]: import re
> In [3]: b = re.search(r'exit: (.*?)', a)
> In [4]: b.group(0)
> Out[4]: 'exit: '
> 
> In [5]: b.group(1)
> Out[5]: ''
> 
> In [6]: b.group(2)
> IndexError: no such group

The ? tells (.*?) to match as little as possible and that is nothing.  
If you change it to (.*) it should do what you want.

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 "Enrico" <[EMAIL PROTECTED]> wrote:

> "Joseph Garvin" <[EMAIL PROTECTED]> ha scritto nel messaggio
> news:[EMAIL PROTECTED]
> > --This code won't run because it's in a comment block
> > --[[
> > print(10)
> > --]]
> >
> > --This code will, because the first two dashes make the rest a comment,
> > breaking the block
> > ---[[
> > print(10)
> > --]]
> >
> > So you can change whether or not code is commented out just by adding a
> > dash. This is much nicer than in C or Python having to get rid of """ or
> > /* and */. Of course, the IDE can compensate. But it's still neat :)
> 
> python:
> 
> """
> print 10
> """
> 
> and
> 
> #"""
> print 10
> #"""


It seems to me that this trick works in Python,too.

"""
print 10
#"""

and

#"""
print 10
#"""


You only have to change the first triple quote.

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


regex question

2005-06-25 Thread Felix Schwarz
Hi all,

I'm experiencing problems with a regular expression and I can't figure 
out which words I use when googling. I read the python documentation for 
the re module multiple times now but still no idea what I'm doing wrong.

What I want to do:
- Extract all digits (\d) in a string.
- Digits are separated by space (\w)

What my program does:
- It extracts only the last digit.

Here is my program:
import re
line = ' 1  2   3'
regex = '^' + '(?:\s+(\d))*' + '$'
match = re.match(regex, line)
print "lastindex is: ",match.lastindex
print "matches: ",match.group(1)


Obviously I do not understand how (?:\s+(\d))* works in conjunction with 
  ^ and $.

Does anybody know how to transform this regex to get the result I want 
to have?

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


Re: authentication project

2005-08-10 Thread Felix Schwarz
Hi,

for some of the "ground work" you could use the Python Web Modules 
(www.pythonweb.org).

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


Re: Inline::Python, pyperl, etc.

2005-09-01 Thread Felix Schwarz

Eli Stevens (WG.c) wrote:
> PyPerl 1.0.1
> http://wiki.python.org/moin/PyPerl
> 
> The interest in these projects seems to have died off about 2001, 
> however.  That, or they simply haven't needed to be updated for the last 
> few Python versions.
> 
> I've bumped into some snags with pyperl (can't import perl2.so?  But 
> it's right there in site-packages/ !), and I'm wondering if it's bitrot 
> or a config error on my end.
> 
> Similarly, with Inline::Python I end up getting strings passed into my 
> python code when I expect integers (I posted about this on 
> inline@perl.org, but things seem pretty dead over there).
> 
> Is anyone actually using any of this stuff?

I made some patches to pyperl and the unit testing suite some months 
ago. At least basic functionality is working again. Have a look at the 
zope-perl mailing list.
I don't know if I announced a single source tar.gz on this mailing list 
but if you have still some interest in this I can mail you  the package.

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


Re: programmatically calling a function

2005-03-05 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 Dave Ekhaus <[EMAIL PROTECTED]> wrote:

> hi
> 
>   i'd like to call a python function programmatically - when all i have 
> is the functions name as a string.  i.e.
> 
>   
> fnames = ['foo', 'bar']
> 
> for func in fnames:
> 
>   #
>   # how do i call function 'func' when all i have is the name of the 
> function ???
>   #
>   
> 
> 
> def foo():
>   
>   print 'foo'
> 
> def bar():
> 
>   print 'bar'
> 
> 
>   i'd really appreciate any help the 'group' has to offer.
> 
> 
> thanks
> dave


Dave,

I think eval might be what you're looking for:

f = eval('len')
length = f([1,2,3])


By the way, are you the Dave Ekhaus I used to work with at Kodak?

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: programmatically calling a function

2005-03-05 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote:

> Doug Schwarz wrote:
> 
> > Dave,
> > 
> > I think eval might be what you're looking for:
> > 
> > f = eval('len')
> > length = f([1,2,3])
> 
> But only if the string given to eval is checked thorougly for allowed
> contents. Better use getattr.
> 
> Reinhold


Actually, upon reading Peter Hansen's reply more carefully, I wil defer 
to his approach, namely,

def foo():
print "foo"

f = globals()["foo"]

as I suspect that it will be more efficient.  You still need to make 
sure that the string in question is one of the keys in the globals() 
dictionary or else handle the error -- just as with eval.

I don't see how getattr solves the original problem.  What, exactly, is 
the first argument to getattr?

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Splitter Brain Teaser

2005-03-27 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 James Stroud <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I have strings represented as a combination of an alphabet (AGCT) and a an 
> operator "/", that signifies degeneracy. I want to split these strings into 
> lists of lists, where the degeneracies are members of the same list and 
> non-degenerates are members of single item lists. An example will clarify 
> this:
> 
> "ATT/GATA/G"
> 
> gets split to
> 
> [['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']]


How about this?

import re
s = "ATT/GATA/G"
result1 = re.findall(r"./.|.", s)
consensus = [c.split("/") for c in result1]

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Splitter Brain Teaser

2005-03-28 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 James Stroud <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I have strings represented as a combination of an alphabet (AGCT) and a an 
> operator "/", that signifies degeneracy. I want to split these strings into 
> lists of lists, where the degeneracies are members of the same list and 
> non-degenerates are members of single item lists. An example will clarify 
> this:
> 
> "ATT/GATA/G"
> 
> gets split to
> 
> [['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']]


How about this?

import re
s = "ATT/GATA/G"
result1 = re.findall(r"./.|.", s)
consensus = [c.split("/") for c in result1]

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Splitter Brain Teaser

2005-03-28 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 James Stroud <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I have strings represented as a combination of an alphabet (AGCT) and a an 
> operator "/", that signifies degeneracy. I want to split these strings into 
> lists of lists, where the degeneracies are members of the same list and 
> non-degenerates are members of single item lists. An example will clarify 
> this:
> 
> "ATT/GATA/G"
> 
> gets split to
> 
> [['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']]


How about this?

import re
s = "ATT/GATA/G"
result1 = re.findall(r"./.|.", s)
consensus = [c.split("/") for c in result1]

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 Dick Moores <[EMAIL PROTECTED]> wrote:

> Dan wrote at 18:02 4/13/2005:
> >On Wed, 13 Apr 2005 03:27:06 -0700, Dick Moores <[EMAIL PROTECTED]>
> >wrote:
> >
> > > I'm just trying to help an artist acquaintance who needs (I just
> > >learned) the first 3003 digits of pi to the base 12.
> >
> >Now you've got me curious.  Why would an artist want the first 3003
> >digits of pi to the base 12?
> 
> He says,
> Do you know how I can get "base12 pi"?
> Because the chromatic scale is base12.
> c c# d d# e f f# g g# a a# b
> 
> Dick

Does your artist friend have any idea what base 12 means?

The chromatic scale is based on one twelfth powers of two, i.e., if the 
frequency of a note in the scale is f(n), then the frequency of the next 
note is given by

  f(n+1) = f(n) * 2^(1/12)

so by the time you go all 12 notes in an octave you have doubled the 
frequency.  There is nothing here involving base 12 or pi.

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Byteorder of audioop functions

2013-11-18 Thread Michael Schwarz
Hi

Is the byteorder (or endianness) of the functions in the audioop module 
somewhere specified or does anyone know how it behaves on different systems?

On my little-endian system it matches the system's endianness:

>>> import sys, audioop
>>> sys.byteorder
'little'
>>> audioop.lin2lin(b'\xff', 1, 2)
b'\x00\xff'

Michael
-- 
https://mail.python.org/mailman/listinfo/python-list


Is %z broken for return values of time.gmtime()?

2013-09-16 Thread Michael Schwarz
I’m wondering whether this is expected:

Python 3.3.2 (default, May 21 2013, 11:50:47) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.strftime("%F %T %z", time.gmtime(40 * 365 * 86400))
'2009-12-22 00:00:00 +0100‘

According to the documentation of time.gmtime(), it returns a struct_time in 
UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s time zone 
without DST, but DST is currently in effect here (but was not at the timestamp 
passed to gmtime()).

40 * 365 * 86400 seconds is a bit less than 40 Years. I’m using a date near to 
today to rule out any peculiarities with dates that are long in the past. Using 
a date at which DST was active yields the same result:

>>> time.strftime("%F %T %z", time.gmtime(40.5 * 365 * 86400))
'2010-06-22 12:00:00 +0100'

Why is my OS’s time zone used for formatting a struct_time with the UTC time 
zone? I’m running OS X 10.8.4, my OS’s time zone is set to CET/CEST.

Regards
Michael

smime.p7s
Description: S/MIME cryptographic signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is %z broken for return values of time.gmtime()?

2013-09-16 Thread Michael Schwarz
On 2013-W38-1, at 19:56, random...@fastmail.us wrote:

> On Mon, Sep 16, 2013, at 9:15, Michael Schwarz wrote:
>> According to the documentation of time.gmtime(), it returns a struct_time
>> in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s
>> time zone without DST, but DST is currently in effect here (but was not
>> at the timestamp passed to gmtime()).
> 
> The struct_time type does not include information about what timezone it
> is in.

Uhm … Python 3.3 introduced the tm_gmtoff member of struct_time, which contains 
the offset to UTC. I thought, %z was also introduced in Python 3.3 and so I 
thought it would use that field. What time zone does it use then? Does it 
always use the system's time zone?

> You can use datetime.datetime (e.g. datetime.datetime.fromtimestamp(40 *
> 365 * 86400,datetime.timezone.utc) - the datetime.datetime class has a
> strftime method.

I do use that, but I was using time.localtime() to convert a POSIX timestamp to 
a date using the system's timezone and saw that while a struct_time produced by 
time.localtime() and formatted using time.strftime() shows the correct time 
zone (+0100 and +0200 here), it does not for a struct_time produced by 
time.gmtime(). I think that's strange.

> You should be aware that %F and %T are not portable and won't work on
> windows for example.

I’m aware of that, but thanks. I was toying around and just needed to print the 
rest of the date.

Regards
Michael

smime.p7s
Description: S/MIME cryptographic signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Running code from source that includes extension modules

2013-10-02 Thread Michael Schwarz
Hi

I've just started looking into distutils because I need to write an
extension module in C (for performance reasons) and distutils seems to be
the most straight-forward way.

I've had success building a C file into a Python extension module using
"python setup.py build" but I am wondering what the recommended way for
using that module during development is. While writing Python code I'm used
to just run the code from the source directory. But the built extension
module's .so of course does not just end up on sys.path magically.

So how do I run my code so it will find the built extension module? Do I
pass the output directory on the command line manually or is there some
other solution? I would like to still be able to run the code from the
source directory as I'm using PyCharm to edit and debug the code.

Many thanks!

Michael
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running code from source that includes extension modules

2013-10-02 Thread Michael Schwarz
On 2013-W40-3, at 19:15, "Gisle Vanem"  wrote:

> "Michael Schwarz"  wrote:
> 
>> So how do I run my code so it will find the built extension module? Do I
>> pass the output directory on the command line manually or is there some
>> other solution? I would like to still be able to run the code from the
>> source directory as I'm using PyCharm to edit and debug the code.
> 
> Doesn't Python on Linux (I assume that since you mentioned the module's .so)
> support having current-dir '.' in $PYTHONPATH? Works fine on Windows.

I'm running OS X 10.8 and Python 3.2, sorry I didn't mention it. But I assume 
the differences to Linux are minimal.

The current directory is included in sys.path, otherwise I wouldn't be able to 
import modules in the same directory. But the problem is that the built 
extension module is in a subdirectory of the "build" directory:

$ find -name '*.so'
./build/lib.macosx-10.8-x86_64-3.2/_foo.so

And so I can't import it without manually adding that directory to sys.path. 
I'm convinced, someone on this list can shout at me, telling me that I got it 
completely backwards and that there's a straightforward and intuitive way to 
develop extension modules!

Michael

smime.p7s
Description: S/MIME cryptographic signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running code from source that includes extension modules

2013-10-02 Thread Michael Schwarz
On 2013-W40-3, at 21:15, Stefan Behnel  wrote:

> Michael Schwarz, 02.10.2013 17:38:
>> I've just started looking into distutils because I need to write an
>> extension module in C (for performance reasons) and distutils seems to be
>> the most straight-forward way.
>> 
>> I've had success building a C file into a Python extension module using
>> "python setup.py build" but I am wondering what the recommended way for
>> using that module during development is. While writing Python code I'm used
>> to just run the code from the source directory. But the built extension
>> module's .so of course does not just end up on sys.path magically.
>> 
>> So how do I run my code so it will find the built extension module? Do I
>> pass the output directory on the command line manually or is there some
>> other solution? I would like to still be able to run the code from the
>> source directory as I'm using PyCharm to edit and debug the code.
> 
> You can run
> 
>   python setup.py build_ext -i
> 
> That will build your extension module and install it right into your
> package structure.

This is really very much what I was looking for! I've set up PyCharm to run 
this command (by configuring it as an "external tool", maybe there's a simpler 
way), before running the actual application. \o/

> BTW, if you use Cython instead of plain C, you can use pyximport to get
> on-the-fly extension module builds during development.

I will look into that too, that sounds very convenient. But am I right, that to 
use Cython the non-Python code needs to be written in the Cython language, 
which means I can't just copy&past C code into it? For my current project, this 
is exactly what I do, because the C code I use already existed.

Thanks
Michael

smime.p7s
Description: S/MIME cryptographic signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: True == 1 weirdness

2015-09-23 Thread Michael Schwarz
On 2015-09-19, at 09:19, Gregory Ewing  wrote:

> Random832 wrote:
>> I'm disputing that chained comparisons are used for the particular
>> combinations that I am actually arguing should not be used in python.
>> Such as a < b > c or a != b != c  [whereas a may or may not be equal to
>> c]
> 
> I can't remember offhand seeing a != b != c written by a
> mathematician, but if I did, I would suspect that he
> *intended* it to imply a != c, even if that's not a strict
> logical consequence of the notation.

Mathematica interprets a != b != c as "none of a, b or c are equal". See [0]. 
It does this by parsing it to Unequal[a, b, c] (square brackets are function 
calls), where Unequal then implements that operation.

Normally I'm used to Mathematica being a very consistent language. But being 
prepared by this thread, I of course wondered where the inconsistencies start 
here and whether inequalities mix well with comparisons. They don't:

While b != c != d gets parsed as this:

Unequal[b, c, d]

But a < b != c != d < e gets parsed as this:

And[Less[a, b], Unequal[b, c], Unequal[c, d], Less[d, e]]

Which means that a != b != c is interpreted differently depending on context. I 
don't think every mathematician would agree which of these interpretations make 
sense. :)

[0]: https://reference.wolfram.com/language/ref/Unequal.html


signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Filename case-insensitivity on OS X

2006-01-03 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 Tom Anderson <[EMAIL PROTECTED]> wrote:

> Afternoon all,
> 
> MacOS X seems to have some heretical ideas about the value of case in 
> paths - it seems to believe that it doesn't exist, more or less, so "touch 
> foo FOO" touches just one file, you can't have both 'makefile' and 
> 'Makefile' in the same directory, 
> "os.path.exists(some_valid_path.upper())" returns True even when 
> "os.path.split(some_valid_path.upper())[1] in 
> os.listdir(os.path.split(some_valid_path)[0])" returns False, etc 
> (although, of course, "ls *.txt" doesn't mention any of those .TXT files 
> lying around).


Strictly speaking, it's not OS X, but the HFS file system that is case 
insensitive.  You can use other file systems, such as "UNIX File 
System".  Use Disk Utility to create a disk image and then erase it 
(again, using Disk Utility) and put UFS on it.  You'll find that "touch 
foo FOO" will create two files.

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex for repeated character?

2005-06-17 Thread Doug Schwarz
In article <[EMAIL PROTECTED]>,
 Leif K-Brooks <[EMAIL PROTECTED]> wrote:

> How do I make a regular expression which will match the same character
> repeated one or more times, instead of matching repetitions of any
> (possibly non-same) characters like ".+" does? In other words, I want a
> pattern like this:
> 
>  >>> re.findall(".+", "foo") # not what I want
>  ['foo']
>  >>> re.findall("something", "foo") # what I want
>  ['f', 'oo']


How's this?

  >>> [x[0] for x in re.findall(r'((.)\2*)', 'abbccccccbba')]
  ['a', 'bb', 'ccc', '', 'ccc', 'bb', 'a']

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list


_struct in Python 2.5.2

2008-02-24 Thread Olaf Schwarz
Hi,

I am trying to run this application
http://svn.navi.cx/misc/trunk/python/bemused/
on uNSLUng Linux 6.10 using the optware python packages.

As I obtained segmentation faults using Python 2.4, I have upgraded to
2.5.2. Now the execution terminates a lot earlier with this error
message:

  File "/usr/local/bemused_mpd/bemused-mpd.py", line 33, in 
import bemused
  File "/usr/local/bemused_mpd/bemused.py", line 27, in 
import bluetooth, syslog
  File "/opt/lib/python2.5/site-packages/bluetooth.py", line 2, in

import struct
  File "/opt/lib/python2.5/struct.py", line 30, in 
from _struct import Struct, error
ImportError: No module named _struct

I found out that there has been a file named _struct.so in 2.5.1 but
it has disappeared in 2.5.2. With no package available for downgrading
to 2.5.1 and no idea how to resolve this I am stuck at this point.

Any help appreciated.

Thank you
Olaf
-- 
http://mail.python.org/mailman/listinfo/python-list


GoEar Mp3 download system

2009-04-25 Thread Carlos Schwarz Júnior
I developed an application using pyGTK to download the MP3 music that are 
hosted on GoEar http://www.goear.com/.
It's not totally finished, but the main functions are working and some other 
interesting features too.


It works well in Windows and Linux (not tested in MAC).
To download: http://code.google.com/p/goear2mp3/

Suggestions and comments are welcome. Enjoy!! 


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