I'm probably just getting languages mixed up, but I thought in my Python
readings over the last couple months that I had noticed an either/or
expression (as opposed to a bitwise or, or truth test). Being a curious
sort, I tried several variations of how a list comprehension *might* be
construc
Try this.
re.findall(r'(.+? \(.+?\))(?:,|$)',yourtexthere)
--
http://mail.python.org/mailman/listinfo/python-list
Oops, the above code doesn't quite work. Use this one instead.
re.findall(r'(.+? (?:\(.+?\))?)(?:,|$)',yourtexthere)
--
http://mail.python.org/mailman/listinfo/python-list
Well, this doesn't have the terseness of an re solution, but it
shouldn't be hard to follow.
-- Paul
#~ This is a very crude first pass. It does not handle nested
#~ ()'s, nor ()'s inside quotes. But if your data does not
#~ stray too far from the example, this will probably do the job.
#~ Down
Alright well I'm quite a noob and when I run a simple command to change the
current directory, nothing happens. I made a little test script to show it:
import os
cwd = os.getcwd()
print cwd
os.system('cd = C:\Program Files')
print cwd
then the result:
C:\Python24\Python Scripts
C:\Python24\
Ivan Shevanski wrote:
> Alright well I'm quite a noob and when I run a simple command to change
> the current directory, nothing happens. I made a little test script to
> show it:
>
> import os
> cwd = os.getcwd()
> print cwd
> os.system('cd = C:\Program Files')
> print cwd
>
> then the result
Koncept wrote:
> I want to incorporate the datetime and other modules into my class. I
> am new to Python and would really appreciate some help doing this.
>
> class FooBar:
>def getDate(self):
> return
>
> ^^^ how do I do something like this?
Um have you read the tutorial yet? I
Ivan Shevanski wrote:
> Alright well I'm quite a noob and when I run a simple command to change
> the current directory, nothing happens. I made a little test script to
> show it:
>
>
> import os
> cwd = os.getcwd()
> print cwd
> os.system('cd = C:\Program Files')
> print cwd
There are at lea
Peter Hansen wrote:
> Ivan Shevanski wrote:
>> Alright well I'm quite a noob and when I run a simple command to
>> change the current directory, nothing happens. I made a little test
>> script to show it:
>
> Generally, the only way to use an application (i.e. a program like the
> Python inter
On 30 Jun 2005 14:38:17 -0700, MooMaster <[EMAIL PROTECTED]> wrote:
> So I started reading about os, threads,
> and the path for the special folders in the archives and in the Python
> docs and I'm kind of lost because there aren't many concrete examples
> in the documentation. Can anyone point me
John Machin wrote:
> Steven Bethard wrote:
>
>> John Machin wrote:
>>
>>> For example, text = 'foo bar', chunks = ['foobar']
>>
>> This doesn't match the (admittedly vague) spec
>
> That is *exactly* my point -- it is not valid input, and you are not
> reporting all cases of invalid input; you h
I have string text with language text records that looks like this:
'en' | 'the brown cow' | 'fr' | 'la vache brun'
Two or more language records can exist in each string (example above
shows 2 - but could contain more)
The second vertical line character in the example above is the record
break
David Pratt wrote:
> I have string text with language text records that looks like this:
>
> 'en' | 'the brown cow' | 'fr' | 'la vache brun'
>
> Two or more language records can exist in each string (example above
> shows 2 - but could contain more)
> The second vertical line character in the ex
"Chinook" wrote:
> I'm probably just getting languages mixed up, but I thought in my Python
> readings over the last couple months that I had noticed an either/or
> expression (as opposed to a bitwise or, or truth test). Being a curious
> sort, I tried several variations of how a list comprehensi
Chinook wrote:
> >>> ta = [5, 15, 12, 10, 9]
> >>> for i in range(len(ta)):
> ... if ta[i] >= 10:
> ... ta[i] -= 10
> ... else:
> ... ta[i] += 10
> ...
> >>> ta
> [15, 5, 2, 0, 19]
One possibility:
py> [(tai + 10, tai - 10)[tai >= 10] for tai in ta]
[15, 5, 2, 0, 19]
But see:
htt
David Pratt wrote:
> I have string text with language text records that looks like this:
>
> 'en' | 'the brown cow' | 'fr' | 'la vache brun'
>
> Two or more language records can exist in each string (example above
> shows 2 - but could contain more)
> The second vertical line character in the ex
On Thursday 30 June 2005 10:13 pm, Chinook wrote:
> >>> ta = [5, 15, 12, 10, 9]
> >>> for i in range(len(ta)):
> ... if ta[i] >= 10:
> ... ta[i] -= 10
> ... else:
> ... ta[i] += 10
It's not exactly the same in that it doesn't change values in
place, but this is similar if you are onl
Why don't you use a different delimiter when you're writing the CSV?
--
http://mail.python.org/mailman/listinfo/python-list
One line solution.
dict(re.findall(r"'(.+?)' \| '(.+?)'(?:\s\||$)",yourtexthere))
--
http://mail.python.org/mailman/listinfo/python-list
"Robert Kern" wrote:
> Ignore the last message.
>
> translations = [x.strip(" '") for x in line.split('|')]
> d = dict(zip(translations[::2], translations[1::2]))
Or in case you're working with a lot and/or huge records, the second
line can be more efficiently written as:
from itertools import i
Wow Robert that is incredible python magic! I am trying to figure out
what this is doing since my attempts were regex and some long string
splitting and collection.
Ok. So it is a list comprehension and then collection. What is zip
doing in the second line?
Regards
David
On Friday, July 1,
Pretty amazing Devan! Great regex! Thank you.
Regards,
David
On Friday, July 1, 2005, at 02:29 AM, Devan L wrote:
> One line solution.
> dict(re.findall(r"'(.+?)' \| '(.+?)'(?:\s\||$)",yourtexthere))
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mai
"David Pratt" wrote:
> Wow Robert that is incredible python magic! I am trying to figure out
> what this is doing since my attempts were regex and some long string
> splitting and collection.
>
> Ok. So it is a list comprehension and then collection. What is zip
> doing in the second line?
>
> R
"Terry Hancock" wrote:
> Chinook wrote:
> > >>> ta = [5, 15, 12, 10, 9]
> > >>> for i in range(len(ta)):
> > ... if ta[i] >= 10:
> > ... ta[i] -= 10
> > ... else:
> > ... ta[i] += 10
>
> It's not exactly the same in that it doesn't change values in
> place, but this is similar if you
Thanks George! You guys are great! I am always learning. Python is
awesome!!
On Friday, July 1, 2005, at 02:33 AM, George Sakkis wrote:
> "Robert Kern" wrote:
>
>> Ignore the last message.
>>
>> translations = [x.strip(" '") for x in line.split('|')]
>> d = dict(zip(translations[::2], transla
"David Pratt"
> Thanks George! You guys are great! I am always learning. Python is
> awesome!!
Yeap, that was the reaction of many/most of us when we stumbled upon
python. Welcome aboard !
George
--
http://mail.python.org/mailman/listinfo/python-list
I am a java programmer and I want to learn Python Please help me.
--
http://mail.python.org/mailman/listinfo/python-list
"[EMAIL PROTECTED]" wrote:
> I am a java programmer and I want to learn Python Please help me.
Google Is Your Friend:
http://www.razorvine.net/python/PythonForJavaProgrammers
http://www.ferg.org/projects/python_java_side-by-side.html
George
--
http://mail.python.org/mailman/listinfo/python-li
201 - 228 of 228 matches
Mail list logo