Thank you, Wayne! This helps a lot.
On Nov 4, 2011, at 5:38 PM, Wayne Werner wrote:
> On Fri, Nov 4, 2011 at 4:21 PM, Max S. wrote:
> Is it possible to create a variable with a string held by another variable in
> Python? For example,
>
> >>> var_name = input("Variable name: ")
> (input: 'var
Thanks Steven.
On Nov 4, 2011, at 6:45 PM, Steven D'Aprano wrote:
> Max S. wrote:
>> Is it possible to create a variable with a string held by another variable
>> in Python? For example,
>
> Yes, but you shouldn't do it. Seriously. Don't do this, you will regret it.
>
>var_name = input("Var
On 11/04/2011 07:00 PM, Steven D'Aprano wrote:
Dinara Vakhitova wrote:
Hello,
I need to find the words in a corpus, which letters are in the
alphabetical
order ("almost", "my" etc.)
Quoting Jamie Zawinski:
Some people, when confronted with a problem, think "I know, I'll
use regular
Dinara, Steven,
On 4 November 2011 23:29, Steven D'Aprano wrote:
> Is this homework? You should have said so.
>
Inded he should've...
> I don't understand questions like this. Do carpenters ask their
> apprentices to cut a piece of wood with a hammer? Do apprentice chefs get
> told to dice ca
Prasad, Ramit wrote:
m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line)
That is the expression I would suggest, except it is still more
efficient to use a compiled regular expression like the original
version.
Not necessarily. The Python regex module caches recently used regex
strings, avoiding re
Dinara Vakhitova wrote:
Sorry, I didn´t know that I couldn´t ask questions about the homework...
You're welcome to ask questions about homework or school projects, but
most of the people here believe that ethically the student should do the
homework, not the tutor :)
So if something looks
On 5 November 2011 00:38, Dinara Vakhitova wrote:
> Sorry, I didn´t know that I couldn´t ask questions about the homework...
This list is meant to help with learning python and not to do
homework assignments. So if you get stuck with something yes you can
post it but be open about it and show wh
Sorry, I didn´t know that I couldn´t ask questions about the homework...
I wanted to do it recursively, like this:
def check_abc(string):
string = string.lower()
check_pair = re.compile("([a-z])[\1-z]")
if check_pair.match(string):
if check_abc(string[1:]):
return T
Dinara Vakhitova wrote:
Thank you for your answer, Steven.
Of course it would have been easier to write this function,
but unfortunately my task is to do it with a regular expression :(
Is this homework? You should have said so.
I don't understand questions like this. Do carpenters ask their
Thank you for your answer, Steven.
Of course it would have been easier to write this function,
but unfortunately my task is to do it with a regular expression :(
D.
2011/11/5 Steven D'Aprano
> Dinara Vakhitova wrote:
>
>> Hello,
>>
>> I need to find the words in a corpus, which letters are in
Dinara Vakhitova wrote:
Hello,
I need to find the words in a corpus, which letters are in the alphabetical
order ("almost", "my" etc.)
Quoting Jamie Zawinski:
Some people, when confronted with a problem, think "I know, I'll
use regular expressions." Now they have two problems.
Now yo
Max S. wrote:
Is it possible to create a variable with a string held by another variable
in Python? For example,
Yes, but you shouldn't do it. Seriously. Don't do this, you will regret it.
var_name = input("Variable name? ") # use raw_input in Python 2
exec("%s = 4" % var_name)
Ins
Hello,
I need to find the words in a corpus, which letters are in the alphabetical
order ("almost", "my" etc.)
I started with matching two consecutive letters in a word, which are in
the alphabetical order, and tried to use this expression: ([a-z])[\1-z],
but it won't work, it's matching any seque
On Fri, 4 Nov 2011, Max S. wrote:
Is it possible to create a variable with a string held by another variable
in Python? For example,
It's possible, but in almost all cases where this comes up, the better
approach is to use a dictionary.___
Tutor ma
Max S. wrote:
> Is it possible to create a variable with a string held by another variable
> in Python? For example,
>
var_name = input("Variable name: ")
> (input: 'var')
var_name = 4
print(var)
> (output: 4)
>
> (Yeah, I know that if this gets typed into Python, it won't work.
On Fri, Nov 4, 2011 at 4:21 PM, Max S. wrote:
> Is it possible to create a variable with a string held by another variable
> in Python? For example,
>
> >>> var_name = input("Variable name: ")
> (input: 'var')
> >>> var_name = 4
> >>> print(var)
> (output: 4)
>
> (Yeah, I know that if this gets
>m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line)
That is the expression I would suggest, except it is still more efficient to
use a compiled regular expression like the original version.
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX
Is it possible to create a variable with a string held by another variable
in Python? For example,
>>> var_name = input("Variable name: ")
(input: 'var')
>>> var_name = 4
>>> print(var)
(output: 4)
(Yeah, I know that if this gets typed into Python, it won't work. It just
pseudocode.)
I'm on a
It seems that you are not opening the file properly. You could do
f = file('///Users/joebatt/Desktop/python3.txt','r')
or:
withfile('///Users/joebatt/Desktop/python3.txt','r') as f:
for line in f:
m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line)
if m:
print("Pattern found")
print(
On Fri, Nov 4, 2011 at 3:42 PM, Joe Batt wrote:
> Hi all,
> Still trying with Python and programming in general….
>
> I am trying to get a grip with re. I am writing a program to open a text
> file and scan it for exactly 3 uppercase letters in a row followed by a
> lowercase followed by exactly
Hi all,Still trying with Python and programming in general….
I am trying to get a grip with re. I am writing a program to open a text file
and scan it for exactly 3 uppercase letters in a row followed by a lowercase
followed by exactly 3 uppercase letters. ( i.e. oooXXXoXXXooo )If possible
co
No, I mean what you said. My class has one or two class-level:
class myClass:
x=5
and a lot of instance-level:
def __init__(self, p1, p2...):
self.__dict__.update(locals())
On 11/4/11, Steven D'Aprano wrote:
> Alex Hall wrote:
>> I'm sorry, I misspoke (well, mistyped anyway). I have a co
lina wrote:
> On Wed, Nov 2, 2011 at 12:14 AM, Peter Otten <__pete...@web.de> wrote:
>> lina wrote:
>>
sorted(new_dictionary.items())
>>>
>>> Thanks, it works, but there is still a minor question,
>>>
>>> can I sort based on the general numerical value?
>>>
>>> namely not:
>>> :
>>> :
>>> 83I
23 matches
Mail list logo